Add cardPublicId to card webhook payloads (#490)
* Add cardPublicId to card webhook payloads * fix: include card publicId in webhook payloads Add data.card.publicId to webhook payloads while keeping data.card.id for compatibility, and update card/webhook call sites and tests so webhook consumers can reliably use public IDs.
This commit is contained in:
@@ -187,6 +187,7 @@ export const cardRouter = createTRPCRouter({
|
|||||||
"card.created",
|
"card.created",
|
||||||
{
|
{
|
||||||
id: String(newCard.id),
|
id: String(newCard.id),
|
||||||
|
publicId: newCard.publicId,
|
||||||
title: input.title,
|
title: input.title,
|
||||||
description: input.description,
|
description: input.description,
|
||||||
dueDate: input.dueDate ?? null,
|
dueDate: input.dueDate ?? null,
|
||||||
@@ -1070,6 +1071,7 @@ export const cardRouter = createTRPCRouter({
|
|||||||
movedToNewList ? "card.moved" : "card.updated",
|
movedToNewList ? "card.moved" : "card.updated",
|
||||||
{
|
{
|
||||||
id: String(result.id),
|
id: String(result.id),
|
||||||
|
publicId: result.publicId,
|
||||||
title: result.title,
|
title: result.title,
|
||||||
description: result.description,
|
description: result.description,
|
||||||
dueDate: result.dueDate,
|
dueDate: result.dueDate,
|
||||||
@@ -1165,6 +1167,7 @@ export const cardRouter = createTRPCRouter({
|
|||||||
"card.deleted",
|
"card.deleted",
|
||||||
{
|
{
|
||||||
id: String(fullCard.id),
|
id: String(fullCard.id),
|
||||||
|
publicId: fullCard.publicId,
|
||||||
title: fullCard.title,
|
title: fullCard.title,
|
||||||
description: fullCard.description,
|
description: fullCard.description,
|
||||||
dueDate: fullCard.dueDate,
|
dueDate: fullCard.dueDate,
|
||||||
|
|||||||
@@ -334,6 +334,7 @@ export const webhookRouter = createTRPCRouter({
|
|||||||
|
|
||||||
const testPayload = createCardWebhookPayload("card.created", {
|
const testPayload = createCardWebhookPayload("card.created", {
|
||||||
id: "test-card-id",
|
id: "test-card-id",
|
||||||
|
publicId: "test-card-public-id",
|
||||||
title: "Test Card",
|
title: "Test Card",
|
||||||
description: "This is a test webhook payload",
|
description: "This is a test webhook payload",
|
||||||
dueDate: null,
|
dueDate: null,
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ describe("webhook utilities", () => {
|
|||||||
"card.created",
|
"card.created",
|
||||||
{
|
{
|
||||||
id: "card-123",
|
id: "card-123",
|
||||||
|
publicId: "card-pub-123",
|
||||||
title: "Test Card",
|
title: "Test Card",
|
||||||
listId: "list-456",
|
listId: "list-456",
|
||||||
},
|
},
|
||||||
@@ -55,12 +56,14 @@ describe("webhook utilities", () => {
|
|||||||
expect(payload.timestamp).toBe("2024-01-15T12:00:00.000Z");
|
expect(payload.timestamp).toBe("2024-01-15T12:00:00.000Z");
|
||||||
expect(payload.data.card).toEqual({
|
expect(payload.data.card).toEqual({
|
||||||
id: "card-123",
|
id: "card-123",
|
||||||
|
publicId: "card-pub-123",
|
||||||
title: "Test Card",
|
title: "Test Card",
|
||||||
description: undefined,
|
description: undefined,
|
||||||
dueDate: null,
|
dueDate: null,
|
||||||
listId: "list-456",
|
listId: "list-456",
|
||||||
boardId: "board-789",
|
boardId: "board-789",
|
||||||
});
|
});
|
||||||
|
expect(payload.data.card.publicId).toBe("card-pub-123");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("includes optional card fields when provided", () => {
|
it("includes optional card fields when provided", () => {
|
||||||
@@ -69,6 +72,7 @@ describe("webhook utilities", () => {
|
|||||||
"card.updated",
|
"card.updated",
|
||||||
{
|
{
|
||||||
id: "card-123",
|
id: "card-123",
|
||||||
|
publicId: "card-pub-123",
|
||||||
title: "Test Card",
|
title: "Test Card",
|
||||||
description: "A description",
|
description: "A description",
|
||||||
dueDate,
|
dueDate,
|
||||||
@@ -88,6 +92,7 @@ describe("webhook utilities", () => {
|
|||||||
"card.created",
|
"card.created",
|
||||||
{
|
{
|
||||||
id: "card-123",
|
id: "card-123",
|
||||||
|
publicId: "card-pub-123",
|
||||||
title: "Test Card",
|
title: "Test Card",
|
||||||
listId: "list-456",
|
listId: "list-456",
|
||||||
},
|
},
|
||||||
@@ -108,6 +113,7 @@ describe("webhook utilities", () => {
|
|||||||
"card.created",
|
"card.created",
|
||||||
{
|
{
|
||||||
id: "card-123",
|
id: "card-123",
|
||||||
|
publicId: "card-pub-123",
|
||||||
title: "Test Card",
|
title: "Test Card",
|
||||||
listId: "list-456",
|
listId: "list-456",
|
||||||
},
|
},
|
||||||
@@ -128,6 +134,7 @@ describe("webhook utilities", () => {
|
|||||||
"card.created",
|
"card.created",
|
||||||
{
|
{
|
||||||
id: "card-123",
|
id: "card-123",
|
||||||
|
publicId: "card-pub-123",
|
||||||
title: "Test Card",
|
title: "Test Card",
|
||||||
listId: "list-456",
|
listId: "list-456",
|
||||||
},
|
},
|
||||||
@@ -151,6 +158,7 @@ describe("webhook utilities", () => {
|
|||||||
"card.updated",
|
"card.updated",
|
||||||
{
|
{
|
||||||
id: "card-123",
|
id: "card-123",
|
||||||
|
publicId: "card-pub-123",
|
||||||
title: "Updated Title",
|
title: "Updated Title",
|
||||||
listId: "list-456",
|
listId: "list-456",
|
||||||
},
|
},
|
||||||
@@ -172,6 +180,7 @@ describe("webhook utilities", () => {
|
|||||||
"card.moved",
|
"card.moved",
|
||||||
{
|
{
|
||||||
id: "card-123",
|
id: "card-123",
|
||||||
|
publicId: "card-pub-123",
|
||||||
title: "Moved Card",
|
title: "Moved Card",
|
||||||
listId: "list-public-done",
|
listId: "list-public-done",
|
||||||
},
|
},
|
||||||
@@ -212,6 +221,7 @@ describe("webhook utilities", () => {
|
|||||||
data: {
|
data: {
|
||||||
card: {
|
card: {
|
||||||
id: "card-123",
|
id: "card-123",
|
||||||
|
publicId: "card-pub-123",
|
||||||
title: "Test Card",
|
title: "Test Card",
|
||||||
listId: "list-456",
|
listId: "list-456",
|
||||||
boardId: "board-789",
|
boardId: "board-789",
|
||||||
@@ -408,6 +418,7 @@ describe("webhook utilities", () => {
|
|||||||
data: {
|
data: {
|
||||||
card: {
|
card: {
|
||||||
id: "card-123",
|
id: "card-123",
|
||||||
|
publicId: "card-pub-123",
|
||||||
title: "Test Card",
|
title: "Test Card",
|
||||||
listId: "list-456",
|
listId: "list-456",
|
||||||
boardId: "board-789",
|
boardId: "board-789",
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export interface WebhookPayload {
|
|||||||
data: {
|
data: {
|
||||||
card: {
|
card: {
|
||||||
id: string;
|
id: string;
|
||||||
|
publicId: string;
|
||||||
title: string;
|
title: string;
|
||||||
description?: string | null;
|
description?: string | null;
|
||||||
dueDate?: string | null; // ISO string after JSON serialization
|
dueDate?: string | null; // ISO string after JSON serialization
|
||||||
@@ -221,6 +222,7 @@ export function createCardWebhookPayload(
|
|||||||
event: WebhookEventType,
|
event: WebhookEventType,
|
||||||
card: {
|
card: {
|
||||||
id: string;
|
id: string;
|
||||||
|
publicId: string;
|
||||||
title: string;
|
title: string;
|
||||||
description?: string | null;
|
description?: string | null;
|
||||||
dueDate?: Date | null;
|
dueDate?: Date | null;
|
||||||
@@ -243,6 +245,7 @@ export function createCardWebhookPayload(
|
|||||||
data: {
|
data: {
|
||||||
card: {
|
card: {
|
||||||
id: card.id,
|
id: card.id,
|
||||||
|
publicId: card.publicId,
|
||||||
title: card.title,
|
title: card.title,
|
||||||
description: card.description,
|
description: card.description,
|
||||||
dueDate: card.dueDate?.toISOString() ?? null,
|
dueDate: card.dueDate?.toISOString() ?? null,
|
||||||
|
|||||||
Reference in New Issue
Block a user