@webiny/api-headless-cms-ddb-es 6.6.0-alpha.0 → 6.6.0-alpha.10
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/CmsDdbEsEntriesEsEntity.d.ts +1 -1
- package/abstractions/CmsDdbEsEntriesEsEntity.js.map +1 -1
- package/debuggerNamespaces.d.ts +12 -0
- package/debuggerNamespaces.js +0 -0
- package/feature.d.ts +6 -0
- package/feature.js +9 -27
- package/feature.js.map +1 -1
- package/operations/entry/DdbEsCreateEntry.d.ts +3 -2
- package/operations/entry/DdbEsCreateEntry.js +7 -4
- package/operations/entry/DdbEsCreateEntry.js.map +1 -1
- package/operations/entry/DdbEsCreateEntryRevisionFrom.d.ts +3 -2
- package/operations/entry/DdbEsCreateEntryRevisionFrom.js +7 -4
- package/operations/entry/DdbEsCreateEntryRevisionFrom.js.map +1 -1
- package/operations/entry/DdbEsDeleteEntryRevision.d.ts +3 -2
- package/operations/entry/DdbEsDeleteEntryRevision.js +7 -4
- package/operations/entry/DdbEsDeleteEntryRevision.js.map +1 -1
- package/operations/entry/DdbEsDeleteMultipleEntries.js +23 -22
- package/operations/entry/DdbEsDeleteMultipleEntries.js.map +1 -1
- package/operations/entry/DdbEsGetPreviousRevision.js +1 -1
- package/operations/entry/DdbEsGetPreviousRevision.js.map +1 -1
- package/operations/entry/DdbEsGetUniqueFieldValues.d.ts +3 -2
- package/operations/entry/DdbEsGetUniqueFieldValues.js +9 -5
- package/operations/entry/DdbEsGetUniqueFieldValues.js.map +1 -1
- package/operations/entry/DdbEsListEntries.d.ts +6 -2
- package/operations/entry/DdbEsListEntries.js +27 -5
- package/operations/entry/DdbEsListEntries.js.map +1 -1
- package/operations/entry/DdbEsMoveEntry.js.map +1 -1
- package/operations/entry/DdbEsMoveToBin.js.map +1 -1
- package/operations/entry/DdbEsPublishEntry.d.ts +3 -2
- package/operations/entry/DdbEsPublishEntry.js +7 -4
- package/operations/entry/DdbEsPublishEntry.js.map +1 -1
- package/operations/entry/DdbEsRestoreFromBin.js.map +1 -1
- package/operations/entry/DdbEsUnpublishEntry.d.ts +3 -2
- package/operations/entry/DdbEsUnpublishEntry.js +7 -4
- package/operations/entry/DdbEsUnpublishEntry.js.map +1 -1
- package/operations/entry/DdbEsUpdateEntry.d.ts +3 -2
- package/operations/entry/DdbEsUpdateEntry.js +7 -4
- package/operations/entry/DdbEsUpdateEntry.js.map +1 -1
- package/operations/entry/feature.js +1 -1
- package/operations/entry/feature.js.map +1 -1
- package/operations/model/DdbEsCreateModel.d.ts +3 -1
- package/operations/model/DdbEsCreateModel.js +8 -4
- package/operations/model/DdbEsCreateModel.js.map +1 -1
- package/operations/model/DdbEsDeleteModel.d.ts +1 -3
- package/operations/model/DdbEsDeleteModel.js +2 -21
- package/operations/model/DdbEsDeleteModel.js.map +1 -1
- package/package.json +27 -27
- package/registry/CmsEntitiesDbRegistryDecorator.d.ts +27 -0
- package/registry/CmsEntitiesDbRegistryDecorator.js +46 -0
- package/registry/CmsEntitiesDbRegistryDecorator.js.map +1 -0
- package/tasks/CreateElasticsearchIndexTask.d.ts +5 -3
- package/tasks/CreateElasticsearchIndexTask.js +25 -25
- package/tasks/CreateElasticsearchIndexTask.js.map +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IOpenSearchEntity } from "@webiny/api-opensearch";
|
|
1
|
+
import type { IOpenSearchEntity } from "@webiny/api-opensearch-aws";
|
|
2
2
|
export declare const CmsDdbEsEntriesEsEntity: import("@webiny/di").Abstraction<IOpenSearchEntity>;
|
|
3
3
|
export declare namespace CmsDdbEsEntriesEsEntity {
|
|
4
4
|
type Interface = IOpenSearchEntity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstractions/CmsDdbEsEntriesEsEntity.js","sources":["../../src/abstractions/CmsDdbEsEntriesEsEntity.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { IOpenSearchEntity } from \"@webiny/api-opensearch\";\n\nexport const CmsDdbEsEntriesEsEntity = createAbstraction<IOpenSearchEntity>(\n \"Cms/DdbEs/EntriesEsEntity\"\n);\n\nexport namespace CmsDdbEsEntriesEsEntity {\n export type Interface = IOpenSearchEntity;\n}\n"],"names":["CmsDdbEsEntriesEsEntity","createAbstraction"],"mappings":";AAGO,MAAMA,0BAA0BC,kBACnC"}
|
|
1
|
+
{"version":3,"file":"abstractions/CmsDdbEsEntriesEsEntity.js","sources":["../../src/abstractions/CmsDdbEsEntriesEsEntity.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { IOpenSearchEntity } from \"@webiny/api-opensearch-aws\";\n\nexport const CmsDdbEsEntriesEsEntity = createAbstraction<IOpenSearchEntity>(\n \"Cms/DdbEs/EntriesEsEntity\"\n);\n\nexport namespace CmsDdbEsEntriesEsEntity {\n export type Interface = IOpenSearchEntity;\n}\n"],"names":["CmsDdbEsEntriesEsEntity","createAbstraction"],"mappings":";AAGO,MAAMA,0BAA0BC,kBACnC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claims the `cms.` debug namespace prefix.
|
|
3
|
+
*
|
|
4
|
+
* The module specifier has to be exactly this one: augmenting a relative path would silently do
|
|
5
|
+
* nothing.
|
|
6
|
+
*/
|
|
7
|
+
declare module "@webiny/api-core/features/debugger/abstractions.js" {
|
|
8
|
+
interface DebugNamespaces {
|
|
9
|
+
cms: `cms.${string}`;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
File without changes
|
package/feature.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DynamoDB+OpenSearch CMS storage. Register it once, in the root container. Tables and entities are
|
|
3
|
+
* built once per process; the storage operations are transient, and per-request state (the entry
|
|
4
|
+
* DataLoaders, the filter registries, the OpenSearch field indexes and model index cache) is
|
|
5
|
+
* container scoped, so each request (child) container gets its own.
|
|
6
|
+
*/
|
|
1
7
|
export declare const HeadlessCmsDdbEsFeature: {
|
|
2
8
|
name: string;
|
|
3
9
|
register(container: import("@webiny/di").Container): void;
|
package/feature.js
CHANGED
|
@@ -1,31 +1,28 @@
|
|
|
1
1
|
import { DynamoDBClient, createTable } from "@webiny/db-dynamodb";
|
|
2
2
|
import { ENTITIES } from "./types.js";
|
|
3
3
|
import { createFeature } from "@webiny/feature/api/index.js";
|
|
4
|
-
import { CmsEntryOpenSearchUtilsFeature } from "@webiny/api-headless-cms-utils-os";
|
|
5
4
|
import { createGroupEntity } from "./definitions/group.js";
|
|
6
5
|
import { createModelEntity } from "./definitions/model.js";
|
|
7
6
|
import { createEntryEntity } from "./definitions/entry.js";
|
|
8
|
-
import { createOpenSearchEntity, createOpenSearchTable } from "@webiny/api-opensearch";
|
|
9
|
-
import { CreateElasticsearchIndexTask } from "./tasks/CreateElasticsearchIndexTask.js";
|
|
10
|
-
import { FilterRegistriesFeature } from "@webiny/api-headless-cms-storage";
|
|
7
|
+
import { createOpenSearchEntity, createOpenSearchTable } from "@webiny/api-opensearch-aws";
|
|
11
8
|
import { FilterUtilFeature } from "@webiny/db-dynamodb/feature/FilterUtil/feature.js";
|
|
12
|
-
import { DbRegistry } from "@webiny/db/exports/api/db.js";
|
|
13
9
|
import { CmsDdbEsTable } from "./abstractions/CmsDdbEsTable.js";
|
|
14
10
|
import { CmsDdbEsOsTable } from "./abstractions/CmsDdbEsOsTable.js";
|
|
15
11
|
import { CmsDdbEsGroupEntity } from "./abstractions/CmsDdbEsGroupEntity.js";
|
|
16
12
|
import { CmsDdbEsModelEntity } from "./abstractions/CmsDdbEsModelEntity.js";
|
|
17
13
|
import { CmsDdbEsEntryEntity } from "./abstractions/CmsDdbEsEntryEntity.js";
|
|
18
14
|
import { CmsDdbEsEntriesEsEntity } from "./abstractions/CmsDdbEsEntriesEsEntity.js";
|
|
15
|
+
import { CmsEntryOpenSearchUtilsFeature } from "@webiny/api-headless-cms-utils-os";
|
|
16
|
+
import { FilterRegistriesFeature } from "@webiny/api-headless-cms-storage";
|
|
17
|
+
import { CreateElasticsearchIndexTask } from "./tasks/CreateElasticsearchIndexTask.js";
|
|
18
|
+
import { CmsEntitiesDbRegistryDecorator } from "./registry/CmsEntitiesDbRegistryDecorator.js";
|
|
19
19
|
import { DdbEsGroupStorageOpsFeature } from "./operations/group/feature.js";
|
|
20
20
|
import { DdbEsModelStorageOpsFeature } from "./operations/model/feature.js";
|
|
21
21
|
import { DdbEsEntryStorageOpsFeature } from "./operations/entry/feature.js";
|
|
22
22
|
const HeadlessCmsDdbEsFeature = createFeature({
|
|
23
23
|
name: "cms.storageOperations.openSearch",
|
|
24
24
|
register: (container)=>{
|
|
25
|
-
CmsEntryOpenSearchUtilsFeature.register(container);
|
|
26
|
-
FilterRegistriesFeature.register(container);
|
|
27
25
|
FilterUtilFeature.register(container);
|
|
28
|
-
container.register(CreateElasticsearchIndexTask);
|
|
29
26
|
const db = container.resolve(DynamoDBClient);
|
|
30
27
|
const documentClient = db.client;
|
|
31
28
|
const tableInstance = createTable({
|
|
@@ -58,25 +55,10 @@ const HeadlessCmsDdbEsFeature = createFeature({
|
|
|
58
55
|
container.registerInstance(CmsDdbEsModelEntity, modelEntity);
|
|
59
56
|
container.registerInstance(CmsDdbEsEntryEntity, entryEntity);
|
|
60
57
|
container.registerInstance(CmsDdbEsEntriesEsEntity, entriesEsEntity);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
app: "cms",
|
|
66
|
-
tags: [
|
|
67
|
-
"regular",
|
|
68
|
-
entryEntity.name
|
|
69
|
-
]
|
|
70
|
-
});
|
|
71
|
-
dbRegistry.register({
|
|
72
|
-
item: entriesEsEntity,
|
|
73
|
-
app: "cms",
|
|
74
|
-
tags: [
|
|
75
|
-
"es",
|
|
76
|
-
entriesEsEntity.name
|
|
77
|
-
]
|
|
78
|
-
});
|
|
79
|
-
} catch {}
|
|
58
|
+
CmsEntryOpenSearchUtilsFeature.register(container);
|
|
59
|
+
FilterRegistriesFeature.register(container);
|
|
60
|
+
container.register(CreateElasticsearchIndexTask);
|
|
61
|
+
container.registerDecorator(CmsEntitiesDbRegistryDecorator);
|
|
80
62
|
DdbEsGroupStorageOpsFeature.register(container);
|
|
81
63
|
DdbEsModelStorageOpsFeature.register(container);
|
|
82
64
|
DdbEsEntryStorageOpsFeature.register(container);
|
package/feature.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.js","sources":["../src/feature.ts"],"sourcesContent":["import { createTable, DynamoDBClient } from \"@webiny/db-dynamodb\";\nimport { ENTITIES } from \"~/types.js\";\nimport { createFeature } from \"@webiny/feature/api/index.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"feature.js","sources":["../src/feature.ts"],"sourcesContent":["import { createTable, DynamoDBClient } from \"@webiny/db-dynamodb\";\nimport { ENTITIES } from \"~/types.js\";\nimport { createFeature } from \"@webiny/feature/api/index.js\";\nimport { createGroupEntity } from \"~/definitions/group.js\";\nimport { createModelEntity } from \"~/definitions/model.js\";\nimport { createEntryEntity } from \"~/definitions/entry.js\";\nimport { createOpenSearchEntity, createOpenSearchTable } from \"@webiny/api-opensearch-aws\";\nimport { FilterUtilFeature } from \"@webiny/db-dynamodb/feature/FilterUtil/feature.js\";\nimport { CmsDdbEsTable } from \"~/abstractions/CmsDdbEsTable.js\";\nimport { CmsDdbEsOsTable } from \"~/abstractions/CmsDdbEsOsTable.js\";\nimport { CmsDdbEsGroupEntity } from \"~/abstractions/CmsDdbEsGroupEntity.js\";\nimport { CmsDdbEsModelEntity } from \"~/abstractions/CmsDdbEsModelEntity.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsEntryOpenSearchUtilsFeature } from \"@webiny/api-headless-cms-utils-os\";\nimport { FilterRegistriesFeature } from \"@webiny/api-headless-cms-storage\";\nimport { CreateElasticsearchIndexTask } from \"~/tasks/CreateElasticsearchIndexTask.js\";\nimport { CmsEntitiesDbRegistryDecorator } from \"~/registry/CmsEntitiesDbRegistryDecorator.js\";\nimport { DdbEsGroupStorageOpsFeature } from \"~/operations/group/feature.js\";\nimport { DdbEsModelStorageOpsFeature } from \"~/operations/model/feature.js\";\nimport { DdbEsEntryStorageOpsFeature } from \"~/operations/entry/feature.js\";\n\n/**\n * DynamoDB+OpenSearch CMS storage. Register it once, in the root container. Tables and entities are\n * built once per process; the storage operations are transient, and per-request state (the entry\n * DataLoaders, the filter registries, the OpenSearch field indexes and model index cache) is\n * container scoped, so each request (child) container gets its own.\n */\nexport const HeadlessCmsDdbEsFeature = createFeature({\n name: \"cms.storageOperations.openSearch\",\n register: container => {\n FilterUtilFeature.register(container);\n\n const db = container.resolve(DynamoDBClient);\n const documentClient = db.client;\n\n const tableInstance = createTable({\n name: process.env.DB_TABLE as string,\n documentClient\n });\n const tableElasticsearchInstance = createOpenSearchTable({\n name: process.env.DB_TABLE_OPENSEARCH as string,\n documentClient\n });\n\n const groupEntity = createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance\n });\n const modelEntity = createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance\n });\n const entryEntity = createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance\n });\n const entriesEsEntity = createOpenSearchEntity({\n entityName: ENTITIES.ENTRIES_ES,\n table: tableElasticsearchInstance\n });\n\n // Register infrastructure instances (app-scoped)\n container.registerInstance(CmsDdbEsTable, tableInstance);\n container.registerInstance(CmsDdbEsOsTable, tableElasticsearchInstance);\n container.registerInstance(CmsDdbEsGroupEntity, groupEntity);\n container.registerInstance(CmsDdbEsModelEntity, modelEntity);\n container.registerInstance(CmsDdbEsEntryEntity, entryEntity);\n container.registerInstance(CmsDdbEsEntriesEsEntity, entriesEsEntity);\n\n CmsEntryOpenSearchUtilsFeature.register(container);\n FilterRegistriesFeature.register(container);\n\n container.register(CreateElasticsearchIndexTask);\n\n // Adds the CMS entities to every request's DbRegistry, for the DDB to OpenSearch sync.\n container.registerDecorator(CmsEntitiesDbRegistryDecorator);\n\n DdbEsGroupStorageOpsFeature.register(container);\n DdbEsModelStorageOpsFeature.register(container);\n DdbEsEntryStorageOpsFeature.register(container);\n }\n});\n"],"names":["HeadlessCmsDdbEsFeature","createFeature","container","FilterUtilFeature","db","DynamoDBClient","documentClient","tableInstance","createTable","process","tableElasticsearchInstance","createOpenSearchTable","groupEntity","createGroupEntity","ENTITIES","modelEntity","createModelEntity","entryEntity","createEntryEntity","entriesEsEntity","createOpenSearchEntity","CmsDdbEsTable","CmsDdbEsOsTable","CmsDdbEsGroupEntity","CmsDdbEsModelEntity","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity","CmsEntryOpenSearchUtilsFeature","FilterRegistriesFeature","CreateElasticsearchIndexTask","CmsEntitiesDbRegistryDecorator","DdbEsGroupStorageOpsFeature","DdbEsModelStorageOpsFeature","DdbEsEntryStorageOpsFeature"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA4BO,MAAMA,0BAA0BC,cAAc;IACjD,MAAM;IACN,UAAUC,CAAAA;QACNC,kBAAkB,QAAQ,CAACD;QAE3B,MAAME,KAAKF,UAAU,OAAO,CAACG;QAC7B,MAAMC,iBAAiBF,GAAG,MAAM;QAEhC,MAAMG,gBAAgBC,YAAY;YAC9B,MAAMC,QAAQ,GAAG,CAAC,QAAQ;YAC1BH;QACJ;QACA,MAAMI,6BAA6BC,sBAAsB;YACrD,MAAMF,QAAQ,GAAG,CAAC,mBAAmB;YACrCH;QACJ;QAEA,MAAMM,cAAcC,kBAAkB;YAClC,YAAYC,SAAS,MAAM;YAC3B,OAAOP;QACX;QACA,MAAMQ,cAAcC,kBAAkB;YAClC,YAAYF,SAAS,MAAM;YAC3B,OAAOP;QACX;QACA,MAAMU,cAAcC,kBAAkB;YAClC,YAAYJ,SAAS,OAAO;YAC5B,OAAOP;QACX;QACA,MAAMY,kBAAkBC,uBAAuB;YAC3C,YAAYN,SAAS,UAAU;YAC/B,OAAOJ;QACX;QAGAR,UAAU,gBAAgB,CAACmB,eAAed;QAC1CL,UAAU,gBAAgB,CAACoB,iBAAiBZ;QAC5CR,UAAU,gBAAgB,CAACqB,qBAAqBX;QAChDV,UAAU,gBAAgB,CAACsB,qBAAqBT;QAChDb,UAAU,gBAAgB,CAACuB,qBAAqBR;QAChDf,UAAU,gBAAgB,CAACwB,yBAAyBP;QAEpDQ,+BAA+B,QAAQ,CAACzB;QACxC0B,wBAAwB,QAAQ,CAAC1B;QAEjCA,UAAU,QAAQ,CAAC2B;QAGnB3B,UAAU,iBAAiB,CAAC4B;QAE5BC,4BAA4B,QAAQ,CAAC7B;QACrC8B,4BAA4B,QAAQ,CAAC9B;QACrC+B,4BAA4B,QAAQ,CAAC/B;IACzC;AACJ"}
|
|
@@ -4,7 +4,7 @@ import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
|
|
|
4
4
|
import { CmsDdbEsEntriesEsEntity } from "../../abstractions/CmsDdbEsEntriesEsEntity.js";
|
|
5
5
|
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
6
6
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
7
|
-
import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
7
|
+
import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier, CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
8
8
|
import { CompressionHandler } from "@webiny/utils/exports/api.js";
|
|
9
9
|
declare class DdbEsCreateEntryImpl implements CreateEntryStorageOperation.Interface {
|
|
10
10
|
private entity;
|
|
@@ -13,8 +13,9 @@ declare class DdbEsCreateEntryImpl implements CreateEntryStorageOperation.Interf
|
|
|
13
13
|
private storageModelProvider;
|
|
14
14
|
private fieldIndexRegistry;
|
|
15
15
|
private compressionHandler;
|
|
16
|
+
private indexProvider;
|
|
16
17
|
private valuesModifiers;
|
|
17
|
-
constructor(entity: CmsDdbEsEntryEntity.Interface, esEntity: CmsDdbEsEntriesEsEntity.Interface, dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface, fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface, compressionHandler: CompressionHandler.Interface, valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]);
|
|
18
|
+
constructor(entity: CmsDdbEsEntryEntity.Interface, esEntity: CmsDdbEsEntriesEsEntity.Interface, dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface, fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface, compressionHandler: CompressionHandler.Interface, indexProvider: CmsModelOpenSearchIndexProvider.Interface, valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]);
|
|
18
19
|
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsCreateParams<T>): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T>>;
|
|
19
20
|
}
|
|
20
21
|
export declare const DdbEsCreateEntry: typeof DdbEsCreateEntryImpl & {
|
|
@@ -4,19 +4,20 @@ import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
|
|
|
4
4
|
import { CmsDdbEsEntriesEsEntity } from "../../abstractions/CmsDdbEsEntriesEsEntity.js";
|
|
5
5
|
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
6
6
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
7
|
-
import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
7
|
+
import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier, CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
8
8
|
import { CompressionHandler } from "@webiny/utils/exports/api.js";
|
|
9
|
-
import {
|
|
9
|
+
import { createConfigurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
|
|
10
10
|
import { createTransformer } from "./transformations/index.js";
|
|
11
11
|
import { createEntryLatestKeys, createEntryPublishedKeys, createEntryRevisionKeys } from "./keys.js";
|
|
12
12
|
class DdbEsCreateEntryImpl {
|
|
13
|
-
constructor(entity, esEntity, dataLoaders, storageModelProvider, fieldIndexRegistry, compressionHandler, valuesModifiers){
|
|
13
|
+
constructor(entity, esEntity, dataLoaders, storageModelProvider, fieldIndexRegistry, compressionHandler, indexProvider, valuesModifiers){
|
|
14
14
|
this.entity = entity;
|
|
15
15
|
this.esEntity = esEntity;
|
|
16
16
|
this.dataLoaders = dataLoaders;
|
|
17
17
|
this.storageModelProvider = storageModelProvider;
|
|
18
18
|
this.fieldIndexRegistry = fieldIndexRegistry;
|
|
19
19
|
this.compressionHandler = compressionHandler;
|
|
20
|
+
this.indexProvider = indexProvider;
|
|
20
21
|
this.valuesModifiers = valuesModifiers;
|
|
21
22
|
}
|
|
22
23
|
async execute(initialModel, params) {
|
|
@@ -36,7 +37,8 @@ class DdbEsCreateEntryImpl {
|
|
|
36
37
|
});
|
|
37
38
|
const { entry, storageEntry } = transformer.transformEntryKeys();
|
|
38
39
|
const esEntry = transformer.transformToIndex();
|
|
39
|
-
const
|
|
40
|
+
const configurations = createConfigurations(this.indexProvider);
|
|
41
|
+
const { index: esIndex } = await configurations.es({
|
|
40
42
|
model
|
|
41
43
|
});
|
|
42
44
|
const revisionKeys = createEntryRevisionKeys(entry);
|
|
@@ -118,6 +120,7 @@ const DdbEsCreateEntry = CreateEntryStorageOperation.createImplementation({
|
|
|
118
120
|
CmsStorageModelProvider,
|
|
119
121
|
CmsEntryOpenSearchFieldIndexRegistry,
|
|
120
122
|
CompressionHandler,
|
|
123
|
+
CmsModelOpenSearchIndexProvider,
|
|
121
124
|
[
|
|
122
125
|
CmsEntryOpenSearchValuesModifier,
|
|
123
126
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/DdbEsCreateEntry.js","sources":["../../../src/operations/entry/DdbEsCreateEntry.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsCreateParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { CreateEntryStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/CreateEntryStorageOperation.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport {\n CmsEntryOpenSearchFieldIndexRegistry,\n CmsEntryOpenSearchValuesModifier\n} from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsCreateEntry.js","sources":["../../../src/operations/entry/DdbEsCreateEntry.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsCreateParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { CreateEntryStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/CreateEntryStorageOperation.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport {\n CmsEntryOpenSearchFieldIndexRegistry,\n CmsEntryOpenSearchValuesModifier,\n CmsModelOpenSearchIndexProvider\n} from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport { createConfigurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { createTransformer } from \"./transformations/index.js\";\nimport {\n createEntryLatestKeys,\n createEntryPublishedKeys,\n createEntryRevisionKeys\n} from \"./keys.js\";\n\nclass DdbEsCreateEntryImpl implements CreateEntryStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsEntryEntity.Interface,\n private esEntity: CmsDdbEsEntriesEsEntity.Interface,\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface,\n private compressionHandler: CompressionHandler.Interface,\n private indexProvider: CmsModelOpenSearchIndexProvider.Interface,\n private valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsCreateParams<T>\n ) {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const isPublished = initialEntry.status === \"published\";\n const locked = isPublished ? true : initialEntry.locked;\n\n initialEntry.locked = locked;\n initialStorageEntry.locked = locked;\n\n const transformer = createTransformer<T>({\n fieldIndexRegistry: this.fieldIndexRegistry,\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry,\n compressionHandler: this.compressionHandler,\n valuesModifiers: this.valuesModifiers\n });\n\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const esEntry = transformer.transformToIndex();\n\n const configurations = createConfigurations(this.indexProvider);\n const { index: esIndex } = await configurations.es({\n model\n });\n\n const revisionKeys = createEntryRevisionKeys(entry);\n const latestKeys = createEntryLatestKeys(entry);\n const publishedKeys = createEntryPublishedKeys(entry);\n\n const entityBatch = this.entity.createEntityWriter({\n put: [\n {\n ...revisionKeys,\n data: {\n ...storageEntry,\n locked\n }\n },\n {\n ...latestKeys,\n data: {\n ...storageEntry,\n locked\n }\n }\n ]\n });\n\n if (isPublished) {\n entityBatch.put({\n ...publishedKeys,\n data: {\n ...storageEntry,\n locked\n }\n });\n }\n\n try {\n await entityBatch.execute();\n this.dataLoaders.clearAll({\n tenant: entry.tenant\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert entry data into the DynamoDB table.\",\n ex.code || \"CREATE_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n const esLatestData = await transformer.getElasticsearchLatestEntryData();\n\n const elasticsearchEntityBatch = this.esEntity.createEntityWriter({\n put: [\n {\n ...latestKeys,\n index: esIndex,\n data: esLatestData\n }\n ]\n });\n\n if (isPublished) {\n const esPublishedData = await transformer.getElasticsearchPublishedEntryData();\n elasticsearchEntityBatch.put({\n ...publishedKeys,\n index: esIndex,\n data: esPublishedData\n });\n }\n\n try {\n await elasticsearchEntityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not insert entry data into the Elasticsearch DynamoDB table.\",\n ex.code || \"CREATE_ES_ENTRY_ERROR\",\n {\n error: ex,\n entry,\n esEntry\n }\n );\n }\n\n return initialStorageEntry;\n }\n}\n\nexport const DdbEsCreateEntry = CreateEntryStorageOperation.createImplementation({\n implementation: DdbEsCreateEntryImpl,\n dependencies: [\n CmsDdbEsEntryEntity,\n CmsDdbEsEntriesEsEntity,\n CmsDdbEsDataLoaders,\n CmsStorageModelProvider,\n CmsEntryOpenSearchFieldIndexRegistry,\n CompressionHandler,\n CmsModelOpenSearchIndexProvider,\n [CmsEntryOpenSearchValuesModifier, { multiple: true }]\n ]\n});\n"],"names":["DdbEsCreateEntryImpl","entity","esEntity","dataLoaders","storageModelProvider","fieldIndexRegistry","compressionHandler","indexProvider","valuesModifiers","initialModel","params","initialEntry","initialStorageEntry","model","isPublished","locked","transformer","createTransformer","entry","storageEntry","esEntry","configurations","createConfigurations","esIndex","revisionKeys","createEntryRevisionKeys","latestKeys","createEntryLatestKeys","publishedKeys","createEntryPublishedKeys","entityBatch","ex","WebinyError","esLatestData","elasticsearchEntityBatch","esPublishedData","DdbEsCreateEntry","CreateEntryStorageOperation","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity","CmsDdbEsDataLoaders","CmsStorageModelProvider","CmsEntryOpenSearchFieldIndexRegistry","CompressionHandler","CmsModelOpenSearchIndexProvider","CmsEntryOpenSearchValuesModifier"],"mappings":";;;;;;;;;;;AAyBA,MAAMA;IACF,YACYC,MAAqC,EACrCC,QAA2C,EAC3CC,WAA0C,EAC1CC,oBAAuD,EACvDC,kBAAkE,EAClEC,kBAAgD,EAChDC,aAAwD,EACxDC,eAA6D,CACvE;aARUP,MAAM,GAANA;aACAC,QAAQ,GAARA;aACAC,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;aACAC,kBAAkB,GAAlBA;aACAC,kBAAkB,GAAlBA;aACAC,aAAa,GAAbA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAAgD,EAClD;QACE,MAAM,EAAE,OAAOC,YAAY,EAAE,cAAcC,mBAAmB,EAAE,GAAGF;QAEnE,MAAMG,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIJ;QAEpD,MAAMK,cAAcH,AAAwB,gBAAxBA,aAAa,MAAM;QACvC,MAAMI,SAASD,cAAc,OAAOH,aAAa,MAAM;QAEvDA,aAAa,MAAM,GAAGI;QACtBH,oBAAoB,MAAM,GAAGG;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ACI,GAAGR,UAAU;oBACb,OAAOH;oBACP,MAAMU;gBACV;aACH;QACL;QAEA,IAAInB,aAAa;YACb,MAAMqB,kBAAkB,MAAMnB,YAAY,kCAAkC;YAC5EkB,yBAAyB,GAAG,CAAC;gBACzB,GAAGN,aAAa;gBAChB,OAAOL;gBACP,MAAMY;YACV;QACJ;QAEA,IAAI;YACA,MAAMD,yBAAyB,OAAO;QAC1C,EAAE,OAAOH,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,sEACdA,GAAG,IAAI,IAAI,yBACX;gBACI,OAAOA;gBACPb;gBACAE;YACJ;QAER;QAEA,OAAOR;IACX;AACJ;AAEO,MAAMwB,mBAAmBC,4BAA4B,oBAAoB,CAAC;IAC7E,gBAAgBrC;IAChB,cAAc;QACVsC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACA;YAACC;YAAkC;gBAAE,UAAU;YAAK;SAAE;KACzD;AACL"}
|
|
@@ -4,7 +4,7 @@ import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
|
|
|
4
4
|
import { CmsDdbEsEntriesEsEntity } from "../../abstractions/CmsDdbEsEntriesEsEntity.js";
|
|
5
5
|
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
6
6
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
7
|
-
import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
7
|
+
import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier, CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
8
8
|
import { CompressionHandler } from "@webiny/utils/exports/api.js";
|
|
9
9
|
declare class DdbEsCreateEntryRevisionFromImpl implements CreateEntryRevisionFromStorageOperation.Interface {
|
|
10
10
|
private entity;
|
|
@@ -13,8 +13,9 @@ declare class DdbEsCreateEntryRevisionFromImpl implements CreateEntryRevisionFro
|
|
|
13
13
|
private storageModelProvider;
|
|
14
14
|
private fieldIndexRegistry;
|
|
15
15
|
private compressionHandler;
|
|
16
|
+
private indexProvider;
|
|
16
17
|
private valuesModifiers;
|
|
17
|
-
constructor(entity: CmsDdbEsEntryEntity.Interface, esEntity: CmsDdbEsEntriesEsEntity.Interface, dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface, fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface, compressionHandler: CompressionHandler.Interface, valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]);
|
|
18
|
+
constructor(entity: CmsDdbEsEntryEntity.Interface, esEntity: CmsDdbEsEntriesEsEntity.Interface, dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface, fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface, compressionHandler: CompressionHandler.Interface, indexProvider: CmsModelOpenSearchIndexProvider.Interface, valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]);
|
|
18
19
|
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsCreateRevisionFromParams<T>): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T>>;
|
|
19
20
|
}
|
|
20
21
|
export declare const DdbEsCreateEntryRevisionFrom: typeof DdbEsCreateEntryRevisionFromImpl & {
|
|
@@ -5,19 +5,20 @@ import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
|
|
|
5
5
|
import { CmsDdbEsEntriesEsEntity } from "../../abstractions/CmsDdbEsEntriesEsEntity.js";
|
|
6
6
|
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
7
7
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
8
|
-
import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
8
|
+
import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier, CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
9
9
|
import { CompressionHandler } from "@webiny/utils/exports/api.js";
|
|
10
|
-
import {
|
|
10
|
+
import { createConfigurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
|
|
11
11
|
import { createTransformer } from "./transformations/index.js";
|
|
12
12
|
import { createEntryLatestKeys, createEntryPublishedKeys, createEntryRevisionKeys } from "./keys.js";
|
|
13
13
|
class DdbEsCreateEntryRevisionFromImpl {
|
|
14
|
-
constructor(entity, esEntity, dataLoaders, storageModelProvider, fieldIndexRegistry, compressionHandler, valuesModifiers){
|
|
14
|
+
constructor(entity, esEntity, dataLoaders, storageModelProvider, fieldIndexRegistry, compressionHandler, indexProvider, valuesModifiers){
|
|
15
15
|
this.entity = entity;
|
|
16
16
|
this.esEntity = esEntity;
|
|
17
17
|
this.dataLoaders = dataLoaders;
|
|
18
18
|
this.storageModelProvider = storageModelProvider;
|
|
19
19
|
this.fieldIndexRegistry = fieldIndexRegistry;
|
|
20
20
|
this.compressionHandler = compressionHandler;
|
|
21
|
+
this.indexProvider = indexProvider;
|
|
21
22
|
this.valuesModifiers = valuesModifiers;
|
|
22
23
|
}
|
|
23
24
|
async execute(initialModel, params) {
|
|
@@ -83,7 +84,8 @@ class DdbEsCreateEntryRevisionFromImpl {
|
|
|
83
84
|
storageEntry
|
|
84
85
|
});
|
|
85
86
|
}
|
|
86
|
-
const
|
|
87
|
+
const configurations = createConfigurations(this.indexProvider);
|
|
88
|
+
const { index: esIndex } = await configurations.es({
|
|
87
89
|
model
|
|
88
90
|
});
|
|
89
91
|
const elasticsearchEntityBatch = this.esEntity.createEntityWriter({
|
|
@@ -123,6 +125,7 @@ const DdbEsCreateEntryRevisionFrom = CreateEntryRevisionFromStorageOperation.cre
|
|
|
123
125
|
CmsStorageModelProvider,
|
|
124
126
|
CmsEntryOpenSearchFieldIndexRegistry,
|
|
125
127
|
CompressionHandler,
|
|
128
|
+
CmsModelOpenSearchIndexProvider,
|
|
126
129
|
[
|
|
127
130
|
CmsEntryOpenSearchValuesModifier,
|
|
128
131
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/DdbEsCreateEntryRevisionFrom.js","sources":["../../../src/operations/entry/DdbEsCreateEntryRevisionFrom.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsCreateRevisionFromParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { CONTENT_ENTRY_STATUS } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CreateEntryRevisionFromStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/CreateEntryRevisionFromStorageOperation.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport {\n CmsEntryOpenSearchFieldIndexRegistry,\n CmsEntryOpenSearchValuesModifier\n} from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport { configurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { createTransformer } from \"./transformations/index.js\";\nimport {\n createEntryLatestKeys,\n createEntryPublishedKeys,\n createEntryRevisionKeys\n} from \"./keys.js\";\n\nclass DdbEsCreateEntryRevisionFromImpl\n implements CreateEntryRevisionFromStorageOperation.Interface\n{\n constructor(\n private entity: CmsDdbEsEntryEntity.Interface,\n private esEntity: CmsDdbEsEntriesEsEntity.Interface,\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface,\n private compressionHandler: CompressionHandler.Interface,\n private valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsCreateRevisionFromParams<T>\n ) {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const transformer = createTransformer<T>({\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry,\n fieldIndexRegistry: this.fieldIndexRegistry,\n compressionHandler: this.compressionHandler,\n valuesModifiers: this.valuesModifiers\n });\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const revisionKeys = createEntryRevisionKeys(entry);\n const latestKeys = createEntryLatestKeys(entry);\n const publishedKeys = createEntryPublishedKeys(entry);\n\n // We'll need this flag below.\n const isPublished = entry.status === \"published\";\n\n const esLatestData = await transformer.getElasticsearchLatestEntryData();\n\n const entityBatch = this.entity.createEntityWriter({\n put: [\n {\n ...revisionKeys,\n data: storageEntry\n },\n {\n ...latestKeys,\n data: storageEntry\n }\n ]\n });\n\n if (isPublished) {\n entityBatch.put({\n ...publishedKeys,\n data: storageEntry\n });\n\n // Unpublish previously published revision (if any).\n const [publishedRevisionStorageEntry] =\n await this.dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n if (publishedRevisionStorageEntry) {\n const publishedRevisionKey = createEntryRevisionKeys(publishedRevisionStorageEntry);\n entityBatch.put({\n ...publishedRevisionKey,\n data: {\n ...publishedRevisionStorageEntry,\n status: CONTENT_ENTRY_STATUS.UNPUBLISHED\n }\n });\n }\n }\n\n try {\n await entityBatch.execute();\n\n this.dataLoaders.clearAll({\n tenant: entry.tenant\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create revision from given entry in the DynamoDB table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n const { index: esIndex } = configurations.es({\n model\n });\n\n const elasticsearchEntityBatch = this.esEntity.createEntityWriter({\n put: [\n {\n ...latestKeys,\n index: esIndex,\n data: esLatestData\n }\n ]\n });\n\n if (isPublished) {\n const esPublishedData = await transformer.getElasticsearchPublishedEntryData();\n elasticsearchEntityBatch.put({\n ...publishedKeys,\n index: esIndex,\n data: esPublishedData\n });\n }\n\n try {\n await elasticsearchEntityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update latest entry in the DynamoDB Elasticsearch table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n /**\n * There are no modifications on the entry created so just return the data.\n */\n return initialStorageEntry;\n }\n}\n\nexport const DdbEsCreateEntryRevisionFrom =\n CreateEntryRevisionFromStorageOperation.createImplementation({\n implementation: DdbEsCreateEntryRevisionFromImpl,\n dependencies: [\n CmsDdbEsEntryEntity,\n CmsDdbEsEntriesEsEntity,\n CmsDdbEsDataLoaders,\n CmsStorageModelProvider,\n CmsEntryOpenSearchFieldIndexRegistry,\n CompressionHandler,\n [CmsEntryOpenSearchValuesModifier, { multiple: true }]\n ]\n });\n"],"names":["DdbEsCreateEntryRevisionFromImpl","entity","esEntity","dataLoaders","storageModelProvider","fieldIndexRegistry","compressionHandler","valuesModifiers","initialModel","params","initialEntry","initialStorageEntry","model","transformer","createTransformer","entry","storageEntry","revisionKeys","createEntryRevisionKeys","latestKeys","createEntryLatestKeys","publishedKeys","createEntryPublishedKeys","isPublished","esLatestData","entityBatch","publishedRevisionStorageEntry","publishedRevisionKey","CONTENT_ENTRY_STATUS","ex","WebinyError","esIndex","configurations","elasticsearchEntityBatch","esPublishedData","DdbEsCreateEntryRevisionFrom","CreateEntryRevisionFromStorageOperation","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity","CmsDdbEsDataLoaders","CmsStorageModelProvider","CmsEntryOpenSearchFieldIndexRegistry","CompressionHandler","CmsEntryOpenSearchValuesModifier"],"mappings":";;;;;;;;;;;;AAyBA,MAAMA;IAGF,YACYC,MAAqC,EACrCC,QAA2C,EAC3CC,WAA0C,EAC1CC,oBAAuD,EACvDC,kBAAkE,EAClEC,kBAAgD,EAChDC,eAA6D,CACvE;aAPUN,MAAM,GAANA;aACAC,QAAQ,GAARA;aACAC,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;aACAC,kBAAkB,GAAlBA;aACAC,kBAAkB,GAAlBA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAA4D,EAC9D;QACE,MAAM,EAAE,OAAOC,YAAY,EAAE,cAAcC,mBAAmB,EAAE,GAAGF;QACnE,MAAMG,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIJ;QAEpD,MAAMK,cAAcC,kBAAqB;YACrCF;YACA,OAAOF;YACP,cAAcC;YACd,oBAAoB,IAAI,CAAC,kBAAkB;YAC3C,oBAAoB,IAAI,CAAC,kBAAkB;YAC3C,iBAAiB,IAAI,CAAC,eAAe;QACzC;QACA,MAAM,EAAEI,KAAK,EAAEC,YAAY,EAAE,GAAGH,YAAY,kBAAkB;QAE9D,MAAMI,eAAeC,wBAAwBH;QAC7C,MAAMI,aAAaC,sBAAsBL;QACzC,MAAMM,gBAAgBC,yBAAyBP;QAG/C,MAAMQ,cAAcR,AAAiB,gBAAjBA,MAAM,MAAM;QAEhC,MAAMS,eAAe,MAAMX,YAAY,+BAA+B;QAEtE,MAAMY,cAAc,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;YAC/C,KAAK;gBACD;oBACI,GAAGR,YAAY;oBACf,MAAMD;gBACV;gBACA;oBACI,GAAGG,UAAU;oBACb,MAAM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J;IACX;AACJ;AAEO,MAAMwB,+BACTC,wCAAwC,oBAAoB,CAAC;IACzD,gBAAgBpC;IAChB,cAAc;QACVqC;QACAC;QACAC;QACAC;QACAC;QACAC;QACA;YAACC;YAAkC;gBAAE,UAAU;YAAK;SAAE;KACzD;AACL"}
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsCreateEntryRevisionFrom.js","sources":["../../../src/operations/entry/DdbEsCreateEntryRevisionFrom.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsCreateRevisionFromParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { CONTENT_ENTRY_STATUS } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CreateEntryRevisionFromStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/CreateEntryRevisionFromStorageOperation.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport {\n CmsEntryOpenSearchFieldIndexRegistry,\n CmsEntryOpenSearchValuesModifier,\n CmsModelOpenSearchIndexProvider\n} from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport { createConfigurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { createTransformer } from \"./transformations/index.js\";\nimport {\n createEntryLatestKeys,\n createEntryPublishedKeys,\n createEntryRevisionKeys\n} from \"./keys.js\";\n\nclass DdbEsCreateEntryRevisionFromImpl\n implements CreateEntryRevisionFromStorageOperation.Interface\n{\n constructor(\n private entity: CmsDdbEsEntryEntity.Interface,\n private esEntity: CmsDdbEsEntriesEsEntity.Interface,\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface,\n private compressionHandler: CompressionHandler.Interface,\n private indexProvider: CmsModelOpenSearchIndexProvider.Interface,\n private valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsCreateRevisionFromParams<T>\n ) {\n const { entry: initialEntry, storageEntry: initialStorageEntry } = params;\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const transformer = createTransformer<T>({\n model,\n entry: initialEntry,\n storageEntry: initialStorageEntry,\n fieldIndexRegistry: this.fieldIndexRegistry,\n compressionHandler: this.compressionHandler,\n valuesModifiers: this.valuesModifiers\n });\n const { entry, storageEntry } = transformer.transformEntryKeys();\n\n const revisionKeys = createEntryRevisionKeys(entry);\n const latestKeys = createEntryLatestKeys(entry);\n const publishedKeys = createEntryPublishedKeys(entry);\n\n // We'll need this flag below.\n const isPublished = entry.status === \"published\";\n\n const esLatestData = await transformer.getElasticsearchLatestEntryData();\n\n const entityBatch = this.entity.createEntityWriter({\n put: [\n {\n ...revisionKeys,\n data: storageEntry\n },\n {\n ...latestKeys,\n data: storageEntry\n }\n ]\n });\n\n if (isPublished) {\n entityBatch.put({\n ...publishedKeys,\n data: storageEntry\n });\n\n // Unpublish previously published revision (if any).\n const [publishedRevisionStorageEntry] =\n await this.dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n\n if (publishedRevisionStorageEntry) {\n const publishedRevisionKey = createEntryRevisionKeys(publishedRevisionStorageEntry);\n entityBatch.put({\n ...publishedRevisionKey,\n data: {\n ...publishedRevisionStorageEntry,\n status: CONTENT_ENTRY_STATUS.UNPUBLISHED\n }\n });\n }\n }\n\n try {\n await entityBatch.execute();\n\n this.dataLoaders.clearAll({\n tenant: entry.tenant\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create revision from given entry in the DynamoDB table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n storageEntry\n }\n );\n }\n\n const configurations = createConfigurations(this.indexProvider);\n const { index: esIndex } = await configurations.es({\n model\n });\n\n const elasticsearchEntityBatch = this.esEntity.createEntityWriter({\n put: [\n {\n ...latestKeys,\n index: esIndex,\n data: esLatestData\n }\n ]\n });\n\n if (isPublished) {\n const esPublishedData = await transformer.getElasticsearchPublishedEntryData();\n elasticsearchEntityBatch.put({\n ...publishedKeys,\n index: esIndex,\n data: esPublishedData\n });\n }\n\n try {\n await elasticsearchEntityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update latest entry in the DynamoDB Elasticsearch table.\",\n ex.code || \"CREATE_REVISION_ERROR\",\n {\n error: ex,\n entry\n }\n );\n }\n /**\n * There are no modifications on the entry created so just return the data.\n */\n return initialStorageEntry;\n }\n}\n\nexport const DdbEsCreateEntryRevisionFrom =\n CreateEntryRevisionFromStorageOperation.createImplementation({\n implementation: DdbEsCreateEntryRevisionFromImpl,\n dependencies: [\n CmsDdbEsEntryEntity,\n CmsDdbEsEntriesEsEntity,\n CmsDdbEsDataLoaders,\n CmsStorageModelProvider,\n CmsEntryOpenSearchFieldIndexRegistry,\n CompressionHandler,\n CmsModelOpenSearchIndexProvider,\n [CmsEntryOpenSearchValuesModifier, { multiple: true }]\n ]\n });\n"],"names":["DdbEsCreateEntryRevisionFromImpl","entity","esEntity","dataLoaders","storageModelProvider","fieldIndexRegistry","compressionHandler","indexProvider","valuesModifiers","initialModel","params","initialEntry","initialStorageEntry","model","transformer","createTransformer","entry","storageEntry","revisionKeys","createEntryRevisionKeys","latestKeys","createEntryLatestKeys","publishedKeys","createEntryPublishedKeys","isPublished","esLatestData","entityBatch","publishedRevisionStorageEntry","publishedRevisionKey","CONTENT_ENTRY_STATUS","ex","WebinyError","configurations","createConfigurations","esIndex","elasticsearchEntityBatch","esPublishedData","DdbEsCreateEntryRevisionFrom","CreateEntryRevisionFromStorageOperation","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity","CmsDdbEsDataLoaders","CmsStorageModelProvider","CmsEntryOpenSearchFieldIndexRegistry","CompressionHandler","CmsModelOpenSearchIndexProvider","CmsEntryOpenSearchValuesModifier"],"mappings":";;;;;;;;;;;;AA0BA,MAAMA;IAGF,YACYC,MAAqC,EACrCC,QAA2C,EAC3CC,WAA0C,EAC1CC,oBAAuD,EACvDC,kBAAkE,EAClEC,kBAAgD,EAChDC,aAAwD,EACxDC,eAA6D,CACvE;aARUP,MAAM,GAANA;aACAC,QAAQ,GAARA;aACAC,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;aACAC,kBAAkB,GAAlBA;aACAC,kBAAkB,GAAlBA;aACAC,aAAa,GAAbA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAA4D,EAC9D;QACE,MAAM,EAAE,OAAOC,YAAY,EAAE,cAAcC,mBAAmB,EAAE,GAAGF;QACnE,MAAMG,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIJ;QAEpD,MAAMK,cAAcC,kBAAqB;YACrCF;YACA,OAAOF;YACP,cAAcC;YACd,oBAAoB,IAAI,CAAC,kBAAkB;YAC3C,oBAAoB,IAAI,CAAC,kBAAkB;YAC3C,iBAAiB,IAAI,CAAC,eAAe;QACzC;QACA,MAAM,EAAEI,KAAK,EAAEC,YAAY,EAAE,GAAGH,YAAY,kBAAkB;QAE9D,MAAMI,eAAeC,wBAAwBH;QAC7C,MAAMI,aAAaC,sBAAsBL;QACzC,MAAMM,gBAAgBC,yBAAyBP;QAG/C,MAAMQ,cAAcR,AAAiB,gBAAjBA,MAAM,MAAM;QAEhC,MAAMS,eAAe,MAAMX,YAAY,+BAA+B;QAEtE,MAAMY,cAAc,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;YAC/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O;QAC1C,EAAE,OAAOL,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,sEACdA,GAAG,IAAI,IAAI,yBACX;gBACI,OAAOA;gBACPd;YACJ;QAER;QAIA,OAAOJ;IACX;AACJ;AAEO,MAAMyB,+BACTC,wCAAwC,oBAAoB,CAAC;IACzD,gBAAgBtC;IAChB,cAAc;QACVuC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACA;YAACC;YAAkC;gBAAE,UAAU;YAAK;SAAE;KACzD;AACL"}
|
|
@@ -4,7 +4,7 @@ import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
|
|
|
4
4
|
import { CmsDdbEsEntriesEsEntity } from "../../abstractions/CmsDdbEsEntriesEsEntity.js";
|
|
5
5
|
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
6
6
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
7
|
-
import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
7
|
+
import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier, CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
8
8
|
import { CompressionHandler } from "@webiny/utils/exports/api.js";
|
|
9
9
|
declare class DdbEsDeleteEntryRevisionImpl implements DeleteEntryRevisionStorageOperation.Interface {
|
|
10
10
|
private entity;
|
|
@@ -13,8 +13,9 @@ declare class DdbEsDeleteEntryRevisionImpl implements DeleteEntryRevisionStorage
|
|
|
13
13
|
private storageModelProvider;
|
|
14
14
|
private fieldIndexRegistry;
|
|
15
15
|
private compressionHandler;
|
|
16
|
+
private indexProvider;
|
|
16
17
|
private valuesModifiers;
|
|
17
|
-
constructor(entity: CmsDdbEsEntryEntity.Interface, esEntity: CmsDdbEsEntriesEsEntity.Interface, dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface, fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface, compressionHandler: CompressionHandler.Interface, valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]);
|
|
18
|
+
constructor(entity: CmsDdbEsEntryEntity.Interface, esEntity: CmsDdbEsEntriesEsEntity.Interface, dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface, fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface, compressionHandler: CompressionHandler.Interface, indexProvider: CmsModelOpenSearchIndexProvider.Interface, valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]);
|
|
18
19
|
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsDeleteRevisionParams<T>): Promise<void>;
|
|
19
20
|
}
|
|
20
21
|
export declare const DdbEsDeleteEntryRevision: typeof DdbEsDeleteEntryRevisionImpl & {
|
|
@@ -4,20 +4,21 @@ import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
|
|
|
4
4
|
import { CmsDdbEsEntriesEsEntity } from "../../abstractions/CmsDdbEsEntriesEsEntity.js";
|
|
5
5
|
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
6
6
|
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
7
|
-
import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
7
|
+
import { CmsEntryOpenSearchFieldIndexRegistry, CmsEntryOpenSearchValuesModifier, CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
8
8
|
import { CompressionHandler } from "@webiny/utils/exports/api.js";
|
|
9
|
-
import {
|
|
9
|
+
import { createConfigurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
|
|
10
10
|
import { createTransformer } from "./transformations/index.js";
|
|
11
11
|
import { createEntryLatestKeys, createEntryRevisionKeys, createPartitionKey, createPublishedSortKey, createRevisionSortKey } from "./keys.js";
|
|
12
12
|
import { convertToStorageEntry } from "./storageEntryUtils.js";
|
|
13
13
|
class DdbEsDeleteEntryRevisionImpl {
|
|
14
|
-
constructor(entity, esEntity, dataLoaders, storageModelProvider, fieldIndexRegistry, compressionHandler, valuesModifiers){
|
|
14
|
+
constructor(entity, esEntity, dataLoaders, storageModelProvider, fieldIndexRegistry, compressionHandler, indexProvider, valuesModifiers){
|
|
15
15
|
this.entity = entity;
|
|
16
16
|
this.esEntity = esEntity;
|
|
17
17
|
this.dataLoaders = dataLoaders;
|
|
18
18
|
this.storageModelProvider = storageModelProvider;
|
|
19
19
|
this.fieldIndexRegistry = fieldIndexRegistry;
|
|
20
20
|
this.compressionHandler = compressionHandler;
|
|
21
|
+
this.indexProvider = indexProvider;
|
|
21
22
|
this.valuesModifiers = valuesModifiers;
|
|
22
23
|
}
|
|
23
24
|
async execute(initialModel, params) {
|
|
@@ -27,7 +28,8 @@ class DdbEsDeleteEntryRevisionImpl {
|
|
|
27
28
|
id: entry.id,
|
|
28
29
|
tenant: model.tenant
|
|
29
30
|
});
|
|
30
|
-
const
|
|
31
|
+
const configurations = createConfigurations(this.indexProvider);
|
|
32
|
+
const { index } = await configurations.es({
|
|
31
33
|
model
|
|
32
34
|
});
|
|
33
35
|
const [publishedStorageEntry] = await this.dataLoaders.getPublishedRevisionByEntryId({
|
|
@@ -120,6 +122,7 @@ const DdbEsDeleteEntryRevision = DeleteEntryRevisionStorageOperation.createImple
|
|
|
120
122
|
CmsStorageModelProvider,
|
|
121
123
|
CmsEntryOpenSearchFieldIndexRegistry,
|
|
122
124
|
CompressionHandler,
|
|
125
|
+
CmsModelOpenSearchIndexProvider,
|
|
123
126
|
[
|
|
124
127
|
CmsEntryOpenSearchValuesModifier,
|
|
125
128
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/DdbEsDeleteEntryRevision.js","sources":["../../../src/operations/entry/DdbEsDeleteEntryRevision.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsDeleteRevisionParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { DeleteEntryRevisionStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport {\n CmsEntryOpenSearchFieldIndexRegistry,\n CmsEntryOpenSearchValuesModifier\n} from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport { configurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { createTransformer } from \"./transformations/index.js\";\nimport {\n createEntryLatestKeys,\n createEntryRevisionKeys,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"./keys.js\";\nimport { convertToStorageEntry } from \"./storageEntryUtils.js\";\n\nclass DdbEsDeleteEntryRevisionImpl implements DeleteEntryRevisionStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsEntryEntity.Interface,\n private esEntity: CmsDdbEsEntriesEsEntity.Interface,\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface,\n private compressionHandler: CompressionHandler.Interface,\n private valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsDeleteRevisionParams<T>\n ): Promise<void> {\n const { entry, latestEntry, latestStorageEntry: initialLatestStorageEntry } = params;\n const model = this.storageModelProvider.getModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n tenant: model.tenant\n });\n\n const { index } = configurations.es({\n model\n });\n /**\n * We need published entry to delete it if necessary.\n */\n const [publishedStorageEntry] = await this.dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n /**\n * We need to delete all existing records of the given entry revision.\n */\n const entityBatch = this.entity.createEntityWriter({\n delete: [\n {\n PK: partitionKey,\n SK: createRevisionSortKey(entry)\n }\n ]\n });\n\n const elasticsearchEntityBatch = this.esEntity.createEntityWriter();\n\n /**\n * If revision we are deleting is the published one as well, we need to delete those records as well.\n */\n if (publishedStorageEntry?.id === entry.id) {\n entityBatch.delete({\n PK: partitionKey,\n SK: createPublishedSortKey()\n });\n\n elasticsearchEntityBatch.delete({\n PK: partitionKey,\n SK: createPublishedSortKey()\n });\n }\n\n if (latestEntry && initialLatestStorageEntry) {\n const latestStorageEntry = convertToStorageEntry({\n storageEntry: initialLatestStorageEntry,\n model\n });\n\n /**\n * In the end we need to set the new latest entry.\n */\n const latestStorageEntryLatestKey = createEntryLatestKeys(latestStorageEntry);\n entityBatch.put({\n ...latestStorageEntryLatestKey,\n data: latestStorageEntry\n });\n\n /**\n * Also perform an update on the actual revision. This is needed\n * because of updates on the entry-level meta fields.\n */\n const actualRevisionEntryKey = createEntryRevisionKeys(initialLatestStorageEntry);\n entityBatch.put({\n ...actualRevisionEntryKey,\n data: latestStorageEntry\n });\n\n const latestTransformer = createTransformer({\n valuesModifiers: this.valuesModifiers,\n model,\n entry: latestEntry,\n storageEntry: initialLatestStorageEntry,\n fieldIndexRegistry: this.fieldIndexRegistry,\n compressionHandler: this.compressionHandler\n });\n\n const esLatestData = await latestTransformer.getElasticsearchLatestEntryData();\n\n const esLatestKeys = createEntryLatestKeys(latestEntry);\n elasticsearchEntityBatch.put({\n ...esLatestKeys,\n index,\n data: esLatestData\n });\n }\n\n try {\n await entityBatch.execute();\n\n this.dataLoaders.clearAll({\n tenant: entry.tenant\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch write entry records to DynamoDB table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n initialLatestStorageEntry\n }\n );\n }\n\n try {\n await elasticsearchEntityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not batch write entry records to DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n initialLatestStorageEntry\n }\n );\n }\n }\n}\n\nexport const DdbEsDeleteEntryRevision = DeleteEntryRevisionStorageOperation.createImplementation({\n implementation: DdbEsDeleteEntryRevisionImpl,\n dependencies: [\n CmsDdbEsEntryEntity,\n CmsDdbEsEntriesEsEntity,\n CmsDdbEsDataLoaders,\n CmsStorageModelProvider,\n CmsEntryOpenSearchFieldIndexRegistry,\n CompressionHandler,\n [CmsEntryOpenSearchValuesModifier, { multiple: true }]\n ]\n});\n"],"names":["DdbEsDeleteEntryRevisionImpl","entity","esEntity","dataLoaders","storageModelProvider","fieldIndexRegistry","compressionHandler","valuesModifiers","initialModel","params","entry","latestEntry","initialLatestStorageEntry","model","partitionKey","createPartitionKey","index","configurations","publishedStorageEntry","entityBatch","createRevisionSortKey","elasticsearchEntityBatch","createPublishedSortKey","latestStorageEntry","convertToStorageEntry","latestStorageEntryLatestKey","createEntryLatestKeys","actualRevisionEntryKey","createEntryRevisionKeys","latestTransformer","createTransformer","esLatestData","esLatestKeys","ex","WebinyError","DdbEsDeleteEntryRevision","DeleteEntryRevisionStorageOperation","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity","CmsDdbEs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AE;KACzD;AACL"}
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsDeleteEntryRevision.js","sources":["../../../src/operations/entry/DdbEsDeleteEntryRevision.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsDeleteRevisionParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { DeleteEntryRevisionStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/DeleteEntryRevisionStorageOperation.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport {\n CmsEntryOpenSearchFieldIndexRegistry,\n CmsEntryOpenSearchValuesModifier,\n CmsModelOpenSearchIndexProvider\n} from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { CompressionHandler } from \"@webiny/utils/exports/api.js\";\nimport { createConfigurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { createTransformer } from \"./transformations/index.js\";\nimport {\n createEntryLatestKeys,\n createEntryRevisionKeys,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"./keys.js\";\nimport { convertToStorageEntry } from \"./storageEntryUtils.js\";\n\nclass DdbEsDeleteEntryRevisionImpl implements DeleteEntryRevisionStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsEntryEntity.Interface,\n private esEntity: CmsDdbEsEntriesEsEntity.Interface,\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface,\n private compressionHandler: CompressionHandler.Interface,\n private indexProvider: CmsModelOpenSearchIndexProvider.Interface,\n private valuesModifiers: CmsEntryOpenSearchValuesModifier.Interface[]\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsDeleteRevisionParams<T>\n ): Promise<void> {\n const { entry, latestEntry, latestStorageEntry: initialLatestStorageEntry } = params;\n const model = this.storageModelProvider.getModel(initialModel);\n\n const partitionKey = createPartitionKey({\n id: entry.id,\n tenant: model.tenant\n });\n\n const configurations = createConfigurations(this.indexProvider);\n const { index } = await configurations.es({\n model\n });\n /**\n * We need published entry to delete it if necessary.\n */\n const [publishedStorageEntry] = await this.dataLoaders.getPublishedRevisionByEntryId({\n model,\n ids: [entry.id]\n });\n /**\n * We need to delete all existing records of the given entry revision.\n */\n const entityBatch = this.entity.createEntityWriter({\n delete: [\n {\n PK: partitionKey,\n SK: createRevisionSortKey(entry)\n }\n ]\n });\n\n const elasticsearchEntityBatch = this.esEntity.createEntityWriter();\n\n /**\n * If revision we are deleting is the published one as well, we need to delete those records as well.\n */\n if (publishedStorageEntry?.id === entry.id) {\n entityBatch.delete({\n PK: partitionKey,\n SK: createPublishedSortKey()\n });\n\n elasticsearchEntityBatch.delete({\n PK: partitionKey,\n SK: createPublishedSortKey()\n });\n }\n\n if (latestEntry && initialLatestStorageEntry) {\n const latestStorageEntry = convertToStorageEntry({\n storageEntry: initialLatestStorageEntry,\n model\n });\n\n /**\n * In the end we need to set the new latest entry.\n */\n const latestStorageEntryLatestKey = createEntryLatestKeys(latestStorageEntry);\n entityBatch.put({\n ...latestStorageEntryLatestKey,\n data: latestStorageEntry\n });\n\n /**\n * Also perform an update on the actual revision. This is needed\n * because of updates on the entry-level meta fields.\n */\n const actualRevisionEntryKey = createEntryRevisionKeys(initialLatestStorageEntry);\n entityBatch.put({\n ...actualRevisionEntryKey,\n data: latestStorageEntry\n });\n\n const latestTransformer = createTransformer({\n valuesModifiers: this.valuesModifiers,\n model,\n entry: latestEntry,\n storageEntry: initialLatestStorageEntry,\n fieldIndexRegistry: this.fieldIndexRegistry,\n compressionHandler: this.compressionHandler\n });\n\n const esLatestData = await latestTransformer.getElasticsearchLatestEntryData();\n\n const esLatestKeys = createEntryLatestKeys(latestEntry);\n elasticsearchEntityBatch.put({\n ...esLatestKeys,\n index,\n data: esLatestData\n });\n }\n\n try {\n await entityBatch.execute();\n\n this.dataLoaders.clearAll({\n tenant: entry.tenant\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not batch write entry records to DynamoDB table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n initialLatestStorageEntry\n }\n );\n }\n\n try {\n await elasticsearchEntityBatch.execute();\n } catch (ex) {\n throw new WebinyError(\n ex.message ||\n \"Could not batch write entry records to DynamoDB Elasticsearch table.\",\n ex.code || \"DELETE_REVISION_ERROR\",\n {\n error: ex,\n entry,\n latestEntry,\n initialLatestStorageEntry\n }\n );\n }\n }\n}\n\nexport const DdbEsDeleteEntryRevision = DeleteEntryRevisionStorageOperation.createImplementation({\n implementation: DdbEsDeleteEntryRevisionImpl,\n dependencies: [\n CmsDdbEsEntryEntity,\n CmsDdbEsEntriesEsEntity,\n CmsDdbEsDataLoaders,\n CmsStorageModelProvider,\n CmsEntryOpenSearchFieldIndexRegistry,\n CompressionHandler,\n CmsModelOpenSearchIndexProvider,\n [CmsEntryOpenSearchValuesModifier, { multiple: true }]\n ]\n});\n"],"names":["DdbEsDeleteEntryRevisionImpl","entity","esEntity","dataLoaders","storageModelProvider","fieldIndexRegistry","compressionHandler","indexProvider","valuesModifiers","initialModel","params","entry","latestEntry","initialLatestStorageEntry","model","partitionKey","createPartitionKey","configurations","createConfigurations","index","publishedStorageEntry","entityBatch","createRevisionSortKey","elasticsearchEntityBatch","createPublishedSortKey","latestStorageEntry","convertToStorageEntry","latestStorageEntryLatestKey","createEntryLatestKeys","actualRevisionEntryKey","createEntryRevisionKeys","latestTransformer","createTransformer","esLatestData","esLatestKeys","ex","WebinyError","DdbEsDeleteEntryRevision","DeleteEntryRevisionStorageOperation","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity","CmsDdbEsDataLoaders","CmsStorageModelProvider","CmsEntryOpenSearchFieldIndexRegistry","CompressionHandler","CmsModelOpenSearchIndexProvider","CmsEntryOpenSearchValuesModifier"],"mappings":";;;;;;;;;;;;AA4BA,MAAMA;IACF,YACYC,MAAqC,EACrCC,QAA2C,EAC3CC,WAA0C,EAC1CC,oBAAuD,EACvDC,kBAAkE,EAClEC,kBAAgD,EAChDC,aAAwD,EACxDC,eAA6D,CACvE;aARUP,MAAM,GAANA;aACAC,QAAQ,GAARA;aACAC,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;aACAC,kBAAkB,GAAlBA;aACAC,kBAAkB,GAAlBA;aACAC,aAAa,GAAbA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAAwD,EAC3C;QACb,MAAM,EAAEC,KAAK,EAAEC,WAAW,EAAE,oBAAoBC,yBAAyB,EAAE,GAAGH;QAC9E,MAAMI,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAACL;QAEjD,MAAMM,eAAeC,mBAAmB;YACpC,IAAIL,MAAM,EAAE;YACZ,QAAQG,MAAM,MAAM;QACxB;QAEA,MAAMG,iBAAiBC,qBAAqB,IAAI,CAAC,aAAa;QAC9D,MAAM,EAAEC,KAAK,EAAE,GAAG,MAAMF,eAAe,EAAE,CAAC;YACtCH;QACJ;QAIA,MAAM,CAACM,sBAAsB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,6BAA6B,CAAC;YACjFN;YACA,KAAK;gBAACH,MAAM,EAAE;aAAC;QACnB;QAIA,MAAMU,cAAc,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;YAC/C,QAAQ;gBACJ;oBACI,IAAIN;oBACJ,IAAIO,sBAAsBX;gBAC9B;aACH;QACL;QAEA,MAAMY,2BAA2B,IAAI,CAAC,QAA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AOA;gBACPxB;gBACAC;gBACAC;YACJ;QAER;IACJ;AACJ;AAEO,MAAMwB,2BAA2BC,oCAAoC,oBAAoB,CAAC;IAC7F,gBAAgBtC;IAChB,cAAc;QACVuC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACA;YAACC;YAAkC;gBAAE,UAAU;YAAK;SAAE;KACzD;AACL"}
|
|
@@ -18,35 +18,33 @@ class DdbEsDeleteMultipleEntriesImpl {
|
|
|
18
18
|
model,
|
|
19
19
|
ids: entries
|
|
20
20
|
});
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
for (const id of entries){
|
|
24
|
-
entityBatch.delete({
|
|
25
|
-
PK: createPartitionKey({
|
|
21
|
+
const esItems = (await Promise.all(entries.map((id)=>this.esEntity.queryAll({
|
|
22
|
+
partitionKey: createPartitionKey({
|
|
26
23
|
id,
|
|
27
24
|
tenant: model.tenant
|
|
28
25
|
}),
|
|
29
|
-
|
|
26
|
+
options: {
|
|
27
|
+
gte: " "
|
|
28
|
+
}
|
|
29
|
+
})))).flat();
|
|
30
|
+
const entityBatch = this.entity.createEntityWriter();
|
|
31
|
+
const elasticsearchEntityBatch = this.esEntity.createEntityWriter({
|
|
32
|
+
delete: esItems.map((item)=>({
|
|
33
|
+
PK: item.PK,
|
|
34
|
+
SK: item.SK
|
|
35
|
+
}))
|
|
36
|
+
});
|
|
37
|
+
for (const id of entries){
|
|
38
|
+
const partitionKey = createPartitionKey({
|
|
39
|
+
id,
|
|
40
|
+
tenant: model.tenant
|
|
30
41
|
});
|
|
31
|
-
|
|
32
|
-
PK:
|
|
33
|
-
id,
|
|
34
|
-
tenant: model.tenant
|
|
35
|
-
}),
|
|
42
|
+
entityBatch.delete({
|
|
43
|
+
PK: partitionKey,
|
|
36
44
|
SK: "L"
|
|
37
45
|
});
|
|
38
46
|
entityBatch.delete({
|
|
39
|
-
PK:
|
|
40
|
-
id,
|
|
41
|
-
tenant: model.tenant
|
|
42
|
-
}),
|
|
43
|
-
SK: "P"
|
|
44
|
-
});
|
|
45
|
-
elasticsearchEntityBatch.delete({
|
|
46
|
-
PK: createPartitionKey({
|
|
47
|
-
id,
|
|
48
|
-
tenant: model.tenant
|
|
49
|
-
}),
|
|
47
|
+
PK: partitionKey,
|
|
50
48
|
SK: "P"
|
|
51
49
|
});
|
|
52
50
|
}
|
|
@@ -61,6 +59,9 @@ class DdbEsDeleteMultipleEntriesImpl {
|
|
|
61
59
|
});
|
|
62
60
|
await entityBatch.execute();
|
|
63
61
|
await elasticsearchEntityBatch.execute();
|
|
62
|
+
this.dataLoaders.clearAll({
|
|
63
|
+
tenant: model.tenant
|
|
64
|
+
});
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
const DdbEsDeleteMultipleEntries = DeleteMultipleEntriesStorageOperation.createImplementation({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations/entry/DdbEsDeleteMultipleEntries.js","sources":["../../../src/operations/entry/DdbEsDeleteMultipleEntries.ts"],"sourcesContent":["import type {\n CmsModel,\n CmsEntryStorageOperationsDeleteEntriesParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { DeleteMultipleEntriesStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { createPartitionKey, createRevisionSortKey } from \"./keys.js\";\n\nclass DdbEsDeleteMultipleEntriesImpl implements DeleteMultipleEntriesStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsEntryEntity.Interface,\n private esEntity: CmsDdbEsEntriesEsEntity.Interface,\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute(initialModel: CmsModel, params: CmsEntryStorageOperationsDeleteEntriesParams) {\n const { entries } = params;\n const model = this.storageModelProvider.getModel(initialModel);\n /**\n * First we need all the revisions of the entries we want to delete.\n */\n const revisions = await this.dataLoaders.getAllEntryRevisions({\n model,\n ids: entries\n });\n /**\n *
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsDeleteMultipleEntries.js","sources":["../../../src/operations/entry/DdbEsDeleteMultipleEntries.ts"],"sourcesContent":["import type {\n CmsModel,\n CmsEntryStorageOperationsDeleteEntriesParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { DeleteMultipleEntriesStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/DeleteMultipleEntriesStorageOperation.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { createPartitionKey, createRevisionSortKey } from \"./keys.js\";\n\nclass DdbEsDeleteMultipleEntriesImpl implements DeleteMultipleEntriesStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsEntryEntity.Interface,\n private esEntity: CmsDdbEsEntriesEsEntity.Interface,\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute(initialModel: CmsModel, params: CmsEntryStorageOperationsDeleteEntriesParams) {\n const { entries } = params;\n const model = this.storageModelProvider.getModel(initialModel);\n /**\n * First we need all the revisions of the entries we want to delete.\n */\n const revisions = await this.dataLoaders.getAllEntryRevisions({\n model,\n ids: entries\n });\n /**\n * The Elasticsearch records that exist: an entry that was never published (or was\n * unpublished) has no published record, and deleting a missing record is an error in the\n * stream handling. As DdbEsDeleteEntry does, only the stored records are deleted.\n */\n const esItems = (\n await Promise.all(\n entries.map(id =>\n this.esEntity.queryAll({\n partitionKey: createPartitionKey({\n id,\n tenant: model.tenant\n }),\n options: {\n gte: \" \"\n }\n })\n )\n )\n ).flat();\n\n const entityBatch = this.entity.createEntityWriter();\n const elasticsearchEntityBatch = this.esEntity.createEntityWriter({\n delete: esItems.map(item => ({ PK: item.PK, SK: item.SK }))\n });\n for (const id of entries) {\n const partitionKey = createPartitionKey({\n id,\n tenant: model.tenant\n });\n /**\n * Latest and published items.\n */\n entityBatch.delete({ PK: partitionKey, SK: \"L\" });\n entityBatch.delete({ PK: partitionKey, SK: \"P\" });\n }\n /**\n * Exact revisions of all the entries\n */\n for (const revision of revisions) {\n entityBatch.delete({\n PK: createPartitionKey({\n id: revision.id,\n tenant: model.tenant\n }),\n SK: createRevisionSortKey({\n version: revision.version\n })\n });\n }\n\n await entityBatch.execute();\n await elasticsearchEntityBatch.execute();\n\n this.dataLoaders.clearAll({\n tenant: model.tenant\n });\n }\n}\n\nexport const DdbEsDeleteMultipleEntries =\n DeleteMultipleEntriesStorageOperation.createImplementation({\n implementation: DdbEsDeleteMultipleEntriesImpl,\n dependencies: [\n CmsDdbEsEntryEntity,\n CmsDdbEsEntriesEsEntity,\n CmsDdbEsDataLoaders,\n CmsStorageModelProvider\n ]\n });\n"],"names":["DdbEsDeleteMultipleEntriesImpl","entity","esEntity","dataLoaders","storageModelProvider","initialModel","params","entries","model","revisions","esItems","Promise","id","createPartitionKey","entityBatch","elasticsearchEntityBatch","item","partitionKey","revision","createRevisionSortKey","DdbEsDeleteMultipleEntries","DeleteMultipleEntriesStorageOperation","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity","CmsDdbEsDataLoaders","CmsStorageModelProvider"],"mappings":";;;;;;AAWA,MAAMA;IACF,YACYC,MAAqC,EACrCC,QAA2C,EAC3CC,WAA0C,EAC1CC,oBAAuD,CACjE;aAJUH,M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