@webiny/api-dynamodb-to-elasticsearch 5.34.6 → 5.34.7-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.js CHANGED
@@ -68,7 +68,7 @@ const checkErrors = result => {
68
68
  continue;
69
69
  }
70
70
 
71
- console.log(item.error);
71
+ console.error(item.error);
72
72
  throw new _error.default(err, "DYNAMODB_TO_ELASTICSEARCH_ERROR", item);
73
73
  }
74
74
  };
@@ -81,7 +81,7 @@ const createEventHandler = () => {
81
81
  const context = ctx;
82
82
 
83
83
  if (!context.elasticsearch) {
84
- console.log("Missing elasticsearch definition on context.");
84
+ console.error("Missing elasticsearch definition on context.");
85
85
  return null;
86
86
  }
87
87
  /**
@@ -132,7 +132,7 @@ const createEventHandler = () => {
132
132
  */
133
133
 
134
134
  if (data === undefined || data === null) {
135
- console.log(`Could not get decompressed data, skipping ES operation "${operation}", ID ${_id}`);
135
+ console.error(`Could not get decompressed data, skipping ES operation "${operation}", ID ${_id}`);
136
136
  continue;
137
137
  }
138
138
  }
@@ -175,7 +175,7 @@ const createEventHandler = () => {
175
175
  if (process.env.DEBUG === "true") {
176
176
  const meta = (error === null || error === void 0 ? void 0 : error.meta) || {};
177
177
  delete meta["meta"];
178
- console.log("Bulk error", JSON.stringify(meta, null, 2));
178
+ console.error("Bulk error", JSON.stringify(meta, null, 2));
179
179
  }
180
180
 
181
181
  throw error;
@@ -199,8 +199,8 @@ const createEventHandler = () => {
199
199
  return;
200
200
  }
201
201
 
202
- console.log(`Attempt #${error.attemptNumber} failed.`);
203
- console.log(error.message);
202
+ console.error(`Attempt #${error.attemptNumber} failed.`);
203
+ console.error(error.message);
204
204
  }
205
205
  });
