@webiny/api-elasticsearch-tasks 5.41.4-beta.3 → 5.41.4-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/definitions/entry.d.ts +6 -2
- package/definitions/entry.js +9 -2
- package/definitions/entry.js.map +1 -1
- package/package.json +23 -23
- package/tasks/Manager.d.ts +6 -8
- package/tasks/Manager.js +0 -6
- package/tasks/Manager.js.map +1 -1
- package/tasks/reindexing/ReindexingTaskRunner.js +8 -4
- package/tasks/reindexing/ReindexingTaskRunner.js.map +1 -1
- package/types.d.ts +12 -13
- package/types.js.map +1 -1
package/definitions/entry.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* TODO If adding GSIs to the Elasticsearch table, add them here.
|
|
3
|
+
*/
|
|
4
|
+
import type { TableDef } from "@webiny/db-dynamodb/toolbox";
|
|
5
|
+
import type { IEntity } from "@webiny/db-dynamodb";
|
|
2
6
|
interface Params {
|
|
3
7
|
table: TableDef;
|
|
4
8
|
entityName: string;
|
|
5
9
|
}
|
|
6
|
-
export declare const createEntry: (params: Params) =>
|
|
10
|
+
export declare const createEntry: (params: Params) => IEntity;
|
|
7
11
|
export {};
|
package/definitions/entry.js
CHANGED
|
@@ -4,13 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createEntry = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
8
|
+
/**
|
|
9
|
+
* TODO If adding GSIs to the Elasticsearch table, add them here.
|
|
10
|
+
*/
|
|
11
|
+
|
|
8
12
|
const createEntry = params => {
|
|
9
13
|
const {
|
|
10
14
|
table,
|
|
11
15
|
entityName
|
|
12
16
|
} = params;
|
|
13
|
-
return
|
|
17
|
+
return (0, _dbDynamodb.createEntity)({
|
|
14
18
|
name: entityName,
|
|
15
19
|
table,
|
|
16
20
|
attributes: {
|
|
@@ -27,6 +31,9 @@ const createEntry = params => {
|
|
|
27
31
|
},
|
|
28
32
|
data: {
|
|
29
33
|
type: "map"
|
|
34
|
+
},
|
|
35
|
+
TYPE: {
|
|
36
|
+
type: "string"
|
|
30
37
|
}
|
|
31
38
|
}
|
|
32
39
|
});
|
package/definitions/entry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_dbDynamodb","require","createEntry","params","table","entityName","createEntity","name","attributes","PK","type","partitionKey","SK","sortKey","index","data","TYPE","exports"],"sources":["entry.ts"],"sourcesContent":["/**\n * TODO If adding GSIs to the Elasticsearch table, add them here.\n */\nimport type { TableDef } from \"@webiny/db-dynamodb/toolbox\";\nimport type { IEntity } from \"@webiny/db-dynamodb\";\nimport { createEntity } from \"@webiny/db-dynamodb\";\n\ninterface Params {\n table: TableDef;\n entityName: string;\n}\n\nexport const createEntry = (params: Params): IEntity => {\n const { table, entityName } = params;\n return createEntity({\n name: entityName,\n table,\n attributes: {\n PK: {\n type: \"string\",\n partitionKey: true\n },\n SK: {\n type: \"string\",\n sortKey: true\n },\n index: {\n type: \"string\"\n },\n data: {\n type: \"map\"\n },\n TYPE: {\n type: \"string\"\n }\n }\n });\n};\n"],"mappings":";;;;;;AAKA,IAAAA,WAAA,GAAAC,OAAA;AALA;AACA;AACA;;AAUO,MAAMC,WAAW,GAAIC,MAAc,IAAc;EACpD,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,MAAM;EACpC,OAAO,IAAAG,wBAAY,EAAC;IAChBC,IAAI,EAAEF,UAAU;IAChBD,KAAK;IACLI,UAAU,EAAE;MACRC,EAAE,EAAE;QACAC,IAAI,EAAE,QAAQ;QACdC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAF,IAAI,EAAE,QAAQ;QACdG,OAAO,EAAE;MACb,CAAC;MACDC,KAAK,EAAE;QACHJ,IAAI,EAAE;MACV,CAAC;MACDK,IAAI,EAAE;QACFL,IAAI,EAAE;MACV,CAAC;MACDM,IAAI,EAAE;QACFN,IAAI,EAAE;MACV;IACJ;EACJ,CAAC,CAAC;AACN,CAAC;AAACO,OAAA,CAAAf,WAAA,GAAAA,WAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-elasticsearch-tasks",
|
|
3
|
-
"version": "5.41.4-beta.
|
|
3
|
+
"version": "5.41.4-beta.5",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,15 +13,15 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@babel/runtime": "7.24.1",
|
|
16
|
-
"@webiny/api": "5.41.4-beta.
|
|
17
|
-
"@webiny/api-dynamodb-to-elasticsearch": "5.41.4-beta.
|
|
18
|
-
"@webiny/api-elasticsearch": "5.41.4-beta.
|
|
19
|
-
"@webiny/aws-sdk": "5.41.4-beta.
|
|
20
|
-
"@webiny/db": "5.41.4-beta.
|
|
21
|
-
"@webiny/db-dynamodb": "5.41.4-beta.
|
|
22
|
-
"@webiny/error": "5.41.4-beta.
|
|
23
|
-
"@webiny/tasks": "5.41.4-beta.
|
|
24
|
-
"@webiny/utils": "5.41.4-beta.
|
|
16
|
+
"@webiny/api": "5.41.4-beta.5",
|
|
17
|
+
"@webiny/api-dynamodb-to-elasticsearch": "5.41.4-beta.5",
|
|
18
|
+
"@webiny/api-elasticsearch": "5.41.4-beta.5",
|
|
19
|
+
"@webiny/aws-sdk": "5.41.4-beta.5",
|
|
20
|
+
"@webiny/db": "5.41.4-beta.5",
|
|
21
|
+
"@webiny/db-dynamodb": "5.41.4-beta.5",
|
|
22
|
+
"@webiny/error": "5.41.4-beta.5",
|
|
23
|
+
"@webiny/tasks": "5.41.4-beta.5",
|
|
24
|
+
"@webiny/utils": "5.41.4-beta.5"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@babel/cli": "7.24.1",
|
|
@@ -29,18 +29,18 @@
|
|
|
29
29
|
"@babel/preset-env": "7.24.3",
|
|
30
30
|
"@babel/preset-typescript": "7.24.1",
|
|
31
31
|
"@webiny/api": "0.0.0",
|
|
32
|
-
"@webiny/api-headless-cms": "5.41.4-beta.
|
|
33
|
-
"@webiny/api-i18n": "5.41.4-beta.
|
|
34
|
-
"@webiny/api-security": "5.41.4-beta.
|
|
35
|
-
"@webiny/api-tenancy": "5.41.4-beta.
|
|
36
|
-
"@webiny/api-wcp": "5.41.4-beta.
|
|
37
|
-
"@webiny/cli": "5.41.4-beta.
|
|
38
|
-
"@webiny/handler": "5.41.4-beta.
|
|
39
|
-
"@webiny/handler-aws": "5.41.4-beta.
|
|
40
|
-
"@webiny/handler-db": "5.41.4-beta.
|
|
41
|
-
"@webiny/handler-graphql": "5.41.4-beta.
|
|
42
|
-
"@webiny/plugins": "5.41.4-beta.
|
|
43
|
-
"@webiny/project-utils": "5.41.4-beta.
|
|
32
|
+
"@webiny/api-headless-cms": "5.41.4-beta.5",
|
|
33
|
+
"@webiny/api-i18n": "5.41.4-beta.5",
|
|
34
|
+
"@webiny/api-security": "5.41.4-beta.5",
|
|
35
|
+
"@webiny/api-tenancy": "5.41.4-beta.5",
|
|
36
|
+
"@webiny/api-wcp": "5.41.4-beta.5",
|
|
37
|
+
"@webiny/cli": "5.41.4-beta.5",
|
|
38
|
+
"@webiny/handler": "5.41.4-beta.5",
|
|
39
|
+
"@webiny/handler-aws": "5.41.4-beta.5",
|
|
40
|
+
"@webiny/handler-db": "5.41.4-beta.5",
|
|
41
|
+
"@webiny/handler-graphql": "5.41.4-beta.5",
|
|
42
|
+
"@webiny/plugins": "5.41.4-beta.5",
|
|
43
|
+
"@webiny/project-utils": "5.41.4-beta.5",
|
|
44
44
|
"rimraf": "5.0.5",
|
|
45
45
|
"ttypescript": "1.5.15",
|
|
46
46
|
"type-fest": "2.19.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"build": "yarn webiny run build",
|
|
55
55
|
"watch": "yarn webiny run watch"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "e3f273ea63f0c426c2ddde0794d303bc8ffaa6c4",
|
|
58
58
|
"adio": {
|
|
59
59
|
"ignore": {
|
|
60
60
|
"src": [
|
package/tasks/Manager.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
|
|
2
2
|
import { Client } from "@webiny/api-elasticsearch";
|
|
3
3
|
import { createTable } from "../definitions";
|
|
4
|
-
import { Context, IManager } from "../types";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { ITimer } from "@webiny/handler-aws/utils";
|
|
4
|
+
import type { Context, IManager } from "../types";
|
|
5
|
+
import type { ITaskResponse } from "@webiny/tasks/response/abstractions";
|
|
6
|
+
import type { IIsCloseToTimeoutCallable, ITaskManagerStore } from "@webiny/tasks/runner/abstractions";
|
|
7
|
+
import type { BatchReadItem, IEntity } from "@webiny/db-dynamodb";
|
|
8
|
+
import type { ITimer } from "@webiny/handler-aws/utils";
|
|
10
9
|
export interface ManagerParams<T> {
|
|
11
10
|
context: Context;
|
|
12
11
|
documentClient?: DynamoDBDocument;
|
|
@@ -29,7 +28,6 @@ export declare class Manager<T> implements IManager<T> {
|
|
|
29
28
|
readonly timer: ITimer;
|
|
30
29
|
private readonly entities;
|
|
31
30
|
constructor(params: ManagerParams<T>);
|
|
32
|
-
getEntity(name: string):
|
|
31
|
+
getEntity(name: string): IEntity;
|
|
33
32
|
read<T>(items: BatchReadItem[]): Promise<T[]>;
|
|
34
|
-
write(items: BatchWriteItem[]): Promise<BatchWriteResult>;
|
|
35
33
|
}
|
package/tasks/Manager.js
CHANGED
package/tasks/Manager.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clientDynamodb","require","_apiElasticsearch","_definitions","_entry","_dbDynamodb","Manager","entities","constructor","params","context","documentClient","getDocumentClient","elasticsearch","elasticsearchClient","createElasticsearchClient","endpoint","process","env","ELASTIC_SEARCH_ENDPOINT","table","createTable","isCloseToTimeout","isAborted","response","store","timer","getEntity","name","createEntry","entityName","read","items","batchReadAll","
|
|
1
|
+
{"version":3,"names":["_clientDynamodb","require","_apiElasticsearch","_definitions","_entry","_dbDynamodb","Manager","entities","constructor","params","context","documentClient","getDocumentClient","elasticsearch","elasticsearchClient","createElasticsearchClient","endpoint","process","env","ELASTIC_SEARCH_ENDPOINT","table","createTable","isCloseToTimeout","isAborted","response","store","timer","getEntity","name","createEntry","entityName","read","items","batchReadAll","exports"],"sources":["Manager.ts"],"sourcesContent":["import { DynamoDBDocument, getDocumentClient } from \"@webiny/aws-sdk/client-dynamodb\";\nimport { Client, createElasticsearchClient } from \"@webiny/api-elasticsearch\";\nimport { createTable } from \"~/definitions\";\nimport type { Context, IManager } from \"~/types\";\nimport { createEntry } from \"~/definitions/entry\";\nimport type { ITaskResponse } from \"@webiny/tasks/response/abstractions\";\nimport type {\n IIsCloseToTimeoutCallable,\n ITaskManagerStore\n} from \"@webiny/tasks/runner/abstractions\";\nimport type { BatchReadItem, IEntity } from \"@webiny/db-dynamodb\";\nimport { batchReadAll } from \"@webiny/db-dynamodb\";\nimport type { ITimer } from \"@webiny/handler-aws/utils\";\n\nexport interface ManagerParams<T> {\n context: Context;\n documentClient?: DynamoDBDocument;\n elasticsearchClient?: Client;\n isCloseToTimeout: IIsCloseToTimeoutCallable;\n isAborted: () => boolean;\n response: ITaskResponse;\n store: ITaskManagerStore<T>;\n timer: ITimer;\n}\n\nexport class Manager<T> implements IManager<T> {\n public readonly documentClient: DynamoDBDocument;\n public readonly elasticsearch: Client;\n public readonly context: Context;\n public readonly table: ReturnType<typeof createTable>;\n public readonly isCloseToTimeout: IIsCloseToTimeoutCallable;\n public readonly isAborted: () => boolean;\n public readonly response: ITaskResponse;\n public readonly store: ITaskManagerStore<T>;\n public readonly timer: ITimer;\n\n private readonly entities: Record<string, IEntity> = {};\n\n public constructor(params: ManagerParams<T>) {\n this.context = params.context;\n this.documentClient = params?.documentClient || getDocumentClient();\n\n this.elasticsearch =\n params?.elasticsearchClient ||\n params.context.elasticsearch ||\n createElasticsearchClient({\n endpoint: `https://${process.env.ELASTIC_SEARCH_ENDPOINT}`\n });\n\n this.table = createTable({\n documentClient: this.documentClient\n });\n this.isCloseToTimeout = () => {\n return params.isCloseToTimeout();\n };\n this.isAborted = () => {\n return params.isAborted();\n };\n this.response = params.response;\n this.store = params.store;\n this.timer = params.timer;\n }\n\n public getEntity(name: string): IEntity {\n if (this.entities[name]) {\n return this.entities[name];\n }\n\n return (this.entities[name] = createEntry({\n table: this.table,\n entityName: name\n }));\n }\n\n public async read<T>(items: BatchReadItem[]): Promise<T[]> {\n return await batchReadAll<T>({\n table: this.table,\n items\n });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AAOA,IAAAI,WAAA,GAAAJ,OAAA;AAcO,MAAMK,OAAO,CAA2B;EAW1BC,QAAQ,GAA4B,CAAC,CAAC;EAEhDC,WAAWA,CAACC,MAAwB,EAAE;IACzC,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,cAAc,GAAGF,MAAM,EAAEE,cAAc,IAAI,IAAAC,iCAAiB,EAAC,CAAC;IAEnE,IAAI,CAACC,aAAa,GACdJ,MAAM,EAAEK,mBAAmB,IAC3BL,MAAM,CAACC,OAAO,CAACG,aAAa,IAC5B,IAAAE,2CAAyB,EAAC;MACtBC,QAAQ,EAAG,WAAUC,OAAO,CAACC,GAAG,CAACC,uBAAwB;IAC7D,CAAC,CAAC;IAEN,IAAI,CAACC,KAAK,GAAG,IAAAC,wBAAW,EAAC;MACrBV,cAAc,EAAE,IAAI,CAACA;IACzB,CAAC,CAAC;IACF,IAAI,CAACW,gBAAgB,GAAG,MAAM;MAC1B,OAAOb,MAAM,CAACa,gBAAgB,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,CAACC,SAAS,GAAG,MAAM;MACnB,OAAOd,MAAM,CAACc,SAAS,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,CAACC,QAAQ,GAAGf,MAAM,CAACe,QAAQ;IAC/B,IAAI,CAACC,KAAK,GAAGhB,MAAM,CAACgB,KAAK;IACzB,IAAI,CAACC,KAAK,GAAGjB,MAAM,CAACiB,KAAK;EAC7B;EAEOC,SAASA,CAACC,IAAY,EAAW;IACpC,IAAI,IAAI,CAACrB,QAAQ,CAACqB,IAAI,CAAC,EAAE;MACrB,OAAO,IAAI,CAACrB,QAAQ,CAACqB,IAAI,CAAC;IAC9B;IAEA,OAAQ,IAAI,CAACrB,QAAQ,CAACqB,IAAI,CAAC,GAAG,IAAAC,kBAAW,EAAC;MACtCT,KAAK,EAAE,IAAI,CAACA,KAAK;MACjBU,UAAU,EAAEF;IAChB,CAAC,CAAC;EACN;EAEA,MAAaG,IAAIA,CAAIC,KAAsB,EAAgB;IACvD,OAAO,MAAM,IAAAC,wBAAY,EAAI;MACzBb,KAAK,EAAE,IAAI,CAACA,KAAK;MACjBY;IACJ,CAAC,CAAC;EACN;AACJ;AAACE,OAAA,CAAA5B,OAAA,GAAAA,OAAA","ignoreList":[]}
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.ReindexingTaskRunner = void 0;
|
|
7
7
|
var _scan = require("../../helpers/scan");
|
|
8
|
+
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
8
9
|
const getKeys = results => {
|
|
9
10
|
if (results.lastEvaluatedKey?.PK && results.lastEvaluatedKey?.SK) {
|
|
10
11
|
return {
|
|
@@ -51,7 +52,9 @@ class ReindexingTaskRunner {
|
|
|
51
52
|
await this.indexManager.enableIndexing();
|
|
52
53
|
return this.response.done("No more items to process.");
|
|
53
54
|
}
|
|
54
|
-
const
|
|
55
|
+
const tableWriteBatch = (0, _dbDynamodb.createTableWriteBatch)({
|
|
56
|
+
table: this.manager.table
|
|
57
|
+
});
|
|
55
58
|
for (const item of results.items) {
|
|
56
59
|
/**
|
|
57
60
|
* No index defined? Impossible but let's skip if really happens.
|
|
@@ -88,12 +91,13 @@ class ReindexingTaskRunner {
|
|
|
88
91
|
/**
|
|
89
92
|
* Reindexing will be triggered by the `putBatch` method.
|
|
90
93
|
*/
|
|
91
|
-
|
|
94
|
+
tableWriteBatch.put(entity.entity, {
|
|
92
95
|
...item,
|
|
96
|
+
TYPE: item.TYPE || "unknown",
|
|
93
97
|
modified: new Date().toISOString()
|
|
94
|
-
})
|
|
98
|
+
});
|
|
95
99
|
}
|
|
96
|
-
await
|
|
100
|
+
await tableWriteBatch.execute();
|
|
97
101
|
/**
|
|
98
102
|
* We always store the index settings, so we can restore them later.
|
|
99
103
|
* Also, we always want to store what was the last key we processed, just in case something breaks, so we can continue from this point.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_scan","require","getKeys","results","lastEvaluatedKey","PK","SK","undefined","ReindexingTaskRunner","constructor","manager","indexManager","response","exec","keys","limit","isIndexAllowed","index","input","store","getInput","matching","includes","isCloseToTimeout","isAborted","aborted","scan","table","options","items","length","enableIndexing","done","batch","item","exists","indexExists","addInfoLog","message","entityName","_et","entity","getEntity","disableIndexing","push","putBatch","modified","Date","toISOString","write","updateInput","settings","continue","ex","er","data","error","exports"],"sources":["ReindexingTaskRunner.ts"],"sourcesContent":["import {\n IDynamoDbElasticsearchRecord,\n IElasticsearchIndexingTaskValues,\n IElasticsearchIndexingTaskValuesKeys,\n IManager\n} from \"~/types\";\nimport { ITaskResponse, ITaskResponseResult } from \"@webiny/tasks/response/abstractions\";\nimport { scan } from \"~/helpers/scan\";\nimport { BatchWriteItem, ScanResponse } from \"@webiny/db-dynamodb\";\nimport { IndexManager } from \"~/settings\";\nimport { IIndexManager } from \"~/settings/types\";\n\nconst getKeys = (results: ScanResponse): IElasticsearchIndexingTaskValuesKeys | undefined => {\n if (results.lastEvaluatedKey?.PK && results.lastEvaluatedKey?.SK) {\n return {\n PK: results.lastEvaluatedKey.PK as unknown as string,\n SK: results.lastEvaluatedKey.SK as unknown as string\n };\n }\n return undefined;\n};\n\nexport class ReindexingTaskRunner {\n private readonly manager: IManager<IElasticsearchIndexingTaskValues>;\n private keys?: IElasticsearchIndexingTaskValuesKeys;\n\n private readonly indexManager: IIndexManager;\n private readonly response: ITaskResponse;\n\n public constructor(\n manager: IManager<IElasticsearchIndexingTaskValues>,\n indexManager: IndexManager\n ) {\n this.manager = manager;\n this.response = manager.response;\n this.indexManager = indexManager;\n }\n\n /**\n * When running the task, we always must check:\n * * if task is close to timeout\n * * if task was aborted\n */\n public async exec(\n keys: IElasticsearchIndexingTaskValuesKeys | undefined = undefined,\n limit: number\n ): Promise<ITaskResponseResult> {\n this.keys = keys;\n\n const isIndexAllowed = (index: string): boolean => {\n const input = this.manager.store.getInput();\n if (typeof input.matching !== \"string\" || !input.matching) {\n return true;\n }\n return index.includes(input.matching);\n };\n\n try {\n while (this.manager.isCloseToTimeout() === false) {\n if (this.manager.isAborted()) {\n return this.response.aborted();\n }\n\n const results = await scan<IDynamoDbElasticsearchRecord>({\n table: this.manager.table,\n keys: this.keys,\n options: {\n limit\n }\n });\n if (results.items.length === 0) {\n await this.indexManager.enableIndexing();\n return this.response.done(\"No more items to process.\");\n }\n\n const batch: BatchWriteItem[] = [];\n for (const item of results.items) {\n /**\n * No index defined? Impossible but let's skip if really happens.\n */\n if (!item.index) {\n continue;\n }\n if (isIndexAllowed(item.index) === false) {\n continue;\n }\n const exists = await this.indexManager.indexExists(item.index);\n if (!exists) {\n await this.manager.store.addInfoLog({\n message: `Index \"${item.index}\" does not exist. Skipping the item.`\n });\n continue;\n }\n /**\n * Is there a possibility that entityName does not exist? What do we do at that point?\n */\n const entityName = item._et || item.entity;\n /**\n * Let's skip for now.\n */\n if (!entityName) {\n continue;\n }\n const entity = this.manager.getEntity(entityName);\n /**\n * Disable the indexing for the current index.\n * Method does nothing if indexing is already disabled.\n */\n await this.indexManager.disableIndexing(item.index);\n /**\n * Reindexing will be triggered by the `putBatch` method.\n */\n batch.push(\n entity.putBatch({\n ...item,\n modified: new Date().toISOString()\n })\n );\n }\n await this.manager.write(batch);\n /**\n * We always store the index settings, so we can restore them later.\n * Also, we always want to store what was the last key we processed, just in case something breaks, so we can continue from this point.\n */\n this.keys = getKeys(results);\n await this.manager.store.updateInput({\n settings: this.indexManager.settings,\n keys: this.keys\n });\n /**\n * We want to make sure that, if there are no last evaluated keys, we enable indexing.\n */\n if (!this.keys) {\n await this.indexManager.enableIndexing();\n return this.response.done(\"No more items to process - no last evaluated keys.\");\n }\n }\n return this.response.continue({\n keys: this.keys\n });\n } catch (ex) {\n /**\n * We want to enable indexing if there was an error.\n */\n try {\n await this.indexManager.enableIndexing();\n } catch (er) {\n er.data = ex;\n return this.response.error(er);\n }\n return this.response.error(ex);\n }\n }\n}\n"],"mappings":";;;;;;AAOA,IAAAA,KAAA,GAAAC,OAAA;AAKA,MAAMC,OAAO,GAAIC,OAAqB,IAAuD;EACzF,IAAIA,OAAO,CAACC,gBAAgB,EAAEC,EAAE,IAAIF,OAAO,CAACC,gBAAgB,EAAEE,EAAE,EAAE;IAC9D,OAAO;MACHD,EAAE,EAAEF,OAAO,CAACC,gBAAgB,CAACC,EAAuB;MACpDC,EAAE,EAAEH,OAAO,CAACC,gBAAgB,CAACE;IACjC,CAAC;EACL;EACA,OAAOC,SAAS;AACpB,CAAC;AAEM,MAAMC,oBAAoB,CAAC;EAOvBC,WAAWA,CACdC,OAAmD,EACnDC,YAA0B,EAC5B;IACE,IAAI,CAACD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AC,CAAC;QACF;AAChB;AACA;QACgB,IAAI,CAAC,IAAI,CAACA,IAAI,EAAE;UACZ,MAAM,IAAI,CAACH,YAAY,CAACoB,cAAc,CAAC,CAAC;UACxC,OAAO,IAAI,CAACnB,QAAQ,CAACoB,IAAI,CAAC,oDAAoD,CAAC;QACnF;MACJ;MACA,OAAO,IAAI,CAACpB,QAAQ,CAACwC,QAAQ,CAAC;QAC1BtC,IAAI,EAAE,IAAI,CAACA;MACf,CAAC,CAAC;IACN,CAAC,CAAC,OAAOuC,EAAE,EAAE;MACT;AACZ;AACA;MACY,IAAI;QACA,MAAM,IAAI,CAAC1C,YAAY,CAACoB,cAAc,CAAC,CAAC;MAC5C,CAAC,CAAC,OAAOuB,EAAE,EAAE;QACTA,EAAE,CAACC,IAAI,GAAGF,EAAE;QACZ,OAAO,IAAI,CAACzC,QAAQ,CAAC4C,KAAK,CAACF,EAAE,CAAC;MAClC;MACA,OAAO,IAAI,CAAC1C,QAAQ,CAAC4C,KAAK,CAACH,EAAE,CAAC;IAClC;EACJ;AACJ;AAACI,OAAA,CAAAjD,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_scan","require","_dbDynamodb","getKeys","results","lastEvaluatedKey","PK","SK","undefined","ReindexingTaskRunner","constructor","manager","indexManager","response","exec","keys","limit","isIndexAllowed","index","input","store","getInput","matching","includes","isCloseToTimeout","isAborted","aborted","scan","table","options","items","length","enableIndexing","done","tableWriteBatch","createTableWriteBatch","item","exists","indexExists","addInfoLog","message","entityName","_et","entity","getEntity","disableIndexing","put","TYPE","modified","Date","toISOString","execute","updateInput","settings","continue","ex","er","data","error","exports"],"sources":["ReindexingTaskRunner.ts"],"sourcesContent":["import {\n IDynamoDbElasticsearchRecord,\n IElasticsearchIndexingTaskValues,\n IElasticsearchIndexingTaskValuesKeys,\n IManager\n} from \"~/types\";\nimport { ITaskResponse, ITaskResponseResult } from \"@webiny/tasks/response/abstractions\";\nimport { scan } from \"~/helpers/scan\";\nimport { createTableWriteBatch, ScanResponse } from \"@webiny/db-dynamodb\";\nimport { IndexManager } from \"~/settings\";\nimport { IIndexManager } from \"~/settings/types\";\n\nconst getKeys = (results: ScanResponse): IElasticsearchIndexingTaskValuesKeys | undefined => {\n if (results.lastEvaluatedKey?.PK && results.lastEvaluatedKey?.SK) {\n return {\n PK: results.lastEvaluatedKey.PK as unknown as string,\n SK: results.lastEvaluatedKey.SK as unknown as string\n };\n }\n return undefined;\n};\n\nexport class ReindexingTaskRunner {\n private readonly manager: IManager<IElasticsearchIndexingTaskValues>;\n private keys?: IElasticsearchIndexingTaskValuesKeys;\n\n private readonly indexManager: IIndexManager;\n private readonly response: ITaskResponse;\n\n public constructor(\n manager: IManager<IElasticsearchIndexingTaskValues>,\n indexManager: IndexManager\n ) {\n this.manager = manager;\n this.response = manager.response;\n this.indexManager = indexManager;\n }\n\n /**\n * When running the task, we always must check:\n * * if task is close to timeout\n * * if task was aborted\n */\n public async exec(\n keys: IElasticsearchIndexingTaskValuesKeys | undefined = undefined,\n limit: number\n ): Promise<ITaskResponseResult> {\n this.keys = keys;\n\n const isIndexAllowed = (index: string): boolean => {\n const input = this.manager.store.getInput();\n if (typeof input.matching !== \"string\" || !input.matching) {\n return true;\n }\n return index.includes(input.matching);\n };\n\n try {\n while (this.manager.isCloseToTimeout() === false) {\n if (this.manager.isAborted()) {\n return this.response.aborted();\n }\n\n const results = await scan<IDynamoDbElasticsearchRecord>({\n table: this.manager.table,\n keys: this.keys,\n options: {\n limit\n }\n });\n if (results.items.length === 0) {\n await this.indexManager.enableIndexing();\n return this.response.done(\"No more items to process.\");\n }\n\n const tableWriteBatch = createTableWriteBatch({\n table: this.manager.table\n });\n\n for (const item of results.items) {\n /**\n * No index defined? Impossible but let's skip if really happens.\n */\n if (!item.index) {\n continue;\n }\n if (isIndexAllowed(item.index) === false) {\n continue;\n }\n const exists = await this.indexManager.indexExists(item.index);\n if (!exists) {\n await this.manager.store.addInfoLog({\n message: `Index \"${item.index}\" does not exist. Skipping the item.`\n });\n continue;\n }\n /**\n * Is there a possibility that entityName does not exist? What do we do at that point?\n */\n const entityName = item._et || item.entity;\n /**\n * Let's skip for now.\n */\n if (!entityName) {\n continue;\n }\n const entity = this.manager.getEntity(entityName);\n /**\n * Disable the indexing for the current index.\n * Method does nothing if indexing is already disabled.\n */\n await this.indexManager.disableIndexing(item.index);\n /**\n * Reindexing will be triggered by the `putBatch` method.\n */\n tableWriteBatch.put(entity.entity, {\n ...item,\n TYPE: item.TYPE || \"unknown\",\n modified: new Date().toISOString()\n });\n }\n await tableWriteBatch.execute();\n /**\n * We always store the index settings, so we can restore them later.\n * Also, we always want to store what was the last key we processed, just in case something breaks, so we can continue from this point.\n */\n this.keys = getKeys(results);\n await this.manager.store.updateInput({\n settings: this.indexManager.settings,\n keys: this.keys\n });\n /**\n * We want to make sure that, if there are no last evaluated keys, we enable indexing.\n */\n if (!this.keys) {\n await this.indexManager.enableIndexing();\n return this.response.done(\"No more items to process - no last evaluated keys.\");\n }\n }\n return this.response.continue({\n keys: this.keys\n });\n } catch (ex) {\n /**\n * We want to enable indexing if there was an error.\n */\n try {\n await this.indexManager.enableIndexing();\n } catch (er) {\n er.data = ex;\n return this.response.error(er);\n }\n return this.response.error(ex);\n }\n }\n}\n"],"mappings":";;;;;;AAOA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAIA,MAAME,OAAO,GAAIC,OAAqB,IAAuD;EACzF,IAAIA,OAAO,CAACC,gBAAgB,EAAEC,EAAE,IAAIF,OAAO,CAACC,gBAAgB,EAAEE,EAAE,EAAE;IAC9D,OAAO;MACHD,EAAE,EAAEF,OAAO,CAACC,gBAAgB,CAACC,EAAuB;MACpDC,EAAE,EAAEH,OAAO,CAACC,gBAAgB,CAACE;IACjC,CAAC;EACL;EACA,OAAOC,SAAS;AACpB,CAAC;AAEM,MAAMC,oBAAoB,CAAC;EAOvBC,WAAWA,CACdC,OAAmD,EACnDC,Y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,CAACO,OAAO,CAACS,KAAK,CAACgC,WAAW,CAAC;UACjCC,QAAQ,EAAE,IAAI,CAACzC,YAAY,CAACyC,QAAQ;UACpCtC,IAAI,EAAE,IAAI,CAACA;QACf,CAAC,CAAC;QACF;AAChB;AACA;QACgB,IAAI,CAAC,IAAI,CAACA,IAAI,EAAE;UACZ,MAAM,IAAI,CAACH,YAAY,CAACoB,cAAc,CAAC,CAAC;UACxC,OAAO,IAAI,CAACnB,QAAQ,CAACoB,IAAI,CAAC,oDAAoD,CAAC;QACnF;MACJ;MACA,OAAO,IAAI,CAACpB,QAAQ,CAACyC,QAAQ,CAAC;QAC1BvC,IAAI,EAAE,IAAI,CAACA;MACf,CAAC,CAAC;IACN,CAAC,CAAC,OAAOwC,EAAE,EAAE;MACT;AACZ;AACA;MACY,IAAI;QACA,MAAM,IAAI,CAAC3C,YAAY,CAACoB,cAAc,CAAC,CAAC;MAC5C,CAAC,CAAC,OAAOwB,EAAE,EAAE;QACTA,EAAE,CAACC,IAAI,GAAGF,EAAE;QACZ,OAAO,IAAI,CAAC1C,QAAQ,CAAC6C,KAAK,CAACF,EAAE,CAAC;MAClC;MACA,OAAO,IAAI,CAAC3C,QAAQ,CAAC6C,KAAK,CAACH,EAAE,CAAC;IAClC;EACJ;AACJ;AAACI,OAAA,CAAAlD,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
package/types.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { ElasticsearchContext } from "@webiny/api-elasticsearch/types";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { Client } from "@webiny/api-elasticsearch";
|
|
1
|
+
import type { ElasticsearchContext } from "@webiny/api-elasticsearch/types";
|
|
2
|
+
import type { Context as TasksContext, IIsCloseToTimeoutCallable, ITaskManagerStore, ITaskResponse, ITaskResponseDoneResultOutput } from "@webiny/tasks/types";
|
|
3
|
+
import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
|
|
4
|
+
import type { Client } from "@webiny/api-elasticsearch";
|
|
6
5
|
import { createTable } from "./definitions";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { ITimer } from "@webiny/handler-aws";
|
|
6
|
+
import type { BatchReadItem, IEntity } from "@webiny/db-dynamodb";
|
|
7
|
+
import type { ITimer } from "@webiny/handler-aws";
|
|
8
|
+
import type { GenericRecord } from "@webiny/api/types";
|
|
11
9
|
export interface Context extends ElasticsearchContext, TasksContext {
|
|
12
10
|
}
|
|
13
11
|
export interface IElasticsearchTaskConfig {
|
|
@@ -32,16 +30,17 @@ export interface IElasticsearchIndexingTaskValues {
|
|
|
32
30
|
settings?: IElasticsearchIndexingTaskValuesSettings;
|
|
33
31
|
}
|
|
34
32
|
export interface AugmentedError extends Error {
|
|
35
|
-
data?:
|
|
33
|
+
data?: GenericRecord;
|
|
36
34
|
[key: string]: any;
|
|
37
35
|
}
|
|
38
36
|
export interface IDynamoDbElasticsearchRecord {
|
|
39
37
|
PK: string;
|
|
40
38
|
SK: string;
|
|
39
|
+
TYPE?: string;
|
|
41
40
|
index: string;
|
|
42
41
|
_et?: string;
|
|
43
42
|
entity: string;
|
|
44
|
-
data:
|
|
43
|
+
data: GenericRecord;
|
|
45
44
|
modified: string;
|
|
46
45
|
}
|
|
47
46
|
export interface IManager<T, O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput> {
|
|
@@ -54,6 +53,6 @@ export interface IManager<T, O extends ITaskResponseDoneResultOutput = ITaskResp
|
|
|
54
53
|
readonly response: ITaskResponse<T, O>;
|
|
55
54
|
readonly store: ITaskManagerStore<T>;
|
|
56
55
|
readonly timer: ITimer;
|
|
57
|
-
getEntity: (name: string) =>
|
|
58
|
-
|
|
56
|
+
getEntity: (name: string) => IEntity;
|
|
57
|
+
read<T>(items: BatchReadItem[]): Promise<T[]>;
|
|
59
58
|
}
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { ElasticsearchContext } from \"@webiny/api-elasticsearch/types\";\nimport
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ElasticsearchContext } from \"@webiny/api-elasticsearch/types\";\nimport type {\n Context as TasksContext,\n IIsCloseToTimeoutCallable,\n ITaskManagerStore,\n ITaskResponse,\n ITaskResponseDoneResultOutput\n} from \"@webiny/tasks/types\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport type { Client } from \"@webiny/api-elasticsearch\";\nimport { createTable } from \"~/definitions\";\nimport type { BatchReadItem, IEntity } from \"@webiny/db-dynamodb\";\nimport type { ITimer } from \"@webiny/handler-aws\";\nimport type { GenericRecord } from \"@webiny/api/types\";\n\nexport interface Context extends ElasticsearchContext, TasksContext {}\n\nexport interface IElasticsearchTaskConfig {\n documentClient?: DynamoDBDocument;\n elasticsearchClient?: Client;\n}\n\nexport interface IElasticsearchIndexingTaskValuesKeys {\n PK: string;\n SK: string;\n}\n\nexport interface IIndexSettingsValues {\n numberOfReplicas: number;\n refreshInterval: string;\n}\n\nexport interface IElasticsearchIndexingTaskValuesSettings {\n [key: string]: IIndexSettingsValues;\n}\n\nexport interface IElasticsearchIndexingTaskValues {\n matching?: string;\n limit?: number;\n keys?: IElasticsearchIndexingTaskValuesKeys;\n settings?: IElasticsearchIndexingTaskValuesSettings;\n}\n\nexport interface AugmentedError extends Error {\n data?: GenericRecord;\n [key: string]: any;\n}\n\nexport interface IDynamoDbElasticsearchRecord {\n PK: string;\n SK: string;\n TYPE?: string;\n index: string;\n _et?: string;\n entity: string;\n data: GenericRecord;\n modified: string;\n}\n\nexport interface IManager<\n T,\n O extends ITaskResponseDoneResultOutput = ITaskResponseDoneResultOutput\n> {\n readonly documentClient: DynamoDBDocument;\n readonly elasticsearch: Client;\n readonly context: Context;\n readonly table: ReturnType<typeof createTable>;\n readonly isCloseToTimeout: IIsCloseToTimeoutCallable;\n readonly isAborted: () => boolean;\n readonly response: ITaskResponse<T, O>;\n readonly store: ITaskManagerStore<T>;\n readonly timer: ITimer;\n\n getEntity: (name: string) => IEntity;\n\n read<T>(items: BatchReadItem[]): Promise<T[]>;\n}\n"],"mappings":"","ignoreList":[]}
|