@webiny/api-headless-cms-ddb-es 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f
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/configurations.d.ts +15 -8
- package/configurations.js +29 -12
- package/configurations.js.map +1 -0
- package/definitions/entry.d.ts +6 -5
- package/definitions/entry.js +111 -20
- package/definitions/entry.js.map +1 -0
- package/definitions/entryElasticsearch.d.ts +6 -5
- package/definitions/entryElasticsearch.js +11 -16
- package/definitions/entryElasticsearch.js.map +1 -0
- package/definitions/group.d.ts +6 -5
- package/definitions/group.js +8 -16
- package/definitions/group.js.map +1 -0
- package/definitions/model.d.ts +6 -5
- package/definitions/model.js +30 -16
- package/definitions/model.js.map +1 -0
- package/definitions/system.d.ts +6 -5
- package/definitions/system.js +8 -16
- package/definitions/system.js.map +1 -0
- package/definitions/table.d.ts +6 -6
- package/definitions/table.js +7 -6
- package/definitions/table.js.map +1 -0
- package/definitions/tableElasticsearch.d.ts +6 -6
- package/definitions/tableElasticsearch.js +7 -6
- package/definitions/tableElasticsearch.js.map +1 -0
- package/dynamoDb/index.d.ts +2 -1
- package/dynamoDb/index.js +10 -12
- package/dynamoDb/index.js.map +1 -0
- package/dynamoDb/storage/longText.d.ts +7 -4
- package/dynamoDb/storage/longText.js +75 -62
- package/dynamoDb/storage/longText.js.map +1 -0
- package/dynamoDb/storage/richText.d.ts +2 -8
- package/dynamoDb/storage/richText.js +49 -100
- package/dynamoDb/storage/richText.js.map +1 -0
- package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
- package/elasticsearch/createElasticsearchIndex.js +40 -0
- package/elasticsearch/createElasticsearchIndex.js.map +1 -0
- package/elasticsearch/deleteElasticsearchIndex.d.ts +8 -0
- package/elasticsearch/deleteElasticsearchIndex.js +38 -0
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -0
- package/elasticsearch/index.d.ts +1 -1
- package/elasticsearch/index.js +3 -6
- package/elasticsearch/index.js.map +1 -0
- package/elasticsearch/indexing/dateTimeIndexing.d.ts +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.js +21 -22
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -0
- package/elasticsearch/indexing/defaultFieldIndexing.d.ts +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.js +17 -10
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -0
- package/elasticsearch/indexing/index.js +5 -11
- package/elasticsearch/indexing/index.js.map +1 -0
- package/elasticsearch/indexing/jsonIndexing.d.ts +2 -0
- package/elasticsearch/indexing/jsonIndexing.js +28 -0
- package/elasticsearch/indexing/jsonIndexing.js.map +1 -0
- package/elasticsearch/indexing/longTextIndexing.d.ts +5 -1
- package/elasticsearch/indexing/longTextIndexing.js +16 -10
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -0
- package/elasticsearch/indexing/numberIndexing.d.ts +1 -1
- package/elasticsearch/indexing/numberIndexing.js +2 -9
- package/elasticsearch/indexing/numberIndexing.js.map +1 -0
- package/elasticsearch/indexing/objectIndexing.d.ts +10 -1
- package/elasticsearch/indexing/objectIndexing.js +37 -36
- package/elasticsearch/indexing/objectIndexing.js.map +1 -0
- package/elasticsearch/indexing/richTextIndexing.d.ts +1 -1
- package/elasticsearch/indexing/richTextIndexing.js +2 -5
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -0
- package/elasticsearch/indices/base.d.ts +2 -0
- package/elasticsearch/indices/base.js +13 -0
- package/elasticsearch/indices/base.js.map +1 -0
- package/elasticsearch/indices/index.d.ts +1 -0
- package/elasticsearch/indices/index.js +14 -0
- package/elasticsearch/indices/index.js.map +1 -0
- package/elasticsearch/indices/japanese.d.ts +2 -0
- package/elasticsearch/indices/japanese.js +14 -0
- package/elasticsearch/indices/japanese.js.map +1 -0
- package/elasticsearch/search/index.d.ts +2 -2
- package/elasticsearch/search/index.js +6 -9
- package/elasticsearch/search/index.js.map +1 -0
- package/elasticsearch/search/refSearch.d.ts +2 -3
- package/elasticsearch/search/refSearch.js +24 -17
- package/elasticsearch/search/refSearch.js.map +1 -0
- package/elasticsearch/search/searchableJson.d.ts +2 -0
- package/elasticsearch/search/searchableJson.js +60 -0
- package/elasticsearch/search/searchableJson.js.map +1 -0
- package/elasticsearch/search/timeSearch.d.ts +2 -3
- package/elasticsearch/search/timeSearch.js +18 -16
- package/elasticsearch/search/timeSearch.js.map +1 -0
- package/helpers/entryIndexHelpers.d.ts +3 -3
- package/helpers/entryIndexHelpers.js +59 -58
- package/helpers/entryIndexHelpers.js.map +1 -0
- package/helpers/fieldIdentifier.d.ts +6 -0
- package/helpers/fieldIdentifier.js +43 -0
- package/helpers/fieldIdentifier.js.map +1 -0
- package/helpers/index.d.ts +1 -1
- package/helpers/index.js +11 -13
- package/helpers/index.js.map +1 -0
- package/index.d.ts +2 -1
- package/index.js +132 -78
- package/index.js.map +1 -0
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +17 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +41 -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 +10 -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 +25 -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 +45 -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 +52 -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 +52 -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 +62 -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 +40 -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 +7 -0
- package/operations/entry/dataLoader/types.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +21 -38
- package/operations/entry/dataLoaders.js +59 -290
- package/operations/entry/dataLoaders.js.map +1 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +18 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +34 -0
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -0
- package/operations/entry/elasticsearch/body.d.ts +13 -0
- package/operations/entry/elasticsearch/body.js +142 -0
- package/operations/entry/elasticsearch/body.js.map +1 -0
- package/operations/entry/elasticsearch/fields.d.ts +10 -0
- package/operations/entry/elasticsearch/fields.js +315 -0
- package/operations/entry/elasticsearch/fields.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +60 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
- package/operations/entry/elasticsearch/filtering/exec.js +175 -0
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
- package/operations/entry/elasticsearch/filtering/index.js +18 -0
- package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/path.d.ts +16 -0
- package/operations/entry/elasticsearch/filtering/path.js +48 -0
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +30 -0
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.js +15 -0
- package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +69 -0
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +57 -0
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/populated.js +25 -0
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
- package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
- package/operations/entry/elasticsearch/filtering/values.js +24 -0
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +12 -0
- package/operations/entry/elasticsearch/fullTextSearch.js +91 -0
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.js +27 -0
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
- package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
- package/operations/entry/elasticsearch/initialQuery.js +106 -0
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
- package/operations/entry/elasticsearch/keyword.d.ts +2 -0
- package/operations/entry/elasticsearch/keyword.js +36 -0
- package/operations/entry/elasticsearch/keyword.js.map +1 -0
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.d.ts +9 -0
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.js +26 -0
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.js +18 -0
- package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
- package/operations/entry/elasticsearch/plugins/operator.js +39 -0
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.js +18 -0
- package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
- package/{helpers/searchPluginsList.js → operations/entry/elasticsearch/plugins/search.js} +9 -9
- package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.js +18 -0
- package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +2 -0
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +13 -0
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -0
- package/operations/entry/elasticsearch/sort.d.ts +12 -0
- package/operations/entry/elasticsearch/sort.js +89 -0
- package/operations/entry/elasticsearch/sort.js.map +1 -0
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
- package/operations/entry/elasticsearch/transformValueForSearch.js +32 -0
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
- package/operations/entry/elasticsearch/types.d.ts +41 -0
- package/operations/entry/elasticsearch/types.js +7 -0
- package/operations/entry/elasticsearch/types.js.map +1 -0
- package/operations/entry/index.d.ts +6 -8
- package/operations/entry/index.js +1422 -693
- package/operations/entry/index.js.map +1 -0
- package/operations/entry/keys.js +2 -9
- package/operations/entry/keys.js.map +1 -0
- package/operations/entry/recordType.d.ts +3 -0
- package/operations/entry/recordType.js +20 -0
- package/operations/entry/recordType.js.map +1 -0
- package/operations/entry/transformations/convertEntryKeys.d.ts +8 -0
- package/operations/entry/transformations/convertEntryKeys.js +38 -0
- package/operations/entry/transformations/convertEntryKeys.js.map +1 -0
- package/operations/entry/transformations/index.d.ts +29 -0
- package/operations/entry/transformations/index.js +127 -0
- package/operations/entry/transformations/index.js.map +1 -0
- package/operations/entry/transformations/modifyEntryValues.d.ts +58 -0
- package/operations/entry/transformations/modifyEntryValues.js +28 -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 +27 -0
- package/operations/entry/transformations/transformEntryKeys.js.map +1 -0
- package/operations/entry/transformations/transformEntryToIndex.d.ts +10 -0
- package/operations/entry/transformations/transformEntryToIndex.js +31 -0
- package/operations/entry/transformations/transformEntryToIndex.js.map +1 -0
- package/operations/group/index.d.ts +5 -5
- package/operations/group/index.js +40 -63
- package/operations/group/index.js.map +1 -0
- package/operations/model/index.d.ts +5 -5
- package/operations/model/index.js +56 -78
- package/operations/model/index.js.map +1 -0
- package/operations/system/index.d.ts +4 -4
- package/operations/system/index.js +20 -31
- package/operations/system/index.js.map +1 -0
- package/operations/system/indexes.d.ts +10 -0
- package/operations/system/indexes.js +41 -0
- package/operations/system/indexes.js.map +1 -0
- package/package.json +38 -40
- package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +69 -0
- package/plugins/CmsElasticsearchModelFieldPlugin.js +52 -0
- package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +9 -4
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +10 -13
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +23 -0
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +27 -0
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.d.ts +4 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +13 -0
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +32 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +40 -0
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +6 -4
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +10 -13
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +6 -4
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +10 -13
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -0
- package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +33 -0
- package/plugins/CmsEntryElasticsearchValuesModifier.js +50 -0
- package/plugins/CmsEntryElasticsearchValuesModifier.js.map +1 -0
- package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
- package/plugins/CmsEntryFilterPlugin.js +22 -0
- package/plugins/CmsEntryFilterPlugin.js.map +1 -0
- package/plugins/index.d.ts +8 -0
- package/plugins/index.js +95 -0
- package/plugins/index.js.map +1 -0
- package/tasks/createIndexTaskPlugin.d.ts +2 -0
- package/tasks/createIndexTaskPlugin.js +67 -0
- package/tasks/createIndexTaskPlugin.js.map +1 -0
- package/types.d.ts +30 -52
- package/types.js +5 -23
- package/types.js.map +1 -0
- package/values/NoValueContainer.d.ts +5 -0
- package/values/NoValueContainer.js +20 -0
- package/values/NoValueContainer.js.map +1 -0
- package/definitions/settings.d.ts +0 -8
- package/definitions/settings.js +0 -62
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -65
- package/helpers/createElasticsearchQueryBody.d.ts +0 -11
- package/helpers/createElasticsearchQueryBody.js +0 -375
- package/helpers/fields.d.ts +0 -77
- package/helpers/fields.js +0 -174
- package/helpers/operatorPluginsList.d.ts +0 -7
- package/helpers/operatorPluginsList.js +0 -30
- package/helpers/searchPluginsList.d.ts +0 -6
- 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/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/plugins/CmsEntryElasticsearchFieldPlugin.d.ts +0 -12
- package/plugins/CmsEntryElasticsearchFieldPlugin.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,28 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createModelsStorageOperations = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
var _configurations = _interopRequireDefault(require("../../configurations"));
|
|
13
|
-
|
|
14
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
-
|
|
16
|
-
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
17
|
-
|
|
9
|
+
var _configurations = require("../../configurations");
|
|
18
10
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
19
|
-
|
|
20
11
|
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
21
|
-
|
|
22
|
-
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; }
|
|
23
|
-
|
|
24
|
-
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; }
|
|
25
|
-
|
|
12
|
+
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
26
13
|
const createPartitionKey = params => {
|
|
27
14
|
const {
|
|
28
15
|
tenant,
|
|
@@ -30,66 +17,43 @@ const createPartitionKey = params => {
|
|
|
30
17
|
} = params;
|
|
31
18
|
return `T#${tenant}#L#${locale}#CMS#CM`;
|
|
32
19
|
};
|
|
33
|
-
|
|
34
20
|
const createSortKey = params => {
|
|
35
21
|
return params.modelId;
|
|
36
22
|
};
|
|
37
|
-
|
|
38
23
|
const createKeys = params => {
|
|
39
24
|
return {
|
|
40
25
|
PK: createPartitionKey(params),
|
|
41
26
|
SK: createSortKey(params)
|
|
42
27
|
};
|
|
43
28
|
};
|
|
44
|
-
|
|
45
29
|
const createType = () => {
|
|
46
30
|
return "cms.model";
|
|
47
31
|
};
|
|
48
|
-
|
|
49
32
|
const createModelsStorageOperations = params => {
|
|
50
33
|
const {
|
|
51
34
|
entity,
|
|
52
35
|
elasticsearch
|
|
53
36
|
} = params;
|
|
54
|
-
|
|
55
37
|
const create = async params => {
|
|
56
38
|
const {
|
|
57
39
|
model
|
|
58
40
|
} = params;
|
|
59
|
-
|
|
60
41
|
const {
|
|
61
42
|
index
|
|
62
|
-
} = _configurations.
|
|
43
|
+
} = _configurations.configurations.es({
|
|
63
44
|
model
|
|
64
45
|
});
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
const {
|
|
68
|
-
body: exists
|
|
69
|
-
} = await elasticsearch.indices.exists({
|
|
70
|
-
index
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
if (!exists) {
|
|
74
|
-
await elasticsearch.indices.create({
|
|
75
|
-
index
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
} catch (ex) {
|
|
79
|
-
throw new _error.default("Could not create Elasticsearch indice.", "ELASTICSEARCH_INDICE_CREATE_ERROR", {
|
|
80
|
-
error: ex,
|
|
81
|
-
index,
|
|
82
|
-
model
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
46
|
const keys = createKeys(model);
|
|
87
47
|
let error;
|
|
88
|
-
|
|
89
48
|
try {
|
|
90
|
-
await
|
|
91
|
-
|
|
92
|
-
|
|
49
|
+
await (0, _dbDynamodb.put)({
|
|
50
|
+
entity,
|
|
51
|
+
item: {
|
|
52
|
+
...(0, _cleanup.cleanupItem)(entity, model),
|
|
53
|
+
...keys,
|
|
54
|
+
TYPE: createType()
|
|
55
|
+
}
|
|
56
|
+
});
|
|
93
57
|
return model;
|
|
94
58
|
} catch (ex) {
|
|
95
59
|
error = ex;
|
|
@@ -97,79 +61,95 @@ const createModelsStorageOperations = params => {
|
|
|
97
61
|
/**
|
|
98
62
|
* In case of DynamoDB error we need to remove the index we created.
|
|
99
63
|
*/
|
|
100
|
-
|
|
101
|
-
|
|
102
64
|
try {
|
|
103
65
|
await elasticsearch.indices.delete({
|
|
104
|
-
index
|
|
66
|
+
index,
|
|
67
|
+
ignore_unavailable: true
|
|
105
68
|
});
|
|
106
69
|
} catch (ex) {
|
|
107
|
-
throw new _error.default(`Could not delete elasticsearch index "${index}" after model record failed to be created.`, "
|
|
70
|
+
throw new _error.default(`Could not delete elasticsearch index "${index}" after model record failed to be created.`, "DELETE_MODEL_INDEX_ERROR", {
|
|
108
71
|
dynamodbError: error,
|
|
109
72
|
elasticsearchError: ex
|
|
110
73
|
});
|
|
111
74
|
}
|
|
112
|
-
|
|
113
75
|
throw error;
|
|
114
76
|
};
|
|
115
|
-
|
|
116
77
|
const update = async params => {
|
|
117
78
|
const {
|
|
118
|
-
original,
|
|
119
79
|
model
|
|
120
80
|
} = params;
|
|
121
81
|
const keys = createKeys(model);
|
|
122
|
-
|
|
123
82
|
try {
|
|
124
|
-
await
|
|
125
|
-
|
|
126
|
-
|
|
83
|
+
await (0, _dbDynamodb.put)({
|
|
84
|
+
entity,
|
|
85
|
+
item: {
|
|
86
|
+
...(0, _cleanup.cleanupItem)(entity, model),
|
|
87
|
+
...keys,
|
|
88
|
+
TYPE: createType()
|
|
89
|
+
}
|
|
90
|
+
});
|
|
127
91
|
return model;
|
|
128
92
|
} catch (ex) {
|
|
129
|
-
throw new _error.default(ex.
|
|
93
|
+
throw new _error.default(ex.message || "Could not update model.", ex.code || "MODEL_UPDATE_ERROR", {
|
|
130
94
|
error: ex,
|
|
131
95
|
model,
|
|
132
|
-
original,
|
|
133
96
|
keys
|
|
134
97
|
});
|
|
135
98
|
}
|
|
136
99
|
};
|
|
137
|
-
|
|
138
100
|
const deleteModel = async params => {
|
|
139
101
|
const {
|
|
140
102
|
model
|
|
141
103
|
} = params;
|
|
142
104
|
const keys = createKeys(model);
|
|
143
|
-
|
|
105
|
+
const {
|
|
106
|
+
index
|
|
107
|
+
} = _configurations.configurations.es({
|
|
108
|
+
model
|
|
109
|
+
});
|
|
144
110
|
try {
|
|
145
|
-
await
|
|
146
|
-
|
|
111
|
+
await (0, _dbDynamodb.deleteItem)({
|
|
112
|
+
entity,
|
|
113
|
+
keys
|
|
114
|
+
});
|
|
147
115
|
} catch (ex) {
|
|
148
|
-
throw new _error.default(ex.
|
|
116
|
+
throw new _error.default(ex.message || "Could not delete model.", ex.code || "MODEL_DELETE_ERROR", {
|
|
149
117
|
error: ex,
|
|
150
118
|
model,
|
|
151
119
|
keys
|
|
152
120
|
});
|
|
153
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Always delete the model index after deleting the model.
|
|
124
|
+
*/
|
|
125
|
+
try {
|
|
126
|
+
await elasticsearch.indices.delete({
|
|
127
|
+
index,
|
|
128
|
+
ignore_unavailable: true
|
|
129
|
+
});
|
|
130
|
+
} catch (ex) {
|
|
131
|
+
throw new _error.default(`Could not delete elasticsearch index "${index}" after model record delete.`, "DELETE_MODEL_INDEX_ERROR", {
|
|
132
|
+
error: ex,
|
|
133
|
+
index,
|
|
134
|
+
model
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return model;
|
|
154
138
|
};
|
|
155
|
-
|
|
156
139
|
const get = async params => {
|
|
157
140
|
const keys = createKeys(params);
|
|
158
|
-
|
|
159
141
|
try {
|
|
160
|
-
|
|
142
|
+
return await (0, _dbDynamodb.getClean)({
|
|
161
143
|
entity,
|
|
162
144
|
keys
|
|
163
145
|
});
|
|
164
|
-
return (0, _cleanup.cleanupItem)(entity, item);
|
|
165
146
|
} catch (ex) {
|
|
166
|
-
throw new _error.default(ex.
|
|
147
|
+
throw new _error.default(ex.message || "Could not get model.", ex.code || "MODEL_GET_ERROR", {
|
|
167
148
|
error: ex,
|
|
168
149
|
keys
|
|
169
150
|
});
|
|
170
151
|
}
|
|
171
152
|
};
|
|
172
|
-
|
|
173
153
|
const list = async params => {
|
|
174
154
|
const {
|
|
175
155
|
where
|
|
@@ -181,18 +161,15 @@ const createModelsStorageOperations = params => {
|
|
|
181
161
|
gte: " "
|
|
182
162
|
}
|
|
183
163
|
};
|
|
184
|
-
|
|
185
164
|
try {
|
|
186
|
-
|
|
187
|
-
return (0, _cleanup.cleanupItems)(entity, items);
|
|
165
|
+
return await (0, _query.queryAllClean)(queryAllParams);
|
|
188
166
|
} catch (ex) {
|
|
189
|
-
throw new _error.default(ex.
|
|
167
|
+
throw new _error.default(ex.message || "Could not list models.", ex.code || "MODEL_LIST_ERROR", {
|
|
190
168
|
error: ex,
|
|
191
169
|
partitionKey: queryAllParams.partitionKey
|
|
192
170
|
});
|
|
193
171
|
}
|
|
194
172
|
};
|
|
195
|
-
|
|
196
173
|
return {
|
|
197
174
|
create,
|
|
198
175
|
update,
|
|
@@ -201,5 +178,6 @@ const createModelsStorageOperations = params => {
|
|
|
201
178
|
list
|
|
202
179
|
};
|
|
203
180
|
};
|
|
181
|
+
exports.createModelsStorageOperations = createModelsStorageOperations;
|
|
204
182
|
|
|
205
|
-
|
|
183
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_configurations","_cleanup","_query","_dbDynamodb","createPartitionKey","params","tenant","locale","createSortKey","modelId","createKeys","PK","SK","createType","createModelsStorageOperations","entity","elasticsearch","create","model","index","configurations","es","keys","error","put","item","cleanupItem","TYPE","ex","indices","delete","ignore_unavailable","WebinyError","dynamodbError","elasticsearchError","update","message","code","deleteModel","deleteItem","get","getClean","list","where","queryAllParams","partitionKey","options","gte","queryAllClean","exports"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModel,\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport type { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport { configurations } from \"~/configurations\";\nimport type { Client } from \"@elastic/elasticsearch\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport type { QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { queryAllClean } from \"@webiny/db-dynamodb/utils/query\";\nimport { deleteItem, getClean, put } from \"@webiny/db-dynamodb\";\n\ninterface PartitionKeysParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant, locale } = params;\n return `T#${tenant}#L#${locale}#CMS#CM`;\n};\n\ninterface SortKeyParams {\n modelId: string;\n}\n\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\n\nconst createKeys = (params: PartitionKeysParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey(params)\n };\n};\n\nconst createType = (): string => {\n return \"cms.model\";\n};\n\nexport interface CreateModelsStorageOperationsParams {\n entity: Entity<any>;\n elasticsearch: Client;\n}\n\nexport const createModelsStorageOperations = (\n params: CreateModelsStorageOperationsParams\n): CmsModelStorageOperations => {\n const { entity, elasticsearch } = params;\n\n const create = async (params: CmsModelStorageOperationsCreateParams) => {\n const { model } = params;\n\n const { index } = configurations.es({\n model\n });\n\n const keys = createKeys(model);\n\n let error;\n try {\n await put({\n entity,\n item: {\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n }\n });\n return model;\n } catch (ex) {\n error = ex;\n }\n /**\n * In case of DynamoDB error we need to remove the index we created.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record failed to be created.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n dynamodbError: error,\n elasticsearchError: ex\n }\n );\n }\n throw error;\n };\n\n const update = async (params: CmsModelStorageOperationsUpdateParams) => {\n const { model } = params;\n\n const keys = createKeys(model);\n\n try {\n await put({\n entity,\n item: {\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n }\n });\n return model;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update model.\",\n ex.code || \"MODEL_UPDATE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n };\n\n const deleteModel = async (params: CmsModelStorageOperationsDeleteParams) => {\n const { model } = params;\n const keys = createKeys(model);\n\n const { index } = configurations.es({\n model\n });\n\n try {\n await deleteItem({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete model.\",\n ex.code || \"MODEL_DELETE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n /**\n * Always delete the model index after deleting the model.\n */\n try {\n await elasticsearch.indices.delete({\n index,\n ignore_unavailable: true\n });\n } catch (ex) {\n throw new WebinyError(\n `Could not delete elasticsearch index \"${index}\" after model record delete.`,\n \"DELETE_MODEL_INDEX_ERROR\",\n {\n error: ex,\n index,\n model\n }\n );\n }\n\n return model;\n };\n\n const get = async (params: CmsModelStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n return await getClean<CmsModel>({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get model.\",\n ex.code || \"MODEL_GET_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n const list = async (params: CmsModelStorageOperationsListParams) => {\n const { where } = params;\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey(where),\n options: {\n gte: \" \"\n }\n };\n try {\n return await queryAllClean<CmsModel>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list models.\",\n ex.code || \"MODEL_LIST_ERROR\",\n {\n error: ex,\n partitionKey: queryAllParams.partitionKey\n }\n );\n }\n };\n\n return {\n create,\n update,\n delete: deleteModel,\n get,\n list\n };\n};\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CmsSystemStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import { Entity } from "dynamodb
|
|
3
|
-
export interface
|
|
1
|
+
import type { CmsSystemStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import type { Entity } from "@webiny/db-dynamodb/toolbox";
|
|
3
|
+
export interface CreateSystemStorageOperationsParams {
|
|
4
4
|
entity: Entity<any>;
|
|
5
5
|
}
|
|
6
|
-
export declare const createSystemStorageOperations: (params:
|
|
6
|
+
export declare const createSystemStorageOperations: (params: CreateSystemStorageOperationsParams) => CmsSystemStorageOperations;
|
|
@@ -1,53 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createSystemStorageOperations = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
9
|
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
15
|
-
|
|
16
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
17
|
-
|
|
18
|
-
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; }
|
|
19
|
-
|
|
20
|
-
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; }
|
|
21
|
-
|
|
10
|
+
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
22
11
|
const createPartitionKey = ({
|
|
23
12
|
tenant
|
|
24
13
|
}) => {
|
|
25
14
|
return `T#${tenant.toLowerCase()}#SYSTEM`;
|
|
26
15
|
};
|
|
27
|
-
|
|
28
16
|
const createSortKey = () => {
|
|
29
17
|
return "CMS";
|
|
30
18
|
};
|
|
31
|
-
|
|
32
19
|
const createKeys = params => {
|
|
33
20
|
return {
|
|
34
21
|
PK: createPartitionKey(params),
|
|
35
22
|
SK: createSortKey()
|
|
36
23
|
};
|
|
37
24
|
};
|
|
38
|
-
|
|
39
25
|
const createSystemStorageOperations = params => {
|
|
40
26
|
const {
|
|
41
27
|
entity
|
|
42
28
|
} = params;
|
|
43
|
-
|
|
44
29
|
const create = async ({
|
|
45
30
|
system
|
|
46
31
|
}) => {
|
|
47
32
|
const keys = createKeys(system);
|
|
48
|
-
|
|
49
33
|
try {
|
|
50
|
-
await
|
|
34
|
+
await (0, _dbDynamodb.put)({
|
|
35
|
+
entity,
|
|
36
|
+
item: {
|
|
37
|
+
...system,
|
|
38
|
+
...keys
|
|
39
|
+
}
|
|
40
|
+
});
|
|
51
41
|
return system;
|
|
52
42
|
} catch (ex) {
|
|
53
43
|
throw new _error.default(ex.message || "Could not create system.", ex.code || "CREATE_SYSTEM_ERROR", {
|
|
@@ -57,36 +47,35 @@ const createSystemStorageOperations = params => {
|
|
|
57
47
|
});
|
|
58
48
|
}
|
|
59
49
|
};
|
|
60
|
-
|
|
61
50
|
const update = async params => {
|
|
62
51
|
const {
|
|
63
|
-
system
|
|
64
|
-
original
|
|
52
|
+
system
|
|
65
53
|
} = params;
|
|
66
54
|
const keys = createKeys(system);
|
|
67
|
-
|
|
68
55
|
try {
|
|
69
|
-
await
|
|
56
|
+
await (0, _dbDynamodb.put)({
|
|
57
|
+
entity,
|
|
58
|
+
item: {
|
|
59
|
+
...system,
|
|
60
|
+
...keys
|
|
61
|
+
}
|
|
62
|
+
});
|
|
70
63
|
return system;
|
|
71
64
|
} catch (ex) {
|
|
72
65
|
throw new _error.default(ex.message || "Could not update system.", ex.code || "UPDATE_SYSTEM_ERROR", {
|
|
73
66
|
error: ex,
|
|
74
67
|
system,
|
|
75
|
-
original,
|
|
76
68
|
keys
|
|
77
69
|
});
|
|
78
70
|
}
|
|
79
71
|
};
|
|
80
|
-
|
|
81
72
|
const get = async params => {
|
|
82
73
|
const keys = createKeys(params);
|
|
83
|
-
|
|
84
74
|
try {
|
|
85
|
-
|
|
75
|
+
return await (0, _get.getClean)({
|
|
86
76
|
entity,
|
|
87
77
|
keys
|
|
88
78
|
});
|
|
89
|
-
return (0, _cleanup.cleanupItem)(entity, system);
|
|
90
79
|
} catch (ex) {
|
|
91
80
|
throw new _error.default(ex.message || "Could not get system.", ex.code || "GET_SYSTEM_ERROR", {
|
|
92
81
|
error: ex,
|
|
@@ -94,12 +83,12 @@ const createSystemStorageOperations = params => {
|
|
|
94
83
|
});
|
|
95
84
|
}
|
|
96
85
|
};
|
|
97
|
-
|
|
98
86
|
return {
|
|
99
87
|
create,
|
|
100
88
|
update,
|
|
101
89
|
get
|
|
102
90
|
};
|
|
103
91
|
};
|
|
92
|
+
exports.createSystemStorageOperations = createSystemStorageOperations;
|
|
104
93
|
|
|
105
|
-
|
|
94
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_get","_dbDynamodb","createPartitionKey","tenant","toLowerCase","createSortKey","createKeys","params","PK","SK","createSystemStorageOperations","entity","create","system","keys","put","item","ex","WebinyError","message","code","error","update","get","getClean","exports"],"sources":["index.ts"],"sourcesContent":["import type {\n CmsSystem,\n CmsSystemStorageOperations,\n CmsSystemStorageOperationsCreateParams,\n CmsSystemStorageOperationsGetParams,\n CmsSystemStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport type { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { put } from \"@webiny/db-dynamodb\";\n\nexport interface CreateSystemStorageOperationsParams {\n entity: Entity<any>;\n}\n\ninterface PartitionKeyParams {\n tenant: string;\n}\nconst createPartitionKey = ({ tenant }: PartitionKeyParams): string => {\n return `T#${tenant.toLowerCase()}#SYSTEM`;\n};\nconst createSortKey = (): string => {\n return \"CMS\";\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey()\n };\n};\n\nexport const createSystemStorageOperations = (\n params: CreateSystemStorageOperationsParams\n): CmsSystemStorageOperations => {\n const { entity } = params;\n\n const create = async ({ system }: CmsSystemStorageOperationsCreateParams) => {\n const keys = createKeys(system);\n try {\n await put({\n entity,\n item: {\n ...system,\n ...keys\n }\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create system.\",\n ex.code || \"CREATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSystemStorageOperationsUpdateParams) => {\n const { system } = params;\n\n const keys = createKeys(system);\n\n try {\n await put({\n entity,\n item: {\n ...system,\n ...keys\n }\n });\n return system;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update system.\",\n ex.code || \"UPDATE_SYSTEM_ERROR\",\n {\n error: ex,\n system,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSystemStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n return await getClean<CmsSystem>({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get system.\",\n ex.code || \"GET_SYSTEM_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n update,\n get\n };\n};\n"],"mappings":";;;;;;;AAQA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AASA,MAAMG,kBAAkB,GAAGA,CAAC;EAAEC;AAA2B,CAAC,KAAa;EACnE,OAAO,KAAKA,MAAM,CAACC,WAAW,CAAC,CAAC,SAAS;AAC7C,CAAC;AACD,MAAMC,aAAa,GAAGA,CAAA,KAAc;EAChC,OAAO,KAAK;AAChB,CAAC;AAMD,MAAMC,UAAU,GAAIC,MAA0B,IAAW;EACrD,OAAO;IACHC,EAAE,EAAEN,kBAAkB,CAACK,MAAM,CAAC;IAC9BE,EAAE,EAAEJ,aAAa,CAAC;EACtB,CAAC;AACL,CAAC;AAEM,MAAMK,6BAA6B,GACtCH,MAA2C,IACd;EAC7B,MAAM;IAAEI;EAAO,CAAC,GAAGJ,MAAM;EAEzB,MAAMK,MAAM,GAAG,MAAAA,CAAO;IAAEC;EAA+C,CAAC,KAAK;IACzE,MAAMC,IAAI,GAAGR,UAAU,CAACO,MAAM,CAAC;IAC/B,IAAI;MACA,MAAM,IAAAE,eAAG,EAAC;QACNJ,MAAM;QACNK,IAAI,EAAE;UACF,GAAGH,MAAM;UACT,GAAGC;QACP;MACJ,CAAC,CAAC;MACF,OAAOD,MAAM;IACjB,CAAC,CAAC,OAAOI,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,0BAA0B,EACxCF,EAAE,CAACG,IAAI,IAAI,qBAAqB,EAChC;QACIC,KAAK,EAAEJ,EAAE;QACTJ,MAAM;QACNC;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMQ,MAAM,GAAG,MAAOf,MAA8C,IAAK;IACrE,MAAM;MAAEM;IAAO,CAAC,GAAGN,MAAM;IAEzB,MAAMO,IAAI,GAAGR,UAAU,CAACO,MAAM,CAAC;IAE/B,IAAI;MACA,MAAM,IAAAE,eAAG,EAAC;QACNJ,MAAM;QACNK,IAAI,EAAE;UACF,GAAGH,MAAM;UACT,GAAGC;QACP;MACJ,CAAC,CAAC;MACF,OAAOD,MAAM;IACjB,CAAC,CAAC,OAAOI,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,0BAA0B,EACxCF,EAAE,CAACG,IAAI,IAAI,qBAAqB,EAChC;QACIC,KAAK,EAAEJ,EAAE;QACTJ,MAAM;QACNC;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMS,GAAG,GAAG,MAAOhB,MAA2C,IAAK;IAC/D,MAAMO,IAAI,GAAGR,UAAU,CAACC,MAAM,CAAC;IAE/B,IAAI;MACA,OAAO,MAAM,IAAAiB,aAAQ,EAAY;QAC7Bb,MAAM;QACNG;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOG,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,uBAAuB,EACrCF,EAAE,CAACG,IAAI,IAAI,kBAAkB,EAC7B;QACIC,KAAK,EAAEJ,EAAE;QACTH;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHF,MAAM;IACNU,MAAM;IACNC;EACJ,CAAC;AACL,CAAC;AAACE,OAAA,CAAAf,6BAAA,GAAAA,6BAAA","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CmsContext } from "../../types";
|
|
2
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
import type { Client } from "@elastic/elasticsearch";
|
|
4
|
+
interface Params {
|
|
5
|
+
context: CmsContext;
|
|
6
|
+
client: Client;
|
|
7
|
+
plugins: PluginsContainer;
|
|
8
|
+
}
|
|
9
|
+
export declare const createElasticsearchIndexesOnLocaleAfterCreate: (params: Params) => Promise<void>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createElasticsearchIndexesOnLocaleAfterCreate = void 0;
|
|
7
|
+
var _createElasticsearchIndex = require("../../elasticsearch/createElasticsearchIndex");
|
|
8
|
+
const createElasticsearchIndexesOnLocaleAfterCreate = async params => {
|
|
9
|
+
const {
|
|
10
|
+
context,
|
|
11
|
+
client,
|
|
12
|
+
plugins
|
|
13
|
+
} = params;
|
|
14
|
+
context.i18n.locales.onLocaleAfterCreate.subscribe(async ({
|
|
15
|
+
locale,
|
|
16
|
+
tenant
|
|
17
|
+
}) => {
|
|
18
|
+
/**
|
|
19
|
+
* Get all the code models and create the indexes for them.
|
|
20
|
+
*/
|
|
21
|
+
const models = await context.security.withoutAuthorization(async () => {
|
|
22
|
+
return (await context.cms.listModels()).map(model => {
|
|
23
|
+
return {
|
|
24
|
+
...model,
|
|
25
|
+
tenant,
|
|
26
|
+
locale: locale.code
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
for (const model of models) {
|
|
31
|
+
await (0, _createElasticsearchIndex.createElasticsearchIndex)({
|
|
32
|
+
client,
|
|
33
|
+
plugins,
|
|
34
|
+
model
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
exports.createElasticsearchIndexesOnLocaleAfterCreate = createElasticsearchIndexesOnLocaleAfterCreate;
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=indexes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_createElasticsearchIndex","require","createElasticsearchIndexesOnLocaleAfterCreate","params","context","client","plugins","i18n","locales","onLocaleAfterCreate","subscribe","locale","tenant","models","security","withoutAuthorization","cms","listModels","map","model","code","createElasticsearchIndex","exports"],"sources":["indexes.ts"],"sourcesContent":["import type { CmsContext } from \"~/types\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { Client } from \"@elastic/elasticsearch\";\nimport { createElasticsearchIndex } from \"~/elasticsearch/createElasticsearchIndex\";\n\ninterface Params {\n context: CmsContext;\n client: Client;\n plugins: PluginsContainer;\n}\n\nexport const createElasticsearchIndexesOnLocaleAfterCreate = async (params: Params) => {\n const { context, client, plugins } = params;\n\n context.i18n.locales.onLocaleAfterCreate.subscribe(async ({ locale, tenant }) => {\n /**\n * Get all the code models and create the indexes for them.\n */\n const models = await context.security.withoutAuthorization(async () => {\n return (await context.cms.listModels()).map(model => {\n return {\n ...model,\n tenant,\n locale: locale.code\n };\n });\n });\n\n for (const model of models) {\n await createElasticsearchIndex({\n client,\n plugins,\n model\n });\n }\n });\n};\n"],"mappings":";;;;;;AAGA,IAAAA,yBAAA,GAAAC,OAAA;AAQO,MAAMC,6CAA6C,GAAG,MAAOC,MAAc,IAAK;EACnF,MAAM;IAAEC,OAAO;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE3CC,OAAO,CAACG,IAAI,CAACC,OAAO,CAACC,mBAAmB,CAACC,SAAS,CAAC,OAAO;IAAEC,MAAM;IAAEC;EAAO,CAAC,KAAK;IAC7E;AACR;AACA;IACQ,MAAMC,MAAM,GAAG,MAAMT,OAAO,CAACU,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACnE,OAAO,CAAC,MAAMX,OAAO,CAACY,GAAG,CAACC,UAAU,CAAC,CAAC,EAAEC,GAAG,CAACC,KAAK,IAAI;QACjD,OAAO;UACH,GAAGA,KAAK;UACRP,MAAM;UACND,MAAM,EAAEA,MAAM,CAACS;QACnB,CAAC;MACL,CAAC,CAAC;IACN,CAAC,CAAC;IAEF,KAAK,MAAMD,KAAK,IAAIN,MAAM,EAAE;MACxB,MAAM,IAAAQ,kDAAwB,EAAC;QAC3BhB,MAAM;QACNC,OAAO;QACPa;MACJ,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC;AAACG,OAAA,CAAApB,6CAAA,GAAAA,6CAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb-es",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-unstable.06b2ede40f",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-headless-cms",
|
|
7
7
|
"storage-operations",
|
|
8
8
|
"dynamodb",
|
|
9
9
|
"elasticsearch",
|
|
10
|
-
"
|
|
10
|
+
"ddb-es",
|
|
11
|
+
"cms:ddb-es",
|
|
12
|
+
"opensearch",
|
|
13
|
+
"ddb-os",
|
|
14
|
+
"cms:ddb-os"
|
|
11
15
|
],
|
|
12
16
|
"repository": {
|
|
13
17
|
"type": "git",
|
|
@@ -22,52 +26,46 @@
|
|
|
22
26
|
],
|
|
23
27
|
"license": "MIT",
|
|
24
28
|
"dependencies": {
|
|
25
|
-
"@
|
|
26
|
-
"@webiny/api-
|
|
27
|
-
"@webiny/api-
|
|
28
|
-
"@webiny/
|
|
29
|
-
"@webiny/
|
|
30
|
-
"@webiny/
|
|
31
|
-
"@webiny/
|
|
32
|
-
"@webiny/handler-db": "0.0.0-
|
|
33
|
-
"@webiny/plugins": "0.0.0-
|
|
34
|
-
"@webiny/utils": "0.0.0-
|
|
35
|
-
"dataloader": "2.
|
|
36
|
-
"
|
|
37
|
-
"jsonpack": "1.1.5",
|
|
38
|
-
"lodash.chunk": "4.2.0",
|
|
39
|
-
"lodash.clonedeep": "4.5.0",
|
|
40
|
-
"lodash.omit": "4.5.0"
|
|
29
|
+
"@webiny/api": "0.0.0-unstable.06b2ede40f",
|
|
30
|
+
"@webiny/api-elasticsearch": "0.0.0-unstable.06b2ede40f",
|
|
31
|
+
"@webiny/api-elasticsearch-tasks": "0.0.0-unstable.06b2ede40f",
|
|
32
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.06b2ede40f",
|
|
33
|
+
"@webiny/aws-sdk": "0.0.0-unstable.06b2ede40f",
|
|
34
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.06b2ede40f",
|
|
35
|
+
"@webiny/error": "0.0.0-unstable.06b2ede40f",
|
|
36
|
+
"@webiny/handler-db": "0.0.0-unstable.06b2ede40f",
|
|
37
|
+
"@webiny/plugins": "0.0.0-unstable.06b2ede40f",
|
|
38
|
+
"@webiny/utils": "0.0.0-unstable.06b2ede40f",
|
|
39
|
+
"dataloader": "2.2.3",
|
|
40
|
+
"lodash": "4.17.21"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@babel/cli": "^7.5.5",
|
|
44
|
-
"@babel/core": "^7.5.5",
|
|
45
|
-
"@babel/preset-env": "^7.5.5",
|
|
46
|
-
"@babel/preset-flow": "^7.0.0",
|
|
47
43
|
"@elastic/elasticsearch": "7.12.0",
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
50
|
-
"@webiny/api-
|
|
51
|
-
"@webiny/api-
|
|
52
|
-
"@webiny/
|
|
53
|
-
"@webiny/
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
44
|
+
"@types/jsonpack": "1.1.6",
|
|
45
|
+
"@webiny/api-dynamodb-to-elasticsearch": "0.0.0-unstable.06b2ede40f",
|
|
46
|
+
"@webiny/api-i18n": "0.0.0-unstable.06b2ede40f",
|
|
47
|
+
"@webiny/api-log": "0.0.0-unstable.06b2ede40f",
|
|
48
|
+
"@webiny/api-security": "0.0.0-unstable.06b2ede40f",
|
|
49
|
+
"@webiny/api-tenancy": "0.0.0-unstable.06b2ede40f",
|
|
50
|
+
"@webiny/api-wcp": "0.0.0-unstable.06b2ede40f",
|
|
51
|
+
"@webiny/handler": "0.0.0-unstable.06b2ede40f",
|
|
52
|
+
"@webiny/handler-aws": "0.0.0-unstable.06b2ede40f",
|
|
53
|
+
"@webiny/handler-graphql": "0.0.0-unstable.06b2ede40f",
|
|
54
|
+
"@webiny/project-utils": "0.0.0-unstable.06b2ede40f",
|
|
55
|
+
"@webiny/tasks": "0.0.0-unstable.06b2ede40f",
|
|
56
|
+
"jest": "29.7.0",
|
|
57
|
+
"jest-dynalite": "3.6.1",
|
|
58
|
+
"prettier": "2.8.8",
|
|
59
|
+
"rimraf": "6.0.1",
|
|
60
|
+
"typescript": "5.3.3"
|
|
63
61
|
},
|
|
64
62
|
"publishConfig": {
|
|
65
63
|
"access": "public",
|
|
66
64
|
"directory": "dist"
|
|
67
65
|
},
|
|
68
66
|
"scripts": {
|
|
69
|
-
"build": "
|
|
70
|
-
"watch": "
|
|
67
|
+
"build": "node ../cli/bin.js run build",
|
|
68
|
+
"watch": "node ../cli/bin.js run watch"
|
|
71
69
|
},
|
|
72
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "06b2ede40fc2212a70eeafd74afd50b56fb0ce82"
|
|
73
71
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import type { CmsModelFieldType } from "@webiny/api-headless-cms/types";
|
|
3
|
+
/**
|
|
4
|
+
* A plugin which allows you to map a custom GraphQL field to an Elasticsearch field.
|
|
5
|
+
*
|
|
6
|
+
* This is useful when you want to create a custom field in the CMS GraphQL Schema, and you want to map it to an Elasticsearch field.
|
|
7
|
+
*/
|
|
8
|
+
export interface CmsModelFieldPluginParams {
|
|
9
|
+
/**
|
|
10
|
+
* The type of the field.
|
|
11
|
+
* Can be something custom, like "my-field-type".
|
|
12
|
+
*/
|
|
13
|
+
fieldType: CmsModelFieldType;
|
|
14
|
+
/**
|
|
15
|
+
* The ID of the field on the GraphQL side
|
|
16
|
+
*/
|
|
17
|
+
fieldId: string;
|
|
18
|
+
/**
|
|
19
|
+
* The path to the field in the Elasticsearch document.
|
|
20
|
+
*/
|
|
21
|
+
path: string;
|
|
22
|
+
/**
|
|
23
|
+
* If the field should be applied only to specific models.
|
|
24
|
+
* Or excluded from the specific models.
|
|
25
|
+
*
|
|
26
|
+
* The default is to apply to all models.
|
|
27
|
+
*/
|
|
28
|
+
models?: {
|
|
29
|
+
include?: string[];
|
|
30
|
+
exclude?: string[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The unmapped type of the field.
|
|
34
|
+
* In most cases, this will be undefined.
|
|
35
|
+
* When does it need to be set?
|
|
36
|
+
*
|
|
37
|
+
* When you are using a custom field type, other than the ones that are defined in the CMS.
|
|
38
|
+
* Let's say you create a field of type `my-field-type`, in which you want to store dates. By the default, it will, in most cases be set as string - if you did not specify the value transformer.
|
|
39
|
+
* If you want to be able to sort/filter properly by this field, you need to specify the unmapped type as "date".
|
|
40
|
+
*/
|
|
41
|
+
unmappedType?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Is this field searchable?
|
|
44
|
+
* If set to false, an error will be thrown when trying to search/filter by this field.
|
|
45
|
+
*/
|
|
46
|
+
searchable?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Is this field sortable?
|
|
49
|
+
* If set to false, an error will be thrown when trying to sort by this field.
|
|
50
|
+
*/
|
|
51
|
+
sortable?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* If the .keyword should be applied when doing the filtering or sorting on the field.
|
|
54
|
+
*/
|
|
55
|
+
keyword?: boolean;
|
|
56
|
+
}
|
|
57
|
+
export declare class CmsElasticsearchModelFieldPlugin extends Plugin {
|
|
58
|
+
static readonly type: string;
|
|
59
|
+
private readonly field;
|
|
60
|
+
get fieldType(): string;
|
|
61
|
+
get fieldId(): string;
|
|
62
|
+
get path(): string;
|
|
63
|
+
get unmappedType(): string | undefined;
|
|
64
|
+
get searchable(): boolean | undefined;
|
|
65
|
+
get sortable(): boolean | undefined;
|
|
66
|
+
get keyword(): boolean | undefined;
|
|
67
|
+
constructor(field: CmsModelFieldPluginParams);
|
|
68
|
+
canBeApplied(modelId: string): boolean;
|
|
69
|
+
}
|