@webiny/api-scheduler-aws 6.5.4-beta.0 → 6.5.4-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/createEventHandler.js.map +1 -1
- package/package.json +18 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createEventHandler.js","sources":["../src/createEventHandler.ts"],"sourcesContent":["import { registry } from \"@webiny/handler-aws/registry.js\";\nimport type { HandlerFactoryParams } from \"@webiny/handler-aws/types.js\";\nimport { createSourceHandler } from \"@webiny/handler-aws/sourceHandler.js\";\nimport { createEventHandler, createHandler } from \"@webiny/handler-aws/raw/index.js\";\nimport { SCHEDULED_ACTION_EVENT_IDENTIFIER } from \"@webiny/api-scheduler/constants.js\";\nimport { ExecuteScheduledActionUseCase } from \"@webiny/api-scheduler/features/ExecuteScheduledAction/index.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { GetTenantByIdUseCase } from \"@webiny/api-core/exports/api/tenancy.js\";\n\nexport interface IScheduledActionEventPayload {\n namespace: string;\n id: string;\n scheduleFor: string;\n tenant: string;\n}\n\nexport interface IScheduledActionEvent {\n [SCHEDULED_ACTION_EVENT_IDENTIFIER]: IScheduledActionEventPayload;\n}\n\nexport interface HandlerParams extends HandlerFactoryParams {\n debug?: boolean;\n}\n\nconst canHandle = (event: Partial<IScheduledActionEvent>): boolean => {\n if (typeof event?.hasOwnProperty !== \"function\") {\n return false;\n } else if (!event.hasOwnProperty(SCHEDULED_ACTION_EVENT_IDENTIFIER)) {\n return false;\n }\n\n const value = event[SCHEDULED_ACTION_EVENT_IDENTIFIER];\n return !!(value?.id && value?.scheduleFor);\n};\n\nconst handler = createSourceHandler<IScheduledActionEvent, HandlerParams>({\n name: \"handler-aws-event-bridge-scheduled-cms-action-event\",\n canUse: canHandle,\n handle: async ({ params, event, context }) => {\n return createHandler(params)(event, context);\n }\n});\n\nregistry.register(handler);\n\nexport const createScheduledActionEventHandler = () => {\n return createEventHandler<IScheduledActionEvent>({\n canHandle,\n handle: async params => {\n const { payload, context } = params;\n const input = payload[SCHEDULED_ACTION_EVENT_IDENTIFIER];\n\n const tenantContext = context.container.resolve(TenantContext);\n /**\n * Use default tenant if tenant is not provided in the payload.\n * This allows backward compatibility with existing scheduled actions that do not have tenant information in their payload.\n */\n if (!input.tenant) {\n input.tenant = tenantContext.getTenant().id;\n }\n const getTenantByIdUseCase = context.container.resolve(GetTenantByIdUseCase);\n const tenantResult = await getTenantByIdUseCase.execute(input.tenant);\n if (tenantResult.isFail()) {\n throw tenantResult.error;\n }\n const tenant = tenantResult.value;\n\n return tenantContext.withTenant(tenant, async () => {\n const executeScheduledAction = context.container.resolve(\n ExecuteScheduledActionUseCase\n );\n const result = await executeScheduledAction.execute(input);\n\n if (result.isFail()) {\n const error = result.error;\n console.error(error.code, error.message);\n throw error;\n }\n return {\n success: true\n };\n });\n }\n });\n};\n"],"names":["canHandle","event","SCHEDULED_ACTION_EVENT_IDENTIFIER","value","handler","createSourceHandler","params","context","createHandler","registry","createScheduledActionEventHandler","createEventHandler","payload","input","tenantContext","TenantContext","getTenantByIdUseCase","GetTenantByIdUseCase","tenantResult","tenant","executeScheduledAction","ExecuteScheduledActionUseCase","result","error","console"],"mappings":";;;;;;;AAwBA,MAAMA,YAAY,CAACC;IACf,IAAI,AAAiC,cAAjC,OAAOA,OAAO,gBACd,OAAO;SACJ,IAAI,CAACA,MAAM,cAAc,CAACC,oCAC7B,OAAO;IAGX,MAAMC,QAAQF,KAAK,CAACC,kCAAkC;IACtD,OAAO,CAAC,CAAEC,CAAAA,OAAO,MAAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"createEventHandler.js","sources":["../src/createEventHandler.ts"],"sourcesContent":["import { registry } from \"@webiny/handler-aws/registry.js\";\nimport type { HandlerFactoryParams } from \"@webiny/handler-aws/types.js\";\nimport { createSourceHandler } from \"@webiny/handler-aws/sourceHandler.js\";\nimport { createEventHandler, createHandler } from \"@webiny/handler-aws/raw/index.js\";\nimport { SCHEDULED_ACTION_EVENT_IDENTIFIER } from \"@webiny/api-scheduler/constants.js\";\nimport { ExecuteScheduledActionUseCase } from \"@webiny/api-scheduler/features/ExecuteScheduledAction/index.js\";\nimport { TenantContext } from \"@webiny/api-core/features/tenancy/TenantContext/index.js\";\nimport { GetTenantByIdUseCase } from \"@webiny/api-core/exports/api/tenancy.js\";\n\nexport interface IScheduledActionEventPayload {\n namespace: string;\n id: string;\n scheduleFor: string;\n tenant: string;\n}\n\nexport interface IScheduledActionEvent {\n [SCHEDULED_ACTION_EVENT_IDENTIFIER]: IScheduledActionEventPayload;\n}\n\nexport interface HandlerParams extends HandlerFactoryParams {\n debug?: boolean;\n}\n\nconst canHandle = (event: Partial<IScheduledActionEvent>): boolean => {\n if (typeof event?.hasOwnProperty !== \"function\") {\n return false;\n } else if (!event.hasOwnProperty(SCHEDULED_ACTION_EVENT_IDENTIFIER)) {\n return false;\n }\n\n const value = event[SCHEDULED_ACTION_EVENT_IDENTIFIER];\n return !!(value?.id && value?.scheduleFor);\n};\n\nconst handler = createSourceHandler<IScheduledActionEvent, HandlerParams>({\n name: \"handler-aws-event-bridge-scheduled-cms-action-event\",\n canUse: canHandle,\n handle: async ({ params, event, context }) => {\n return createHandler(params)(event, context);\n }\n});\n\nregistry.register(handler);\n\nexport const createScheduledActionEventHandler = () => {\n return createEventHandler<IScheduledActionEvent>({\n canHandle,\n handle: async params => {\n const { payload, context } = params;\n const input = payload[SCHEDULED_ACTION_EVENT_IDENTIFIER];\n\n const tenantContext = context.container.resolve(TenantContext);\n /**\n * Use default tenant if tenant is not provided in the payload.\n * This allows backward compatibility with existing scheduled actions that do not have tenant information in their payload.\n */\n if (!input.tenant) {\n input.tenant = tenantContext.getTenant().id;\n }\n const getTenantByIdUseCase = context.container.resolve(GetTenantByIdUseCase);\n const tenantResult = await getTenantByIdUseCase.execute(input.tenant);\n if (tenantResult.isFail()) {\n throw tenantResult.error;\n }\n const tenant = tenantResult.value;\n\n return tenantContext.withTenant(tenant, async () => {\n const executeScheduledAction = context.container.resolve(\n ExecuteScheduledActionUseCase\n );\n const result = await executeScheduledAction.execute(input);\n\n if (result.isFail()) {\n const error = result.error;\n console.error(error.code, error.message);\n throw error;\n }\n return {\n success: true\n };\n });\n }\n });\n};\n"],"names":["canHandle","event","SCHEDULED_ACTION_EVENT_IDENTIFIER","value","handler","createSourceHandler","params","context","createHandler","registry","createScheduledActionEventHandler","createEventHandler","payload","input","tenantContext","TenantContext","getTenantByIdUseCase","GetTenantByIdUseCase","tenantResult","tenant","executeScheduledAction","ExecuteScheduledActionUseCase","result","error","console"],"mappings":";;;;;;;AAwBA,MAAMA,YAAY,CAACC;IACf,IAAI,AAAiC,cAAjC,OAAOA,OAAO,gBACd,OAAO;SACJ,IAAI,CAACA,MAAM,cAAc,CAACC,oCAC7B,OAAO;IAGX,MAAMC,QAAQF,KAAK,CAACC,kCAAkC;IACtD,OAAO,CAAC,CAAEC,CAAAA,OAAO,MAAMA,OAAO,WAAW;AAC7C;AAEA,MAAMC,UAAUC,oBAA0D;IACtE,MAAM;IACN,QAAQL;IACR,QAAQ,OAAO,EAAEM,MAAM,EAAEL,KAAK,EAAEM,OAAO,EAAE,GAC9BC,cAAcF,QAAQL,OAAOM;AAE5C;AAEAE,SAAS,QAAQ,CAACL;AAEX,MAAMM,oCAAoC,IACtCC,mBAA0C;QAC7CX;QACA,QAAQ,OAAMM;YACV,MAAM,EAAEM,OAAO,EAAEL,OAAO,EAAE,GAAGD;YAC7B,MAAMO,QAAQD,OAAO,CAACV,kCAAkC;YAExD,MAAMY,gBAAgBP,QAAQ,SAAS,CAAC,OAAO,CAACQ;YAKhD,IAAI,CAACF,MAAM,MAAM,EACbA,MAAM,MAAM,GAAGC,cAAc,SAAS,GAAG,EAAE;YAE/C,MAAME,uBAAuBT,QAAQ,SAAS,CAAC,OAAO,CAACU;YACvD,MAAMC,eAAe,MAAMF,qBAAqB,OAAO,CAACH,MAAM,MAAM;YACpE,IAAIK,aAAa,MAAM,IACnB,MAAMA,aAAa,KAAK;YAE5B,MAAMC,SAASD,aAAa,KAAK;YAEjC,OAAOJ,cAAc,UAAU,CAACK,QAAQ;gBACpC,MAAMC,yBAAyBb,QAAQ,SAAS,CAAC,OAAO,CACpDc;gBAEJ,MAAMC,SAAS,MAAMF,uBAAuB,OAAO,CAACP;gBAEpD,IAAIS,OAAO,MAAM,IAAI;oBACjB,MAAMC,QAAQD,OAAO,KAAK;oBAC1BE,QAAQ,KAAK,CAACD,MAAM,IAAI,EAAEA,MAAM,OAAO;oBACvC,MAAMA;gBACV;gBACA,OAAO;oBACH,SAAS;gBACb;YACJ;QACJ;IACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-scheduler-aws",
|
|
3
|
-
"version": "6.5.4-beta.
|
|
3
|
+
"version": "6.5.4-beta.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -18,28 +18,28 @@
|
|
|
18
18
|
"description": "AWS EventBridge implementation for the Webiny action scheduler.",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@webiny/api": "6.5.4-beta.
|
|
22
|
-
"@webiny/api-core": "6.5.4-beta.
|
|
23
|
-
"@webiny/api-headless-cms": "6.5.4-beta.
|
|
24
|
-
"@webiny/api-scheduler": "6.5.4-beta.
|
|
25
|
-
"@webiny/aws-sdk": "6.5.4-beta.
|
|
26
|
-
"@webiny/error": "6.5.4-beta.
|
|
27
|
-
"@webiny/handler": "6.5.4-beta.
|
|
28
|
-
"@webiny/handler-aws": "6.5.4-beta.
|
|
29
|
-
"@webiny/plugins": "6.5.4-beta.
|
|
30
|
-
"@webiny/utils": "6.5.4-beta.
|
|
21
|
+
"@webiny/api": "6.5.4-beta.2",
|
|
22
|
+
"@webiny/api-core": "6.5.4-beta.2",
|
|
23
|
+
"@webiny/api-headless-cms": "6.5.4-beta.2",
|
|
24
|
+
"@webiny/api-scheduler": "6.5.4-beta.2",
|
|
25
|
+
"@webiny/aws-sdk": "6.5.4-beta.2",
|
|
26
|
+
"@webiny/error": "6.5.4-beta.2",
|
|
27
|
+
"@webiny/handler": "6.5.4-beta.2",
|
|
28
|
+
"@webiny/handler-aws": "6.5.4-beta.2",
|
|
29
|
+
"@webiny/plugins": "6.5.4-beta.2",
|
|
30
|
+
"@webiny/utils": "6.5.4-beta.2",
|
|
31
31
|
"zod": "4.6.7"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@webiny/build-tools": "6.5.4-beta.
|
|
35
|
-
"@webiny/feature": "6.5.4-beta.
|
|
36
|
-
"@webiny/handler-graphql": "6.5.4-beta.
|
|
37
|
-
"@webiny/project-utils": "6.5.4-beta.
|
|
38
|
-
"@webiny/testing": "6.5.4-beta.
|
|
39
|
-
"@webiny/wcp": "6.5.4-beta.
|
|
34
|
+
"@webiny/build-tools": "6.5.4-beta.2",
|
|
35
|
+
"@webiny/feature": "6.5.4-beta.2",
|
|
36
|
+
"@webiny/handler-graphql": "6.5.4-beta.2",
|
|
37
|
+
"@webiny/project-utils": "6.5.4-beta.2",
|
|
38
|
+
"@webiny/testing": "6.5.4-beta.2",
|
|
39
|
+
"@webiny/wcp": "6.5.4-beta.2",
|
|
40
40
|
"aws-sdk-client-mock": "4.1.0",
|
|
41
41
|
"typescript": "7.0.2",
|
|
42
|
-
"vitest": "5.1.
|
|
42
|
+
"vitest": "5.1.2"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|