@webiny/api-sync-system 6.4.12-beta.5 → 6.5.0-beta.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-sync-system",
3
- "version": "6.4.12-beta.5",
3
+ "version": "6.5.0-beta.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -14,28 +14,30 @@
14
14
  "author": "Webiny LTD",
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "@webiny/api": "6.4.12-beta.5",
18
- "@webiny/aws-sdk": "6.4.12-beta.5",
19
- "@webiny/error": "6.4.12-beta.5",
20
- "@webiny/handler": "6.4.12-beta.5",
21
- "@webiny/handler-aws": "6.4.12-beta.5",
22
- "@webiny/plugins": "6.4.12-beta.5",
23
- "@webiny/utils": "6.4.12-beta.5",
17
+ "@webiny/api": "6.5.0-beta.0",
18
+ "@webiny/api-core": "6.5.0-beta.0",
19
+ "@webiny/aws-sdk": "6.5.0-beta.0",
20
+ "@webiny/error": "6.5.0-beta.0",
21
+ "@webiny/handler": "6.5.0-beta.0",
22
+ "@webiny/handler-aws": "6.5.0-beta.0",
23
+ "@webiny/plugins": "6.5.0-beta.0",
24
+ "@webiny/utils": "6.5.0-beta.0",
24
25
  "bytes": "3.1.2",
25
26
  "lodash": "4.18.1",
26
27
  "semver": "7.8.5",
27
- "zod": "4.6.5"
28
+ "zod": "4.4.3"
28
29
  },
29
30
  "devDependencies": {
30
- "@faker-js/faker": "10.6.0",
31
- "@types/lodash": "4.17.25",
32
- "@webiny/build-tools": "6.4.12-beta.5",
33
- "@webiny/project-utils": "6.4.12-beta.5",
31
+ "@faker-js/faker": "10.5.0",
32
+ "@types/lodash": "4.17.24",
33
+ "@webiny/api-core-ddb": "6.5.0-beta.0",
34
+ "@webiny/build-tools": "6.5.0-beta.0",
35
+ "@webiny/project-utils": "6.5.0-beta.0",
34
36
  "aws-sdk-client-mock": "4.1.0",
35
37
  "jest-dynalite": "3.6.1",
36
38
  "rimraf": "6.1.3",
37
- "typescript": "6.0.3",
38
- "vitest": "5.0.1"
39
+ "typescript": "7.0.2",
40
+ "vitest": "4.1.10"
39
41
  },
