@webiny/api-sync-system 6.5.0-beta.4 → 6.5.0-beta.5
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 +16 -16
- package/resolver/recordTypes/fileManager/shouldBeHandled.js +3 -3
- package/resolver/recordTypes/fileManager/shouldBeHandled.js.map +1 -1
- package/resolver/recordTypes/users/shouldBeHandled.js +4 -4
- package/resolver/recordTypes/users/shouldBeHandled.js.map +1 -1
- package/sync/createSyncSystem.js +1 -2
- package/sync/createSyncSystem.js.map +1 -1
- package/sync/requestPlugin.js +1 -2
- package/sync/requestPlugin.js.map +1 -1
- package/sync/utils/validateSystemInput.js +2 -2
- package/sync/utils/validateSystemInput.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-sync-system",
|
|
3
|
-
"version": "6.5.0-beta.
|
|
3
|
+
"version": "6.5.0-beta.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -14,30 +14,30 @@
|
|
|
14
14
|
"author": "Webiny LTD",
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@webiny/api": "6.5.0-beta.
|
|
18
|
-
"@webiny/api-core": "6.5.0-beta.
|
|
19
|
-
"@webiny/aws-sdk": "6.5.0-beta.
|
|
20
|
-
"@webiny/error": "6.5.0-beta.
|
|
21
|
-
"@webiny/handler": "6.5.0-beta.
|
|
22
|
-
"@webiny/handler-aws": "6.5.0-beta.
|
|
23
|
-
"@webiny/plugins": "6.5.0-beta.
|
|
24
|
-
"@webiny/utils": "6.5.0-beta.
|
|
17
|
+
"@webiny/api": "6.5.0-beta.5",
|
|
18
|
+
"@webiny/api-core": "6.5.0-beta.5",
|
|
19
|
+
"@webiny/aws-sdk": "6.5.0-beta.5",
|
|
20
|
+
"@webiny/error": "6.5.0-beta.5",
|
|
21
|
+
"@webiny/handler": "6.5.0-beta.5",
|
|
22
|
+
"@webiny/handler-aws": "6.5.0-beta.5",
|
|
23
|
+
"@webiny/plugins": "6.5.0-beta.5",
|
|
24
|
+
"@webiny/utils": "6.5.0-beta.5",
|
|
25
25
|
"bytes": "3.1.2",
|
|
26
26
|
"lodash": "4.18.1",
|
|
27
27
|
"semver": "7.8.5",
|
|
28
|
-
"zod": "4.
|
|
28
|
+
"zod": "4.6.5"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@faker-js/faker": "10.
|
|
32
|
-
"@types/lodash": "4.17.
|
|
33
|
-
"@webiny/api-core-ddb": "6.5.0-beta.
|
|
34
|
-
"@webiny/build-tools": "6.5.0-beta.
|
|
35
|
-
"@webiny/project-utils": "6.5.0-beta.
|
|
31
|
+
"@faker-js/faker": "10.6.0",
|
|
32
|
+
"@types/lodash": "4.17.25",
|
|
33
|
+
"@webiny/api-core-ddb": "6.5.0-beta.5",
|
|
34
|
+
"@webiny/build-tools": "6.5.0-beta.5",
|
|
35
|
+
"@webiny/project-utils": "6.5.0-beta.5",
|
|
36
36
|
"aws-sdk-client-mock": "4.1.0",
|
|
37
37
|
"jest-dynalite": "3.6.1",
|
|
38
38
|
"rimraf": "6.1.3",
|
|
39
39
|
"typescript": "7.0.2",
|
|
40
|
-
"vitest": "
|
|
40
|
+
"vitest": "5.0.2"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const shouldBeHandled = (params)=>{
|
|
2
2
|
const { item, table } = params;
|
|
3
3
|
if ("regular" !== table.type) return false;
|
|
4
|
-
if ("L" !== item.SK) return false;
|
|
5
|
-
if ("fmFile" !== item.modelId) return false;
|
|
6
|
-
if (!item.values) 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;
|
|
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;
|
|
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,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
|
-
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;
|
|
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;
|
|
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;
|
|
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"}
|
package/sync/createSyncSystem.js
CHANGED
|
@@ -11,8 +11,7 @@ const createSyncSystem = (params)=>{
|
|
|
11
11
|
if (error) {
|
|
12
12
|
console.error(error);
|
|
13
13
|
return emptyResponse;
|
|
14
|
-
}
|
|
15
|
-
if (!system) {
|
|
14
|
+
} else if (!system) {
|
|
16
15
|
console.error("Sync System: No system provided. Sync System will not be attached.");
|
|
17
16
|
return emptyResponse;
|
|
18
17
|
}
|
|
@@ -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
|
|
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"}
|
package/sync/requestPlugin.js
CHANGED
|
@@ -13,8 +13,7 @@ const createSyncSystemHandlerOnRequestPlugin = (params)=>createHandlerOnRequest(
|
|
|
13
13
|
error: convertException(error)
|
|
14
14
|
}));
|
|
15
15
|
return;
|
|
16
|
-
}
|
|
17
|
-
if (!manifest?.sync?.region) {
|
|
16
|
+
} else if (!manifest?.sync?.region) {
|
|
18
17
|
if ("true" !== process.env.DEBUG) return;
|
|
19
18
|
console.error("There is no manifest.");
|
|
20
19
|
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();\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
|
|
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,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"}
|
|
@@ -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
|
-
if (!region) return {
|
|
7
|
+
else if (!region) return {
|
|
8
8
|
error: "Sync System: No region variable provided. Sync System will not be attached."
|
|
9
9
|
};
|
|
10
|
-
if (!version) return {
|
|
10
|
+
else 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;
|
|
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"}
|