@webiny/api-headless-cms-ddb-es 0.0.0-mt-2 → 0.0.0-unstable.0156a4c312
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/README.md +6 -30
- package/abstractions/CmsDdbEsDataLoaders.d.ts +5 -0
- package/abstractions/CmsDdbEsDataLoaders.js +5 -0
- package/abstractions/CmsDdbEsDataLoaders.js.map +1 -0
- package/abstractions/CmsDdbEsEntriesEsEntity.d.ts +5 -0
- package/abstractions/CmsDdbEsEntriesEsEntity.js +5 -0
- package/abstractions/CmsDdbEsEntriesEsEntity.js.map +1 -0
- package/abstractions/CmsDdbEsEntryEntity.d.ts +5 -0
- package/abstractions/CmsDdbEsEntryEntity.js +5 -0
- package/abstractions/CmsDdbEsEntryEntity.js.map +1 -0
- package/abstractions/CmsDdbEsGroupEntity.d.ts +5 -0
- package/abstractions/CmsDdbEsGroupEntity.js +5 -0
- package/abstractions/CmsDdbEsGroupEntity.js.map +1 -0
- package/abstractions/CmsDdbEsModelEntity.d.ts +5 -0
- package/abstractions/CmsDdbEsModelEntity.js +5 -0
- package/abstractions/CmsDdbEsModelEntity.js.map +1 -0
- package/abstractions/CmsDdbEsOsTable.d.ts +5 -0
- package/abstractions/CmsDdbEsOsTable.js +5 -0
- package/abstractions/CmsDdbEsOsTable.js.map +1 -0
- package/abstractions/CmsDdbEsTable.d.ts +5 -0
- package/abstractions/CmsDdbEsTable.js +5 -0
- package/abstractions/CmsDdbEsTable.js.map +1 -0
- package/debuggerNamespaces.d.ts +12 -0
- package/debuggerNamespaces.js +0 -0
- package/definitions/entry.d.ts +5 -6
- package/definitions/entry.js +9 -89
- package/definitions/entry.js.map +1 -0
- package/definitions/group.d.ts +6 -6
- package/definitions/group.js +9 -72
- package/definitions/group.js.map +1 -0
- package/definitions/model.d.ts +6 -6
- package/definitions/model.js +9 -94
- package/definitions/model.js.map +1 -0
- package/definitions/types.d.ts +65 -0
- package/definitions/types.js +0 -0
- package/feature.d.ts +10 -0
- package/feature.js +69 -0
- package/feature.js.map +1 -0
- package/index.d.ts +1 -2
- package/index.js +1 -171
- package/operations/entry/DdbEsCreateEntry.d.ts +24 -0
- package/operations/entry/DdbEsCreateEntry.js +134 -0
- package/operations/entry/DdbEsCreateEntry.js.map +1 -0
- package/operations/entry/DdbEsCreateEntryRevisionFrom.d.ts +24 -0
- package/operations/entry/DdbEsCreateEntryRevisionFrom.js +139 -0
- package/operations/entry/DdbEsCreateEntryRevisionFrom.js.map +1 -0
- package/operations/entry/DdbEsDeleteEntry.d.ts +18 -0
- package/operations/entry/DdbEsDeleteEntry.js +79 -0
- package/operations/entry/DdbEsDeleteEntry.js.map +1 -0
- package/operations/entry/DdbEsDeleteEntryRevision.d.ts +24 -0
- package/operations/entry/DdbEsDeleteEntryRevision.js +136 -0
- package/operations/entry/DdbEsDeleteEntryRevision.js.map +1 -0
- package/operations/entry/DdbEsDeleteMultipleEntries.d.ts +18 -0
- package/operations/entry/DdbEsDeleteMultipleEntries.js +80 -0
- package/operations/entry/DdbEsDeleteMultipleEntries.js.map +1 -0
- package/operations/entry/DdbEsGetEntriesByIds.d.ts +14 -0
- package/operations/entry/DdbEsGetEntriesByIds.js +31 -0
- package/operations/entry/DdbEsGetEntriesByIds.js.map +1 -0
- package/operations/entry/DdbEsGetEntry.d.ts +14 -0
- package/operations/entry/DdbEsGetEntry.js +27 -0
- package/operations/entry/DdbEsGetEntry.js.map +1 -0
- package/operations/entry/DdbEsGetLatestEntriesByIds.d.ts +14 -0
- package/operations/entry/DdbEsGetLatestEntriesByIds.js +31 -0
- package/operations/entry/DdbEsGetLatestEntriesByIds.js.map +1 -0
- package/operations/entry/DdbEsGetLatestRevisionByEntryId.d.ts +14 -0
- package/operations/entry/DdbEsGetLatestRevisionByEntryId.js +34 -0
- package/operations/entry/DdbEsGetLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/DdbEsGetPreviousRevision.d.ts +14 -0
- package/operations/entry/DdbEsGetPreviousRevision.js +56 -0
- package/operations/entry/DdbEsGetPreviousRevision.js.map +1 -0
- package/operations/entry/DdbEsGetPublishedEntriesByIds.d.ts +14 -0
- package/operations/entry/DdbEsGetPublishedEntriesByIds.js +31 -0
- package/operations/entry/DdbEsGetPublishedEntriesByIds.js.map +1 -0
- package/operations/entry/DdbEsGetPublishedRevisionByEntryId.d.ts +14 -0
- package/operations/entry/DdbEsGetPublishedRevisionByEntryId.js +34 -0
- package/operations/entry/DdbEsGetPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/DdbEsGetRevisionById.d.ts +14 -0
- package/operations/entry/DdbEsGetRevisionById.js +34 -0
- package/operations/entry/DdbEsGetRevisionById.js.map +1 -0
- package/operations/entry/DdbEsGetRevisions.d.ts +14 -0
- package/operations/entry/DdbEsGetRevisions.js +33 -0
- package/operations/entry/DdbEsGetRevisions.js.map +1 -0
- package/operations/entry/DdbEsGetUniqueFieldValues.d.ts +18 -0
- package/operations/entry/DdbEsGetUniqueFieldValues.js +77 -0
- package/operations/entry/DdbEsGetUniqueFieldValues.js.map +1 -0
- package/operations/entry/DdbEsListEntries.d.ts +28 -0
- package/operations/entry/DdbEsListEntries.js +110 -0
- package/operations/entry/DdbEsListEntries.js.map +1 -0
- package/operations/entry/DdbEsMoveEntry.d.ts +20 -0
- package/operations/entry/DdbEsMoveEntry.js +113 -0
- package/operations/entry/DdbEsMoveEntry.js.map +1 -0
- package/operations/entry/DdbEsMoveToBin.d.ts +23 -0
- package/operations/entry/DdbEsMoveToBin.js +137 -0
- package/operations/entry/DdbEsMoveToBin.js.map +1 -0
- package/operations/entry/DdbEsPublishEntry.d.ts +24 -0
- package/operations/entry/DdbEsPublishEntry.js +231 -0
- package/operations/entry/DdbEsPublishEntry.js.map +1 -0
- package/operations/entry/DdbEsRestoreFromBin.d.ts +23 -0
- package/operations/entry/DdbEsRestoreFromBin.js +137 -0
- package/operations/entry/DdbEsRestoreFromBin.js.map +1 -0
- package/operations/entry/DdbEsUnpublishEntry.d.ts +24 -0
- package/operations/entry/DdbEsUnpublishEntry.js +127 -0
- package/operations/entry/DdbEsUnpublishEntry.js.map +1 -0
- package/operations/entry/DdbEsUpdateEntry.d.ts +24 -0
- package/operations/entry/DdbEsUpdateEntry.js +175 -0
- package/operations/entry/DdbEsUpdateEntry.js.map +1 -0
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
- package/operations/entry/dataLoader/constants.d.ts +1 -0
- package/operations/entry/dataLoader/constants.js +5 -0
- package/operations/entry/dataLoader/constants.js.map +1 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +34 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +34 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
- package/operations/entry/dataLoader/getRevisionById.js +40 -0
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
- package/operations/entry/dataLoader/index.d.ts +8 -0
- package/operations/entry/dataLoader/index.js +18 -0
- package/operations/entry/dataLoader/index.js.map +1 -0
- package/operations/entry/dataLoader/types.d.ts +6 -0
- package/operations/entry/dataLoader/types.js +0 -0
- package/operations/entry/dataLoaders.d.ts +22 -39
- package/operations/entry/dataLoaders.js +90 -339
- package/operations/entry/dataLoaders.js.map +1 -0
- package/operations/entry/feature.d.ts +4 -0
- package/operations/entry/feature.js +55 -0
- package/operations/entry/feature.js.map +1 -0
- package/operations/entry/keys.d.ts +31 -1
- package/operations/entry/keys.js +45 -35
- package/operations/entry/keys.js.map +1 -0
- package/operations/entry/recordType.d.ts +3 -0
- package/operations/entry/recordType.js +6 -0
- package/operations/entry/recordType.js.map +1 -0
- package/operations/entry/storageEntryUtils.d.ts +7 -0
- package/operations/entry/storageEntryUtils.js +14 -0
- package/operations/entry/storageEntryUtils.js.map +1 -0
- package/operations/entry/transformations/convertEntryKeys.d.ts +8 -0
- package/operations/entry/transformations/convertEntryKeys.js +25 -0
- package/operations/entry/transformations/convertEntryKeys.js.map +1 -0
- package/operations/entry/transformations/index.d.ts +32 -0
- package/operations/entry/transformations/index.js +91 -0
- package/operations/entry/transformations/index.js.map +1 -0
- package/operations/entry/transformations/modifyEntryValues.d.ts +53 -0
- package/operations/entry/transformations/modifyEntryValues.js +16 -0
- package/operations/entry/transformations/modifyEntryValues.js.map +1 -0
- package/operations/entry/transformations/transformEntryKeys.d.ts +11 -0
- package/operations/entry/transformations/transformEntryKeys.js +17 -0
- package/operations/entry/transformations/transformEntryKeys.js.map +1 -0
- package/operations/group/DdbEsCreateGroup.d.ts +12 -0
- package/operations/group/DdbEsCreateGroup.js +35 -0
- package/operations/group/DdbEsCreateGroup.js.map +1 -0
- package/operations/group/DdbEsDeleteGroup.d.ts +12 -0
- package/operations/group/DdbEsDeleteGroup.js +31 -0
- package/operations/group/DdbEsDeleteGroup.js.map +1 -0
- package/operations/group/DdbEsGetGroup.d.ts +12 -0
- package/operations/group/DdbEsGetGroup.js +31 -0
- package/operations/group/DdbEsGetGroup.js.map +1 -0
- package/operations/group/DdbEsListGroups.d.ts +14 -0
- package/operations/group/DdbEsListGroups.js +52 -0
- package/operations/group/DdbEsListGroups.js.map +1 -0
- package/operations/group/DdbEsUpdateGroup.d.ts +12 -0
- package/operations/group/DdbEsUpdateGroup.js +35 -0
- package/operations/group/DdbEsUpdateGroup.js.map +1 -0
- package/operations/group/feature.d.ts +4 -0
- package/operations/group/feature.js +19 -0
- package/operations/group/feature.js.map +1 -0
- package/operations/group/keys.d.ts +15 -0
- package/operations/group/keys.js +17 -0
- package/operations/group/keys.js.map +1 -0
- package/operations/model/DdbEsCreateModel.d.ts +16 -0
- package/operations/model/DdbEsCreateModel.js +56 -0
- package/operations/model/DdbEsCreateModel.js.map +1 -0
- package/operations/model/DdbEsDeleteModel.d.ts +12 -0
- package/operations/model/DdbEsDeleteModel.js +31 -0
- package/operations/model/DdbEsDeleteModel.js.map +1 -0
- package/operations/model/DdbEsGetModel.d.ts +12 -0
- package/operations/model/DdbEsGetModel.js +30 -0
- package/operations/model/DdbEsGetModel.js.map +1 -0
- package/operations/model/DdbEsListModels.d.ts +12 -0
- package/operations/model/DdbEsListModels.js +36 -0
- package/operations/model/DdbEsListModels.js.map +1 -0
- package/operations/model/DdbEsUpdateModel.d.ts +12 -0
- package/operations/model/DdbEsUpdateModel.js +36 -0
- package/operations/model/DdbEsUpdateModel.js.map +1 -0
- package/operations/model/feature.d.ts +4 -0
- package/operations/model/feature.js +19 -0
- package/operations/model/feature.js.map +1 -0
- package/operations/model/keys.d.ts +15 -0
- package/operations/model/keys.js +17 -0
- package/operations/model/keys.js.map +1 -0
- package/package.json +49 -46
- 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 +15 -0
- package/tasks/CreateElasticsearchIndexTask.js +49 -0
- package/tasks/CreateElasticsearchIndexTask.js.map +1 -0
- package/types.d.ts +13 -182
- package/types.js +10 -60
- package/types.js.map +1 -0
- package/configurations.d.ts +0 -12
- package/configurations.js +0 -32
- package/definitions/entryElasticsearch.d.ts +0 -8
- package/definitions/entryElasticsearch.js +0 -46
- package/definitions/settings.d.ts +0 -8
- package/definitions/settings.js +0 -62
- package/definitions/system.d.ts +0 -8
- package/definitions/system.js +0 -50
- package/definitions/table.d.ts +0 -8
- package/definitions/table.js +0 -24
- package/definitions/tableElasticsearch.d.ts +0 -8
- package/definitions/tableElasticsearch.js +0 -24
- package/dynamoDb/index.d.ts +0 -2
- package/dynamoDb/index.js +0 -18
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -65
- package/dynamoDb/storage/longText.d.ts +0 -7
- package/dynamoDb/storage/longText.js +0 -83
- package/dynamoDb/storage/richText.d.ts +0 -8
- package/dynamoDb/storage/richText.js +0 -110
- package/elasticsearch/index.d.ts +0 -2
- package/elasticsearch/index.js +0 -16
- package/elasticsearch/indexing/dateTimeIndexing.d.ts +0 -3
- package/elasticsearch/indexing/dateTimeIndexing.js +0 -89
- package/elasticsearch/indexing/defaultFieldIndexing.d.ts +0 -3
- package/elasticsearch/indexing/defaultFieldIndexing.js +0 -47
- package/elasticsearch/indexing/index.d.ts +0 -2
- package/elasticsearch/indexing/index.js +0 -24
- package/elasticsearch/indexing/longTextIndexing.d.ts +0 -3
- package/elasticsearch/indexing/longTextIndexing.js +0 -36
- package/elasticsearch/indexing/numberIndexing.d.ts +0 -3
- package/elasticsearch/indexing/numberIndexing.js +0 -48
- package/elasticsearch/indexing/objectIndexing.d.ts +0 -3
- package/elasticsearch/indexing/objectIndexing.js +0 -200
- package/elasticsearch/indexing/richTextIndexing.d.ts +0 -3
- package/elasticsearch/indexing/richTextIndexing.js +0 -34
- package/elasticsearch/search/index.d.ts +0 -3
- package/elasticsearch/search/index.js +0 -16
- package/elasticsearch/search/refSearch.d.ts +0 -3
- package/elasticsearch/search/refSearch.js +0 -24
- package/elasticsearch/search/timeSearch.d.ts +0 -3
- package/elasticsearch/search/timeSearch.js +0 -25
- package/helpers/createElasticsearchQueryBody.d.ts +0 -11
- package/helpers/createElasticsearchQueryBody.js +0 -375
- package/helpers/entryIndexHelpers.d.ts +0 -18
- package/helpers/entryIndexHelpers.js +0 -189
- package/helpers/fields.d.ts +0 -77
- package/helpers/fields.js +0 -174
- package/helpers/index.d.ts +0 -2
- package/helpers/index.js +0 -31
- package/helpers/operatorPluginsList.d.ts +0 -7
- package/helpers/operatorPluginsList.js +0 -30
- package/helpers/searchPluginsList.d.ts +0 -6
- package/helpers/searchPluginsList.js +0 -26
- package/helpers/transformValueForSearch.d.ts +0 -9
- package/helpers/transformValueForSearch.js +0 -26
- package/operations/entry/elasticsearchFields.d.ts +0 -2
- package/operations/entry/elasticsearchFields.js +0 -32
- package/operations/entry/fields.d.ts +0 -3
- package/operations/entry/fields.js +0 -60
- package/operations/entry/index.d.ts +0 -13
- package/operations/entry/index.js +0 -1152
- package/operations/group/index.d.ts +0 -8
- package/operations/group/index.js +0 -202
- package/operations/model/index.d.ts +0 -8
- package/operations/model/index.js +0 -205
- package/operations/settings/index.d.ts +0 -6
- package/operations/settings/index.js +0 -141
- package/operations/system/createElasticsearchTemplate.d.ts +0 -5
- package/operations/system/createElasticsearchTemplate.js +0 -62
- package/operations/system/index.d.ts +0 -6
- package/operations/system/index.js +0 -105
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +0 -17
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +0 -24
- package/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +0 -12
- package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -24
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +0 -17
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +0 -24
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +0 -17
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +0 -24
- package/upgrades/index.d.ts +0 -2
- package/upgrades/index.js +0 -16
- package/upgrades/utils.d.ts +0 -1
- package/upgrades/utils.js +0 -16
- package/upgrades/v5.0.0/cleanDatabaseRecord.d.ts +0 -6
- package/upgrades/v5.0.0/cleanDatabaseRecord.js +0 -16
- package/upgrades/v5.0.0/createOldVersionIndiceName.d.ts +0 -2
- package/upgrades/v5.0.0/createOldVersionIndiceName.js +0 -12
- package/upgrades/v5.0.0/entryValueFixer.d.ts +0 -4
- package/upgrades/v5.0.0/entryValueFixer.js +0 -124
- package/upgrades/v5.0.0/fieldFinder.d.ts +0 -6
- package/upgrades/v5.0.0/fieldFinder.js +0 -42
- package/upgrades/v5.0.0/helpers.d.ts +0 -4
- package/upgrades/v5.0.0/helpers.js +0 -57
- package/upgrades/v5.0.0/index.d.ts +0 -4
- package/upgrades/v5.0.0/index.js +0 -232
- package/upgrades/v5.8.0/index.d.ts +0 -4
- package/upgrades/v5.8.0/index.js +0 -426
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsGetPreviousRevisionParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetPreviousRevisionStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js";
|
|
3
|
+
import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
|
|
4
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
declare class DdbEsGetPreviousRevisionImpl implements GetPreviousRevisionStorageOperation.Interface {
|
|
6
|
+
private entity;
|
|
7
|
+
private storageModelProvider;
|
|
8
|
+
constructor(entity: CmsDdbEsEntryEntity.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
|
|
9
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsGetPreviousRevisionParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T> | null>;
|
|
10
|
+
}
|
|
11
|
+
export declare const DdbEsGetPreviousRevision: typeof DdbEsGetPreviousRevisionImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js").IGetPreviousRevisionStorageOperation>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import error from "@webiny/error";
|
|
2
|
+
import { GetPreviousRevisionStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js";
|
|
3
|
+
import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
|
|
4
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
import { createPartitionKey } from "./keys.js";
|
|
6
|
+
import { convertEntryKeysFromStorage } from "./transformations/convertEntryKeys.js";
|
|
7
|
+
class DdbEsGetPreviousRevisionImpl {
|
|
8
|
+
constructor(entity, storageModelProvider){
|
|
9
|
+
this.entity = entity;
|
|
10
|
+
this.storageModelProvider = storageModelProvider;
|
|
11
|
+
}
|
|
12
|
+
async execute(initialModel, params) {
|
|
13
|
+
const model = this.storageModelProvider.getModel(initialModel);
|
|
14
|
+
const { tenant } = model;
|
|
15
|
+
const { entryId, version } = params;
|
|
16
|
+
const partitionKey = createPartitionKey({
|
|
17
|
+
tenant,
|
|
18
|
+
id: entryId
|
|
19
|
+
});
|
|
20
|
+
const options = {
|
|
21
|
+
beginsWith: "REV#",
|
|
22
|
+
reverse: true
|
|
23
|
+
};
|
|
24
|
+
try {
|
|
25
|
+
const unfilteredEntries = (await this.entity.queryAll({
|
|
26
|
+
partitionKey,
|
|
27
|
+
options
|
|
28
|
+
})).map((item)=>item.data);
|
|
29
|
+
const entries = unfilteredEntries.filter((item)=>item.modelId === model.modelId && item.version < version);
|
|
30
|
+
const entry = entries[0];
|
|
31
|
+
if (!entry) return null;
|
|
32
|
+
return convertEntryKeysFromStorage({
|
|
33
|
+
entry,
|
|
34
|
+
model
|
|
35
|
+
});
|
|
36
|
+
} catch (ex) {
|
|
37
|
+
throw new error(ex.message || "Could not get previous version of given entry.", ex.code || "GET_PREVIOUS_VERSION_ERROR", {
|
|
38
|
+
...params,
|
|
39
|
+
error: ex,
|
|
40
|
+
partitionKey,
|
|
41
|
+
options,
|
|
42
|
+
model
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const DdbEsGetPreviousRevision = GetPreviousRevisionStorageOperation.createImplementation({
|
|
48
|
+
implementation: DdbEsGetPreviousRevisionImpl,
|
|
49
|
+
dependencies: [
|
|
50
|
+
CmsDdbEsEntryEntity,
|
|
51
|
+
CmsStorageModelProvider
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
export { DdbEsGetPreviousRevision };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=DdbEsGetPreviousRevision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsGetPreviousRevision.js","sources":["../../../src/operations/entry/DdbEsGetPreviousRevision.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsGetPreviousRevisionParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetPreviousRevisionStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPreviousRevisionStorageOperation.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { createPartitionKey } from \"./keys.js\";\nimport { convertEntryKeysFromStorage } from \"./transformations/convertEntryKeys.js\";\nimport type { IEntityQueryAllParams } from \"@webiny/db-dynamodb\";\n\nclass DdbEsGetPreviousRevisionImpl implements GetPreviousRevisionStorageOperation.Interface {\n constructor(\n private entity: CmsDdbEsEntryEntity.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsGetPreviousRevisionParams\n ) {\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const { tenant } = model;\n const { entryId, version } = params;\n\n const partitionKey = createPartitionKey({\n tenant,\n id: entryId\n });\n const options: IEntityQueryAllParams[\"options\"] = {\n beginsWith: `REV#`,\n reverse: true\n };\n\n try {\n const unfilteredEntries = (\n await this.entity.queryAll({\n partitionKey,\n options\n })\n ).map(item => {\n return item.data;\n });\n\n /**\n * The partition key does not include the model, so filter by it as well.\n */\n const entries = unfilteredEntries.filter(item => {\n return item.modelId === model.modelId && item.version < version;\n });\n\n const entry = entries[0];\n\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage<T>({\n entry,\n model\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get previous version of given entry.\",\n ex.code || \"GET_PREVIOUS_VERSION_ERROR\",\n {\n ...params,\n error: ex,\n partitionKey,\n options,\n model\n }\n );\n }\n }\n}\n\nexport const DdbEsGetPreviousRevision = GetPreviousRevisionStorageOperation.createImplementation({\n implementation: DdbEsGetPreviousRevisionImpl,\n dependencies: [CmsDdbEsEntryEntity, CmsStorageModelProvider]\n});\n"],"names":["DdbEsGetPreviousRevisionImpl","entity","storageModelProvider","initialModel","params","model","tenant","entryId","version","partitionKey","createPartitionKey","options","unfilteredEntries","item","entries","entry","convertEntryKeysFromStorage","ex","WebinyError","DdbEsGetPreviousRevision","GetPreviousRevisionStorageOperation","CmsDdbEsEntryEntity","CmsStorageModelProvider"],"mappings":";;;;;;AAaA,MAAMA;IACF,YACYC,MAAqC,EACrCC,oBAAuD,CACjE;aAFUD,MAAM,GAANA;aACAC,oBAAoB,GAApBA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAA0D,EAC5D;QACE,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIF;QAEpD,MAAM,EAAEG,MAAM,EAAE,GAAGD;QACnB,MAAM,EAAEE,OAAO,EAAEC,OAAO,EAAE,GAAGJ;QAE7B,MAAMK,eAAeC,mBAAmB;YACpCJ;YACA,IAAIC;QACR;QACA,MAAMI,UAA4C;YAC9C,YAAY;YACZ,SAAS;QACb;QAEA,IAAI;YACA,MAAMC,oBACF,OAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;gBACvBH;gBACAE;YACJ,EAAC,EACH,GAAG,CAACE,CAAAA,OACKA,KAAK,IAAI;YAMpB,MAAMC,UAAUF,kBAAkB,MAAM,CAACC,CAAAA,OAC9BA,KAAK,OAAO,KAAKR,MAAM,OAAO,IAAIQ,KAAK,OAAO,GAAGL;YAG5D,MAAMO,QAAQD,OAAO,CAAC,EAAE;YAExB,IAAI,CAACC,OACD,OAAO;YAEX,OAAOC,4BAA+B;gBAClCD;gBACAV;YACJ;QACJ,EAAE,OAAOY,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,kDACdA,GAAG,IAAI,IAAI,8BACX;gBACI,GAAGb,MAAM;gBACT,OAAOa;gBACPR;gBACAE;gBACAN;YACJ;QAER;IACJ;AACJ;AAEO,MAAMc,2BAA2BC,oCAAoC,oBAAoB,CAAC;IAC7F,gBAAgBpB;IAChB,cAAc;QAACqB;QAAqBC;KAAwB;AAChE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsGetPublishedByIdsParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetPublishedEntriesByIdsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.js";
|
|
3
|
+
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
4
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
declare class DdbEsGetPublishedEntriesByIdsImpl implements GetPublishedEntriesByIdsStorageOperation.Interface {
|
|
6
|
+
private dataLoaders;
|
|
7
|
+
private storageModelProvider;
|
|
8
|
+
constructor(dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
|
|
9
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsGetPublishedByIdsParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T>[]>;
|
|
10
|
+
}
|
|
11
|
+
export declare const DdbEsGetPublishedEntriesByIds: typeof DdbEsGetPublishedEntriesByIdsImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.js").IGetPublishedEntriesByIdsStorageOperation>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { GetPublishedEntriesByIdsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.js";
|
|
2
|
+
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
3
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
4
|
+
import { convertEntryKeysFromStorage } from "./transformations/convertEntryKeys.js";
|
|
5
|
+
class DdbEsGetPublishedEntriesByIdsImpl {
|
|
6
|
+
constructor(dataLoaders, storageModelProvider){
|
|
7
|
+
this.dataLoaders = dataLoaders;
|
|
8
|
+
this.storageModelProvider = storageModelProvider;
|
|
9
|
+
}
|
|
10
|
+
async execute(initialModel, params) {
|
|
11
|
+
const model = this.storageModelProvider.getModel(initialModel);
|
|
12
|
+
const entries = await this.dataLoaders.getPublishedRevisionByEntryId({
|
|
13
|
+
model,
|
|
14
|
+
ids: params.ids
|
|
15
|
+
});
|
|
16
|
+
return entries.map((entry)=>convertEntryKeysFromStorage({
|
|
17
|
+
model,
|
|
18
|
+
entry
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const DdbEsGetPublishedEntriesByIds = GetPublishedEntriesByIdsStorageOperation.createImplementation({
|
|
23
|
+
implementation: DdbEsGetPublishedEntriesByIdsImpl,
|
|
24
|
+
dependencies: [
|
|
25
|
+
CmsDdbEsDataLoaders,
|
|
26
|
+
CmsStorageModelProvider
|
|
27
|
+
]
|
|
28
|
+
});
|
|
29
|
+
export { DdbEsGetPublishedEntriesByIds };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=DdbEsGetPublishedEntriesByIds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsGetPublishedEntriesByIds.js","sources":["../../../src/operations/entry/DdbEsGetPublishedEntriesByIds.ts"],"sourcesContent":["import type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsGetPublishedByIdsParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetPublishedEntriesByIdsStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPublishedEntriesByIdsStorageOperation.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { convertEntryKeysFromStorage } from \"./transformations/convertEntryKeys.js\";\n\nclass DdbEsGetPublishedEntriesByIdsImpl\n implements GetPublishedEntriesByIdsStorageOperation.Interface\n{\n constructor(\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedByIdsParams\n ) {\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const entries = await this.dataLoaders.getPublishedRevisionByEntryId<T>({\n model,\n ids: params.ids\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage<T>({\n model,\n entry\n });\n });\n }\n}\n\nexport const DdbEsGetPublishedEntriesByIds =\n GetPublishedEntriesByIdsStorageOperation.createImplementation({\n implementation: DdbEsGetPublishedEntriesByIdsImpl,\n dependencies: [CmsDdbEsDataLoaders, CmsStorageModelProvider]\n });\n"],"names":["DdbEsGetPublishedEntriesByIdsImpl","dataLoaders","storageModelProvider","initialModel","params","model","entries","entry","convertEntryKeysFromStorage","DdbEsGetPublishedEntriesByIds","GetPublishedEntriesByIdsStorageOperation","CmsDdbEsDataLoaders","CmsStorageModelProvider"],"mappings":";;;;AAUA,MAAMA;IAGF,YACYC,WAA0C,EAC1CC,oBAAuD,CACjE;aAFUD,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAAwD,EAC1D;QACE,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIF;QAEpD,MAAMG,UAAU,MAAM,IAAI,CAAC,WAAW,CAAC,6BAA6B,CAAI;YACpED;YACA,KAAKD,OAAO,GAAG;QACnB;QAEA,OAAOE,QAAQ,GAAG,CAACC,CAAAA,QACRC,4BAA+B;gBAClCH;gBACAE;YACJ;IAER;AACJ;AAEO,MAAME,gCACTC,yCAAyC,oBAAoB,CAAC;IAC1D,gBAAgBV;IAChB,cAAc;QAACW;QAAqBC;KAAwB;AAChE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsGetPublishedRevisionParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetPublishedRevisionByEntryIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.js";
|
|
3
|
+
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
4
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
declare class DdbEsGetPublishedRevisionByEntryIdImpl implements GetPublishedRevisionByEntryIdStorageOperation.Interface {
|
|
6
|
+
private dataLoaders;
|
|
7
|
+
private storageModelProvider;
|
|
8
|
+
constructor(dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
|
|
9
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsGetPublishedRevisionParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T> | null>;
|
|
10
|
+
}
|
|
11
|
+
export declare const DdbEsGetPublishedRevisionByEntryId: typeof DdbEsGetPublishedRevisionByEntryIdImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.js").IGetPublishedRevisionByEntryIdStorageOperation>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { GetPublishedRevisionByEntryIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.js";
|
|
2
|
+
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
3
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
4
|
+
import { convertEntryKeysFromStorage } from "./transformations/convertEntryKeys.js";
|
|
5
|
+
class DdbEsGetPublishedRevisionByEntryIdImpl {
|
|
6
|
+
constructor(dataLoaders, storageModelProvider){
|
|
7
|
+
this.dataLoaders = dataLoaders;
|
|
8
|
+
this.storageModelProvider = storageModelProvider;
|
|
9
|
+
}
|
|
10
|
+
async execute(initialModel, params) {
|
|
11
|
+
const model = this.storageModelProvider.getModel(initialModel);
|
|
12
|
+
const [entry] = await this.dataLoaders.getPublishedRevisionByEntryId({
|
|
13
|
+
model,
|
|
14
|
+
ids: [
|
|
15
|
+
params.id
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
if (!entry) return null;
|
|
19
|
+
return convertEntryKeysFromStorage({
|
|
20
|
+
model,
|
|
21
|
+
entry
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const DdbEsGetPublishedRevisionByEntryId = GetPublishedRevisionByEntryIdStorageOperation.createImplementation({
|
|
26
|
+
implementation: DdbEsGetPublishedRevisionByEntryIdImpl,
|
|
27
|
+
dependencies: [
|
|
28
|
+
CmsDdbEsDataLoaders,
|
|
29
|
+
CmsStorageModelProvider
|
|
30
|
+
]
|
|
31
|
+
});
|
|
32
|
+
export { DdbEsGetPublishedRevisionByEntryId };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=DdbEsGetPublishedRevisionByEntryId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsGetPublishedRevisionByEntryId.js","sources":["../../../src/operations/entry/DdbEsGetPublishedRevisionByEntryId.ts"],"sourcesContent":["import type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsGetPublishedRevisionParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetPublishedRevisionByEntryIdStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetPublishedRevisionByEntryIdStorageOperation.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { convertEntryKeysFromStorage } from \"./transformations/convertEntryKeys.js\";\n\nclass DdbEsGetPublishedRevisionByEntryIdImpl\n implements GetPublishedRevisionByEntryIdStorageOperation.Interface\n{\n constructor(\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedRevisionParams\n ) {\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const [entry] = await this.dataLoaders.getPublishedRevisionByEntryId<T>({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage<T>({\n model,\n entry\n });\n }\n}\n\nexport const DdbEsGetPublishedRevisionByEntryId =\n GetPublishedRevisionByEntryIdStorageOperation.createImplementation({\n implementation: DdbEsGetPublishedRevisionByEntryIdImpl,\n dependencies: [CmsDdbEsDataLoaders, CmsStorageModelProvider]\n });\n"],"names":["DdbEsGetPublishedRevisionByEntryIdImpl","dataLoaders","storageModelProvider","initialModel","params","model","entry","convertEntryKeysFromStorage","DdbEsGetPublishedRevisionByEntryId","GetPublishedRevisionByEntryIdStorageOperation","CmsDdbEsDataLoaders","CmsStorageModelProvider"],"mappings":";;;;AAUA,MAAMA;IAGF,YACYC,WAA0C,EAC1CC,oBAAuD,CACjE;aAFUD,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAA2D,EAC7D;QACE,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIF;QAEpD,MAAM,CAACG,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,6BAA6B,CAAI;YACpED;YACA,KAAK;gBAACD,OAAO,EAAE;aAAC;QACpB;QACA,IAAI,CAACE,OACD,OAAO;QAEX,OAAOC,4BAA+B;YAClCF;YACAC;QACJ;IACJ;AACJ;AAEO,MAAME,qCACTC,8CAA8C,oBAAoB,CAAC;IAC/D,gBAAgBT;IAChB,cAAc;QAACU;QAAqBC;KAAwB;AAChE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsGetRevisionParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetRevisionByIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js";
|
|
3
|
+
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
4
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
declare class DdbEsGetRevisionByIdImpl implements GetRevisionByIdStorageOperation.Interface {
|
|
6
|
+
private dataLoaders;
|
|
7
|
+
private storageModelProvider;
|
|
8
|
+
constructor(dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
|
|
9
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsGetRevisionParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T> | null>;
|
|
10
|
+
}
|
|
11
|
+
export declare const DdbEsGetRevisionById: typeof DdbEsGetRevisionByIdImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js").IGetRevisionByIdStorageOperation>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { GetRevisionByIdStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js";
|
|
2
|
+
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
3
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
4
|
+
import { convertEntryKeysFromStorage } from "./transformations/convertEntryKeys.js";
|
|
5
|
+
class DdbEsGetRevisionByIdImpl {
|
|
6
|
+
constructor(dataLoaders, storageModelProvider){
|
|
7
|
+
this.dataLoaders = dataLoaders;
|
|
8
|
+
this.storageModelProvider = storageModelProvider;
|
|
9
|
+
}
|
|
10
|
+
async execute(initialModel, params) {
|
|
11
|
+
const model = this.storageModelProvider.getModel(initialModel);
|
|
12
|
+
const [entry] = await this.dataLoaders.getRevisionById({
|
|
13
|
+
model,
|
|
14
|
+
ids: [
|
|
15
|
+
params.id
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
if (!entry) return null;
|
|
19
|
+
return convertEntryKeysFromStorage({
|
|
20
|
+
model,
|
|
21
|
+
entry
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const DdbEsGetRevisionById = GetRevisionByIdStorageOperation.createImplementation({
|
|
26
|
+
implementation: DdbEsGetRevisionByIdImpl,
|
|
27
|
+
dependencies: [
|
|
28
|
+
CmsDdbEsDataLoaders,
|
|
29
|
+
CmsStorageModelProvider
|
|
30
|
+
]
|
|
31
|
+
});
|
|
32
|
+
export { DdbEsGetRevisionById };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=DdbEsGetRevisionById.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsGetRevisionById.js","sources":["../../../src/operations/entry/DdbEsGetRevisionById.ts"],"sourcesContent":["import type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsGetRevisionParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetRevisionByIdStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionByIdStorageOperation.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { convertEntryKeysFromStorage } from \"./transformations/convertEntryKeys.js\";\n\nclass DdbEsGetRevisionByIdImpl implements GetRevisionByIdStorageOperation.Interface {\n constructor(\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionParams\n ) {\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const [entry] = await this.dataLoaders.getRevisionById<T>({\n model,\n ids: [params.id]\n });\n if (!entry) {\n return null;\n }\n return convertEntryKeysFromStorage<T>({\n model,\n entry\n });\n }\n}\n\nexport const DdbEsGetRevisionById = GetRevisionByIdStorageOperation.createImplementation({\n implementation: DdbEsGetRevisionByIdImpl,\n dependencies: [CmsDdbEsDataLoaders, CmsStorageModelProvider]\n});\n"],"names":["DdbEsGetRevisionByIdImpl","dataLoaders","storageModelProvider","initialModel","params","model","entry","convertEntryKeysFromStorage","DdbEsGetRevisionById","GetRevisionByIdStorageOperation","CmsDdbEsDataLoaders","CmsStorageModelProvider"],"mappings":";;;;AAUA,MAAMA;IACF,YACYC,WAA0C,EAC1CC,oBAAuD,CACjE;aAFUD,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAAkD,EACpD;QACE,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIF;QAEpD,MAAM,CAACG,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,eAAe,CAAI;YACtDD;YACA,KAAK;gBAACD,OAAO,EAAE;aAAC;QACpB;QACA,IAAI,CAACE,OACD,OAAO;QAEX,OAAOC,4BAA+B;YAClCF;YACAC;QACJ;IACJ;AACJ;AAEO,MAAME,uBAAuBC,gCAAgC,oBAAoB,CAAC;IACrF,gBAAgBT;IAChB,cAAc;QAACU;QAAqBC;KAAwB;AAChE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsGetRevisionsParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetRevisionsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js";
|
|
3
|
+
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
4
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
5
|
+
declare class DdbEsGetRevisionsImpl implements GetRevisionsStorageOperation.Interface {
|
|
6
|
+
private dataLoaders;
|
|
7
|
+
private storageModelProvider;
|
|
8
|
+
constructor(dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface);
|
|
9
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsGetRevisionsParams): Promise<import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T>[]>;
|
|
10
|
+
}
|
|
11
|
+
export declare const DdbEsGetRevisions: typeof DdbEsGetRevisionsImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js").IGetRevisionsStorageOperation>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { GetRevisionsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js";
|
|
2
|
+
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
3
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
4
|
+
import { convertEntryKeysFromStorage } from "./transformations/convertEntryKeys.js";
|
|
5
|
+
class DdbEsGetRevisionsImpl {
|
|
6
|
+
constructor(dataLoaders, storageModelProvider){
|
|
7
|
+
this.dataLoaders = dataLoaders;
|
|
8
|
+
this.storageModelProvider = storageModelProvider;
|
|
9
|
+
}
|
|
10
|
+
async execute(initialModel, params) {
|
|
11
|
+
const model = this.storageModelProvider.getModel(initialModel);
|
|
12
|
+
const entries = await this.dataLoaders.getAllEntryRevisions({
|
|
13
|
+
model,
|
|
14
|
+
ids: [
|
|
15
|
+
params.id
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
return entries.map((entry)=>convertEntryKeysFromStorage({
|
|
19
|
+
model,
|
|
20
|
+
entry
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const DdbEsGetRevisions = GetRevisionsStorageOperation.createImplementation({
|
|
25
|
+
implementation: DdbEsGetRevisionsImpl,
|
|
26
|
+
dependencies: [
|
|
27
|
+
CmsDdbEsDataLoaders,
|
|
28
|
+
CmsStorageModelProvider
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
export { DdbEsGetRevisions };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=DdbEsGetRevisions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsGetRevisions.js","sources":["../../../src/operations/entry/DdbEsGetRevisions.ts"],"sourcesContent":["import type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsGetRevisionsParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetRevisionsStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetRevisionsStorageOperation.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { convertEntryKeysFromStorage } from \"./transformations/convertEntryKeys.js\";\n\nclass DdbEsGetRevisionsImpl implements GetRevisionsStorageOperation.Interface {\n constructor(\n private dataLoaders: CmsDdbEsDataLoaders.Interface,\n private storageModelProvider: CmsStorageModelProvider.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionsParams\n ) {\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const entries = await this.dataLoaders.getAllEntryRevisions<T>({\n model,\n ids: [params.id]\n });\n\n return entries.map(entry => {\n return convertEntryKeysFromStorage<T>({\n model,\n entry\n });\n });\n }\n}\n\nexport const DdbEsGetRevisions = GetRevisionsStorageOperation.createImplementation({\n implementation: DdbEsGetRevisionsImpl,\n dependencies: [CmsDdbEsDataLoaders, CmsStorageModelProvider]\n});\n"],"names":["DdbEsGetRevisionsImpl","dataLoaders","storageModelProvider","initialModel","params","model","entries","entry","convertEntryKeysFromStorage","DdbEsGetRevisions","GetRevisionsStorageOperation","CmsDdbEsDataLoaders","CmsStorageModelProvider"],"mappings":";;;;AAUA,MAAMA;IACF,YACYC,WAA0C,EAC1CC,oBAAuD,CACjE;aAFUD,WAAW,GAAXA;aACAC,oBAAoB,GAApBA;IACT;IAEH,MAAM,QACFC,YAAsB,EACtBC,MAAmD,EACrD;QACE,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIF;QAEpD,MAAMG,UAAU,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAI;YAC3DD;YACA,KAAK;gBAACD,OAAO,EAAE;aAAC;QACpB;QAEA,OAAOE,QAAQ,GAAG,CAACC,CAAAA,QACRC,4BAA+B;gBAClCH;gBACAE;YACJ;IAER;AACJ;AAEO,MAAME,oBAAoBC,6BAA6B,oBAAoB,CAAC;IAC/E,gBAAgBV;IAChB,cAAc;QAACW;QAAqBC;KAAwB;AAChE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CmsModel, CmsEntryStorageOperationsGetUniqueFieldValuesParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { GetUniqueFieldValuesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js";
|
|
3
|
+
import { OpenSearchClient } from "@webiny/api-opensearch/exports/api/opensearch.js";
|
|
4
|
+
import { CmsEntryOpenSearchBodyBuilder, CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
5
|
+
declare class DdbEsGetUniqueFieldValuesImpl implements GetUniqueFieldValuesStorageOperation.Interface {
|
|
6
|
+
private bodyBuilder;
|
|
7
|
+
private indexProvider;
|
|
8
|
+
private elasticsearch;
|
|
9
|
+
constructor(bodyBuilder: CmsEntryOpenSearchBodyBuilder.Interface, openSearchClient: OpenSearchClient.Interface, indexProvider: CmsModelOpenSearchIndexProvider.Interface);
|
|
10
|
+
execute(model: CmsModel, params: CmsEntryStorageOperationsGetUniqueFieldValuesParams): Promise<{
|
|
11
|
+
value: string;
|
|
12
|
+
count: number;
|
|
13
|
+
}[]>;
|
|
14
|
+
}
|
|
15
|
+
export declare const DdbEsGetUniqueFieldValues: typeof DdbEsGetUniqueFieldValuesImpl & {
|
|
16
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js").IGetUniqueFieldValuesStorageOperation>;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import _webiny_error from "@webiny/error";
|
|
2
|
+
import { GetUniqueFieldValuesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js";
|
|
3
|
+
import { OpenSearchClient } from "@webiny/api-opensearch/exports/api/opensearch.js";
|
|
4
|
+
import { createConfigurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
|
|
5
|
+
import { shouldIgnoreEsResponseError } from "@webiny/api-headless-cms-utils-os/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js";
|
|
6
|
+
import { CmsEntryOpenSearchBodyBuilder, CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
7
|
+
class DdbEsGetUniqueFieldValuesImpl {
|
|
8
|
+
constructor(bodyBuilder, openSearchClient, indexProvider){
|
|
9
|
+
this.bodyBuilder = bodyBuilder;
|
|
10
|
+
this.indexProvider = indexProvider;
|
|
11
|
+
this.elasticsearch = openSearchClient.use();
|
|
12
|
+
}
|
|
13
|
+
async execute(model, params) {
|
|
14
|
+
const { where, fieldId } = params;
|
|
15
|
+
const configurations = createConfigurations(this.indexProvider);
|
|
16
|
+
const { index, shared } = await configurations.es({
|
|
17
|
+
model
|
|
18
|
+
});
|
|
19
|
+
const initialBody = this.bodyBuilder.build({
|
|
20
|
+
model,
|
|
21
|
+
shared,
|
|
22
|
+
params: {
|
|
23
|
+
limit: 1,
|
|
24
|
+
where
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const field = model.fields.find((f)=>f.fieldId === fieldId);
|
|
28
|
+
if (!field) throw new _webiny_error('Could not find field with given "fieldId" value.', "FIELD_NOT_FOUND", {
|
|
29
|
+
fieldId
|
|
30
|
+
});
|
|
31
|
+
const body = {
|
|
32
|
+
...initialBody,
|
|
33
|
+
size: 0,
|
|
34
|
+
aggregations: {
|
|
35
|
+
getUniqueFieldValues: {
|
|
36
|
+
terms: {
|
|
37
|
+
field: `values.${field.storageId}.keyword`,
|
|
38
|
+
size: 1000000
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
let response;
|
|
44
|
+
try {
|
|
45
|
+
response = await this.elasticsearch.search({
|
|
46
|
+
index,
|
|
47
|
+
body
|
|
48
|
+
});
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (shouldIgnoreEsResponseError(error)) return [];
|
|
51
|
+
throw new _webiny_error(error.message || "Error in the Elasticsearch query.", error.code || "OPENSEARCH_ERROR", {
|
|
52
|
+
error,
|
|
53
|
+
index,
|
|
54
|
+
model,
|
|
55
|
+
body
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const aggregations = response.body.aggregations || {};
|
|
59
|
+
const agg = aggregations["getUniqueFieldValues"];
|
|
60
|
+
const buckets = agg && "buckets" in agg && Array.isArray(agg.buckets) ? agg.buckets : [];
|
|
61
|
+
return buckets.map((bucket)=>({
|
|
62
|
+
value: bucket.key,
|
|
63
|
+
count: bucket.doc_count
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const DdbEsGetUniqueFieldValues = GetUniqueFieldValuesStorageOperation.createImplementation({
|
|
68
|
+
implementation: DdbEsGetUniqueFieldValuesImpl,
|
|
69
|
+
dependencies: [
|
|
70
|
+
CmsEntryOpenSearchBodyBuilder,
|
|
71
|
+
OpenSearchClient,
|
|
72
|
+
CmsModelOpenSearchIndexProvider
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
export { DdbEsGetUniqueFieldValues };
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=DdbEsGetUniqueFieldValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsGetUniqueFieldValues.js","sources":["../../../src/operations/entry/DdbEsGetUniqueFieldValues.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryStorageOperationsGetUniqueFieldValuesParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { GetUniqueFieldValuesStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/GetUniqueFieldValuesStorageOperation.js\";\nimport { OpenSearchClient } from \"@webiny/api-opensearch/exports/api/opensearch.js\";\nimport type { Client } from \"@webiny/api-opensearch\";\nimport type {\n OpenSearchSearchResponse,\n SearchBody as OpenSearchSearchBody\n} from \"@webiny/api-opensearch/types.js\";\nimport { createConfigurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { shouldIgnoreEsResponseError } from \"@webiny/api-headless-cms-utils-os/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js\";\nimport {\n CmsEntryOpenSearchBodyBuilder,\n CmsModelOpenSearchIndexProvider\n} from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\n\nclass DdbEsGetUniqueFieldValuesImpl implements GetUniqueFieldValuesStorageOperation.Interface {\n private elasticsearch: Client;\n\n constructor(\n private bodyBuilder: CmsEntryOpenSearchBodyBuilder.Interface,\n openSearchClient: OpenSearchClient.Interface,\n private indexProvider: CmsModelOpenSearchIndexProvider.Interface\n ) {\n this.elasticsearch = openSearchClient.use();\n }\n\n async execute(model: CmsModel, params: CmsEntryStorageOperationsGetUniqueFieldValuesParams) {\n const { where, fieldId } = params;\n\n const configurations = createConfigurations(this.indexProvider);\n const { index, shared } = await configurations.es({\n model\n });\n\n const initialBody = this.bodyBuilder.build({\n model,\n shared,\n params: {\n limit: 1,\n where\n }\n });\n\n const field = model.fields.find(f => f.fieldId === fieldId);\n if (!field) {\n throw new WebinyError(\n `Could not find field with given \"fieldId\" value.`,\n \"FIELD_NOT_FOUND\",\n {\n fieldId\n }\n );\n }\n\n const body: OpenSearchSearchBody = {\n ...initialBody,\n /**\n * We do not need any hits returned, we only need the aggregations.\n */\n size: 0,\n aggregations: {\n getUniqueFieldValues: {\n terms: {\n // @ts-expect-error opensearch 3.9 types omit `field` from TermsAggregationFields\n field: `values.${field.storageId}.keyword`,\n size: 1000000\n }\n }\n }\n };\n\n let response: OpenSearchSearchResponse | undefined = undefined;\n\n try {\n response = await this.elasticsearch.search({\n index,\n body\n });\n } catch (error) {\n if (shouldIgnoreEsResponseError(error)) {\n return [];\n }\n\n throw new WebinyError(\n error.message || \"Error in the Elasticsearch query.\",\n error.code || \"OPENSEARCH_ERROR\",\n {\n error,\n index,\n model,\n body\n }\n );\n }\n\n const aggregations = response.body.aggregations || {};\n const agg = aggregations[\"getUniqueFieldValues\"];\n const buckets = agg && \"buckets\" in agg && Array.isArray(agg.buckets) ? agg.buckets : [];\n return buckets.map((bucket: { key: string; doc_count: number }) => {\n return {\n value: bucket.key,\n count: bucket.doc_count\n };\n });\n }\n}\n\nexport const DdbEsGetUniqueFieldValues = GetUniqueFieldValuesStorageOperation.createImplementation({\n implementation: DdbEsGetUniqueFieldValuesImpl,\n dependencies: [CmsEntryOpenSearchBodyBuilder, OpenSearchClient, CmsModelOpenSearchIndexProvider]\n});\n"],"names":["DdbEsGetUniqueFieldValuesImpl","bodyBuilder","openSearchClient","indexProvider","model","params","where","fieldId","configurations","createConfigurations","index","shared","initialBody","field","f","WebinyError","body","response","error","shouldIgnoreEsResponseError","aggregations","agg","buckets","Array","bucket","DdbEsGetUniqueFieldValues","GetUniqueFieldValuesStorageOperation","CmsEntryOpenSearchBodyBuilder","OpenSearchClient","CmsModelOpenSearchIndexProvider"],"mappings":";;;;;;AAmBA,MAAMA;IAGF,YACYC,WAAoD,EAC5DC,gBAA4C,EACpCC,aAAwD,CAClE;aAHUF,WAAW,GAAXA;aAEAE,aAAa,GAAbA;QAER,IAAI,CAAC,aAAa,GAAGD,iBAAiB,GAAG;IAC7C;IAEA,MAAM,QAAQE,KAAe,EAAEC,MAA2D,EAAE;QACxF,MAAM,EAAEC,KAAK,EAAEC,OAAO,EAAE,GAAGF;QAE3B,MAAMG,iBAAiBC,qBAAqB,IAAI,CAAC,aAAa;QAC9D,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAE,GAAG,MAAMH,eAAe,EAAE,CAAC;YAC9CJ;QACJ;QAEA,MAAMQ,cAAc,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;YACvCR;YACAO;YACA,QAAQ;gBACJ,OAAO;gBACPL;YACJ;QACJ;QAEA,MAAMO,QAAQT,MAAM,MAAM,CAAC,IAAI,CAACU,CAAAA,IAAKA,EAAE,OAAO,KAAKP;QACnD,IAAI,CAACM,OACD,MAAM,IAAIE,cACN,oDACA,mBACA;YACIR;QACJ;QAIR,MAAMS,OAA6B;YAC/B,GAAGJ,WAAW;YAId,MAAM;YACN,cAAc;gBACV,sBAAsB;oBAClB,OAAO;wBAEH,OAAO,CAAC,OAAO,EAAEC,MAAM,SAAS,CAAC,QAAQ,CAAC;wBAC1C,MAAM;oBACV;gBACJ;YACJ;QACJ;QAEA,IAAII;QAEJ,IAAI;YACAA,WAAW,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;gBACvCP;gBACAM;YACJ;QACJ,EAAE,OAAOE,OAAO;YACZ,IAAIC,4BAA4BD,QAC5B,OAAO,EAAE;YAGb,MAAM,IAAIH,cACNG,MAAM,OAAO,IAAI,qCACjBA,MAAM,IAAI,IAAI,oBACd;gBACIA;gBACAR;gBACAN;gBACAY;YACJ;QAER;QAEA,MAAMI,eAAeH,SAAS,IAAI,CAAC,YAAY,IAAI,CAAC;QACpD,MAAMI,MAAMD,YAAY,CAAC,uBAAuB;QAChD,MAAME,UAAUD,OAAO,aAAaA,OAAOE,MAAM,OAAO,CAACF,IAAI,OAAO,IAAIA,IAAI,OAAO,GAAG,EAAE;QACxF,OAAOC,QAAQ,GAAG,CAAC,CAACE,SACT;gBACH,OAAOA,OAAO,GAAG;gBACjB,OAAOA,OAAO,SAAS;YAC3B;IAER;AACJ;AAEO,MAAMC,4BAA4BC,qCAAqC,oBAAoB,CAAC;IAC/F,gBAAgB1B;IAChB,cAAc;QAAC2B;QAA+BC;QAAkBC;KAAgC;AACpG"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CmsModel, CmsEntryValues, CmsEntryStorageOperationsListParams } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { ListEntriesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js";
|
|
3
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
4
|
+
import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
|
|
5
|
+
import { OpenSearchClient } from "@webiny/api-opensearch/exports/api/opensearch.js";
|
|
6
|
+
import { CmsEntryOpenSearchBodyBuilder, CmsEntryOpenSearchFieldIndexRegistry, CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
7
|
+
import { Debugger } from "@webiny/api-core/features/debugger/index.js";
|
|
8
|
+
import "~/debuggerNamespaces.js";
|
|
9
|
+
declare class DdbEsListEntriesImpl implements ListEntriesStorageOperation.Interface {
|
|
10
|
+
private storageModelProvider;
|
|
11
|
+
private bodyBuilder;
|
|
12
|
+
private fieldRegistry;
|
|
13
|
+
private fieldIndexRegistry;
|
|
14
|
+
private indexProvider;
|
|
15
|
+
private debuggerService;
|
|
16
|
+
private elasticsearch;
|
|
17
|
+
constructor(storageModelProvider: CmsStorageModelProvider.Interface, bodyBuilder: CmsEntryOpenSearchBodyBuilder.Interface, fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface, fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface, openSearchClient: OpenSearchClient.Interface, indexProvider: CmsModelOpenSearchIndexProvider.Interface, debuggerService: Debugger.Interface);
|
|
18
|
+
execute<T extends CmsEntryValues = CmsEntryValues>(initialModel: CmsModel, params: CmsEntryStorageOperationsListParams): Promise<{
|
|
19
|
+
hasMoreItems: boolean;
|
|
20
|
+
totalCount: number;
|
|
21
|
+
cursor: string | null;
|
|
22
|
+
items: import("@webiny/api-headless-cms/types/types.js").CmsStorageEntry<T>[];
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
export declare const DdbEsListEntries: typeof DdbEsListEntriesImpl & {
|
|
26
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js").IListEntriesStorageOperation>;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import _webiny_error from "@webiny/error";
|
|
2
|
+
import { ListEntriesStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js";
|
|
3
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
4
|
+
import { CmsModelFieldToGraphQLRegistry } from "@webiny/api-headless-cms/exports/api/cms/graphql.js";
|
|
5
|
+
import { OpenSearchClient } from "@webiny/api-opensearch/exports/api/opensearch.js";
|
|
6
|
+
import { createLimit, decodeCursor, encodeCursor } from "@webiny/api-opensearch";
|
|
7
|
+
import { getTotalCount } from "@webiny/api-opensearch/types.js";
|
|
8
|
+
import { createConfigurations } from "@webiny/api-headless-cms-utils-os/configurations.js";
|
|
9
|
+
import { extractEntriesFromIndex } from "@webiny/api-headless-cms-utils-os/helpers/index.js";
|
|
10
|
+
import { shouldIgnoreEsResponseError } from "@webiny/api-headless-cms-utils-os/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js";
|
|
11
|
+
import { CmsEntryOpenSearchBodyBuilder, CmsEntryOpenSearchFieldIndexRegistry, CmsModelOpenSearchIndexProvider } from "@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js";
|
|
12
|
+
import { Debugger } from "@webiny/api-core/features/debugger/index.js";
|
|
13
|
+
import "../../debuggerNamespaces.js";
|
|
14
|
+
import { convertEntryKeysFromStorage } from "./transformations/convertEntryKeys.js";
|
|
15
|
+
class DdbEsListEntriesImpl {
|
|
16
|
+
constructor(storageModelProvider, bodyBuilder, fieldRegistry, fieldIndexRegistry, openSearchClient, indexProvider, debuggerService){
|
|
17
|
+
this.storageModelProvider = storageModelProvider;
|
|
18
|
+
this.bodyBuilder = bodyBuilder;
|
|
19
|
+
this.fieldRegistry = fieldRegistry;
|
|
20
|
+
this.fieldIndexRegistry = fieldIndexRegistry;
|
|
21
|
+
this.indexProvider = indexProvider;
|
|
22
|
+
this.debuggerService = debuggerService;
|
|
23
|
+
this.elasticsearch = openSearchClient.use();
|
|
24
|
+
}
|
|
25
|
+
async execute(initialModel, params) {
|
|
26
|
+
const model = this.storageModelProvider.getModel(initialModel);
|
|
27
|
+
const limit = createLimit(params.limit, 50);
|
|
28
|
+
const configurations = createConfigurations(this.indexProvider);
|
|
29
|
+
const { index, shared } = await configurations.es({
|
|
30
|
+
model
|
|
31
|
+
});
|
|
32
|
+
const body = this.bodyBuilder.build({
|
|
33
|
+
model,
|
|
34
|
+
shared,
|
|
35
|
+
params: {
|
|
36
|
+
...params,
|
|
37
|
+
limit,
|
|
38
|
+
after: decodeCursor(params.after)
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
let response;
|
|
42
|
+
const startedAt = Date.now();
|
|
43
|
+
try {
|
|
44
|
+
response = await this.elasticsearch.search({
|
|
45
|
+
index,
|
|
46
|
+
body
|
|
47
|
+
});
|
|
48
|
+
this.debuggerService.log("cms.os.list", ()=>({
|
|
49
|
+
index,
|
|
50
|
+
query: body,
|
|
51
|
+
body: response.body,
|
|
52
|
+
statusCode: response.statusCode,
|
|
53
|
+
tookMs: Date.now() - startedAt
|
|
54
|
+
}));
|
|
55
|
+
} catch (error) {
|
|
56
|
+
this.debuggerService.log("cms.os.list", ()=>({
|
|
57
|
+
index,
|
|
58
|
+
query: body,
|
|
59
|
+
error,
|
|
60
|
+
tookMs: Date.now() - startedAt
|
|
61
|
+
}));
|
|
62
|
+
if (shouldIgnoreEsResponseError(error)) return {
|
|
63
|
+
hasMoreItems: false,
|
|
64
|
+
totalCount: 0,
|
|
65
|
+
cursor: null,
|
|
66
|
+
items: []
|
|
67
|
+
};
|
|
68
|
+
throw new _webiny_error(error.message, error.code || "OPENSEARCH_ERROR", {
|
|
69
|
+
error,
|
|
70
|
+
index,
|
|
71
|
+
body,
|
|
72
|
+
model
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
const { hits, total } = response.body.hits;
|
|
76
|
+
const items = extractEntriesFromIndex({
|
|
77
|
+
fieldRegistry: this.fieldRegistry,
|
|
78
|
+
fieldIndexRegistry: this.fieldIndexRegistry,
|
|
79
|
+
model,
|
|
80
|
+
entries: hits.map((item)=>item._source)
|
|
81
|
+
}).map((item)=>convertEntryKeysFromStorage({
|
|
82
|
+
model,
|
|
83
|
+
entry: item
|
|
84
|
+
}));
|
|
85
|
+
const hasMoreItems = items.length > limit;
|
|
86
|
+
if (hasMoreItems) items.pop();
|
|
87
|
+
const cursor = items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null;
|
|
88
|
+
return {
|
|
89
|
+
hasMoreItems,
|
|
90
|
+
totalCount: getTotalCount(total),
|
|
91
|
+
cursor,
|
|
92
|
+
items
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const DdbEsListEntries = ListEntriesStorageOperation.createImplementation({
|
|
97
|
+
implementation: DdbEsListEntriesImpl,
|
|
98
|
+
dependencies: [
|
|
99
|
+
CmsStorageModelProvider,
|
|
100
|
+
CmsEntryOpenSearchBodyBuilder,
|
|
101
|
+
CmsModelFieldToGraphQLRegistry,
|
|
102
|
+
CmsEntryOpenSearchFieldIndexRegistry,
|
|
103
|
+
OpenSearchClient,
|
|
104
|
+
CmsModelOpenSearchIndexProvider,
|
|
105
|
+
Debugger
|
|
106
|
+
]
|
|
107
|
+
});
|
|
108
|
+
export { DdbEsListEntries };
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=DdbEsListEntries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/DdbEsListEntries.js","sources":["../../../src/operations/entry/DdbEsListEntries.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsEntryValues,\n CmsEntryStorageOperationsListParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { ListEntriesStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/entry/ListEntriesStorageOperation.js\";\nimport { CmsStorageModelProvider } from \"@webiny/api-headless-cms/features/shared/abstractions.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { OpenSearchClient } from \"@webiny/api-opensearch/exports/api/opensearch.js\";\nimport type { Client } from \"@webiny/api-opensearch\";\nimport { createLimit, decodeCursor, encodeCursor } from \"@webiny/api-opensearch\";\nimport type { OpenSearchSearchResponse } from \"@webiny/api-opensearch/types.js\";\nimport { getTotalCount } from \"@webiny/api-opensearch/types.js\";\nimport { createConfigurations } from \"@webiny/api-headless-cms-utils-os/configurations.js\";\nimport { extractEntriesFromIndex } from \"@webiny/api-headless-cms-utils-os/helpers/index.js\";\nimport { shouldIgnoreEsResponseError } from \"@webiny/api-headless-cms-utils-os/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js\";\nimport {\n CmsEntryOpenSearchBodyBuilder,\n CmsEntryOpenSearchFieldIndexRegistry,\n CmsModelOpenSearchIndexProvider\n} from \"@webiny/api-headless-cms-utils-os/exports/api/cms/opensearch.js\";\nimport type { CmsIndexEntry } from \"@webiny/api-headless-cms-utils-os/types.js\";\nimport { Debugger } from \"@webiny/api-core/features/debugger/index.js\";\nimport \"~/debuggerNamespaces.js\";\nimport { convertEntryKeysFromStorage } from \"./transformations/convertEntryKeys.js\";\n\nclass DdbEsListEntriesImpl implements ListEntriesStorageOperation.Interface {\n private elasticsearch: Client;\n\n constructor(\n private storageModelProvider: CmsStorageModelProvider.Interface,\n private bodyBuilder: CmsEntryOpenSearchBodyBuilder.Interface,\n private fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface,\n private fieldIndexRegistry: CmsEntryOpenSearchFieldIndexRegistry.Interface,\n openSearchClient: OpenSearchClient.Interface,\n private indexProvider: CmsModelOpenSearchIndexProvider.Interface,\n private debuggerService: Debugger.Interface\n ) {\n this.elasticsearch = openSearchClient.use();\n }\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n initialModel: CmsModel,\n params: CmsEntryStorageOperationsListParams\n ) {\n const model = this.storageModelProvider.getModel<T>(initialModel);\n\n const limit = createLimit(params.limit, 50);\n const configurations = createConfigurations(this.indexProvider);\n const { index, shared } = await configurations.es({\n model\n });\n\n const body = this.bodyBuilder.build({\n model,\n shared,\n params: {\n ...params,\n limit,\n after: decodeCursor(params.after)\n }\n });\n\n let response: OpenSearchSearchResponse;\n const startedAt = Date.now();\n try {\n response = await this.elasticsearch.search({\n index,\n body\n });\n\n this.debuggerService.log(\"cms.os.list\", () => ({\n index,\n query: body,\n /**\n * Only the response body and status. The full client response also carries\n * `meta.connection.url` (the cluster endpoint) plus request headers.\n */\n body: response.body,\n statusCode: response.statusCode,\n tookMs: Date.now() - startedAt\n }));\n } catch (error) {\n /**\n * Logged before the `index_not_found` check below, which swallows the error and returns\n * an empty result. That silent exit is exactly what is hard to see from the outside.\n */\n this.debuggerService.log(\"cms.os.list\", () => ({\n index,\n query: body,\n error,\n tookMs: Date.now() - startedAt\n }));\n\n /**\n * We will silently ignore the `index_not_found_exception` error and return an empty result set.\n * This is because the index might not exist yet, and we don't want to throw an error.\n */\n if (shouldIgnoreEsResponseError(error)) {\n return {\n hasMoreItems: false,\n totalCount: 0,\n cursor: null,\n items: []\n };\n }\n\n throw new WebinyError(error.message, error.code || \"OPENSEARCH_ERROR\", {\n error,\n index,\n body,\n model\n });\n }\n\n const { hits, total } = response.body.hits;\n\n const items = extractEntriesFromIndex<T>({\n fieldRegistry: this.fieldRegistry,\n fieldIndexRegistry: this.fieldIndexRegistry,\n model,\n entries: hits.map(item => {\n return item._source as CmsIndexEntry<T>;\n })\n }).map(item => {\n return convertEntryKeysFromStorage<T>({\n model,\n entry: item\n });\n });\n\n const hasMoreItems = items.length > limit;\n if (hasMoreItems) {\n /**\n * Remove the last item from results, we don't want to include it.\n */\n items.pop();\n }\n /**\n * Cursor is the `sort` value of the last item in the array.\n * https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#search-after\n */\n const cursor = items.length > 0 ? encodeCursor(hits[items.length - 1].sort) || null : null;\n return {\n hasMoreItems,\n totalCount: getTotalCount(total),\n cursor,\n items\n };\n }\n}\n\nexport const DdbEsListEntries = ListEntriesStorageOperation.createImplementation({\n implementation: DdbEsListEntriesImpl,\n dependencies: [\n CmsStorageModelProvider,\n CmsEntryOpenSearchBodyBuilder,\n CmsModelFieldToGraphQLRegistry,\n CmsEntryOpenSearchFieldIndexRegistry,\n OpenSearchClient,\n CmsModelOpenSearchIndexProvider,\n Debugger\n ]\n});\n"],"names":["DdbEsListEntriesImpl","storageModelProvider","bodyBuilder","fieldRegistry","fieldIndexRegistry","openSearchClient","indexProvider","debuggerService","initialModel","params","model","limit","createLimit","configurations","createConfigurations","index","shared","body","decodeCursor","response","startedAt","Date","error","shouldIgnoreEsResponseError","WebinyError","hits","total","items","extractEntriesFromIndex","item","convertEntryKeysFromStorage","hasMoreItems","cursor","encodeCursor","getTotalCount","DdbEsListEntries","ListEntriesStorageOperation","CmsStorageModelProvider","CmsEntryOpenSearchBodyBuilder","CmsModelFieldToGraphQLRegistry","CmsEntryOpenSearchFieldIndexRegistry","OpenSearchClient","CmsModelOpenSearchIndexProvider","Debugger"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAMA;IAGF,YACYC,oBAAuD,EACvDC,WAAoD,EACpDC,aAAuD,EACvDC,kBAAkE,EAC1EC,gBAA4C,EACpCC,aAAwD,EACxDC,eAAmC,CAC7C;aAPUN,oBAAoB,GAApBA;aACAC,WAAW,GAAXA;aACAC,aAAa,GAAbA;aACAC,kBAAkB,GAAlBA;aAEAE,aAAa,GAAbA;aACAC,eAAe,GAAfA;QAER,IAAI,CAAC,aAAa,GAAGF,iBAAiB,GAAG;IAC7C;IAEA,MAAM,QACFG,YAAsB,EACtBC,MAA2C,EAC7C;QACE,MAAMC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,QAAQ,CAAIF;QAEpD,MAAMG,QAAQC,YAAYH,OAAO,KAAK,EAAE;QACxC,MAAMI,iBAAiBC,qBAAqB,IAAI,CAAC,aAAa;QAC9D,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAE,GAAG,MAAMH,eAAe,EAAE,CAAC;YAC9CH;QACJ;QAEA,MAAMO,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;YAChCP;YACAM;YACA,QAAQ;gBACJ,GAAGP,MAAM;gBACTE;gBACA,OAAOO,aAAaT,OAAO,KAAK;YACpC;QACJ;QAEA,IAAIU;QACJ,MAAMC,YAAYC,KAAK,GAAG;QAC1B,IAAI;YACAF,WAAW,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;gBACvCJ;gBACAE;YACJ;YAEA,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,eAAe,IAAO;oBAC3CF;oBACA,OAAOE;oBAKP,MAAME,SAAS,IAAI;oBACnB,YAAYA,SAAS,UAAU;oBAC/B,QAAQE,KAAK,GAAG,KAAKD;gBACzB;QACJ,EAAE,OAAOE,OAAO;YAKZ,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,eAAe,IAAO;oBAC3CP;oBACA,OAAOE;oBACPK;oBACA,QAAQD,KAAK,GAAG,KAAKD;gBACzB;YAMA,IAAIG,4BAA4BD,QAC5B,OAAO;gBACH,cAAc;gBACd,YAAY;gBACZ,QAAQ;gBACR,OAAO,EAAE;YACb;YAGJ,MAAM,IAAIE,cAAYF,MAAM,OAAO,EAAEA,MAAM,IAAI,IAAI,oBAAoB;gBACnEA;gBACAP;gBACAE;gBACAP;YACJ;QACJ;QAEA,MAAM,EAAEe,IAAI,EAAEC,KAAK,EAAE,GAAGP,SAAS,IAAI,CAAC,IAAI;QAE1C,MAAMQ,QAAQC,wBAA2B;YACrC,eAAe,IAAI,CAAC,aAAa;YACjC,oBAAoB,IAAI,CAAC,kBAAkB;YAC3ClB;YACA,SAASe,KAAK,GAAG,CAACI,CAAAA,OACPA,KAAK,OAAO;QAE3B,GAAG,GAAG,CAACA,CAAAA,OACIC,4BAA+B;gBAClCpB;gBACA,OAAOmB;YACX;QAGJ,MAAME,eAAeJ,MAAM,MAAM,GAAGhB;QACpC,IAAIoB,cAIAJ,MAAM,GAAG;QAMb,MAAMK,SAASL,MAAM,MAAM,GAAG,IAAIM,aAAaR,IAAI,CAACE,MAAM,MAAM,GAAG,EAAE,CAAC,IAAI,KAAK,OAAO;QACtF,OAAO;YACHI;YACA,YAAYG,cAAcR;YAC1BM;YACAL;QACJ;IACJ;AACJ;AAEO,MAAMQ,mBAAmBC,4BAA4B,oBAAoB,CAAC;IAC7E,gBAAgBpC;IAChB,cAAc;QACVqC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import { MoveEntryStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveEntryStorageOperation.js";
|
|
3
|
+
import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
|
|
4
|
+
import { CmsDdbEsEntriesEsEntity } from "../../abstractions/CmsDdbEsEntriesEsEntity.js";
|
|
5
|
+
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
6
|
+
import { CmsStorageModelProvider } from "@webiny/api-headless-cms/features/shared/abstractions.js";
|
|
7
|
+
import { CompressionHandler } from "@webiny/utils/exports/api.js";
|
|
8
|
+
declare class DdbEsMoveEntryImpl implements MoveEntryStorageOperation.Interface {
|
|
9
|
+
private entity;
|
|
10
|
+
private esEntity;
|
|
11
|
+
private dataLoaders;
|
|
12
|
+
private storageModelProvider;
|
|
13
|
+
private compressionHandler;
|
|
14
|
+
constructor(entity: CmsDdbEsEntryEntity.Interface, esEntity: CmsDdbEsEntriesEsEntity.Interface, dataLoaders: CmsDdbEsDataLoaders.Interface, storageModelProvider: CmsStorageModelProvider.Interface, compressionHandler: CompressionHandler.Interface);
|
|
15
|
+
execute(initialModel: CmsModel, id: string, folderId: string): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare const DdbEsMoveEntry: typeof DdbEsMoveEntryImpl & {
|
|
18
|
+
__abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/entry/MoveEntryStorageOperation.js").IMoveEntryStorageOperation>;
|
|
19
|
+
};
|
|
20
|
+
export {};
|