@webiny/api-headless-cms-ddb-es 6.0.0-alpha.0 → 6.0.0-alpha.2
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 +3 -3
- package/configurations.js.map +1 -1
- package/definitions/entry.d.ts +3 -2
- package/definitions/entry.js.map +1 -1
- package/definitions/entryElasticsearch.d.ts +3 -2
- package/definitions/entryElasticsearch.js.map +1 -1
- package/definitions/group.d.ts +3 -2
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +3 -2
- package/definitions/model.js.map +1 -1
- package/definitions/system.d.ts +3 -2
- package/definitions/system.js.map +1 -1
- package/definitions/table.d.ts +2 -2
- package/definitions/table.js.map +1 -1
- package/definitions/tableElasticsearch.d.ts +2 -2
- package/definitions/tableElasticsearch.js.map +1 -1
- package/elasticsearch/createElasticsearchIndex.d.ts +3 -3
- package/elasticsearch/createElasticsearchIndex.js.map +1 -1
- package/elasticsearch/deleteElasticsearchIndex.d.ts +2 -2
- package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.d.ts +1 -1
- package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.d.ts +1 -1
- package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -1
- package/elasticsearch/indexing/jsonIndexing.d.ts +1 -1
- package/elasticsearch/indexing/jsonIndexing.js.map +1 -1
- package/elasticsearch/indexing/longTextIndexing.d.ts +1 -1
- package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
- package/elasticsearch/indexing/numberIndexing.d.ts +1 -1
- package/elasticsearch/indexing/numberIndexing.js.map +1 -1
- package/elasticsearch/indexing/objectIndexing.d.ts +1 -1
- package/elasticsearch/indexing/objectIndexing.js.map +1 -1
- package/elasticsearch/indexing/richTextIndexing.d.ts +1 -1
- package/elasticsearch/indexing/richTextIndexing.js.map +1 -1
- package/elasticsearch/search/index.d.ts +1 -1
- package/elasticsearch/search/index.js +2 -1
- package/elasticsearch/search/index.js.map +1 -1
- package/elasticsearch/search/refSearch.js.map +1 -1
- 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.js.map +1 -1
- package/helpers/entryIndexHelpers.d.ts +3 -3
- package/helpers/entryIndexHelpers.js.map +1 -1
- package/helpers/fieldIdentifier.d.ts +1 -1
- package/helpers/fieldIdentifier.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +2 -2
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +2 -2
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +2 -2
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.d.ts +2 -2
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/index.d.ts +2 -2
- package/operations/entry/dataLoader/index.js.map +1 -1
- package/operations/entry/dataLoader/types.d.ts +1 -1
- package/operations/entry/dataLoader/types.js.map +1 -1
- package/operations/entry/dataLoaders.d.ts +3 -3
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.d.ts +1 -1
- package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
- package/operations/entry/elasticsearch/body.d.ts +3 -3
- package/operations/entry/elasticsearch/body.js.map +1 -1
- package/operations/entry/elasticsearch/fields.d.ts +2 -2
- 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 +1 -0
- package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/exec.d.ts +4 -4
- package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/path.d.ts +2 -1
- package/operations/entry/elasticsearch/filtering/path.js +4 -2
- package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
- package/operations/entry/elasticsearch/filtering/populated.d.ts +1 -1
- 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.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearch.d.ts +3 -3
- package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +1 -1
- package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
- package/operations/entry/elasticsearch/initialQuery.d.ts +2 -2
- package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
- package/operations/entry/elasticsearch/keyword.d.ts +1 -1
- package/operations/entry/elasticsearch/keyword.js.map +1 -1
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.d.ts +2 -2
- package/operations/entry/elasticsearch/logIgnoredEsResponseError.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +2 -2
- package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -1
- package/operations/entry/elasticsearch/plugins/operator.d.ts +2 -2
- 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.map +1 -1
- package/operations/entry/elasticsearch/plugins/search.d.ts +2 -2
- 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.map +1 -1
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.d.ts +1 -1
- package/operations/entry/elasticsearch/shouldIgnoreEsResponseError.js.map +1 -1
- package/operations/entry/elasticsearch/sort.d.ts +4 -4
- package/operations/entry/elasticsearch/sort.js +4 -2
- package/operations/entry/elasticsearch/sort.js.map +1 -1
- package/operations/entry/elasticsearch/transformValueForSearch.d.ts +2 -2
- package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
- package/operations/entry/elasticsearch/types.d.ts +3 -3
- package/operations/entry/elasticsearch/types.js.map +1 -1
- package/operations/entry/transformations/convertEntryKeys.d.ts +1 -1
- package/operations/entry/transformations/convertEntryKeys.js.map +1 -1
- package/operations/entry/transformations/index.d.ts +3 -3
- package/operations/entry/transformations/index.js.map +1 -1
- package/operations/entry/transformations/modifyEntryValues.d.ts +2 -2
- package/operations/entry/transformations/modifyEntryValues.js.map +1 -1
- package/operations/entry/transformations/transformEntryKeys.d.ts +1 -1
- package/operations/entry/transformations/transformEntryKeys.js.map +1 -1
- package/operations/entry/transformations/transformEntryToIndex.d.ts +2 -2
- package/operations/entry/transformations/transformEntryToIndex.js.map +1 -1
- package/operations/group/index.d.ts +3 -3
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +3 -3
- package/operations/model/index.js.map +1 -1
- package/operations/system/index.d.ts +2 -2
- package/operations/system/index.js.map +1 -1
- package/operations/system/indexes.d.ts +3 -3
- package/operations/system/indexes.js.map +1 -1
- package/package.json +23 -23
- package/plugins/CmsElasticsearchModelFieldPlugin.d.ts +1 -1
- package/plugins/CmsElasticsearchModelFieldPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.d.ts +3 -2
- package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +2 -2
- package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +2 -1
- package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.d.ts +3 -2
- package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.d.ts +3 -2
- package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
- package/plugins/CmsEntryElasticsearchValuesModifier.d.ts +1 -1
- package/plugins/CmsEntryElasticsearchValuesModifier.js.map +1 -1
- package/plugins/CmsEntryFilterPlugin.d.ts +3 -3
- package/plugins/CmsEntryFilterPlugin.js.map +1 -1
- package/tasks/createIndexTaskPlugin.d.ts +1 -1
- package/tasks/createIndexTaskPlugin.js.map +1 -1
- package/types.d.ts +6 -6
- package/types.js.map +1 -1
- package/values/NoValueContainer.d.ts +5 -0
- package/values/NoValueContainer.js +20 -0
- package/values/NoValueContainer.js.map +1 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CmsEntryElasticsearchSortModifierPlugin } from "../../../../plugins";
|
|
2
|
-
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
-
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types";
|
|
4
4
|
interface Params {
|
|
5
5
|
plugins: PluginsContainer;
|
|
6
6
|
model: CmsModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_plugins","require","createSortModifierPluginList","plugins","model","byType","CmsEntryElasticsearchSortModifierPlugin","type","filter","pl","modelId","exports"],"sources":["sortModifier.ts"],"sourcesContent":["import { CmsEntryElasticsearchSortModifierPlugin } from \"~/plugins\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n}\nexport const createSortModifierPluginList = ({ plugins, model }: Params) => {\n return plugins\n .byType<CmsEntryElasticsearchSortModifierPlugin>(\n CmsEntryElasticsearchSortModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAQO,MAAMC,4BAA4B,GAAGA,CAAC;EAAEC,OAAO;EAAEC;AAAc,CAAC,KAAK;EACxE,OAAOD,OAAO,CACTE,MAAM,CACHC,gDAAuC,CAACC,IAC5C,CAAC,CACAC,MAAM,CAACC,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAO,IAAID,EAAE,CAACC,OAAO,KAAKN,KAAK,CAACM,OAAO;EACtD,CAAC,CAAC;AACV,CAAC;AAACC,OAAA,CAAAT,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_plugins","require","createSortModifierPluginList","plugins","model","byType","CmsEntryElasticsearchSortModifierPlugin","type","filter","pl","modelId","exports"],"sources":["sortModifier.ts"],"sourcesContent":["import { CmsEntryElasticsearchSortModifierPlugin } from \"~/plugins\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\n\ninterface Params {\n plugins: PluginsContainer;\n model: CmsModel;\n}\nexport const createSortModifierPluginList = ({ plugins, model }: Params) => {\n return plugins\n .byType<CmsEntryElasticsearchSortModifierPlugin>(\n CmsEntryElasticsearchSortModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n};\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAQO,MAAMC,4BAA4B,GAAGA,CAAC;EAAEC,OAAO;EAAEC;AAAc,CAAC,KAAK;EACxE,OAAOD,OAAO,CACTE,MAAM,CACHC,gDAAuC,CAACC,IAC5C,CAAC,CACAC,MAAM,CAACC,EAAE,IAAI;IACV,OAAO,CAACA,EAAE,CAACC,OAAO,IAAID,EAAE,CAACC,OAAO,KAAKN,KAAK,CAACM,OAAO;EACtD,CAAC,CAAC;AACV,CAAC;AAACC,OAAA,CAAAT,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import WebinyError from "@webiny/error";
|
|
1
|
+
import type WebinyError from "@webiny/error";
|
|
2
2
|
export declare const shouldIgnoreEsResponseError: (error: WebinyError) => boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["IGNORED_ES_SEARCH_EXCEPTIONS","shouldIgnoreEsResponseError","error","includes","message","exports"],"sources":["shouldIgnoreEsResponseError.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nconst IGNORED_ES_SEARCH_EXCEPTIONS = [\n \"index_not_found_exception\",\n \"search_phase_execution_exception\"\n];\n\nexport const shouldIgnoreEsResponseError = (error: WebinyError) => {\n return IGNORED_ES_SEARCH_EXCEPTIONS.includes(error.message);\n};\n"],"mappings":";;;;;;AAEA,MAAMA,4BAA4B,GAAG,CACjC,2BAA2B,EAC3B,kCAAkC,CACrC;AAEM,MAAMC,2BAA2B,GAAIC,KAAkB,IAAK;EAC/D,OAAOF,4BAA4B,CAACG,QAAQ,CAACD,KAAK,CAACE,OAAO,CAAC;AAC/D,CAAC;AAACC,OAAA,CAAAJ,2BAAA,GAAAA,2BAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["IGNORED_ES_SEARCH_EXCEPTIONS","shouldIgnoreEsResponseError","error","includes","message","exports"],"sources":["shouldIgnoreEsResponseError.ts"],"sourcesContent":["import type WebinyError from \"@webiny/error\";\n\nconst IGNORED_ES_SEARCH_EXCEPTIONS = [\n \"index_not_found_exception\",\n \"search_phase_execution_exception\"\n];\n\nexport const shouldIgnoreEsResponseError = (error: WebinyError) => {\n return IGNORED_ES_SEARCH_EXCEPTIONS.includes(error.message);\n};\n"],"mappings":";;;;;;AAEA,MAAMA,4BAA4B,GAAG,CACjC,2BAA2B,EAC3B,kCAAkC,CACrC;AAEM,MAAMC,2BAA2B,GAAIC,KAAkB,IAAK;EAC/D,OAAOF,4BAA4B,CAACG,QAAQ,CAACD,KAAK,CAACE,OAAO,CAAC;AAC/D,CAAC;AAACC,OAAA,CAAAJ,2BAAA,GAAAA,2BAAA","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Sort as esSort } from "@webiny/api-elasticsearch/types";
|
|
2
|
-
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
-
import { CmsEntryListSort, CmsModel } from "@webiny/api-headless-cms/types";
|
|
4
|
-
import { ModelFields } from "./types";
|
|
1
|
+
import type { Sort as esSort } from "@webiny/api-elasticsearch/types";
|
|
2
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
import type { CmsEntryListSort, CmsModel } from "@webiny/api-headless-cms/types";
|
|
4
|
+
import type { ModelFields } from "./types";
|
|
5
5
|
interface Params {
|
|
6
6
|
plugins: PluginsContainer;
|
|
7
7
|
sort?: CmsEntryListSort;
|
|
@@ -8,6 +8,7 @@ var _apiElasticsearch = require("@webiny/api-elasticsearch");
|
|
|
8
8
|
var _keyword = require("./keyword");
|
|
9
9
|
var _search = require("./plugins/search");
|
|
10
10
|
var _path = require("./filtering/path");
|
|
11
|
+
var _NoValueContainer = require("../../../values/NoValueContainer.js");
|
|
11
12
|
const createElasticsearchSort = params => {
|
|
12
13
|
const {
|
|
13
14
|
sort,
|
|
@@ -45,8 +46,9 @@ const createElasticsearchSort = params => {
|
|
|
45
46
|
} = createFieldPath({
|
|
46
47
|
key: storageId,
|
|
47
48
|
field,
|
|
48
|
-
value:
|
|
49
|
-
keyword: false
|
|
49
|
+
value: _NoValueContainer.NoValueContainer.create(),
|
|
50
|
+
keyword: false,
|
|
51
|
+
originalValue: _NoValueContainer.NoValueContainer.create()
|
|
50
52
|
});
|
|
51
53
|
/**
|
|
52
54
|
* Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_apiElasticsearch","require","_keyword","_search","_path","createElasticsearchSort","params","sort","modelFields","plugins","length","order","searchPlugins","createSearchPluginList","createFieldPath","createFieldPathFactory","fieldIdToStorageIdIdMap","sortPlugins","Object","values","reduce","field","parents","fieldId","storageId","path","key","value","keyword","ElasticsearchFieldPlugin","unmappedType","hasKeyword","sortable","searchable","ALL","transformedSort","map","matched","match","filter","Boolean","createSort","fieldPlugins","exports"],"sources":["sort.ts"],"sourcesContent":["import { Sort as esSort } from \"@webiny/api-elasticsearch/types\";\nimport { createSort, ElasticsearchFieldPlugin } from \"@webiny/api-elasticsearch\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryListSort, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { ModelFields } from \"./types\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path\";\n\ninterface Params {\n plugins: PluginsContainer;\n sort?: CmsEntryListSort;\n modelFields: ModelFields;\n model: CmsModel;\n}\nexport const createElasticsearchSort = (params: Params): esSort => {\n const { sort, modelFields, plugins } = params;\n\n if (!sort || sort.length === 0) {\n return [\n {\n [\"id.keyword\"]: {\n order: \"asc\"\n }\n }\n ];\n }\n\n const searchPlugins = createSearchPluginList({\n plugins\n });\n\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n const fieldIdToStorageIdIdMap: Record<string, string> = {};\n\n const sortPlugins = Object.values(modelFields).reduce<Record<string, ElasticsearchFieldPlugin>>(\n (plugins, field) => {\n /**\n * We do not support sorting by nested fields.\n */\n if (field.parents.length > 0) {\n return plugins;\n }\n const { fieldId, storageId } = field.field;\n\n fieldIdToStorageIdIdMap[fieldId] = fieldId;\n\n const { path } = createFieldPath({\n key: storageId,\n field,\n value:
|
|
1
|
+
{"version":3,"names":["_apiElasticsearch","require","_keyword","_search","_path","_NoValueContainer","createElasticsearchSort","params","sort","modelFields","plugins","length","order","searchPlugins","createSearchPluginList","createFieldPath","createFieldPathFactory","fieldIdToStorageIdIdMap","sortPlugins","Object","values","reduce","field","parents","fieldId","storageId","path","key","value","NoValueContainer","create","keyword","originalValue","ElasticsearchFieldPlugin","unmappedType","hasKeyword","sortable","searchable","ALL","transformedSort","map","matched","match","filter","Boolean","createSort","fieldPlugins","exports"],"sources":["sort.ts"],"sourcesContent":["import type { Sort as esSort } from \"@webiny/api-elasticsearch/types\";\nimport { createSort, ElasticsearchFieldPlugin } from \"@webiny/api-elasticsearch\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { CmsEntryListSort, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport type { ModelFields } from \"./types\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path\";\nimport { NoValueContainer } from \"~/values/NoValueContainer.js\";\n\ninterface Params {\n plugins: PluginsContainer;\n sort?: CmsEntryListSort;\n modelFields: ModelFields;\n model: CmsModel;\n}\nexport const createElasticsearchSort = (params: Params): esSort => {\n const { sort, modelFields, plugins } = params;\n\n if (!sort || sort.length === 0) {\n return [\n {\n [\"id.keyword\"]: {\n order: \"asc\"\n }\n }\n ];\n }\n\n const searchPlugins = createSearchPluginList({\n plugins\n });\n\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n const fieldIdToStorageIdIdMap: Record<string, string> = {};\n\n const sortPlugins = Object.values(modelFields).reduce<Record<string, ElasticsearchFieldPlugin>>(\n (plugins, field) => {\n /**\n * We do not support sorting by nested fields.\n */\n if (field.parents.length > 0) {\n return plugins;\n }\n const { fieldId, storageId } = field.field;\n\n fieldIdToStorageIdIdMap[fieldId] = fieldId;\n\n const { path } = createFieldPath({\n key: storageId,\n field,\n value: NoValueContainer.create(),\n keyword: false,\n originalValue: NoValueContainer.create()\n });\n /**\n * Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.\n */\n plugins[fieldId] = new ElasticsearchFieldPlugin({\n unmappedType: field.unmappedType,\n keyword: hasKeyword(field),\n sortable: field.sortable,\n searchable: field.searchable,\n field: fieldId,\n path\n });\n return plugins;\n },\n {\n [\"*\"]: new ElasticsearchFieldPlugin({\n field: ElasticsearchFieldPlugin.ALL,\n keyword: false\n })\n }\n );\n\n const transformedSort = sort\n .map(value => {\n const matched = value.match(/^([a-zA-Z-0-9_]+)_(ASC|DESC)$/);\n if (!matched) {\n return null;\n }\n const [, fieldId, order] = matched;\n if (fieldIdToStorageIdIdMap[fieldId]) {\n return `${fieldIdToStorageIdIdMap[fieldId]}_${order}`;\n }\n\n return value;\n })\n .filter(Boolean) as string[];\n return createSort({\n fieldPlugins: sortPlugins,\n sort: transformedSort\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AAIA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAQO,MAAMK,uBAAuB,GAAIC,MAAc,IAAa;EAC/D,MAAM;IAAEC,IAAI;IAAEC,WAAW;IAAEC;EAAQ,CAAC,GAAGH,MAAM;EAE7C,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACG,MAAM,KAAK,CAAC,EAAE;IAC5B,OAAO,CACH;MACI,CAAC,YAAY,GAAG;QACZC,KAAK,EAAE;MACX;IACJ,CAAC,CACJ;EACL;EAEA,MAAMC,aAAa,GAAG,IAAAC,8BAAsB,EAAC;IACzCJ;EACJ,CAAC,CAAC;EAEF,MAAMK,eAAe,GAAG,IAAAC,4BAAsB,EAAC;IAC3CN,OAAO,EAAE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C5D,IAAI,CAACD,OAAO,EAAE;MACV,OAAO,IAAI;IACf;IACA,MAAM,GAAGjB,OAAO,EAAEZ,KAAK,CAAC,GAAG6B,OAAO;IAClC,IAAIxB,uBAAuB,CAACO,OAAO,CAAC,EAAE;MAClC,OAAO,GAAGP,uBAAuB,CAACO,OAAO,CAAC,IAAIZ,KAAK,EAAE;IACzD;IAEA,OAAOgB,KAAK;EAChB,CAAC,CAAC,CACDe,MAAM,CAACC,OAAO,CAAa;EAChC,OAAO,IAAAC,4BAAU,EAAC;IACdC,YAAY,EAAE5B,WAAW;IACzBV,IAAI,EAAE+B;EACV,CAAC,CAAC;AACN,CAAC;AAACQ,OAAA,CAAAzC,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* We use any for input and output because they really can be anything.
|
|
3
3
|
* Plugin, if exists, makes sure that response value is correct.
|
|
4
4
|
*/
|
|
5
|
-
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
6
|
-
import { ElasticsearchQuerySearchValuePlugins } from "./types";
|
|
5
|
+
import type { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
6
|
+
import type { ElasticsearchQuerySearchValuePlugins } from "./types";
|
|
7
7
|
interface Params {
|
|
8
8
|
plugins: ElasticsearchQuerySearchValuePlugins;
|
|
9
9
|
field: CmsModelField;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["transformValueForSearch","params","field","plugins","value","plugin","type","transform","exports"],"sources":["transformValueForSearch.ts"],"sourcesContent":["/**\n * We use any for input and output because they really can be anything.\n * Plugin, if exists, makes sure that response value is correct.\n */\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { ElasticsearchQuerySearchValuePlugins } from \"./types\";\n\ninterface Params {\n plugins: ElasticsearchQuerySearchValuePlugins;\n field: CmsModelField;\n value: any;\n}\n\n/**\n * Transformed value can be anything.\n */\nexport const transformValueForSearch = (params: Params): any => {\n const { field, plugins, value } = params;\n const plugin = plugins[field.type];\n if (!plugin) {\n return value;\n }\n return plugin.transform({ field, value });\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACO,MAAMA,uBAAuB,GAAIC,MAAc,IAAU;EAC5D,MAAM;IAAEC,KAAK;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGH,MAAM;EACxC,MAAMI,MAAM,GAAGF,OAAO,CAACD,KAAK,CAACI,IAAI,CAAC;EAClC,IAAI,CAACD,MAAM,EAAE;IACT,OAAOD,KAAK;EAChB;EACA,OAAOC,MAAM,CAACE,SAAS,CAAC;IAAEL,KAAK;IAAEE;EAAM,CAAC,CAAC;AAC7C,CAAC;AAACI,OAAA,CAAAR,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["transformValueForSearch","params","field","plugins","value","plugin","type","transform","exports"],"sources":["transformValueForSearch.ts"],"sourcesContent":["/**\n * We use any for input and output because they really can be anything.\n * Plugin, if exists, makes sure that response value is correct.\n */\nimport type { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport type { ElasticsearchQuerySearchValuePlugins } from \"./types\";\n\ninterface Params {\n plugins: ElasticsearchQuerySearchValuePlugins;\n field: CmsModelField;\n value: any;\n}\n\n/**\n * Transformed value can be anything.\n */\nexport const transformValueForSearch = (params: Params): any => {\n const { field, plugins, value } = params;\n const plugin = plugins[field.type];\n if (!plugin) {\n return value;\n }\n return plugin.transform({ field, value });\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACO,MAAMA,uBAAuB,GAAIC,MAAc,IAAU;EAC5D,MAAM;IAAEC,KAAK;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGH,MAAM;EACxC,MAAMI,MAAM,GAAGF,OAAO,CAACD,KAAK,CAACI,IAAI,CAAC;EAClC,IAAI,CAACD,MAAM,EAAE;IACT,OAAOD,KAAK;EAChB;EACA,OAAOC,MAAM,CAACE,SAAS,CAAC;IAAEL,KAAK;IAAEE;EAAM,CAAC,CAAC;AAC7C,CAAC;AAACI,OAAA,CAAAR,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from "../../../plugins";
|
|
2
|
-
import { ElasticsearchQueryBuilderOperatorPlugin } from "@webiny/api-elasticsearch";
|
|
3
|
-
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
1
|
+
import type { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from "../../../plugins";
|
|
2
|
+
import type { ElasticsearchQueryBuilderOperatorPlugin } from "@webiny/api-elasticsearch";
|
|
3
|
+
import type { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
4
4
|
/**
|
|
5
5
|
* ./fields
|
|
6
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from \"~/plugins\";\nimport { ElasticsearchQueryBuilderOperatorPlugin } from \"@webiny/api-elasticsearch\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\n/**\n * ./fields\n */\ntype ModelFieldPath = string | ((value: string) => string);\n\nexport type FieldType = \"text\" | \"date\" | \"datetime\" | \"time\" | \"number\" | \"boolean\" | string;\n\nexport interface ModelFieldParent {\n fieldId: string;\n storageId: string;\n type: FieldType;\n}\nexport interface ModelField {\n unmappedType?: string;\n keyword?: boolean;\n searchable: boolean;\n sortable: boolean;\n type: FieldType;\n systemField?: boolean;\n field: CmsModelField;\n path?: ModelFieldPath;\n fullTextSearch?: boolean;\n parents: ModelFieldParent[];\n}\n\nexport interface ModelFields {\n [fieldId: string]: ModelField;\n}\n\n/**\n * ./plugins/operator\n */\nexport interface ElasticsearchQueryBuilderOperatorPlugins {\n [key: string]: ElasticsearchQueryBuilderOperatorPlugin;\n}\n/**\n * ./plugins/search\n */\nexport interface ElasticsearchQuerySearchValuePlugins {\n [fieldType: string]: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { CmsEntryElasticsearchQueryBuilderValueSearchPlugin } from \"~/plugins\";\nimport type { ElasticsearchQueryBuilderOperatorPlugin } from \"@webiny/api-elasticsearch\";\nimport type { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\n/**\n * ./fields\n */\ntype ModelFieldPath = string | ((value: string) => string);\n\nexport type FieldType = \"text\" | \"date\" | \"datetime\" | \"time\" | \"number\" | \"boolean\" | string;\n\nexport interface ModelFieldParent {\n fieldId: string;\n storageId: string;\n type: FieldType;\n}\nexport interface ModelField {\n unmappedType?: string;\n keyword?: boolean;\n searchable: boolean;\n sortable: boolean;\n type: FieldType;\n systemField?: boolean;\n field: CmsModelField;\n path?: ModelFieldPath;\n fullTextSearch?: boolean;\n parents: ModelFieldParent[];\n}\n\nexport interface ModelFields {\n [fieldId: string]: ModelField;\n}\n\n/**\n * ./plugins/operator\n */\nexport interface ElasticsearchQueryBuilderOperatorPlugins {\n [key: string]: ElasticsearchQueryBuilderOperatorPlugin;\n}\n/**\n * ./plugins/search\n */\nexport interface ElasticsearchQuerySearchValuePlugins {\n [fieldType: string]: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CmsStorageEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types";
|
|
1
|
+
import type { CmsStorageEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types";
|
|
2
2
|
interface ConvertStorageEntryParams {
|
|
3
3
|
entry: CmsStorageEntry;
|
|
4
4
|
model: StorageOperationsCmsModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["convertEntryKeysToStorage","params","model","entry","values","convertValueKeyToStorage","fields","exports","convertEntryKeysFromStorage","convertValueKeyFromStorage"],"sources":["convertEntryKeys.ts"],"sourcesContent":["import { CmsStorageEntry, StorageOperationsCmsModel } from \"@webiny/api-headless-cms/types\";\n\ninterface ConvertStorageEntryParams {\n entry: CmsStorageEntry;\n model: StorageOperationsCmsModel;\n}\nexport const convertEntryKeysToStorage = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, entry } = params;\n\n const values = model.convertValueKeyToStorage({\n fields: model.fields,\n values: entry.values\n });\n return {\n ...entry,\n values\n };\n};\n\nexport const convertEntryKeysFromStorage = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, entry } = params;\n\n const values = model.convertValueKeyFromStorage({\n fields: model.fields,\n values: entry.values\n });\n return {\n ...entry,\n values\n };\n};\n"],"mappings":";;;;;;AAMO,MAAMA,yBAAyB,GAAIC,MAAiC,IAAsB;EAC7F,MAAM;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAE/B,MAAMG,MAAM,GAAGF,KAAK,CAACG,wBAAwB,CAAC;IAC1CC,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBF,MAAM,EAAED,KAAK,CAACC;EAClB,CAAC,CAAC;EACF,OAAO;IACH,GAAGD,KAAK;IACRC;EACJ,CAAC;AACL,CAAC;AAACG,OAAA,CAAAP,yBAAA,GAAAA,yBAAA;AAEK,MAAMQ,2BAA2B,GAAIP,MAAiC,IAAsB;EAC/F,MAAM;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAE/B,MAAMG,MAAM,GAAGF,KAAK,CAACO,0BAA0B,CAAC;IAC5CH,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBF,MAAM,EAAED,KAAK,CAACC;EAClB,CAAC,CAAC;EACF,OAAO;IACH,GAAGD,KAAK;IACRC;EACJ,CAAC;AACL,CAAC;AAACG,OAAA,CAAAC,2BAAA,GAAAA,2BAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["convertEntryKeysToStorage","params","model","entry","values","convertValueKeyToStorage","fields","exports","convertEntryKeysFromStorage","convertValueKeyFromStorage"],"sources":["convertEntryKeys.ts"],"sourcesContent":["import type { CmsStorageEntry, StorageOperationsCmsModel } from \"@webiny/api-headless-cms/types\";\n\ninterface ConvertStorageEntryParams {\n entry: CmsStorageEntry;\n model: StorageOperationsCmsModel;\n}\nexport const convertEntryKeysToStorage = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, entry } = params;\n\n const values = model.convertValueKeyToStorage({\n fields: model.fields,\n values: entry.values\n });\n return {\n ...entry,\n values\n };\n};\n\nexport const convertEntryKeysFromStorage = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, entry } = params;\n\n const values = model.convertValueKeyFromStorage({\n fields: model.fields,\n values: entry.values\n });\n return {\n ...entry,\n values\n };\n};\n"],"mappings":";;;;;;AAMO,MAAMA,yBAAyB,GAAIC,MAAiC,IAAsB;EAC7F,MAAM;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAE/B,MAAMG,MAAM,GAAGF,KAAK,CAACG,wBAAwB,CAAC;IAC1CC,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBF,MAAM,EAAED,KAAK,CAACC;EAClB,CAAC,CAAC;EACF,OAAO;IACH,GAAGD,KAAK;IACRC;EACJ,CAAC;AACL,CAAC;AAACG,OAAA,CAAAP,yBAAA,GAAAA,yBAAA;AAEK,MAAMQ,2BAA2B,GAAIP,MAAiC,IAAsB;EAC/F,MAAM;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAE/B,MAAMG,MAAM,GAAGF,KAAK,CAACO,0BAA0B,CAAC;IAC5CH,MAAM,EAAEJ,KAAK,CAACI,MAAM;IACpBF,MAAM,EAAED,KAAK,CAACC;EAClB,CAAC,CAAC;EACF,OAAO;IACH,GAAGD,KAAK;IACRC;EACJ,CAAC;AACL,CAAC;AAACG,OAAA,CAAAC,2BAAA,GAAAA,2BAAA","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PluginsContainer } from "@webiny/plugins";
|
|
2
|
-
import { CmsEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types";
|
|
3
|
-
import { CmsIndexEntry } from "../../../types";
|
|
1
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
2
|
+
import type { CmsEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types";
|
|
3
|
+
import type { CmsIndexEntry } from "../../../types";
|
|
4
4
|
interface BaseTransformerParams {
|
|
5
5
|
plugins: PluginsContainer;
|
|
6
6
|
model: StorageOperationsCmsModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_transformEntryKeys","require","_transformEntryToIndex","_plugins","_modifyEntryValues","_apiElasticsearch","_recordType","_error","_interopRequireDefault","createTransformer","params","plugins","model","entry","baseEntry","storageEntry","baseStorageEntry","transformedToIndex","initialTransformedEntryToIndex","undefined","transformedEntryKeys","transformedEntryToIndex","modifiedEntryValues","elasticsearchLatestEntry","elasticsearchPublishedEntry","modifierPlugins","byType","CmsEntryElasticsearchValuesModifier","type","filter","pl","canModify","modelId","modifyEntryValues","WebinyError","modifiedEntry","modifyEntryValuesCallable","modifiedStorageEntry","transformEntryKeys","transformToIndex","length","result","transformEntryToIndex","getElasticsearchLatestEntryData","compress","latest","TYPE","createLatestRecordType","__type","getElasticsearchPublishedEntryData","published","createPublishedRecordType","exports"],"sources":["index.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport {\n CmsEntry,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types\";\nimport { transformEntryKeys } from \"./transformEntryKeys\";\nimport { CmsIndexEntry } from \"~/types\";\nimport { transformEntryToIndex } from \"~/operations/entry/transformations/transformEntryToIndex\";\nimport { CmsEntryElasticsearchValuesModifier } from \"~/plugins\";\nimport { modifyEntryValues as modifyEntryValuesCallable } from \"~/operations/entry/transformations/modifyEntryValues\";\nimport { compress } from \"@webiny/api-elasticsearch\";\nimport { createLatestRecordType, createPublishedRecordType } from \"~/operations/entry/recordType\";\nimport WebinyError from \"@webiny/error\";\n\ninterface BaseTransformerParams {\n plugins: PluginsContainer;\n model: StorageOperationsCmsModel;\n}\n\ninterface EntryTransformerParams extends BaseTransformerParams {\n entry: CmsEntry;\n storageEntry: CmsEntry;\n transformedToIndex?: never;\n}\n\ninterface TransformedEntryTransformerParams extends BaseTransformerParams {\n entry?: never;\n storageEntry?: never;\n transformedToIndex: CmsIndexEntry;\n}\n\ninterface TransformedKeysEntry {\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\ninterface ModifiedEntryValues {\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\ninterface TransformerResult {\n transformEntryKeys: () => TransformedKeysEntry;\n transformToIndex: () => CmsIndexEntry;\n getElasticsearchLatestEntryData: () => Promise<Record<string, any>>;\n getElasticsearchPublishedEntryData: () => Promise<Record<string, any>>;\n}\n\nexport const createTransformer = (\n params: EntryTransformerParams | TransformedEntryTransformerParams\n): TransformerResult => {\n const {\n plugins,\n model,\n entry: baseEntry,\n storageEntry: baseStorageEntry,\n transformedToIndex: initialTransformedEntryToIndex = undefined\n } = params;\n\n let transformedEntryKeys: TransformedKeysEntry | undefined = undefined;\n let transformedEntryToIndex: CmsIndexEntry | undefined = initialTransformedEntryToIndex;\n let modifiedEntryValues: ModifiedEntryValues | undefined = undefined;\n let elasticsearchLatestEntry: any = undefined;\n let elasticsearchPublishedEntry: any = undefined;\n\n const modifierPlugins = plugins\n .byType<CmsEntryElasticsearchValuesModifier>(CmsEntryElasticsearchValuesModifier.type)\n .filter(pl => pl.canModify(model.modelId));\n\n const modifyEntryValues = () => {\n if (initialTransformedEntryToIndex || !baseEntry) {\n throw new WebinyError(\n `Should not call the \"modifyEntryValues\" when \"transformedToIndex\" is provided.`,\n \"METHOD_NOT_ALLOWED\",\n {\n entry: initialTransformedEntryToIndex\n }\n );\n }\n if (modifiedEntryValues) {\n return modifiedEntryValues;\n }\n const modifiedEntry = modifyEntryValuesCallable({\n plugins: modifierPlugins,\n model,\n entry: baseEntry\n });\n const modifiedStorageEntry = modifyEntryValuesCallable({\n plugins: modifierPlugins,\n model,\n entry: baseStorageEntry\n });\n\n return (modifiedEntryValues = transformEntryKeys({\n model,\n entry: modifiedEntry,\n storageEntry: modifiedStorageEntry\n }));\n };\n\n return {\n transformEntryKeys: function () {\n if (initialTransformedEntryToIndex || !baseEntry) {\n throw new WebinyError(\n `Should not call the \"modifyEntryValues\" when \"transformedToIndex\" is provided.`,\n \"METHOD_NOT_ALLOWED\",\n {\n entry: initialTransformedEntryToIndex\n }\n );\n }\n if (transformedEntryKeys) {\n return transformedEntryKeys;\n }\n return (transformedEntryKeys = transformEntryKeys({\n model,\n entry: baseEntry,\n storageEntry: baseStorageEntry\n }));\n },\n transformToIndex: function () {\n if (transformedEntryToIndex) {\n return transformedEntryToIndex;\n }\n let entry: CmsEntry;\n let storageEntry: CmsStorageEntry;\n /**\n * In case there are value modifier plugins, we need to\n * - run modifiers\n * - transform keys\n */\n if (modifierPlugins.length > 0) {\n const result = modifyEntryValues();\n entry = result.entry;\n storageEntry = result.storageEntry;\n }\n // In case there are no modifier plugins, just transform the keys - or used already transformed.\n else {\n const result = this.transformEntryKeys();\n entry = result.entry;\n storageEntry = result.storageEntry;\n }\n return (transformedEntryToIndex = transformEntryToIndex({\n plugins,\n model,\n entry,\n storageEntry\n }));\n },\n getElasticsearchLatestEntryData: async function () {\n if (elasticsearchLatestEntry) {\n return elasticsearchLatestEntry;\n }\n const entry = this.transformToIndex();\n\n return (elasticsearchLatestEntry = await compress(plugins, {\n ...entry,\n latest: true,\n TYPE: createLatestRecordType(),\n __type: createLatestRecordType()\n }));\n },\n getElasticsearchPublishedEntryData: async function () {\n if (elasticsearchPublishedEntry) {\n return elasticsearchPublishedEntry;\n }\n const entry = this.transformToIndex();\n\n return (elasticsearchPublishedEntry = await compress(plugins, {\n ...entry,\n published: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4CAAqB,EAAC;QACpD/B,OAAO;QACPC,KAAK;QACLC,KAAK;QACLE;MACJ,CAAC,CAAC;IACN,CAAC;IACD4B,+BAA+B,EAAE,eAAAA,CAAA,EAAkB;MAC/C,IAAIpB,wBAAwB,EAAE;QAC1B,OAAOA,wBAAwB;MACnC;MACA,MAAMV,KAAK,GAAG,IAAI,CAAC0B,gBAAgB,CAAC,CAAC;MAErC,OAAQhB,wBAAwB,GAAG,MAAM,IAAAqB,0BAAQ,EAACjC,OAAO,EAAE;QACvD,GAAGE,KAAK;QACRgC,MAAM,EAAE,IAAI;QACZC,IAAI,EAAE,IAAAC,kCAAsB,EAAC,CAAC;QAC9BC,MAAM,EAAE,IAAAD,kCAAsB,EAAC;MACnC,CAAC,CAAC;IACN,CAAC;IACDE,kCAAkC,EAAE,eAAAA,CAAA,EAAkB;MAClD,IAAIzB,2BAA2B,EAAE;QAC7B,OAAOA,2BAA2B;MACtC;MACA,MAAMX,KAAK,GAAG,IAAI,CAAC0B,gBAAgB,CAAC,CAAC;MAErC,OAAQf,2BAA2B,GAAG,MAAM,IAAAoB,0BAAQ,EAACjC,OAAO,EAAE;QAC1D,GAAGE,KAAK;QACRqC,SAAS,EAAE,IAAI;QACfJ,IAAI,EAAE,IAAAK,qCAAyB,EAAC,CAAC;QACjCH,MAAM,EAAE,IAAAG,qCAAyB,EAAC;MACtC,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAA3C,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_transformEntryKeys","require","_transformEntryToIndex","_plugins","_modifyEntryValues","_apiElasticsearch","_recordType","_error","_interopRequireDefault","createTransformer","params","plugins","model","entry","baseEntry","storageEntry","baseStorageEntry","transformedToIndex","initialTransformedEntryToIndex","undefined","transformedEntryKeys","transformedEntryToIndex","modifiedEntryValues","elasticsearchLatestEntry","elasticsearchPublishedEntry","modifierPlugins","byType","CmsEntryElasticsearchValuesModifier","type","filter","pl","canModify","modelId","modifyEntryValues","WebinyError","modifiedEntry","modifyEntryValuesCallable","modifiedStorageEntry","transformEntryKeys","transformToIndex","length","result","transformEntryToIndex","getElasticsearchLatestEntryData","compress","latest","TYPE","createLatestRecordType","__type","getElasticsearchPublishedEntryData","published","createPublishedRecordType","exports"],"sources":["index.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport type {\n CmsEntry,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types\";\nimport { transformEntryKeys } from \"./transformEntryKeys\";\nimport type { CmsIndexEntry } from \"~/types\";\nimport { transformEntryToIndex } from \"~/operations/entry/transformations/transformEntryToIndex\";\nimport { CmsEntryElasticsearchValuesModifier } from \"~/plugins\";\nimport { modifyEntryValues as modifyEntryValuesCallable } from \"~/operations/entry/transformations/modifyEntryValues\";\nimport { compress } from \"@webiny/api-elasticsearch\";\nimport { createLatestRecordType, createPublishedRecordType } from \"~/operations/entry/recordType\";\nimport WebinyError from \"@webiny/error\";\n\ninterface BaseTransformerParams {\n plugins: PluginsContainer;\n model: StorageOperationsCmsModel;\n}\n\ninterface EntryTransformerParams extends BaseTransformerParams {\n entry: CmsEntry;\n storageEntry: CmsEntry;\n transformedToIndex?: never;\n}\n\ninterface TransformedEntryTransformerParams extends BaseTransformerParams {\n entry?: never;\n storageEntry?: never;\n transformedToIndex: CmsIndexEntry;\n}\n\ninterface TransformedKeysEntry {\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\ninterface ModifiedEntryValues {\n entry: CmsEntry;\n storageEntry: CmsEntry;\n}\n\ninterface TransformerResult {\n transformEntryKeys: () => TransformedKeysEntry;\n transformToIndex: () => CmsIndexEntry;\n getElasticsearchLatestEntryData: () => Promise<Record<string, any>>;\n getElasticsearchPublishedEntryData: () => Promise<Record<string, any>>;\n}\n\nexport const createTransformer = (\n params: EntryTransformerParams | TransformedEntryTransformerParams\n): TransformerResult => {\n const {\n plugins,\n model,\n entry: baseEntry,\n storageEntry: baseStorageEntry,\n transformedToIndex: initialTransformedEntryToIndex = undefined\n } = params;\n\n let transformedEntryKeys: TransformedKeysEntry | undefined = undefined;\n let transformedEntryToIndex: CmsIndexEntry | undefined = initialTransformedEntryToIndex;\n let modifiedEntryValues: ModifiedEntryValues | undefined = undefined;\n let elasticsearchLatestEntry: any = undefined;\n let elasticsearchPublishedEntry: any = undefined;\n\n const modifierPlugins = plugins\n .byType<CmsEntryElasticsearchValuesModifier>(CmsEntryElasticsearchValuesModifier.type)\n .filter(pl => pl.canModify(model.modelId));\n\n const modifyEntryValues = () => {\n if (initialTransformedEntryToIndex || !baseEntry) {\n throw new WebinyError(\n `Should not call the \"modifyEntryValues\" when \"transformedToIndex\" is provided.`,\n \"METHOD_NOT_ALLOWED\",\n {\n entry: initialTransformedEntryToIndex\n }\n );\n }\n if (modifiedEntryValues) {\n return modifiedEntryValues;\n }\n const modifiedEntry = modifyEntryValuesCallable({\n plugins: modifierPlugins,\n model,\n entry: baseEntry\n });\n const modifiedStorageEntry = modifyEntryValuesCallable({\n plugins: modifierPlugins,\n model,\n entry: baseStorageEntry\n });\n\n return (modifiedEntryValues = transformEntryKeys({\n model,\n entry: modifiedEntry,\n storageEntry: modifiedStorageEntry\n }));\n };\n\n return {\n transformEntryKeys: function () {\n if (initialTransformedEntryToIndex || !baseEntry) {\n throw new WebinyError(\n `Should not call the \"modifyEntryValues\" when \"transformedToIndex\" is provided.`,\n \"METHOD_NOT_ALLOWED\",\n {\n entry: initialTransformedEntryToIndex\n }\n );\n }\n if (transformedEntryKeys) {\n return transformedEntryKeys;\n }\n return (transformedEntryKeys = transformEntryKeys({\n model,\n entry: baseEntry,\n storageEntry: baseStorageEntry\n }));\n },\n transformToIndex: function () {\n if (transformedEntryToIndex) {\n return transformedEntryToIndex;\n }\n let entry: CmsEntry;\n let storageEntry: CmsStorageEntry;\n /**\n * In case there are value modifier plugins, we need to\n * - run modifiers\n * - transform keys\n */\n if (modifierPlugins.length > 0) {\n const result = modifyEntryValues();\n entry = result.entry;\n storageEntry = result.storageEntry;\n }\n // In case there are no modifier plugins, just transform the keys - or used already transformed.\n else {\n const result = this.transformEntryKeys();\n entry = result.entry;\n storageEntry = result.storageEntry;\n }\n return (transformedEntryToIndex = transformEntryToIndex({\n plugins,\n model,\n entry,\n storageEntry\n }));\n },\n getElasticsearchLatestEntryData: async function () {\n if (elasticsearchLatestEntry) {\n return elasticsearchLatestEntry;\n }\n const entry = this.transformToIndex();\n\n return (elasticsearchLatestEntry = await compress(plugins, {\n ...entry,\n latest: true,\n TYPE: createLatestRecordType(),\n __type: createLatestRecordType()\n }));\n },\n getElasticsearchPublishedEntryData: async function () {\n if (elasticsearchPublishedEntry) {\n return elasticsearchPublishedEntry;\n }\n const entry = this.transformToIndex();\n\n return (elasticsearchPublishedEntry = await compress(plugins, {\n ...entry,\n published: true,\n TYPE: createPublishedRecordType(),\n __type: createPublishedRecordType()\n }));\n }\n };\n};\n"],"mappings":";;;;;;;AAMA,IAAAA,mBAAA,GAAAC,OAAA;AAEA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAC,sBAAA,CAAAP,OAAA;AAoCO,MAAMQ,iBAAiB,GAC1BC,MAAkE,IAC9C;EACpB,MAAM;IACFC,OAAO;IACPC,KAAK;IACLC,KAAK,EAAEC,SAAS;IAChBC,YAAY,EAAEC,gBAAgB;IAC9BC,kBAAkB,EAAEC,8BAA8B,GAAGC;EACzD,CAAC,GAAGT,MAAM;EAEV,IAAIU,oBAAsD,GAAGD,SAAS;EACtE,IAAIE,uBAAkD,GAAGH,8BAA8B;EACvF,IAAII,mBAAoD,GAAGH,SAAS;EACpE,IAAII,wBAA6B,GAAGJ,SAAS;EAC7C,IAAIK,2BAAgC,GAAGL,SAAS;E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O,EAAE;QAC1D,GAAGE,KAAK;QACRqC,SAAS,EAAE,IAAI;QACfJ,IAAI,EAAE,IAAAK,qCAAyB,EAAC,CAAC;QACjCH,MAAM,EAAE,IAAAG,qCAAyB,EAAC;MACtC,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAA3C,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CmsEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import { CmsEntryElasticsearchValuesModifier } from "../../../plugins";
|
|
1
|
+
import type { CmsEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import type { CmsEntryElasticsearchValuesModifier } from "../../../plugins";
|
|
3
3
|
interface Params {
|
|
4
4
|
model: StorageOperationsCmsModel;
|
|
5
5
|
plugins: CmsEntryElasticsearchValuesModifier[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["modifyEntryValues","params","plugins","model","entry","values","plugin","modify","exports"],"sources":["modifyEntryValues.ts"],"sourcesContent":["import { CmsEntry, StorageOperationsCmsModel } from \"@webiny/api-headless-cms/types\";\nimport { CmsEntryElasticsearchValuesModifier } from \"~/plugins\";\n\ninterface Params {\n model: StorageOperationsCmsModel;\n plugins: CmsEntryElasticsearchValuesModifier[];\n entry: CmsEntry;\n}\n\nexport const modifyEntryValues = (params: Params) => {\n const { plugins, model, entry } = params;\n let values = entry.values;\n for (const plugin of plugins) {\n values = plugin.modify({\n model,\n entry,\n values\n });\n }\n return {\n ...entry,\n values\n };\n};\n"],"mappings":";;;;;;AASO,MAAMA,iBAAiB,GAAIC,MAAc,IAAK;EACjD,MAAM;IAAEC,OAAO;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGH,MAAM;EACxC,IAAII,MAAM,GAAGD,KAAK,CAACC,MAAM;EACzB,KAAK,MAAMC,MAAM,IAAIJ,OAAO,EAAE;IAC1BG,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC;MACnBJ,KAAK;MACLC,KAAK;MACLC;IACJ,CAAC,CAAC;EACN;EACA,OAAO;IACH,GAAGD,KAAK;IACRC;EACJ,CAAC;AACL,CAAC;AAACG,OAAA,CAAAR,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["modifyEntryValues","params","plugins","model","entry","values","plugin","modify","exports"],"sources":["modifyEntryValues.ts"],"sourcesContent":["import type { CmsEntry, StorageOperationsCmsModel } from \"@webiny/api-headless-cms/types\";\nimport type { CmsEntryElasticsearchValuesModifier } from \"~/plugins\";\n\ninterface Params {\n model: StorageOperationsCmsModel;\n plugins: CmsEntryElasticsearchValuesModifier[];\n entry: CmsEntry;\n}\n\nexport const modifyEntryValues = (params: Params) => {\n const { plugins, model, entry } = params;\n let values = entry.values;\n for (const plugin of plugins) {\n values = plugin.modify({\n model,\n entry,\n values\n });\n }\n return {\n ...entry,\n values\n };\n};\n"],"mappings":";;;;;;AASO,MAAMA,iBAAiB,GAAIC,MAAc,IAAK;EACjD,MAAM;IAAEC,OAAO;IAAEC,KAAK;IAAEC;EAAM,CAAC,GAAGH,MAAM;EACxC,IAAII,MAAM,GAAGD,KAAK,CAACC,MAAM;EACzB,KAAK,MAAMC,MAAM,IAAIJ,OAAO,EAAE;IAC1BG,MAAM,GAAGC,MAAM,CAACC,MAAM,CAAC;MACnBJ,KAAK;MACLC,KAAK;MACLC;IACJ,CAAC,CAAC;EACN;EACA,OAAO;IACH,GAAGD,KAAK;IACRC;EACJ,CAAC;AACL,CAAC;AAACG,OAAA,CAAAR,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CmsEntry, CmsStorageEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types";
|
|
1
|
+
import type { CmsEntry, CmsStorageEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types";
|
|
2
2
|
interface TransformKeysParams {
|
|
3
3
|
model: StorageOperationsCmsModel;
|
|
4
4
|
entry: CmsEntry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_convertEntryKeys","require","transformEntryKeys","params","model","entry","storageEntry","convertEntryKeysToStorage","exports"],"sources":["transformEntryKeys.ts"],"sourcesContent":["import {\n CmsEntry,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types\";\nimport { convertEntryKeysToStorage } from \"./convertEntryKeys\";\n\ninterface TransformKeysParams {\n model: StorageOperationsCmsModel;\n entry: CmsEntry;\n storageEntry: CmsStorageEntry;\n}\n\nexport const transformEntryKeys = (params: TransformKeysParams) => {\n const { model, entry, storageEntry } = params;\n return {\n entry: convertEntryKeysToStorage({\n model,\n entry\n }),\n storageEntry: convertEntryKeysToStorage({\n model,\n entry: storageEntry\n })\n };\n};\n"],"mappings":";;;;;;AAKA,IAAAA,iBAAA,GAAAC,OAAA;AAQO,MAAMC,kBAAkB,GAAIC,MAA2B,IAAK;EAC/D,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC;EAAa,CAAC,GAAGH,MAAM;EAC7C,OAAO;IACHE,KAAK,EAAE,IAAAE,2CAAyB,EAAC;MAC7BH,KAAK;MACLC;IACJ,CAAC,CAAC;IACFC,YAAY,EAAE,IAAAC,2CAAyB,EAAC;MACpCH,KAAK;MACLC,KAAK,EAAEC;IACX,CAAC;EACL,CAAC;AACL,CAAC;AAACE,OAAA,CAAAN,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_convertEntryKeys","require","transformEntryKeys","params","model","entry","storageEntry","convertEntryKeysToStorage","exports"],"sources":["transformEntryKeys.ts"],"sourcesContent":["import type {\n CmsEntry,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types\";\nimport { convertEntryKeysToStorage } from \"./convertEntryKeys\";\n\ninterface TransformKeysParams {\n model: StorageOperationsCmsModel;\n entry: CmsEntry;\n storageEntry: CmsStorageEntry;\n}\n\nexport const transformEntryKeys = (params: TransformKeysParams) => {\n const { model, entry, storageEntry } = params;\n return {\n entry: convertEntryKeysToStorage({\n model,\n entry\n }),\n storageEntry: convertEntryKeysToStorage({\n model,\n entry: storageEntry\n })\n };\n};\n"],"mappings":";;;;;;AAKA,IAAAA,iBAAA,GAAAC,OAAA;AAQO,MAAMC,kBAAkB,GAAIC,MAA2B,IAAK;EAC/D,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC;EAAa,CAAC,GAAGH,MAAM;EAC7C,OAAO;IACHE,KAAK,EAAE,IAAAE,2CAAyB,EAAC;MAC7BH,KAAK;MACLC;IACJ,CAAC,CAAC;IACFC,YAAY,EAAE,IAAAC,2CAAyB,EAAC;MACpCH,KAAK;MACLC,KAAK,EAAEC;IACX,CAAC;EACL,CAAC;AACL,CAAC;AAACE,OAAA,CAAAN,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PluginsContainer } from "@webiny/plugins";
|
|
2
|
-
import { CmsEntry, CmsStorageEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types";
|
|
1
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
2
|
+
import type { CmsEntry, CmsStorageEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types";
|
|
3
3
|
interface TransformEntryToIndexParams {
|
|
4
4
|
plugins: PluginsContainer;
|
|
5
5
|
model: StorageOperationsCmsModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_helpers","require","transformEntryToIndex","params","plugins","model","entry","storageEntry","result","prepareEntryToIndex","structuredClone","exports"],"sources":["transformEntryToIndex.ts"],"sourcesContent":["import { PluginsContainer } from \"@webiny/plugins\";\nimport {\n CmsEntry,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types\";\nimport { prepareEntryToIndex } from \"~/helpers\";\n\ninterface TransformEntryToIndexParams {\n plugins: PluginsContainer;\n model: StorageOperationsCmsModel;\n entry: CmsEntry;\n storageEntry: CmsStorageEntry;\n}\n\nexport const transformEntryToIndex = (params: TransformEntryToIndexParams) => {\n const { plugins, model, entry, storageEntry } = params;\n const result = prepareEntryToIndex({\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":";;;;;;AAMA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,qBAAqB,GAAIC,MAAmC,IAAK;EAC1E,MAAM;IAAEC,OAAO;IAAEC,KAAK;IAAEC,KAAK;IAAEC;EAAa,CAAC,GAAGJ,MAAM;EACtD,MAAMK,MAAM,GAAG,IAAAC,4BAAmB,EAAC;IAC/BL,OAAO;IACPC,KAAK;IACLC,KAAK,EAAEI,eAAe,CAACJ,KAAK,CAAC;IAC7BC,YAAY,EAAEG,eAAe,CAACH,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;AAACG,OAAA,CAAAT,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_helpers","require","transformEntryToIndex","params","plugins","model","entry","storageEntry","result","prepareEntryToIndex","structuredClone","exports"],"sources":["transformEntryToIndex.ts"],"sourcesContent":["import type { PluginsContainer } from \"@webiny/plugins\";\nimport type {\n CmsEntry,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types\";\nimport { prepareEntryToIndex } from \"~/helpers\";\n\ninterface TransformEntryToIndexParams {\n plugins: PluginsContainer;\n model: StorageOperationsCmsModel;\n entry: CmsEntry;\n storageEntry: CmsStorageEntry;\n}\n\nexport const transformEntryToIndex = (params: TransformEntryToIndexParams) => {\n const { plugins, model, entry, storageEntry } = params;\n const result = prepareEntryToIndex({\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":";;;;;;AAMA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,qBAAqB,GAAIC,MAAmC,IAAK;EAC1E,MAAM;IAAEC,OAAO;IAAEC,KAAK;IAAEC,KAAK;IAAEC;EAAa,CAAC,GAAGJ,MAAM;EACtD,MAAMK,MAAM,GAAG,IAAAC,4BAAmB,EAAC;IAC/BL,OAAO;IACPC,KAAK;IACLC,KAAK,EAAEI,eAAe,CAACJ,KAAK,CAAC;IAC7BC,YAAY,EAAEG,eAAe,CAACH,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;AAACG,OAAA,CAAAT,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CmsGroupStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import { Entity } from "@webiny/db-dynamodb/toolbox";
|
|
3
|
-
import { PluginsContainer } from "@webiny/plugins";
|
|
1
|
+
import type { CmsGroupStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import type { Entity } from "@webiny/db-dynamodb/toolbox";
|
|
3
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
4
4
|
export interface CreateGroupsStorageOperationsParams {
|
|
5
5
|
entity: Entity<any>;
|
|
6
6
|
plugins: PluginsContainer;
|
|
@@ -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 {\n CmsGroup,\n CmsGroupStorageOperations,\n CmsGroupStorageOperationsCreateParams,\n CmsGroupStorageOperationsDeleteParams,\n CmsGroupStorageOperationsGetParams,\n CmsGroupStorageOperationsListParams,\n CmsGroupStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { getClean } from \"@webiny/db-dynamodb/utils/get\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport { 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;AACA,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,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AAK,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":["_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,IAA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AAK,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,6 +1,6 @@
|
|
|
1
|
-
import { CmsModelStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import { Entity } from "@webiny/db-dynamodb/toolbox";
|
|
3
|
-
import { Client } from "@elastic/elasticsearch";
|
|
1
|
+
import type { CmsModelStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import type { Entity } from "@webiny/db-dynamodb/toolbox";
|
|
3
|
+
import type { Client } from "@elastic/elasticsearch";
|
|
4
4
|
export interface CreateModelsStorageOperationsParams {
|
|
5
5
|
entity: Entity<any>;
|
|
6
6
|
elasticsearch: Client;
|
|
@@ -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 {\n CmsModel,\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport { configurations } from \"~/configurations\";\nimport { Client } from \"@elastic/elasticsearch\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { queryAllClean, QueryAllParams } 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;AACA,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,OAAO,WAAW;AACtB,CAAC;AAOM,MAAMC,6BAA6B,GACtCT,MAA2C,IACf;EAC5B,MAAM;IAAEU,MAAM;IAAEC;EAAc,CAAC,GAAGX,MAAM;EAExC,MAAMY,MAAM,GAAG,MAAOZ,MAA6C,IAAK;IACpE,MAAM;MAAEa;IAAM,CAAC,GAAGb,MAAM;IAExB,MAAM;MAAEc;IAAM,CAAC,GAAGC,8BAAc,CAACC,EAAE,CAAC;MAChCH;IACJ,CAAC,CAAC;IAEF,MAAMI,IAAI,GAAGZ,UAAU,CAACQ,KAAK,CAAC;IAE9B,IAAIK,KAAK;IACT,IAAI;MACA,MAAM,IAAAC,eAAG,EAAC;QACNT,MAAM;QACNU,IAAI,EAAE;UACF,GAAG,IAAAC,o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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":["_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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BAAa,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,5 +1,5 @@
|
|
|
1
|
-
import { CmsSystemStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import { Entity } from "@webiny/db-dynamodb/toolbox";
|
|
1
|
+
import type { CmsSystemStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import type { Entity } from "@webiny/db-dynamodb/toolbox";
|
|
3
3
|
export interface CreateSystemStorageOperationsParams {
|
|
4
4
|
entity: Entity<any>;
|
|
5
5
|
}
|
|
@@ -1 +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 {\n CmsSystem,\n CmsSystemStorageOperations,\n CmsSystemStorageOperationsCreateParams,\n CmsSystemStorageOperationsGetParams,\n CmsSystemStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { 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,K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AI,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":[]}
|
|
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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ACTJ,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":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CmsContext } from "../../types";
|
|
2
|
-
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
-
import { Client } from "@elastic/elasticsearch";
|
|
1
|
+
import type { CmsContext } from "../../types";
|
|
2
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
import type { Client } from "@elastic/elasticsearch";
|
|
4
4
|
interface Params {
|
|
5
5
|
context: CmsContext;
|
|
6
6
|
client: Client;
|
|
@@ -1 +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 { CmsContext } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { 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":[]}
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb-es",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-headless-cms",
|
|
@@ -26,33 +26,33 @@
|
|
|
26
26
|
],
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@webiny/api": "6.0.0-alpha.
|
|
30
|
-
"@webiny/api-elasticsearch": "6.0.0-alpha.
|
|
31
|
-
"@webiny/api-elasticsearch-tasks": "6.0.0-alpha.
|
|
32
|
-
"@webiny/api-headless-cms": "6.0.0-alpha.
|
|
33
|
-
"@webiny/aws-sdk": "6.0.0-alpha.
|
|
34
|
-
"@webiny/db-dynamodb": "6.0.0-alpha.
|
|
35
|
-
"@webiny/error": "6.0.0-alpha.
|
|
36
|
-
"@webiny/handler-db": "6.0.0-alpha.
|
|
37
|
-
"@webiny/plugins": "6.0.0-alpha.
|
|
38
|
-
"@webiny/utils": "6.0.0-alpha.
|
|
29
|
+
"@webiny/api": "6.0.0-alpha.2",
|
|
30
|
+
"@webiny/api-elasticsearch": "6.0.0-alpha.2",
|
|
31
|
+
"@webiny/api-elasticsearch-tasks": "6.0.0-alpha.2",
|
|
32
|
+
"@webiny/api-headless-cms": "6.0.0-alpha.2",
|
|
33
|
+
"@webiny/aws-sdk": "6.0.0-alpha.2",
|
|
34
|
+
"@webiny/db-dynamodb": "6.0.0-alpha.2",
|
|
35
|
+
"@webiny/error": "6.0.0-alpha.2",
|
|
36
|
+
"@webiny/handler-db": "6.0.0-alpha.2",
|
|
37
|
+
"@webiny/plugins": "6.0.0-alpha.2",
|
|
38
|
+
"@webiny/utils": "6.0.0-alpha.2",
|
|
39
39
|
"dataloader": "2.2.3",
|
|
40
40
|
"lodash": "4.17.21"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@elastic/elasticsearch": "7.12.0",
|
|
44
44
|
"@types/jsonpack": "1.1.6",
|
|
45
|
-
"@webiny/api-dynamodb-to-elasticsearch": "6.0.0-alpha.
|
|
46
|
-
"@webiny/api-i18n": "6.0.0-alpha.
|
|
47
|
-
"@webiny/api-log": "6.0.0-alpha.
|
|
48
|
-
"@webiny/api-security": "6.0.0-alpha.
|
|
49
|
-
"@webiny/api-tenancy": "6.0.0-alpha.
|
|
50
|
-
"@webiny/api-wcp": "6.0.0-alpha.
|
|
51
|
-
"@webiny/handler": "6.0.0-alpha.
|
|
52
|
-
"@webiny/handler-aws": "6.0.0-alpha.
|
|
53
|
-
"@webiny/handler-graphql": "6.0.0-alpha.
|
|
54
|
-
"@webiny/project-utils": "6.0.0-alpha.
|
|
55
|
-
"@webiny/tasks": "6.0.0-alpha.
|
|
45
|
+
"@webiny/api-dynamodb-to-elasticsearch": "6.0.0-alpha.2",
|
|
46
|
+
"@webiny/api-i18n": "6.0.0-alpha.2",
|
|
47
|
+
"@webiny/api-log": "6.0.0-alpha.2",
|
|
48
|
+
"@webiny/api-security": "6.0.0-alpha.2",
|
|
49
|
+
"@webiny/api-tenancy": "6.0.0-alpha.2",
|
|
50
|
+
"@webiny/api-wcp": "6.0.0-alpha.2",
|
|
51
|
+
"@webiny/handler": "6.0.0-alpha.2",
|
|
52
|
+
"@webiny/handler-aws": "6.0.0-alpha.2",
|
|
53
|
+
"@webiny/handler-graphql": "6.0.0-alpha.2",
|
|
54
|
+
"@webiny/project-utils": "6.0.0-alpha.2",
|
|
55
|
+
"@webiny/tasks": "6.0.0-alpha.2",
|
|
56
56
|
"jest": "29.7.0",
|
|
57
57
|
"jest-dynalite": "3.6.1",
|
|
58
58
|
"prettier": "2.8.8",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"build": "node ../cli/bin.js run build",
|
|
68
68
|
"watch": "node ../cli/bin.js run watch"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "7c9e8fbfd62a57ece5f880dbad6c864636b0355e"
|
|
71
71
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins";
|
|
2
|
-
import { CmsModelFieldType } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import type { CmsModelFieldType } from "@webiny/api-headless-cms/types";
|
|
3
3
|
/**
|
|
4
4
|
* A plugin which allows you to map a custom GraphQL field to an Elasticsearch field.
|
|
5
5
|
*
|