206
206
  return null;
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["Operations","getError","item","index","error","reason","match","getNumberEnvVariable","name","def","input","process","env","value","Number","checkErrors","result","body","items","err","DEBUG","console","log","JSON","stringify","WebinyError","createEventHandler","createDynamoDBEventHandler","event","context","ctx","elasticsearch","execute","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","meta","maxRetryTime","retries","minTimeout","maxTimeout","pRetry","onFailedAttempt","attemptNumber","message"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Converter } from \"aws-sdk/clients/dynamodb\";\nimport { decompress } from \"@webiny/api-elasticsearch\";\nimport { ApiResponse, ElasticsearchContext } from \"@webiny/api-elasticsearch/types\";\nimport { createDynamoDBEventHandler } from \"@webiny/handler-aws\";\nimport { StreamRecord } from \"aws-lambda/trigger/dynamodb-stream\";\nimport pRetry from \"p-retry\";\n\nenum Operations {\n INSERT = \"INSERT\",\n MODIFY = \"MODIFY\",\n REMOVE = \"REMOVE\"\n}\n\ninterface BulkOperationsResponseBodyItemIndexError {\n reason?: string;\n}\n\ninterface BulkOperationsResponseBodyItemIndex {\n error?: BulkOperationsResponseBodyItemIndexError;\n}\n\ninterface BulkOperationsResponseBodyItem {\n index?: BulkOperationsResponseBodyItemIndex;\n error?: string;\n}\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 getNumberEnvVariable = (name: string, def: number): number => {\n const input = process.env[name];\n const value = Number(input);\n if (value > 0) {\n return value;\n }\n return def;\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\n /**\n * Wrap the code we need to run into the function, so it can be called within itself.\n */\n const execute = async (): Promise<void> => {\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;\n }\n\n try {\n const res = await context.elasticsearch.bulk<BulkOperationsResponseBody>({\n body: operations\n });\n checkErrors(res);\n } catch (error) {\n if (process.env.DEBUG === \"true\") {\n const meta = error?.meta || {};\n delete meta[\"meta\"];\n console.log(\"Bulk error\", JSON.stringify(meta, null, 2));\n }\n throw error;\n }\n };\n\n const maxRetryTime = getNumberEnvVariable(\n \"WEBINY_DYNAMODB_TO_ELASTICSEARCH_MAX_RETRY_TIME\",\n 300000\n );\n const retries = getNumberEnvVariable(\"WEBINY_DYNAMODB_TO_ELASTICSEARCH_RETRIES\", 20);\n const minTimeout = getNumberEnvVariable(\n \"WEBINY_DYNAMODB_TO_ELASTICSEARCH_MIN_TIMEOUT\",\n 1500\n );\n const maxTimeout = getNumberEnvVariable(\n \"WEBINY_DYNAMODB_TO_ELASTICSEARCH_MAX_TIMEOUT\",\n 30000\n );\n\n await pRetry(execute, {\n maxRetryTime,\n retries,\n minTimeout,\n maxTimeout,\n onFailedAttempt: error => {\n /**\n * We will only log attempts which are after 3/4 of total attempts.\n */\n if (error.attemptNumber < retries * 0.75) {\n return;\n }\n console.log(`Attempt #${error.attemptNumber} failed.`);\n console.log(error.message);\n }\n });\n\n return null;\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEA;;IAEKA,U;;WAAAA,U;EAAAA,U;EAAAA,U;EAAAA,U;GAAAA,U,KAAAA,U;;AAuBL,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,KAA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AC,0CAAD,EAA6C,EAA7C,CAApC;IACA,MAAM4D,UAAU,GAAG5D,oBAAoB,CACnC,8CADmC,EAEnC,IAFmC,CAAvC;IAIA,MAAM6D,UAAU,GAAG7D,oBAAoB,CACnC,8CADmC,EAEnC,KAFmC,CAAvC;IAKA,MAAM,IAAA8D,eAAA,EAAOrC,OAAP,EAAgB;MAClBiC,YADkB;MAElBC,OAFkB;MAGlBC,UAHkB;MAIlBC,UAJkB;MAKlBE,eAAe,EAAElE,KAAK,IAAI;QACtB;AAChB;AACA;QACgB,IAAIA,KAAK,CAACmE,aAAN,GAAsBL,OAAO,GAAG,IAApC,EAA0C;UACtC;QACH;;QACD7C,OAAO,CAACC,GAAR,CAAa,YAAWlB,KAAK,CAACmE,aAAc,UAA5C;QACAlD,OAAO,CAACC,GAAR,CAAYlB,KAAK,CAACoE,OAAlB;MACH;IAdiB,CAAhB,CAAN;IAiBA,OAAO,IAAP;EACH,CAtHM,CAAP;AAuHH,CAxHM"}
1
+ {"version":3,"names":["Operations","getError","item","index","error","reason","match","getNumberEnvVariable","name","def","input","process","env","value","Number","checkErrors","result","body","items","err","DEBUG","console","log","JSON","stringify","WebinyError","createEventHandler","createDynamoDBEventHandler","event","context","ctx","elasticsearch","execute","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","meta","maxRetryTime","retries","minTimeout","maxTimeout","pRetry","onFailedAttempt","attemptNumber","message"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Converter } from \"aws-sdk/clients/dynamodb\";\nimport { decompress } from \"@webiny/api-elasticsearch\";\nimport { ApiResponse, ElasticsearchContext } from \"@webiny/api-elasticsearch/types\";\nimport { createDynamoDBEventHandler } from \"@webiny/handler-aws\";\nimport { StreamRecord } from \"aws-lambda/trigger/dynamodb-stream\";\nimport pRetry from \"p-retry\";\n\nenum Operations {\n INSERT = \"INSERT\",\n MODIFY = \"MODIFY\",\n REMOVE = \"REMOVE\"\n}\n\ninterface BulkOperationsResponseBodyItemIndexError {\n reason?: string;\n}\n\ninterface BulkOperationsResponseBodyItemIndex {\n error?: BulkOperationsResponseBodyItemIndexError;\n}\n\ninterface BulkOperationsResponseBodyItem {\n index?: BulkOperationsResponseBodyItemIndex;\n error?: string;\n}\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 getNumberEnvVariable = (name: string, def: number): number => {\n const input = process.env[name];\n const value = Number(input);\n if (value > 0) {\n return value;\n }\n return def;\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.error(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.error(\"Missing elasticsearch definition on context.\");\n return null;\n }\n\n /**\n * Wrap the code we need to run into the function, so it can be called within itself.\n */\n const execute = async (): Promise<void> => {\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.error(\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;\n }\n\n try {\n const res = await context.elasticsearch.bulk<BulkOperationsResponseBody>({\n body: operations\n });\n checkErrors(res);\n } catch (error) {\n if (process.env.DEBUG === \"true\") {\n const meta = error?.meta || {};\n delete meta[\"meta\"];\n console.error(\"Bulk error\", JSON.stringify(meta, null, 2));\n }\n throw error;\n }\n };\n\n const maxRetryTime = getNumberEnvVariable(\n \"WEBINY_DYNAMODB_TO_ELASTICSEARCH_MAX_RETRY_TIME\",\n 300000\n );\n const retries = getNumberEnvVariable(\"WEBINY_DYNAMODB_TO_ELASTICSEARCH_RETRIES\", 20);\n const minTimeout = getNumberEnvVariable(\n \"WEBINY_DYNAMODB_TO_ELASTICSEARCH_MIN_TIMEOUT\",\n 1500\n );\n const maxTimeout = getNumberEnvVariable(\n \"WEBINY_DYNAMODB_TO_ELASTICSEARCH_MAX_TIMEOUT\",\n 30000\n );\n\n await pRetry(execute, {\n maxRetryTime,\n retries,\n minTimeout,\n maxTimeout,\n onFailedAttempt: error => {\n /**\n * We will only log attempts which are after 3/4 of total attempts.\n */\n if (error.attemptNumber < retries * 0.75) {\n return;\n }\n console.error(`Attempt #${error.attemptNumber} failed.`);\n console.error(error.message);\n }\n });\n\n return null;\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEA;;IAEKA,U;;WAAAA,U;EAAAA,U;EAAAA,U;EAAAA,U;GAAAA,U,KAAAA,U;;AAuBL,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,oBAAoB,GAAG,CAACC,IAAD,EAAeC,GAAf,KAAuC;EAChE,MAAMC,KAAK,GAAGC,OAAO,CAACC,GAAR,CAAYJ,IAAZ,CAAd;EACA,MAAMK,KAAK,GAAGC,MAAM,CAACJ,KAAD,CAApB;;EACA,IAAIG,KAAK,GAAG,CAAZ,EAAe;IACX,OAAOA,KAAP;EACH;;EACD,OAAOJ,GAAP;AACH,CAPD;;AASA,MAAMM,WAAW,GAAIC,MAAD,IAA4D;EAC5E,IAAI,CAACA,MAAD,IAAW,CAACA,MA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B,KAAR,CAAcA,KAAK,CAACoE,OAApB;MACH;IAdiB,CAAhB,CAAN;IAiBA,OAAO,IAAP;EACH,CAtHM,CAAP;AAuHH,CAxHM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-dynamodb-to-elasticsearch",
3
- "version": "5.34.6",
3
+ "version": "5.34.7-beta.1",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -12,9 +12,9 @@
12
12
  "author": "Webiny Ltd.",
13
13
  "dependencies": {
14
14
  "@babel/runtime": "7.19.0",
15
- "@webiny/api-elasticsearch": "5.34.6",
16
- "@webiny/error": "5.34.6",
17
- "@webiny/handler-aws": "5.34.6",
15
+ "@webiny/api-elasticsearch": "5.34.7-beta.1",
16
+ "@webiny/error": "5.34.7-beta.1",
17
+ "@webiny/handler-aws": "5.34.7-beta.1",
18
18
  "aws-lambda": "1.0.7",
19
19
  "aws-sdk": "2.1230.0",
20
20
  "p-retry": "4.6.2"
@@ -26,9 +26,9 @@
26
26
  "@babel/plugin-transform-runtime": "^7.16.4",
27
27
  "@babel/preset-env": "^7.19.4",
28
28
  "@babel/preset-typescript": "^7.18.6",
29
- "@webiny/cli": "^5.34.6",
30
- "@webiny/plugins": "^5.34.6",
31
- "@webiny/project-utils": "^5.34.6",
29
+ "@webiny/cli": "^5.34.7-beta.1",
30
+ "@webiny/plugins": "^5.34.7-beta.1",
31
+ "@webiny/project-utils": "^5.34.7-beta.1",
32
32
  "typescript": "4.7.4"
33
33
  },
34
34
  "publishConfig": {
@@ -49,5 +49,5 @@
49
49
  ]
50
50
  }
51
51
  },
52
- "gitHead": "b4142ace8452d98c7773e846b0b1fb8164ea80c6"
52
+ "gitHead": "fd29a7876dcb76b7ac4fbc9fb2dd6cf00a011ad4"
53
53
  }