@webiny/api-headless-cms-ddb-es 0.0.0-mt-3 → 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
|
@@ -1,347 +1,98 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _dataloader = _interopRequireDefault(require("dataloader"));
|
|
13
|
-
|
|
14
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
|
-
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
17
|
-
|
|
18
|
-
var _keys = require("./keys");
|
|
19
|
-
|
|
20
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
21
|
-
|
|
22
|
-
var _utils = require("@webiny/utils");
|
|
23
|
-
|
|
24
|
-
var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
|
|
25
|
-
|
|
26
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
-
|
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
29
|
-
|
|
30
|
-
const getAllEntryRevisions = params => {
|
|
31
|
-
const {
|
|
32
|
-
entity,
|
|
33
|
-
model
|
|
34
|
-
} = params;
|
|
35
|
-
const {
|
|
36
|
-
tenant,
|
|
37
|
-
locale
|
|
38
|
-
} = model;
|
|
39
|
-
return new _dataloader.default(async ids => {
|
|
40
|
-
const results = [];
|
|
41
|
-
|
|
42
|
-
for (const id of ids) {
|
|
43
|
-
const queryAllParams = {
|
|
44
|
-
entity,
|
|
45
|
-
partitionKey: (0, _keys.createPartitionKey)({
|
|
46
|
-
tenant,
|
|
47
|
-
locale,
|
|
48
|
-
id
|
|
49
|
-
}),
|
|
50
|
-
options: {
|
|
51
|
-
beginsWith: "REV#"
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
const items = await (0, _query.queryAll)(queryAllParams);
|
|
55
|
-
const entries = (0, _cleanup.cleanupItems)(entity, items);
|
|
56
|
-
results.push(entries);
|
|
1
|
+
import error from "@webiny/error";
|
|
2
|
+
import { DataLoaderCache } from "./dataLoader/DataLoaderCache.js";
|
|
3
|
+
import { getDataLoaderFactory } from "./dataLoader/index.js";
|
|
4
|
+
import { parseIdentifier } from "@webiny/utils";
|
|
5
|
+
import { CmsDdbEsDataLoaders } from "../../abstractions/CmsDdbEsDataLoaders.js";
|
|
6
|
+
import { CmsDdbEsEntryEntity } from "../../abstractions/CmsDdbEsEntryEntity.js";
|
|
7
|
+
class DataLoadersHandlerImpl {
|
|
8
|
+
constructor(entity){
|
|
9
|
+
this.entity = entity;
|
|
10
|
+
this.cache = new DataLoaderCache();
|
|
57
11
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const {
|
|
65
|
-
entity,
|
|
66
|
-
model
|
|
67
|
-
} = params;
|
|
68
|
-
const {
|
|
69
|
-
locale,
|
|
70
|
-
tenant
|
|
71
|
-
} = model;
|
|
72
|
-
return new _dataloader.default(async ids => {
|
|
73
|
-
const queries = ids.reduce((collection, id) => {
|
|
74
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
75
|
-
tenant,
|
|
76
|
-
locale,
|
|
77
|
-
id
|
|
78
|
-
});
|
|
79
|
-
const {
|
|
80
|
-
version
|
|
81
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
82
|
-
const sortKey = (0, _keys.createRevisionSortKey)({
|
|
83
|
-
version
|
|
84
|
-
});
|
|
85
|
-
const keys = `${partitionKey}__${sortKey}`;
|
|
86
|
-
|
|
87
|
-
if (collection[keys]) {
|
|
88
|
-
return collection;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
collection[keys] = entity.getBatch({
|
|
92
|
-
PK: partitionKey,
|
|
93
|
-
SK: sortKey
|
|
94
|
-
});
|
|
95
|
-
return collection;
|
|
96
|
-
}, {});
|
|
97
|
-
const records = await (0, _batchRead.batchReadAll)({
|
|
98
|
-
table: entity.table,
|
|
99
|
-
items: Object.values(queries)
|
|
100
|
-
});
|
|
101
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
102
|
-
return ids.map(id => {
|
|
103
|
-
return items.filter(item => {
|
|
104
|
-
return id === item.id;
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const getPublishedRevisionByEntryId = params => {
|
|
111
|
-
const {
|
|
112
|
-
entity,
|
|
113
|
-
model
|
|
114
|
-
} = params;
|
|
115
|
-
const {
|
|
116
|
-
locale,
|
|
117
|
-
tenant
|
|
118
|
-
} = model;
|
|
119
|
-
const publishedKey = (0, _keys.createPublishedSortKey)();
|
|
120
|
-
return new _dataloader.default(async ids => {
|
|
121
|
-
const queries = ids.reduce((collection, id) => {
|
|
122
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
123
|
-
tenant,
|
|
124
|
-
locale,
|
|
125
|
-
id
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
if (collection[partitionKey]) {
|
|
129
|
-
return collection;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
collection[partitionKey] = entity.getBatch({
|
|
133
|
-
PK: partitionKey,
|
|
134
|
-
SK: publishedKey
|
|
135
|
-
});
|
|
136
|
-
return collection;
|
|
137
|
-
}, {});
|
|
138
|
-
const records = await (0, _batchRead.batchReadAll)({
|
|
139
|
-
table: entity.table,
|
|
140
|
-
items: Object.values(queries)
|
|
141
|
-
});
|
|
142
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
143
|
-
return ids.map(id => {
|
|
144
|
-
const {
|
|
145
|
-
id: entryId
|
|
146
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
147
|
-
return items.filter(item => {
|
|
148
|
-
return entryId === item.entryId;
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
const getLatestRevisionByEntryId = params => {
|
|
155
|
-
const {
|
|
156
|
-
entity,
|
|
157
|
-
model
|
|
158
|
-
} = params;
|
|
159
|
-
const {
|
|
160
|
-
locale,
|
|
161
|
-
tenant
|
|
162
|
-
} = model;
|
|
163
|
-
const latestKey = (0, _keys.createLatestSortKey)();
|
|
164
|
-
return new _dataloader.default(async ids => {
|
|
165
|
-
const queries = ids.reduce((collection, id) => {
|
|
166
|
-
const partitionKey = (0, _keys.createPartitionKey)({
|
|
167
|
-
tenant,
|
|
168
|
-
locale,
|
|
169
|
-
id
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
if (collection[partitionKey]) {
|
|
173
|
-
return collection;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
collection[partitionKey] = entity.getBatch({
|
|
177
|
-
PK: partitionKey,
|
|
178
|
-
SK: latestKey
|
|
179
|
-
});
|
|
180
|
-
return collection;
|
|
181
|
-
}, {});
|
|
182
|
-
const records = await (0, _batchRead.batchReadAll)({
|
|
183
|
-
table: entity.table,
|
|
184
|
-
items: Object.values(queries)
|
|
185
|
-
});
|
|
186
|
-
const items = (0, _cleanup.cleanupItems)(entity, records);
|
|
187
|
-
return ids.map(id => {
|
|
188
|
-
const {
|
|
189
|
-
id: entryId
|
|
190
|
-
} = (0, _utils.parseIdentifier)(id);
|
|
191
|
-
return items.filter(item => {
|
|
192
|
-
return entryId === item.entryId;
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
const dataLoaders = {
|
|
199
|
-
getAllEntryRevisions,
|
|
200
|
-
getRevisionById,
|
|
201
|
-
getPublishedRevisionByEntryId,
|
|
202
|
-
getLatestRevisionByEntryId
|
|
203
|
-
};
|
|
204
|
-
const loaderNames = Object.keys(dataLoaders);
|
|
205
|
-
|
|
206
|
-
class DataLoadersHandler {
|
|
207
|
-
constructor(params) {
|
|
208
|
-
(0, _defineProperty2.default)(this, "loaders", new Map());
|
|
209
|
-
(0, _defineProperty2.default)(this, "entity", void 0);
|
|
210
|
-
this.entity = params.entity;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
async getAllEntryRevisions(params) {
|
|
214
|
-
return await this.loadMany("getAllEntryRevisions", params, params.ids);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
clearAllEntryRevisions(params) {
|
|
218
|
-
this.clear("getAllEntryRevisions", params);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
async getRevisionById(params) {
|
|
222
|
-
return await this.loadMany("getRevisionById", params, params.ids);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
clearRevisionById(params) {
|
|
226
|
-
this.clear("getRevisionById", params);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
async getPublishedRevisionByEntryId(params) {
|
|
230
|
-
return await this.loadMany("getPublishedRevisionByEntryId", params, params.ids);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
clearPublishedRevisionByEntryId(params) {
|
|
234
|
-
this.clear("getPublishedRevisionByEntryId", params);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
async getLatestRevisionByEntryId(params) {
|
|
238
|
-
return await this.loadMany("getLatestRevisionByEntryId", params, params.ids);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
clearLatestRevisionByEntryId(params) {
|
|
242
|
-
this.clear("getLatestRevisionByEntryId", params);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
getLoader(name, params) {
|
|
246
|
-
if (!dataLoaders[name]) {
|
|
247
|
-
throw new _error.default("Unknown data loader.", "UNKNOWN_DATA_LOADER", {
|
|
248
|
-
name
|
|
249
|
-
});
|
|
12
|
+
async getAllEntryRevisions(params) {
|
|
13
|
+
const ids = params.ids.map((id)=>{
|
|
14
|
+
const { id: entryId } = parseIdentifier(id);
|
|
15
|
+
return entryId;
|
|
16
|
+
});
|
|
17
|
+
return await this.loadMany("getAllEntryRevisions", params, ids);
|
|
250
18
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
model
|
|
254
|
-
} = params;
|
|
255
|
-
const {
|
|
256
|
-
tenant,
|
|
257
|
-
locale
|
|
258
|
-
} = model;
|
|
259
|
-
const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;
|
|
260
|
-
|
|
261
|
-
if (!this.loaders.has(loaderKey)) {
|
|
262
|
-
this.loaders.set(loaderKey, dataLoaders[name](_objectSpread(_objectSpread({}, params), {}, {
|
|
263
|
-
entity: this.entity
|
|
264
|
-
})));
|
|
19
|
+
async getRevisionById(params) {
|
|
20
|
+
return await this.loadMany("getRevisionById", params, params.ids);
|
|
265
21
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
try {
|
|
274
|
-
results = await this.getLoader(loader, params).loadMany(ids);
|
|
275
|
-
|
|
276
|
-
if (Array.isArray(results) === true) {
|
|
277
|
-
return results.reduce((acc, res) => {
|
|
278
|
-
if (Array.isArray(res) === false) {
|
|
279
|
-
if (res && res.message) {
|
|
280
|
-
throw new _error.default(res.message, res.code, _objectSpread(_objectSpread({}, res), {}, {
|
|
281
|
-
data: JSON.stringify(res.data || {})
|
|
282
|
-
}));
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
throw new _error.default("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", _objectSpread(_objectSpread({}, params), {}, {
|
|
286
|
-
loader
|
|
287
|
-
}));
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
acc.push(...res);
|
|
291
|
-
return acc;
|
|
292
|
-
}, []);
|
|
293
|
-
}
|
|
294
|
-
} catch (ex) {
|
|
295
|
-
throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", _objectSpread(_objectSpread({
|
|
296
|
-
error: ex
|
|
297
|
-
}, params), {}, {
|
|
298
|
-
loader,
|
|
299
|
-
ids
|
|
300
|
-
}));
|
|
22
|
+
async getPublishedRevisionByEntryId(params) {
|
|
23
|
+
const ids = params.ids.map((id)=>{
|
|
24
|
+
const { id: entryId } = parseIdentifier(id);
|
|
25
|
+
return entryId;
|
|
26
|
+
});
|
|
27
|
+
return await this.loadMany("getPublishedRevisionByEntryId", params, ids);
|
|
301
28
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
clearAll(params) {
|
|
311
|
-
for (const name of loaderNames) {
|
|
312
|
-
const loader = this.getLoader(name, params);
|
|
313
|
-
loader.clearAll();
|
|
29
|
+
async getLatestRevisionByEntryId(params) {
|
|
30
|
+
const ids = params.ids.map((id)=>{
|
|
31
|
+
const { id: entryId } = parseIdentifier(id);
|
|
32
|
+
return entryId;
|
|
33
|
+
});
|
|
34
|
+
return await this.loadMany("getLatestRevisionByEntryId", params, ids);
|
|
314
35
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
36
|
+
getLoader(name, params) {
|
|
37
|
+
const { model } = params;
|
|
38
|
+
const cacheParams = {
|
|
39
|
+
tenant: model.tenant,
|
|
40
|
+
modelId: model.modelId,
|
|
41
|
+
name
|
|
42
|
+
};
|
|
43
|
+
let loader = this.cache.getDataLoader(cacheParams);
|
|
44
|
+
if (loader) return loader;
|
|
45
|
+
const factory = getDataLoaderFactory(name);
|
|
46
|
+
loader = factory({
|
|
47
|
+
entity: this.entity,
|
|
48
|
+
tenant: model.tenant,
|
|
49
|
+
modelId: model.modelId
|
|
50
|
+
});
|
|
51
|
+
this.cache.setDataLoader(cacheParams, loader);
|
|
52
|
+
return loader;
|
|
53
|
+
}
|
|
54
|
+
async loadMany(loader, params, ids) {
|
|
55
|
+
let results = [];
|
|
56
|
+
try {
|
|
57
|
+
results = await this.getLoader(loader, params).loadMany(ids);
|
|
58
|
+
if (true === Array.isArray(results)) return results.reduce((acc, res)=>{
|
|
59
|
+
if (false === Array.isArray(res)) {
|
|
60
|
+
if (res && res.message) throw new error(res.message, res.code, {
|
|
61
|
+
...res,
|
|
62
|
+
data: JSON.stringify(res.data || {})
|
|
63
|
+
});
|
|
64
|
+
throw new error("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", {
|
|
65
|
+
...params,
|
|
66
|
+
loader
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
acc.push(...res);
|
|
70
|
+
return acc;
|
|
71
|
+
}, []);
|
|
72
|
+
} catch (ex) {
|
|
73
|
+
throw new error(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", {
|
|
74
|
+
error: ex,
|
|
75
|
+
...params,
|
|
76
|
+
loader,
|
|
77
|
+
ids
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
throw new error("Data loader did not return array of items or empty array.", "INVALID_DATA_LOADER_RESULT", {
|
|
81
|
+
loader,
|
|
82
|
+
ids,
|
|
83
|
+
results
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
clearAll(params) {
|
|
87
|
+
this.cache.clearAll(params);
|
|
331
88
|
}
|
|
332
|
-
|
|
333
|
-
loader.clear(entry.id);
|
|
334
|
-
const {
|
|
335
|
-
tenant,
|
|
336
|
-
locale
|
|
337
|
-
} = params.model;
|
|
338
|
-
loader.clear((0, _keys.createPartitionKey)({
|
|
339
|
-
tenant,
|
|
340
|
-
locale,
|
|
341
|
-
id: entry.id
|
|
342
|
-
}));
|
|
343
|
-
}
|
|
344
|
-
|
|
345
89
|
}
|
|
90
|
+
const DataLoadersHandler = CmsDdbEsDataLoaders.createImplementation({
|
|
91
|
+
implementation: DataLoadersHandlerImpl,
|
|
92
|
+
dependencies: [
|
|
93
|
+
CmsDdbEsEntryEntity
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
export { DataLoadersHandler };
|
|
346
97
|
|
|
347
|
-
|
|
98
|
+
//# sourceMappingURL=dataLoaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/dataLoaders.js","sources":["../../../src/operations/entry/dataLoaders.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport type {\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CacheKeyParams } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport { DataLoaderCache } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport type { DataLoaders } from \"~/operations/entry/dataLoader/index.js\";\nimport { getDataLoaderFactory } from \"~/operations/entry/dataLoader/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport type { DataLoadersHandlerInterfaceClearAllParams, IDataLoadersHandler } from \"~/types.js\";\nimport type { IEntryEntity } from \"~/definitions/types.js\";\nimport { CmsDdbEsDataLoaders } from \"~/abstractions/CmsDdbEsDataLoaders.js\";\nimport { CmsDdbEsEntryEntity } from \"~/abstractions/CmsDdbEsEntryEntity.js\";\n\ninterface DataLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n ids: readonly string[];\n}\n\ninterface GetLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\nexport interface ClearAllParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\nclass DataLoadersHandlerImpl implements IDataLoadersHandler {\n private readonly cache = new DataLoaderCache();\n\n public constructor(private readonly entity: IEntryEntity) {}\n\n public async getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getAllEntryRevisions\", params, ids);\n }\n\n public async getRevisionById<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n return await this.loadMany<T>(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getPublishedRevisionByEntryId\", params, ids);\n }\n\n public async getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getLatestRevisionByEntryId\", params, ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: DataLoaders, params: GetLoaderParams): DataLoader<any, any> {\n const { model } = params;\n const cacheParams: CacheKeyParams = {\n tenant: model.tenant,\n modelId: model.modelId,\n name\n };\n let loader = this.cache.getDataLoader(cacheParams);\n if (loader) {\n return loader;\n }\n const factory = getDataLoaderFactory(name);\n loader = factory({\n entity: this.entity,\n tenant: model.tenant,\n modelId: model.modelId\n });\n this.cache.setDataLoader(cacheParams, loader);\n return loader;\n }\n\n private async loadMany<T extends CmsEntryValues = CmsEntryValues>(\n loader: DataLoaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry<T>[]> {\n let results: CmsStorageEntry<T>[] = [];\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce<CmsStorageEntry<T>[]>((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void {\n this.cache.clearAll(params);\n }\n}\n\nexport const DataLoadersHandler = CmsDdbEsDataLoaders.createImplementation({\n implementation: DataLoadersHandlerImpl,\n dependencies: [CmsDdbEsEntryEntity]\n});\n"],"names":["DataLoadersHandlerImpl","entity","DataLoaderCache","params","ids","id","entryId","parseIdentifier","name","model","cacheParams","loader","factory","getDataLoaderFactory","results","Array","acc","res","WebinyError","JSON","ex","DataLoadersHandler","CmsDdbEsDataLoaders","CmsDdbEsEntryEntity"],"mappings":";;;;;;AA8BA,MAAMA;IAGF,YAAoCC,MAAoB,CAAE;aAAtBA,MAAM,GAANA;aAFnB,KAAK,GAAG,IAAIC;IAE8B;IAE3D,MAAa,qBACTC,MAAwB,EACK;QAC7B,MAAMC,MAAMD,OAAO,GAAG,CAAC,GAAG,CAACE,CAAAA;YACvB,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBF;YACxC,OAAOC;QACX;QACA,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,wBAAwBH,QAAQC;IAClE;IAEA,MAAa,gBACTD,MAAwB,EACK;QAC7B,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,mBAAmBA,QAAQA,OAAO,GAAG;IACvE;IAEA,MAAa,8BACTA,MAAwB,EACK;QAC7B,MAAMC,MAAMD,OAAO,GAAG,CAAC,GAAG,CAACE,CAAAA;YACvB,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBF;YACxC,OAAOC;QACX;QACA,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,iCAAiCH,QAAQC;IAC3E;IAEA,MAAa,2BACTD,MAAwB,EACK;QAC7B,MAAMC,MAAMD,OAAO,GAAG,CAAC,GAAG,CAACE,CAAAA;YACvB,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBF;YACxC,OAAOC;QACX;QACA,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,8BAA8BH,QAAQC;IACxE;IAMQ,UAAUI,IAAiB,EAAEL,MAAuB,EAAwB;QAChF,MAAM,EAAEM,KAAK,EAAE,GAAGN;QAClB,MAAMO,cAA8B;YAChC,QAAQD,MAAM,MAAM;YACpB,SAASA,MAAM,OAAO;YACtBD;QACJ;QACA,IAAIG,SAAS,IAAI,CAAC,KAAK,CAAC,aAAa,CAACD;QACtC,IAAIC,QACA,OAAOA;QAEX,MAAMC,UAAUC,qBAAqBL;QACrCG,SAASC,QAAQ;YACb,QAAQ,IAAI,CAAC,MAAM;YACnB,QAAQH,MAAM,MAAM;YACpB,SAASA,MAAM,OAAO;QAC1B;QACA,IAAI,CAAC,KAAK,CAAC,aAAa,CAACC,aAAaC;QACtC,OAAOA;IACX;IAEA,MAAc,SACVA,MAAmB,EACnBR,MAAuB,EACvBC,GAAsB,EACO;QAC7B,IAAIU,UAAgC,EAAE;QACtC,IAAI;YACAA,UAAU,MAAM,IAAI,CAAC,SAAS,CAACH,QAAQR,QAAQ,QAAQ,CAACC;YACxD,IAAIW,AAA2B,SAA3BA,MAAM,OAAO,CAACD,UACd,OAAOA,QAAQ,MAAM,CAAuB,CAACE,KAAKC;gBAC9C,IAAIF,AAAuB,UAAvBA,MAAM,OAAO,CAACE,MAAgB;oBAC9B,IAAIA,OAAOA,IAAI,OAAO,EAClB,MAAM,IAAIC,MAAYD,IAAI,OAAO,EAAEA,IAAI,IAAI,EAAE;wBACzC,GAAGA,GAAG;wBACN,MAAME,KAAK,SAAS,CAACF,IAAI,IAAI,IAAI,CAAC;oBACtC;oBAEJ,MAAM,IAAIC,MACN,yFACA,6BACA;wBACI,GAAGf,MAAM;wBACTQ;oBACJ;gBAER;gBACAK,IAAI,IAAI,IAAIC;gBACZ,OAAOD;YACX,GAAG,EAAE;QAEb,EAAE,OAAOI,IAAI;YACT,MAAM,IAAIF,MACNE,GAAG,OAAO,IAAI,sBACdA,GAAG,IAAI,IAAI,qBACX;gBACI,OAAOA;gBACP,GAAGjB,MAAM;gBACTQ;gBACAP;YACJ;QAER;QACA,MAAM,IAAIc,MACN,6DACA,8BACA;YACIP;YACAP;YACAU;QACJ;IAER;IAEO,SAASX,MAAkD,EAAQ;QACtE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAACA;IACxB;AACJ;AAEO,MAAMkB,qBAAqBC,oBAAoB,oBAAoB,CAAC;IACvE,gBAAgBtB;IAChB,cAAc;QAACuB;KAAoB;AACvC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api/index.js";
|
|
2
|
+
import { DataLoadersHandler } from "./dataLoaders.js";
|
|
3
|
+
import { DdbEsCreateEntry } from "./DdbEsCreateEntry.js";
|
|
4
|
+
import { DdbEsCreateEntryRevisionFrom } from "./DdbEsCreateEntryRevisionFrom.js";
|
|
5
|
+
import { DdbEsUpdateEntry } from "./DdbEsUpdateEntry.js";
|
|
6
|
+
import { DdbEsMoveEntry } from "./DdbEsMoveEntry.js";
|
|
7
|
+
import { DdbEsMoveToBin } from "./DdbEsMoveToBin.js";
|
|
8
|
+
import { DdbEsDeleteEntry } from "./DdbEsDeleteEntry.js";
|
|
9
|
+
import { DdbEsRestoreFromBin } from "./DdbEsRestoreFromBin.js";
|
|
10
|
+
import { DdbEsDeleteEntryRevision } from "./DdbEsDeleteEntryRevision.js";
|
|
11
|
+
import { DdbEsDeleteMultipleEntries } from "./DdbEsDeleteMultipleEntries.js";
|
|
12
|
+
import { DdbEsGetEntry } from "./DdbEsGetEntry.js";
|
|
13
|
+
import { DdbEsListEntries } from "./DdbEsListEntries.js";
|
|
14
|
+
import { DdbEsPublishEntry } from "./DdbEsPublishEntry.js";
|
|
15
|
+
import { DdbEsUnpublishEntry } from "./DdbEsUnpublishEntry.js";
|
|
16
|
+
import { DdbEsGetEntriesByIds } from "./DdbEsGetEntriesByIds.js";
|
|
17
|
+
import { DdbEsGetLatestEntriesByIds } from "./DdbEsGetLatestEntriesByIds.js";
|
|
18
|
+
import { DdbEsGetPublishedEntriesByIds } from "./DdbEsGetPublishedEntriesByIds.js";
|
|
19
|
+
import { DdbEsGetRevisions } from "./DdbEsGetRevisions.js";
|
|
20
|
+
import { DdbEsGetRevisionById } from "./DdbEsGetRevisionById.js";
|
|
21
|
+
import { DdbEsGetLatestRevisionByEntryId } from "./DdbEsGetLatestRevisionByEntryId.js";
|
|
22
|
+
import { DdbEsGetPublishedRevisionByEntryId } from "./DdbEsGetPublishedRevisionByEntryId.js";
|
|
23
|
+
import { DdbEsGetPreviousRevision } from "./DdbEsGetPreviousRevision.js";
|
|
24
|
+
import { DdbEsGetUniqueFieldValues } from "./DdbEsGetUniqueFieldValues.js";
|
|
25
|
+
const DdbEsEntryStorageOpsFeature = createFeature({
|
|
26
|
+
name: "cms.ddbEs.entryStorageOps",
|
|
27
|
+
register: (container)=>{
|
|
28
|
+
container.register(DataLoadersHandler).inContainerScope();
|
|
29
|
+
container.register(DdbEsCreateEntry);
|
|
30
|
+
container.register(DdbEsCreateEntryRevisionFrom);
|
|
31
|
+
container.register(DdbEsUpdateEntry);
|
|
32
|
+
container.register(DdbEsMoveEntry);
|
|
33
|
+
container.register(DdbEsMoveToBin);
|
|
34
|
+
container.register(DdbEsDeleteEntry);
|
|
35
|
+
container.register(DdbEsRestoreFromBin);
|
|
36
|
+
container.register(DdbEsDeleteEntryRevision);
|
|
37
|
+
container.register(DdbEsDeleteMultipleEntries);
|
|
38
|
+
container.register(DdbEsGetEntry);
|
|
39
|
+
container.register(DdbEsListEntries);
|
|
40
|
+
container.register(DdbEsPublishEntry);
|
|
41
|
+
container.register(DdbEsUnpublishEntry);
|
|
42
|
+
container.register(DdbEsGetEntriesByIds);
|
|
43
|
+
container.register(DdbEsGetLatestEntriesByIds);
|
|
44
|
+
container.register(DdbEsGetPublishedEntriesByIds);
|
|
45
|
+
container.register(DdbEsGetRevisions);
|
|
46
|
+
container.register(DdbEsGetRevisionById);
|
|
47
|
+
container.register(DdbEsGetLatestRevisionByEntryId);
|
|
48
|
+
container.register(DdbEsGetPublishedRevisionByEntryId);
|
|
49
|
+
container.register(DdbEsGetPreviousRevision);
|
|
50
|
+
container.register(DdbEsGetUniqueFieldValues);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
export { DdbEsEntryStorageOpsFeature };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/feature.js","sources":["../../../src/operations/entry/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { DataLoadersHandler } from \"./dataLoaders.js\";\nimport { DdbEsCreateEntry } from \"./DdbEsCreateEntry.js\";\nimport { DdbEsCreateEntryRevisionFrom } from \"./DdbEsCreateEntryRevisionFrom.js\";\nimport { DdbEsUpdateEntry } from \"./DdbEsUpdateEntry.js\";\nimport { DdbEsMoveEntry } from \"./DdbEsMoveEntry.js\";\nimport { DdbEsMoveToBin } from \"./DdbEsMoveToBin.js\";\nimport { DdbEsDeleteEntry } from \"./DdbEsDeleteEntry.js\";\nimport { DdbEsRestoreFromBin } from \"./DdbEsRestoreFromBin.js\";\nimport { DdbEsDeleteEntryRevision } from \"./DdbEsDeleteEntryRevision.js\";\nimport { DdbEsDeleteMultipleEntries } from \"./DdbEsDeleteMultipleEntries.js\";\nimport { DdbEsGetEntry } from \"./DdbEsGetEntry.js\";\nimport { DdbEsListEntries } from \"./DdbEsListEntries.js\";\nimport { DdbEsPublishEntry } from \"./DdbEsPublishEntry.js\";\nimport { DdbEsUnpublishEntry } from \"./DdbEsUnpublishEntry.js\";\nimport { DdbEsGetEntriesByIds } from \"./DdbEsGetEntriesByIds.js\";\nimport { DdbEsGetLatestEntriesByIds } from \"./DdbEsGetLatestEntriesByIds.js\";\nimport { DdbEsGetPublishedEntriesByIds } from \"./DdbEsGetPublishedEntriesByIds.js\";\nimport { DdbEsGetRevisions } from \"./DdbEsGetRevisions.js\";\nimport { DdbEsGetRevisionById } from \"./DdbEsGetRevisionById.js\";\nimport { DdbEsGetLatestRevisionByEntryId } from \"./DdbEsGetLatestRevisionByEntryId.js\";\nimport { DdbEsGetPublishedRevisionByEntryId } from \"./DdbEsGetPublishedRevisionByEntryId.js\";\nimport { DdbEsGetPreviousRevision } from \"./DdbEsGetPreviousRevision.js\";\nimport { DdbEsGetUniqueFieldValues } from \"./DdbEsGetUniqueFieldValues.js\";\n\nexport const DdbEsEntryStorageOpsFeature = createFeature({\n name: \"cms.ddbEs.entryStorageOps\",\n register: container => {\n // The DataLoader caches reads, so it must live for one request: container scoped, it is built\n // per request (child) container even though the feature is registered once in the root.\n container.register(DataLoadersHandler).inContainerScope();\n container.register(DdbEsCreateEntry);\n container.register(DdbEsCreateEntryRevisionFrom);\n container.register(DdbEsUpdateEntry);\n container.register(DdbEsMoveEntry);\n container.register(DdbEsMoveToBin);\n container.register(DdbEsDeleteEntry);\n container.register(DdbEsRestoreFromBin);\n container.register(DdbEsDeleteEntryRevision);\n container.register(DdbEsDeleteMultipleEntries);\n container.register(DdbEsGetEntry);\n container.register(DdbEsListEntries);\n container.register(DdbEsPublishEntry);\n container.register(DdbEsUnpublishEntry);\n container.register(DdbEsGetEntriesByIds);\n container.register(DdbEsGetLatestEntriesByIds);\n container.register(DdbEsGetPublishedEntriesByIds);\n container.register(DdbEsGetRevisions);\n container.register(DdbEsGetRevisionById);\n container.register(DdbEsGetLatestRevisionByEntryId);\n container.register(DdbEsGetPublishedRevisionByEntryId);\n container.register(DdbEsGetPreviousRevision);\n container.register(DdbEsGetUniqueFieldValues);\n }\n});\n"],"names":["DdbEsEntryStorageOpsFeature","createFeature","container","DataLoadersHandler","DdbEsCreateEntry","DdbEsCreateEntryRevisionFrom","DdbEsUpdateEntry","DdbEsMoveEntry","DdbEsMoveToBin","DdbEsDeleteEntry","DdbEsRestoreFromBin","DdbEsDeleteEntryRevision","DdbEsDeleteMultipleEntries","DdbEsGetEntry","DdbEsListEntries","DdbEsPublishEntry","DdbEsUnpublishEntry","DdbEsGetEntriesByIds","DdbEsGetLatestEntriesByIds","DdbEsGetPublishedEntriesByIds","DdbEsGetRevisions","DdbEsGetRevisionById","DdbEsGetLatestRevisionByEntryId","DdbEsGetPublishedRevisionByEntryId","DdbEsGetPreviousRevision","DdbEsGetUniqueFieldValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAMA,8BAA8BC,cAAc;IACrD,MAAM;IACN,UAAUC,CAAAA;QAGNA,UAAU,QAAQ,CAACC,oBAAoB,gBAAgB;QACvDD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;QACnBL,UAAU,QAAQ,CAACM;QACnBN,UAAU,QAAQ,CAACO;QACnBP,UAAU,QAAQ,CAACQ;QACnBR,UAAU,QAAQ,CAACS;QACnBT,UAAU,QAAQ,CAACU;QACnBV,UAAU,QAAQ,CAACW;QACnBX,UAAU,QAAQ,CAACY;QACnBZ,UAAU,QAAQ,CAACa;QACnBb,UAAU,QAAQ,CAACc;QACnBd,UAAU,QAAQ,CAACe;QACnBf,UAAU,QAAQ,CAACgB;QACnBhB,UAAU,QAAQ,CAACiB;QACnBjB,UAAU,QAAQ,CAACkB;QACnBlB,UAAU,QAAQ,CAACmB;QACnBnB,UAAU,QAAQ,CAACoB;QACnBpB,UAAU,QAAQ,CAACqB;QACnBrB,UAAU,QAAQ,CAACsB;QACnBtB,UAAU,QAAQ,CAACuB;IACvB;AACJ"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export interface PartitionKeyParams {
|
|
2
2
|
id: string;
|
|
3
3
|
tenant: string;
|
|
4
|
-
locale: string;
|
|
5
4
|
}
|
|
6
5
|
export declare const createPartitionKey: (params: PartitionKeyParams) => string;
|
|
7
6
|
export interface SortKeyParams {
|
|
@@ -10,3 +9,34 @@ export interface SortKeyParams {
|
|
|
10
9
|
export declare const createRevisionSortKey: (params: SortKeyParams) => string;
|
|
11
10
|
export declare const createLatestSortKey: () => string;
|
|
12
11
|
export declare const createPublishedSortKey: () => string;
|
|
12
|
+
export interface ICreateEntryPublishedKeysParams {
|
|
13
|
+
id: string;
|
|
14
|
+
tenant: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const createEntryPublishedKeys: (params: ICreateEntryPublishedKeysParams) => {
|
|
17
|
+
PK: string;
|
|
18
|
+
SK: string;
|
|
19
|
+
TYPE: string;
|
|
20
|
+
GSI_TENANT: string;
|
|
21
|
+
};
|
|
22
|
+
export interface ICreateEntryLatestKeysParams {
|
|
23
|
+
id: string;
|
|
24
|
+
tenant: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const createEntryLatestKeys: (params: ICreateEntryLatestKeysParams) => {
|
|
27
|
+
PK: string;
|
|
28
|
+
SK: string;
|
|
29
|
+
TYPE: string;
|
|
30
|
+
GSI_TENANT: string;
|
|
31
|
+
};
|
|
32
|
+
export interface ICreateRevisionKeysParams {
|
|
33
|
+
id: string;
|
|
34
|
+
tenant: string;
|
|
35
|
+
version: number;
|
|
36
|
+
}
|
|
37
|
+
export declare const createEntryRevisionKeys: (params: ICreateRevisionKeysParams) => {
|
|
38
|
+
PK: string;
|
|
39
|
+
SK: string;
|
|
40
|
+
TYPE: string;
|
|
41
|
+
GSI_TENANT: string;
|
|
42
|
+
};
|
package/operations/entry/keys.js
CHANGED
|
@@ -1,40 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
exports.createRevisionSortKey = exports.createPublishedSortKey = exports.createPartitionKey = exports.createLatestSortKey = void 0;
|
|
7
|
-
|
|
8
|
-
var _utils = require("@webiny/utils");
|
|
9
|
-
|
|
10
|
-
const createPartitionKey = params => {
|
|
11
|
-
const {
|
|
12
|
-
tenant,
|
|
13
|
-
locale,
|
|
14
|
-
id: initialId
|
|
15
|
-
} = params;
|
|
16
|
-
const {
|
|
17
|
-
id
|
|
18
|
-
} = (0, _utils.parseIdentifier)(initialId);
|
|
19
|
-
return `T#${tenant}#L#${locale}#CMS#CME#${id}`;
|
|
1
|
+
import { parseIdentifier, zeroPad } from "@webiny/utils";
|
|
2
|
+
const createPartitionKey = (params)=>{
|
|
3
|
+
const { tenant, id: initialId } = params;
|
|
4
|
+
const { id } = parseIdentifier(initialId);
|
|
5
|
+
return `T#${tenant}#CMS#CME#${id}`;
|
|
20
6
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
7
|
+
const createRevisionSortKey = (params)=>`REV#${zeroPad(params.version)}`;
|
|
8
|
+
const createLatestSortKey = ()=>"L";
|
|
9
|
+
const createPublishedSortKey = ()=>"P";
|
|
10
|
+
const createEntryPublishedKeys = (params)=>{
|
|
11
|
+
const { id, tenant } = params;
|
|
12
|
+
return {
|
|
13
|
+
PK: createPartitionKey({
|
|
14
|
+
id,
|
|
15
|
+
tenant
|
|
16
|
+
}),
|
|
17
|
+
SK: createPublishedSortKey(),
|
|
18
|
+
TYPE: "cms.entry.p",
|
|
19
|
+
GSI_TENANT: tenant
|
|
20
|
+
};
|
|
26
21
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
const createEntryLatestKeys = (params)=>{
|
|
23
|
+
const { id, tenant } = params;
|
|
24
|
+
return {
|
|
25
|
+
PK: createPartitionKey({
|
|
26
|
+
id,
|
|
27
|
+
tenant
|
|
28
|
+
}),
|
|
29
|
+
SK: createLatestSortKey(),
|
|
30
|
+
TYPE: "cms.entry.l",
|
|
31
|
+
GSI_TENANT: tenant
|
|
32
|
+
};
|
|
32
33
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
const createEntryRevisionKeys = (params)=>{
|
|
35
|
+
const { id, tenant, version } = params;
|
|
36
|
+
return {
|
|
37
|
+
PK: createPartitionKey({
|
|
38
|
+
id,
|
|
39
|
+
tenant
|
|
40
|
+
}),
|
|
41
|
+
SK: createRevisionSortKey({
|
|
42
|
+
version
|
|
43
|
+
}),
|
|
44
|
+
TYPE: "cms.entry",
|
|
45
|
+
GSI_TENANT: tenant
|
|
46
|
+
};
|
|
38
47
|
};
|
|
48
|
+
export { createEntryLatestKeys, createEntryPublishedKeys, createEntryRevisionKeys, createLatestSortKey, createPartitionKey, createPublishedSortKey, createRevisionSortKey };
|
|
39
49
|
|
|
40
|
-
|
|
50
|
+
//# sourceMappingURL=keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operations/entry/keys.js","sources":["../../../src/operations/entry/keys.ts"],"sourcesContent":["import { parseIdentifier, zeroPad } from \"@webiny/utils\";\n\nexport interface PartitionKeyParams {\n id: string;\n tenant: string;\n}\nexport const createPartitionKey = (params: PartitionKeyParams): string => {\n const { tenant, id: initialId } = params;\n const { id } = parseIdentifier(initialId);\n return `T#${tenant}#CMS#CME#${id}`;\n};\n\nexport interface SortKeyParams {\n version: number;\n}\nexport const createRevisionSortKey = (params: SortKeyParams): string => {\n return `REV#${zeroPad(params.version)}`;\n};\n\nexport const createLatestSortKey = (): string => {\n return \"L\";\n};\n\nexport const createPublishedSortKey = (): string => {\n return \"P\";\n};\n\nexport interface ICreateEntryPublishedKeysParams {\n id: string;\n tenant: string;\n}\n\nexport const createEntryPublishedKeys = (params: ICreateEntryPublishedKeysParams) => {\n const { id, tenant } = params;\n return {\n PK: createPartitionKey({\n id,\n tenant\n }),\n SK: createPublishedSortKey(),\n TYPE: `cms.entry.p`,\n GSI_TENANT: tenant\n };\n};\n\nexport interface ICreateEntryLatestKeysParams {\n id: string;\n tenant: string;\n}\n\nexport const createEntryLatestKeys = (params: ICreateEntryLatestKeysParams) => {\n const { id, tenant } = params;\n return {\n PK: createPartitionKey({\n id,\n tenant\n }),\n SK: createLatestSortKey(),\n TYPE: `cms.entry.l`,\n GSI_TENANT: tenant\n };\n};\n\nexport interface ICreateRevisionKeysParams {\n id: string;\n tenant: string;\n version: number;\n}\n\nexport const createEntryRevisionKeys = (params: ICreateRevisionKeysParams) => {\n const { id, tenant, version } = params;\n return {\n PK: createPartitionKey({\n id,\n tenant\n }),\n SK: createRevisionSortKey({\n version\n }),\n TYPE: `cms.entry`,\n GSI_TENANT: tenant\n };\n};\n"],"names":["createPartitionKey","params","tenant","initialId","id","parseIdentifier","createRevisionSortKey","zeroPad","createLatestSortKey","createPublishedSortKey","createEntryPublishedKeys","createEntryLatestKeys","createEntryRevisionKeys","version"],"mappings":";AAMO,MAAMA,qBAAqB,CAACC;IAC/B,MAAM,EAAEC,MAAM,EAAE,IAAIC,SAAS,EAAE,GAAGF;IAClC,MAAM,EAAEG,EAAE,EAAE,GAAGC,gBAAgBF;IAC/B,OAAO,CAAC,EAAE,EAAED,OAAO,SAAS,EAAEE,IAAI;AACtC;AAKO,MAAME,wBAAwB,CAACL,SAC3B,CAAC,IAAI,EAAEM,QAAQN,OAAO,OAAO,GAAG;AAGpC,MAAMO,sBAAsB,IACxB;AAGJ,MAAMC,yBAAyB,IAC3B;AAQJ,MAAMC,2BAA2B,CAACT;IACrC,MAAM,EAAEG,EAAE,EAAEF,MAAM,EAAE,GAAGD;IACvB,OAAO;QACH,IAAID,mBAAmB;YACnBI;YACAF;QACJ;QACA,IAAIO;QACJ,MAAM;QACN,YAAYP;IAChB;AACJ;AAOO,MAAMS,wBAAwB,CAACV;IAClC,MAAM,EAAEG,EAAE,EAAEF,MAAM,EAAE,GAAGD;IACvB,OAAO;QACH,IAAID,mBAAmB;YACnBI;YACAF;QACJ;QACA,IAAIM;QACJ,MAAM;QACN,YAAYN;IAChB;AACJ;AAQO,MAAMU,0BAA0B,CAACX;IACpC,MAAM,EAAEG,EAAE,EAAEF,MAAM,EAAEW,OAAO,EAAE,GAAGZ;IAChC,OAAO;QACH,IAAID,mBAAmB;YACnBI;YACAF;QACJ;QACA,IAAII,sBAAsB;YACtBO;QACJ;QACA,MAAM;QACN,YAAYX;IAChB;AACJ"}
|