From e4f79b236fe65718b7897c93b666a03e4a7ed562 Mon Sep 17 00:00:00 2001 From: Mohammad AbuAboud Date: Tue, 13 Aug 2024 00:43:51 +0200 Subject: [PATCH 1/4] feat: 0.30.0-rc.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0ab9b81bfb..a6229d6570 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "activepieces", "version": "0.29.1", - "rcVersion": "0.30.0-rc.4", + "rcVersion": "0.30.0-rc.5", "scripts": { "prepare": "husky install", "serve:frontend": "nx serve ui-core", From 9630a341648288bce66b6298767ef97111d1a432 Mon Sep 17 00:00:00 2001 From: Mohammad AbuAboud Date: Tue, 13 Aug 2024 00:45:15 +0200 Subject: [PATCH 2/4] revert: "feat: 0.30.0-rc.5" This reverts commit e4f79b236fe65718b7897c93b666a03e4a7ed562. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a6229d6570..0ab9b81bfb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "activepieces", "version": "0.29.1", - "rcVersion": "0.30.0-rc.5", + "rcVersion": "0.30.0-rc.4", "scripts": { "prepare": "husky install", "serve:frontend": "nx serve ui-core", From 50928d16306d72803aff681ada82e8c3fb366624 Mon Sep 17 00:00:00 2001 From: Mohammad AbuAboud Date: Tue, 13 Aug 2024 00:46:08 +0200 Subject: [PATCH 3/4] feat: 0.30.0-rc.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0ab9b81bfb..a6229d6570 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "activepieces", "version": "0.29.1", - "rcVersion": "0.30.0-rc.4", + "rcVersion": "0.30.0-rc.5", "scripts": { "prepare": "husky install", "serve:frontend": "nx serve ui-core", From 0d1f01e87076ca26fbf27dcc7e5ac0d66bcac517 Mon Sep 17 00:00:00 2001 From: Mohammad AbuAboud Date: Tue, 13 Aug 2024 01:00:30 +0200 Subject: [PATCH 4/4] fix: revert schema in app event controller --- .../app-event-routing.module.ts | 148 +++++++++--------- 1 file changed, 76 insertions(+), 72 deletions(-) diff --git a/packages/server/api/src/app/app-event-routing/app-event-routing.module.ts b/packages/server/api/src/app/app-event-routing/app-event-routing.module.ts index 1993541f52..e511ad9c0f 100644 --- a/packages/server/api/src/app/app-event-routing/app-event-routing.module.ts +++ b/packages/server/api/src/app/app-event-routing/app-event-routing.module.ts @@ -15,6 +15,7 @@ import { FastifyPluginAsyncTypebox, Type } from '@fastify/type-provider-typebox' import { StatusCodes } from 'http-status-codes' import { DEFAULT_PRIORITY } from '../workers/queue/queue-manager' import { appEventRoutingService } from './app-event-routing.service' +import { FastifyRequest } from 'fastify' const appWebhooks: Record = { slack, @@ -36,79 +37,82 @@ export const appEventRoutingModule: FastifyPluginAsyncTypebox = async (app) => { export const appEventRoutingController: FastifyPluginAsyncTypebox = async ( fastify, ) => { - fastify.all('/:pieceUrl', EventRoutingParam, async (request, requestReply) => { - const pieceUrl = request.params.pieceUrl - const payload = { - headers: request.headers as Record, - body: request.body, - rawBody: request.rawBody, - method: request.method, - queryParams: request.query as Record, - } - const piece = appWebhooks[pieceUrl] - if (isNil(piece)) { - throw new ActivepiecesError({ - code: ErrorCode.PIECE_NOT_FOUND, - params: { - pieceName: pieceUrl, - pieceVersion: 'latest', - message: 'Pieces is not found in app event routing', - }, - }) - } - const appName = pieceNames[pieceUrl] - assertNotNullOrUndefined(piece.events, 'Event is possible in this piece') - const { reply, event, identifierValue } = piece.events.parseAndReply({ payload }) - if (!isNil(reply)) { + fastify.all( + '/:pieceUrl', + { + config: { + rawBody: true, + allowedPrincipals: ALL_PRINCIPAL_TYPES, + }, + }, + async ( + request: FastifyRequest<{ + Body: unknown + Params: { + pieceUrl: string + } + }>, + requestReply, + ) => { + const pieceUrl = request.params.pieceUrl + const payload = { + headers: request.headers as Record, + body: request.body, + rawBody: request.rawBody, + method: request.method, + queryParams: request.query as Record, + } + const piece = appWebhooks[pieceUrl] + if (isNil(piece)) { + throw new ActivepiecesError({ + code: ErrorCode.PIECE_NOT_FOUND, + params: { + pieceName: pieceUrl, + pieceVersion: 'latest', + message: 'Pieces is not found in app event routing', + }, + }) + } + const appName = pieceNames[pieceUrl] + assertNotNullOrUndefined(piece.events, 'Event is possible in this piece') + const { reply, event, identifierValue } = piece.events.parseAndReply({ payload }) + if (!isNil(reply)) { + logger.info({ + reply, + piece: pieceUrl, + }, '[AppEventRoutingController#event] reply') + return requestReply.status(StatusCodes.OK).headers(reply?.headers ?? {}).send(reply?.body ?? {}) + } logger.info({ - reply, - piece: pieceUrl, - }, '[AppEventRoutingController#event] reply') - return requestReply.status(StatusCodes.OK).headers(reply?.headers ?? {}).send(reply?.body ?? {}) - } - logger.info({ - event, - identifierValue, - }, '[AppEventRoutingController#event] event') - if (isNil(event) || isNil(identifierValue)) { - return requestReply.status(StatusCodes.BAD_REQUEST).send({}) - } - const listeners = await appEventRoutingService.listListeners({ - appName, - event, - identifierValue, - }) - const eventsQueue = listeners.map(async (listener) => { - const requestId = apId() - return { - id: requestId, - type: JobType.WEBHOOK, - data: { - projectId: listener.projectId, - schemaVersion: LATEST_JOB_DATA_SCHEMA_VERSION, - requestId, - synchronousHandlerId: null, - payload, - flowId: listener.flowId, - simulate: false, - }, - priority: DEFAULT_PRIORITY, + event, + identifierValue, + }, '[AppEventRoutingController#event] event') + if (isNil(event) || isNil(identifierValue)) { + return requestReply.status(StatusCodes.BAD_REQUEST).send({}) } + const listeners = await appEventRoutingService.listListeners({ + appName, + event, + identifierValue, + }) + const eventsQueue = listeners.map(async (listener) => { + const requestId = apId() + return { + id: requestId, + type: JobType.WEBHOOK, + data: { + projectId: listener.projectId, + schemaVersion: LATEST_JOB_DATA_SCHEMA_VERSION, + requestId, + synchronousHandlerId: null, + payload, + flowId: listener.flowId, + simulate: false, + }, + priority: DEFAULT_PRIORITY, + } + }) + rejectedPromiseHandler(Promise.all(eventsQueue)) + return requestReply.status(StatusCodes.OK).send({}) }) - rejectedPromiseHandler(Promise.all(eventsQueue)) - return requestReply.status(StatusCodes.OK).send({}) - }) } - -const EventRoutingParam = { - config: { - rawBody: true, - allowedPrincipals: ALL_PRINCIPAL_TYPES, - }, - schema: { - params: Type.Object({ - pieceUrl: Type.String(), - }), - body: Type.Unknown(), - }, -} \ No newline at end of file