From ba2d6fd73b7886977dcf07643c9dc20a7b4ffdf1 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 11 Jul 2024 17:16:14 +0200 Subject: [PATCH] Renames --- .../src/api/controllers/rowAction/crud.ts | 1 - .../src/api/routes/tests/rowAction.spec.ts | 20 +++++++++---------- packages/server/src/sdk/app/rowActions.ts | 4 ++-- packages/types/src/api/web/app/rowAction.ts | 7 ++----- 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/packages/server/src/api/controllers/rowAction/crud.ts b/packages/server/src/api/controllers/rowAction/crud.ts index 1b93228f59..b4e5612a7f 100644 --- a/packages/server/src/api/controllers/rowAction/crud.ts +++ b/packages/server/src/api/controllers/rowAction/crud.ts @@ -65,7 +65,6 @@ export async function update( ctx.body = { tableId: table._id!, - ...actions, } } diff --git a/packages/server/src/api/routes/tests/rowAction.spec.ts b/packages/server/src/api/routes/tests/rowAction.spec.ts index 7a3bc26068..a1c2973b66 100644 --- a/packages/server/src/api/routes/tests/rowAction.spec.ts +++ b/packages/server/src/api/routes/tests/rowAction.spec.ts @@ -95,8 +95,8 @@ describe("/rowsActions", () => { }) expect(res).toEqual({ + id: expect.stringMatching(/^row_action_\w+/), tableId: tableId, - actionId: expect.stringMatching(/^row_action_\w+/), ...rowAction, }) @@ -105,7 +105,7 @@ describe("/rowsActions", () => { _rev: expect.stringMatching(/^1-\w+/), tableId: tableId, actions: { - [res.actionId]: rowAction, + [res.id]: rowAction, }, createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), @@ -123,9 +123,9 @@ describe("/rowsActions", () => { _id: `ra_${tableId}`, _rev: expect.stringMatching(/^3-\w+/), actions: { - [responses[0].actionId]: rowActions[0], - [responses[1].actionId]: rowActions[1], - [responses[2].actionId]: rowActions[2], + [responses[0].id]: rowActions[0], + [responses[1].id]: rowActions[1], + [responses[2].id]: rowActions[2], }, tableId: tableId, createdAt: new Date().toISOString(), @@ -166,9 +166,9 @@ describe("/rowsActions", () => { expect.objectContaining({ tableId, actions: { - [rowActions[0].actionId]: expect.any(Object), - [rowActions[1].actionId]: expect.any(Object), - [rowActions[2].actionId]: expect.any(Object), + [rowActions[0].id]: expect.any(Object), + [rowActions[1].id]: expect.any(Object), + [rowActions[2].id]: expect.any(Object), }, }) ) @@ -207,8 +207,8 @@ describe("/rowsActions", () => { }) expect(res).toEqual({ + id: actionId, tableId, - actionId, ...actionData, name: updatedName, }) @@ -245,7 +245,7 @@ describe("/rowsActions", () => { const action = await createRowAction(tableId, createRowActionRequest()) await config.api.rowAction.update( otherTable._id!, - action.actionId, + action.id, createRowActionRequest(), { status: 400 } ) diff --git a/packages/server/src/sdk/app/rowActions.ts b/packages/server/src/sdk/app/rowActions.ts index 1d9ed92441..b6fce219c2 100644 --- a/packages/server/src/sdk/app/rowActions.ts +++ b/packages/server/src/sdk/app/rowActions.ts @@ -26,7 +26,7 @@ export async function create(tableId: string, rowAction: { name: string }) { await db.put(doc) return { - actionId: newId, + id: newId, ...rowAction, } } @@ -62,7 +62,7 @@ export async function update( await db.put(actionsDoc) return { - actionId: rowActionId, + id: rowActionId, ...rowAction, } } diff --git a/packages/types/src/api/web/app/rowAction.ts b/packages/types/src/api/web/app/rowAction.ts index 760ab697f8..72662fcb49 100644 --- a/packages/types/src/api/web/app/rowAction.ts +++ b/packages/types/src/api/web/app/rowAction.ts @@ -1,8 +1,8 @@ export interface CreateRowActionRequest extends RowActionData {} export interface RowActionResponse extends RowActionData { + id: string tableId: string - actionId: string } export interface RowActionsResponse { @@ -14,7 +14,4 @@ interface RowActionData { name: string } -export interface UpdateRowActionRequest { - id: string - name: string -} +export interface UpdateRowActionRequest extends RowActionData {}