@webiny/api-elasticsearch-tasks 6.3.0-beta.4 → 6.4.0-beta.0
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/abstractions/DbRegistry.js +2 -1
- package/abstractions/DbRegistry.js.map +1 -1
- package/abstractions/OpensearchTenantIndexFactory.js +2 -1
- package/abstractions/OpensearchTenantIndexFactory.js.map +1 -1
- package/abstractions/SynchronizationContext.js +2 -1
- package/abstractions/SynchronizationContext.js.map +1 -1
- package/errors/IndexSettingsGetError.js +10 -9
- package/errors/IndexSettingsGetError.js.map +1 -1
- package/errors/IndexSettingsSetError.js +10 -9
- package/errors/IndexSettingsSetError.js.map +1 -1
- package/errors/IndexingDisableError.js +3 -1
- package/errors/IndexingDisableError.js.map +1 -1
- package/errors/IndexingEnableError.js +3 -1
- package/errors/IndexingEnableError.js.map +1 -1
- package/errors/index.js +0 -2
- package/helpers/getClients.js +9 -10
- package/helpers/getClients.js.map +1 -1
- package/helpers/scan.js +12 -14
- package/helpers/scan.js.map +1 -1
- package/index.js +14 -11
- package/index.js.map +1 -1
- package/package.json +22 -22
- package/settings/DisableIndexing.js +16 -15
- package/settings/DisableIndexing.js.map +1 -1
- package/settings/EnableIndexing.js +16 -15
- package/settings/EnableIndexing.js.map +1 -1
- package/settings/IndexManager.js +67 -79
- package/settings/IndexManager.js.map +1 -1
- package/settings/IndexSettingsManager.js +31 -30
- package/settings/IndexSettingsManager.js.map +1 -1
- package/settings/index.js +0 -2
- package/settings/types.js +0 -3
- package/tasks/Manager.js +23 -24
- package/tasks/Manager.js.map +1 -1
- package/tasks/createIndexes/CreateIndexesTask.js +33 -48
- package/tasks/createIndexes/CreateIndexesTask.js.map +1 -1
- package/tasks/createIndexes/CreateIndexesTaskRunner.js +45 -61
- package/tasks/createIndexes/CreateIndexesTaskRunner.js.map +1 -1
- package/tasks/createIndexes/OnBeforeTrigger.js +28 -41
- package/tasks/createIndexes/OnBeforeTrigger.js.map +1 -1
- package/tasks/createIndexes/createIndex.js +12 -17
- package/tasks/createIndexes/createIndex.js.map +1 -1
- package/tasks/createIndexes/index.js +9 -12
- package/tasks/createIndexes/index.js.map +1 -1
- package/tasks/createIndexes/listIndexes.js +10 -16
- package/tasks/createIndexes/listIndexes.js.map +1 -1
- package/tasks/createIndexes/types.js +0 -3
- package/tasks/dataSynchronization/DataSynchronizationTask.js +52 -64
- package/tasks/dataSynchronization/DataSynchronizationTask.js.map +1 -1
- package/tasks/dataSynchronization/DataSynchronizationTaskRunner.js +31 -39
- package/tasks/dataSynchronization/DataSynchronizationTaskRunner.js.map +1 -1
- package/tasks/dataSynchronization/createFactories.js +4 -7
- package/tasks/dataSynchronization/createFactories.js.map +1 -1
- package/tasks/dataSynchronization/elasticsearch/ElasticsearchFetcher.js +65 -89
- package/tasks/dataSynchronization/elasticsearch/ElasticsearchFetcher.js.map +1 -1
- package/tasks/dataSynchronization/elasticsearch/ElasticsearchSynchronize.js +49 -62
- package/tasks/dataSynchronization/elasticsearch/ElasticsearchSynchronize.js.map +1 -1
- package/tasks/dataSynchronization/elasticsearch/ElasticsearchToDynamoDbSynchronization.js +50 -62
- package/tasks/dataSynchronization/elasticsearch/ElasticsearchToDynamoDbSynchronization.js.map +1 -1
- package/tasks/dataSynchronization/elasticsearch/abstractions/ElasticsearchFetcher.js +0 -3
- package/tasks/dataSynchronization/elasticsearch/abstractions/ElasticsearchSynchronize.js +0 -3
- package/tasks/dataSynchronization/elasticsearch/shouldIgnoreEsResponseError.js +7 -4
- package/tasks/dataSynchronization/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -1
- package/tasks/dataSynchronization/entities/getElasticsearchEntity.js +14 -20
- package/tasks/dataSynchronization/entities/getElasticsearchEntity.js.map +1 -1
- package/tasks/dataSynchronization/entities/getElasticsearchEntityType.js +7 -8
- package/tasks/dataSynchronization/entities/getElasticsearchEntityType.js.map +1 -1
- package/tasks/dataSynchronization/entities/getTable.js +13 -19
- package/tasks/dataSynchronization/entities/getTable.js.map +1 -1
- package/tasks/dataSynchronization/entities/index.js +0 -2
- package/tasks/dataSynchronization/index.js +15 -18
- package/tasks/dataSynchronization/index.js.map +1 -1
- package/tasks/dataSynchronization/types.js +0 -3
- package/tasks/enableIndexing/EnableIndexingTaskRunner.js +27 -35
- package/tasks/enableIndexing/EnableIndexingTaskRunner.js.map +1 -1
- package/tasks/enableIndexing/index.js +23 -33
- package/tasks/enableIndexing/index.js.map +1 -1
- package/tasks/enableIndexing/types.js +0 -3
- package/tasks/index.js +0 -2
- package/tasks/reindexing/ReindexingTaskRunner.js +75 -119
- package/tasks/reindexing/ReindexingTaskRunner.js.map +1 -1
- package/tasks/reindexing/index.js +0 -2
- package/tasks/reindexing/reindexingTaskDefinition.js +25 -40
- package/tasks/reindexing/reindexingTaskDefinition.js.map +1 -1
- package/types.js +0 -3
- package/errors/index.js.map +0 -1
- package/settings/index.js.map +0 -1
- package/settings/types.js.map +0 -1
- package/tasks/createIndexes/types.js.map +0 -1
- package/tasks/dataSynchronization/elasticsearch/abstractions/ElasticsearchFetcher.js.map +0 -1
- package/tasks/dataSynchronization/elasticsearch/abstractions/ElasticsearchSynchronize.js.map +0 -1
- package/tasks/dataSynchronization/entities/index.js.map +0 -1
- package/tasks/dataSynchronization/types.js.map +0 -1
- package/tasks/enableIndexing/types.js.map +0 -1
- package/tasks/index.js.map +0 -1
- package/tasks/reindexing/index.js.map +0 -1
- package/types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"abstractions/DbRegistry.js","sources":["../../src/abstractions/DbRegistry.ts"],"sourcesContent":["import type { Entity } from \"@webiny/db-dynamodb/toolbox.js\";\nimport type { IRegistryItem } from \"@webiny/db\";\nimport { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface IDbRegistry {\n getOneItem<T = Entity>(\n predicate: (item: IRegistryItem) => boolean\n ): {\n item: T;\n };\n}\n\nexport const DbRegistry = createAbstraction<IDbRegistry>(\"DbRegistry\");\nexport namespace DbRegistry {\n export type Interface = IDbRegistry;\n}\n"],"names":["DbRegistry","createAbstraction"],"mappings":";AAYO,MAAMA,aAAaC,kBAA+B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
2
|
+
const OpensearchTenantIndexFactory = createAbstraction("OpensearchTenantIndexFactory");
|
|
3
|
+
export { OpensearchTenantIndexFactory };
|
|
3
4
|
|
|
4
5
|
//# sourceMappingURL=OpensearchTenantIndexFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"abstractions/OpensearchTenantIndexFactory.js","sources":["../../src/abstractions/OpensearchTenantIndexFactory.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { OpenSearchIndexRequestBody } from \"@webiny/api-opensearch/types.js\";\nimport type { Tenant } from \"@webiny/api-core/types/tenancy.js\";\n\nexport interface IOpensearchIndexConfig {\n index: string;\n settings?: Partial<OpenSearchIndexRequestBody>;\n}\n\nexport interface IOpensearchTenantIndexFactory {\n getIndexList(tenant: Pick<Tenant, \"id\">): Promise<IOpensearchIndexConfig[]>;\n}\n\nexport const OpensearchTenantIndexFactory = createAbstraction<IOpensearchTenantIndexFactory>(\n \"OpensearchTenantIndexFactory\"\n);\n\nexport namespace OpensearchTenantIndexFactory {\n export type Interface = IOpensearchTenantIndexFactory;\n export type IndexConfig = IOpensearchIndexConfig;\n}\n"],"names":["OpensearchTenantIndexFactory","createAbstraction"],"mappings":";AAaO,MAAMA,+BAA+BC,kBACxC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
-
|
|
2
|
+
const SynchronizationContext = createAbstraction("SynchronizationContext");
|
|
3
|
+
export { SynchronizationContext };
|
|
3
4
|
|
|
4
5
|
//# sourceMappingURL=SynchronizationContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"abstractions/SynchronizationContext.js","sources":["../../src/abstractions/SynchronizationContext.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { Context } from \"~/types.js\";\n\nexport type ISynchronizationContext = Pick<Context, \"opensearch\"> & {\n elasticsearch: Context[\"opensearch\"];\n};\n\nexport const SynchronizationContext =\n createAbstraction<ISynchronizationContext>(\"SynchronizationContext\");\n\nexport namespace SynchronizationContext {\n export type Interface = ISynchronizationContext;\n}\n"],"names":["SynchronizationContext","createAbstraction"],"mappings":";AAOO,MAAMA,yBACTC,kBAA2C"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import _webiny_error from "@webiny/error";
|
|
2
|
+
class IndexSettingsGetError extends _webiny_error {
|
|
3
|
+
constructor(error, index){
|
|
4
|
+
super(error.message, "GET_INDEX_SETTINGS_ERROR", {
|
|
5
|
+
...error.data,
|
|
6
|
+
index
|
|
7
|
+
});
|
|
8
|
+
this.index = index;
|
|
9
|
+
}
|
|
10
10
|
}
|
|
11
|
+
export { IndexSettingsGetError };
|
|
11
12
|
|
|
12
13
|
//# sourceMappingURL=IndexSettingsGetError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"errors/IndexSettingsGetError.js","sources":["../../src/errors/IndexSettingsGetError.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { AugmentedError } from \"~/types.js\";\n\nexport class IndexSettingsGetError extends WebinyError {\n public readonly index: string;\n\n public constructor(error: AugmentedError, index: string) {\n super(error.message, \"GET_INDEX_SETTINGS_ERROR\", {\n ...error.data,\n index\n });\n this.index = index;\n }\n}\n"],"names":["IndexSettingsGetError","WebinyError","error","index"],"mappings":";AAGO,MAAMA,8BAA8BC;IAGvC,YAAmBC,KAAqB,EAAEC,KAAa,CAAE;QACrD,KAAK,CAACD,MAAM,OAAO,EAAE,4BAA4B;YAC7C,GAAGA,MAAM,IAAI;YACbC;QACJ;QACA,IAAI,CAAC,KAAK,GAAGA;IACjB;AACJ"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import _webiny_error from "@webiny/error";
|
|
2
|
+
class IndexSettingsSetError extends _webiny_error {
|
|
3
|
+
constructor(error, index){
|
|
4
|
+
super(error.message, "SET_INDEX_SETTINGS_ERROR", {
|
|
5
|
+
...error.data,
|
|
6
|
+
index
|
|
7
|
+
});
|
|
8
|
+
this.index = index;
|
|
9
|
+
}
|
|
10
10
|
}
|
|
11
|
+
export { IndexSettingsSetError };
|
|
11
12
|
|
|
12
13
|
//# sourceMappingURL=IndexSettingsSetError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"errors/IndexSettingsSetError.js","sources":["../../src/errors/IndexSettingsSetError.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { AugmentedError } from \"~/types.js\";\n\nexport class IndexSettingsSetError extends WebinyError {\n public readonly index: string;\n\n public constructor(error: AugmentedError, index: string) {\n super(error.message, \"SET_INDEX_SETTINGS_ERROR\", {\n ...error.data,\n index\n });\n this.index = index;\n }\n}\n"],"names":["IndexSettingsSetError","WebinyError","error","index"],"mappings":";AAGO,MAAMA,8BAA8BC;IAGvC,YAAmBC,KAAqB,EAAEC,KAAa,CAAE;QACrD,KAAK,CAACD,MAAM,OAAO,EAAE,4BAA4B;YAC7C,GAAGA,MAAM,IAAI;YACbC;QACJ;QACA,IAAI,CAAC,KAAK,GAAGA;IACjB;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"errors/IndexingDisableError.js","sources":["../../src/errors/IndexingDisableError.ts"],"sourcesContent":["export class IndexingDisableError extends Error {}\n"],"names":["IndexingDisableError","Error"],"mappings":"AAAO,MAAMA,6BAA6BC;AAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"errors/IndexingEnableError.js","sources":["../../src/errors/IndexingEnableError.ts"],"sourcesContent":["export class IndexingEnableError extends Error {}\n"],"names":["IndexingEnableError","Error"],"mappings":"AAAO,MAAMA,4BAA4BC;AAAO"}
|
package/errors/index.js
CHANGED
package/helpers/getClients.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { getDocumentClient } from "@webiny/aws-sdk/client-dynamodb/index.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
function getClients(context, params) {
|
|
3
|
+
const documentClient = params?.documentClient ?? getDocumentClient();
|
|
4
|
+
if (params?.elasticsearchClient) return {
|
|
5
|
+
documentClient,
|
|
6
|
+
elasticsearchClient: params.elasticsearchClient
|
|
7
|
+
};
|
|
5
8
|
return {
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
documentClient,
|
|
10
|
+
elasticsearchClient: context.opensearch
|
|
8
11
|
};
|
|
9
|
-
}
|
|
10
|
-
return {
|
|
11
|
-
documentClient,
|
|
12
|
-
elasticsearchClient: context.opensearch
|
|
13
|
-
};
|
|
14
12
|
}
|
|
13
|
+
export { getClients };
|
|
15
14
|
|
|
16
15
|
//# sourceMappingURL=getClients.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"helpers/getClients.js","sources":["../../src/helpers/getClients.ts"],"sourcesContent":["import { getDocumentClient } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\nimport type { Context, IElasticsearchTaskConfig } from \"~/types.js\";\n\nexport function getClients(context: Context, params?: Partial<IElasticsearchTaskConfig>) {\n const documentClient = params?.documentClient ?? getDocumentClient();\n if (params?.elasticsearchClient) {\n return {\n documentClient,\n elasticsearchClient: params.elasticsearchClient\n };\n }\n\n return {\n documentClient,\n elasticsearchClient: context.opensearch\n };\n}\n"],"names":["getClients","context","params","documentClient","getDocumentClient"],"mappings":";AAGO,SAASA,WAAWC,OAAgB,EAAEC,MAA0C;IACnF,MAAMC,iBAAiBD,QAAQ,kBAAkBE;IACjD,IAAIF,QAAQ,qBACR,OAAO;QACHC;QACA,qBAAqBD,OAAO,mBAAmB;IACnD;IAGJ,OAAO;QACHC;QACA,qBAAqBF,QAAQ,UAAU;IAC3C;AACJ"}
|
package/helpers/scan.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { scan
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
limit: params.options?.limit || 200
|
|
13
|
-
}
|
|
14
|
-
});
|
|
1
|
+
import { scan } from "@webiny/db-dynamodb";
|
|
2
|
+
const scan_scan = async (params)=>{
|
|
3
|
+
const { table, keys } = params;
|
|
4
|
+
return scan({
|
|
5
|
+
table,
|
|
6
|
+
options: {
|
|
7
|
+
...params.options,
|
|
8
|
+
startKey: keys,
|
|
9
|
+
limit: params.options?.limit || 200
|
|
10
|
+
}
|
|
11
|
+
});
|
|
15
12
|
};
|
|
13
|
+
export { scan_scan as scan };
|
|
16
14
|
|
|
17
15
|
//# sourceMappingURL=scan.js.map
|
package/helpers/scan.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"helpers/scan.js","sources":["../../src/helpers/scan.ts"],"sourcesContent":["import type { ScanOptions } from \"@webiny/db-dynamodb\";\nimport { scan as tableScan } from \"@webiny/db-dynamodb\";\nimport type { TableDef } from \"@webiny/db-dynamodb/toolbox.js\";\nimport type { IElasticsearchIndexingTaskValuesKeys } from \"~/types.js\";\n\ninterface Params {\n table: TableDef;\n keys?: IElasticsearchIndexingTaskValuesKeys;\n options?: ScanOptions;\n}\n\nexport const scan = async <T = any>(params: Params) => {\n const { table, keys } = params;\n return tableScan<T>({\n table,\n options: {\n ...params.options,\n startKey: keys,\n limit: params.options?.limit || 200\n }\n });\n};\n"],"names":["scan","params","table","keys","tableScan"],"mappings":";AAWO,MAAMA,YAAO,OAAgBC;IAChC,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAE,GAAGF;IACxB,OAAOG,KAAa;QAChBF;QACA,SAAS;YACL,GAAGD,OAAO,OAAO;YACjB,UAAUE;YACV,OAAOF,OAAO,OAAO,EAAE,SAAS;QACpC;IACJ;AACJ"}
|
package/index.js
CHANGED
|
@@ -2,17 +2,20 @@ import { createContextPlugin } from "@webiny/api";
|
|
|
2
2
|
import { createDataSynchronization, createElasticsearchReindexingTask, createEnableIndexingTask, createIndexesTaskDefinition } from "./tasks/index.js";
|
|
3
3
|
import { DbRegistry } from "./abstractions/DbRegistry.js";
|
|
4
4
|
import { SynchronizationContext } from "./abstractions/SynchronizationContext.js";
|
|
5
|
-
export const createElasticsearchBackgroundTasks = params => {
|
|
6
|
-
return [createContextPlugin(context => {
|
|
7
|
-
// Register DbRegistry abstraction with the actual context.db.registry implementation
|
|
8
|
-
// @ts-expect-error We are going to remove this DB client.
|
|
9
|
-
context.container.registerInstance(DbRegistry, context.db.registry);
|
|
10
|
-
context.container.registerInstance(SynchronizationContext, {
|
|
11
|
-
opensearch: context.opensearch,
|
|
12
|
-
elasticsearch: context.opensearch
|
|
13
|
-
});
|
|
14
|
-
}), createElasticsearchReindexingTask(params), createEnableIndexingTask(params), createIndexesTaskDefinition(params), createDataSynchronization(params)];
|
|
15
|
-
};
|
|
16
5
|
export * from "./abstractions/OpensearchTenantIndexFactory.js";
|
|
6
|
+
const createElasticsearchBackgroundTasks = (params)=>[
|
|
7
|
+
createContextPlugin((context)=>{
|
|
8
|
+
context.container.registerInstance(DbRegistry, context.db.registry);
|
|
9
|
+
context.container.registerInstance(SynchronizationContext, {
|
|
10
|
+
opensearch: context.opensearch,
|
|
11
|
+
elasticsearch: context.opensearch
|
|
12
|
+
});
|
|
13
|
+
}),
|
|
14
|
+
createElasticsearchReindexingTask(params),
|
|
15
|
+
createEnableIndexingTask(params),
|
|
16
|
+
createIndexesTaskDefinition(params),
|
|
17
|
+
createDataSynchronization(params)
|
|
18
|
+
];
|
|
19
|
+
export { createElasticsearchBackgroundTasks };
|
|
17
20
|
|
|
18
21
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { createContextPlugin } from \"@webiny/api\";\nimport {\n createDataSynchronization,\n createElasticsearchReindexingTask,\n createEnableIndexingTask,\n createIndexesTaskDefinition\n} from \"~/tasks/index.js\";\nimport type { PluginCollection } from \"@webiny/plugins/types.js\";\nimport type { Context, IElasticsearchTaskConfig } from \"~/types.js\";\nimport { DbRegistry } from \"~/abstractions/DbRegistry.js\";\nimport { SynchronizationContext } from \"~/abstractions/SynchronizationContext.js\";\n\nexport type CreateElasticsearchBackgroundTasksParams = Partial<IElasticsearchTaskConfig>;\n\nexport const createElasticsearchBackgroundTasks = (\n params?: CreateElasticsearchBackgroundTasksParams\n): PluginCollection => {\n return [\n createContextPlugin<Context>(context => {\n // Register DbRegistry abstraction with the actual context.db.registry implementation\n // @ts-expect-error We are going to remove this DB client.\n context.container.registerInstance(DbRegistry, context.db.registry);\n\n context.container.registerInstance(SynchronizationContext, {\n opensearch: context.opensearch,\n elasticsearch: context.opensearch\n });\n }),\n createElasticsearchReindexingTask(params),\n createEnableIndexingTask(params),\n createIndexesTaskDefinition(params),\n createDataSynchronization(params)\n ];\n};\n\nexport * from \"./abstractions/OpensearchTenantIndexFactory.js\";\n"],"names":["createElasticsearchBackgroundTasks","params","createContextPlugin","context","DbRegistry","SynchronizationContext","createElasticsearchReindexingTask","createEnableIndexingTask","createIndexesTaskDefinition","createDataSynchronization"],"mappings":";;;;;AAcO,MAAMA,qCAAqC,CAC9CC,SAEO;QACHC,oBAA6BC,CAAAA;YAGzBA,QAAQ,SAAS,CAAC,gBAAgB,CAACC,YAAYD,QAAQ,EAAE,CAAC,QAAQ;YAElEA,QAAQ,SAAS,CAAC,gBAAgB,CAACE,wBAAwB;gBACvD,YAAYF,QAAQ,UAAU;gBAC9B,eAAeA,QAAQ,UAAU;YACrC;QACJ;QACAG,kCAAkCL;QAClCM,yBAAyBN;QACzBO,4BAA4BP;QAC5BQ,0BAA0BR;KAC7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-elasticsearch-tasks",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -16,36 +16,36 @@
|
|
|
16
16
|
],
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@webiny/api": "6.
|
|
20
|
-
"@webiny/api-core": "6.
|
|
21
|
-
"@webiny/api-dynamodb-to-elasticsearch": "6.
|
|
22
|
-
"@webiny/api-opensearch": "6.
|
|
23
|
-
"@webiny/aws-sdk": "6.
|
|
24
|
-
"@webiny/db": "6.
|
|
25
|
-
"@webiny/db-dynamodb": "6.
|
|
26
|
-
"@webiny/error": "6.
|
|
27
|
-
"@webiny/feature": "6.
|
|
28
|
-
"@webiny/plugins": "6.
|
|
29
|
-
"@webiny/tasks": "6.
|
|
30
|
-
"@webiny/utils": "6.
|
|
19
|
+
"@webiny/api": "6.4.0-beta.0",
|
|
20
|
+
"@webiny/api-core": "6.4.0-beta.0",
|
|
21
|
+
"@webiny/api-dynamodb-to-elasticsearch": "6.4.0-beta.0",
|
|
22
|
+
"@webiny/api-opensearch": "6.4.0-beta.0",
|
|
23
|
+
"@webiny/aws-sdk": "6.4.0-beta.0",
|
|
24
|
+
"@webiny/db": "6.4.0-beta.0",
|
|
25
|
+
"@webiny/db-dynamodb": "6.4.0-beta.0",
|
|
26
|
+
"@webiny/error": "6.4.0-beta.0",
|
|
27
|
+
"@webiny/feature": "6.4.0-beta.0",
|
|
28
|
+
"@webiny/plugins": "6.4.0-beta.0",
|
|
29
|
+
"@webiny/tasks": "6.4.0-beta.0",
|
|
30
|
+
"@webiny/utils": "6.4.0-beta.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@webiny/api": "0.0.0",
|
|
34
|
-
"@webiny/api-headless-cms": "6.
|
|
35
|
-
"@webiny/build-tools": "6.
|
|
36
|
-
"@webiny/handler": "6.
|
|
37
|
-
"@webiny/handler-aws": "6.
|
|
38
|
-
"@webiny/handler-db": "6.
|
|
39
|
-
"@webiny/handler-graphql": "6.
|
|
40
|
-
"@webiny/project-utils": "6.
|
|
34
|
+
"@webiny/api-headless-cms": "6.4.0-beta.0",
|
|
35
|
+
"@webiny/build-tools": "6.4.0-beta.0",
|
|
36
|
+
"@webiny/handler": "6.4.0-beta.0",
|
|
37
|
+
"@webiny/handler-aws": "6.4.0-beta.0",
|
|
38
|
+
"@webiny/handler-db": "6.4.0-beta.0",
|
|
39
|
+
"@webiny/handler-graphql": "6.4.0-beta.0",
|
|
40
|
+
"@webiny/project-utils": "6.4.0-beta.0",
|
|
41
41
|
"rimraf": "6.1.3",
|
|
42
42
|
"type-fest": "5.6.0",
|
|
43
43
|
"typescript": "6.0.3",
|
|
44
|
-
"vitest": "4.1.
|
|
44
|
+
"vitest": "4.1.6"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public",
|
|
48
48
|
"directory": "dist"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "a545d7529828af07d08d49c3da1bcb967483b9ce"
|
|
51
51
|
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { IndexingDisableError } from "../errors/index.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
class DisableIndexing {
|
|
3
|
+
constructor(settings){
|
|
4
|
+
this.settings = settings;
|
|
5
|
+
}
|
|
6
|
+
async exec(index) {
|
|
7
|
+
const settings = await this.settings.getSettings(index);
|
|
8
|
+
try {
|
|
9
|
+
await this.settings.setSettings(index, {
|
|
10
|
+
numberOfReplicas: 0,
|
|
11
|
+
refreshInterval: "-1"
|
|
12
|
+
});
|
|
13
|
+
} catch (ex) {
|
|
14
|
+
throw new IndexingDisableError(ex);
|
|
15
|
+
}
|
|
16
|
+
return settings;
|
|
15
17
|
}
|
|
16
|
-
return settings;
|
|
17
|
-
}
|
|
18
18
|
}
|
|
19
|
+
export { DisableIndexing };
|
|
19
20
|
|
|
20
21
|
//# sourceMappingURL=DisableIndexing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"settings/DisableIndexing.js","sources":["../../src/settings/DisableIndexing.ts"],"sourcesContent":["import { IndexingDisableError } from \"~/errors/index.js\";\nimport type { IIndexSettingsValues } from \"~/types.js\";\nimport type { IndexSettingsManager } from \"./IndexSettingsManager.js\";\n\nexport class DisableIndexing {\n private readonly settings: IndexSettingsManager;\n\n public constructor(settings: IndexSettingsManager) {\n this.settings = settings;\n }\n\n public async exec(index: string): Promise<IIndexSettingsValues> {\n const settings = await this.settings.getSettings(index);\n\n try {\n await this.settings.setSettings(index, {\n numberOfReplicas: 0,\n refreshInterval: \"-1\"\n });\n } catch (ex) {\n throw new IndexingDisableError(ex);\n }\n\n return settings;\n }\n}\n"],"names":["DisableIndexing","settings","index","ex","IndexingDisableError"],"mappings":";AAIO,MAAMA;IAGT,YAAmBC,QAA8B,CAAE;QAC/C,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEA,MAAa,KAAKC,KAAa,EAAiC;QAC5D,MAAMD,WAAW,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAACC;QAEjD,IAAI;YACA,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAACA,OAAO;gBACnC,kBAAkB;gBAClB,iBAAiB;YACrB;QACJ,EAAE,OAAOC,IAAI;YACT,MAAM,IAAIC,qBAAqBD;QACnC;QAEA,OAAOF;IACX;AACJ"}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { IndexingEnableError } from "../errors/index.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
class EnableIndexing {
|
|
3
|
+
constructor(settings){
|
|
4
|
+
this.settings = settings;
|
|
5
|
+
}
|
|
6
|
+
async exec(index, settings) {
|
|
7
|
+
try {
|
|
8
|
+
const refreshInterval = parseInt(settings.refreshInterval || "", 10) || 0;
|
|
9
|
+
await this.settings.setSettings(index, {
|
|
10
|
+
...settings,
|
|
11
|
+
numberOfReplicas: settings.numberOfReplicas < 1 ? 1 : settings.numberOfReplicas,
|
|
12
|
+
refreshInterval: refreshInterval <= 0 ? "1s" : settings.refreshInterval
|
|
13
|
+
});
|
|
14
|
+
} catch (ex) {
|
|
15
|
+
throw new IndexingEnableError(ex);
|
|
16
|
+
}
|
|
16
17
|
}
|
|
17
|
-
}
|
|
18
18
|
}
|
|
19
|
+
export { EnableIndexing };
|
|
19
20
|
|
|
20
21
|
//# sourceMappingURL=EnableIndexing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"settings/EnableIndexing.js","sources":["../../src/settings/EnableIndexing.ts"],"sourcesContent":["import { IndexingEnableError } from \"~/errors/index.js\";\nimport type { IIndexSettingsValues } from \"~/types.js\";\nimport type { IndexSettingsManager } from \"./IndexSettingsManager.js\";\n\nexport class EnableIndexing {\n private readonly settings: IndexSettingsManager;\n\n public constructor(settings: IndexSettingsManager) {\n this.settings = settings;\n }\n\n public async exec(index: string, settings: IIndexSettingsValues): Promise<void> {\n try {\n const refreshInterval = parseInt(settings.refreshInterval || \"\", 10) || 0;\n await this.settings.setSettings(index, {\n ...settings,\n numberOfReplicas: settings.numberOfReplicas < 1 ? 1 : settings.numberOfReplicas,\n refreshInterval: refreshInterval <= 0 ? \"1s\" : settings.refreshInterval\n });\n } catch (ex) {\n throw new IndexingEnableError(ex);\n }\n }\n}\n"],"names":["EnableIndexing","settings","index","refreshInterval","parseInt","ex","IndexingEnableError"],"mappings":";AAIO,MAAMA;IAGT,YAAmBC,QAA8B,CAAE;QAC/C,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEA,MAAa,KAAKC,KAAa,EAAED,QAA8B,EAAiB;QAC5E,IAAI;YACA,MAAME,kBAAkBC,SAASH,SAAS,eAAe,IAAI,IAAI,OAAO;YACxE,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAACC,OAAO;gBACnC,GAAGD,QAAQ;gBACX,kBAAkBA,SAAS,gBAAgB,GAAG,IAAI,IAAIA,SAAS,gBAAgB;gBAC/E,iBAAiBE,mBAAmB,IAAI,OAAOF,SAAS,eAAe;YAC3E;QACJ,EAAE,OAAOI,IAAI;YACT,MAAM,IAAIC,oBAAoBD;QAClC;IACJ;AACJ"}
|
package/settings/IndexManager.js
CHANGED
|
@@ -3,91 +3,79 @@ import { DisableIndexing } from "./DisableIndexing.js";
|
|
|
3
3
|
import { EnableIndexing } from "./EnableIndexing.js";
|
|
4
4
|
import { getObjectProperties } from "@webiny/utils";
|
|
5
5
|
const defaultIndexSettings = {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
numberOfReplicas: 1,
|
|
7
|
+
refreshInterval: "1s"
|
|
8
8
|
};
|
|
9
9
|
const indexPrefix = process.env.OPENSEARCH_INDEX_PREFIX || "";
|
|
10
|
-
const filterIndex = item
|
|
11
|
-
|
|
12
|
-
return false;
|
|
13
|
-
|
|
14
|
-
return
|
|
15
|
-
} else if (indexPrefix) {
|
|
16
|
-
return item.startsWith(indexPrefix);
|
|
17
|
-
}
|
|
18
|
-
return true;
|
|
10
|
+
const filterIndex = (item)=>{
|
|
11
|
+
if (!item) return false;
|
|
12
|
+
if (item.startsWith(".")) return false;
|
|
13
|
+
if (indexPrefix) return item.startsWith(indexPrefix);
|
|
14
|
+
return true;
|
|
19
15
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
constructor(client, settings, defaults) {
|
|
25
|
-
const indexSettings = new IndexSettingsManager(client);
|
|
26
|
-
this.client = client;
|
|
27
|
-
this.disable = new DisableIndexing(indexSettings);
|
|
28
|
-
this.enable = new EnableIndexing(indexSettings);
|
|
29
|
-
this._settings = settings;
|
|
30
|
-
this.defaults = {
|
|
31
|
-
refreshInterval: defaults?.refreshInterval || defaultIndexSettings.refreshInterval,
|
|
32
|
-
numberOfReplicas: defaults?.numberOfReplicas || defaultIndexSettings.numberOfReplicas
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
async list() {
|
|
36
|
-
try {
|
|
37
|
-
const response = await this.client.cat.indices({
|
|
38
|
-
format: "json"
|
|
39
|
-
});
|
|
40
|
-
if (!Array.isArray(response.body)) {
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
return response.body.map(item => item.index).filter(index => filterIndex(index));
|
|
44
|
-
} catch (ex) {
|
|
45
|
-
console.error(JSON.stringify({
|
|
46
|
-
message: "Failed to list indices.",
|
|
47
|
-
error: getObjectProperties(ex)
|
|
48
|
-
}));
|
|
49
|
-
return [];
|
|
16
|
+
class IndexManager {
|
|
17
|
+
get settings() {
|
|
18
|
+
return this._settings;
|
|
50
19
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
20
|
+
constructor(client, settings, defaults){
|
|
21
|
+
const indexSettings = new IndexSettingsManager(client);
|
|
22
|
+
this.client = client;
|
|
23
|
+
this.disable = new DisableIndexing(indexSettings);
|
|
24
|
+
this.enable = new EnableIndexing(indexSettings);
|
|
25
|
+
this._settings = settings;
|
|
26
|
+
this.defaults = {
|
|
27
|
+
refreshInterval: defaults?.refreshInterval || defaultIndexSettings.refreshInterval,
|
|
28
|
+
numberOfReplicas: defaults?.numberOfReplicas || defaultIndexSettings.numberOfReplicas
|
|
29
|
+
};
|
|
58
30
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
31
|
+
async list() {
|
|
32
|
+
try {
|
|
33
|
+
const response = await this.client.cat.indices({
|
|
34
|
+
format: "json"
|
|
35
|
+
});
|
|
36
|
+
if (!Array.isArray(response.body)) return [];
|
|
37
|
+
return response.body.map((item)=>item.index).filter((index)=>filterIndex(index));
|
|
38
|
+
} catch (ex) {
|
|
39
|
+
console.error(JSON.stringify({
|
|
40
|
+
message: "Failed to list indices.",
|
|
41
|
+
error: getObjectProperties(ex)
|
|
42
|
+
}));
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async disableIndexing(index) {
|
|
47
|
+
if (this._settings[index]) return this._settings[index];
|
|
48
|
+
const settings = await this.disable.exec(index);
|
|
49
|
+
this._settings[index] = settings;
|
|
50
|
+
return settings;
|
|
51
|
+
}
|
|
52
|
+
async enableIndexing(index) {
|
|
53
|
+
if (!index) {
|
|
54
|
+
const indexes = Object.keys(this._settings);
|
|
55
|
+
for (const index of indexes)await this.enableIndexing(index);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const settings = this._settings[index] || this.defaults;
|
|
59
|
+
await this.enable.exec(index, settings);
|
|
60
|
+
}
|
|
61
|
+
async createIndex(index, settings) {
|
|
62
|
+
await this.client.indices.create({
|
|
63
|
+
index,
|
|
64
|
+
body: settings
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async indexExists(index) {
|
|
68
|
+
const response = await this.client.indices.exists({
|
|
69
|
+
index,
|
|
70
|
+
ignore_unavailable: false,
|
|
71
|
+
allow_no_indices: true,
|
|
72
|
+
include_defaults: true,
|
|
73
|
+
flat_settings: false,
|
|
74
|
+
local: false
|
|
75
|
+
});
|
|
76
|
+
return !!response.body;
|
|
70
77
|
}
|
|
71
|
-
const settings = this._settings[index] || this.defaults;
|
|
72
|
-
await this.enable.exec(index, settings);
|
|
73
|
-
}
|
|
74
|
-
async createIndex(index, settings) {
|
|
75
|
-
await this.client.indices.create({
|
|
76
|
-
index,
|
|
77
|
-
body: settings
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
async indexExists(index) {
|
|
81
|
-
const response = await this.client.indices.exists({
|
|
82
|
-
index,
|
|
83
|
-
ignore_unavailable: false,
|
|
84
|
-
allow_no_indices: true,
|
|
85
|
-
include_defaults: true,
|
|
86
|
-
flat_settings: false,
|
|
87
|
-
local: false
|
|
88
|
-
});
|
|
89
|
-
return !!response.body;
|
|
90
|
-
}
|
|
91
78
|
}
|
|
79
|
+
export { IndexManager };
|
|
92
80
|
|
|
93
81
|
//# sourceMappingURL=IndexManager.js.map
|