@webiny/api-sync-ddb-to-opensearch 0.0.0-unstable.0d717d18dd → 0.0.0-unstable.3fddf667ea
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.
|
@@ -12,7 +12,7 @@ class DdbOperationsBuilderImpl {
|
|
|
12
12
|
const operations = this.operationsFactory.create();
|
|
13
13
|
for (const record of params.records){
|
|
14
14
|
if (!record.dynamodb) continue;
|
|
15
|
-
if (!record.eventName) {
|
|
15
|
+
else if (!record.eventName) {
|
|
16
16
|
console.error(`Could not get operation from the record, skipping event "${record.eventID}".`);
|
|
17
17
|
continue;
|
|
18
18
|
}
|
|
@@ -25,8 +25,8 @@ class DdbOperationsBuilderImpl {
|
|
|
25
25
|
if (record.eventName === OperationType.INSERT || record.eventName === OperationType.MODIFY) {
|
|
26
26
|
const newImage = unmarshall(record.dynamodb.NewImage);
|
|
27
27
|
if (!newImage || "object" != typeof newImage || 0 === Object.keys(newImage).length) continue;
|
|
28
|
-
if (true === newImage.ignore) continue;
|
|
29
|
-
if (!newImage.index) {
|
|
28
|
+
else if (true === newImage.ignore) continue;
|
|
29
|
+
else if (!newImage.index) {
|
|
30
30
|
console.error(`Could not get index from the new image, skipping event "${record.eventID}".`);
|
|
31
31
|
console.log({
|
|
32
32
|
newImage
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/DdbOperationsBuilder/DdbOperationsBuilder.js","sources":["../../../src/features/DdbOperationsBuilder/DdbOperationsBuilder.ts"],"sourcesContent":["import type { DynamoDBRecord } from \"@webiny/aws-sdk/types/index.js\";\nimport { OperationsBuilder } from \"@webiny/api-sync-to-opensearch/features/OperationsBuilder/abstraction.js\";\nimport { OperationType } from \"@webiny/api-sync-to-opensearch/features/Operations/Operations.js\";\nimport type { Operations } from \"@webiny/api-sync-to-opensearch/features/Operations/abstractions/Operations.js\";\nimport { OperationsFactory } from \"@webiny/api-sync-to-opensearch/features/Operations/abstractions/OperationsFactory.js\";\nimport { unmarshall } from \"~/marshall.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\n\ninterface RecordDynamoDbImage {\n data: {\n compression: string;\n value: string;\n };\n ignore?: boolean;\n index: string;\n}\n\ninterface RecordDynamoDbKeys {\n PK: string;\n SK: string;\n}\n\nclass DdbOperationsBuilderImpl implements OperationsBuilder.Interface<DynamoDBRecord> {\n public constructor(\n private readonly compressor: CompressionHandler.Interface,\n private readonly operationsFactory: OperationsFactory.Interface\n ) {}\n\n public async build(params: { records: DynamoDBRecord[] }): Promise<Operations.Interface> {\n const operations = this.operationsFactory.create();\n for (const record of params.records) {\n if (!record.dynamodb) {\n continue;\n } else if (!record.eventName) {\n console.error(\n `Could not get operation from the record, skipping event \"${record.eventID}\".`\n );\n continue;\n }\n\n const keys = unmarshall<RecordDynamoDbKeys>(record.dynamodb.Keys);\n if (!keys?.PK || !keys.SK) {\n console.error(\n `Could not get keys from the record, skipping event \"${record.eventID}\".`\n );\n continue;\n }\n\n const id = `${keys.PK}:${keys.SK}`;\n\n if (\n record.eventName === OperationType.INSERT ||\n record.eventName === OperationType.MODIFY\n ) {\n const newImage = unmarshall<RecordDynamoDbImage>(record.dynamodb.NewImage);\n if (\n !newImage ||\n typeof newImage !== \"object\" ||\n Object.keys(newImage).length === 0\n ) {\n continue;\n } else if (newImage.ignore === true) {\n continue;\n } else if (!newImage.index) {\n console.error(\n `Could not get index from the new image, skipping event \"${record.eventID}\".`\n );\n console.log({ newImage });\n continue;\n }\n const data = await this.compressor.decompress(newImage.data);\n if (data === undefined || data === null) {\n console.error(\n `Could not get decompressed data, skipping ES operation \"${record.eventName}\", ID ${id}. Skipping...`\n );\n continue;\n }\n\n operations.insert({\n id,\n index: newImage.index,\n data\n });\n } else if (record.eventName === OperationType.REMOVE) {\n const oldImage = unmarshall<RecordDynamoDbImage>(record.dynamodb.OldImage);\n if (!oldImage?.index) {\n continue;\n }\n operations.delete({\n id,\n index: oldImage.index\n });\n }\n }\n return operations;\n }\n}\n\nexport const DdbOperationsBuilder = OperationsBuilder.createImplementation({\n implementation: DdbOperationsBuilderImpl,\n dependencies: [CompressionHandler, OperationsFactory]\n});\n"],"names":["DdbOperationsBuilderImpl","compressor","operationsFactory","params","operations","record","console","keys","unmarshall","id","OperationType","newImage","Object","data","oldImage","DdbOperationsBuilder","OperationsBuilder","CompressionHandler","OperationsFactory"],"mappings":";;;;;AAsBA,MAAMA;IACF,YACqBC,UAAwC,EACxCC,iBAA8C,CACjE;aAFmBD,UAAU,GAAVA;aACAC,iBAAiB,GAAjBA;IAClB;IAEH,MAAa,MAAMC,MAAqC,EAAiC;QACrF,MAAMC,aAAa,IAAI,CAAC,iBAAiB,CAAC,MAAM;QAChD,KAAK,MAAMC,UAAUF,OAAO,OAAO,CAAE;YACjC,IAAI,CAACE,OAAO,QAAQ,EAChB;
|
|
1
|
+
{"version":3,"file":"features/DdbOperationsBuilder/DdbOperationsBuilder.js","sources":["../../../src/features/DdbOperationsBuilder/DdbOperationsBuilder.ts"],"sourcesContent":["import type { DynamoDBRecord } from \"@webiny/aws-sdk/types/index.js\";\nimport { OperationsBuilder } from \"@webiny/api-sync-to-opensearch/features/OperationsBuilder/abstraction.js\";\nimport { OperationType } from \"@webiny/api-sync-to-opensearch/features/Operations/Operations.js\";\nimport type { Operations } from \"@webiny/api-sync-to-opensearch/features/Operations/abstractions/Operations.js\";\nimport { OperationsFactory } from \"@webiny/api-sync-to-opensearch/features/Operations/abstractions/OperationsFactory.js\";\nimport { unmarshall } from \"~/marshall.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\n\ninterface RecordDynamoDbImage {\n data: {\n compression: string;\n value: string;\n };\n ignore?: boolean;\n index: string;\n}\n\ninterface RecordDynamoDbKeys {\n PK: string;\n SK: string;\n}\n\nclass DdbOperationsBuilderImpl implements OperationsBuilder.Interface<DynamoDBRecord> {\n public constructor(\n private readonly compressor: CompressionHandler.Interface,\n private readonly operationsFactory: OperationsFactory.Interface\n ) {}\n\n public async build(params: { records: DynamoDBRecord[] }): Promise<Operations.Interface> {\n const operations = this.operationsFactory.create();\n for (const record of params.records) {\n if (!record.dynamodb) {\n continue;\n } else if (!record.eventName) {\n console.error(\n `Could not get operation from the record, skipping event \"${record.eventID}\".`\n );\n continue;\n }\n\n const keys = unmarshall<RecordDynamoDbKeys>(record.dynamodb.Keys);\n if (!keys?.PK || !keys.SK) {\n console.error(\n `Could not get keys from the record, skipping event \"${record.eventID}\".`\n );\n continue;\n }\n\n const id = `${keys.PK}:${keys.SK}`;\n\n if (\n record.eventName === OperationType.INSERT ||\n record.eventName === OperationType.MODIFY\n ) {\n const newImage = unmarshall<RecordDynamoDbImage>(record.dynamodb.NewImage);\n if (\n !newImage ||\n typeof newImage !== \"object\" ||\n Object.keys(newImage).length === 0\n ) {\n continue;\n } else if (newImage.ignore === true) {\n continue;\n } else if (!newImage.index) {\n console.error(\n `Could not get index from the new image, skipping event \"${record.eventID}\".`\n );\n console.log({ newImage });\n continue;\n }\n const data = await this.compressor.decompress(newImage.data);\n if (data === undefined || data === null) {\n console.error(\n `Could not get decompressed data, skipping ES operation \"${record.eventName}\", ID ${id}. Skipping...`\n );\n continue;\n }\n\n operations.insert({\n id,\n index: newImage.index,\n data\n });\n } else if (record.eventName === OperationType.REMOVE) {\n const oldImage = unmarshall<RecordDynamoDbImage>(record.dynamodb.OldImage);\n if (!oldImage?.index) {\n continue;\n }\n operations.delete({\n id,\n index: oldImage.index\n });\n }\n }\n return operations;\n }\n}\n\nexport const DdbOperationsBuilder = OperationsBuilder.createImplementation({\n implementation: DdbOperationsBuilderImpl,\n dependencies: [CompressionHandler, OperationsFactory]\n});\n"],"names":["DdbOperationsBuilderImpl","compressor","operationsFactory","params","operations","record","console","keys","unmarshall","id","OperationType","newImage","Object","data","oldImage","DdbOperationsBuilder","OperationsBuilder","CompressionHandler","OperationsFactory"],"mappings":";;;;;AAsBA,MAAMA;IACF,YACqBC,UAAwC,EACxCC,iBAA8C,CACjE;aAFm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O,SAAS,CAAC,MAAM,EAAEI,GAAG,aAAa,CAAC;oBAEzG;gBACJ;gBAEAL,WAAW,MAAM,CAAC;oBACdK;oBACA,OAAOE,SAAS,KAAK;oBACrBE;gBACJ;YACJ,OAAO,IAAIR,OAAO,SAAS,KAAKK,cAAc,MAAM,EAAE;gBAClD,MAAMI,WAAWN,WAAgCH,OAAO,QAAQ,CAAC,QAAQ;gBACzE,IAAI,CAACS,UAAU,OACX;gBAEJV,WAAW,MAAM,CAAC;oBACdK;oBACA,OAAOK,SAAS,KAAK;gBACzB;YACJ;QACJ;QACA,OAAOV;IACX;AACJ;AAEO,MAAMW,uBAAuBC,kBAAkB,oBAAoB,CAAC;IACvE,gBAAgBhB;IAChB,cAAc;QAACiB;QAAoBC;KAAkB;AACzD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-sync-ddb-to-opensearch",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.3fddf667ea",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -15,18 +15,18 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"author": "Webiny Ltd.",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@webiny/api": "0.0.0-unstable.
|
|
19
|
-
"@webiny/api-opensearch": "0.0.0-unstable.
|
|
20
|
-
"@webiny/api-sync-to-opensearch": "0.0.0-unstable.
|
|
21
|
-
"@webiny/aws-sdk": "0.0.0-unstable.
|
|
22
|
-
"@webiny/event-handler-aws": "0.0.0-unstable.
|
|
23
|
-
"@webiny/event-handler-core": "0.0.0-unstable.
|
|
24
|
-
"@webiny/feature": "0.0.0-unstable.
|
|
25
|
-
"@webiny/stdlib": "0.0.
|
|
26
|
-
"@webiny/utils": "0.0.0-unstable.
|
|
18
|
+
"@webiny/api": "0.0.0-unstable.3fddf667ea",
|
|
19
|
+
"@webiny/api-opensearch": "0.0.0-unstable.3fddf667ea",
|
|
20
|
+
"@webiny/api-sync-to-opensearch": "0.0.0-unstable.3fddf667ea",
|
|
21
|
+
"@webiny/aws-sdk": "0.0.0-unstable.3fddf667ea",
|
|
22
|
+
"@webiny/event-handler-aws": "0.0.0-unstable.3fddf667ea",
|
|
23
|
+
"@webiny/event-handler-core": "0.0.0-unstable.3fddf667ea",
|
|
24
|
+
"@webiny/feature": "0.0.0-unstable.3fddf667ea",
|
|
25
|
+
"@webiny/stdlib": "0.0.21",
|
|
26
|
+
"@webiny/utils": "0.0.0-unstable.3fddf667ea"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@webiny/build-tools": "0.0.0-unstable.
|
|
29
|
+
"@webiny/build-tools": "0.0.0-unstable.3fddf667ea",
|
|
30
30
|
"typescript": "7.0.2"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|