@webiny/api-elasticsearch-tasks 5.39.0 → 5.39.1-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/index.js +16 -1
- package/index.js.map +1 -1
- package/package.json +21 -21
- package/settings/IndexManager.d.ts +2 -0
- package/settings/IndexManager.js +17 -0
- package/settings/IndexManager.js.map +1 -1
- package/tasks/createIndexes/CreateElasticsearchIndexTaskPlugin.d.ts +23 -0
- package/tasks/createIndexes/CreateElasticsearchIndexTaskPlugin.js +25 -0
- package/tasks/createIndexes/CreateElasticsearchIndexTaskPlugin.js.map +1 -0
- package/tasks/createIndexes/CreateIndexesTaskRunner.d.ts +9 -0
- package/tasks/createIndexes/CreateIndexesTaskRunner.js +85 -0
- package/tasks/createIndexes/CreateIndexesTaskRunner.js.map +1 -0
- package/tasks/createIndexes/index.d.ts +3 -0
- package/tasks/createIndexes/index.js +49 -0
- package/tasks/createIndexes/index.js.map +1 -0
- package/tasks/createIndexes/types.d.ts +4 -0
- package/tasks/createIndexes/types.js +7 -0
- package/tasks/createIndexes/types.js.map +1 -0
- package/tasks/index.d.ts +1 -0
- package/tasks/index.js +11 -0
- package/tasks/index.js.map +1 -1
- package/tasks/reindexing/reindexingTaskDefinition.js +3 -3
- package/tasks/reindexing/reindexingTaskDefinition.js.map +1 -1
package/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ import { Plugin } from "@webiny/plugins/types";
|
|
|
2
2
|
import { IElasticsearchTaskConfig } from "./types";
|
|
3
3
|
export declare type CreateElasticsearchBackgroundTasksParams = IElasticsearchTaskConfig;
|
|
4
4
|
export declare const createElasticsearchBackgroundTasks: (params?: CreateElasticsearchBackgroundTasksParams) => Plugin[];
|
|
5
|
+
export * from "./tasks/createIndexes/CreateElasticsearchIndexTaskPlugin";
|
package/index.js
CHANGED
|
@@ -3,10 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
createElasticsearchBackgroundTasks: true
|
|
8
|
+
};
|
|
6
9
|
exports.createElasticsearchBackgroundTasks = void 0;
|
|
7
10
|
var _tasks = require("./tasks");
|
|
11
|
+
var _CreateElasticsearchIndexTaskPlugin = require("./tasks/createIndexes/CreateElasticsearchIndexTaskPlugin");
|
|
12
|
+
Object.keys(_CreateElasticsearchIndexTaskPlugin).forEach(function (key) {
|
|
13
|
+
if (key === "default" || key === "__esModule") return;
|
|
14
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
15
|
+
if (key in exports && exports[key] === _CreateElasticsearchIndexTaskPlugin[key]) return;
|
|
16
|
+
Object.defineProperty(exports, key, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return _CreateElasticsearchIndexTaskPlugin[key];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
8
23
|
const createElasticsearchBackgroundTasks = params => {
|
|
9
|
-
return [(0, _tasks.createElasticsearchReindexingTask)(params), (0, _tasks.createEnableIndexingTask)(params)];
|
|
24
|
+
return [(0, _tasks.createElasticsearchReindexingTask)(params), (0, _tasks.createEnableIndexingTask)(params), (0, _tasks.createIndexesTaskDefinition)(params)];
|
|
10
25
|
};
|
|
11
26
|
exports.createElasticsearchBackgroundTasks = createElasticsearchBackgroundTasks;
|
|
12
27
|
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_tasks","require","createElasticsearchBackgroundTasks","params","createElasticsearchReindexingTask","createEnableIndexingTask","
|
|
1
|
+
{"version":3,"names":["_tasks","require","_CreateElasticsearchIndexTaskPlugin","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","createElasticsearchBackgroundTasks","params","createElasticsearchReindexingTask","createEnableIndexingTask","createIndexesTaskDefinition"],"sources":["index.ts"],"sourcesContent":["import {\n createElasticsearchReindexingTask,\n createEnableIndexingTask,\n createIndexesTaskDefinition\n} from \"~/tasks\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport { IElasticsearchTaskConfig } from \"~/types\";\n\nexport type CreateElasticsearchBackgroundTasksParams = IElasticsearchTaskConfig;\n\nexport const createElasticsearchBackgroundTasks = (\n params?: CreateElasticsearchBackgroundTasksParams\n): Plugin[] => {\n return [\n createElasticsearchReindexingTask(params),\n createEnableIndexingTask(params),\n createIndexesTaskDefinition(params)\n ];\n};\n\nexport * from \"~/tasks/createIndexes/CreateElasticsearchIndexTaskPlugin\";\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAoBA,IAAAC,mCAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,mCAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,mCAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,mCAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAVO,MAAMS,kCAAkC,GAC3CC,MAAiD,IACtC;EACX,OAAO,CACH,IAAAC,wCAAiC,EAACD,MAAM,CAAC,EACzC,IAAAE,+BAAwB,EAACF,MAAM,CAAC,EAChC,IAAAG,kCAA2B,EAACH,MAAM,CAAC,CACtC;AACL,CAAC;AAACL,OAAA,CAAAI,kCAAA,GAAAA,kCAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-elasticsearch-tasks",
|
|
3
|
-
"version": "5.39.
|
|
3
|
+
"version": "5.39.1-beta.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,31 +13,31 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@babel/runtime": "7.22.6",
|
|
16
|
-
"@webiny/api
|
|
17
|
-
"@webiny/
|
|
18
|
-
"@webiny/
|
|
19
|
-
"@webiny/
|
|
20
|
-
"@webiny/
|
|
21
|
-
"@webiny/
|
|
16
|
+
"@webiny/api": "5.39.1-beta.1",
|
|
17
|
+
"@webiny/api-elasticsearch": "5.39.1-beta.1",
|
|
18
|
+
"@webiny/aws-sdk": "5.39.1-beta.1",
|
|
19
|
+
"@webiny/db-dynamodb": "5.39.1-beta.1",
|
|
20
|
+
"@webiny/error": "5.39.1-beta.1",
|
|
21
|
+
"@webiny/tasks": "5.39.1-beta.1",
|
|
22
|
+
"@webiny/utils": "5.39.1-beta.1"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
25
|
"@babel/cli": "7.22.6",
|
|
25
26
|
"@babel/core": "7.22.8",
|
|
26
27
|
"@babel/preset-env": "7.22.7",
|
|
27
28
|
"@babel/preset-typescript": "7.22.5",
|
|
28
|
-
"@webiny/api": "5.39.
|
|
29
|
-
"@webiny/api-
|
|
30
|
-
"@webiny/api-
|
|
31
|
-
"@webiny/api-
|
|
32
|
-
"@webiny/api-
|
|
33
|
-
"@webiny/
|
|
34
|
-
"@webiny/
|
|
35
|
-
"@webiny/handler": "5.39.
|
|
36
|
-
"@webiny/handler-
|
|
37
|
-
"@webiny/handler-
|
|
38
|
-
"@webiny/
|
|
39
|
-
"@webiny/
|
|
40
|
-
"@webiny/project-utils": "5.39.0",
|
|
29
|
+
"@webiny/api-headless-cms": "5.39.1-beta.1",
|
|
30
|
+
"@webiny/api-i18n": "5.39.1-beta.1",
|
|
31
|
+
"@webiny/api-security": "5.39.1-beta.1",
|
|
32
|
+
"@webiny/api-tenancy": "5.39.1-beta.1",
|
|
33
|
+
"@webiny/api-wcp": "5.39.1-beta.1",
|
|
34
|
+
"@webiny/cli": "5.39.1-beta.1",
|
|
35
|
+
"@webiny/handler": "5.39.1-beta.1",
|
|
36
|
+
"@webiny/handler-aws": "5.39.1-beta.1",
|
|
37
|
+
"@webiny/handler-db": "5.39.1-beta.1",
|
|
38
|
+
"@webiny/handler-graphql": "5.39.1-beta.1",
|
|
39
|
+
"@webiny/plugins": "5.39.1-beta.1",
|
|
40
|
+
"@webiny/project-utils": "5.39.1-beta.1",
|
|
41
41
|
"rimraf": "3.0.2",
|
|
42
42
|
"ttypescript": "1.5.15",
|
|
43
43
|
"type-fest": "2.19.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"build": "yarn webiny run build",
|
|
52
52
|
"watch": "yarn webiny run watch"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "6fc74b45740bd4123dcf9b5890bfacee594208bf"
|
|
55
55
|
}
|
|
@@ -12,4 +12,6 @@ export declare class IndexManager implements IIndexManager {
|
|
|
12
12
|
list(): Promise<string[]>;
|
|
13
13
|
disableIndexing(index: string): Promise<IIndexSettingsValues>;
|
|
14
14
|
enableIndexing(index?: string): Promise<void>;
|
|
15
|
+
createIndex(index: string, settings?: Record<string, any>): Promise<void>;
|
|
16
|
+
indexExists(index: string): Promise<boolean>;
|
|
15
17
|
}
|
package/settings/IndexManager.js
CHANGED
|
@@ -66,6 +66,23 @@ class IndexManager {
|
|
|
66
66
|
const settings = this._settings[index] || this.defaults;
|
|
67
67
|
await this.enable.exec(index, settings);
|
|
68
68
|
}
|
|
69
|
+
async createIndex(index, settings) {
|
|
70
|
+
await this.client.indices.create({
|
|
71
|
+
index,
|
|
72
|
+
body: settings
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
async indexExists(index) {
|
|
76
|
+
const response = await this.client.indices.exists({
|
|
77
|
+
index,
|
|
78
|
+
ignore_unavailable: false,
|
|
79
|
+
allow_no_indices: true,
|
|
80
|
+
include_defaults: true,
|
|
81
|
+
flat_settings: false,
|
|
82
|
+
local: false
|
|
83
|
+
});
|
|
84
|
+
return !!response.body;
|
|
85
|
+
}
|
|
69
86
|
}
|
|
70
87
|
exports.IndexManager = IndexManager;
|
|
71
88
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_IndexSettingsManager","require","_DisableIndexing","_EnableIndexing","_utils","defaultIndexSettings","numberOfReplicas","refreshInterval","IndexManager","settings","_settings","constructor","client","defaults","indexSettings","IndexSettingsManager","disable","DisableIndexing","enable","EnableIndexing","list","response","cat","indices","format","Array","isArray","body","map","item","index","filter","Boolean","ex","console","error","JSON","stringify","message","getObjectProperties","disableIndexing","exec","enableIndexing","indexes","Object","keys","exports"],"sources":["IndexManager.ts"],"sourcesContent":["import { IndexSettingsManager } from \"~/settings/IndexSettingsManager\";\nimport { DisableIndexing } from \"./DisableIndexing\";\nimport { EnableIndexing } from \"./EnableIndexing\";\nimport { IElasticsearchIndexingTaskValuesSettings, IIndexSettingsValues } from \"~/types\";\nimport { IIndexManager } from \"~/settings/types\";\nimport { Client } from \"@webiny/api-elasticsearch\";\nimport { getObjectProperties } from \"@webiny/utils\";\n\nconst defaultIndexSettings: IIndexSettingsValues = {\n numberOfReplicas: 1,\n refreshInterval: \"1s\"\n};\n\nexport class IndexManager implements IIndexManager {\n private readonly client: Client;\n private readonly disable: DisableIndexing;\n private readonly enable: EnableIndexing;\n private readonly _settings: IElasticsearchIndexingTaskValuesSettings;\n\n private readonly defaults: IIndexSettingsValues;\n\n public get settings(): IElasticsearchIndexingTaskValuesSettings {\n return this._settings;\n }\n\n public constructor(\n client: Client,\n settings: IElasticsearchIndexingTaskValuesSettings,\n defaults?: Partial<IIndexSettingsValues>\n ) {\n const indexSettings = new IndexSettingsManager(client);\n this.client = client;\n this.disable = new DisableIndexing(indexSettings);\n this.enable = new EnableIndexing(indexSettings);\n this._settings = settings;\n this.defaults = {\n refreshInterval: defaults?.refreshInterval || defaultIndexSettings.refreshInterval,\n numberOfReplicas: defaults?.numberOfReplicas || defaultIndexSettings.numberOfReplicas\n };\n }\n\n public async list(): Promise<string[]> {\n try {\n const response = await this.client.cat.indices({\n format: \"json\"\n });\n if (!Array.isArray(response.body)) {\n return [];\n }\n return response.body.map((item: any) => item.index).filter(Boolean);\n } catch (ex) {\n console.error(\n JSON.stringify({\n message: \"Failed to list indices.\",\n error: getObjectProperties(ex)\n })\n );\n return [];\n }\n }\n\n public async disableIndexing(index: string) {\n /**\n * No need to disable indexing if it's already disabled.\n */\n if (this._settings[index]) {\n return this._settings[index];\n }\n const settings = await this.disable.exec(index);\n this._settings[index] = settings;\n return settings;\n }\n\n public async enableIndexing(index?: string) {\n if (!index) {\n const indexes = Object.keys(this._settings);\n for (const index of indexes) {\n await this.enableIndexing(index);\n }\n return;\n }\n const settings = this._settings[index] || this.defaults;\n await this.enable.exec(index, settings);\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAIA,IAAAG,MAAA,GAAAH,OAAA;AAEA,MAAMI,oBAA0C,GAAG;EAC/CC,gBAAgB,EAAE,CAAC;EACnBC,eAAe,EAAE;AACrB,CAAC;AAEM,MAAMC,YAAY,CAA0B;EAQ/C,IAAWC,QAAQA,CAAA,EAA6C;IAC5D,OAAO,IAAI,CAACC,SAAS;EACzB;EAEOC,WAAWA,CACdC,MAAc,EACdH,QAAkD,EAClDI,QAAwC,EAC1C;IACE,MAAMC,aAAa,GAAG,IAAIC,0CAAoB,CAACH,MAAM,CAAC;IACtD,IAAI,CAACA,MAAM,GAAGA,MAAM;IACpB,IAAI,CAACI,OAAO,GAAG,IAAIC,gCAAe,CAACH,aAAa,CAAC;IACjD,IAAI,CAACI,MAAM,GAAG,IAAIC,8BAAc,CAACL,aAAa,CAAC;IA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AAO,GAAGC,MAAM,CAACC,IAAI,CAAC,IAAI,CAACnC,SAAS,CAAC;MAC3C,KAAK,MAAMoB,KAAK,IAAIa,OAAO,EAAE;QACzB,MAAM,IAAI,CAACD,cAAc,CAACZ,KAAK,CAAC;MACpC;MACA;IACJ;IACA,MAAMrB,QAAQ,GAAG,IAAI,CAACC,SAAS,CAACoB,KAAK,CAAC,IAAI,IAAI,CAACjB,QAAQ;IACvD,MAAM,IAAI,CAACK,MAAM,CAACuB,IAAI,CAACX,KAAK,EAAErB,QAAQ,CAAC;EAC3C;AACJ;
|
|
1
|
+
{"version":3,"names":["_IndexSettingsManager","require","_DisableIndexing","_EnableIndexing","_utils","defaultIndexSettings","numberOfReplicas","refreshInterval","IndexManager","settings","_settings","constructor","client","defaults","indexSettings","IndexSettingsManager","disable","DisableIndexing","enable","EnableIndexing","list","response","cat","indices","format","Array","isArray","body","map","item","index","filter","Boolean","ex","console","error","JSON","stringify","message","getObjectProperties","disableIndexing","exec","enableIndexing","indexes","Object","keys","createIndex","create","indexExists","exists","ignore_unavailable","allow_no_indices","include_defaults","flat_settings","local","exports"],"sources":["IndexManager.ts"],"sourcesContent":["import { IndexSettingsManager } from \"~/settings/IndexSettingsManager\";\nimport { DisableIndexing } from \"./DisableIndexing\";\nimport { EnableIndexing } from \"./EnableIndexing\";\nimport { IElasticsearchIndexingTaskValuesSettings, IIndexSettingsValues } from \"~/types\";\nimport { IIndexManager } from \"~/settings/types\";\nimport { Client } from \"@webiny/api-elasticsearch\";\nimport { getObjectProperties } from \"@webiny/utils\";\n\nconst defaultIndexSettings: IIndexSettingsValues = {\n numberOfReplicas: 1,\n refreshInterval: \"1s\"\n};\n\nexport class IndexManager implements IIndexManager {\n private readonly client: Client;\n private readonly disable: DisableIndexing;\n private readonly enable: EnableIndexing;\n private readonly _settings: IElasticsearchIndexingTaskValuesSettings;\n\n private readonly defaults: IIndexSettingsValues;\n\n public get settings(): IElasticsearchIndexingTaskValuesSettings {\n return this._settings;\n }\n\n public constructor(\n client: Client,\n settings: IElasticsearchIndexingTaskValuesSettings,\n defaults?: Partial<IIndexSettingsValues>\n ) {\n const indexSettings = new IndexSettingsManager(client);\n this.client = client;\n this.disable = new DisableIndexing(indexSettings);\n this.enable = new EnableIndexing(indexSettings);\n this._settings = settings;\n this.defaults = {\n refreshInterval: defaults?.refreshInterval || defaultIndexSettings.refreshInterval,\n numberOfReplicas: defaults?.numberOfReplicas || defaultIndexSettings.numberOfReplicas\n };\n }\n\n public async list(): Promise<string[]> {\n try {\n const response = await this.client.cat.indices({\n format: \"json\"\n });\n if (!Array.isArray(response.body)) {\n return [];\n }\n return response.body.map((item: any) => item.index).filter(Boolean);\n } catch (ex) {\n console.error(\n JSON.stringify({\n message: \"Failed to list indices.\",\n error: getObjectProperties(ex)\n })\n );\n return [];\n }\n }\n\n public async disableIndexing(index: string) {\n /**\n * No need to disable indexing if it's already disabled.\n */\n if (this._settings[index]) {\n return this._settings[index];\n }\n const settings = await this.disable.exec(index);\n this._settings[index] = settings;\n return settings;\n }\n\n public async enableIndexing(index?: string) {\n if (!index) {\n const indexes = Object.keys(this._settings);\n for (const index of indexes) {\n await this.enableIndexing(index);\n }\n return;\n }\n const settings = this._settings[index] || this.defaults;\n await this.enable.exec(index, settings);\n }\n\n public async createIndex(index: string, settings?: Record<string, any>): Promise<void> {\n await this.client.indices.create({\n index,\n body: settings\n });\n }\n\n public async indexExists(index: string): Promise<boolean> {\n const response = await this.client.indices.exists({\n index,\n ignore_unavailable: false,\n allow_no_indices: true,\n include_defaults: true,\n flat_settings: false,\n local: false\n });\n return !!response.body;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAIA,IAAAG,MAAA,GAAAH,OAAA;AAEA,MAAMI,oBAA0C,GAAG;EAC/CC,gBAAgB,EAAE,CAAC;EACnBC,eAAe,EAAE;AACrB,CAAC;AA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AC1B;AACJ;AAAC4B,OAAA,CAAA/C,YAAA,GAAAA,YAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import { Context } from "@webiny/api/types";
|
|
3
|
+
import { ElasticsearchIndexRequestBody } from "@webiny/api-elasticsearch/types";
|
|
4
|
+
export interface CreateElasticsearchIndexTaskPluginIndex {
|
|
5
|
+
index: string;
|
|
6
|
+
settings?: Partial<ElasticsearchIndexRequestBody>;
|
|
7
|
+
}
|
|
8
|
+
export interface CreateElasticsearchIndexTaskPluginConfigParams<C extends Context> {
|
|
9
|
+
context: C;
|
|
10
|
+
tenant: string;
|
|
11
|
+
locale: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CreateElasticsearchIndexTaskPluginConfig<C extends Context> {
|
|
14
|
+
name?: string;
|
|
15
|
+
getIndexList(params: CreateElasticsearchIndexTaskPluginConfigParams<C>): Promise<CreateElasticsearchIndexTaskPluginIndex[]>;
|
|
16
|
+
}
|
|
17
|
+
export declare class CreateElasticsearchIndexTaskPlugin<C extends Context> extends Plugin {
|
|
18
|
+
static readonly type: string;
|
|
19
|
+
private readonly config;
|
|
20
|
+
constructor(config: CreateElasticsearchIndexTaskPluginConfig<C>);
|
|
21
|
+
getIndexList(params: CreateElasticsearchIndexTaskPluginConfigParams<C>): Promise<CreateElasticsearchIndexTaskPluginIndex[]>;
|
|
22
|
+
}
|
|
23
|
+
export declare const createElasticsearchIndexTaskPlugin: <C extends Context>(config: CreateElasticsearchIndexTaskPluginConfig<C>) => CreateElasticsearchIndexTaskPlugin<C>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createElasticsearchIndexTaskPlugin = exports.CreateElasticsearchIndexTaskPlugin = void 0;
|
|
7
|
+
var _plugins = require("@webiny/plugins");
|
|
8
|
+
class CreateElasticsearchIndexTaskPlugin extends _plugins.Plugin {
|
|
9
|
+
static type = "elasticsearch.createElasticsearchIndexTaskPlugin";
|
|
10
|
+
constructor(config) {
|
|
11
|
+
super();
|
|
12
|
+
this.name = config.name;
|
|
13
|
+
this.config = config;
|
|
14
|
+
}
|
|
15
|
+
getIndexList(params) {
|
|
16
|
+
return this.config.getIndexList(params);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.CreateElasticsearchIndexTaskPlugin = CreateElasticsearchIndexTaskPlugin;
|
|
20
|
+
const createElasticsearchIndexTaskPlugin = config => {
|
|
21
|
+
return new CreateElasticsearchIndexTaskPlugin(config);
|
|
22
|
+
};
|
|
23
|
+
exports.createElasticsearchIndexTaskPlugin = createElasticsearchIndexTaskPlugin;
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=CreateElasticsearchIndexTaskPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_plugins","require","CreateElasticsearchIndexTaskPlugin","Plugin","type","constructor","config","name","getIndexList","params","exports","createElasticsearchIndexTaskPlugin"],"sources":["CreateElasticsearchIndexTaskPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { Context } from \"@webiny/api/types\";\nimport { ElasticsearchIndexRequestBody } from \"@webiny/api-elasticsearch/types\";\n\nexport interface CreateElasticsearchIndexTaskPluginIndex {\n index: string;\n settings?: Partial<ElasticsearchIndexRequestBody>;\n}\n\nexport interface CreateElasticsearchIndexTaskPluginConfigParams<C extends Context> {\n context: C;\n tenant: string;\n locale: string;\n}\n\nexport interface CreateElasticsearchIndexTaskPluginConfig<C extends Context> {\n name?: string;\n getIndexList(\n params: CreateElasticsearchIndexTaskPluginConfigParams<C>\n ): Promise<CreateElasticsearchIndexTaskPluginIndex[]>;\n}\n\nexport class CreateElasticsearchIndexTaskPlugin<C extends Context> extends Plugin {\n public static override readonly type: string =\n \"elasticsearch.createElasticsearchIndexTaskPlugin\";\n\n private readonly config: CreateElasticsearchIndexTaskPluginConfig<C>;\n\n public constructor(config: CreateElasticsearchIndexTaskPluginConfig<C>) {\n super();\n this.name = config.name;\n this.config = config;\n }\n\n public getIndexList(\n params: CreateElasticsearchIndexTaskPluginConfigParams<C>\n ): Promise<CreateElasticsearchIndexTaskPluginIndex[]> {\n return this.config.getIndexList(params);\n }\n}\n\nexport const createElasticsearchIndexTaskPlugin = <C extends Context>(\n config: CreateElasticsearchIndexTaskPluginConfig<C>\n) => {\n return new CreateElasticsearchIndexTaskPlugin<C>(config);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAsBO,MAAMC,kCAAkC,SAA4BC,eAAM,CAAC;EAC9E,OAAgCC,IAAI,GAChC,kDAAkD;EAI/CC,WAAWA,CAACC,MAAmD,EAAE;IACpE,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,IAAI,GAAGD,MAAM,CAACC,IAAI;IACvB,IAAI,CAACD,MAAM,GAAGA,MAAM;EACxB;EAEOE,YAAYA,CACfC,MAAyD,EACP;IAClD,OAAO,IAAI,CAACH,MAAM,CAACE,YAAY,CAACC,MAAM,CAAC;EAC3C;AACJ;AAACC,OAAA,CAAAR,kCAAA,GAAAA,kCAAA;AAEM,MAAMS,kCAAkC,GAC3CL,MAAmD,IAClD;EACD,OAAO,IAAIJ,kCAAkC,CAAII,MAAM,CAAC;AAC5D,CAAC;AAACI,OAAA,CAAAC,kCAAA,GAAAA,kCAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Manager } from "../Manager";
|
|
2
|
+
import { IndexManager } from "../../settings";
|
|
3
|
+
import { ITaskResponseResult } from "@webiny/tasks";
|
|
4
|
+
export declare class CreateIndexesTaskRunner {
|
|
5
|
+
private readonly manager;
|
|
6
|
+
private readonly indexManager;
|
|
7
|
+
constructor(manager: Manager, indexManager: IndexManager);
|
|
8
|
+
execute(matching: string | undefined, done: string[]): Promise<ITaskResponseResult>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CreateIndexesTaskRunner = void 0;
|
|
7
|
+
var _CreateElasticsearchIndexTaskPlugin = require("./CreateElasticsearchIndexTaskPlugin");
|
|
8
|
+
class CreateIndexesTaskRunner {
|
|
9
|
+
constructor(manager, indexManager) {
|
|
10
|
+
this.manager = manager;
|
|
11
|
+
this.indexManager = indexManager;
|
|
12
|
+
}
|
|
13
|
+
async execute(matching, done) {
|
|
14
|
+
const plugins = this.manager.context.plugins.byType(_CreateElasticsearchIndexTaskPlugin.CreateElasticsearchIndexTaskPlugin.type);
|
|
15
|
+
if (plugins.length === 0) {
|
|
16
|
+
return this.manager.response.done("No index plugins found.");
|
|
17
|
+
}
|
|
18
|
+
const indexes = [];
|
|
19
|
+
const tenants = await this.manager.context.tenancy.listTenants();
|
|
20
|
+
for (const tenant of tenants) {
|
|
21
|
+
const locales = await this.manager.context.i18n.getLocales();
|
|
22
|
+
for (const locale of locales) {
|
|
23
|
+
for (const plugin of plugins) {
|
|
24
|
+
const results = await plugin.getIndexList({
|
|
25
|
+
context: this.manager.context,
|
|
26
|
+
tenant: tenant.id,
|
|
27
|
+
locale: locale.code
|
|
28
|
+
});
|
|
29
|
+
indexes.push(...results);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (indexes.length === 0) {
|
|
34
|
+
return this.manager.response.done("No indexes found.");
|
|
35
|
+
}
|
|
36
|
+
const isIndexAllowed = index => {
|
|
37
|
+
if (typeof matching !== "string" || !matching) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return index.includes(matching);
|
|
41
|
+
};
|
|
42
|
+
for (const {
|
|
43
|
+
index,
|
|
44
|
+
settings
|
|
45
|
+
} of indexes) {
|
|
46
|
+
if (this.manager.isAborted()) {
|
|
47
|
+
return this.manager.response.aborted();
|
|
48
|
+
} else if (this.manager.isCloseToTimeout()) {
|
|
49
|
+
return this.manager.response.continue({
|
|
50
|
+
done
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
if (done.includes(index)) {
|
|
55
|
+
continue;
|
|
56
|
+
} else if (isIndexAllowed(index) === false) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const exists = await this.indexManager.indexExists(index);
|
|
60
|
+
if (exists) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
done.push(index);
|
|
64
|
+
await this.indexManager.createIndex(index, settings);
|
|
65
|
+
await this.manager.store.addInfoLog({
|
|
66
|
+
message: `Index "${index}" created.`,
|
|
67
|
+
data: {
|
|
68
|
+
index
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
} catch (ex) {
|
|
72
|
+
await this.manager.store.addErrorLog({
|
|
73
|
+
message: `Failed to create index "${index}".`,
|
|
74
|
+
error: ex
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return this.manager.response.done("Indexes created.", {
|
|
79
|
+
done
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.CreateIndexesTaskRunner = CreateIndexesTaskRunner;
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=CreateIndexesTaskRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_CreateElasticsearchIndexTaskPlugin","require","CreateIndexesTaskRunner","constructor","manager","indexManager","execute","matching","done","plugins","context","byType","CreateElasticsearchIndexTaskPlugin","type","length","response","indexes","tenants","tenancy","listTenants","tenant","locales","i18n","getLocales","locale","plugin","results","getIndexList","id","code","push","isIndexAllowed","index","includes","settings","isAborted","aborted","isCloseToTimeout","continue","exists","indexExists","createIndex","store","addInfoLog","message","data","ex","addErrorLog","error","exports"],"sources":["CreateIndexesTaskRunner.ts"],"sourcesContent":["import { Manager } from \"~/tasks/Manager\";\nimport { IndexManager } from \"~/settings\";\nimport { ITaskResponseResult } from \"@webiny/tasks\";\nimport {\n CreateElasticsearchIndexTaskPlugin,\n CreateElasticsearchIndexTaskPluginIndex\n} from \"./CreateElasticsearchIndexTaskPlugin\";\nimport { Context } from \"~/types\";\n\nexport class CreateIndexesTaskRunner {\n private readonly manager: Manager;\n private readonly indexManager: IndexManager;\n\n public constructor(manager: Manager, indexManager: IndexManager) {\n this.manager = manager;\n\n this.indexManager = indexManager;\n }\n\n public async execute(\n matching: string | undefined,\n done: string[]\n ): Promise<ITaskResponseResult> {\n const plugins = this.manager.context.plugins.byType<\n CreateElasticsearchIndexTaskPlugin<Context>\n >(CreateElasticsearchIndexTaskPlugin.type);\n if (plugins.length === 0) {\n return this.manager.response.done(\"No index plugins found.\");\n }\n const indexes: CreateElasticsearchIndexTaskPluginIndex[] = [];\n\n const tenants = await this.manager.context.tenancy.listTenants();\n\n for (const tenant of tenants) {\n const locales = await this.manager.context.i18n.getLocales();\n for (const locale of locales) {\n for (const plugin of plugins) {\n const results = await plugin.getIndexList({\n context: this.manager.context,\n tenant: tenant.id,\n locale: locale.code\n });\n indexes.push(...results);\n }\n }\n }\n if (indexes.length === 0) {\n return this.manager.response.done(\"No indexes found.\");\n }\n\n const isIndexAllowed = (index: string): boolean => {\n if (typeof matching !== \"string\" || !matching) {\n return true;\n }\n return index.includes(matching);\n };\n\n for (const { index, settings } of indexes) {\n if (this.manager.isAborted()) {\n return this.manager.response.aborted();\n } else if (this.manager.isCloseToTimeout()) {\n return this.manager.response.continue({\n done\n });\n }\n try {\n if (done.includes(index)) {\n continue;\n } else if (isIndexAllowed(index) === false) {\n continue;\n }\n const exists = await this.indexManager.indexExists(index);\n if (exists) {\n continue;\n }\n done.push(index);\n await this.indexManager.createIndex(index, settings);\n await this.manager.store.addInfoLog({\n message: `Index \"${index}\" created.`,\n data: {\n index\n }\n });\n } catch (ex) {\n await this.manager.store.addErrorLog({\n message: `Failed to create index \"${index}\".`,\n error: ex\n });\n }\n }\n\n return this.manager.response.done(\"Indexes created.\", {\n done\n });\n }\n}\n"],"mappings":";;;;;;AAGA,IAAAA,mCAAA,GAAAC,OAAA;AAMO,MAAMC,uBAAuB,CAAC;EAI1BC,WAAWA,CAACC,OAAgB,EAAEC,YAA0B,EAAE;IAC7D,IAAI,CAACD,OAAO,GAAGA,OAAO;IAEtB,IAAI,CAACC,YAAY,GAAGA,YAAY;EACpC;EAEA,MAAaC,OAAOA,CAChBC,QAA4B,EAC5BC,IAAc,EACc;IAC5B,MAAMC,OAAO,GAAG,IAAI,CAACL,OAAO,CAACM,OAAO,CAACD,OAAO,CAACE,MAAM,CAEjDC,sEAAkC,CAACC,IAAI,CAAC;IAC1C,IAAIJ,OAAO,CAACK,MAAM,KAAK,CAAC,EAAE;MACtB,OAAO,IAAI,CAACV,OAAO,CAACW,QAAQ,CAACP,IAAI,CAAC,yBAAyB,CAAC;IAChE;IACA,MAAMQ,OAAkD,GAAG,EAAE;IAE7D,MAAMC,OAAO,GAAG,MAAM,IAAI,CAACb,OAAO,CAACM,OAAO,CAACQ,OAAO,CAACC,WAAW,CAAC,CAAC;IAEhE,KAAK,MAAMC,MAAM,IAAIH,OAAO,EAAE;MAC1B,MAAMI,OAAO,GAAG,MAAM,IAAI,CAACjB,OAAO,CAACM,OAAO,CAACY,IAAI,CAACC,UAAU,CAAC,CAAC;MAC5D,KAAK,MAAMC,MAAM,IAAIH,OAAO,EAAE;QAC1B,KAAK,MAAMI,MAAM,IAAIhB,OAAO,EAAE;UAC1B,MAAMiB,OAAO,GAAG,MAAMD,MAAM,CAACE,YAAY,CAAC;YACtCjB,OAAO,EAAE,IAAI,CAACN,OAAO,CAACM,OAAO;YAC7BU,MAAM,EAAEA,MAAM,CAACQ,EAAE;YACjBJ,MAAM,EAAEA,MAAM,CAACK;UACnB,CAAC,CAAC;UACFb,OAAO,CAACc,IAAI,CAAC,GAAGJ,OAAO,CAAC;QAC5B;MACJ;IAC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UACJ;QACJ,CAAC,CAAC;MACN,CAAC,CAAC,OAAOc,EAAE,EAAE;QACT,MAAM,IAAI,CAAC1C,OAAO,CAACsC,KAAK,CAACK,WAAW,CAAC;UACjCH,OAAO,EAAG,2BAA0BZ,KAAM,IAAG;UAC7CgB,KAAK,EAAEF;QACX,CAAC,CAAC;MACN;IACJ;IAEA,OAAO,IAAI,CAAC1C,OAAO,CAACW,QAAQ,CAACP,IAAI,CAAC,kBAAkB,EAAE;MAClDA;IACJ,CAAC,CAAC;EACN;AACJ;AAACyC,OAAA,CAAA/C,uBAAA,GAAAA,uBAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Context, IElasticsearchTaskConfig } from "../../types";
|
|
2
|
+
import { IElasticsearchCreateIndexesTaskInput } from "./types";
|
|
3
|
+
export declare const createIndexesTaskDefinition: (params?: IElasticsearchTaskConfig) => import("@webiny/tasks").TaskDefinitionPlugin<Context, IElasticsearchCreateIndexesTaskInput, import("@webiny/tasks").ITaskResponseDoneResultOutput>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createIndexesTaskDefinition = void 0;
|
|
7
|
+
var _tasks = require("@webiny/tasks");
|
|
8
|
+
var _CreateIndexesTaskRunner = require("./CreateIndexesTaskRunner");
|
|
9
|
+
const createIndexesTaskDefinition = params => {
|
|
10
|
+
return (0, _tasks.createTaskDefinition)({
|
|
11
|
+
id: "elasticsearchCreateIndexes",
|
|
12
|
+
title: "Create Missing Elasticsearch Indexes",
|
|
13
|
+
/**
|
|
14
|
+
* Maximum number of iterations before the task goes into the error state.
|
|
15
|
+
* No point in having more than 2 runs, as the create index operations should not even take 1 full run, no matter how much indeexs is there to create.
|
|
16
|
+
*/
|
|
17
|
+
maxIterations: 2,
|
|
18
|
+
run: async ({
|
|
19
|
+
response,
|
|
20
|
+
context,
|
|
21
|
+
isCloseToTimeout,
|
|
22
|
+
isAborted,
|
|
23
|
+
store,
|
|
24
|
+
input
|
|
25
|
+
}) => {
|
|
26
|
+
const {
|
|
27
|
+
Manager
|
|
28
|
+
} = await import( /* webpackChunkName: "ElasticsearchTaskManager" */"../Manager");
|
|
29
|
+
const {
|
|
30
|
+
IndexManager
|
|
31
|
+
} = await import( /* webpackChunkName: "ElasticsearchTaskSettings" */"../../settings");
|
|
32
|
+
const manager = new Manager({
|
|
33
|
+
elasticsearchClient: params?.elasticsearchClient,
|
|
34
|
+
documentClient: params?.documentClient,
|
|
35
|
+
response,
|
|
36
|
+
context,
|
|
37
|
+
isAborted,
|
|
38
|
+
isCloseToTimeout,
|
|
39
|
+
store
|
|
40
|
+
});
|
|
41
|
+
const indexManager = new IndexManager(manager.elasticsearch, {});
|
|
42
|
+
const createIndexesTaskRunner = new _CreateIndexesTaskRunner.CreateIndexesTaskRunner(manager, indexManager);
|
|
43
|
+
return createIndexesTaskRunner.execute(input.matching, Array.from(input.done || []));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
exports.createIndexesTaskDefinition = createIndexesTaskDefinition;
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_tasks","require","_CreateIndexesTaskRunner","createIndexesTaskDefinition","params","createTaskDefinition","id","title","maxIterations","run","response","context","isCloseToTimeout","isAborted","store","input","Manager","IndexManager","manager","elasticsearchClient","documentClient","indexManager","elasticsearch","createIndexesTaskRunner","CreateIndexesTaskRunner","execute","matching","Array","from","done","exports"],"sources":["index.ts"],"sourcesContent":["import { createTaskDefinition } from \"@webiny/tasks\";\nimport { Context, IElasticsearchTaskConfig } from \"~/types\";\nimport { IElasticsearchCreateIndexesTaskInput } from \"~/tasks/createIndexes/types\";\nimport { CreateIndexesTaskRunner } from \"./CreateIndexesTaskRunner\";\n\nexport const createIndexesTaskDefinition = (params?: IElasticsearchTaskConfig) => {\n return createTaskDefinition<Context, IElasticsearchCreateIndexesTaskInput>({\n id: \"elasticsearchCreateIndexes\",\n title: \"Create Missing Elasticsearch Indexes\",\n /**\n * Maximum number of iterations before the task goes into the error state.\n * No point in having more than 2 runs, as the create index operations should not even take 1 full run, no matter how much indeexs is there to create.\n */\n maxIterations: 2,\n run: async ({ response, context, isCloseToTimeout, isAborted, store, input }) => {\n const { Manager } = await import(\n /* webpackChunkName: \"ElasticsearchTaskManager\" */\n \"../Manager\"\n );\n const { IndexManager } = await import(\n /* webpackChunkName: \"ElasticsearchTaskSettings\" */ \"~/settings\"\n );\n\n const manager = new Manager({\n elasticsearchClient: params?.elasticsearchClient,\n documentClient: params?.documentClient,\n response,\n context,\n isAborted,\n isCloseToTimeout,\n store\n });\n\n const indexManager = new IndexManager(manager.elasticsearch, {});\n\n const createIndexesTaskRunner = new CreateIndexesTaskRunner(manager, indexManager);\n\n return createIndexesTaskRunner.execute(input.matching, Array.from(input.done || []));\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,wBAAA,GAAAD,OAAA;AAEO,MAAME,2BAA2B,GAAIC,MAAiC,IAAK;EAC9E,OAAO,IAAAC,2BAAoB,EAAgD;IACvEC,EAAE,EAAE,4BAA4B;IAChCC,KAAK,EAAE,sCAAsC;IAC7C;AACR;AACA;AACA;IACQC,aAAa,EAAE,CAAC;IAChBC,GAAG,EAAE,MAAAA,CAAO;MAAEC,QAAQ;MAAEC,OAAO;MAAEC,gBAAgB;MAAEC,SAAS;MAAEC,KAAK;MAAEC;IAAM,CAAC,KAAK;MAC7E,MAAM;QAAEC;MAAQ,CAAC,GAAG,MAAM,MAAM,EAC5B,8DAEJ,CAAC;MACD,MAAM;QAAEC;MAAa,CAAC,GAAG,MAAM,MAAM,EACjC,mEACJ,CAAC;MAED,MAAMC,OAAO,GAAG,IAAIF,OAAO,CAAC;QACxBG,mBAAmB,EAAEf,MAAM,EAAEe,mBAAmB;QAChDC,cAAc,EAAEhB,MAAM,EAAEgB,cAAc;QACtCV,QAAQ;QACRC,OAAO;QACPE,SAAS;QACTD,gBAAgB;QAChBE;MACJ,CAAC,CAAC;MAEF,MAAMO,YAAY,GAAG,IAAIJ,YAAY,CAACC,OAAO,CAACI,aAAa,EAAE,CAAC,CAAC,CAAC;MAEhE,MAAMC,uBAAuB,GAAG,IAAIC,gDAAuB,CAACN,OAAO,EAAEG,YAAY,CAAC;MAElF,OAAOE,uBAAuB,CAACE,OAAO,CAACV,KAAK,CAACW,QAAQ,EAAEC,KAAK,CAACC,IAAI,CAACb,KAAK,CAACc,IAAI,IAAI,EAAE,CAAC,CAAC;IACxF;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAA3B,2BAAA,GAAAA,2BAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export interface IElasticsearchCreateIndexesTaskInput {\n matching?: string;\n done?: string[];\n}\n"],"mappings":""}
|
package/tasks/index.d.ts
CHANGED
package/tasks/index.js
CHANGED
|
@@ -25,5 +25,16 @@ Object.keys(_reindexing).forEach(function (key) {
|
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
+
var _createIndexes = require("./createIndexes");
|
|
29
|
+
Object.keys(_createIndexes).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _createIndexes[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _createIndexes[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
28
39
|
|
|
29
40
|
//# sourceMappingURL=index.js.map
|
package/tasks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_enableIndexing","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_reindexing"],"sources":["index.ts"],"sourcesContent":["export * from \"./enableIndexing\";\nexport * from \"./reindexing\";\n"],"mappings":";;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,eAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,eAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,eAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,WAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,WAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,WAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,WAAA,CAAAL,GAAA;IAAA;EAAA;AAAA"}
|
|
1
|
+
{"version":3,"names":["_enableIndexing","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_reindexing","_createIndexes"],"sources":["index.ts"],"sourcesContent":["export * from \"./enableIndexing\";\nexport * from \"./reindexing\";\nexport * from \"./createIndexes\";\n"],"mappings":";;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,eAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,eAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,eAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,WAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,WAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,WAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,WAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,cAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,cAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,cAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,cAAA,CAAAN,GAAA;IAAA;EAAA;AAAA"}
|
|
@@ -19,13 +19,13 @@ const createElasticsearchReindexingTask = params => {
|
|
|
19
19
|
}) => {
|
|
20
20
|
const {
|
|
21
21
|
Manager
|
|
22
|
-
} = await import("../Manager");
|
|
22
|
+
} = await import( /* webpackChunkName: "ApiElasticsearchTasksReindexingManager" */"../Manager");
|
|
23
23
|
const {
|
|
24
24
|
IndexManager
|
|
25
|
-
} = await import("../../settings");
|
|
25
|
+
} = await import( /* webpackChunkName: "ApiElasticsearchTasksReindexingSettings" */"../../settings");
|
|
26
26
|
const {
|
|
27
27
|
ReindexingTaskRunner
|
|
28
|
-
} = await import("./ReindexingTaskRunner");
|
|
28
|
+
} = await import( /* webpackChunkName: "ApiElasticsearchTasksReindexingTaskRunner" */"./ReindexingTaskRunner");
|
|
29
29
|
const manager = new Manager({
|
|
30
30
|
elasticsearchClient: params?.elasticsearchClient,
|
|
31
31
|
documentClient: params?.documentClient,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_tasks","require","createElasticsearchReindexingTask","params","createTaskDefinition","id","title","run","context","isCloseToTimeout","response","input","isAborted","store","Manager","IndexManager","ReindexingTaskRunner","manager","elasticsearchClient","documentClient","indexManager","elasticsearch","settings","reindexing","keys","undefined","exec","exports"],"sources":["reindexingTaskDefinition.ts"],"sourcesContent":["import { createTaskDefinition } from \"@webiny/tasks\";\nimport { Context, IElasticsearchIndexingTaskValues, IElasticsearchTaskConfig } from \"~/types\";\n\nexport const createElasticsearchReindexingTask = (params?: IElasticsearchTaskConfig) => {\n return createTaskDefinition<Context, IElasticsearchIndexingTaskValues>({\n id: \"elasticsearchReindexing\",\n title: \"Elasticsearch reindexing\",\n run: async ({ context, isCloseToTimeout, response, input, isAborted, store }) => {\n const { Manager } = await import(\"../Manager\");\n const { IndexManager } = await import(\"~/settings\");\n const { ReindexingTaskRunner } = await import(\"./ReindexingTaskRunner\");\n\n const manager = new Manager({\n elasticsearchClient: params?.elasticsearchClient,\n documentClient: params?.documentClient,\n response,\n context,\n isAborted,\n isCloseToTimeout,\n store\n });\n\n const indexManager = new IndexManager(manager.elasticsearch, input.settings || {});\n const reindexing = new ReindexingTaskRunner(manager, indexManager);\n\n const keys = input.keys || undefined;\n return reindexing.exec(keys, 200);\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,iCAAiC,GAAIC,MAAiC,IAAK;EACpF,OAAO,IAAAC,2BAAoB,EAA4C;IACnEC,EAAE,EAAE,yBAAyB;IAC7BC,KAAK,EAAE,0BAA0B;IACjCC,GAAG,EAAE,MAAAA,CAAO;MAAEC,OAAO;MAAEC,gBAAgB;MAAEC,QAAQ;MAAEC,KAAK;MAAEC,SAAS;MAAEC;IAAM,CAAC,KAAK;MAC7E,MAAM;QAAEC;MAAQ,CAAC,GAAG,MAAM,MAAM,
|
|
1
|
+
{"version":3,"names":["_tasks","require","createElasticsearchReindexingTask","params","createTaskDefinition","id","title","run","context","isCloseToTimeout","response","input","isAborted","store","Manager","IndexManager","ReindexingTaskRunner","manager","elasticsearchClient","documentClient","indexManager","elasticsearch","settings","reindexing","keys","undefined","exec","exports"],"sources":["reindexingTaskDefinition.ts"],"sourcesContent":["import { createTaskDefinition } from \"@webiny/tasks\";\nimport { Context, IElasticsearchIndexingTaskValues, IElasticsearchTaskConfig } from \"~/types\";\n\nexport const createElasticsearchReindexingTask = (params?: IElasticsearchTaskConfig) => {\n return createTaskDefinition<Context, IElasticsearchIndexingTaskValues>({\n id: \"elasticsearchReindexing\",\n title: \"Elasticsearch reindexing\",\n run: async ({ context, isCloseToTimeout, response, input, isAborted, store }) => {\n const { Manager } = await import(\n /* webpackChunkName: \"ApiElasticsearchTasksReindexingManager\" */\n \"../Manager\"\n );\n const { IndexManager } = await import(\n /* webpackChunkName: \"ApiElasticsearchTasksReindexingSettings\" */\n \"~/settings\"\n );\n const { ReindexingTaskRunner } = await import(\n /* webpackChunkName: \"ApiElasticsearchTasksReindexingTaskRunner\" */\n \"./ReindexingTaskRunner\"\n );\n\n const manager = new Manager({\n elasticsearchClient: params?.elasticsearchClient,\n documentClient: params?.documentClient,\n response,\n context,\n isAborted,\n isCloseToTimeout,\n store\n });\n\n const indexManager = new IndexManager(manager.elasticsearch, input.settings || {});\n const reindexing = new ReindexingTaskRunner(manager, indexManager);\n\n const keys = input.keys || undefined;\n return reindexing.exec(keys, 200);\n }\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,iCAAiC,GAAIC,MAAiC,IAAK;EACpF,OAAO,IAAAC,2BAAoB,EAA4C;IACnEC,EAAE,EAAE,yBAAyB;IAC7BC,KAAK,EAAE,0BAA0B;IACjCC,GAAG,EAAE,MAAAA,CAAO;MAAEC,OAAO;MAAEC,gBAAgB;MAAEC,QAAQ;MAAEC,KAAK;MAAEC,SAAS;MAAEC;IAAM,CAAC,KAAK;MAC7E,MAAM;QAAEC;MAAQ,CAAC,GAAG,MAAM,MAAM,EAC5B,4EAEJ,CAAC;MACD,MAAM;QAAEC;MAAa,CAAC,GAAG,MAAM,MAAM,EACjC,iFAEJ,CAAC;MACD,MAAM;QAAEC;MAAqB,CAAC,GAAG,MAAM,MAAM,EACzC,2FAEJ,CAAC;MAED,MAAMC,OAAO,GAAG,IAAIH,OAAO,CAAC;QACxBI,mBAAmB,EAAEf,MAAM,EAAEe,mBAAmB;QAChDC,cAAc,EAAEhB,MAAM,EAAEgB,cAAc;QACtCT,QAAQ;QACRF,OAAO;QACPI,SAAS;QACTH,gBAAgB;QAChBI;MACJ,CAAC,CAAC;MAEF,MAAMO,YAAY,GAAG,IAAIL,YAAY,CAACE,OAAO,CAACI,aAAa,EAAEV,KAAK,CAACW,QAAQ,IAAI,CAAC,CAAC,CAAC;MAClF,MAAMC,UAAU,GAAG,IAAIP,oBAAoB,CAACC,OAAO,EAAEG,YAAY,CAAC;MAElE,MAAMI,IAAI,GAAGb,KAAK,CAACa,IAAI,IAAIC,SAAS;MACpC,OAAOF,UAAU,CAACG,IAAI,CAACF,IAAI,EAAE,GAAG,CAAC;IACrC;EACJ,CAAC,CAAC;AACN,CAAC;AAACG,OAAA,CAAAzB,iCAAA,GAAAA,iCAAA"}
|