@webiny/api-headless-cms-ddb-es 6.0.0-alpha.5 → 6.0.0-rc.0
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/configurations.d.ts +4 -5
- package/configurations.js +12 -24
- package/configurations.js.map +1 -1
- package/definitions/entry.d.ts +4 -6
- package/definitions/entry.js +5 -174
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +6 -7
- package/definitions/group.js +5 -58
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +6 -7
- package/definitions/model.js +5 -102
- package/definitions/model.js.map +1 -1
- package/definitions/types.d.ts +59 -0
- package/definitions/types.js +3 -0
- package/definitions/types.js.map +1 -0
- package/dynamoDb/index.d.ts +2 -2
- package/dynamoDb/index.js +5 -13
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/storage/longText.js +10 -18
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.js +10 -18
- package/dynamoDb/storage/richText.js.map +1 -1
- package/elasticsearch/createElasticsearchIndex.d.ts +1 -1
- package/elasticsearch/createElasticsearchIndex.js +7 -15
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.d.ts +1 -1
- package/elasticsearch/deleteElasticsearchIndex.js +3 -10
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
- package/elasticsearch/index.d.ts +1 -1
- package/elasticsearch/index.js +3 -11
- package/elasticsearch/index.js.map +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.d.ts +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.js +1 -8
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.d.ts +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.js +1 -8
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -1
- package/elasticsearch/indexing/index.d.ts +1 -1
- package/elasticsearch/indexing/index.js +8 -16
- package/elasticsearch/indexing/index.js.map +1 -1
- package/elasticsearch/indexing/jsonIndexing.d.ts +1 -1
- package/elasticsearch/indexing/jsonIndexing.js +1 -8
- package/elasticsearch/indexing/jsonIndexing.js.map +1 -1
- package/elasticsearch/indexing/longTextIndexing.d.ts +1 -1
- package/elasticsearch/indexing/longTextIndexing.js +1 -8
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
- package/elasticsearch/indexing/numberIndexing.d.ts +1 -1
- package/elasticsearch/indexing/numberIndexing.js +1 -8
- package/elasticsearch/indexing/numberIndexing.js.map +1 -1
- package/elasticsearch/indexing/objectIndexing.d.ts +1 -1
- package/elasticsearch/indexing/objectIndexing.js +6 -13
- package/elasticsearch/indexing/objectIndexing.js.map +1 -1
- package/elasticsearch/indexing/richTextIndexing.d.ts +1 -1
- package/elasticsearch/indexing/richTextIndexing.js +1 -8
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -1
- package/elasticsearch/indices/base.d.ts +1 -1
- package/elasticsearch/indices/base.js +4 -10
- package/elasticsearch/indices/base.js.map +1 -1
- package/elasticsearch/indices/index.d.ts +1 -1
- package/elasticsearch/indices/index.js +3 -11
- package/elasticsearch/indices/index.js.map +1 -1
- package/elasticsearch/search/index.d.ts +1 -1
- package/elasticsearch/search/index.js +4 -11
- package/elasticsearch/search/index.js.map +1 -1
- package/elasticsearch/search/refSearch.d.ts +1 -1
- package/elasticsearch/search/refSearch.js +3 -10
- package/elasticsearch/search/refSearch.js.map +1 -1
- package/elasticsearch/search/searchableJson.d.ts +1 -1
- package/elasticsearch/search/searchableJson.js +9 -16
- package/elasticsearch/search/searchableJson.js.map +1 -1
- package/elasticsearch/search/timeSearch.d.ts +1 -1
- package/elasticsearch/search/timeSearch.js +3 -10
- package/elasticsearch/search/timeSearch.js.map +1 -1
- package/helpers/entryIndexHelpers.d.ts +9 -9
- package/helpers/entryIndexHelpers.js +32 -26
- package/helpers/entryIndexHelpers.js.map +1 -1
- package/helpers/fieldIdentifier.d.ts +1 -1
- package/helpers/fieldIdentifier.js +2 -10
- package/helpers/fieldIdentifier.js.map +1 -1
- package/helpers/index.d.ts +2 -2
- package/helpers/index.js +2 -27
- package/helpers/index.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +98 -133
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +0 -2
- package/operations/entry/dataLoader/DataLoaderCache.js +2 -9
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/constants.js +1 -7
- package/operations/entry/dataLoader/constants.js.map +1 -1
- package/operations/entry/dataLoader/createBatchScheduleFn.js +4 -10
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
- package/operations/entry/dataLoader/getAllEntryRevisions.js +11 -24
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +18 -30
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +18 -30
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
- package/operations/entry/dataLoader/getRevisionById.js +23 -35
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/index.d.ts +3 -3
- package/operations/entry/dataLoader/index.js +10 -31
- package/operations/entry/dataLoader/index.js.map +1 -1
- package/operations/entry/dataLoader/types.d.ts +3 -4
- package/operations/entry/dataLoader/types.js +1 -5
- package/operations/entry/dataLoader/types.js.map +1 -1
- package/operations/entry/dataLoaders.d.ts +13 -13
- package/operations/entry/dataLoaders.js +15 -25
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +1 -8
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
- package/operations/entry/elasticsearch/body.d.ts +2 -2
- package/operations/entry/elasticsearch/body.js +21 -28
- package/operations/entry/elasticsearch/body.js.map +1 -1
- package/operations/entry/elasticsearch/fields.d.ts +2 -2
- package/operations/entry/elasticsearch/fields.js +110 -24
- package/operations/entry/elasticsearch/fields.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +2 -2
- package/operations/entry/elasticsearch/filtering/applyFiltering.js +9 -17
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/exec.d.ts +6 -5
- package/operations/entry/elasticsearch/filtering/exec.js +48 -45
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/index.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/index.js +1 -16
- package/operations/entry/elasticsearch/filtering/index.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/path.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/path.js +5 -15
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +6 -14
- package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/index.js +5 -12
- package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +7 -15
- package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +7 -15
- package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/populated.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/populated.js +1 -8
- package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/values.d.ts +1 -1
- package/operations/entry/elasticsearch/filtering/values.js +4 -12
- package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +2 -2
- package/operations/entry/elasticsearch/fullTextSearch.js +6 -12
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.js +1 -8
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
- package/operations/entry/elasticsearch/initialQuery.d.ts +2 -2
- package/operations/entry/elasticsearch/initialQuery.js +9 -27
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
- package/operations/entry/elasticsearch/keyword.d.ts +1 -1
- package/operations/entry/elasticsearch/keyword.js +4 -9
- package/operations/entry/elasticsearch/keyword.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +2 -2
- package/operations/entry/elasticsearch/plugins/bodyModifier.js +3 -10
- package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/operator.d.ts +1 -2
- package/operations/entry/elasticsearch/plugins/operator.js +4 -19
- package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +2 -2
- package/operations/entry/elasticsearch/plugins/queryModifier.js +3 -10
- package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/search.d.ts +1 -1
- package/operations/entry/elasticsearch/plugins/search.js +5 -13
- package/operations/entry/elasticsearch/plugins/search.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +2 -2
- package/operations/entry/elasticsearch/plugins/sortModifier.js +3 -10
- package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -1
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js +1 -8
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -1
- package/operations/entry/elasticsearch/sort.d.ts +3 -3
- package/operations/entry/elasticsearch/sort.js +51 -33
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +2 -2
- package/operations/entry/elasticsearch/transformValueForSearch.js +4 -9
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
- package/operations/entry/elasticsearch/types.d.ts +2 -2
- package/operations/entry/elasticsearch/types.js +1 -5
- package/operations/entry/elasticsearch/types.js.map +1 -1
- package/operations/entry/index.d.ts +5 -4
- package/operations/entry/index.js +333 -515
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.d.ts +31 -1
- package/operations/entry/keys.js +56 -19
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/recordType.js +3 -12
- package/operations/entry/recordType.js.map +1 -1
- package/operations/entry/transformations/convertEntryKeys.d.ts +6 -6
- package/operations/entry/transformations/convertEntryKeys.js +2 -10
- package/operations/entry/transformations/convertEntryKeys.js.map +1 -1
- package/operations/entry/transformations/index.d.ts +16 -16
- package/operations/entry/transformations/index.js +22 -30
- package/operations/entry/transformations/index.js.map +1 -1
- package/operations/entry/transformations/modifyEntryValues.d.ts +27 -34
- package/operations/entry/transformations/modifyEntryValues.js +1 -8
- package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
- package/operations/entry/transformations/transformEntryKeys.d.ts +8 -8
- package/operations/entry/transformations/transformEntryKeys.js +4 -11
- package/operations/entry/transformations/transformEntryKeys.js.map +1 -1
- package/operations/entry/transformations/transformEntryToIndex.d.ts +6 -6
- package/operations/entry/transformations/transformEntryToIndex.js +3 -10
- package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
- package/operations/group/index.d.ts +5 -4
- package/operations/group/index.js +39 -73
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +3 -3
- package/operations/model/index.js +38 -57
- package/operations/model/index.js.map +1 -1
- package/package.json +27 -32
- package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +1 -1
- package/plugins/CmsElasticsearchModelFieldPlugin.js +2 -8
- package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +1 -1
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +2 -2
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchIndexPlugin.js +2 -9
- package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +2 -2
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +3 -11
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +12 -12
- package/plugins/CmsEntryElasticsearchValuesModifier.js +4 -12
- package/plugins/CmsEntryElasticsearchValuesModifier.js.map +1 -1
- package/plugins/CmsEntryFilterPlugin.d.ts +3 -3
- package/plugins/CmsEntryFilterPlugin.js +2 -9
- package/plugins/CmsEntryFilterPlugin.js.map +1 -1
- package/plugins/index.d.ts +8 -8
- package/plugins/index.js +8 -93
- package/plugins/index.js.map +1 -1
- package/tasks/createIndexTaskPlugin.d.ts +2 -2
- package/tasks/createIndexTaskPlugin.js +36 -62
- package/tasks/createIndexTaskPlugin.js.map +1 -1
- package/types.d.ts +23 -26
- package/types.js +5 -8
- package/types.js.map +1 -1
- package/values/NoValueContainer.js +1 -8
- package/values/NoValueContainer.js.map +1 -1
- package/definitions/entryElasticsearch.d.ts +0 -9
- package/definitions/entryElasticsearch.js +0 -41
- package/definitions/entryElasticsearch.js.map +0 -1
- package/definitions/system.d.ts +0 -9
- package/definitions/system.js +0 -42
- package/definitions/system.js.map +0 -1
- package/definitions/table.d.ts +0 -8
- package/definitions/table.js +0 -25
- package/definitions/table.js.map +0 -1
- package/definitions/tableElasticsearch.d.ts +0 -8
- package/definitions/tableElasticsearch.js +0 -25
- package/definitions/tableElasticsearch.js.map +0 -1
- package/elasticsearch/indices/japanese.d.ts +0 -2
- package/elasticsearch/indices/japanese.js +0 -14
- package/elasticsearch/indices/japanese.js.map +0 -1
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.d.ts +0 -9
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.js +0 -26
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.js.map +0 -1
- package/operations/system/index.d.ts +0 -6
- package/operations/system/index.js +0 -94
- package/operations/system/index.js.map +0 -1
- package/operations/system/indexes.d.ts +0 -10
- package/operations/system/indexes.js +0 -41
- package/operations/system/indexes.js.map +0 -1
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.transformEntryToIndex = void 0;
|
|
7
|
-
var _helpers = require("../../../helpers");
|
|
8
|
-
const transformEntryToIndex = params => {
|
|
1
|
+
import { prepareEntryToIndex } from "../../../helpers/index.js";
|
|
2
|
+
export const transformEntryToIndex = params => {
|
|
9
3
|
const {
|
|
10
4
|
plugins,
|
|
11
5
|
model,
|
|
12
6
|
entry,
|
|
13
7
|
storageEntry
|
|
14
8
|
} = params;
|
|
15
|
-
const result =
|
|
9
|
+
const result = prepareEntryToIndex({
|
|
16
10
|
plugins,
|
|
17
11
|
model,
|
|
18
12
|
entry: structuredClone(entry),
|
|
@@ -26,6 +20,5 @@ const transformEntryToIndex = params => {
|
|
|
26
20
|
delete result["latest"];
|
|
27
21
|
return result;
|
|
28
22
|
};
|
|
29
|
-
exports.transformEntryToIndex = transformEntryToIndex;
|
|
30
23
|
|
|
31
24
|
//# sourceMappingURL=transformEntryToIndex.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["prepareEntryToIndex","transformEntryToIndex","params","plugins","model","entry","storageEntry","result","structuredClone"],"sources":["transformEntryToIndex.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { prepareEntryToIndex } from \"~/helpers/index.js\";\n\ninterface TransformEntryToIndexParams<T extends CmsEntryValues = CmsEntryValues> {\n plugins: PluginsContainer;\n model: StorageOperationsCmsModel<T>;\n entry: CmsEntry<T>;\n storageEntry: CmsStorageEntry<T>;\n}\n\nexport const transformEntryToIndex = <T extends CmsEntryValues = CmsEntryValues>(\n params: TransformEntryToIndexParams<T>\n) => {\n const { plugins, model, entry, storageEntry } = params;\n const result = prepareEntryToIndex<T>({\n plugins,\n model,\n entry: structuredClone(entry),\n storageEntry: structuredClone(storageEntry)\n });\n\n delete result[\"PK\"];\n delete result[\"SK\"];\n delete result[\"GSI1_PK\"];\n delete result[\"GSI1_SK\"];\n delete result[\"published\"];\n delete result[\"latest\"];\n\n return result;\n};\n"],"mappings":"AAOA,SAASA,mBAAmB;AAS5B,OAAO,MAAMC,qBAAqB,GAC9BC,MAAsC,IACrC;EACD,MAAM;IAAEC,OAAO;IAAEC,KAAK;IAAEC,KAAK;IAAEC;EAAa,CAAC,GAAGJ,MAAM;EACtD,MAAMK,MAAM,GAAGP,mBAAmB,CAAI;IAClCG,OAAO;IACPC,KAAK;IACLC,KAAK,EAAEG,eAAe,CAACH,KAAK,CAAC;IAC7BC,YAAY,EAAEE,eAAe,CAACF,YAAY;EAC9C,CAAC,CAAC;EAEF,OAAOC,MAAM,CAAC,IAAI,CAAC;EACnB,OAAOA,MAAM,CAAC,IAAI,CAAC;EACnB,OAAOA,MAAM,CAAC,SAAS,CAAC;EACxB,OAAOA,MAAM,CAAC,SAAS,CAAC;EACxB,OAAOA,MAAM,CAAC,WAAW,CAAC;EAC1B,OAAOA,MAAM,CAAC,QAAQ,CAAC;EAEvB,OAAOA,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { CmsGroupStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import type { Entity } from "@webiny/db-dynamodb/toolbox";
|
|
1
|
+
import type { CmsGroupStorageOperations } from "@webiny/api-headless-cms/types/index.js";
|
|
3
2
|
import type { PluginsContainer } from "@webiny/plugins";
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { IGroupEntity } from "../../definitions/types.js";
|
|
4
|
+
interface CreateGroupsStorageOperationsParams {
|
|
5
|
+
entity: IGroupEntity;
|
|
6
6
|
plugins: PluginsContainer;
|
|
7
7
|
}
|
|
8
8
|
export declare const createGroupsStorageOperations: (params: CreateGroupsStorageOperationsParams) => CmsGroupStorageOperations;
|
|
9
|
+
export {};
|
|
@@ -1,23 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createGroupsStorageOperations = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
10
|
-
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
11
|
-
var _filter = require("@webiny/db-dynamodb/utils/filter");
|
|
12
|
-
var _ValueFilterPlugin = require("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin");
|
|
13
|
-
var _sort = require("@webiny/db-dynamodb/utils/sort");
|
|
14
|
-
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
1
|
+
import WebinyError from "@webiny/error";
|
|
2
|
+
import { filterItems, sortItems, ValueFilterPlugin } from "@webiny/db-dynamodb";
|
|
15
3
|
const createPartitionKey = params => {
|
|
16
4
|
const {
|
|
17
|
-
tenant
|
|
18
|
-
locale
|
|
5
|
+
tenant
|
|
19
6
|
} = params;
|
|
20
|
-
return `T#${tenant}#
|
|
7
|
+
return `T#${tenant}#CMS#CMG`;
|
|
21
8
|
};
|
|
22
9
|
const createSortKeys = params => {
|
|
23
10
|
const {
|
|
@@ -28,20 +15,21 @@ const createSortKeys = params => {
|
|
|
28
15
|
const createKeys = params => {
|
|
29
16
|
return {
|
|
30
17
|
PK: createPartitionKey(params),
|
|
31
|
-
SK: createSortKeys(params)
|
|
18
|
+
SK: createSortKeys(params),
|
|
19
|
+
GSI_TENANT: params.tenant
|
|
32
20
|
};
|
|
33
21
|
};
|
|
34
22
|
const createType = () => {
|
|
35
23
|
return "cms.group";
|
|
36
24
|
};
|
|
37
|
-
const createGroupsStorageOperations = params => {
|
|
25
|
+
export const createGroupsStorageOperations = params => {
|
|
38
26
|
const {
|
|
39
27
|
entity,
|
|
40
28
|
plugins
|
|
41
29
|
} = params;
|
|
42
|
-
const filteringPlugins = plugins.byType(
|
|
30
|
+
const filteringPlugins = plugins.byType(ValueFilterPlugin.type);
|
|
43
31
|
if (filteringPlugins.length === 0) {
|
|
44
|
-
throw new
|
|
32
|
+
throw new WebinyError("DynamoDB filtering plugins not loaded.", "MISSING_DYNAMODB_FILTERING_PLUGINS");
|
|
45
33
|
}
|
|
46
34
|
const create = async params => {
|
|
47
35
|
const {
|
|
@@ -49,17 +37,13 @@ const createGroupsStorageOperations = params => {
|
|
|
49
37
|
} = params;
|
|
50
38
|
const keys = createKeys(group);
|
|
51
39
|
try {
|
|
52
|
-
await
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
TYPE: createType(),
|
|
57
|
-
...keys
|
|
58
|
-
}
|
|
40
|
+
await entity.put({
|
|
41
|
+
data: group,
|
|
42
|
+
TYPE: createType(),
|
|
43
|
+
...keys
|
|
59
44
|
});
|
|
60
|
-
return group;
|
|
61
45
|
} catch (ex) {
|
|
62
|
-
throw new
|
|
46
|
+
throw new WebinyError(ex.message || "Could not create group.", ex.code || "CREATE_GROUP_ERROR", {
|
|
63
47
|
error: ex,
|
|
64
48
|
group,
|
|
65
49
|
keys
|
|
@@ -72,17 +56,13 @@ const createGroupsStorageOperations = params => {
|
|
|
72
56
|
} = params;
|
|
73
57
|
const keys = createKeys(group);
|
|
74
58
|
try {
|
|
75
|
-
await
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
TYPE: createType(),
|
|
80
|
-
...keys
|
|
81
|
-
}
|
|
59
|
+
await entity.put({
|
|
60
|
+
data: group,
|
|
61
|
+
TYPE: createType(),
|
|
62
|
+
...keys
|
|
82
63
|
});
|
|
83
|
-
return group;
|
|
84
64
|
} catch (ex) {
|
|
85
|
-
throw new
|
|
65
|
+
throw new WebinyError(ex.message || "Could not update group.", ex.code || "UPDATE_GROUP_ERROR", {
|
|
86
66
|
error: ex,
|
|
87
67
|
group,
|
|
88
68
|
keys
|
|
@@ -95,13 +75,9 @@ const createGroupsStorageOperations = params => {
|
|
|
95
75
|
} = params;
|
|
96
76
|
const keys = createKeys(group);
|
|
97
77
|
try {
|
|
98
|
-
await (
|
|
99
|
-
entity,
|
|
100
|
-
keys
|
|
101
|
-
});
|
|
102
|
-
return group;
|
|
78
|
+
await entity.delete(keys);
|
|
103
79
|
} catch (ex) {
|
|
104
|
-
throw new
|
|
80
|
+
throw new WebinyError(ex.message || "Could not delete group.", ex.code || "DELETE_GROUP_ERROR", {
|
|
105
81
|
error: ex,
|
|
106
82
|
group,
|
|
107
83
|
keys
|
|
@@ -111,12 +87,10 @@ const createGroupsStorageOperations = params => {
|
|
|
111
87
|
const get = async params => {
|
|
112
88
|
const keys = createKeys(params);
|
|
113
89
|
try {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
keys
|
|
117
|
-
});
|
|
90
|
+
const result = await entity.get(keys);
|
|
91
|
+
return result ? result.data : null;
|
|
118
92
|
} catch (ex) {
|
|
119
|
-
throw new
|
|
93
|
+
throw new WebinyError(ex.message || "Could not get group.", ex.code || "GET_GROUP_ERROR", {
|
|
120
94
|
error: ex,
|
|
121
95
|
...params,
|
|
122
96
|
keys
|
|
@@ -126,44 +100,37 @@ const createGroupsStorageOperations = params => {
|
|
|
126
100
|
const list = async params => {
|
|
127
101
|
const {
|
|
128
102
|
sort,
|
|
129
|
-
where
|
|
103
|
+
where
|
|
130
104
|
} = params;
|
|
131
|
-
const queryAllParams = {
|
|
132
|
-
entity,
|
|
133
|
-
partitionKey: createPartitionKey(initialWhere),
|
|
134
|
-
options: {
|
|
135
|
-
gte: " "
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
105
|
let records = [];
|
|
139
106
|
try {
|
|
140
|
-
|
|
107
|
+
const ddbRecords = await entity.queryAll({
|
|
108
|
+
partitionKey: createPartitionKey(where),
|
|
109
|
+
options: {
|
|
110
|
+
gte: " "
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
records = ddbRecords.map(item => item.data);
|
|
141
114
|
} catch (ex) {
|
|
142
|
-
throw new
|
|
115
|
+
throw new WebinyError(ex.message || "Could not list groups.", ex.code || "LIST_GROUP_ERROR", {
|
|
143
116
|
error: ex,
|
|
144
117
|
...params,
|
|
145
118
|
sort,
|
|
146
|
-
where
|
|
119
|
+
where
|
|
147
120
|
});
|
|
148
121
|
}
|
|
149
|
-
const
|
|
150
|
-
...initialWhere
|
|
151
|
-
};
|
|
152
|
-
delete where["tenant"];
|
|
153
|
-
delete where["locale"];
|
|
154
|
-
const filteredItems = (0, _dbDynamodb.cleanupItems)(entity, (0, _filter.filterItems)({
|
|
122
|
+
const filteredItems = filterItems({
|
|
155
123
|
items: records,
|
|
156
124
|
where,
|
|
157
125
|
fields: [],
|
|
158
126
|
plugins
|
|
159
|
-
})
|
|
160
|
-
if (!sort || sort.length === 0
|
|
127
|
+
});
|
|
128
|
+
if (!sort || sort.length === 0) {
|
|
161
129
|
return filteredItems;
|
|
162
130
|
}
|
|
163
|
-
return
|
|
131
|
+
return sortItems({
|
|
164
132
|
items: filteredItems,
|
|
165
|
-
sort
|
|
166
|
-
fields: []
|
|
133
|
+
sort
|
|
167
134
|
});
|
|
168
135
|
};
|
|
169
136
|
return {
|
|
@@ -174,6 +141,5 @@ const createGroupsStorageOperations = params => {
|
|
|
174
141
|
list
|
|
175
142
|
};
|
|
176
143
|
};
|
|
177
|
-
exports.createGroupsStorageOperations = createGroupsStorageOperations;
|
|
178
144
|
|
|
179
145
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_get","_query","_filter","_ValueFilterPlugin","_sort","_dbDynamodb","createPartitionKey","params","tenant","locale","createSortKeys","id","createKeys","PK","SK","createType","createGroupsStorageOperations","entity","plugins","filteringPlugins","byType","ValueFilterPlugin","type","length","WebinyError","create","group","keys","put","item","TYPE","ex","message","code","error","update","deleteGroup","deleteItem","get","getClean","list","sort","where","initialWhere","queryAllParams","partitionKey","options","gte","records","queryAll","filteredItems","cleanupItems","filterItems","items","fields","sortItems","delete","exports"],"sources":["index.ts"],"sourcesContent":["import type {\n CmsGroup,\n CmsGroupStorageOperations,\n CmsGroupStorageOperationsCreateParams,\n CmsGroupStorageOperationsDeleteParams,\n CmsGroupStorageOperationsGetParams,\n CmsGroupStorageOperationsListParams,\n CmsGroupStorageOperationsUpdateParams\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 type { QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { queryAll } from \"@webiny/db-dynamodb/utils/query\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { deleteItem, put, cleanupItems } from \"@webiny/db-dynamodb\";\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\nconst createPartitionKey = (params: PartitionKeyParams): string => {\n const { tenant, locale } = params;\n return `T#${tenant}#L#${locale}#CMS#CMG`;\n};\n\ninterface SortKeyParams {\n id: string;\n}\nconst createSortKeys = (params: SortKeyParams): string => {\n const { id } = params;\n return id;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n}\nconst createKeys = (params: PartitionKeyParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKeys(params)\n };\n};\n\nconst createType = (): string => {\n return \"cms.group\";\n};\n\nexport interface CreateGroupsStorageOperationsParams {\n entity: Entity<any>;\n plugins: PluginsContainer;\n}\nexport const createGroupsStorageOperations = (\n params: CreateGroupsStorageOperationsParams\n): CmsGroupStorageOperations => {\n const { entity, plugins } = params;\n\n const filteringPlugins = plugins.byType<ValueFilterPlugin>(ValueFilterPlugin.type);\n if (filteringPlugins.length === 0) {\n throw new WebinyError(\n \"DynamoDB filtering plugins not loaded.\",\n \"MISSING_DYNAMODB_FILTERING_PLUGINS\"\n );\n }\n\n const create = async (params: CmsGroupStorageOperationsCreateParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await put({\n entity,\n item: {\n ...group,\n TYPE: createType(),\n ...keys\n }\n });\n return group;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create group.\",\n ex.code || \"CREATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const update = async (params: CmsGroupStorageOperationsUpdateParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await put({\n entity,\n item: {\n ...group,\n TYPE: createType(),\n ...keys\n }\n });\n return group;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update group.\",\n ex.code || \"UPDATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const deleteGroup = async (params: CmsGroupStorageOperationsDeleteParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await deleteItem({\n entity,\n keys\n });\n return group;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete group.\",\n ex.code || \"DELETE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const get = async (params: CmsGroupStorageOperationsGetParams) => {\n const keys = createKeys(params);\n try {\n return await getClean<CmsGroup>({\n entity,\n keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get group.\",\n ex.code || \"GET_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n keys\n }\n );\n }\n };\n const list = async (params: CmsGroupStorageOperationsListParams) => {\n const { sort, where: initialWhere } = params;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey(initialWhere),\n options: {\n gte: \" \"\n }\n };\n\n let records: CmsGroup[] = [];\n try {\n records = await queryAll(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list groups.\",\n ex.code || \"LIST_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n sort,\n where: initialWhere\n }\n );\n }\n\n const where: Partial<CmsGroupStorageOperationsListParams[\"where\"]> = {\n ...initialWhere\n };\n delete where[\"tenant\"];\n delete where[\"locale\"];\n\n const filteredItems = cleanupItems(\n entity,\n filterItems({\n items: records,\n where,\n fields: [],\n plugins\n })\n );\n\n if (!sort || sort.length === 0 || filteredItems.length === 0) {\n return filteredItems;\n }\n return sortItems({\n items: filteredItems,\n sort,\n fields: []\n });\n };\n\n return {\n create,\n update,\n delete: deleteGroup,\n get,\n list\n };\n};\n"],"mappings":";;;;;;;AAUA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAEA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAMA,MAAMO,kBAAkB,GAAIC,MAA0B,IAAa;EAC/D,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EACjC,OAAO,KAAKC,MAAM,MAAMC,MAAM,UAAU;AAC5C,CAAC;AAKD,MAAMC,cAAc,GAAIH,MAAqB,IAAa;EACtD,MAAM;IAAEI;EAAG,CAAC,GAAGJ,MAAM;EACrB,OAAOI,EAAE;AACb,CAAC;AAMD,MAAMC,UAAU,GAAIL,MAA0C,IAAW;EACrE,OAAO;IACHM,EAAE,EAAEP,kBAAkB,CAACC,MAAM,CAAC;IAC9BO,EAAE,EAAEJ,cAAc,CAACH,MAAM;EAC7B,CAAC;AACL,CAAC;AAED,MAAMQ,UAAU,GAAGA,CAAA,KAAc;EAC7B,OAAO,WAAW;AACtB,CAAC;AAMM,MAAMC,6BAA6B,GACtCT,MAA2C,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,YAAY,CAAC;MAC9CG,OAAO,EAAE;QACLC,GAAG,EAAE;MACT;IACJ,CAAC;IAED,IAAIC,OAAmB,GAAG,EAAE;IAC5B,IAAI;MACAA,OAAO,GAAG,MAAM,IAAAC,eAAQ,EAACL,cAAc,CAAC;IAC5C,CAAC,CAAC,OAAOb,EAAE,EAAE;MACT,MAAM,IAAIP,cAAW,CACjBO,EAAE,CAACC,OAAO,IAAI,wBAAwB,EACtCD,EAAE,CAACE,IAAI,IAAI,kBAAkB,EAC7B;QACIC,KAAK,EAAEH,EAAE;QACT,GAAGxB,MAAM;QACTkC,IAAI;QACJC,KAAK,EAAEC;MACX,CACJ,CAAC;IACL;IAEA,MAAMD,KAA4D,GAAG;MACjE,GAAGC;IACP,CAAC;IACD,OAAOD,KAAK,CAAC,QAAQ,CAAC;IACtB,OAAOA,KAAK,CAAC,QAAQ,CAAC;IAEtB,MAAMQ,aAAa,GAAG,IAAAC,wBAAY,EAC9BlC,MAAM,EACN,IAAAmC,mBAAW,EAAC;MACRC,KAAK,EAAEL,OAAO;MACdN,KAAK;MACLY,MAAM,EAAE,EAAE;MACVpC;IACJ,CAAC,CACL,CAAC;IAED,IAAI,CAACuB,IAAI,IAAIA,IAAI,CAAClB,MAAM,KAAK,CAAC,IAAI2B,aAAa,CAAC3B,MAAM,KAAK,CAAC,EAAE;MAC1D,OAAO2B,aAAa;IACxB;IACA,OAAO,IAAAK,eAAS,EAAC;MACbF,KAAK,EAAEH,aAAa;MACpBT,IAAI;MACJa,MAAM,EAAE;IACZ,CAAC,CAAC;EACN,CAAC;EAED,OAAO;IACH7B,MAAM;IACNU,MAAM;IACNqB,MAAM,EAAEpB,WAAW;IACnBE,GAAG;IACHE;EACJ,CAAC;AACL,CAAC;AAACiB,OAAA,CAAAzC,6BAAA,GAAAA,6BAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["WebinyError","filterItems","sortItems","ValueFilterPlugin","createPartitionKey","params","tenant","createSortKeys","id","createKeys","PK","SK","GSI_TENANT","createType","createGroupsStorageOperations","entity","plugins","filteringPlugins","byType","type","length","create","group","keys","put","data","TYPE","ex","message","code","error","update","deleteGroup","delete","get","result","list","sort","where","records","ddbRecords","queryAll","partitionKey","options","gte","map","item","filteredItems","items","fields"],"sources":["index.ts"],"sourcesContent":["import type {\n CmsGroup,\n CmsGroupStorageOperations,\n CmsGroupStorageOperationsCreateParams,\n CmsGroupStorageOperationsDeleteParams,\n CmsGroupStorageOperationsGetParams,\n CmsGroupStorageOperationsListParams,\n CmsGroupStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { filterItems, sortItems, ValueFilterPlugin } from \"@webiny/db-dynamodb\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { IGroupEntity } from \"~/definitions/types.js\";\n\ninterface PartitionKeyParams {\n tenant: string;\n}\nconst createPartitionKey = (params: PartitionKeyParams): string => {\n const { tenant } = params;\n return `T#${tenant}#CMS#CMG`;\n};\n\ninterface SortKeyParams {\n id: string;\n}\nconst createSortKeys = (params: SortKeyParams): string => {\n const { id } = params;\n return id;\n};\n\ninterface IDynamoDbTableKeys {\n PK: string;\n SK: string;\n GSI_TENANT: string;\n}\nconst createKeys = (params: PartitionKeyParams & SortKeyParams): IDynamoDbTableKeys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKeys(params),\n GSI_TENANT: params.tenant\n };\n};\n\nconst createType = (): string => {\n return \"cms.group\";\n};\n\ninterface CreateGroupsStorageOperationsParams {\n entity: IGroupEntity;\n plugins: PluginsContainer;\n}\nexport const createGroupsStorageOperations = (\n params: CreateGroupsStorageOperationsParams\n): CmsGroupStorageOperations => {\n const { entity, plugins } = params;\n\n const filteringPlugins = plugins.byType<ValueFilterPlugin>(ValueFilterPlugin.type);\n if (filteringPlugins.length === 0) {\n throw new WebinyError(\n \"DynamoDB filtering plugins not loaded.\",\n \"MISSING_DYNAMODB_FILTERING_PLUGINS\"\n );\n }\n\n const create = async (params: CmsGroupStorageOperationsCreateParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await entity.put({\n data: group,\n TYPE: createType(),\n ...keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create group.\",\n ex.code || \"CREATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const update = async (params: CmsGroupStorageOperationsUpdateParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await entity.put({\n data: group,\n TYPE: createType(),\n ...keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update group.\",\n ex.code || \"UPDATE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const deleteGroup = async (params: CmsGroupStorageOperationsDeleteParams) => {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete group.\",\n ex.code || \"DELETE_GROUP_ERROR\",\n {\n error: ex,\n group,\n keys\n }\n );\n }\n };\n const get = async (params: CmsGroupStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const result = await entity.get(keys);\n\n return result ? result.data : null;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get group.\",\n ex.code || \"GET_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n keys\n }\n );\n }\n };\n const list = async (params: CmsGroupStorageOperationsListParams) => {\n const { sort, where } = params;\n\n let records: CmsGroup[] = [];\n try {\n const ddbRecords = await entity.queryAll({\n partitionKey: createPartitionKey(where),\n options: {\n gte: \" \"\n }\n });\n records = ddbRecords.map(item => item.data);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list groups.\",\n ex.code || \"LIST_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n sort,\n where\n }\n );\n }\n\n const filteredItems = filterItems({\n items: records,\n where,\n fields: [],\n plugins\n });\n if (!sort || sort.length === 0) {\n return filteredItems;\n }\n\n return sortItems({\n items: filteredItems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,CAAC,CAAC;IACF,IAAI,CAACqB,IAAI,IAAIA,IAAI,CAACjB,MAAM,KAAK,CAAC,EAAE;MAC5B,OAAO2B,aAAa;IACxB;IAEA,OAAO7C,SAAS,CAAC;MACb8C,KAAK,EAAED,aAAa;MACpBV;IACJ,CAAC,CAAC;EACN,CAAC;EAED,OAAO;IACHhB,MAAM;IACNU,MAAM;IACNE,MAAM,EAAED,WAAW;IACnBE,GAAG;IACHE;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { CmsModelStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import type { Entity } from "@webiny/db-dynamodb/toolbox";
|
|
1
|
+
import type { CmsModelStorageOperations } from "@webiny/api-headless-cms/types/index.js";
|
|
3
2
|
import type { Client } from "@elastic/elasticsearch";
|
|
3
|
+
import type { IModelEntity } from "../../definitions/types.js";
|
|
4
4
|
export interface CreateModelsStorageOperationsParams {
|
|
5
|
-
entity:
|
|
5
|
+
entity: IModelEntity;
|
|
6
6
|
elasticsearch: Client;
|
|
7
7
|
}
|
|
8
8
|
export declare const createModelsStorageOperations: (params: CreateModelsStorageOperationsParams) => CmsModelStorageOperations;
|
|
@@ -1,35 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.createModelsStorageOperations = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _configurations = require("../../configurations");
|
|
10
|
-
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
11
|
-
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
12
|
-
var _dbDynamodb = require("@webiny/db-dynamodb");
|
|
1
|
+
import WebinyError from "@webiny/error";
|
|
2
|
+
import { configurations } from "../../configurations.js";
|
|
13
3
|
const createPartitionKey = params => {
|
|
14
4
|
const {
|
|
15
|
-
tenant
|
|
16
|
-
locale
|
|
5
|
+
tenant
|
|
17
6
|
} = params;
|
|
18
|
-
return `T#${tenant}#
|
|
7
|
+
return `T#${tenant}#CMS#CM`;
|
|
19
8
|
};
|
|
20
9
|
const createSortKey = params => {
|
|
21
10
|
return params.modelId;
|
|
22
11
|
};
|
|
23
12
|
const createKeys = params => {
|
|
13
|
+
if (!params.tenant) {
|
|
14
|
+
throw new Error("Missing tenant when creating model keys!");
|
|
15
|
+
}
|
|
24
16
|
return {
|
|
25
17
|
PK: createPartitionKey(params),
|
|
26
|
-
SK: createSortKey(params)
|
|
18
|
+
SK: createSortKey(params),
|
|
19
|
+
GSI_TENANT: params.tenant
|
|
27
20
|
};
|
|
28
21
|
};
|
|
29
22
|
const createType = () => {
|
|
30
23
|
return "cms.model";
|
|
31
24
|
};
|
|
32
|
-
const createModelsStorageOperations = params => {
|
|
25
|
+
export const createModelsStorageOperations = params => {
|
|
33
26
|
const {
|
|
34
27
|
entity,
|
|
35
28
|
elasticsearch
|
|
@@ -40,19 +33,16 @@ const createModelsStorageOperations = params => {
|
|
|
40
33
|
} = params;
|
|
41
34
|
const {
|
|
42
35
|
index
|
|
43
|
-
} =
|
|
36
|
+
} = configurations.es({
|
|
44
37
|
model
|
|
45
38
|
});
|
|
46
39
|
const keys = createKeys(model);
|
|
47
40
|
let error;
|
|
48
41
|
try {
|
|
49
|
-
await
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
...keys,
|
|
54
|
-
TYPE: createType()
|
|
55
|
-
}
|
|
42
|
+
await entity.put({
|
|
43
|
+
data: model,
|
|
44
|
+
...keys,
|
|
45
|
+
TYPE: createType()
|
|
56
46
|
});
|
|
57
47
|
return model;
|
|
58
48
|
} catch (ex) {
|
|
@@ -67,7 +57,7 @@ const createModelsStorageOperations = params => {
|
|
|
67
57
|
ignore_unavailable: true
|
|
68
58
|
});
|
|
69
59
|
} catch (ex) {
|
|
70
|
-
throw new
|
|
60
|
+
throw new WebinyError(`Could not delete elasticsearch index "${index}" after model record failed to be created.`, "DELETE_MODEL_INDEX_ERROR", {
|
|
71
61
|
dynamodbError: error,
|
|
72
62
|
elasticsearchError: ex
|
|
73
63
|
});
|
|
@@ -80,17 +70,14 @@ const createModelsStorageOperations = params => {
|
|
|
80
70
|
} = params;
|
|
81
71
|
const keys = createKeys(model);
|
|
82
72
|
try {
|
|
83
|
-
await
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
...keys,
|
|
88
|
-
TYPE: createType()
|
|
89
|
-
}
|
|
73
|
+
await entity.put({
|
|
74
|
+
data: model,
|
|
75
|
+
...keys,
|
|
76
|
+
TYPE: createType()
|
|
90
77
|
});
|
|
91
78
|
return model;
|
|
92
79
|
} catch (ex) {
|
|
93
|
-
throw new
|
|
80
|
+
throw new WebinyError(ex.message || "Could not update model.", ex.code || "MODEL_UPDATE_ERROR", {
|
|
94
81
|
error: ex,
|
|
95
82
|
model,
|
|
96
83
|
keys
|
|
@@ -104,16 +91,13 @@ const createModelsStorageOperations = params => {
|
|
|
104
91
|
const keys = createKeys(model);
|
|
105
92
|
const {
|
|
106
93
|
index
|
|
107
|
-
} =
|
|
94
|
+
} = configurations.es({
|
|
108
95
|
model
|
|
109
96
|
});
|
|
110
97
|
try {
|
|
111
|
-
await (
|
|
112
|
-
entity,
|
|
113
|
-
keys
|
|
114
|
-
});
|
|
98
|
+
await entity.delete(keys);
|
|
115
99
|
} catch (ex) {
|
|
116
|
-
throw new
|
|
100
|
+
throw new WebinyError(ex.message || "Could not delete model.", ex.code || "MODEL_DELETE_ERROR", {
|
|
117
101
|
error: ex,
|
|
118
102
|
model,
|
|
119
103
|
keys
|
|
@@ -128,7 +112,7 @@ const createModelsStorageOperations = params => {
|
|
|
128
112
|
ignore_unavailable: true
|
|
129
113
|
});
|
|
130
114
|
} catch (ex) {
|
|
131
|
-
throw new
|
|
115
|
+
throw new WebinyError(`Could not delete elasticsearch index "${index}" after model record delete.`, "DELETE_MODEL_INDEX_ERROR", {
|
|
132
116
|
error: ex,
|
|
133
117
|
index,
|
|
134
118
|
model
|
|
@@ -139,12 +123,10 @@ const createModelsStorageOperations = params => {
|
|
|
139
123
|
const get = async params => {
|
|
140
124
|
const keys = createKeys(params);
|
|
141
125
|
try {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
keys
|
|
145
|
-
});
|
|
126
|
+
const result = await entity.get(keys);
|
|
127
|
+
return result ? result.data : null;
|
|
146
128
|
} catch (ex) {
|
|
147
|
-
throw new
|
|
129
|
+
throw new WebinyError(ex.message || "Could not get model.", ex.code || "MODEL_GET_ERROR", {
|
|
148
130
|
error: ex,
|
|
149
131
|
keys
|
|
150
132
|
});
|
|
@@ -154,19 +136,19 @@ const createModelsStorageOperations = params => {
|
|
|
154
136
|
const {
|
|
155
137
|
where
|
|
156
138
|
} = params;
|
|
157
|
-
const
|
|
158
|
-
entity,
|
|
159
|
-
partitionKey: createPartitionKey(where),
|
|
160
|
-
options: {
|
|
161
|
-
gte: " "
|
|
162
|
-
}
|
|
163
|
-
};
|
|
139
|
+
const partitionKey = createPartitionKey(where);
|
|
164
140
|
try {
|
|
165
|
-
|
|
141
|
+
const result = await entity.queryAll({
|
|
142
|
+
partitionKey,
|
|
143
|
+
options: {
|
|
144
|
+
gte: " "
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
return result ? result.map(item => item.data) : [];
|
|
166
148
|
} catch (ex) {
|
|
167
|
-
throw new
|
|
149
|
+
throw new WebinyError(ex.message || "Could not list models.", ex.code || "MODEL_LIST_ERROR", {
|
|
168
150
|
error: ex,
|
|
169
|
-
partitionKey
|
|
151
|
+
partitionKey
|
|
170
152
|
});
|
|
171
153
|
}
|
|
172
154
|
};
|
|
@@ -178,6 +160,5 @@ const createModelsStorageOperations = params => {
|
|
|
178
160
|
list
|
|
179
161
|
};
|
|
180
162
|
};
|
|
181
|
-
exports.createModelsStorageOperations = createModelsStorageOperations;
|
|
182
163
|
|
|
183
164
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +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":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAWA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAOA,MAAMK,kBAAkB,GAAIC,MAA2B,IAAa;EAChE,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EACjC,OAAO,KAAKC,MAAM,MAAMC,MAAM,SAAS;AAC3C,CAAC;AAMD,MAAMC,aAAa,GAAIH,MAAqB,IAAa;EACrD,OAAOA,MAAM,CAACI,OAAO;AACzB,CAAC;AAOD,MAAMC,UAAU,GAAIL,MAA2C,IAAW;EACtE,OAAO;IACHM,EAAE,EAAEP,kBAAkB,CAACC,MAAM,CAAC;IAC9BO,EAAE,EAAEJ,aAAa,CAACH,MAAM;EAC5B,CAAC;AACL,CAAC;AAED,MAAMQ,UAAU,GAAGA,CAAA,KAAc;EAC7B,OAA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AED,MAAMsB,GAAG,GAAG,MAAOnC,MAA0C,IAAK;IAC9D,MAAMiB,IAAI,GAAGZ,UAAU,CAACL,MAAM,CAAC;IAE/B,IAAI;MACA,OAAO,MAAM,IAAAoC,oBAAQ,EAAW;QAC5B1B,MAAM;QACNO;MACJ,CAAC,CAAC;IACN,CAAC,CAAC,OAAOM,EAAE,EAAE;MACT,MAAM,IAAII,cAAW,CACjBJ,EAAE,CAACQ,OAAO,IAAI,sBAAsB,EACpCR,EAAE,CAACS,IAAI,IAAI,iBAAiB,EAC5B;QACId,KAAK,EAAEK,EAAE;QACTN;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMoB,IAAI,GAAG,MAAOrC,MAA2C,IAAK;IAChE,MAAM;MAAEsC;IAAM,CAAC,GAAGtC,MAAM;IACxB,MAAMuC,cAA8B,GAAG;MACnC7B,MAAM;MACN8B,YAAY,EAAEzC,kBAAkB,CAACuC,KAAK,CAAC;MACvCG,OAAO,EAAE;QACLC,GAAG,EAAE;MACT;IACJ,CAAC;IACD,IAAI;MACA,OAAO,MAAM,IAAAC,oBAAa,EAAWJ,cAAc,CAAC;IACxD,CAAC,CAAC,OAAOhB,EAAE,EAAE;MACT,MAAM,IAAII,cAAW,CACjBJ,EAAE,CAACQ,OAAO,IAAI,wBAAwB,EACtCR,EAAE,CAACS,IAAI,IAAI,kBAAkB,EAC7B;QACId,KAAK,EAAEK,EAAE;QACTiB,YAAY,EAAED,cAAc,CAACC;MACjC,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACH5B,MAAM;IACNkB,MAAM;IACNL,MAAM,EAAEQ,WAAW;IACnBE,GAAG;IACHE;EACJ,CAAC;AACL,CAAC;AAACO,OAAA,CAAAnC,6BAAA,GAAAA,6BAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["WebinyError","configurations","createPartitionKey","params","tenant","createSortKey","modelId","createKeys","Error","PK","SK","GSI_TENANT","createType","createModelsStorageOperations","entity","elasticsearch","create","model","index","es","keys","error","put","data","TYPE","ex","indices","delete","ignore_unavailable","dynamodbError","elasticsearchError","update","message","code","deleteModel","get","result","list","where","partitionKey","queryAll","options","gte","map","item"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport { configurations } from \"~/configurations.js\";\nimport type { Client } from \"@elastic/elasticsearch\";\nimport type { IModelEntity } from \"~/definitions/types.js\";\n\ninterface PartitionKeysParams {\n tenant: string;\n}\n\nconst createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant } = params;\n return `T#${tenant}#CMS#CM`;\n};\n\ninterface SortKeyParams {\n modelId: string;\n}\n\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface IDynamoDbTableKeys {\n PK: string;\n SK: string;\n GSI_TENANT: string;\n}\n\nconst createKeys = (params: PartitionKeysParams & SortKeyParams): IDynamoDbTableKeys => {\n if (!params.tenant) {\n throw new Error(\"Missing tenant when creating model keys!\");\n }\n return {\n PK: createPartitionKey(params),\n SK: createSortKey(params),\n GSI_TENANT: params.tenant\n };\n};\n\nconst createType = (): string => {\n return \"cms.model\";\n};\n\nexport interface CreateModelsStorageOperationsParams {\n entity: IModelEntity;\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 entity.put({\n data: model,\n ...keys,\n TYPE: createType()\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 entity.put({\n data: model,\n ...keys,\n TYPE: createType()\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 entity.delete(keys);\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 const result = await entity.get(keys);\n\n return result ? result.data : null;\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 partitionKey = createPartitionKey(where);\n try {\n const result = await entity.queryAll({\n partitionKey,\n options: {\n gte: \" \"\n }\n });\n return result ? result.map(item => item.data) : [];\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\n }\n );\n }\n };\n\n return {\n create,\n update,\n delete: deleteModel,\n get,\n list\n };\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AASvC,SAASC,cAAc;AAQvB,MAAMC,kBAAkB,GAAIC,MAA2B,IAAa;EAChE,MAAM;IAAEC;EAAO,CAAC,GAAGD,MAAM;EACzB,OAAO,KAAKC,MAAM,SAAS;AAC/B,CAAC;AAMD,MAAMC,aAAa,GAAIF,MAAqB,IAAa;EACrD,OAAOA,MAAM,CAACG,OAAO;AACzB,CAAC;AAQD,MAAMC,UAAU,GAAIJ,MAA2C,IAAyB;EACpF,IAAI,CAACA,MAAM,CAACC,MAAM,EAAE;IAChB,MAAM,IAAII,KAAK,CAAC,0CAA0C,CAAC;EAC/D;EACA,OAAO;IACHC,EAAE,EAAEP,kBAAkB,CAACC,MAAM,CAAC;IAC9BO,EAAE,EAAEL,aAAa,CAACF,MAAM,CAAC;IACzBQ,UAAU,EAAER,MAAM,CAACC;EACvB,CAAC;AACL,CAAC;AAED,MAAMQ,UAAU,GAAGA,CAAA,KAAc;EAC7B,OAAO,WAAW;AACtB,CAAC;AAOD,OAAO,MAAMC,6BAA6B,GACtCV,MAA2C,IACf;EAC5B,MAAM;IAAEW,MAAM;IAAEC;EAAc,CAAC,GAAGZ,MAAM;EAExC,MAAMa,MAAM,GAAG,MAAOb,MAA6C,IAAK;IACpE,MAAM;MAAEc;IAAM,CAAC,GAAGd,MAAM;IAExB,MAAM;MAAEe;IAAM,CAAC,GAAGjB,cAAc,CAACkB,EAAE,CAAC;MAChCF;IACJ,CAAC,CAAC;IAEF,MAAMG,IAAI,GAAGb,UAAU,CAACU,KAAK,CAAC;IAE9B,IAAII,KAAK;IACT,IAAI;MACA,MAAMP,MAAM,CAACQ,GAAG,CAAC;QACbC,IAAI,EAAEN,KAAK;QACX,GAAGG,IAAI;QACPI,IAAI,EA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;IAC9C,IAAI;MACA,MAAMF,MAAM,GAAG,MAAMtB,MAAM,CAAC0B,QAAQ,CAAC;QACjCD,YAAY;QACZE,OAAO,EAAE;UACLC,GAAG,EAAE;QACT;MACJ,CAAC,CAAC;MACF,OAAON,MAAM,GAAGA,MAAM,CAACO,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACrB,IAAI,CAAC,GAAG,EAAE;IACtD,CAAC,CAAC,OAAOE,EAAE,EAAE;MACT,MAAM,IAAIzB,WAAW,CACjByB,EAAE,CAACO,OAAO,IAAI,wBAAwB,EACtCP,EAAE,CAACQ,IAAI,IAAI,kBAAkB,EAC7B;QACIZ,KAAK,EAAEI,EAAE;QACTc;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHvB,MAAM;IACNe,MAAM;IACNJ,MAAM,EAAEO,WAAW;IACnBC,GAAG;IACHE;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb-es",
|
|
3
|
-
"version": "6.0.0-
|
|
3
|
+
"version": "6.0.0-rc.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"main": "index.js",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"@webiny/api-headless-cms",
|
|
@@ -26,46 +27,40 @@
|
|
|
26
27
|
],
|
|
27
28
|
"license": "MIT",
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@webiny/api": "6.0.0-
|
|
30
|
-
"@webiny/api-elasticsearch": "6.0.0-
|
|
31
|
-
"@webiny/api-elasticsearch-tasks": "6.0.0-
|
|
32
|
-
"@webiny/api-headless-cms": "6.0.0-
|
|
33
|
-
"@webiny/aws-sdk": "6.0.0-
|
|
34
|
-
"@webiny/db-dynamodb": "6.0.0-
|
|
35
|
-
"@webiny/error": "6.0.0-
|
|
36
|
-
"@webiny/handler-db": "6.0.0-
|
|
37
|
-
"@webiny/plugins": "6.0.0-
|
|
38
|
-
"@webiny/utils": "6.0.0-
|
|
30
|
+
"@webiny/api": "6.0.0-rc.0",
|
|
31
|
+
"@webiny/api-elasticsearch": "6.0.0-rc.0",
|
|
32
|
+
"@webiny/api-elasticsearch-tasks": "6.0.0-rc.0",
|
|
33
|
+
"@webiny/api-headless-cms": "6.0.0-rc.0",
|
|
34
|
+
"@webiny/aws-sdk": "6.0.0-rc.0",
|
|
35
|
+
"@webiny/db-dynamodb": "6.0.0-rc.0",
|
|
36
|
+
"@webiny/error": "6.0.0-rc.0",
|
|
37
|
+
"@webiny/handler-db": "6.0.0-rc.0",
|
|
38
|
+
"@webiny/plugins": "6.0.0-rc.0",
|
|
39
|
+
"@webiny/utils": "6.0.0-rc.0",
|
|
39
40
|
"dataloader": "2.2.3",
|
|
40
|
-
"lodash": "4.17.
|
|
41
|
+
"lodash": "4.17.23"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@elastic/elasticsearch": "7.12.0",
|
|
44
45
|
"@types/jsonpack": "1.1.6",
|
|
45
|
-
"@webiny/api-
|
|
46
|
-
"@webiny/api-
|
|
47
|
-
"@webiny/
|
|
48
|
-
"@webiny/
|
|
49
|
-
"@webiny/
|
|
50
|
-
"@webiny/
|
|
51
|
-
"@webiny/
|
|
52
|
-
"@webiny/
|
|
53
|
-
"@webiny/
|
|
54
|
-
"@webiny/project-utils": "6.0.0-alpha.5",
|
|
55
|
-
"@webiny/tasks": "6.0.0-alpha.5",
|
|
56
|
-
"jest": "29.7.0",
|
|
46
|
+
"@webiny/api-core": "6.0.0-rc.0",
|
|
47
|
+
"@webiny/api-dynamodb-to-elasticsearch": "6.0.0-rc.0",
|
|
48
|
+
"@webiny/build-tools": "6.0.0-rc.0",
|
|
49
|
+
"@webiny/handler": "6.0.0-rc.0",
|
|
50
|
+
"@webiny/handler-aws": "6.0.0-rc.0",
|
|
51
|
+
"@webiny/handler-graphql": "6.0.0-rc.0",
|
|
52
|
+
"@webiny/project-utils": "6.0.0-rc.0",
|
|
53
|
+
"@webiny/tasks": "6.0.0-rc.0",
|
|
54
|
+
"@webiny/wcp": "6.0.0-rc.0",
|
|
57
55
|
"jest-dynalite": "3.6.1",
|
|
58
|
-
"prettier": "
|
|
59
|
-
"rimraf": "6.
|
|
60
|
-
"typescript": "5.
|
|
56
|
+
"prettier": "3.6.2",
|
|
57
|
+
"rimraf": "6.1.3",
|
|
58
|
+
"typescript": "5.9.3",
|
|
59
|
+
"vitest": "4.0.18"
|
|
61
60
|
},
|
|
62
61
|
"publishConfig": {
|
|
63
62
|
"access": "public",
|
|
64
63
|
"directory": "dist"
|
|
65
64
|
},
|
|
66
|
-
"
|
|
67
|
-
"build": "node ../cli/bin.js run build",
|
|
68
|
-
"watch": "node ../cli/bin.js run watch"
|
|
69
|
-
},
|
|
70
|
-
"gitHead": "b7e120541b093e91f214904a9f13e4c2c4640978"
|
|
65
|
+
"gitHead": "0f2aa699f4642e550ab62c96fcd050e8d02345c9"
|
|
71
66
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import type { CmsModelFieldType } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import type { CmsModelFieldType } from "@webiny/api-headless-cms/types/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* A plugin which allows you to map a custom GraphQL field to an Elasticsearch field.
|
|
5
5
|
*
|