40
42
  "publishConfig": {
41
43
  "access": "public"
@@ -14,14 +14,14 @@ export declare const createBodyValidation: () => zod.ZodObject<{
14
14
  SK: zod.ZodString;
15
15
  tableName: zod.ZodString;
16
16
  tableType: zod.ZodPipe<zod.ZodEnum<{
17
- regular: "regular";
17
+ log: "log";
18
18
  opensearch: "opensearch";
19
+ regular: "regular";
19
20
  unknown: "unknown";
20
- log: "log";
21
- }>, zod.ZodTransform<import("../../../types.js").DynamoDBTableType, "regular" | "opensearch" | "unknown" | "log">>;
21
+ }>, zod.ZodTransform<import("../../../types.js").DynamoDBTableType, "log" | "opensearch" | "regular" | "unknown">>;
22
22
  command: zod.ZodEnum<{
23
- put: "put";
24
23
  delete: "delete";
24
+ put: "put";
25
25
  update: "update";
26
26
  }>;
27
27
  }, zod.core.$strip>>, zod.ZodTransform<import("@webiny/api/types.js").NonEmptyArray<import("../abstractions/ResolverRecord.js").IResolverRecordBodyItem>, {
@@ -29,7 +29,7 @@ export declare const createBodyValidation: () => zod.ZodObject<{
29
29
  SK: string;
30
30
  tableName: string;
31
31
  tableType: import("../../../types.js").DynamoDBTableType;
32
- command: "put" | "delete" | "update";
32
+ command: "delete" | "put" | "update";
33
33
  }[]>>;
34
34
  source: zod.ZodObject<{
35
35
  name: zod.ZodString;
@@ -8,14 +8,14 @@ export declare const createDetailValidation: () => zod.ZodObject<{
8
8
  SK: zod.ZodString;
9
9
  tableName: zod.ZodString;
10
10
  tableType: zod.ZodPipe<zod.ZodEnum<{
11
- regular: "regular";
11
+ log: "log";
12
12
  opensearch: "opensearch";
13
+ regular: "regular";
13
14
  unknown: "unknown";
14
- log: "log";
15
- }>, zod.ZodTransform<DynamoDBTableType, "regular" | "opensearch" | "unknown" | "log">>;
15
+ }>, zod.ZodTransform<DynamoDBTableType, "log" | "opensearch" | "regular" | "unknown">>;
16
16
  command: zod.ZodEnum<{
17
- put: "put";
18
17
  delete: "delete";
18
+ put: "put";
19
19
  update: "update";
20
20
  }>;
21
21
  }, zod.core.$strip>>, zod.ZodTransform<NonEmptyArray<IResolverRecordBodyItem>, {
@@ -23,7 +23,7 @@ export declare const createDetailValidation: () => zod.ZodObject<{
23
23
  SK: string;
24
24
  tableName: string;
25
25
  tableType: DynamoDBTableType;
26
- command: "put" | "delete" | "update";
26
+ command: "delete" | "put" | "update";
27
27
  }[]>>;
28
28
  source: zod.ZodObject<{
29
29
  name: zod.ZodString;
@@ -17,14 +17,14 @@ export declare const createEventValidation: () => zod.ZodArray<zod.ZodObject<{
17
17
  SK: zod.ZodString;
18
18
  tableName: zod.ZodString;
19
19
  tableType: zod.ZodPipe<zod.ZodEnum<{
20
- regular: "regular";
20
+ log: "log";
21
21
  opensearch: "opensearch";
22
+ regular: "regular";
22
23
  unknown: "unknown";
23
- log: "log";
24
- }>, zod.ZodTransform<import("../../../types").DynamoDBTableType, "regular" | "opensearch" | "unknown" | "log">>;
24
+ }>, zod.ZodTransform<import("../../../types").DynamoDBTableType, "log" | "opensearch" | "regular" | "unknown">>;
25
25
  command: zod.ZodEnum<{
26
- put: "put";
27
26
  delete: "delete";
27
+ put: "put";
28
28
  update: "update";
29
29
  }>;
30
30
  }, zod.core.$strip>>, zod.ZodTransform<import("@webiny/api/types").NonEmptyArray<import("../abstractions/ResolverRecord").IResolverRecordBodyItem>, {
@@ -32,7 +32,7 @@ export declare const createEventValidation: () => zod.ZodArray<zod.ZodObject<{
32
32
  SK: string;
33
33
  tableName: string;
34
34
  tableType: import("../../../types").DynamoDBTableType;
35
- command: "put" | "delete" | "update";
35
+ command: "delete" | "put" | "update";
36
36
  }[]>>;
37
37
  source: zod.ZodObject<{
38
38
  name: zod.ZodString;
@@ -1,9 +1,9 @@
1
1
  const shouldBeHandled = (params)=>{
2
2
  const { item, table } = params;
3
3
  if ("regular" !== table.type) return false;
4
- else if ("L" !== item.SK) return false;
5
- else if ("fmFile" !== item.modelId) return false;
6
- else if (!item.values) return false;
4
+ if ("L" !== item.SK) return false;
5
+ if ("fmFile" !== item.modelId) return false;
6
+ if (!item.values) return false;
7
7
  const key = item.values["text@key"] || item.values["key"];
8
8
  if (!key) return false;
9
9
  return "string" == typeof key && key.length > 2;
@@ -1 +1 @@
1
- {"version":3,"file":"resolver/recordTypes/fileManager/shouldBeHandled.js","sources":["../../../../src/resolver/recordTypes/fileManager/shouldBeHandled.ts"],"sourcesContent":["import type { IStorerAfterEachPluginCanHandleParams } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\n\nexport const shouldBeHandled = (params: IStorerAfterEachPluginCanHandleParams): boolean => {\n const { item, table } = params;\n if (table.type !== \"regular\") {\n return false;\n } else if (item.SK !== \"L\") {\n return false;\n }\n // TODO use constant from fileManager\n else if (item.modelId !== \"fmFile\") {\n return false;\n } else if (!item.values) {\n return false;\n }\n\n // @ts-expect-error\n const key = item.values[\"text@key\"] || item.values[\"key\"];\n if (!key) {\n return false;\n }\n /**\n * We can check length for being more than 2 characters,\n * because we know that the key is a string.\n */\n return typeof key === \"string\" && key.length > 2;\n};\n"],"names":["shouldBeHandled","params","item","table","key"],"mappings":"AAEO,MAAMA,kBAAkB,CAACC;IAC5B,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGF;IACxB,IAAIE,AAAe,cAAfA,MAAM,IAAI,EACV,OAAO;SACJ,IAAID,AAAY,QAAZA,KAAK,EAAE,EACd,OAAO;SAGN,IAAIA,AAAiB,aAAjBA,KAAK,OAAO,EACjB,OAAO;SACJ,IAAI,CAACA,KAAK,MAAM,EACnB,OAAO;IAIX,MAAME,MAAMF,KAAK,MAAM,CAAC,WAAW,IAAIA,KAAK,MAAM,CAAC,MAAM;IACzD,IAAI,CAACE,KACD,OAAO;IAMX,OAAO,AAAe,YAAf,OAAOA,OAAoBA,IAAI,MAAM,GAAG;AACnD"}
1
+ {"version":3,"file":"resolver/recordTypes/fileManager/shouldBeHandled.js","sources":["../../../../src/resolver/recordTypes/fileManager/shouldBeHandled.ts"],"sourcesContent":["import type { IStorerAfterEachPluginCanHandleParams } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\n\nexport const shouldBeHandled = (params: IStorerAfterEachPluginCanHandleParams): boolean => {\n const { item, table } = params;\n if (table.type !== \"regular\") {\n return false;\n } else if (item.SK !== \"L\") {\n return false;\n }\n // TODO use constant from fileManager\n else if (item.modelId !== \"fmFile\") {\n return false;\n } else if (!item.values) {\n return false;\n }\n\n // @ts-expect-error\n const key = item.values[\"text@key\"] || item.values[\"key\"];\n if (!key) {\n return false;\n }\n /**\n * We can check length for being more than 2 characters,\n * because we know that the key is a string.\n */\n return typeof key === \"string\" && key.length > 2;\n};\n"],"names":["shouldBeHandled","params","item","table","key"],"mappings":"AAEO,MAAMA,kBAAkB,CAACC;IAC5B,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGF;IACxB,IAAIE,AAAe,cAAfA,MAAM,IAAI,EACV,OAAO;IACJ,IAAID,AAAY,QAAZA,KAAK,EAAE,EACd,OAAO;IAGN,IAAIA,AAAiB,aAAjBA,KAAK,OAAO,EACjB,OAAO;IACJ,IAAI,CAACA,KAAK,MAAM,EACnB,OAAO;IAIX,MAAME,MAAMF,KAAK,MAAM,CAAC,WAAW,IAAIA,KAAK,MAAM,CAAC,MAAM;IACzD,IAAI,CAACE,KACD,OAAO;IAMX,OAAO,AAAe,YAAf,OAAOA,OAAoBA,IAAI,MAAM,GAAG;AACnD"}
@@ -1,10 +1,10 @@
1
1
  const shouldBeHandled = (params)=>{
2
2
  const { item, table, source, target } = params;
3
3
  if ("regular" !== table.type) return false;
4
- else if (false === item.PK.includes("#ADMIN_USER#")) return false;
5
- else if ("A" !== item.SK) return false;
6
- else if ("adminUsers.user" !== item.TYPE) return false;
7
- else if (!source.services.cognitoUserPoolId || !target.services.cognitoUserPoolId) return false;
4
+ if (false === item.PK.includes("#ADMIN_USER#")) return false;
5
+ if ("A" !== item.SK) return false;
6
+ if ("adminUsers.user" !== item.TYPE) return false;
7
+ if (!source.services.cognitoUserPoolId || !target.services.cognitoUserPoolId) return false;
8
8
  else if (!item.data?.email) return false;
9
9
  return true;
10
10
  };
@@ -1 +1 @@
1
- {"version":3,"file":"resolver/recordTypes/users/shouldBeHandled.js","sources":["../../../../src/resolver/recordTypes/users/shouldBeHandled.ts"],"sourcesContent":["import type { IStorerAfterEachPluginCanHandleParams } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\n\nexport const shouldBeHandled = (params: IStorerAfterEachPluginCanHandleParams): boolean => {\n const { item, table, source, target } = params;\n if (table.type !== \"regular\") {\n return false;\n } else if (item.PK.includes(\"#ADMIN_USER#\") === false) {\n return false;\n } else if (item.SK !== \"A\") {\n return false;\n } else if (item.TYPE !== \"adminUsers.user\") {\n return false;\n } else if (!source.services.cognitoUserPoolId || !target.services.cognitoUserPoolId) {\n return false;\n }\n /**\n * TODO verify that email is always present in Cognito users.\n */\n // @ts-expect-error\n else if (!item.data?.email) {\n return false;\n }\n return true;\n};\n"],"names":["shouldBeHandled","params","item","table","source","target"],"mappings":"AAEO,MAAMA,kBAAkB,CAACC;IAC5B,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGJ;IACxC,IAAIE,AAAe,cAAfA,MAAM,IAAI,EACV,OAAO;SACJ,IAAID,AAAqC,UAArCA,KAAK,EAAE,CAAC,QAAQ,CAAC,iBACxB,OAAO;SACJ,IAAIA,AAAY,QAAZA,KAAK,EAAE,EACd,OAAO;SACJ,IAAIA,AAAc,sBAAdA,KAAK,IAAI,EAChB,OAAO;SACJ,IAAI,CAACE,OAAO,QAAQ,CAAC,iBAAiB,IAAI,CAACC,OAAO,QAAQ,CAAC,iBAAiB,EAC/E,OAAO;SAMN,IAAI,CAACH,KAAK,IAAI,EAAE,OACjB,OAAO;IAEX,OAAO;AACX"}
1
+ {"version":3,"file":"resolver/recordTypes/users/shouldBeHandled.js","sources":["../../../../src/resolver/recordTypes/users/shouldBeHandled.ts"],"sourcesContent":["import type { IStorerAfterEachPluginCanHandleParams } from \"~/resolver/plugins/StorerAfterEachPlugin.js\";\n\nexport const shouldBeHandled = (params: IStorerAfterEachPluginCanHandleParams): boolean => {\n const { item, table, source, target } = params;\n if (table.type !== \"regular\") {\n return false;\n } else if (item.PK.includes(\"#ADMIN_USER#\") === false) {\n return false;\n } else if (item.SK !== \"A\") {\n return false;\n } else if (item.TYPE !== \"adminUsers.user\") {\n return false;\n } else if (!source.services.cognitoUserPoolId || !target.services.cognitoUserPoolId) {\n return false;\n }\n /**\n * TODO verify that email is always present in Cognito users.\n */\n // @ts-expect-error\n else if (!item.data?.email) {\n return false;\n }\n return true;\n};\n"],"names":["shouldBeHandled","params","item","table","source","target"],"mappings":"AAEO,MAAMA,kBAAkB,CAACC;IAC5B,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAEC,MAAM,EAAEC,MAAM,EAAE,GAAGJ;IACxC,IAAIE,AAAe,cAAfA,MAAM,IAAI,EACV,OAAO;IACJ,IAAID,AAAqC,UAArCA,KAAK,EAAE,CAAC,QAAQ,CAAC,iBACxB,OAAO;IACJ,IAAIA,AAAY,QAAZA,KAAK,EAAE,EACd,OAAO;IACJ,IAAIA,AAAc,sBAAdA,KAAK,IAAI,EAChB,OAAO;IACJ,IAAI,CAACE,OAAO,QAAQ,CAAC,iBAAiB,IAAI,CAACC,OAAO,QAAQ,CAAC,iBAAiB,EAC/E,OAAO;SAMN,IAAI,CAACH,KAAK,IAAI,EAAE,OACjB,OAAO;IAEX,OAAO;AACX"}
@@ -11,7 +11,8 @@ const createSyncSystem = (params)=>{
11
11
  if (error) {
12
12
  console.error(error);
13
13
  return emptyResponse;
14
- } else if (!system) {
14
+ }
15
+ if (!system) {
15
16
  console.error("Sync System: No system provided. Sync System will not be attached.");
16
17
  return emptyResponse;
17
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"sync/createSyncSystem.js","sources":["../../src/sync/createSyncSystem.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types.js\";\nimport type { IGetEventBridgeCallable, ISystem } from \"./types.js\";\nimport { validateSystemInput } from \"./utils/validateSystemInput.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { PossiblyUndefinedProperties } from \"@webiny/api/types.js\";\nimport { createSyncSystemHandlerOnRequestPlugin } from \"./requestPlugin.js\";\nimport type { FilterOutRecordPlugin } from \"./plugins/FilterOutRecordPlugin.js\";\nimport { createDefaultFilterOutRecordPlugins } from \"./filter/createDefaultFilterOutRecordPlugins.js\";\n\nexport type IAllowedPlugins = FilterOutRecordPlugin;\n\nexport interface ICreateSyncSystemParams {\n getDocumentClient(): Pick<DynamoDBDocument, \"send\">;\n getEventBridgeClient: IGetEventBridgeCallable;\n system: PossiblyUndefinedProperties<Omit<ISystem, \"name\">>;\n plugins?: IAllowedPlugins[];\n}\n\nexport interface ICreateSyncSystemResponse {\n plugins(): Plugin[];\n}\n\nconst emptyResponse: ICreateSyncSystemResponse = {\n plugins(): Plugin[] {\n return [];\n }\n};\n\nexport const createSyncSystem = (params: ICreateSyncSystemParams): ICreateSyncSystemResponse => {\n const { system, error } = validateSystemInput(params.system);\n /**\n * We do not want to throw any errors. We will log them and just return a function which returns empty array as plugins.\n */\n if (error) {\n console.error(error);\n return emptyResponse;\n } else if (!system) {\n console.error(\"Sync System: No system provided. Sync System will not be attached.\");\n return emptyResponse;\n }\n\n return {\n plugins: () => {\n return [\n ...(params.plugins || []),\n ...createDefaultFilterOutRecordPlugins(),\n createSyncSystemHandlerOnRequestPlugin({\n getDocumentClient: params.getDocumentClient,\n getEventBridgeClient: params.getEventBridgeClient,\n system\n })\n ];\n }\n };\n};\n"],"names":["emptyResponse","createSyncSystem","params","system","error","validateSystemInput","console","createDefaultFilterOutRecordPlugins","createSyncSystemHandlerOnRequestPlugin"],"mappings":";;;AAsBA,MAAMA,gBAA2C;IAC7C;QACI,OAAO,EAAE;IACb;AACJ;AAEO,MAAMC,mBAAmB,CAACC;IAC7B,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGC,oBAAoBH,OAAO,MAAM;IAI3D,IAAIE,OAAO;QACPE,QAAQ,KAAK,CAACF;QACd,OAAOJ;IACX,OAAO,IAAI,CAACG,QAAQ;QAChBG,QAAQ,KAAK,CAAC;QACd,OAAON;IACX;IAEA,OAAO;QACH,SAAS,IACE;mBACCE,OAAO,OAAO,IAAI,EAAE;mBACrBK;gBACHC,uCAAuC;oBACnC,mBAAmBN,OAAO,iBAAiB;oBAC3C,sBAAsBA,OAAO,oBAAoB;oBACjDC;gBACJ;aACH;IAET;AACJ"}
1
+ {"version":3,"file":"sync/createSyncSystem.js","sources":["../../src/sync/createSyncSystem.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types.js\";\nimport type { IGetEventBridgeCallable, ISystem } from \"./types.js\";\nimport { validateSystemInput } from \"./utils/validateSystemInput.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { PossiblyUndefinedProperties } from \"@webiny/api/types.js\";\nimport { createSyncSystemHandlerOnRequestPlugin } from \"./requestPlugin.js\";\nimport type { FilterOutRecordPlugin } from \"./plugins/FilterOutRecordPlugin.js\";\nimport { createDefaultFilterOutRecordPlugins } from \"./filter/createDefaultFilterOutRecordPlugins.js\";\n\nexport type IAllowedPlugins = FilterOutRecordPlugin;\n\nexport interface ICreateSyncSystemParams {\n getDocumentClient(): Pick<DynamoDBDocument, \"send\">;\n getEventBridgeClient: IGetEventBridgeCallable;\n system: PossiblyUndefinedProperties<Omit<ISystem, \"name\">>;\n plugins?: IAllowedPlugins[];\n}\n\nexport interface ICreateSyncSystemResponse {\n plugins(): Plugin[];\n}\n\nconst emptyResponse: ICreateSyncSystemResponse = {\n plugins(): Plugin[] {\n return [];\n }\n};\n\nexport const createSyncSystem = (params: ICreateSyncSystemParams): ICreateSyncSystemResponse => {\n const { system, error } = validateSystemInput(params.system);\n /**\n * We do not want to throw any errors. We will log them and just return a function which returns empty array as plugins.\n */\n if (error) {\n console.error(error);\n return emptyResponse;\n } else if (!system) {\n console.error(\"Sync System: No system provided. Sync System will not be attached.\");\n return emptyResponse;\n }\n\n return {\n plugins: () => {\n return [\n ...(params.plugins || []),\n ...createDefaultFilterOutRecordPlugins(),\n createSyncSystemHandlerOnRequestPlugin({\n getDocumentClient: params.getDocumentClient,\n getEventBridgeClient: params.getEventBridgeClient,\n system\n })\n ];\n }\n };\n};\n"],"names":["emptyResponse","createSyncSystem","params","system","error","validateSystemInput","console","createDefaultFilterOutRecordPlugins","createSyncSystemHandlerOnRequestPlugin"],"mappings":";;;AAsBA,MAAMA,gBAA2C;IAC7C;QACI,OAAO,EAAE;IACb;AACJ;AAEO,MAAMC,mBAAmB,CAACC;IAC7B,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAE,GAAGC,oBAAoBH,OAAO,MAAM;IAI3D,IAAIE,OAAO;QACPE,QAAQ,KAAK,CAACF;QACd,OAAOJ;IACX;IAAO,IAAI,CAACG,QAAQ;QAChBG,QAAQ,KAAK,CAAC;QACd,OAAON;IACX;IAEA,OAAO;QACH,SAAS,IACE;mBACCE,OAAO,OAAO,IAAI,EAAE;mBACrBK;gBACHC,uCAAuC;oBACnC,mBAAmBN,OAAO,iBAAiB;oBAC3C,sBAAsBA,OAAO,oBAAoB;oBACjDC;gBACJ;aACH;IAET;AACJ"}
@@ -5,7 +5,7 @@ import { createSendDataToEventBridgeOnRequestEnd } from "./createSendDataToEvent
5
5
  import { createHandler } from "./createHandler.js";
6
6
  import { convertException } from "@webiny/utils/exception.js";
7
7
  const createSyncSystemHandlerOnRequestPlugin = (params)=>createHandlerOnRequest(async (_, __, context)=>{
8
- const { data: manifest, error } = await getManifest(params);
8
+ const { data: manifest, error } = await getManifest();
9
9
  if (error) {
10
10
  if ("true" !== process.env.DEBUG) return;
11
11
  console.error("Error happened when fetching manifest.");
@@ -13,7 +13,8 @@ const createSyncSystemHandlerOnRequestPlugin = (params)=>createHandlerOnRequest(
13
13
  error: convertException(error)
14
14
  }));
15
15
  return;
16
- } else if (!manifest?.sync?.region) {
16
+ }
17
+ if (!manifest?.sync?.region) {
17
18
  if ("true" !== process.env.DEBUG) return;
18
19
  console.error("There is no manifest.");
19
20
  console.log(JSON.stringify({
@@ -1 +1 @@
1
- {"version":3,"file":"sync/requestPlugin.js","sources":["../../src/sync/requestPlugin.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { ICommandConverter, IGetEventBridgeCallable, ISystem } from \"~/sync/types.js\";\nimport { createHandlerOnRequest } from \"@webiny/handler\";\nimport { getManifest } from \"~/sync/utils/manifest.js\";\nimport { attachToDynamoDbDocument } from \"~/sync/attachToDynamoDbDocument.js\";\nimport { createSendDataToEventBridgeOnRequestEnd } from \"~/sync/createSendDataToEventBridgeOnRequestEnd.js\";\nimport { createHandler } from \"./createHandler.js\";\nimport { convertException } from \"@webiny/utils/exception.js\";\n\nexport interface ICreateSyncSystemHandlerOnRequestPluginParams {\n getDocumentClient(): Pick<DynamoDBDocument, \"send\">;\n getEventBridgeClient: IGetEventBridgeCallable;\n system: ISystem;\n commandConverters?: ICommandConverter[];\n}\n\nexport const createSyncSystemHandlerOnRequestPlugin = (\n params: ICreateSyncSystemHandlerOnRequestPluginParams\n) => {\n return createHandlerOnRequest(async (_, __, context) => {\n const { data: manifest, error } = await getManifest(params);\n if (error) {\n if (process.env.DEBUG !== \"true\") {\n return;\n }\n console.error(\"Error happened when fetching manifest.\");\n console.log(\n JSON.stringify({\n error: convertException(error)\n })\n );\n return;\n } else if (!manifest?.sync?.region) {\n if (process.env.DEBUG !== \"true\") {\n return;\n }\n console.error(\"There is no manifest.\");\n console.log(\n JSON.stringify({\n manifest\n })\n );\n return;\n }\n\n const { handler } = createHandler({\n getEventBridgeClient: () => {\n return params.getEventBridgeClient({\n region: manifest.sync.region\n });\n },\n system: params.system,\n manifest,\n commandConverters: params.commandConverters,\n getPlugins: () => {\n return context.plugins;\n }\n });\n\n attachToDynamoDbDocument({\n handler\n });\n context.plugins.register([\n /**\n * When request ends, send the data to the EventBridge.\n */\n createSendDataToEventBridgeOnRequestEnd(handler)\n ]);\n });\n};\n"],"names":["createSyncSystemHandlerOnRequestPlugin","params","createHandlerOnRequest","_","__","context","manifest","error","getManifest","process","console","JSON","convertException","handler","createHandler","attachToDynamoDbDocument","createSendDataToEventBridgeOnRequestEnd"],"mappings":";;;;;;AAgBO,MAAMA,yCAAyC,CAClDC,SAEOC,uBAAuB,OAAOC,GAAGC,IAAIC;QACxC,MAAM,EAAE,MAAMC,QAAQ,EAAEC,KAAK,EAAE,GAAG,MAAMC,YAAYP;QACpD,IAAIM,OAAO;YACP,IAAIE,AAAsB,WAAtBA,QAAQ,GAAG,CAAC,KAAK,EACjB;YAEJC,QAAQ,KAAK,CAAC;YACdA,QAAQ,GAAG,CACPC,KAAK,SAAS,CAAC;gBACX,OAAOC,iBAAiBL;YAC5B;YAEJ;QACJ,OAAO,IAAI,CAACD,UAAU,MAAM,QAAQ;YAChC,IAAIG,AAAsB,WAAtBA,QAAQ,GAAG,CAAC,KAAK,EACjB;YAEJC,QAAQ,KAAK,CAAC;YACdA,QAAQ,GAAG,CACPC,KAAK,SAAS,CAAC;gBACXL;YACJ;YAEJ;QACJ;QAEA,MAAM,EAAEO,OAAO,EAAE,GAAGC,cAAc;YAC9B,sBAAsB,IACXb,OAAO,oBAAoB,CAAC;oBAC/B,QAAQK,SAAS,IAAI,CAAC,MAAM;gBAChC;YAEJ,QAAQL,OAAO,MAAM;YACrBK;YACA,mBAAmBL,OAAO,iBAAiB;YAC3C,YAAY,IACDI,QAAQ,OAAO;QAE9B;QAEAU,yBAAyB;YACrBF;QACJ;QACAR,QAAQ,OAAO,CAAC,QAAQ,CAAC;YAIrBW,wCAAwCH;SAC3C;IACL"}
1
+ {"version":3,"file":"sync/requestPlugin.js","sources":["../../src/sync/requestPlugin.ts"],"sourcesContent":["import type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { ICommandConverter, IGetEventBridgeCallable, ISystem } from \"~/sync/types.js\";\nimport { createHandlerOnRequest } from \"@webiny/handler\";\nimport { getManifest } from \"~/sync/utils/manifest.js\";\nimport { attachToDynamoDbDocument } from \"~/sync/attachToDynamoDbDocument.js\";\nimport { createSendDataToEventBridgeOnRequestEnd } from \"~/sync/createSendDataToEventBridgeOnRequestEnd.js\";\nimport { createHandler } from \"./createHandler.js\";\nimport { convertException } from \"@webiny/utils/exception.js\";\n\nexport interface ICreateSyncSystemHandlerOnRequestPluginParams {\n getDocumentClient(): Pick<DynamoDBDocument, \"send\">;\n getEventBridgeClient: IGetEventBridgeCallable;\n system: ISystem;\n commandConverters?: ICommandConverter[];\n}\n\nexport const createSyncSystemHandlerOnRequestPlugin = (\n params: ICreateSyncSystemHandlerOnRequestPluginParams\n) => {\n return createHandlerOnRequest(async (_, __, context) => {\n const { data: manifest, error } = await getManifest();\n if (error) {\n if (process.env.DEBUG !== \"true\") {\n return;\n }\n console.error(\"Error happened when fetching manifest.\");\n console.log(\n JSON.stringify({\n error: convertException(error)\n })\n );\n return;\n } else if (!manifest?.sync?.region) {\n if (process.env.DEBUG !== \"true\") {\n return;\n }\n console.error(\"There is no manifest.\");\n console.log(\n JSON.stringify({\n manifest\n })\n );\n return;\n }\n\n const { handler } = createHandler({\n getEventBridgeClient: () => {\n return params.getEventBridgeClient({\n region: manifest.sync.region\n });\n },\n system: params.system,\n manifest,\n commandConverters: params.commandConverters,\n getPlugins: () => {\n return context.plugins;\n }\n });\n\n attachToDynamoDbDocument({\n handler\n });\n context.plugins.register([\n /**\n * When request ends, send the data to the EventBridge.\n */\n createSendDataToEventBridgeOnRequestEnd(handler)\n ]);\n });\n};\n"],"names":["createSyncSystemHandlerOnRequestPlugin","params","createHandlerOnRequest","_","__","context","manifest","error","getManifest","process","console","JSON","convertException","handler","createHandler","attachToDynamoDbDocument","createSendDataToEventBridgeOnRequestEnd"],"mappings":";;;;;;AAgBO,MAAMA,yCAAyC,CAClDC,SAEOC,uBAAuB,OAAOC,GAAGC,IAAIC;QACxC,MAAM,EAAE,MAAMC,QAAQ,EAAEC,KAAK,EAAE,GAAG,MAAMC;QACxC,IAAID,OAAO;YACP,IAAIE,AAAsB,WAAtBA,QAAQ,GAAG,CAAC,KAAK,EACjB;YAEJC,QAAQ,KAAK,CAAC;YACdA,QAAQ,GAAG,CACPC,KAAK,SAAS,CAAC;gBACX,OAAOC,iBAAiBL;YAC5B;YAEJ;QACJ;QAAO,IAAI,CAACD,UAAU,MAAM,QAAQ;YAChC,IAAIG,AAAsB,WAAtBA,QAAQ,GAAG,CAAC,KAAK,EACjB;YAEJC,QAAQ,KAAK,CAAC;YACdA,QAAQ,GAAG,CACPC,KAAK,SAAS,CAAC;gBACXL;YACJ;YAEJ;QACJ;QAEA,MAAM,EAAEO,OAAO,EAAE,GAAGC,cAAc;YAC9B,sBAAsB,IACXb,OAAO,oBAAoB,CAAC;oBAC/B,QAAQK,SAAS,IAAI,CAAC,MAAM;gBAChC;YAEJ,QAAQL,OAAO,MAAM;YACrBK;YACA,mBAAmBL,OAAO,iBAAiB;YAC3C,YAAY,IACDI,QAAQ,OAAO;QAE9B;QAEAU,yBAAyB;YACrBF;QACJ;QACAR,QAAQ,OAAO,CAAC,QAAQ,CAAC;YAIrBW,wCAAwCH;SAC3C;IACL"}
@@ -1,8 +1,4 @@
1
- import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb/index.js";
2
- export interface IGetManifestParams {
3
- getDocumentClient(): Pick<DynamoDBDocument, "send">;
4
- }
5
- export declare const getManifest: (params: IGetManifestParams) => Promise<{
1
+ export declare const getManifest: () => Promise<{
6
2
  data: {
7
3
  sync: {
8
4
  eventBusArn: string;
@@ -12,6 +8,6 @@ export declare const getManifest: (params: IGetManifestParams) => Promise<{
12
8
  };
13
9
  error?: undefined;
14
10
  } | {
15
- error: any;
16
11
  data?: undefined;
12
+ error: any;
17
13
  }>;
@@ -1,4 +1,4 @@
1
- import { ServiceDiscovery } from "@webiny/api";
1
+ import { ServiceDiscovery } from "@webiny/api-core/features/serviceDiscovery/index.js";
2
2
  import zod from "zod";
3
3
  import { createZodError } from "@webiny/utils";
4
4
  const validateManifest = zod.object({
@@ -8,10 +8,8 @@ const validateManifest = zod.object({
8
8
  region: zod.string()
9
9
  })
10
10
  });
11
- const getManifest = async (params)=>{
12
- const documentClient = params.getDocumentClient();
11
+ const getManifest = async ()=>{
13
12
  try {
14
- ServiceDiscovery.setDocumentClient(documentClient);
15
13
  const manifest = await ServiceDiscovery.load();
16
14
  if (!manifest?.sync) return {
17
15
  error: new Error("Sync System Manifest not found. Probably Sync System is not turned on.")
@@ -1 +1 @@
1
- {"version":3,"file":"sync/utils/manifest.js","sources":["../../../src/sync/utils/manifest.ts"],"sourcesContent":["import { ServiceDiscovery } from \"@webiny/api\";\nimport zod from \"zod\";\nimport { createZodError } from \"@webiny/utils\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\n\nconst validateManifest = zod.object({\n sync: zod.object({\n eventBusArn: zod.string(),\n eventBusName: zod.string(),\n region: zod.string()\n })\n});\n\nexport interface IGetManifestParams {\n getDocumentClient(): Pick<DynamoDBDocument, \"send\">;\n}\n\nexport const getManifest = async (params: IGetManifestParams) => {\n const documentClient = params.getDocumentClient();\n try {\n ServiceDiscovery.setDocumentClient(documentClient);\n const manifest = await ServiceDiscovery.load();\n if (!manifest?.sync) {\n return {\n /**\n * This error will be silent. We do not want to log or throw at this point.\n */\n error: new Error(\n \"Sync System Manifest not found. Probably Sync System is not turned on.\"\n )\n };\n }\n const { data, error } = validateManifest.safeParse(manifest);\n if (error) {\n const err = createZodError(error);\n return {\n error: err\n };\n }\n return {\n data\n };\n } catch (ex) {\n return {\n error: ex\n };\n }\n};\n"],"names":["validateManifest","zod","getManifest","params","documentClient","ServiceDiscovery","manifest","Error","data","error","err","createZodError","ex"],"mappings":";;;AAKA,MAAMA,mBAAmBC,IAAI,MAAM,CAAC;IAChC,MAAMA,IAAI,MAAM,CAAC;QACb,aAAaA,IAAI,MAAM;QACvB,cAAcA,IAAI,MAAM;QACxB,QAAQA,IAAI,MAAM;IACtB;AACJ;AAMO,MAAMC,cAAc,OAAOC;IAC9B,MAAMC,iBAAiBD,OAAO,iBAAiB;IAC/C,IAAI;QACAE,iBAAiB,iBAAiB,CAACD;QACnC,MAAME,WAAW,MAAMD,iBAAiB,IAAI;QAC5C,IAAI,CAACC,UAAU,MACX,OAAO;YAIH,OAAO,IAAIC,MACP;QAER;QAEJ,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGT,iBAAiB,SAAS,CAACM;QACnD,IAAIG,OAAO;YACP,MAAMC,MAAMC,eAAeF;YAC3B,OAAO;gBACH,OAAOC;YACX;QACJ;QACA,OAAO;YACHF;QACJ;IACJ,EAAE,OAAOI,IAAI;QACT,OAAO;YACH,OAAOA;QACX;IACJ;AACJ"}
1
+ {"version":3,"file":"sync/utils/manifest.js","sources":["../../../src/sync/utils/manifest.ts"],"sourcesContent":["import { ServiceDiscovery } from \"@webiny/api-core/features/serviceDiscovery/index.js\";\nimport zod from \"zod\";\nimport { createZodError } from \"@webiny/utils\";\n\nconst validateManifest = zod.object({\n sync: zod.object({\n eventBusArn: zod.string(),\n eventBusName: zod.string(),\n region: zod.string()\n })\n});\n\nexport const getManifest = async () => {\n try {\n const manifest = await ServiceDiscovery.load();\n if (!manifest?.sync) {\n return {\n /*\n * This error will be silent. We do not want to log or throw at this point.\n */\n error: new Error(\n \"Sync System Manifest not found. Probably Sync System is not turned on.\"\n )\n };\n }\n const { data, error } = validateManifest.safeParse(manifest);\n if (error) {\n const err = createZodError(error);\n return {\n error: err\n };\n }\n return {\n data\n };\n } catch (ex) {\n return {\n error: ex\n };\n }\n};\n"],"names":["validateManifest","zod","getManifest","manifest","ServiceDiscovery","Error","data","error","err","createZodError","ex"],"mappings":";;;AAIA,MAAMA,mBAAmBC,IAAI,MAAM,CAAC;IAChC,MAAMA,IAAI,MAAM,CAAC;QACb,aAAaA,IAAI,MAAM;QACvB,cAAcA,IAAI,MAAM;QACxB,QAAQA,IAAI,MAAM;IACtB;AACJ;AAEO,MAAMC,cAAc;IACvB,IAAI;QACA,MAAMC,WAAW,MAAMC,iBAAiB,IAAI;QAC5C,IAAI,CAACD,UAAU,MACX,OAAO;YAIH,OAAO,IAAIE,MACP;QAER;QAEJ,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGP,iBAAiB,SAAS,CAACG;QACnD,IAAII,OAAO;YACP,MAAMC,MAAMC,eAAeF;YAC3B,OAAO;gBACH,OAAOC;YACX;QACJ;QACA,OAAO;YACHF;QACJ;IACJ,EAAE,OAAOI,IAAI;QACT,OAAO;YACH,OAAOA;QACX;IACJ;AACJ"}
@@ -4,10 +4,10 @@ const validateSystemInput = (input)=>{
4
4
  if (!env) return {
5
5
  error: "Sync System: No environment variable provided. Sync System will not be attached."
6
6
  };
7
- else if (!region) return {
7
+ if (!region) return {
8
8
  error: "Sync System: No region variable provided. Sync System will not be attached."
9
9
  };
10
- else if (!version) return {
10
+ if (!version) return {
11
11
  error: "Sync System: No version variable provided. Sync System will not be attached."
12
12
  };
13
13
  const name = createSystemName({
@@ -1 +1 @@
1
- {"version":3,"file":"sync/utils/validateSystemInput.js","sources":["../../../src/sync/utils/validateSystemInput.ts"],"sourcesContent":["import type { ISystem } from \"~/sync/types.js\";\nimport { createSystemName } from \"~/utils/createSystemName.js\";\n\nexport interface IValidResponse {\n system: ISystem;\n error?: never;\n}\n\nexport interface IErrorResponse {\n error: string;\n system?: never;\n}\n\nexport type ValidateSystemInputResponse = IValidResponse | IErrorResponse;\n\nexport const validateSystemInput = (input: Partial<ISystem>): ValidateSystemInputResponse => {\n const { env, region, variant, version } = input;\n if (!env) {\n return {\n error: \"Sync System: No environment variable provided. Sync System will not be attached.\"\n };\n } else if (!region) {\n return {\n error: \"Sync System: No region variable provided. Sync System will not be attached.\"\n };\n } else if (!version) {\n return {\n error: \"Sync System: No version variable provided. Sync System will not be attached.\"\n };\n }\n const name = createSystemName({\n env,\n variant\n });\n\n return {\n system: {\n env,\n name,\n region,\n variant,\n version\n }\n };\n};\n"],"names":["validateSystemInput","input","env","region","variant","version","name","createSystemName"],"mappings":";AAeO,MAAMA,sBAAsB,CAACC;IAChC,MAAM,EAAEC,GAAG,EAAEC,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGJ;IAC1C,IAAI,CAACC,KACD,OAAO;QACH,OAAO;IACX;SACG,IAAI,CAACC,QACR,OAAO;QACH,OAAO;IACX;SACG,IAAI,CAACE,SACR,OAAO;QACH,OAAO;IACX;IAEJ,MAAMC,OAAOC,iBAAiB;QAC1BL;QACAE;IACJ;IAEA,OAAO;QACH,QAAQ;YACJF;YACAI;YACAH;YACAC;YACAC;QACJ;IACJ;AACJ"}
1
+ {"version":3,"file":"sync/utils/validateSystemInput.js","sources":["../../../src/sync/utils/validateSystemInput.ts"],"sourcesContent":["import type { ISystem } from \"~/sync/types.js\";\nimport { createSystemName } from \"~/utils/createSystemName.js\";\n\nexport interface IValidResponse {\n system: ISystem;\n error?: never;\n}\n\nexport interface IErrorResponse {\n error: string;\n system?: never;\n}\n\nexport type ValidateSystemInputResponse = IValidResponse | IErrorResponse;\n\nexport const validateSystemInput = (input: Partial<ISystem>): ValidateSystemInputResponse => {\n const { env, region, variant, version } = input;\n if (!env) {\n return {\n error: \"Sync System: No environment variable provided. Sync System will not be attached.\"\n };\n } else if (!region) {\n return {\n error: \"Sync System: No region variable provided. Sync System will not be attached.\"\n };\n } else if (!version) {\n return {\n error: \"Sync System: No version variable provided. Sync System will not be attached.\"\n };\n }\n const name = createSystemName({\n env,\n variant\n });\n\n return {\n system: {\n env,\n name,\n region,\n variant,\n version\n }\n };\n};\n"],"names":["validateSystemInput","input","env","region","variant","version","name","createSystemName"],"mappings":";AAeO,MAAMA,sBAAsB,CAACC;IAChC,MAAM,EAAEC,GAAG,EAAEC,MAAM,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGJ;IAC1C,IAAI,CAACC,KACD,OAAO;QACH,OAAO;IACX;IACG,IAAI,CAACC,QACR,OAAO;QACH,OAAO;IACX;IACG,IAAI,CAACE,SACR,OAAO;QACH,OAAO;IACX;IAEJ,MAAMC,OAAOC,iBAAiB;QAC1BL;QACAE;IACJ;IAEA,OAAO;QACH,QAAQ;YACJF;YACAI;YACAH;YACAC;YACAC;QACJ;IACJ;AACJ"}