@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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DbRegistry } from "@webiny/db/exports/api/db.js";
|
|
2
|
+
import { CmsDdbEsEntryEntity } from "../abstractions/CmsDdbEsEntryEntity.js";
|
|
3
|
+
import { CmsDdbEsEntriesEsEntity } from "../abstractions/CmsDdbEsEntriesEsEntity.js";
|
|
4
|
+
/**
|
|
5
|
+
* Adds the CMS entities to every request's DbRegistry.
|
|
6
|
+
*
|
|
7
|
+
* DbRegistry is container scoped: each request (child) container builds its own, empty registry. The
|
|
8
|
+
* DDB to OpenSearch sync looks up two CMS entities in it (the DynamoDB entries entity and the
|
|
9
|
+
* OpenSearch entries entity), so every one of those registries needs them.
|
|
10
|
+
*
|
|
11
|
+
* The CMS storage feature runs once, in the root, before any request exists, so it can't register into
|
|
12
|
+
* per-request registries directly. Instead it registers this decorator in the root. Decorators on a
|
|
13
|
+
* container-scoped registration apply to every instance as it is built, so this constructor runs once
|
|
14
|
+
* per request registry and adds the two entities. Every other call passes through to the registry.
|
|
15
|
+
*/
|
|
16
|
+
declare class CmsEntitiesDbRegistryDecoratorImpl implements DbRegistry.Interface {
|
|
17
|
+
private readonly decoratee;
|
|
18
|
+
constructor(entryEntity: CmsDdbEsEntryEntity.Interface, entriesEsEntity: CmsDdbEsEntriesEsEntity.Interface, decoratee: DbRegistry.Interface);
|
|
19
|
+
register<T = unknown>(params: DbRegistry.RegisterParams<T>): void;
|
|
20
|
+
getOneItem<T = unknown>(cb: (item: DbRegistry.RegistryItem<T>) => boolean): DbRegistry.RegistryItem<T>;
|
|
21
|
+
getItem<T = unknown>(cb: (item: DbRegistry.RegistryItem<T>) => boolean): DbRegistry.RegistryItem<T> | null;
|
|
22
|
+
getItems<T = unknown>(cb: (item: DbRegistry.RegistryItem<T>) => boolean): DbRegistry.RegistryItem<T>[];
|
|
23
|
+
}
|
|
24
|
+
export declare const CmsEntitiesDbRegistryDecorator: typeof CmsEntitiesDbRegistryDecoratorImpl & {
|
|
25
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/db/features/DbRegistry/abstractions").IRegistry>;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { DbRegistry } from "@webiny/db/exports/api/db.js";
|
|
2
|
+
import { CmsDdbEsEntryEntity } from "../abstractions/CmsDdbEsEntryEntity.js";
|
|
3
|
+
import { CmsDdbEsEntriesEsEntity } from "../abstractions/CmsDdbEsEntriesEsEntity.js";
|
|
4
|
+
class CmsEntitiesDbRegistryDecoratorImpl {
|
|
5
|
+
constructor(entryEntity, entriesEsEntity, decoratee){
|
|
6
|
+
this.decoratee = decoratee;
|
|
7
|
+
decoratee.register({
|
|
8
|
+
item: entryEntity,
|
|
9
|
+
app: "cms",
|
|
10
|
+
tags: [
|
|
11
|
+
"regular",
|
|
12
|
+
entryEntity.name
|
|
13
|
+
]
|
|
14
|
+
});
|
|
15
|
+
decoratee.register({
|
|
16
|
+
item: entriesEsEntity,
|
|
17
|
+
app: "cms",
|
|
18
|
+
tags: [
|
|
19
|
+
"es",
|
|
20
|
+
entriesEsEntity.name
|
|
21
|
+
]
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
register(params) {
|
|
25
|
+
this.decoratee.register(params);
|
|
26
|
+
}
|
|
27
|
+
getOneItem(cb) {
|
|
28
|
+
return this.decoratee.getOneItem(cb);
|
|
29
|
+
}
|
|
30
|
+
getItem(cb) {
|
|
31
|
+
return this.decoratee.getItem(cb);
|
|
32
|
+
}
|
|
33
|
+
getItems(cb) {
|
|
34
|
+
return this.decoratee.getItems(cb);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const CmsEntitiesDbRegistryDecorator = DbRegistry.createDecorator({
|
|
38
|
+
decorator: CmsEntitiesDbRegistryDecoratorImpl,
|
|
39
|
+
dependencies: [
|
|
40
|
+
CmsDdbEsEntryEntity,
|
|
41
|
+
CmsDdbEsEntriesEsEntity
|
|
42
|
+
]
|
|
43
|
+
});
|
|
44
|
+
export { CmsEntitiesDbRegistryDecorator };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=CmsEntitiesDbRegistryDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry/CmsEntitiesDbRegistryDecorator.js","sources":["../../src/registry/CmsEntitiesDbRegistryDecorator.ts"],"sourcesContent":["import { DbRegistry } from \"@webiny/db/exports/api/db.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsDdbEsEntriesEsEntity } from \"~/abstractions/CmsDdbEsEntriesEsEntity.js\";\n\n/**\n * Adds the CMS entities to every request's DbRegistry.\n *\n * DbRegistry is container scoped: each request (child) container builds its own, empty registry. The\n * DDB to OpenSearch sync looks up two CMS entities in it (the DynamoDB entries entity and the\n * OpenSearch entries entity), so every one of those registries needs them.\n *\n * The CMS storage feature runs once, in the root, before any request exists, so it can't register into\n * per-request registries directly. Instead it registers this decorator in the root. Decorators on a\n * container-scoped registration apply to every instance as it is built, so this constructor runs once\n * per request registry and adds the two entities. Every other call passes through to the registry.\n */\nclass CmsEntitiesDbRegistryDecoratorImpl implements DbRegistry.Interface {\n public constructor(\n entryEntity: CmsDdbEsEntryEntity.Interface,\n entriesEsEntity: CmsDdbEsEntriesEsEntity.Interface,\n private readonly decoratee: DbRegistry.Interface\n ) {\n decoratee.register({\n item: entryEntity,\n app: \"cms\",\n tags: [\"regular\", entryEntity.name]\n });\n decoratee.register({\n item: entriesEsEntity,\n app: \"cms\",\n tags: [\"es\", entriesEsEntity.name]\n });\n }\n\n public register<T = unknown>(params: DbRegistry.RegisterParams<T>): void {\n this.decoratee.register(params);\n }\n\n public getOneItem<T = unknown>(\n cb: (item: DbRegistry.RegistryItem<T>) => boolean\n ): DbRegistry.RegistryItem<T> {\n return this.decoratee.getOneItem(cb);\n }\n\n public getItem<T = unknown>(\n cb: (item: DbRegistry.RegistryItem<T>) => boolean\n ): DbRegistry.RegistryItem<T> | null {\n return this.decoratee.getItem(cb);\n }\n\n public getItems<T = unknown>(\n cb: (item: DbRegistry.RegistryItem<T>) => boolean\n ): DbRegistry.RegistryItem<T>[] {\n return this.decoratee.getItems(cb);\n }\n}\n\nexport const CmsEntitiesDbRegistryDecorator = DbRegistry.createDecorator({\n decorator: CmsEntitiesDbRegistryDecoratorImpl,\n dependencies: [CmsDdbEsEntryEntity, CmsDdbEsEntriesEsEntity]\n});\n"],"names":["CmsEntitiesDbRegistryDecoratorImpl","entryEntity","entriesEsEntity","decoratee","params","cb","CmsEntitiesDbRegistryDecorator","DbRegistry","CmsDdbEsEntryEntity","CmsDdbEsEntriesEsEntity"],"mappings":";;;AAgBA,MAAMA;IACF,YACIC,WAA0C,EAC1CC,eAAkD,EACjCC,SAA+B,CAClD;aADmBA,SAAS,GAATA;QAEjBA,UAAU,QAAQ,CAAC;YACf,MAAMF;YACN,KAAK;YACL,MAAM;gBAAC;gBAAWA,YAAY,IAAI;aAAC;QACvC;QACAE,UAAU,QAAQ,CAAC;YACf,MAAMD;YACN,KAAK;YACL,MAAM;gBAAC;gBAAMA,gBAAgB,IAAI;aAAC;QACtC;IACJ;IAEO,SAAsBE,MAAoC,EAAQ;QACrE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAACA;IAC5B;IAEO,WACHC,EAAiD,EACvB;QAC1B,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAACA;IACrC;IAEO,QACHA,EAAiD,EAChB;QACjC,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAACA;IAClC;IAEO,SACHA,EAAiD,EACrB;QAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAACA;IACnC;AACJ;AAEO,MAAMC,iCAAiCC,WAAW,eAAe,CAAC;IACrE,WAAWP;IACX,cAAc;QAACQ;QAAqBC;KAAwB;AAChE"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { TenantIndexFactory } from "@webiny/api-search-index-tasks";
|
|
2
2
|
import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
|
|
3
|
-
import {
|
|
3
|
+
import { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
4
|
+
import { Logger } from "@webiny/api-core/features/logger/index.js";
|
|
4
5
|
declare class CreateElasticsearchIndexTaskImpl implements TenantIndexFactory.Interface {
|
|
5
|
-
private readonly
|
|
6
|
+
private readonly indexProvider;
|
|
6
7
|
private listModels;
|
|
7
|
-
|
|
8
|
+
private readonly logger;
|
|
9
|
+
constructor(indexProvider: CmsModelOpenSearchIndexProvider.Interface, listModels: ListModelsUseCase.Interface, logger: Logger.Interface);
|
|
8
10
|
getIndexList(tenant: TenantIndexFactory.Tenant): Promise<TenantIndexFactory.IndexConfig[]>;
|
|
9
11
|
}
|
|
10
12
|
export declare const CreateElasticsearchIndexTask: typeof CreateElasticsearchIndexTaskImpl & {
|
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
import { TenantIndexFactory } from "@webiny/api-search-index-tasks";
|
|
2
2
|
import { ListModelsUseCase } from "@webiny/api-headless-cms/features/contentModel/ListModels/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { createConfigurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
|
|
4
|
+
import { CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
5
|
+
import { Logger } from "@webiny/api-core/features/logger/index.js";
|
|
5
6
|
class CreateElasticsearchIndexTaskImpl {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
7
|
+
constructor(indexProvider, listModels, logger){
|
|
8
|
+
this.indexProvider = indexProvider;
|
|
8
9
|
this.listModels = listModels;
|
|
10
|
+
this.logger = logger;
|
|
9
11
|
}
|
|
10
12
|
async getIndexList(tenant) {
|
|
11
13
|
const result = await this.listModels.execute();
|
|
14
|
+
if (result.isFail()) {
|
|
15
|
+
this.logger.error({
|
|
16
|
+
error: result.error
|
|
17
|
+
}, "Failed to list models for index creation.");
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
12
20
|
const models = result.value;
|
|
13
21
|
if (0 === models.length) return [];
|
|
14
|
-
|
|
15
|
-
|
|
22
|
+
const configurations = createConfigurations(this.indexProvider);
|
|
23
|
+
const indices = [];
|
|
24
|
+
for (const model of models){
|
|
25
|
+
const { index, settings } = await configurations.es({
|
|
16
26
|
model: {
|
|
17
|
-
|
|
27
|
+
...model,
|
|
18
28
|
tenant: tenant.id
|
|
19
29
|
}
|
|
20
30
|
});
|
|
21
|
-
|
|
31
|
+
indices.push({
|
|
22
32
|
index,
|
|
23
|
-
settings
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
tenant: tenant.id,
|
|
28
|
-
group: model.group
|
|
29
|
-
}
|
|
30
|
-
})
|
|
31
|
-
};
|
|
32
|
-
});
|
|
33
|
+
settings
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return indices;
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
const CreateElasticsearchIndexTask = TenantIndexFactory.createImplementation({
|
|
36
40
|
implementation: CreateElasticsearchIndexTaskImpl,
|
|
37
41
|
dependencies: [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
multiple: true
|
|
42
|
-
}
|
|
43
|
-
],
|
|
44
|
-
ListModelsUseCase
|
|
42
|
+
CmsModelOpenSearchIndexProvider,
|
|
43
|
+
ListModelsUseCase,
|
|
44
|
+
Logger
|
|
45
45
|
]
|
|
46
46
|
});
|
|
47
47
|
export { CreateElasticsearchIndexTask };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks/CreateElasticsearchIndexTask.js","sources":["../../src/tasks/CreateElasticsearchIndexTask.ts"],"sourcesContent":["import { TenantIndexFactory } from \"@webiny/api-search-index-tasks\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"tasks/CreateElasticsearchIndexTask.js","sources":["../../src/tasks/CreateElasticsearchIndexTask.ts"],"sourcesContent":["import { TenantIndexFactory } from \"@webiny/api-search-index-tasks\";\nimport { ListModelsUseCase } from \"@webiny/api-headless-cms/features/contentModel/ListModels/index.js\";\nimport { createConfigurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { CmsModelOpenSearchIndexProvider } from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport { Logger } from \"@webiny/api-core/features/logger/index.js\";\n\nclass CreateElasticsearchIndexTaskImpl implements TenantIndexFactory.Interface {\n constructor(\n private readonly indexProvider: CmsModelOpenSearchIndexProvider.Interface,\n private listModels: ListModelsUseCase.Interface,\n private readonly logger: Logger.Interface\n ) {}\n\n async getIndexList(\n tenant: TenantIndexFactory.Tenant\n ): Promise<TenantIndexFactory.IndexConfig[]> {\n const result = await this.listModels.execute();\n if (result.isFail()) {\n this.logger.error({ error: result.error }, \"Failed to list models for index creation.\");\n return [];\n }\n const models = result.value;\n\n if (models.length === 0) {\n return [];\n }\n\n const configurations = createConfigurations(this.indexProvider);\n\n const indices: TenantIndexFactory.IndexConfig[] = [];\n for (const model of models) {\n const { index, settings } = await configurations.es({\n model: {\n ...model,\n tenant: tenant.id\n }\n });\n indices.push({ index, settings });\n }\n return indices;\n }\n}\n\nexport const CreateElasticsearchIndexTask = TenantIndexFactory.createImplementation({\n implementation: CreateElasticsearchIndexTaskImpl,\n dependencies: [CmsModelOpenSearchIndexProvider, ListModelsUseCase, Logger]\n});\n"],"names":["CreateElasticsearchIndexTaskImpl","indexProvider","listModels","logger","tenant","result","models","configurations","createConfigurations","indices","model","index","settings","CreateElasticsearchIndexTask","TenantIndexFactory","CmsModelOpenSearchIndexProvider","ListModelsUseCase","Logger"],"mappings":";;;;;AAMA,MAAMA;IACF,YACqBC,aAAwD,EACjEC,UAAuC,EAC9BC,MAAwB,CAC3C;aAHmBF,aAAa,GAAbA;aACTC,UAAU,GAAVA;aACSC,MAAM,GAANA;IAClB;IAEH,MAAM,aACFC,MAAiC,EACQ;QACzC,MAAMC,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO;QAC5C,IAAIA,OAAO,MAAM,IAAI;YACjB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAAE,OAAOA,OAAO,KAAK;YAAC,GAAG;YAC3C,OAAO,EAAE;QACb;QACA,MAAMC,SAASD,OAAO,KAAK;QAE3B,IAAIC,AAAkB,MAAlBA,OAAO,MAAM,EACb,OAAO,EAAE;QAGb,MAAMC,iBAAiBC,qBAAqB,IAAI,CAAC,aAAa;QAE9D,MAAMC,UAA4C,EAAE;QACpD,KAAK,MAAMC,SAASJ,OAAQ;YACxB,MAAM,EAAEK,KAAK,EAAEC,QAAQ,EAAE,GAAG,MAAML,eAAe,EAAE,CAAC;gBAChD,OAAO;oBACH,GAAGG,KAAK;oBACR,QAAQN,OAAO,EAAE;gBACrB;YACJ;YACAK,QAAQ,IAAI,CAAC;gBAAEE;gBAAOC;YAAS;QACnC;QACA,OAAOH;IACX;AACJ;AAEO,MAAMI,+BAA+BC,mBAAmB,oBAAoB,CAAC;IAChF,gBAAgBd;IAChB,cAAc;QAACe;QAAiCC;QAAmBC;KAAO;AAC9E"}
|