@webiny/api-headless-cms-ddb 0.0.0-mt-3 → 0.0.0-unstable.40876133bb
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/definitions/entry.d.ts +2 -1
- package/definitions/entry.js +6 -7
- package/definitions/entry.js.map +1 -0
- package/definitions/group.d.ts +2 -1
- package/definitions/group.js +3 -7
- package/definitions/group.js.map +1 -0
- package/definitions/model.d.ts +2 -1
- package/definitions/model.js +3 -7
- package/definitions/model.js.map +1 -0
- package/definitions/settings.d.ts +2 -1
- package/definitions/settings.js +3 -7
- package/definitions/settings.js.map +1 -0
- package/definitions/system.d.ts +2 -1
- package/definitions/system.js +3 -7
- package/definitions/system.js.map +1 -0
- package/definitions/table.d.ts +2 -1
- package/definitions/table.js.map +1 -0
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +6 -10
- package/dynamoDb/index.js.map +1 -0
- package/dynamoDb/path/plainObject.d.ts +2 -3
- package/dynamoDb/path/plainObject.js +29 -22
- package/dynamoDb/path/plainObject.js.map +1 -0
- package/dynamoDb/storage/date.d.ts +2 -3
- package/dynamoDb/storage/date.js +80 -46
- package/dynamoDb/storage/date.js.map +1 -0
- package/dynamoDb/storage/longText.d.ts +7 -4
- package/dynamoDb/storage/longText.js +72 -54
- package/dynamoDb/storage/longText.js.map +1 -0
- package/dynamoDb/storage/richText.d.ts +2 -8
- package/dynamoDb/storage/richText.js +70 -67
- package/dynamoDb/storage/richText.js.map +1 -0
- package/dynamoDb/transformValue/datetime.d.ts +4 -2
- package/dynamoDb/transformValue/datetime.js +31 -26
- package/dynamoDb/transformValue/datetime.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +42 -24
- package/index.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +12 -8
- package/operations/entry/dataLoaders.js +31 -13
- package/operations/entry/dataLoaders.js.map +1 -0
- package/operations/entry/index.d.ts +2 -2
- package/operations/entry/index.js +253 -219
- package/operations/entry/index.js.map +1 -0
- package/operations/entry/keys.js +11 -0
- package/operations/entry/keys.js.map +1 -0
- package/operations/entry/systemFields.js +24 -0
- package/operations/entry/systemFields.js.map +1 -0
- package/operations/entry/utils.d.ts +10 -5
- package/operations/entry/utils.js +370 -96
- package/operations/entry/utils.js.map +1 -0
- package/operations/group/index.d.ts +3 -2
- package/operations/group/index.js +7 -13
- package/operations/group/index.js.map +1 -0
- package/operations/model/index.d.ts +3 -2
- package/operations/model/index.js +15 -14
- package/operations/model/index.js.map +1 -0
- package/operations/settings/index.d.ts +3 -2
- package/operations/settings/index.js +7 -13
- package/operations/settings/index.js.map +1 -0
- package/operations/system/index.d.ts +3 -2
- package/operations/system/index.js +5 -11
- package/operations/system/index.js.map +1 -0
- package/package.json +22 -23
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +22 -0
- package/plugins/CmsEntryFieldFilterPathPlugin.js +55 -0
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -0
- package/plugins/index.d.ts +1 -0
- package/plugins/index.js +18 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +1 -32
- package/types.js.map +1 -0
- package/dynamoDb/path/ref.d.ts +0 -3
- package/dynamoDb/path/ref.js +0 -27
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["VALUES_ATTRIBUTE","extractWhereParams","key","result","split","fieldId","shift","rawOp","length","join","operation","negate","match","replace","transformValue","value","transform","Array","isArray","map","v","getFilterPlugin","params","plugins","plugin","WebinyError","createValuePath","field","index","valuePathPlugin","type","basePath","systemFields","canUse","path","createPath","isObjectFiltering","Date","toISOString","createFilters","where","fields","filterPlugins","getMappedPlugins","ValueFilterPlugin","property","transformValuePlugins","valuePathPlugins","CmsEntryFieldFilterPathPlugin","filters","hasOwnProperty","undefined","whereParams","transformValuePlugin","def","transformValueCallable","objectFilteringParams","propertyFilters","Object","keys","propertyFilter","propertyId","propertyOperation","propertyNegate","filterPlugin","multiValuesPath","multipleValues","push","compareValue","getFilterValuePath","filter","includes","paths","getFilterValuePropertyPath","pop","execFilter","plainValue","matched","matches","createFullTextSearch","term","targetFields","trim","item","fromStorage","targetField","values","find","target","filterItems","items","records","fullTextSearch","fullTextSearchPlugin","byType","getOperation","search","promises","record","valuePath","rawValue","dotProp","get","propertyPath","console","log","set","results","Promise","all","Boolean","extractSort","sortBy","order","modelField","reverse","sortEntryItems","sort","firstSort","itemsToSort","id","valueTransformer","sortedItems","lodashSortBy","newItems","s","i","sortingBy","pluginsContainer","reduce","collection","buildModelFields","model","isSystemField","storageId","modelId"],"sources":["utils.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport lodashSortBy from \"lodash/sortBy\";\nimport dotProp from \"dot-prop\";\nimport {\n CmsEntry,\n CmsEntryListWhere,\n CmsModel,\n CmsModelField\n} from \"@webiny/api-headless-cms/types\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport { CmsFieldFilterValueTransformPlugin } from \"~/types\";\nimport { systemFields } from \"./systemFields\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport {\n CmsEntryFieldFilterPathPlugin,\n CmsEntryFieldFilterPathPluginParams,\n CreatePathCallable as CmsEntryFieldFieldCreatePathCallable\n} from \"~/plugins/CmsEntryFieldFilterPathPlugin\";\n\ninterface ModelField {\n def: CmsModelField;\n valueTransformer: (value: any) => any;\n createPath: CmsEntryFieldFieldCreatePathCallable;\n isSystemField?: boolean;\n}\n\ntype ModelFieldRecords = Record<string, ModelField>;\n\ntype MappedPlugins<T extends Plugin> = Record<string, T>;\n\ninterface CreateFiltersParams {\n plugins: PluginsContainer;\n where: Partial<CmsEntryListWhere>;\n fields: ModelFieldRecords;\n}\n\ninterface ItemFilter {\n fieldId: string;\n path: string;\n filterPlugin: ValueFilterPlugin;\n negate: boolean;\n compareValue: any;\n transformValue: <I = any, O = any>(value: I) => O;\n}\n\nexport interface FilterItemFromStorage {\n <T = any>(field: CmsModelField, value: any): Promise<T>;\n}\ninterface FilterItemsParams {\n items: CmsEntry[];\n where: Partial<CmsEntryListWhere>;\n plugins: PluginsContainer;\n fields: ModelFieldRecords;\n fromStorage: FilterItemFromStorage;\n fullTextSearch?: {\n term?: string;\n fields?: string[];\n };\n}\n\nconst VALUES_ATTRIBUTE = \"values\";\n\nconst extractWhereParams = (key: string) => {\n const result = key.split(\"_\");\n const fieldId = result.shift();\n if (!fieldId) {\n return null;\n }\n const rawOp = result.length === 0 ? \"eq\" : result.join(\"_\");\n /**\n * When rawOp is not, it means it is equal negated so just return that.\n */\n if (rawOp === \"not\") {\n return {\n fieldId,\n operation: \"eq\",\n negate: true\n };\n }\n const negate = rawOp.match(\"not_\") !== null;\n const operation = rawOp.replace(\"not_\", \"\");\n return {\n fieldId,\n operation,\n negate\n };\n};\n\nconst transformValue = (value: any, transform: (value: any) => any): any => {\n if (Array.isArray(value)) {\n return value.map(v => transform(v));\n }\n return transform(value);\n};\n\ninterface GetFilterPluginParams {\n plugins: MappedPlugins<ValueFilterPlugin>;\n operation: string;\n}\nconst getFilterPlugin = (params: GetFilterPluginParams) => {\n const { plugins, operation } = params;\n const plugin = plugins[operation];\n if (plugin) {\n return plugin;\n }\n throw new WebinyError(\n `There is no filter plugin for operation \"${operation}\".`,\n \"FILTER_PLUGIN_ERROR\",\n {\n operation\n }\n );\n};\n\ninterface CreateValuePathParams {\n field: CmsModelField;\n plugins: MappedPlugins<CmsEntryFieldFilterPathPlugin>;\n index?: number;\n}\nconst createValuePath = (params: CreateValuePathParams): string => {\n const { field, plugins, index } = params;\n const { fieldId } = field;\n const valuePathPlugin = plugins[field.type];\n const basePath = systemFields[fieldId] ? \"\" : `${VALUES_ATTRIBUTE}.`;\n if (!valuePathPlugin || valuePathPlugin.canUse(field) === false) {\n return `${basePath}${fieldId}`;\n }\n const path = valuePathPlugin.createPath({\n field,\n index\n });\n return `${basePath}${path}`;\n};\n\ninterface ObjectFilteringParams {\n key: string;\n field: CmsModelField;\n value: any;\n}\nconst isObjectFiltering = (params: ObjectFilteringParams): boolean => {\n const { value } = params;\n if (!value) {\n return false;\n } else if (Array.isArray(value) === true) {\n return false;\n } else if (value instanceof Date || !!value.toISOString) {\n return false;\n } else if (typeof value !== \"object\") {\n return false;\n }\n return true;\n};\n\nconst createFilters = (params: CreateFiltersParams): ItemFilter[] => {\n const { where, plugins, fields } = params;\n const filterPlugins = getMappedPlugins<ValueFilterPlugin>({\n plugins,\n type: ValueFilterPlugin.type,\n property: \"operation\"\n });\n const transformValuePlugins = getMappedPlugins<CmsFieldFilterValueTransformPlugin>({\n plugins,\n type: \"cms-field-filter-value-transform\",\n property: \"fieldType\"\n });\n const valuePathPlugins = getMappedPlugins<CmsEntryFieldFilterPathPlugin>({\n plugins,\n type: CmsEntryFieldFilterPathPlugin.type,\n property: \"fieldType\"\n });\n\n const filters: ItemFilter[] = [];\n\n for (const key in where) {\n if (where.hasOwnProperty(key) === false) {\n continue;\n }\n\n const value = (where as any)[key];\n if (value === undefined) {\n continue;\n }\n\n const whereParams = extractWhereParams(key);\n if (!whereParams) {\n continue;\n }\n\n const { fieldId, operation, negate } = whereParams;\n\n const field: ModelField = fields[fieldId];\n if (!field) {\n throw new WebinyError(\n `There is no field with the fieldId \"${fieldId}\".`,\n \"FIELD_ERROR\",\n {\n fieldId\n }\n );\n }\n\n const transformValuePlugin: CmsFieldFilterValueTransformPlugin =\n transformValuePlugins[field.def.type];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field: field.def,\n value\n });\n };\n\n const objectFilteringParams = {\n key,\n value,\n field: field.def\n };\n if (isObjectFiltering(objectFilteringParams)) {\n const propertyFilters = Object.keys(value);\n if (propertyFilters.length === 0) {\n continue;\n }\n for (const propertyFilter of propertyFilters) {\n const whereParams = extractWhereParams(propertyFilter);\n if (!whereParams) {\n continue;\n }\n const {\n fieldId: propertyId,\n operation: propertyOperation,\n negate: propertyNegate\n } = whereParams;\n\n const filterPlugin = getFilterPlugin({\n plugins: filterPlugins,\n operation: propertyOperation\n });\n\n const basePath = createValuePath({\n field: field.def,\n plugins: valuePathPlugins\n });\n\n const multiValuesPath = field.def.multipleValues ? \"%s.\" : \"\";\n\n filters.push({\n fieldId,\n path: `${basePath}.${multiValuesPath}${propertyId}`,\n filterPlugin,\n negate: propertyNegate,\n compareValue: transformValue(value[propertyFilter], transformValueCallable),\n transformValue: transformValueCallable\n });\n }\n\n continue;\n }\n\n const filterPlugin = getFilterPlugin({\n plugins: filterPlugins,\n operation\n });\n\n filters.push({\n fieldId,\n path: createValuePath({\n field: field.def,\n plugins: valuePathPlugins\n }),\n filterPlugin,\n negate,\n compareValue: transformValue(value, transformValueCallable),\n transformValue: transformValueCallable\n });\n }\n\n return filters;\n};\n/**\n * In case filter field is not multiple values one, return exact path.\n * If is multiple values field, use path without the last part\n */\nconst getFilterValuePath = (filter: ItemFilter): string => {\n if (filter.path.includes(\".%s.\") === false) {\n return filter.path;\n }\n const paths = filter.path.split(\".%s.\");\n return paths.shift() as string;\n};\n\nconst getFilterValuePropertyPath = (filter: ItemFilter): string | null => {\n if (filter.path.includes(\".%s.\") === false) {\n return null;\n }\n const paths = filter.path.split(\".%s.\");\n return paths.pop() || null;\n};\n\ninterface ExecFilterParams {\n value: any;\n filter: ItemFilter;\n}\nconst execFilter = (params: ExecFilterParams) => {\n const { value: plainValue, filter } = params;\n\n const value = transformValue(plainValue, filter.transformValue);\n const matched = filter.filterPlugin.matches({\n value,\n compareValue: filter.compareValue\n });\n if (filter.negate) {\n return matched === false;\n }\n return matched;\n};\n\ninterface CreateFullTextSearchParams {\n term?: string;\n fields?: string[];\n plugin: ValueFilterPlugin;\n}\n\ninterface FullTextSearchParams {\n item: CmsEntry;\n fromStorage: FilterItemFromStorage;\n fields: ModelFieldRecords;\n}\n/**\n * Unfortunately we must use the contains plugin directly as plugins do not support multi field searching.\n */\nconst createFullTextSearch = ({\n term,\n fields: targetFields,\n plugin\n}: CreateFullTextSearchParams) => {\n if (!term || term.trim().length === 0 || !targetFields || targetFields.length === 0) {\n return null;\n }\n return async ({ item, fromStorage, fields }: FullTextSearchParams) => {\n for (const targetField of targetFields) {\n const field = Object.values(fields).find(field => {\n return field.def.fieldId === targetField;\n });\n if (!field) {\n throw new WebinyError(\n `Unknown field \"${targetField}\" in the model.`,\n \"UNKNOWN_FIELD\",\n {\n target: targetField\n }\n );\n }\n const value = await fromStorage(field.def, item.values[targetField]);\n if (!value) {\n continue;\n }\n if (plugin.matches({ value, compareValue: term }) === true) {\n return true;\n }\n }\n return false;\n };\n};\n\nexport const filterItems = async (params: FilterItemsParams): Promise<CmsEntry[]> => {\n const { items: records, where, plugins, fields, fromStorage, fullTextSearch } = params;\n\n const filters = createFilters({\n plugins,\n where,\n fields\n });\n\n const fullTextSearchPlugin = plugins\n .byType<ValueFilterPlugin>(ValueFilterPlugin.type)\n .find(plugin => plugin.getOperation() === \"contains\");\n if (!fullTextSearchPlugin) {\n throw new WebinyError(\n `Missing \"contains\" plugin to run the full-text search.`,\n \"MISSING_PLUGIN\"\n );\n }\n\n const search = createFullTextSearch({\n ...fullTextSearch,\n plugin: fullTextSearchPlugin\n });\n\n const promises: Promise<CmsEntry | null>[] = records.map(async record => {\n /**\n * We need to go through all the filters and apply them to the given record.\n */\n for (const filter of filters) {\n /**\n * In case is multiple values field, last part is removed from path.\n * -> values.categories.id -> values.categories\n */\n const valuePath = getFilterValuePath(filter);\n\n const rawValue = dotProp.get(record, valuePath);\n if (valuePath !== filter.path) {\n /**\n * Calculated is different than original because we need to search in the array of objects.\n */\n const propertyPath = getFilterValuePropertyPath(filter);\n if (!propertyPath) {\n console.log(`Cannot determine the property path of \"${filter.path}\".`);\n continue;\n }\n\n const plainValue = await fromStorage<Record<string, string>[]>(\n fields[filter.fieldId].def,\n rawValue\n );\n /**\n * We cannot go through the value because it is not array. Log the error and continue.\n */\n if (Array.isArray(plainValue) === false) {\n console.log(\n `Cannot go through the value on ${valuePath} because it is not an array, and we expect it to be.`\n );\n continue;\n }\n record = dotProp.set(record, valuePath, plainValue);\n\n const values = plainValue.map(value => {\n return value[propertyPath];\n });\n\n const result = execFilter({\n value: values,\n filter\n });\n\n if (!result) {\n return null;\n }\n continue;\n }\n\n const plainValue = await fromStorage(fields[filter.fieldId].def, rawValue);\n /**\n * If raw value is not same as the value after the storage transform, set the value to the items being filtered.\n */\n if (plainValue !== rawValue) {\n record = dotProp.set(record, filter.path, plainValue);\n }\n\n const result = execFilter({\n value: plainValue,\n filter\n });\n if (result === false) {\n return null;\n }\n }\n /**\n * If we have full text search defined, run it. Otherwise just return the given record.\n */\n if (!search) {\n return record;\n }\n const result = await search({\n item: record,\n fromStorage,\n fields\n });\n if (!result) {\n return null;\n }\n\n return record;\n });\n /**\n * We run filtering as promises so it is a bit faster than in for ... of loop.\n */\n const results: (CmsEntry | null)[] = await Promise.all(promises);\n /**\n * And filter out the null values which are returned when filter is not satisfied.\n */\n\n return results.filter(Boolean) as CmsEntry[];\n};\n\ninterface ExtractSortResult {\n valuePath: string;\n reverse: boolean;\n fieldId: string;\n field: ModelField;\n}\n\nconst extractSort = (sortBy: string, fields: ModelFieldRecords): ExtractSortResult => {\n const result = sortBy.split(\"_\");\n if (result.length !== 2) {\n throw new WebinyError(\n \"Problem in determining the sorting for the entry items.\",\n \"SORT_EXTRACT_ERROR\",\n {\n sortBy\n }\n );\n }\n const [fieldId, order] = result;\n\n const modelField = Object.values(fields).find(field => {\n return field.def.fieldId === fieldId;\n });\n\n if (!modelField) {\n throw new WebinyError(\n \"Sorting field does not exist in the content model.\",\n \"SORTING_FIELD_ERROR\",\n {\n fieldId,\n fields\n }\n );\n }\n const valuePath = modelField.createPath({\n field: modelField.def\n });\n return {\n field: modelField,\n fieldId,\n valuePath,\n reverse: order === \"DESC\"\n };\n};\n\ninterface SortEntryItemsArgs {\n items: CmsEntry[];\n sort?: string[];\n fields: ModelFieldRecords;\n}\n\nexport const sortEntryItems = (params: SortEntryItemsArgs): CmsEntry[] => {\n const { items, sort = [], fields } = params;\n if (items.length <= 1) {\n return items;\n } else if (sort.length === 0) {\n sort.push(\"savedOn_DESC\");\n } else if (sort.length > 1) {\n throw new WebinyError(\n \"Sorting is limited to a single field.\",\n \"SORT_MULTIPLE_FIELDS_ERROR\",\n {\n sort: sort\n }\n );\n }\n const [firstSort] = sort;\n if (!firstSort) {\n throw new WebinyError(\"Empty sort array item.\", \"SORT_EMPTY_ERROR\", {\n sort\n });\n }\n\n const { fieldId, field, valuePath, reverse } = extractSort(firstSort, fields);\n\n const itemsToSort = items.map(item => {\n return {\n id: item.id,\n value: field.valueTransformer(dotProp.get(item, valuePath))\n };\n });\n const sortedItems: { id: string; value: any }[] = lodashSortBy(itemsToSort, \"value\");\n const newItems = sortedItems.map(s => {\n const item = items.find(i => i.id === s.id);\n if (item) {\n return item;\n }\n throw new WebinyError(\n \"Could not find item by given id after the sorting.\",\n \"SORTING_ITEMS_ERROR\",\n {\n id: s.id,\n sortingBy: fieldId,\n reverse\n }\n );\n });\n if (!reverse) {\n return newItems;\n }\n return newItems.reverse();\n};\n\nconst getMappedPlugins = <T extends Plugin>(params: {\n plugins: PluginsContainer;\n type: string;\n property: string;\n}): MappedPlugins<T> => {\n const { plugins: pluginsContainer, type, property } = params;\n const plugins = pluginsContainer.byType<T>(type);\n if (plugins.length === 0) {\n throw new WebinyError(`There are no plugins of type \"${type}\".`, \"PLUGINS_ERROR\", {\n type\n });\n }\n return plugins.reduce((collection, plugin) => {\n const key = plugin[property];\n if (typeof key !== \"string\") {\n throw new WebinyError(\n \"Property to map the plugins on must be a string.\",\n \"PLUGIN_PROPERTY_ERROR\",\n {\n type,\n property\n }\n );\n }\n collection[key] = plugin;\n return collection;\n }, {} as MappedPlugins<T>);\n};\n\nexport const buildModelFields = ({\n plugins,\n model\n}: {\n plugins: PluginsContainer;\n model: CmsModel;\n}) => {\n const transformValuePlugins = getMappedPlugins<CmsFieldFilterValueTransformPlugin>({\n plugins,\n type: \"cms-field-filter-value-transform\",\n property: \"fieldType\"\n });\n const valuePathPlugins = getMappedPlugins<CmsEntryFieldFilterPathPlugin>({\n plugins,\n type: CmsEntryFieldFilterPathPlugin.type,\n property: \"fieldType\"\n });\n const fields: ModelFieldRecords = Object.values(systemFields).reduce((collection, field) => {\n /**\n * This should be caught on the tests runs and never actually happen on live system.\n */\n if (!field.fieldId) {\n throw new WebinyError(\"Missing system field `fieldId`.\", \"FIELD_ID_ERROR\", {\n field\n });\n }\n const transformValuePlugin = transformValuePlugins[field.type];\n const valuePathPlugin = valuePathPlugins[field.type];\n\n let createPath: CmsEntryFieldFilterPathPluginParams[\"path\"] = params => {\n return params.field.fieldId;\n };\n if (valuePathPlugin) {\n createPath = params => {\n return valuePathPlugin.createPath(params);\n };\n }\n collection[field.fieldId] = {\n def: field,\n valueTransformer: (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({ field, value });\n },\n createPath,\n isSystemField: true\n };\n\n return collection;\n }, {} as ModelFieldRecords);\n\n return model.fields.reduce((collection, field) => {\n if (!field.fieldId) {\n console.log(\n `Field \"${field.storageId}\" in model \"${model.modelId}\" is missing fieldId.`\n );\n return collection;\n }\n const transformValuePlugin = transformValuePlugins[field.type];\n const valuePathPlugin = valuePathPlugins[field.type];\n\n let createPath: CmsEntryFieldFilterPathPluginParams[\"path\"] = params => {\n return `${VALUES_ATTRIBUTE}.${params.field.fieldId}`;\n };\n if (valuePathPlugin) {\n createPath = params => {\n return valuePathPlugin.createPath(params);\n };\n }\n\n collection[field.fieldId] = {\n def: field,\n valueTransformer: (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({ field, value });\n },\n createPath\n };\n\n return collection;\n }, fields);\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AASA;;AACA;;AAEA;;AA+CA,MAAMA,gBAAgB,GAAG,QAAzB;;AAEA,MAAMC,kBAAkB,GAAIC,GAAD,IAAiB;EAC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from "@webiny/api-headless-cms/types";
|
|
2
2
|
import { Entity } from "dynamodb-toolbox";
|
|
3
3
|
import { PluginsContainer } from "@webiny/plugins";
|
|
4
|
-
|
|
4
|
+
interface CreateGroupsStorageOperationsParams {
|
|
5
5
|
entity: Entity<any>;
|
|
6
6
|
plugins: PluginsContainer;
|
|
7
7
|
}
|
|
8
|
-
export declare const createGroupsStorageOperations: (params:
|
|
8
|
+
export declare const createGroupsStorageOperations: (params: CreateGroupsStorageOperationsParams) => CmsGroupStorageOperations;
|
|
9
|
+
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createGroupsStorageOperations = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
13
|
|
|
@@ -23,10 +23,6 @@ var _ValueFilterPlugin = require("@webiny/db-dynamodb/plugins/definitions/ValueF
|
|
|
23
23
|
|
|
24
24
|
var _sort = require("@webiny/db-dynamodb/utils/sort");
|
|
25
25
|
|
|
26
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
-
|
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
29
|
-
|
|
30
26
|
const createPartitionKey = params => {
|
|
31
27
|
const {
|
|
32
28
|
tenant,
|
|
@@ -71,7 +67,7 @@ const createGroupsStorageOperations = params => {
|
|
|
71
67
|
const keys = createKeys(group);
|
|
72
68
|
|
|
73
69
|
try {
|
|
74
|
-
await entity.put(
|
|
70
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, group), {}, {
|
|
75
71
|
TYPE: createType()
|
|
76
72
|
}, keys));
|
|
77
73
|
return group;
|
|
@@ -86,13 +82,12 @@ const createGroupsStorageOperations = params => {
|
|
|
86
82
|
|
|
87
83
|
const update = async params => {
|
|
88
84
|
const {
|
|
89
|
-
group
|
|
90
|
-
original
|
|
85
|
+
group
|
|
91
86
|
} = params;
|
|
92
87
|
const keys = createKeys(group);
|
|
93
88
|
|
|
94
89
|
try {
|
|
95
|
-
await entity.put(
|
|
90
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, group), {}, {
|
|
96
91
|
TYPE: createType()
|
|
97
92
|
}, keys));
|
|
98
93
|
return group;
|
|
@@ -100,7 +95,6 @@ const createGroupsStorageOperations = params => {
|
|
|
100
95
|
throw new _error.default(ex.message || "Could not update group.", ex.code || "UPDATE_GROUP_ERROR", {
|
|
101
96
|
error: ex,
|
|
102
97
|
group,
|
|
103
|
-
original,
|
|
104
98
|
keys
|
|
105
99
|
});
|
|
106
100
|
}
|
|
@@ -135,7 +129,7 @@ const createGroupsStorageOperations = params => {
|
|
|
135
129
|
});
|
|
136
130
|
return (0, _cleanup.cleanupItem)(entity, group);
|
|
137
131
|
} catch (ex) {
|
|
138
|
-
throw new _error.default(ex.message || "Could not get group.", ex.code || "GET_GROUP_ERROR",
|
|
132
|
+
throw new _error.default(ex.message || "Could not get group.", ex.code || "GET_GROUP_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
139
133
|
error: ex
|
|
140
134
|
}, params), {}, {
|
|
141
135
|
keys
|
|
@@ -160,7 +154,7 @@ const createGroupsStorageOperations = params => {
|
|
|
160
154
|
try {
|
|
161
155
|
records = await (0, _query.queryAll)(queryAllParams);
|
|
162
156
|
} catch (ex) {
|
|
163
|
-
throw new _error.default(ex.message || "Could not list groups.", ex.code || "LIST_GROUP_ERROR",
|
|
157
|
+
throw new _error.default(ex.message || "Could not list groups.", ex.code || "LIST_GROUP_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
164
158
|
error: ex
|
|
165
159
|
}, params), {}, {
|
|
166
160
|
sort,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createPartitionKey","params","tenant","locale","createSortKeys","id","createKeys","PK","SK","createType","createGroupsStorageOperations","entity","plugins","filteringPlugins","byType","ValueFilterPlugin","type","length","WebinyError","create","group","keys","put","TYPE","ex","message","code","error","update","deleteGroup","delete","get","getRecord","cleanupItem","list","sort","where","queryAllParams","partitionKey","options","gte","records","queryAll","filteredItems","filterItems","items","fields","sortItems"],"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 \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\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\";\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\ninterface 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 entity.put({\n ...group,\n TYPE: createType(),\n ...keys\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 entity.put({\n ...group,\n TYPE: createType(),\n ...keys\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 // TODO make sure that group has locale and tenant on it - add it in the crud just in case\n const keys = createKeys(group);\n\n try {\n await entity.delete(keys);\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\n try {\n const group = await getRecord<CmsGroup>({\n entity,\n keys\n });\n\n return cleanupItem(entity, group);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get group.\",\n ex.code || \"GET_GROUP_ERROR\",\n {\n error: ex,\n ...params,\n keys\n }\n );\n }\n };\n const list = async (params: CmsGroupStorageOperationsListParams) => {\n const { sort, where } = params;\n\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey(where),\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\n }\n );\n }\n\n const filteredItems = filterItems({\n items: records,\n where,\n fields: [],\n plugins\n });\n if (!sort || sort.length === 0) {\n return filteredItems;\n }\n 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;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAMA,MAAMA,kBAAkB,GAAIC,MAAD,IAAwC;EAC/D,MAAM;IAAEC,MAAF;IAAUC;EAAV,IAAqBF,MAA3B;EACA,OAAQ,KAAIC,MAAO,MAAKC,MAAO,UAA/B;AACH,CAHD;;AAQA,MAAMC,cAAc,GAAIH,MAAD,IAAmC;EACtD,MAAM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3
|
-
|
|
3
|
+
interface CreateModelsStorageOperationsParams {
|
|
4
4
|
entity: Entity<any>;
|
|
5
5
|
}
|
|
6
|
-
export declare const createModelsStorageOperations: (params:
|
|
6
|
+
export declare const createModelsStorageOperations: (params: CreateModelsStorageOperationsParams) => CmsModelStorageOperations;
|
|
7
|
+
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createModelsStorageOperations = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
13
|
|
|
@@ -17,15 +17,18 @@ var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
|
17
17
|
|
|
18
18
|
var _query = require("@webiny/db-dynamodb/utils/query");
|
|
19
19
|
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
-
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
23
|
-
|
|
24
20
|
const createPartitionKey = params => {
|
|
25
21
|
const {
|
|
26
22
|
tenant,
|
|
27
23
|
locale
|
|
28
24
|
} = params;
|
|
25
|
+
|
|
26
|
+
if (!tenant) {
|
|
27
|
+
throw new _error.default(`Missing tenant variable when creating model partitionKey.`);
|
|
28
|
+
} else if (!locale) {
|
|
29
|
+
throw new _error.default(`Missing locale variable when creating model partitionKey.`);
|
|
30
|
+
}
|
|
31
|
+
|
|
29
32
|
return `T#${tenant}#L#${locale}#CMS#CM`;
|
|
30
33
|
};
|
|
31
34
|
|
|
@@ -56,7 +59,7 @@ const createModelsStorageOperations = params => {
|
|
|
56
59
|
const keys = createKeys(model);
|
|
57
60
|
|
|
58
61
|
try {
|
|
59
|
-
await entity.put(
|
|
62
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _cleanup.cleanupItem)(entity, model)), keys), {}, {
|
|
60
63
|
TYPE: createType()
|
|
61
64
|
}));
|
|
62
65
|
return model;
|
|
@@ -71,21 +74,19 @@ const createModelsStorageOperations = params => {
|
|
|
71
74
|
|
|
72
75
|
const update = async params => {
|
|
73
76
|
const {
|
|
74
|
-
original,
|
|
75
77
|
model
|
|
76
78
|
} = params;
|
|
77
79
|
const keys = createKeys(model);
|
|
78
80
|
|
|
79
81
|
try {
|
|
80
|
-
await entity.put(
|
|
82
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _cleanup.cleanupItem)(entity, model)), keys), {}, {
|
|
81
83
|
TYPE: createType()
|
|
82
84
|
}));
|
|
83
85
|
return model;
|
|
84
86
|
} catch (ex) {
|
|
85
|
-
throw new _error.default(ex.
|
|
87
|
+
throw new _error.default(ex.message || "Could not update model.", ex.code || "MODEL_UPDATE_ERROR", {
|
|
86
88
|
error: ex,
|
|
87
89
|
model,
|
|
88
|
-
original,
|
|
89
90
|
keys
|
|
90
91
|
});
|
|
91
92
|
}
|
|
@@ -101,7 +102,7 @@ const createModelsStorageOperations = params => {
|
|
|
101
102
|
await entity.delete(keys);
|
|
102
103
|
return model;
|
|
103
104
|
} catch (ex) {
|
|
104
|
-
throw new _error.default(ex.
|
|
105
|
+
throw new _error.default(ex.message || "Could not delete model.", ex.code || "MODEL_DELETE_ERROR", {
|
|
105
106
|
error: ex,
|
|
106
107
|
model,
|
|
107
108
|
keys
|
|
@@ -119,7 +120,7 @@ const createModelsStorageOperations = params => {
|
|
|
119
120
|
});
|
|
120
121
|
return (0, _cleanup.cleanupItem)(entity, item);
|
|
121
122
|
} catch (ex) {
|
|
122
|
-
throw new _error.default(ex.
|
|
123
|
+
throw new _error.default(ex.message || "Could not get model.", ex.code || "MODEL_GET_ERROR", {
|
|
123
124
|
error: ex,
|
|
124
125
|
keys
|
|
125
126
|
});
|
|
@@ -142,7 +143,7 @@ const createModelsStorageOperations = params => {
|
|
|
142
143
|
const items = await (0, _query.queryAll)(queryAllParams);
|
|
143
144
|
return (0, _cleanup.cleanupItems)(entity, items);
|
|
144
145
|
} catch (ex) {
|
|
145
|
-
throw new _error.default(ex.
|
|
146
|
+
throw new _error.default(ex.message || "Could not list models.", ex.code || "MODEL_LIST_ERROR", {
|
|
146
147
|
error: ex,
|
|
147
148
|
partitionKey: queryAllParams.partitionKey
|
|
148
149
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createPartitionKey","params","tenant","locale","WebinyError","createSortKey","modelId","createKeys","PK","SK","createType","createModelsStorageOperations","entity","create","model","keys","put","cleanupItem","TYPE","ex","error","update","message","code","deleteModel","delete","get","item","getRecord","list","where","queryAllParams","partitionKey","options","gte","items","queryAll","cleanupItems"],"sources":["index.ts"],"sourcesContent":["import {\n CmsModel,\n CmsModelStorageOperations,\n CmsModelStorageOperationsCreateParams,\n CmsModelStorageOperationsDeleteParams,\n CmsModelStorageOperationsGetParams,\n CmsModelStorageOperationsListParams,\n CmsModelStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem, cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\n\ninterface PartitionKeysParams {\n tenant: string;\n locale: string;\n}\nconst createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant, locale } = params;\n if (!tenant) {\n throw new WebinyError(`Missing tenant variable when creating model partitionKey.`);\n } else if (!locale) {\n throw new WebinyError(`Missing locale variable when creating model partitionKey.`);\n }\n return `T#${tenant}#L#${locale}#CMS#CM`;\n};\n\ninterface SortKeyParams {\n modelId: string;\n}\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\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\ninterface CreateModelsStorageOperationsParams {\n entity: Entity<any>;\n}\nexport const createModelsStorageOperations = (\n params: CreateModelsStorageOperationsParams\n): CmsModelStorageOperations => {\n const { entity } = params;\n\n const create = async (params: CmsModelStorageOperationsCreateParams) => {\n const { model } = params;\n\n const keys = createKeys(model);\n\n try {\n await entity.put({\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n throw new WebinyError(`Could not create CMS Content Model.`, \"CREATE_MODEL_ERROR\", {\n error: ex,\n model,\n keys\n });\n }\n };\n\n const update = async (params: CmsModelStorageOperationsUpdateParams) => {\n const { model } = params;\n\n const keys = createKeys(model);\n\n try {\n await entity.put({\n ...cleanupItem(entity, model),\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update model.\",\n ex.code || \"MODEL_UPDATE_ERROR\",\n {\n error: ex,\n model,\n keys\n }\n );\n }\n };\n\n const deleteModel = async (params: CmsModelStorageOperationsDeleteParams) => {\n const { model } = params;\n const keys = createKeys(model);\n\n try {\n await entity.delete(keys);\n return model;\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\n const get = async (params: CmsModelStorageOperationsGetParams) => {\n const keys = createKeys(params);\n\n try {\n const item = await getRecord<CmsModel>({\n entity,\n keys\n });\n return cleanupItem(entity, item);\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 const items = await queryAll<CmsModel>(queryAllParams);\n\n return cleanupItems(entity, items);\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":";;;;;;;;;;;AAUA;;AACA;;AACA;;AACA;;AAMA,MAAMA,kBAAkB,GAAIC,MAAD,IAAyC;EAChE,MAAM;IAAEC,MAAF;IAAUC;EAAV,IAAqBF,MAA3B;;EACA,IAAI,CAACC,MAAL,EAAa;IACT,MAAM,IAAIE,cAAJ,CAAiB,2DAAjB,CAAN;EACH,CAFD,MAEO,IAAI,CAACD,MAAL,EAAa;IAChB,MAAM,IAAIC,cAAJ,CAAiB,2DAAjB,CAAN;EACH;;EACD,OAAQ,KAAIF,MAAO,MAAKC,MAAO,SAA/B;AACH,CARD;;AAaA,MAAME,aA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AEnCoB,YAAY,EAAEhC,kBAAkB,CAAC8B,KAAD,CAFG;MAGnCG,OAAO,EAAE;QACLC,GAAG,EAAE;MADA;IAH0B,CAAvC;;IAOA,IAAI;MACA,MAAMC,KAAK,GAAG,MAAM,IAAAC,eAAA,EAAmBL,cAAnB,CAApB;MAEA,OAAO,IAAAM,qBAAA,EAAazB,MAAb,EAAqBuB,KAArB,CAAP;IACH,CAJD,CAIE,OAAOhB,EAAP,EAAW;MACT,MAAM,IAAIf,cAAJ,CACFe,EAAE,CAACG,OAAH,IAAc,wBADZ,EAEFH,EAAE,CAACI,IAAH,IAAW,kBAFT,EAGF;QACIH,KAAK,EAAED,EADX;QAEIa,YAAY,EAAED,cAAc,CAACC;MAFjC,CAHE,CAAN;IAQH;EACJ,CAvBD;;EAyBA,OAAO;IACHnB,MADG;IAEHQ,MAFG;IAGHI,MAAM,EAAED,WAHL;IAIHE,GAJG;IAKHG;EALG,CAAP;AAOH,CA5HM"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CmsSettingsStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
2
|
import { Entity } from "dynamodb-toolbox";
|
|
3
|
-
|
|
3
|
+
interface CreateSettingsStorageOperationsParams {
|
|
4
4
|
entity: Entity<any>;
|
|
5
5
|
}
|
|
6
|
-
export declare const createSettingsStorageOperations: (params:
|
|
6
|
+
export declare const createSettingsStorageOperations: (params: CreateSettingsStorageOperationsParams) => CmsSettingsStorageOperations;
|
|
7
|
+
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createSettingsStorageOperations = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _get = require("@webiny/db-dynamodb/utils/get");
|
|
13
13
|
|
|
@@ -15,12 +15,8 @@ var _error = _interopRequireDefault(require("@webiny/error"));
|
|
|
15
15
|
|
|
16
16
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
17
17
|
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
21
|
-
|
|
22
18
|
const convertToDbData = settings => {
|
|
23
|
-
return
|
|
19
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
|
24
20
|
contentModelLastChange: settings.contentModelLastChange.toISOString()
|
|
25
21
|
});
|
|
26
22
|
};
|
|
@@ -38,7 +34,7 @@ const convertFromDbData = settings => {
|
|
|
38
34
|
contentModelLastChange = new Date();
|
|
39
35
|
}
|
|
40
36
|
|
|
41
|
-
return
|
|
37
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings), {}, {
|
|
42
38
|
contentModelLastChange
|
|
43
39
|
});
|
|
44
40
|
};
|
|
@@ -74,7 +70,7 @@ const createSettingsStorageOperations = params => {
|
|
|
74
70
|
const dbSettings = convertToDbData(settings);
|
|
75
71
|
|
|
76
72
|
try {
|
|
77
|
-
await entity.put(
|
|
73
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
|
|
78
74
|
return settings;
|
|
79
75
|
} catch (ex) {
|
|
80
76
|
throw new _error.default(ex.message || "Could not create settings.", ex.code || "CREATE_SETTINGS_ERROR", {
|
|
@@ -88,21 +84,19 @@ const createSettingsStorageOperations = params => {
|
|
|
88
84
|
|
|
89
85
|
const update = async params => {
|
|
90
86
|
const {
|
|
91
|
-
settings
|
|
92
|
-
original
|
|
87
|
+
settings
|
|
93
88
|
} = params;
|
|
94
89
|
const keys = createKeys(settings);
|
|
95
90
|
const dbSettings = convertToDbData(settings);
|
|
96
91
|
|
|
97
92
|
try {
|
|
98
|
-
await entity.put(
|
|
93
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, dbSettings), keys));
|
|
99
94
|
return settings;
|
|
100
95
|
} catch (ex) {
|
|
101
96
|
throw new _error.default(ex.message || "Could not update settings.", ex.code || "UPDATE_SETTINGS_ERROR", {
|
|
102
97
|
error: ex,
|
|
103
98
|
settings,
|
|
104
99
|
dbSettings,
|
|
105
|
-
original,
|
|
106
100
|
keys
|
|
107
101
|
});
|
|
108
102
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["convertToDbData","settings","contentModelLastChange","toISOString","convertFromDbData","Date","createPartitionKey","tenant","locale","createSortKey","createKeys","params","PK","SK","createSettingsStorageOperations","entity","create","keys","dbSettings","put","ex","WebinyError","message","code","error","update","get","record","getRecord","cleanupItem"],"sources":["index.ts"],"sourcesContent":["import {\n CmsSettings,\n CmsSettingsStorageOperations,\n CmsSettingsStorageOperationsCreateParams,\n CmsSettingsStorageOperationsGetParams,\n CmsSettingsStorageOperationsUpdateParams\n} from \"@webiny/api-headless-cms/types\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport WebinyError from \"@webiny/error\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface CmsSettingsDb extends Omit<CmsSettings, \"contentModelLastChange\"> {\n contentModelLastChange: string;\n}\n\nconst convertToDbData = (settings: CmsSettings): CmsSettingsDb => {\n return {\n ...settings,\n contentModelLastChange: settings.contentModelLastChange.toISOString()\n };\n};\n\nconst convertFromDbData = (settings?: CmsSettingsDb): CmsSettings | null => {\n if (!settings) {\n return null;\n }\n let contentModelLastChange;\n try {\n contentModelLastChange = new Date(settings.contentModelLastChange);\n } catch {\n contentModelLastChange = new Date();\n }\n return {\n ...settings,\n contentModelLastChange\n };\n};\n\ninterface PartitionKeyParams {\n tenant: string;\n locale: string;\n}\n\nconst createPartitionKey = ({ tenant, locale }: PartitionKeyParams): string => {\n return `T#${tenant}#L#${locale}#CMS#SETTINGS`;\n};\n\nconst createSortKey = (): string => {\n return \"settings\";\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\ninterface CreateSettingsStorageOperationsParams {\n entity: Entity<any>;\n}\n\nexport const createSettingsStorageOperations = (\n params: CreateSettingsStorageOperationsParams\n): CmsSettingsStorageOperations => {\n const { entity } = params;\n\n const create = async (params: CmsSettingsStorageOperationsCreateParams) => {\n const { settings } = params;\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create settings.\",\n ex.code || \"CREATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const update = async (params: CmsSettingsStorageOperationsUpdateParams) => {\n const { settings } = params;\n\n const keys = createKeys(settings);\n\n const dbSettings: CmsSettingsDb = convertToDbData(settings);\n\n try {\n await entity.put({\n ...dbSettings,\n ...keys\n });\n return settings;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update settings.\",\n ex.code || \"UPDATE_SETTINGS_ERROR\",\n {\n error: ex,\n settings,\n dbSettings,\n keys\n }\n );\n }\n };\n\n const get = async (params: CmsSettingsStorageOperationsGetParams) => {\n const keys = createKeys(params);\n try {\n const record = await getRecord<CmsSettingsDb>({\n entity,\n keys\n });\n if (!record) {\n return null;\n }\n const settings = cleanupItem(entity, record) as CmsSettingsDb;\n return convertFromDbData(settings);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get settings.\",\n ex.code || \"GET_SETTINGS_ERROR\",\n {\n error: ex,\n keys\n }\n );\n }\n };\n\n return {\n create,\n get,\n update\n };\n};\n"],"mappings":";;;;;;;;;;;AAQA;;AACA;;AACA;;AAMA,MAAMA,eAAe,GAAIC,QAAD,IAA0C;EAC9D,mEACOA,QADP;IAEIC,sBAAsB,EAAED,QAAQ,CAACC,sBAAT,CAAgCC,WAAhC;EAF5B;AAIH,CALD;;AAOA,MAAMC,iBAAiB,GAAIH,QAAD,IAAkD;EACxE,IAAI,CAACA,QAAL,EAAe;IACX,OAAO,IAAP;EACH;;EACD,IAAIC,sBAAJ;;EACA,IAAI;IACAA,sBAAsB,GAAG,IAAIG,IAAJ,CAASJ,QAAQ,CAACC,sBAAlB,CAAzB;EACH,CAFD,CAEE,MAAM;IACJA,sBAAsB,GAAG,IAAIG,IAAJ,EAAzB;EACH;;EACD,mEACOJ,QADP;IAEIC;EAFJ;AAIH,CAdD;;AAqBA,MAAMI,kBAAkB,GAAG,CAAC;EAAEC,MAAF;EAAUC;AAAV,CAAD,KAAoD;EAC3E,OAAQ,KAAID,MAAO,MAAKC,MAAO,eAA/B;AACH,CAFD;;AAIA,MAAMC,aAAa,GAAG,MAAc;EAChC,OAAO,UAAP;AACH,CAFD;;AAQA,MAAMC,UAAU,GAAIC,MAAD,IAAsC;EACrD,OAAO;IACHC,EAAE,EAAEN,kBAAkB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AG,GAAG,MAAOf,MAAP,IAAyD;IACjE,MAAMM,IAAI,GAAGP,UAAU,CAACC,MAAD,CAAvB;;IACA,IAAI;MACA,MAAMgB,MAAM,GAAG,MAAM,IAAAC,QAAA,EAAyB;QAC1Cb,MAD0C;QAE1CE;MAF0C,CAAzB,CAArB;;MAIA,IAAI,CAACU,MAAL,EAAa;QACT,OAAO,IAAP;MACH;;MACD,MAAM1B,QAAQ,GAAG,IAAA4B,oBAAA,EAAYd,MAAZ,EAAoBY,MAApB,CAAjB;MACA,OAAOvB,iBAAiB,CAACH,QAAD,CAAxB;IACH,CAVD,CAUE,OAAOmB,EAAP,EAAW;MACT,MAAM,IAAIC,cAAJ,CACFD,EAAE,CAACE,OAAH,IAAc,yBADZ,EAEFF,EAAE,CAACG,IAAH,IAAW,oBAFT,EAGF;QACIC,KAAK,EAAEJ,EADX;QAEIH;MAFJ,CAHE,CAAN;IAQH;EACJ,CAtBD;;EAwBA,OAAO;IACHD,MADG;IAEHU,GAFG;IAGHD;EAHG,CAAP;AAKH,CAvFM"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CmsSystemStorageOperations } from "@webiny/api-headless-cms/types";
|
|
2
2
|
import { Entity } from "dynamodb-toolbox";
|
|
3
|
-
|
|
3
|
+
interface CreateSystemStorageOperationsParams {
|
|
4
4
|
entity: Entity<any>;
|
|
5
5
|
}
|
|
6
|
-
export declare const createSystemStorageOperations: (params:
|
|
6
|
+
export declare const createSystemStorageOperations: (params: CreateSystemStorageOperationsParams) => CmsSystemStorageOperations;
|
|
7
|
+
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.createSystemStorageOperations = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
11
|
|
|
12
12
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
13
|
|
|
@@ -15,10 +15,6 @@ var _get = require("@webiny/db-dynamodb/utils/get");
|
|
|
15
15
|
|
|
16
16
|
var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
|
|
17
17
|
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
-
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
21
|
-
|
|
22
18
|
const createPartitionKey = ({
|
|
23
19
|
tenant
|
|
24
20
|
}) => {
|
|
@@ -47,7 +43,7 @@ const createSystemStorageOperations = params => {
|
|
|
47
43
|
const keys = createKeys(system);
|
|
48
44
|
|
|
49
45
|
try {
|
|
50
|
-
await entity.put(
|
|
46
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
|
|
51
47
|
return system;
|
|
52
48
|
} catch (ex) {
|
|
53
49
|
throw new _error.default(ex.message || "Could not create system.", ex.code || "CREATE_SYSTEM_ERROR", {
|
|
@@ -60,19 +56,17 @@ const createSystemStorageOperations = params => {
|
|
|
60
56
|
|
|
61
57
|
const update = async params => {
|
|
62
58
|
const {
|
|
63
|
-
system
|
|
64
|
-
original
|
|
59
|
+
system
|
|
65
60
|
} = params;
|
|
66
61
|
const keys = createKeys(system);
|
|
67
62
|
|
|
68
63
|
try {
|
|
69
|
-
await entity.put(
|
|
64
|
+
await entity.put((0, _objectSpread2.default)((0, _objectSpread2.default)({}, system), keys));
|
|
70
65
|
return system;
|
|
71
66
|
} catch (ex) {
|
|
72
67
|
throw new _error.default(ex.message || "Could not update system.", ex.code || "UPDATE_SYSTEM_ERROR", {
|
|
73
68
|
error: ex,
|
|
74
69
|
system,
|
|
75
|
-
original,
|
|
76
70
|
keys
|
|
77
71
|
});
|
|
78
72
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createPartitionKey","tenant","toLowerCase","createSortKey","createKeys","params","PK","SK","createSystemStorageOperations","entity","create","system","keys","put","ex","WebinyError","message","code","error","update","get","getRecord","cleanupItem"],"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 \"dynamodb-toolbox\";\nimport WebinyError from \"@webiny/error\";\nimport { get as getRecord } from \"@webiny/db-dynamodb/utils/get\";\nimport { cleanupItem } from \"@webiny/db-dynamodb/utils/cleanup\";\n\ninterface 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 entity.put({\n ...system,\n ...keys\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 entity.put({\n ...system,\n ...keys\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 const system = await getRecord<CmsSystem>({\n entity,\n keys\n });\n return cleanupItem(entity, system);\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;;AACA;;AACA;;AASA,MAAMA,kBAAkB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAA4C;EACnE,OAAQ,KAAIA,MAAM,CAACC,WAAP,EAAqB,SAAjC;AACH,CAFD;;AAGA,MAAMC,aAAa,GAAG,MAAc;EAChC,OAAO,KAAP;AACH,CAFD;;AAQA,MAAMC,UAAU,GAAIC,MAAD,IAAsC;EACrD,OAAO;IACHC,EAAE,EAAEN,kBAAkB,CAACK,MAAD,CADnB;IAEHE,EAAE,EAAEJ,aAAa;EAFd,CAAP;AAIH,CALD;;AAOO,MAAMK,6BAA6B,GACtCH,MADyC,IAEZ;EAC7B,MAAM;IAAEI;EAAF,IAAaJ,MAAnB;;EAEA,MAAMK,MAAM,GAAG,OAAO;IAAEC;EAAF,CAAP,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AFT,EAGF;QACIC,KAAK,EAAEJ,EADX;QAEIF;MAFJ,CAHE,CAAN;IAQH;EACJ,CAnBD;;EAqBA,OAAO;IACHF,MADG;IAEHS,MAFG;IAGHC;EAHG,CAAP;AAKH,CA5EM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms-ddb",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-unstable.40876133bb",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"@webiny/api-headless-cms",
|
|
@@ -21,33 +21,32 @@
|
|
|
21
21
|
],
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@babel/runtime": "7.
|
|
25
|
-
"@webiny/api-headless-cms": "0.0.0-
|
|
26
|
-
"@webiny/db-dynamodb": "0.0.0-
|
|
27
|
-
"@webiny/error": "0.0.0-
|
|
28
|
-
"@webiny/handler-db": "0.0.0-
|
|
29
|
-
"@webiny/utils": "0.0.0-
|
|
30
|
-
"aws-sdk": "2.
|
|
31
|
-
"dataloader": "2.
|
|
32
|
-
"dot-prop": "
|
|
33
|
-
"dynamodb-toolbox": "0.3.
|
|
24
|
+
"@babel/runtime": "7.19.0",
|
|
25
|
+
"@webiny/api-headless-cms": "0.0.0-unstable.40876133bb",
|
|
26
|
+
"@webiny/db-dynamodb": "0.0.0-unstable.40876133bb",
|
|
27
|
+
"@webiny/error": "0.0.0-unstable.40876133bb",
|
|
28
|
+
"@webiny/handler-db": "0.0.0-unstable.40876133bb",
|
|
29
|
+
"@webiny/utils": "0.0.0-unstable.40876133bb",
|
|
30
|
+
"aws-sdk": "2.1230.0",
|
|
31
|
+
"dataloader": "2.1.0",
|
|
32
|
+
"dot-prop": "6.0.1",
|
|
33
|
+
"dynamodb-toolbox": "0.3.5",
|
|
34
34
|
"jsonpack": "1.1.5",
|
|
35
|
-
"lodash
|
|
35
|
+
"lodash": "4.17.21"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@babel/cli": "^7.
|
|
39
|
-
"@babel/core": "^7.
|
|
40
|
-
"@babel/preset-env": "^7.
|
|
41
|
-
"@babel/preset-flow": "^7.0.0",
|
|
38
|
+
"@babel/cli": "^7.19.3",
|
|
39
|
+
"@babel/core": "^7.19.3",
|
|
40
|
+
"@babel/preset-env": "^7.19.4",
|
|
42
41
|
"@types/jsonpack": "^1.1.0",
|
|
43
|
-
"@webiny/cli": "^0.0.0-
|
|
44
|
-
"@webiny/plugins": "^0.0.0-
|
|
45
|
-
"@webiny/project-utils": "^0.0.0-
|
|
46
|
-
"jest": "^
|
|
42
|
+
"@webiny/cli": "^0.0.0-unstable.40876133bb",
|
|
43
|
+
"@webiny/plugins": "^0.0.0-unstable.40876133bb",
|
|
44
|
+
"@webiny/project-utils": "^0.0.0-unstable.40876133bb",
|
|
45
|
+
"jest": "^28.1.0",
|
|
47
46
|
"jest-dynalite": "^3.2.0",
|
|
48
|
-
"jest-environment-node": "^
|
|
47
|
+
"jest-environment-node": "^27.2.4",
|
|
49
48
|
"ttypescript": "^1.5.12",
|
|
50
|
-
"typescript": "
|
|
49
|
+
"typescript": "4.7.4"
|
|
51
50
|
},
|
|
52
51
|
"publishConfig": {
|
|
53
52
|
"access": "public",
|
|
@@ -57,5 +56,5 @@
|
|
|
57
56
|
"build": "yarn webiny run build",
|
|
58
57
|
"watch": "yarn webiny run watch"
|
|
59
58
|
},
|
|
60
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "f33811072795d25c5787ae39808e75e3312fb247"
|
|
61
60
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
+
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
3
|
+
export interface CreatePathCallableParams {
|
|
4
|
+
field: CmsModelField;
|
|
5
|
+
index?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface CreatePathCallable {
|
|
8
|
+
(params: CreatePathCallableParams): string;
|
|
9
|
+
}
|
|
10
|
+
export interface CmsEntryFieldFilterPathPluginParams {
|
|
11
|
+
fieldType: string;
|
|
12
|
+
fieldId?: string[];
|
|
13
|
+
path: string | CreatePathCallable;
|
|
14
|
+
}
|
|
15
|
+
export declare class CmsEntryFieldFilterPathPlugin extends Plugin {
|
|
16
|
+
static readonly type: string;
|
|
17
|
+
private readonly config;
|
|
18
|
+
get fieldType(): string;
|
|
19
|
+
constructor(config: CmsEntryFieldFilterPathPluginParams);
|
|
20
|
+
canUse(field: CmsModelField): boolean;
|
|
21
|
+
createPath(params: CreatePathCallableParams): string;
|
|
22
|
+
}
|