@webiny/api-dynamodb-to-elasticsearch 5.30.0-beta.1 → 5.31.0-beta.1
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/index.d.ts +1 -0
- package/{handler/index.js → index.js} +28 -14
- package/index.js.map +1 -0
- package/package.json +11 -9
- package/handler/index.d.ts +0 -4
- package/handler/index.js.map +0 -1
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createEventHandler: () => import("@webiny/handler-aws").DynamoDBEventHandler<null>;
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.createEventHandler = void 0;
|
|
9
9
|
|
|
10
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
11
|
|
|
@@ -13,6 +13,8 @@ var _dynamodb = require("aws-sdk/clients/dynamodb");
|
|
|
13
13
|
|
|
14
14
|
var _compression = require("@webiny/api-elasticsearch/compression");
|
|
15
15
|
|
|
16
|
+
var _handlerAws = require("@webiny/handler-aws");
|
|
17
|
+
|
|
16
18
|
var Operations;
|
|
17
19
|
|
|
18
20
|
(function (Operations) {
|
|
@@ -58,23 +60,36 @@ const checkErrors = result => {
|
|
|
58
60
|
}
|
|
59
61
|
};
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
const createEventHandler = () => {
|
|
64
|
+
return (0, _handlerAws.createDynamoDBEventHandler)(async ({
|
|
65
|
+
event,
|
|
66
|
+
context: ctx
|
|
67
|
+
}) => {
|
|
68
|
+
const context = ctx;
|
|
69
|
+
|
|
70
|
+
if (!context.elasticsearch) {
|
|
71
|
+
console.log("Missing elasticsearch definition on context.");
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
63
74
|
|
|
64
|
-
async handle(context) {
|
|
65
|
-
const [event] = context.args;
|
|
66
75
|
const operations = [];
|
|
67
76
|
|
|
68
77
|
for (const record of event.Records) {
|
|
69
|
-
const
|
|
78
|
+
const dynamodb = record.dynamodb;
|
|
79
|
+
|
|
80
|
+
if (!dynamodb) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const newImage = _dynamodb.Converter.unmarshall(dynamodb.NewImage);
|
|
70
85
|
|
|
71
86
|
if (newImage.ignore === true) {
|
|
72
87
|
continue;
|
|
73
88
|
}
|
|
74
89
|
|
|
75
|
-
const oldImage = _dynamodb.Converter.unmarshall(
|
|
90
|
+
const oldImage = _dynamodb.Converter.unmarshall(dynamodb.OldImage);
|
|
76
91
|
|
|
77
|
-
const keys = _dynamodb.Converter.unmarshall(
|
|
92
|
+
const keys = _dynamodb.Converter.unmarshall(dynamodb.Keys);
|
|
78
93
|
|
|
79
94
|
const _id = `${keys.PK}:${keys.SK}`;
|
|
80
95
|
const operation = record.eventName;
|
|
@@ -130,7 +145,7 @@ var _default = () => ({
|
|
|
130
145
|
}
|
|
131
146
|
|
|
132
147
|
if (!operations.length) {
|
|
133
|
-
return
|
|
148
|
+
return null;
|
|
134
149
|
}
|
|
135
150
|
|
|
136
151
|
try {
|
|
@@ -150,9 +165,8 @@ var _default = () => ({
|
|
|
150
165
|
throw error;
|
|
151
166
|
}
|
|
152
167
|
|
|
153
|
-
return
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
});
|
|
168
|
+
return null;
|
|
169
|
+
});
|
|
170
|
+
};
|
|
157
171
|
|
|
158
|
-
exports.
|
|
172
|
+
exports.createEventHandler = createEventHandler;
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Operations","getError","item","index","error","reason","match","checkErrors","result","body","items","err","process","env","DEBUG","console","log","JSON","stringify","WebinyError","createEventHandler","createDynamoDBEventHandler","event","context","ctx","elasticsearch","operations","record","Records","dynamodb","newImage","Converter","unmarshall","NewImage","ignore","oldImage","OldImage","keys","Keys","_id","PK","SK","operation","eventName","data","undefined","REMOVE","decompress","plugins","INSERT","MODIFY","push","_index","delete","length","res","bulk"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Converter } from \"aws-sdk/clients/dynamodb\";\nimport { decompress } from \"@webiny/api-elasticsearch/compression\";\nimport { ApiResponse, ElasticsearchContext } from \"@webiny/api-elasticsearch/types\";\nimport { createDynamoDBEventHandler } from \"@webiny/handler-aws\";\nimport { StreamRecord } from \"aws-lambda/trigger/dynamodb-stream\";\n\nenum Operations {\n INSERT = \"INSERT\",\n MODIFY = \"MODIFY\",\n REMOVE = \"REMOVE\"\n}\n\ninterface BulkOperationsResponseBodyItemIndexError {\n reason?: string;\n}\ninterface BulkOperationsResponseBodyItemIndex {\n error?: BulkOperationsResponseBodyItemIndexError;\n}\ninterface BulkOperationsResponseBodyItem {\n index?: BulkOperationsResponseBodyItemIndex;\n error?: string;\n}\ninterface BulkOperationsResponseBody {\n items: BulkOperationsResponseBodyItem[];\n}\n\nconst getError = (item: BulkOperationsResponseBodyItem): string | null => {\n if (!item.index || !item.index.error || !item.index.error.reason) {\n return null;\n }\n const reason = item.index.error.reason;\n if (reason.match(/no such index \\[([a-zA-Z0-9_-]+)\\]/) !== null) {\n return \"index\";\n }\n return reason;\n};\n\nconst checkErrors = (result?: ApiResponse<BulkOperationsResponseBody>): void => {\n if (!result || !result.body || !result.body.items) {\n return;\n }\n for (const item of result.body.items) {\n const err = getError(item);\n if (!err) {\n continue;\n } else if (err === \"index\") {\n if (process.env.DEBUG === \"true\") {\n console.log(\"Bulk response\", JSON.stringify(result, null, 2));\n }\n continue;\n }\n console.log(item.error);\n throw new WebinyError(err, \"DYNAMODB_TO_ELASTICSEARCH_ERROR\", item);\n }\n};\n\ninterface RecordDynamoDbImage {\n data: Record<string, any>;\n ignore?: boolean;\n index: string;\n}\n\ninterface RecordDynamoDbKeys {\n PK: string;\n SK: string;\n}\n\nexport const createEventHandler = () => {\n return createDynamoDBEventHandler(async ({ event, context: ctx }) => {\n const context = ctx as unknown as ElasticsearchContext;\n if (!context.elasticsearch) {\n console.log(\"Missing elasticsearch definition on context.\");\n return null;\n }\n const operations = [];\n\n for (const record of event.Records) {\n const dynamodb = record.dynamodb as Required<StreamRecord>;\n if (!dynamodb) {\n continue;\n }\n const newImage = Converter.unmarshall(dynamodb.NewImage) as RecordDynamoDbImage;\n\n if (newImage.ignore === true) {\n continue;\n }\n\n const oldImage = Converter.unmarshall(dynamodb.OldImage) as RecordDynamoDbImage;\n const keys = Converter.unmarshall(dynamodb.Keys) as RecordDynamoDbKeys;\n const _id = `${keys.PK}:${keys.SK}`;\n const operation = record.eventName;\n\n /**\n * On operations other than REMOVE we decompress the data and store it into the Elasticsearch.\n * No need to try to decompress if operation is REMOVE since there is no data sent into that operation.\n */\n let data: any = undefined;\n if (operation !== Operations.REMOVE) {\n /**\n * We must decompress the data that is going into the Elasticsearch.\n */\n data = await decompress(context.plugins, newImage.data);\n /**\n * No point in writing null or undefined data into the Elasticsearch.\n * This might happen on some error while decompressing. We will log it.\n *\n * Data should NEVER be null or undefined in the Elasticsearch DynamoDB table, unless it is a delete operations.\n * If it is - it is a bug.\n */\n if (data === undefined || data === null) {\n console.log(\n `Could not get decompressed data, skipping ES operation \"${operation}\", ID ${_id}`\n );\n continue;\n }\n }\n\n switch (record.eventName) {\n case Operations.INSERT:\n case Operations.MODIFY:\n operations.push({ index: { _id, _index: newImage.index } }, data);\n break;\n case Operations.REMOVE:\n operations.push({ delete: { _id, _index: oldImage.index } });\n break;\n default:\n break;\n }\n }\n\n if (!operations.length) {\n return null;\n }\n\n try {\n const res = await context.elasticsearch.bulk<BulkOperationsResponseBody>({\n body: operations\n });\n checkErrors(res);\n if (process.env.DEBUG === \"true\") {\n console.log(\"Bulk response\", JSON.stringify(res, null, 2));\n }\n } catch (error) {\n if (process.env.DEBUG === \"true\") {\n console.log(\"Bulk error\", JSON.stringify(error, null, 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IACH;;IAED,OAAO,IAAP;EACH,CAlFM,CAAP;AAmFH,CApFM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-dynamodb-to-elasticsearch",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.31.0-beta.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Webiny Ltd.",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@babel/runtime": "7.18.
|
|
15
|
-
"@webiny/api-elasticsearch": "5.
|
|
16
|
-
"@webiny/error": "5.
|
|
17
|
-
"@webiny/handler": "5.
|
|
18
|
-
"aws-
|
|
14
|
+
"@babel/runtime": "7.18.9",
|
|
15
|
+
"@webiny/api-elasticsearch": "5.31.0-beta.1",
|
|
16
|
+
"@webiny/error": "5.31.0-beta.1",
|
|
17
|
+
"@webiny/handler-aws": "5.31.0-beta.1",
|
|
18
|
+
"aws-lambda": "1.0.7",
|
|
19
|
+
"aws-sdk": "2.1188.0"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
22
|
"@babel/cli": "^7.16.0",
|
|
@@ -24,8 +25,9 @@
|
|
|
24
25
|
"@babel/plugin-transform-runtime": "^7.16.4",
|
|
25
26
|
"@babel/preset-env": "^7.16.4",
|
|
26
27
|
"@babel/preset-typescript": "^7.16.0",
|
|
27
|
-
"@webiny/cli": "^5.
|
|
28
|
-
"@webiny/
|
|
28
|
+
"@webiny/cli": "^5.31.0-beta.1",
|
|
29
|
+
"@webiny/plugins": "^5.31.0-beta.1",
|
|
30
|
+
"@webiny/project-utils": "^5.31.0-beta.1",
|
|
29
31
|
"typescript": "4.7.4"
|
|
30
32
|
},
|
|
31
33
|
"publishConfig": {
|
|
@@ -46,5 +48,5 @@
|
|
|
46
48
|
]
|
|
47
49
|
}
|
|
48
50
|
},
|
|
49
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "b29a1cdd4c7cba5af3b9b993a78f4561525a9201"
|
|
50
52
|
}
|
package/handler/index.d.ts
DELETED
package/handler/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Operations","getError","item","index","error","reason","match","checkErrors","result","body","items","err","process","env","DEBUG","console","log","JSON","stringify","WebinyError","type","handle","context","event","args","operations","record","Records","newImage","Converter","unmarshall","dynamodb","NewImage","ignore","oldImage","OldImage","keys","Keys","_id","PK","SK","operation","eventName","data","undefined","REMOVE","decompress","plugins","INSERT","MODIFY","push","_index","delete","length","res","elasticsearch","bulk"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Converter } from \"aws-sdk/clients/dynamodb\";\nimport { HandlerPlugin } from \"@webiny/handler/types\";\nimport { ElasticsearchContext } from \"@webiny/api-elasticsearch/types\";\nimport { decompress } from \"@webiny/api-elasticsearch/compression\";\nimport { ApiResponse } from \"@webiny/api-elasticsearch/types\";\n\nenum Operations {\n INSERT = \"INSERT\",\n MODIFY = \"MODIFY\",\n REMOVE = \"REMOVE\"\n}\n\ninterface BulkOperationsResponseBodyItemIndexError {\n reason?: string;\n}\ninterface BulkOperationsResponseBodyItemIndex {\n error?: BulkOperationsResponseBodyItemIndexError;\n}\ninterface BulkOperationsResponseBodyItem {\n index?: BulkOperationsResponseBodyItemIndex;\n error?: string;\n}\ninterface BulkOperationsResponseBody {\n items: BulkOperationsResponseBodyItem[];\n}\n\nconst getError = (item: BulkOperationsResponseBodyItem): string | null => {\n if (!item.index || !item.index.error || !item.index.error.reason) {\n return null;\n }\n const reason = item.index.error.reason;\n if (reason.match(/no such index \\[([a-zA-Z0-9_-]+)\\]/) !== null) {\n return \"index\";\n }\n return reason;\n};\n\nconst checkErrors = (result?: ApiResponse<BulkOperationsResponseBody>): void => {\n if (!result || !result.body || !result.body.items) {\n return;\n }\n for (const item of result.body.items) {\n const err = getError(item);\n if (!err) {\n continue;\n } else if (err === \"index\") {\n if (process.env.DEBUG === \"true\") {\n console.log(\"Bulk response\", JSON.stringify(result, null, 2));\n }\n continue;\n }\n console.log(item.error);\n throw new WebinyError(err, \"DYNAMODB_TO_ELASTICSEARCH_ERROR\", item);\n }\n};\n\ninterface RecordDynamoDbImage {\n data: Record<string, any>;\n ignore?: boolean;\n index: string;\n}\n\ninterface RecordDynamoDbKeys {\n PK: string;\n SK: string;\n}\n\nexport default (): HandlerPlugin<ElasticsearchContext> => ({\n type: \"handler\",\n async handle(context) {\n const [event] = context.args;\n const operations = [];\n\n for (const record of event.Records) {\n const newImage = Converter.unmarshall(record.dynamodb.NewImage) as RecordDynamoDbImage;\n\n if (newImage.ignore === true) {\n continue;\n }\n\n const oldImage = Converter.unmarshall(record.dynamodb.OldImage) as RecordDynamoDbImage;\n const keys = Converter.unmarshall(record.dynamodb.Keys) as RecordDynamoDbKeys;\n const _id = `${keys.PK}:${keys.SK}`;\n const operation = record.eventName;\n\n /**\n * On operations other than REMOVE we decompress the data and store it into the Elasticsearch.\n * No need to try to decompress if operation is REMOVE since there is no data sent into that operation.\n */\n let data: any = undefined;\n if (operation !== Operations.REMOVE) {\n /**\n * We must decompress the data that is going into the Elasticsearch.\n */\n data = await decompress(context.plugins, newImage.data);\n /**\n * No point in writing null or undefined data into the Elasticsearch.\n * This might happen on some error while decompressing. We will log it.\n *\n * Data should NEVER be null or undefined in the Elasticsearch DynamoDB table, unless it is a delete operations.\n * If it is - it is a bug.\n */\n if (data === undefined || data === null) {\n console.log(\n `Could not get decompressed data, skipping ES operation \"${operation}\", ID ${_id}`\n );\n continue;\n }\n }\n\n switch (record.eventName) {\n case Operations.INSERT:\n case Operations.MODIFY:\n operations.push({ index: { _id, _index: newImage.index } }, data);\n break;\n case Operations.REMOVE:\n operations.push({ delete: { _id, _index: oldImage.index } });\n break;\n default:\n break;\n }\n }\n\n if (!operations.length) {\n return false;\n }\n\n try {\n const res = await context.elasticsearch.bulk<BulkOperationsResponseBody>({\n body: operations\n });\n checkErrors(res);\n if (process.env.DEBUG === \"true\") {\n console.log(\"Bulk response\", JSON.stringify(res, null, 2));\n }\n } catch (error) {\n if (process.env.DEBUG === \"true\") {\n console.log(\"Bulk error\", JSON.stringify(error, null, 2));\n }\n throw error;\n }\n\n return true;\n }\n});\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAGA;;IAGKA,U;;WAAAA,U;EAAAA,U;EAAAA,U;EAAAA,U;GAAAA,U,KAAAA,U;;AAoBL,MAAMC,QAAQ,GAAIC,IAAD,IAAyD;EACtE,IAAI,CAACA,IAAI,CAACC,KAAN,IAAe,CAACD,IAAI,CAACC,KAAL,CAAWC,KAA3B,IAAoC,CAACF,IAAI,CAACC,KAAL,CAAWC,KAAX,CAAiBC,MAA1D,EAAkE;IAC9D,OAAO,IAAP;EACH;;EACD,MAAMA,MAAM,GAAGH,IAAI,CAACC,KAAL,CAAWC,KAAX,CAAiBC,MAAhC;;EACA,IAAIA,MAAM,CAACC,KAAP,CAAa,oCAAb,MAAuD,IAA3D,EAAiE;IAC7D,OAAO,OAAP;EACH;;EACD,OAAOD,MAAP;AACH,CATD;;AAWA,MAAME,WAAW,GAAIC,MAAD,IAA4D;EAC5E,IAAI,CAACA,MAAD,IAAW,CAACA,MAAM,CAACC,IAAnB,IAA2B,CAACD,MAAM,CAACC,IAAP,CAAYC,KAA5C,EAAmD;IAC/C;EACH;;EACD,KAAK,MAAMR,IAAX,IAAmBM,MAAM,CAACC,IAAP,CAAYC,KAA/B,EAAsC;IAClC,MAAMC,GAAG,GAAGV,QAAQ,CAACC,IAAD,CAApB;;IACA,IAAI,CAACS,GAAL,EAAU;MACN;IACH,CAFD,MAEO,IAAIA,GAAG,KAAK,OAAZ,EAAqB;MACxB,IAAIC,OAAO,CAACC,GAAR,CAAYC,KAAZ,KAAsB,MAA1B,EAAkC;QAC9BC,OAAO,CAACC,GAAR,CAAY,eAAZ,EAA6BC,IAAI,CAACC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