@webiny/api-headless-cms-ddb 0.0.0-unstable.df7a8bb475 → 0.0.0-unstable.e1999482d0
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/abstractions/CmsDdbDataLoaders.d.ts +5 -0
- package/abstractions/CmsDdbDataLoaders.js +5 -0
- package/abstractions/CmsDdbDataLoaders.js.map +1 -0
- package/abstractions/CmsDdbEntryEntity.d.ts +5 -0
- package/abstractions/CmsDdbEntryEntity.js +5 -0
- package/abstractions/CmsDdbEntryEntity.js.map +1 -0
- package/abstractions/CmsDdbGroupEntity.d.ts +5 -0
- package/abstractions/CmsDdbGroupEntity.js +5 -0
- package/abstractions/CmsDdbGroupEntity.js.map +1 -0
- package/abstractions/CmsDdbModelEntity.d.ts +5 -0
- package/abstractions/CmsDdbModelEntity.js +5 -0
- package/abstractions/CmsDdbModelEntity.js.map +1 -0
- package/abstractions/CmsDdbTable.d.ts +5 -0
- package/abstractions/CmsDdbTable.js +5 -0
- package/abstractions/CmsDdbTable.js.map +1 -0
- package/definitions/entry.js +7 -9
- package/definitions/entry.js.map +1 -1
- package/definitions/group.js +7 -9
- package/definitions/group.js.map +1 -1
- package/definitions/model.js +7 -9
- package/definitions/model.js.map +1 -1
- package/definitions/table.js +6 -7
- package/definitions/table.js.map +1 -1
- package/definitions/types.d.ts +11 -5
- package/definitions/types.js +0 -3
- package/index.d.ts +10 -3
- package/index.js +40 -85
- package/index.js.map +1 -1
- package/operations/entry/DdbCreateEntry.d.ts +16 -0
- package/operations/entry/DdbCreateEntry.js +77 -0
- package/operations/entry/DdbCreateEntry.js.map +1 -0
- package/operations/entry/DdbCreateEntryRevisionFrom.d.ts +16 -0
- package/operations/entry/DdbCreateEntryRevisionFrom.js +85 -0
- package/operations/entry/DdbCreateEntryRevisionFrom.js.map +1 -0
- package/operations/entry/DdbDeleteEntry.d.ts +16 -0
- package/operations/entry/DdbDeleteEntry.js +65 -0
- package/operations/entry/DdbDeleteEntry.js.map +1 -0
- package/operations/entry/DdbDeleteEntryRevision.d.ts +17 -0
- package/operations/entry/DdbDeleteEntryRevision.js +91 -0
- package/operations/entry/DdbDeleteEntryRevision.js.map +1 -0
- package/operations/entry/DdbDeleteMultipleEntries.d.ts +16 -0
- package/operations/entry/DdbDeleteMultipleEntries.js +59 -0
- package/operations/entry/DdbDeleteMultipleEntries.js.map +1 -0
- package/operations/entry/DdbGetEntriesByIds.d.ts +14 -0
- package/operations/entry/DdbGetEntriesByIds.js +31 -0
- package/operations/entry/DdbGetEntriesByIds.js.map +1 -0
- package/operations/entry/DdbGetEntry.d.ts +14 -0
- package/operations/entry/DdbGetEntry.js +27 -0
- package/operations/entry/DdbGetEntry.js.map +1 -0
- package/operations/entry/DdbGetLatestEntriesByIds.d.ts +14 -0
- package/operations/entry/DdbGetLatestEntriesByIds.js +31 -0
- package/operations/entry/DdbGetLatestEntriesByIds.js.map +1 -0
- package/operations/entry/DdbGetLatestRevisionByEntryId.d.ts +14 -0
- package/operations/entry/DdbGetLatestRevisionByEntryId.js +35 -0
- package/operations/entry/DdbGetLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/DdbGetPreviousRevision.d.ts +14 -0
- package/operations/entry/DdbGetPreviousRevision.js +53 -0
- package/operations/entry/DdbGetPreviousRevision.js.map +1 -0
- package/operations/entry/DdbGetPublishedEntriesByIds.d.ts +14 -0
- package/operations/entry/DdbGetPublishedEntriesByIds.js +31 -0
- package/operations/entry/DdbGetPublishedEntriesByIds.js.map +1 -0
- package/operations/entry/DdbGetPublishedRevisionByEntryId.d.ts +14 -0
- package/operations/entry/DdbGetPublishedRevisionByEntryId.js +35 -0
- package/operations/entry/DdbGetPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/DdbGetRevisionById.d.ts +14 -0
- package/operations/entry/DdbGetRevisionById.js +34 -0
- package/operations/entry/DdbGetRevisionById.js.map +1 -0
- package/operations/entry/DdbGetRevisions.d.ts +14 -0
- package/operations/entry/DdbGetRevisions.js +33 -0
- package/operations/entry/DdbGetRevisions.js.map +1 -0
- package/operations/entry/DdbGetUniqueFieldValues.d.ts +12 -0
- package/operations/entry/DdbGetUniqueFieldValues.js +31 -0
- package/operations/entry/DdbGetUniqueFieldValues.js.map +1 -0
- package/operations/entry/DdbListEntries.d.ts +30 -0
- package/operations/entry/DdbListEntries.js +133 -0
- package/operations/entry/DdbListEntries.js.map +1 -0
- package/operations/entry/DdbMoveEntry.d.ts +16 -0
- package/operations/entry/DdbMoveEntry.js +63 -0
- package/operations/entry/DdbMoveEntry.js.map +1 -0
- package/operations/entry/DdbMoveToBin.d.ts +16 -0
- package/operations/entry/DdbMoveToBin.js +77 -0
- package/operations/entry/DdbMoveToBin.js.map +1 -0
- package/operations/entry/DdbPublishEntry.d.ts +18 -0
- package/operations/entry/DdbPublishEntry.js +162 -0
- package/operations/entry/DdbPublishEntry.js.map +1 -0
- package/operations/entry/DdbRestoreFromBin.d.ts +16 -0
- package/operations/entry/DdbRestoreFromBin.js +78 -0
- package/operations/entry/DdbRestoreFromBin.js.map +1 -0
- package/operations/entry/DdbUnpublishEntry.d.ts +17 -0
- package/operations/entry/DdbUnpublishEntry.js +112 -0
- package/operations/entry/DdbUnpublishEntry.js.map +1 -0
- package/operations/entry/DdbUpdateEntry.d.ts +17 -0
- package/operations/entry/DdbUpdateEntry.js +105 -0
- package/operations/entry/DdbUpdateEntry.js.map +1 -0
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +22 -29
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/constants.js +2 -1
- package/operations/entry/dataLoader/constants.js.map +1 -1
- package/operations/entry/dataLoader/createBatchScheduleFn.js +6 -15
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
- package/operations/entry/dataLoader/getAllEntryRevisions.js +18 -26
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +32 -38
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +32 -38
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.js +34 -44
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/index.js +8 -9
- package/operations/entry/dataLoader/index.js.map +1 -1
- package/operations/entry/dataLoader/types.d.ts +1 -0
- package/operations/entry/dataLoader/types.js +0 -3
- package/operations/entry/dataLoaders.d.ts +7 -6
- package/operations/entry/dataLoaders.js +89 -97
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/feature.d.ts +4 -0
- package/operations/entry/feature.js +55 -0
- package/operations/entry/feature.js.map +1 -0
- package/operations/entry/keys.d.ts +6 -0
- package/operations/entry/keys.js +57 -77
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/storageEntryUtils.d.ts +8 -0
- package/operations/entry/storageEntryUtils.js +25 -0
- package/operations/entry/storageEntryUtils.js.map +1 -0
- package/operations/group/DdbCreateGroup.d.ts +12 -0
- package/operations/group/DdbCreateGroup.js +35 -0
- package/operations/group/DdbCreateGroup.js.map +1 -0
- package/operations/group/DdbDeleteGroup.d.ts +12 -0
- package/operations/group/DdbDeleteGroup.js +31 -0
- package/operations/group/DdbDeleteGroup.js.map +1 -0
- package/operations/group/DdbGetGroup.d.ts +12 -0
- package/operations/group/DdbGetGroup.js +31 -0
- package/operations/group/DdbGetGroup.js.map +1 -0
- package/operations/group/DdbListGroups.d.ts +14 -0
- package/operations/group/DdbListGroups.js +52 -0
- package/operations/group/DdbListGroups.js.map +1 -0
- package/operations/group/DdbUpdateGroup.d.ts +12 -0
- package/operations/group/DdbUpdateGroup.js +35 -0
- package/operations/group/DdbUpdateGroup.js.map +1 -0
- package/operations/group/feature.d.ts +4 -0
- package/operations/group/feature.js +19 -0
- package/operations/group/feature.js.map +1 -0
- package/operations/group/keys.d.ts +15 -0
- package/operations/group/keys.js +17 -0
- package/operations/group/keys.js.map +1 -0
- package/operations/model/DdbCreateModel.d.ts +12 -0
- package/operations/model/DdbCreateModel.js +37 -0
- package/operations/model/DdbCreateModel.js.map +1 -0
- package/operations/model/DdbDeleteModel.d.ts +12 -0
- package/operations/model/DdbDeleteModel.js +31 -0
- package/operations/model/DdbDeleteModel.js.map +1 -0
- package/operations/model/DdbGetModel.d.ts +12 -0
- package/operations/model/DdbGetModel.js +30 -0
- package/operations/model/DdbGetModel.js.map +1 -0
- package/operations/model/DdbListModels.d.ts +12 -0
- package/operations/model/DdbListModels.js +36 -0
- package/operations/model/DdbListModels.js.map +1 -0
- package/operations/model/DdbUpdateModel.d.ts +12 -0
- package/operations/model/DdbUpdateModel.js +36 -0
- package/operations/model/DdbUpdateModel.js.map +1 -0
- package/operations/model/feature.d.ts +4 -0
- package/operations/model/feature.js +19 -0
- package/operations/model/feature.js.map +1 -0
- package/operations/model/keys.d.ts +15 -0
- package/operations/model/keys.js +16 -0
- package/operations/model/keys.js.map +1 -0
- package/package.json +26 -22
- package/types.d.ts +10 -48
- package/types.js +6 -5
- package/types.js.map +1 -1
- package/definitions/types.js.map +0 -1
- package/dynamoDb/index.d.ts +0 -2
- package/dynamoDb/index.js +0 -8
- package/dynamoDb/index.js.map +0 -1
- package/dynamoDb/path/locationFolderId.d.ts +0 -2
- package/dynamoDb/path/locationFolderId.js +0 -34
- package/dynamoDb/path/locationFolderId.js.map +0 -1
- package/dynamoDb/path/plainObject.d.ts +0 -2
- package/dynamoDb/path/plainObject.js +0 -26
- package/dynamoDb/path/plainObject.js.map +0 -1
- package/dynamoDb/storage/longText.d.ts +0 -10
- package/dynamoDb/storage/longText.js +0 -86
- package/dynamoDb/storage/longText.js.map +0 -1
- package/dynamoDb/storage/richText.d.ts +0 -2
- package/dynamoDb/storage/richText.js +0 -52
- package/dynamoDb/storage/richText.js.map +0 -1
- package/dynamoDb/transformValue/datetime.d.ts +0 -5
- package/dynamoDb/transformValue/datetime.js +0 -40
- package/dynamoDb/transformValue/datetime.js.map +0 -1
- package/operations/entry/dataLoader/types.js.map +0 -1
- package/operations/entry/filtering/createExpressions.d.ts +0 -26
- package/operations/entry/filtering/createExpressions.js +0 -175
- package/operations/entry/filtering/createExpressions.js.map +0 -1
- package/operations/entry/filtering/createFields.d.ts +0 -16
- package/operations/entry/filtering/createFields.js +0 -106
- package/operations/entry/filtering/createFields.js.map +0 -1
- package/operations/entry/filtering/extractSort.d.ts +0 -17
- package/operations/entry/filtering/extractSort.js +0 -84
- package/operations/entry/filtering/extractSort.js.map +0 -1
- package/operations/entry/filtering/filter.d.ts +0 -15
- package/operations/entry/filtering/filter.js +0 -150
- package/operations/entry/filtering/filter.js.map +0 -1
- package/operations/entry/filtering/fullTextSearch.d.ts +0 -14
- package/operations/entry/filtering/fullTextSearch.js +0 -42
- package/operations/entry/filtering/fullTextSearch.js.map +0 -1
- package/operations/entry/filtering/getValue.d.ts +0 -5
- package/operations/entry/filtering/getValue.js +0 -59
- package/operations/entry/filtering/getValue.js.map +0 -1
- package/operations/entry/filtering/index.d.ts +0 -2
- package/operations/entry/filtering/index.js +0 -4
- package/operations/entry/filtering/index.js.map +0 -1
- package/operations/entry/filtering/mapPlugins.d.ts +0 -8
- package/operations/entry/filtering/mapPlugins.js +0 -25
- package/operations/entry/filtering/mapPlugins.js.map +0 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -37
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +0 -1
- package/operations/entry/filtering/plugins/index.d.ts +0 -1
- package/operations/entry/filtering/plugins/index.js +0 -9
- package/operations/entry/filtering/plugins/index.js.map +0 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -84
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +0 -1
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +0 -3
- package/operations/entry/filtering/plugins/refFilterCreate.js +0 -74
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +0 -1
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +0 -2
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +0 -57
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +0 -1
- package/operations/entry/filtering/sort.d.ts +0 -12
- package/operations/entry/filtering/sort.js +0 -67
- package/operations/entry/filtering/sort.js.map +0 -1
- package/operations/entry/filtering/systemFields.d.ts +0 -2
- package/operations/entry/filtering/systemFields.js +0 -116
- package/operations/entry/filtering/systemFields.js.map +0 -1
- package/operations/entry/filtering/transform.d.ts +0 -6
- package/operations/entry/filtering/transform.js +0 -11
- package/operations/entry/filtering/transform.js.map +0 -1
- package/operations/entry/filtering/types.d.ts +0 -40
- package/operations/entry/filtering/types.js +0 -3
- package/operations/entry/filtering/types.js.map +0 -1
- package/operations/entry/filtering/values.d.ts +0 -2
- package/operations/entry/filtering/values.js +0 -16
- package/operations/entry/filtering/values.js.map +0 -1
- package/operations/entry/filtering/where.d.ts +0 -5
- package/operations/entry/filtering/where.js +0 -28
- package/operations/entry/filtering/where.js.map +0 -1
- package/operations/entry/index.d.ts +0 -7
- package/operations/entry/index.js +0 -1196
- package/operations/entry/index.js.map +0 -1
- package/operations/group/index.d.ts +0 -9
- package/operations/group/index.js +0 -145
- package/operations/group/index.js.map +0 -1
- package/operations/model/index.d.ts +0 -7
- package/operations/model/index.js +0 -128
- package/operations/model/index.js.map +0 -1
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +0 -23
- package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -40
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +0 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +0 -43
- package/plugins/CmsEntryFieldFilterPlugin.js +0 -21
- package/plugins/CmsEntryFieldFilterPlugin.js.map +0 -1
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +0 -42
- package/plugins/CmsEntryFieldSortingPlugin.js +0 -19
- package/plugins/CmsEntryFieldSortingPlugin.js.map +0 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +0 -11
- package/plugins/CmsFieldFilterValueTransformPlugin.js +0 -16
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +0 -1
- package/plugins/index.d.ts +0 -4
- package/plugins/index.js +0 -6
- package/plugins/index.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["CmsEntryFieldFilterPlugin","extractWhereParams","WebinyError","transformValue","getBaseFieldType","objectFilterCreate","plugin","fieldType","create","params","value","objectValue","valueFilterPlugins","transformValuePlugins","getFilterCreatePlugin","field","parentField","fields","filters","key","undefined","whereParams","negate","fieldId","operation","fieldPath","parents","map","p","concat","join","filterCreatePlugin","transformValuePlugin","transformValueCallable","transform","result","compareValue","Array","isArray","push","name"],"sources":["objectFilterCreate.ts"],"sourcesContent":["import { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where.js\";\nimport WebinyError from \"@webiny/error\";\nimport type { CmsFieldFilterValueTransformPlugin } from \"~/types.js\";\nimport { transformValue } from \"~/operations/entry/filtering/transform.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\nexport const objectFilterCreate = () => {\n const plugin = new CmsEntryFieldFilterPlugin({\n fieldType: \"object\",\n create: params => {\n const {\n value: objectValue,\n valueFilterPlugins,\n transformValuePlugins,\n getFilterCreatePlugin,\n field: parentField,\n fields\n } = params;\n\n const filters = [];\n\n for (const key in objectValue) {\n const value = objectValue[key];\n if (value === undefined) {\n continue;\n }\n const whereParams = extractWhereParams(key);\n if (!whereParams) {\n continue;\n }\n const { negate, fieldId, operation } = whereParams;\n\n const fieldPath = parentField.parents\n .map(p => p.fieldId)\n .concat([parentField.fieldId, fieldId])\n .join(\".\");\n\n const field = fields[fieldPath];\n if (!field) {\n throw new WebinyError(\n `There is no field with the field path \"${fieldPath}\".`,\n \"FIELD_ERROR\",\n {\n fieldId\n }\n );\n }\n\n const fieldType = getBaseFieldType(field);\n\n const filterCreatePlugin = getFilterCreatePlugin(fieldType);\n\n const transformValuePlugin: CmsFieldFilterValueTransformPlugin =\n transformValuePlugins[fieldType];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const result = filterCreatePlugin.create({\n key,\n value,\n valueFilterPlugins,\n transformValuePlugins,\n getFilterCreatePlugin,\n operation,\n negate,\n field,\n fields,\n compareValue: transformValue({\n value,\n transform: transformValueCallable\n }),\n transformValue: transformValueCallable\n });\n if (!result) {\n continue;\n }\n if (Array.isArray(result)) {\n filters.push(...result);\n continue;\n }\n\n filters.push(result);\n }\n return filters;\n }\n });\n\n plugin.name = `headless-cms.ddb.filter.object`;\n\n return plugin;\n};\n"],"mappings":"AAAA,SAASA,yBAAyB;AAClC,SAASC,kBAAkB;AAC3B,OAAOC,WAAW,MAAM,eAAe;AAEvC,SAASC,cAAc;AACvB,SAASC,gBAAgB,QAAQ,oDAAoD;AAErF,OAAO,MAAMC,kBAAkB,GAAGA,CAAA,KAAM;EACpC,MAAMC,MAAM,GAAG,IAAIN,yBAAyB,CAAC;IACzCO,SAAS,EAAE,QAAQ;IACnBC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QACFC,KAAK,EAAEC,WAAW;QAClBC,kBAAkB;QAClBC,qBAAqB;QACrBC,qBAAqB;QACrBC,KAAK,EAAEC,WAAW;QAClBC;MACJ,CAAC,GAAGR,MAAM;MAEV,MAAMS,OAAO,GAAG,EAAE;MAElB,KAAK,MAAMC,GAAG,IAAIR,WAAW,EAAE;QAC3B,MAAMD,KAAK,GAAGC,WAAW,CAACQ,GAAG,CAAC;QAC9B,IAAIT,KA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QACpB,CAAC,CAAC;QACF,IAAI,CAACE,MAAM,EAAE;UACT;QACJ;QACA,IAAIE,KAAK,CAACC,OAAO,CAACH,MAAM,CAAC,EAAE;UACvBjB,OAAO,CAACqB,IAAI,CAAC,GAAGJ,MAAM,CAAC;UACvB;QACJ;QAEAjB,OAAO,CAACqB,IAAI,CAACJ,MAAM,CAAC;MACxB;MACA,OAAOjB,OAAO;IAClB;EACJ,CAAC,CAAC;EAEFZ,MAAM,CAACkC,IAAI,GAAG,gCAAgC;EAE9C,OAAOlC,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import WebinyError from "@webiny/error";
|
|
2
|
-
import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
|
|
3
|
-
import { extractWhereParams } from "../where.js";
|
|
4
|
-
import { transformValue } from "../transform.js";
|
|
5
|
-
import { getBaseFieldType } from "@webiny/api-headless-cms/utils/getBaseFieldType.js";
|
|
6
|
-
export const createRefFilterCreate = () => {
|
|
7
|
-
const plugin = new CmsEntryFieldFilterPlugin({
|
|
8
|
-
fieldType: "ref",
|
|
9
|
-
create: params => {
|
|
10
|
-
const {
|
|
11
|
-
valueFilterPlugins,
|
|
12
|
-
transformValuePlugins,
|
|
13
|
-
field
|
|
14
|
-
} = params;
|
|
15
|
-
let value = params.value;
|
|
16
|
-
if (!value) {
|
|
17
|
-
value = {
|
|
18
|
-
entryId: null
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
const propertyFilters = Object.keys(value);
|
|
22
|
-
if (propertyFilters.length === 0) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
const filters = [];
|
|
26
|
-
for (const propertyFilter of propertyFilters) {
|
|
27
|
-
const whereParams = extractWhereParams(propertyFilter);
|
|
28
|
-
if (!whereParams) {
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
const {
|
|
32
|
-
fieldId: propertyId,
|
|
33
|
-
operation: propertyOperation,
|
|
34
|
-
negate
|
|
35
|
-
} = whereParams;
|
|
36
|
-
const fieldType = getBaseFieldType(field);
|
|
37
|
-
const transformValuePlugin = transformValuePlugins[fieldType];
|
|
38
|
-
const transformValueCallable = value => {
|
|
39
|
-
if (!transformValuePlugin) {
|
|
40
|
-
return value;
|
|
41
|
-
}
|
|
42
|
-
return transformValuePlugin.transform({
|
|
43
|
-
field,
|
|
44
|
-
value
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
const filterPlugin = valueFilterPlugins[propertyOperation];
|
|
48
|
-
if (!filterPlugin) {
|
|
49
|
-
throw new WebinyError(`Missing operation filter for "${propertyOperation}".`, "MISSING_OPERATION_FILTER");
|
|
50
|
-
}
|
|
51
|
-
const paths = [field.createPath({
|
|
52
|
-
field
|
|
53
|
-
}), propertyId];
|
|
54
|
-
filters.push({
|
|
55
|
-
field,
|
|
56
|
-
path: paths.join("."),
|
|
57
|
-
fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join("."),
|
|
58
|
-
plugin: filterPlugin,
|
|
59
|
-
negate,
|
|
60
|
-
compareValue: transformValue({
|
|
61
|
-
value: value[propertyFilter],
|
|
62
|
-
transform: transformValueCallable
|
|
63
|
-
}),
|
|
64
|
-
transformValue: transformValueCallable
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return filters;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
plugin.name = `headless-cms.ddb.filter.ref`;
|
|
71
|
-
return plugin;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
//# sourceMappingURL=refFilterCreate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","CmsEntryFieldFilterPlugin","extractWhereParams","transformValue","getBaseFieldType","createRefFilterCreate","plugin","fieldType","create","params","valueFilterPlugins","transformValuePlugins","field","value","entryId","propertyFilters","Object","keys","length","filters","propertyFilter","whereParams","fieldId","propertyId","operation","propertyOperation","negate","transformValuePlugin","transformValueCallable","transform","filterPlugin","paths","createPath","push","path","join","fieldPathId","parents","map","f","compareValue","name"],"sources":["refFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsEntryFieldFilterPluginCreateResponse } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where.js\";\nimport { transformValue } from \"~/operations/entry/filtering/transform.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\nexport const createRefFilterCreate = () => {\n const plugin = new CmsEntryFieldFilterPlugin<GenericRecord | null | undefined>({\n fieldType: \"ref\",\n create: params => {\n const { valueFilterPlugins, transformValuePlugins, field } = params;\n let value = params.value;\n if (!value) {\n value = {\n entryId: null\n };\n }\n const propertyFilters = Object.keys(value);\n if (propertyFilters.length === 0) {\n return null;\n }\n const filters: CmsEntryFieldFilterPluginCreateResponse[] = [];\n\n for (const propertyFilter of propertyFilters) {\n const whereParams = extractWhereParams(propertyFilter);\n if (!whereParams) {\n continue;\n }\n const { fieldId: propertyId, operation: propertyOperation, negate } = whereParams;\n\n const fieldType = getBaseFieldType(field);\n\n const transformValuePlugin = transformValuePlugins[fieldType];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const filterPlugin = valueFilterPlugins[propertyOperation];\n if (!filterPlugin) {\n throw new WebinyError(\n `Missing operation filter for \"${propertyOperation}\".`,\n \"MISSING_OPERATION_FILTER\"\n );\n }\n\n const paths = [\n field.createPath({\n field\n }),\n propertyId\n ];\n\n filters.push({\n field,\n path: paths.join(\".\"),\n fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join(\".\"),\n plugin: filterPlugin,\n negate,\n compareValue: transformValue({\n value: value[propertyFilter],\n transform: transformValueCallable\n }),\n transformValue: transformValueCallable\n });\n }\n\n return filters;\n }\n });\n\n plugin.name = `headless-cms.ddb.filter.ref`;\n\n return plugin;\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AAEvC,SAASC,yBAAyB;AAClC,SAASC,kBAAkB;AAC3B,SAASC,cAAc;AAEvB,SAASC,gBAAgB,QAAQ,oDAAoD;AAErF,OAAO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,MAAMC,MAAM,GAAG,IAAIL,yBAAyB,CAAmC;IAC3EM,SAAS,EAAE,KAAK;IAChBC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,kBAAkB;QAAEC,qBAAqB;QAAEC;MAAM,CAAC,GAAGH,MAAM;MACnE,IAAII,KAAK,GAAGJ,MAAM,CAACI,KAAK;MACxB,IAAI,CAACA,KAAK,EAAE;QACRA,KAAK,GAAG;UACJC,OAAO,EAAE;QACb,CAAC;MACL;MACA,MAAMC,eAAe,GAAGC,MAAM,CAACC,IAAI,CAACJ,KAAK,CAAC;MAC1C,IAAIE,eAAe,CAACG,MAAM,KAAK,CAAC,EAAE;QAC9B,OAAO,IAAI;MACf;MACA,MAAMC,OAAkD,GAAG,EAAE;MAE7D,KAAK,MAAMC,cAAc,IAAIL,eAAe,EAAE;QAC1C,MAAMM,WAAW,GAAGnB,kBAAkB,CAACkB,cAAc,CAAC;QACtD,IAAI,CAACC,WAAW,EAAE;UACd;QACJ;QACA,MAAM;UAAEC,OAAO,EAAEC,UAAU;UAAEC,SAAS,EAAEC,iBAAiB;UAAEC;QAAO,CAAC,GAAGL,WAAW;QAEjF,MAAMd,SAAS,GAAGH,gBAAgB,CAACQ,KAAK,CAAC;QAEzC,MAAMe,oBAAoB,GAAGhB,qBAAqB,CAACJ,SAAS,CAAC;QAE7D,MAAMqB,sBAAsB,GAAIf,KAAU,IAAK;UAC3C,IAAI,CAACc,oBAAoB,EAAE;YACvB,OAAOd,KAAK;UAChB;UACA,OAAOc,oBAAoB,CAACE,SAAS,CAAC;YAClCjB,KAAK;YACLC;UACJ,CAAC,CAAC;QACN,CAAC;QAED,MAAMiB,YAAY,GAAGpB,kBAAkB,CAACe,iBAAiB,CAAC;QAC1D,IAAI,CAACK,YAAY,EAAE;UACf,MAAM,IAAI9B,WAAW,CACjB,iCAAiCyB,iBAAiB,IAAI,EACtD,0BACJ,CAAC;QACL;QAEA,MAAMM,KAAK,GAAG,CACVnB,KAAK,CAACoB,UAAU,CAAC;UACbpB;QACJ,CAAC,CAAC,EACFW,UAAU,CACb;QAEDJ,OAAO,CAACc,IAAI,CAAC;UACTrB,KAAK;UACLsB,IAAI,EAAEH,KAAK,CAACI,IAAI,CAAC,GAAG,CAAC;UACrBC,WAAW,EAAE,CAAC,GAAGxB,KAAK,CAACyB,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACjB,OAAO,CAAC,EAAEV,KAAK,CAACU,OAAO,CAAC,CAACa,IAAI,CAAC,GAAG,CAAC;UAC5E7B,MAAM,EAAEwB,YAAY;UACpBJ,MAAM;UACNc,YAAY,EAAErC,cAAc,CAAC;YACzBU,KAAK,EAAEA,KAAK,CAACO,cAAc,CAAC;YAC5BS,SAAS,EAAED;UACf,CAAC,CAAC;UACFzB,cAAc,EAAEyB;QACpB,CAAC,CAAC;MACN;MAEA,OAAOT,OAAO;IAClB;EACJ,CAAC,CAAC;EAEFb,MAAM,CAACmC,IAAI,GAAG,6BAA6B;EAE3C,OAAOnC,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import dot from "dot-object";
|
|
2
|
-
import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
|
|
3
|
-
import { extractWhereParams } from "../where.js";
|
|
4
|
-
export const searchableJsonFilterCreate = () => {
|
|
5
|
-
const plugin = new CmsEntryFieldFilterPlugin({
|
|
6
|
-
fieldType: "searchable-json",
|
|
7
|
-
create: params => {
|
|
8
|
-
const {
|
|
9
|
-
value: objectValue,
|
|
10
|
-
valueFilterPlugins,
|
|
11
|
-
field: parentField
|
|
12
|
-
} = params;
|
|
13
|
-
const filters = [];
|
|
14
|
-
const accessPatterns = dot.dot(objectValue);
|
|
15
|
-
for (const key in accessPatterns) {
|
|
16
|
-
const value = accessPatterns[key];
|
|
17
|
-
if (value === undefined) {
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
const whereParams = extractWhereParams(key);
|
|
21
|
-
if (!whereParams) {
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
const {
|
|
25
|
-
negate,
|
|
26
|
-
operation
|
|
27
|
-
} = whereParams;
|
|
28
|
-
const transformValueCallable = value => {
|
|
29
|
-
return value;
|
|
30
|
-
};
|
|
31
|
-
const fieldId = `${parentField.fieldId}.${whereParams.fieldId ?? key}`;
|
|
32
|
-
const result = {
|
|
33
|
-
field: parentField,
|
|
34
|
-
path: `values.${fieldId}`,
|
|
35
|
-
fieldPathId: `values.${fieldId}`,
|
|
36
|
-
negate,
|
|
37
|
-
plugin: valueFilterPlugins[operation],
|
|
38
|
-
compareValue: value,
|
|
39
|
-
transformValue: transformValueCallable
|
|
40
|
-
};
|
|
41
|
-
if (!result) {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
if (Array.isArray(result)) {
|
|
45
|
-
filters.push(...result);
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
filters.push(result);
|
|
49
|
-
}
|
|
50
|
-
return filters;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
plugin.name = `headless-cms.ddb.filter.searchable-json`;
|
|
54
|
-
return plugin;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
//# sourceMappingURL=searchableJsonFilterCreate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["dot","CmsEntryFieldFilterPlugin","extractWhereParams","searchableJsonFilterCreate","plugin","fieldType","create","params","value","objectValue","valueFilterPlugins","field","parentField","filters","accessPatterns","key","undefined","whereParams","negate","operation","transformValueCallable","fieldId","result","path","fieldPathId","compareValue","transformValue","Array","isArray","push","name"],"sources":["searchableJsonFilterCreate.ts"],"sourcesContent":["import dot from \"dot-object\";\nimport type { CmsEntryFieldFilterPluginCreateResponse } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where.js\";\n\nexport const searchableJsonFilterCreate = () => {\n const plugin = new CmsEntryFieldFilterPlugin({\n fieldType: \"searchable-json\",\n create: params => {\n const { value: objectValue, valueFilterPlugins, field: parentField } = params;\n\n const filters = [];\n\n const accessPatterns = dot.dot(objectValue);\n\n for (const key in accessPatterns) {\n const value = accessPatterns[key];\n if (value === undefined) {\n continue;\n }\n\n const whereParams = extractWhereParams(key);\n if (!whereParams) {\n continue;\n }\n const { negate, operation } = whereParams;\n\n const transformValueCallable = (value: any) => {\n return value;\n };\n\n const fieldId = `${parentField.fieldId}.${whereParams.fieldId ?? key}`;\n\n const result: CmsEntryFieldFilterPluginCreateResponse = {\n field: parentField,\n path: `values.${fieldId}`,\n fieldPathId: `values.${fieldId}`,\n negate,\n plugin: valueFilterPlugins[operation],\n compareValue: value,\n transformValue: transformValueCallable\n };\n\n if (!result) {\n continue;\n }\n if (Array.isArray(result)) {\n filters.push(...result);\n continue;\n }\n\n filters.push(result);\n }\n return filters;\n }\n });\n\n plugin.name = `headless-cms.ddb.filter.searchable-json`;\n\n return plugin;\n};\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,YAAY;AAE5B,SAASC,yBAAyB;AAClC,SAASC,kBAAkB;AAE3B,OAAO,MAAMC,0BAA0B,GAAGA,CAAA,KAAM;EAC5C,MAAMC,MAAM,GAAG,IAAIH,yBAAyB,CAAC;IACzCI,SAAS,EAAE,iBAAiB;IAC5BC,MAAM,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D,OAAO1B,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { CmsEntry, CmsEntryValues, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
-
import type { Field } from "./types.js";
|
|
3
|
-
import type { PluginsContainer } from "@webiny/plugins";
|
|
4
|
-
interface Params<T extends CmsEntryValues = CmsEntryValues> {
|
|
5
|
-
model: CmsModel;
|
|
6
|
-
items: CmsEntry<T>[];
|
|
7
|
-
sort?: string[];
|
|
8
|
-
fields: Record<string, Field>;
|
|
9
|
-
plugins: PluginsContainer;
|
|
10
|
-
}
|
|
11
|
-
export declare const sort: <T extends CmsEntryValues = CmsEntryValues>(params: Params<T>) => CmsEntry<T>[];
|
|
12
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import WebinyError from "@webiny/error";
|
|
2
|
-
import dotProp from "dot-prop";
|
|
3
|
-
import lodashSortBy from "lodash/sortBy.js";
|
|
4
|
-
import { extractSort } from "./extractSort.js";
|
|
5
|
-
export const sort = params => {
|
|
6
|
-
const {
|
|
7
|
-
model,
|
|
8
|
-
items,
|
|
9
|
-
sort = [],
|
|
10
|
-
fields,
|
|
11
|
-
plugins
|
|
12
|
-
} = params;
|
|
13
|
-
if (items.length <= 1) {
|
|
14
|
-
return items;
|
|
15
|
-
} else if (sort.length === 0) {
|
|
16
|
-
sort.push("savedOn_DESC");
|
|
17
|
-
} else if (sort.length > 1) {
|
|
18
|
-
throw new WebinyError("Sorting is limited to a single field on DynamoDB only system.", "SORT_MULTIPLE_FIELDS_ERROR", {
|
|
19
|
-
sort
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
const [firstSort] = sort;
|
|
23
|
-
if (!firstSort) {
|
|
24
|
-
throw new WebinyError("Empty sort array item.", "SORT_EMPTY_ERROR", {
|
|
25
|
-
sort
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
const {
|
|
29
|
-
fieldId,
|
|
30
|
-
field,
|
|
31
|
-
valuePath,
|
|
32
|
-
reverse
|
|
33
|
-
} = extractSort({
|
|
34
|
-
model,
|
|
35
|
-
sortBy: firstSort,
|
|
36
|
-
fields,
|
|
37
|
-
plugins
|
|
38
|
-
});
|
|
39
|
-
const itemsToSort = items.map(item => {
|
|
40
|
-
return {
|
|
41
|
-
id: item.id,
|
|
42
|
-
value: field.transform(dotProp.get(item, valuePath))
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
const sortedItems = lodashSortBy(itemsToSort, "value");
|
|
46
|
-
const newItems = sortedItems.map(s => {
|
|
47
|
-
const item = items.find(i => i.id === s.id);
|
|
48
|
-
if (item) {
|
|
49
|
-
return item;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* This is impossible to happen because sorting items does not remove the items.
|
|
53
|
-
* BUT, we need to have this check just in case for development purposes.
|
|
54
|
-
*/
|
|
55
|
-
throw new WebinyError("Could not find item by given id after the sorting.", "SORTING_ITEMS_ERROR", {
|
|
56
|
-
id: s.id,
|
|
57
|
-
sortingBy: fieldId,
|
|
58
|
-
reverse
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
if (!reverse) {
|
|
62
|
-
return newItems;
|
|
63
|
-
}
|
|
64
|
-
return newItems.reverse();
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
//# sourceMappingURL=sort.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","dotProp","lodashSortBy","extractSort","sort","params","model","items","fields","plugins","length","push","firstSort","fieldId","field","valuePath","reverse","sortBy","itemsToSort","map","item","id","value","transform","get","sortedItems","newItems","s","find","i","sortingBy"],"sources":["sort.ts"],"sourcesContent":["import type { CmsEntry, CmsEntryValues, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport dotProp from \"dot-prop\";\nimport lodashSortBy from \"lodash/sortBy.js\";\nimport { extractSort } from \"./extractSort.js\";\nimport type { Field } from \"./types.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\n\ninterface Params<T extends CmsEntryValues = CmsEntryValues> {\n model: CmsModel;\n items: CmsEntry<T>[];\n sort?: string[];\n fields: Record<string, Field>;\n plugins: PluginsContainer;\n}\n\ninterface SortedItem {\n id: string;\n value: any;\n}\n\nexport const sort = <T extends CmsEntryValues = CmsEntryValues>(\n params: Params<T>\n): CmsEntry<T>[] => {\n const { model, items, sort = [], fields, plugins } = 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 on DynamoDB only system.\",\n \"SORT_MULTIPLE_FIELDS_ERROR\",\n {\n 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({\n model,\n sortBy: firstSort,\n fields,\n plugins\n });\n\n const itemsToSort = items.map(item => {\n return {\n id: item.id,\n value: field.transform(dotProp.get(item, valuePath))\n };\n });\n const sortedItems: SortedItem[] = 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 /**\n * This is impossible to happen because sorting items does not remove the items.\n * BUT, we need to have this check just in case for development purposes.\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"],"mappings":"AACA,OAAOA,WAAW,MAAM,eAAe;AACvC,OAAOC,OAAO,MAAM,UAAU;AAC9B,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,SAASC,WAAW;AAiBpB,OAAO,MAAMC,IAAI,GACbC,MAAiB,IACD;EAChB,MAAM;IAAEC,KAAK;IAAEC,K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,IAAI,EAAE;MACN,OAAOA,IAAI;IACf;IACA;AACR;AACA;AACA;IACQ,MAAM,IAAIpB,WAAW,CACjB,oDAAoD,EACpD,qBAAqB,EACrB;MACIqB,EAAE,EAAEM,CAAC,CAACN,EAAE;MACRS,SAAS,EAAEjB,OAAO;MAClBG;IACJ,CACJ,CAAC;EACL,CAAC,CAAC;EACF,IAAI,CAACA,OAAO,EAAE;IACV,OAAOU,QAAQ;EACnB;EACA,OAAOA,QAAQ,CAACV,OAAO,CAAC,CAAC;AAC7B,CAAC","ignoreList":[]}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { ENTRY_META_FIELDS, isDateTimeEntryMetaField, isIdentityEntryMetaField } from "@webiny/api-headless-cms/constants.js";
|
|
2
|
-
import lodashStartCase from "lodash/startCase.js";
|
|
3
|
-
import { createModelField } from "@webiny/api-headless-cms";
|
|
4
|
-
export const createSystemFields = () => {
|
|
5
|
-
const onMetaFields = ENTRY_META_FIELDS.filter(isDateTimeEntryMetaField).map(fieldName => {
|
|
6
|
-
return createModelField({
|
|
7
|
-
id: fieldName,
|
|
8
|
-
type: "datetime",
|
|
9
|
-
storageId: fieldName,
|
|
10
|
-
fieldId: fieldName,
|
|
11
|
-
label: lodashStartCase(fieldName)
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
const byMetaFields = ENTRY_META_FIELDS.filter(isIdentityEntryMetaField).map(fieldName => {
|
|
15
|
-
return createModelField({
|
|
16
|
-
id: fieldName,
|
|
17
|
-
type: "plainObject",
|
|
18
|
-
storageId: fieldName,
|
|
19
|
-
fieldId: fieldName,
|
|
20
|
-
label: lodashStartCase(fieldName),
|
|
21
|
-
settings: {
|
|
22
|
-
path: `${fieldName}.id`
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
return [createModelField({
|
|
27
|
-
id: "id",
|
|
28
|
-
type: "text",
|
|
29
|
-
storageId: "id",
|
|
30
|
-
fieldId: "id",
|
|
31
|
-
label: "ID"
|
|
32
|
-
}), createModelField({
|
|
33
|
-
id: "entryId",
|
|
34
|
-
type: "text",
|
|
35
|
-
storageId: "entryId",
|
|
36
|
-
fieldId: "entryId",
|
|
37
|
-
label: "Entry ID"
|
|
38
|
-
}), ...onMetaFields, ...byMetaFields, createModelField({
|
|
39
|
-
id: "meta",
|
|
40
|
-
type: "plainObject",
|
|
41
|
-
storageId: "meta",
|
|
42
|
-
fieldId: "meta",
|
|
43
|
-
label: "Meta"
|
|
44
|
-
}), createModelField({
|
|
45
|
-
id: "wbyAco_location",
|
|
46
|
-
type: "object",
|
|
47
|
-
storageId: "location",
|
|
48
|
-
label: "Location",
|
|
49
|
-
fieldId: "wbyAco_location",
|
|
50
|
-
settings: {
|
|
51
|
-
fields: [createModelField({
|
|
52
|
-
id: "folderId",
|
|
53
|
-
type: "text",
|
|
54
|
-
fieldId: "folderId",
|
|
55
|
-
label: "Folder ID",
|
|
56
|
-
storageId: "folderId",
|
|
57
|
-
settings: {
|
|
58
|
-
path: "location.folderId"
|
|
59
|
-
}
|
|
60
|
-
})]
|
|
61
|
-
}
|
|
62
|
-
}), createModelField({
|
|
63
|
-
id: "version",
|
|
64
|
-
type: "number",
|
|
65
|
-
storageId: "version",
|
|
66
|
-
fieldId: "version",
|
|
67
|
-
label: "Version"
|
|
68
|
-
}), createModelField({
|
|
69
|
-
id: "status",
|
|
70
|
-
type: "text",
|
|
71
|
-
storageId: "status",
|
|
72
|
-
fieldId: "status",
|
|
73
|
-
label: "Status"
|
|
74
|
-
}), createModelField({
|
|
75
|
-
id: "wbyDeleted",
|
|
76
|
-
type: "boolean",
|
|
77
|
-
storageId: "wbyDeleted",
|
|
78
|
-
fieldId: "wbyDeleted",
|
|
79
|
-
label: "Deleted"
|
|
80
|
-
}), createModelField({
|
|
81
|
-
id: "state",
|
|
82
|
-
type: "object",
|
|
83
|
-
storageId: "object@state",
|
|
84
|
-
fieldId: "state",
|
|
85
|
-
label: "State",
|
|
86
|
-
settings: {
|
|
87
|
-
fields: [createModelField({
|
|
88
|
-
id: "stepId",
|
|
89
|
-
type: "text",
|
|
90
|
-
fieldId: "stepId",
|
|
91
|
-
label: "Step ID",
|
|
92
|
-
storageId: "stepId"
|
|
93
|
-
}), createModelField({
|
|
94
|
-
id: "stepName",
|
|
95
|
-
type: "text",
|
|
96
|
-
fieldId: "stepName",
|
|
97
|
-
label: "Step Name",
|
|
98
|
-
storageId: "stepName"
|
|
99
|
-
}), createModelField({
|
|
100
|
-
id: "state",
|
|
101
|
-
type: "text",
|
|
102
|
-
fieldId: "state",
|
|
103
|
-
label: "State",
|
|
104
|
-
storageId: "state"
|
|
105
|
-
})]
|
|
106
|
-
}
|
|
107
|
-
}), createModelField({
|
|
108
|
-
id: "values",
|
|
109
|
-
type: "object",
|
|
110
|
-
storageId: "values",
|
|
111
|
-
fieldId: "values",
|
|
112
|
-
label: "Values"
|
|
113
|
-
})];
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
//# sourceMappingURL=systemFields.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["ENTRY_META_FIELDS","isDateTimeEntryMetaField","isIdentityEntryMetaField","lodashStartCase","createModelField","createSystemFields","onMetaFields","filter","map","fieldName","id","type","storageId","fieldId","label","byMetaFields","settings","path","fields"],"sources":["systemFields.ts"],"sourcesContent":["import type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport {\n ENTRY_META_FIELDS,\n isDateTimeEntryMetaField,\n isIdentityEntryMetaField\n} from \"@webiny/api-headless-cms/constants.js\";\nimport lodashStartCase from \"lodash/startCase.js\";\nimport { createModelField } from \"@webiny/api-headless-cms\";\n\nexport const createSystemFields = (): CmsModelField[] => {\n const onMetaFields = ENTRY_META_FIELDS.filter(isDateTimeEntryMetaField).map<CmsModelField>(\n fieldName => {\n return createModelField({\n id: fieldName,\n type: \"datetime\",\n storageId: fieldName,\n fieldId: fieldName,\n label: lodashStartCase(fieldName)\n });\n }\n );\n\n const byMetaFields = ENTRY_META_FIELDS.filter(isIdentityEntryMetaField).map<CmsModelField>(\n fieldName => {\n return createModelField({\n id: fieldName,\n type: \"plainObject\",\n storageId: fieldName,\n fieldId: fieldName,\n label: lodashStartCase(fieldName),\n settings: {\n path: `${fieldName}.id`\n }\n });\n }\n );\n\n return [\n createModelField({\n id: \"id\",\n type: \"text\",\n storageId: \"id\",\n fieldId: \"id\",\n label: \"ID\"\n }),\n createModelField({\n id: \"entryId\",\n type: \"text\",\n storageId: \"entryId\",\n fieldId: \"entryId\",\n label: \"Entry ID\"\n }),\n\n ...onMetaFields,\n ...byMetaFields,\n\n createModelField({\n id: \"meta\",\n type: \"plainObject\",\n storageId: \"meta\",\n fieldId: \"meta\",\n label: \"Meta\"\n }),\n createModelField({\n id: \"wbyAco_location\",\n type: \"object\",\n storageId: \"location\",\n label: \"Location\",\n fieldId: \"wbyAco_location\",\n settings: {\n fields: [\n createModelField({\n id: \"folderId\",\n type: \"text\",\n fieldId: \"folderId\",\n label: \"Folder ID\",\n storageId: \"folderId\",\n settings: {\n path: \"location.folderId\"\n }\n })\n ]\n }\n }),\n\n createModelField({\n id: \"version\",\n type: \"number\",\n storageId: \"version\",\n fieldId: \"version\",\n label: \"Version\"\n }),\n createModelField({\n id: \"status\",\n type: \"text\",\n storageId: \"status\",\n fieldId: \"status\",\n label: \"Status\"\n }),\n createModelField({\n id: \"wbyDeleted\",\n type: \"boolean\",\n storageId: \"wbyDeleted\",\n fieldId: \"wbyDeleted\",\n label: \"Deleted\"\n }),\n createModelField({\n id: \"state\",\n type: \"object\",\n storageId: \"object@state\",\n fieldId: \"state\",\n label: \"State\",\n settings: {\n fields: [\n createModelField({\n id: \"stepId\",\n type: \"text\",\n fieldId: \"stepId\",\n label: \"Step ID\",\n storageId: \"stepId\"\n }),\n createModelField({\n id: \"stepName\",\n type: \"text\",\n fieldId: \"stepName\",\n label: \"Step Name\",\n storageId: \"stepName\"\n }),\n createModelField({\n id: \"state\",\n type: \"text\",\n fieldId: \"state\",\n label: \"State\",\n storageId: \"state\"\n })\n ]\n }\n }),\n createModelField({\n id: \"values\",\n type: \"object\",\n storageId: \"values\",\n fieldId: \"values\",\n label: \"Values\"\n })\n ];\n};\n"],"mappings":"AACA,SACIA,iBAAiB,EACjBC,wBAAwB,EACxBC,wBAAwB,QACrB,uCAAuC;AAC9C,OAAOC,eAAe,MAAM,qBAAqB;AACjD,SAASC,gBAAgB,QAAQ,0BAA0B;AAE3D,OAAO,MAAMC,kBAAkB,GAAGA,CAAA,KAAuB;EACrD,MAAMC,YAAY,GAAGN,iBAAiB,CAACO,MAAM,CAACN,wBAAwB,CAAC,CAACO,GAAG,CACvEC,SAAS,IAAI;IACT,OAAOL,gBAAgB,CAAC;MACpBM,EAAE,EAAED,SAAS;MACbE,IAAI,EAAE,UAAU;MAChBC,SAAS,EAAEH,SAAS;MACpBI,OAAO,EAAEJ,SAAS;MAClBK,KAAK,EAAEX,eAAe,CAACM,SAAS;IACpC,CAAC,CAAC;EACN,CACJ,CAAC;EAED,MAAMM,YAAY,GAAGf,iBAAiB,CAACO,MAAM,CAACL,wBAAwB,CAAC,CAACM,GAAG,CACvEC,SAAS,IAAI;IACT,OAAOL,gBAAgB,CAAC;MACpBM,EAAE,EAAED,SAAS;MACbE,IAAI,EAAE,aAAa;MACnBC,SAAS,EAAEH,SAAS;MACpBI,OAAO,EAAEJ,SAAS;MAClBK,KAAK,EAAEX,eAAe,CAACM,SAAS,CAAC;MACjCO,QAAQ,EAAE;QACNC,IAAI,EAAE,GAAGR,SAAS;MACtB;IACJ,CAAC,CAAC;EACN,CACJ,CAAC;EAED,OAAO,CACHL,gBAAgB,CAAC;IACbM,EAAE,EAAE,IAAI;IACRC,IAAI,EAAE,MAAM;IACZC,SAAS,EAAE,IAAI;IACfC,OAAO,EAAE,IAAI;IACbC,KAAK,EAAE;EACX,CAAC,CAAC,EACFV,gBAAgB,CAAC;IACbM,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,MAAM;IACZC,SAAS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AAS,EAAE,cAAc;IACzBC,OAAO,EAAE,OAAO;IAChBC,KAAK,EAAE,OAAO;IACdE,QAAQ,EAAE;MACNE,MAAM,EAAE,CACJd,gBAAgB,CAAC;QACbM,EAAE,EAAE,QAAQ;QACZC,IAAI,EAAE,MAAM;QACZE,OAAO,EAAE,QAAQ;QACjBC,KAAK,EAAE,SAAS;QAChBF,SAAS,EAAE;MACf,CAAC,CAAC,EACFR,gBAAgB,CAAC;QACbM,EAAE,EAAE,UAAU;QACdC,IAAI,EAAE,MAAM;QACZE,OAAO,EAAE,UAAU;QACnBC,KAAK,EAAE,WAAW;QAClBF,SAAS,EAAE;MACf,CAAC,CAAC,EACFR,gBAAgB,CAAC;QACbM,EAAE,EAAE,OAAO;QACXC,IAAI,EAAE,MAAM;QACZE,OAAO,EAAE,OAAO;QAChBC,KAAK,EAAE,OAAO;QACdF,SAAS,EAAE;MACf,CAAC,CAAC;IAEV;EACJ,CAAC,CAAC,EACFR,gBAAgB,CAAC;IACbM,EAAE,EAAE,QAAQ;IACZC,IAAI,EAAE,QAAQ;IACdC,SAAS,EAAE,QAAQ;IACnBC,OAAO,EAAE,QAAQ;IACjBC,KAAK,EAAE;EACX,CAAC,CAAC,CACL;AACL,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["transformValue","value","transform","Array","isArray","map","v"],"sources":["transform.ts"],"sourcesContent":["import type { Field } from \"./types.js\";\n\ninterface Params extends Pick<Field, \"transform\"> {\n value: any;\n}\nexport const transformValue = ({ value, transform }: Params): any => {\n if (Array.isArray(value)) {\n return value.map(v => transform(v));\n }\n return transform(value);\n};\n"],"mappings":"AAKA,OAAO,MAAMA,cAAc,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAkB,CAAC,KAAU;EACjE,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;IACtB,OAAOA,KAAK,CAACI,GAAG,CAACC,CAAC,IAAIJ,SAAS,CAACI,CAAC,CAAC,CAAC;EACvC;EACA,OAAOJ,SAAS,CAACD,KAAK,CAAC;AAC3B,CAAC","ignoreList":[]}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { CmsModelField } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
-
import type { CreatePathCallable } from "../../../plugins/index.js";
|
|
3
|
-
interface FieldValueTransform {
|
|
4
|
-
(value: any): any;
|
|
5
|
-
}
|
|
6
|
-
export interface FieldParent {
|
|
7
|
-
fieldId: string;
|
|
8
|
-
list?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export interface Field extends Partial<Omit<CmsModelField, "id" | "type" | "storageId" | "fieldId">>, Pick<CmsModelField, "id" | "type" | "storageId" | "fieldId"> {
|
|
11
|
-
/**
|
|
12
|
-
* A list od fieldId of all parents of the current field.
|
|
13
|
-
*
|
|
14
|
-
* This is used to check if we need to iterate through an array of parent values.
|
|
15
|
-
*/
|
|
16
|
-
parents: FieldParent[];
|
|
17
|
-
/**
|
|
18
|
-
* The method which creates a path for the filtering.
|
|
19
|
-
*
|
|
20
|
-
* Always exists. In most cases it will return some fixed value.
|
|
21
|
-
* When having a CmsEntryFieldFilterPathPlugin then it is executed to create a path.
|
|
22
|
-
*/
|
|
23
|
-
createPath: CreatePathCallable;
|
|
24
|
-
/**
|
|
25
|
-
* In most cases, return value of this method is what ever is the input.
|
|
26
|
-
*
|
|
27
|
-
* In some cases there might be a CmsFieldFilterValueTransformPlugin, which transforms value to a comparable one.
|
|
28
|
-
* For example, time in format 15:45:58 is not comparable, so we transform it into the seconds and then compare.
|
|
29
|
-
*/
|
|
30
|
-
transform: FieldValueTransform;
|
|
31
|
-
/**
|
|
32
|
-
* Is the field a system field?
|
|
33
|
-
* System fields are built into the code and cannot be changed.
|
|
34
|
-
*/
|
|
35
|
-
system: boolean;
|
|
36
|
-
}
|
|
37
|
-
export interface FilterItemFromStorage {
|
|
38
|
-
<T = any>(field: Partial<CmsModelField> & Pick<CmsModelField, "fieldId" | "storageId" | "id" | "settings" | "type">, value: any): Promise<T>;
|
|
39
|
-
}
|
|
40
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CreatePathCallable } from \"~/plugins/index.js\";\n\ninterface FieldValueTransform {\n (value: any): any;\n}\n\nexport interface FieldParent {\n fieldId: string;\n list?: boolean;\n}\n\nexport interface Field\n extends Partial<Omit<CmsModelField, \"id\" | \"type\" | \"storageId\" | \"fieldId\">>,\n Pick<CmsModelField, \"id\" | \"type\" | \"storageId\" | \"fieldId\"> {\n /**\n * A list od fieldId of all parents of the current field.\n *\n * This is used to check if we need to iterate through an array of parent values.\n */\n parents: FieldParent[];\n /**\n * The method which creates a path for the filtering.\n *\n * Always exists. In most cases it will return some fixed value.\n * When having a CmsEntryFieldFilterPathPlugin then it is executed to create a path.\n */\n createPath: CreatePathCallable;\n /**\n * In most cases, return value of this method is what ever is the input.\n *\n * In some cases there might be a CmsFieldFilterValueTransformPlugin, which transforms value to a comparable one.\n * For example, time in format 15:45:58 is not comparable, so we transform it into the seconds and then compare.\n */\n transform: FieldValueTransform;\n /**\n * Is the field a system field?\n * System fields are built into the code and cannot be changed.\n */\n system: boolean;\n}\n\nexport interface FilterItemFromStorage {\n <T = any>(\n field: Partial<CmsModelField> &\n Pick<CmsModelField, \"fieldId\" | \"storageId\" | \"id\" | \"settings\" | \"type\">,\n value: any\n ): Promise<T>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import WebinyError from "@webiny/error";
|
|
2
|
-
export const getWhereValues = (value, condition) => {
|
|
3
|
-
const values = value;
|
|
4
|
-
if (!Array.isArray(values)) {
|
|
5
|
-
throw new WebinyError(`Trying to run filtering with "${condition}", but the value sent is not an array.`, `MALFORMED_${condition}_CONDITION`, {
|
|
6
|
-
value
|
|
7
|
-
});
|
|
8
|
-
} else if (values.length === 0) {
|
|
9
|
-
throw new WebinyError(`Trying to run filtering with "${condition}", but the value sent is empty array.`, `MALFORMED_${condition}_CONDITION`, {
|
|
10
|
-
value
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
return values;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=values.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["WebinyError","getWhereValues","value","condition","values","Array","isArray","length"],"sources":["values.ts"],"sourcesContent":["import type { CmsEntryListWhere } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\n\nexport const getWhereValues = (value: unknown, condition: \"AND\" | \"OR\") => {\n const values = value as CmsEntryListWhere[] | undefined;\n if (!Array.isArray(values)) {\n throw new WebinyError(\n `Trying to run filtering with \"${condition}\", but the value sent is not an array.`,\n `MALFORMED_${condition}_CONDITION`,\n {\n value\n }\n );\n } else if (values.length === 0) {\n throw new WebinyError(\n `Trying to run filtering with \"${condition}\", but the value sent is empty array.`,\n `MALFORMED_${condition}_CONDITION`,\n {\n value\n }\n );\n }\n return values;\n};\n"],"mappings":"AACA,OAAOA,WAAW,MAAM,eAAe;AAEvC,OAAO,MAAMC,cAAc,GAAGA,CAACC,KAAc,EAAEC,SAAuB,KAAK;EACvE,MAAMC,MAAM,GAAGF,KAAwC;EACvD,IAAI,CAACG,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;IACxB,MAAM,IAAIJ,WAAW,CACjB,iCAAiCG,SAAS,wCAAwC,EAClF,aAAaA,SAAS,YAAY,EAClC;MACID;IACJ,CACJ,CAAC;EACL,CAAC,MAAM,IAAIE,MAAM,CAACG,MAAM,KAAK,CAAC,EAAE;IAC5B,MAAM,IAAIP,WAAW,CACjB,iCAAiCG,SAAS,uCAAuC,EACjF,aAAaA,SAAS,YAAY,EAClC;MACID;IACJ,CACJ,CAAC;EACL;EACA,OAAOE,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export const extractWhereParams = key => {
|
|
2
|
-
const isWbyAco = key.match("wbyAco_") !== null;
|
|
3
|
-
const result = key.replace("wbyAco_", "").split("_");
|
|
4
|
-
const fieldId = result.shift();
|
|
5
|
-
if (!fieldId) {
|
|
6
|
-
return null;
|
|
7
|
-
}
|
|
8
|
-
const rawOp = result.length === 0 ? "eq" : result.join("_");
|
|
9
|
-
/**
|
|
10
|
-
* When rawOp is not, it means it is equal negated so just return that.
|
|
11
|
-
*/
|
|
12
|
-
if (rawOp === "not") {
|
|
13
|
-
return {
|
|
14
|
-
fieldId,
|
|
15
|
-
operation: "eq",
|
|
16
|
-
negate: true
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
const negate = rawOp.match("not_") !== null;
|
|
20
|
-
const operation = rawOp.replace("not_", "");
|
|
21
|
-
return {
|
|
22
|
-
fieldId: isWbyAco ? `wbyAco_${fieldId}` : fieldId,
|
|
23
|
-
operation,
|
|
24
|
-
negate
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=where.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["extractWhereParams","key","isWbyAco","match","result","replace","split","fieldId","shift","rawOp","length","join","operation","negate"],"sources":["where.ts"],"sourcesContent":["export const extractWhereParams = (key: string) => {\n const isWbyAco = key.match(\"wbyAco_\") !== null;\n const result = key.replace(\"wbyAco_\", \"\").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: isWbyAco ? `wbyAco_${fieldId}` : fieldId,\n operation,\n negate\n };\n};\n"],"mappings":"AAAA,OAAO,MAAMA,kBAAkB,GAAIC,GAAW,IAAK;EAC/C,MAAMC,QAAQ,GAAGD,GAAG,CAACE,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI;EAC9C,MAAMC,MAAM,GAAGH,GAAG,CAACI,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAACC,KAAK,CAAC,GAAG,CAAC;EACpD,MAAMC,OAAO,GAAGH,MAAM,CAACI,KAAK,CAAC,CAAC;EAC9B,IAAI,CAACD,OAAO,EAAE;IACV,OAAO,IAAI;EACf;EACA,MAAME,KAAK,GAAGL,MAAM,CAACM,MAAM,KAAK,CAAC,GAAG,IAAI,GAAGN,MAAM,CAACO,IAAI,CAAC,GAAG,CAAC;EAC3D;AACJ;AACA;EACI,IAAIF,KAAK,KAAK,KAAK,EAAE;IACjB,OAAO;MACHF,OAAO;MACPK,SAAS,EAAE,IAAI;MACfC,MAAM,EAAE;IACZ,CAAC;EACL;EACA,MAAMA,MAAM,GAAGJ,KAAK,CAACN,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI;EAC3C,MAAMS,SAAS,GAAGH,KAAK,CAACJ,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;EAC3C,OAAO;IACHE,OAAO,EAAEL,QAAQ,GAAG,UAAUK,OAAO,EAAE,GAAGA,OAAO;IACjDK,SAAS;IACTC;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { PluginsContainer } from "@webiny/plugins";
|
|
2
|
-
import type { CmsEntryStorageOperations, IEntryEntity } from "../../types.js";
|
|
3
|
-
export interface CreateEntriesStorageOperationsParams {
|
|
4
|
-
entity: IEntryEntity;
|
|
5
|
-
plugins: PluginsContainer;
|
|
6
|
-
}
|
|
7
|
-
export declare const createEntriesStorageOperations: (params: CreateEntriesStorageOperationsParams) => CmsEntryStorageOperations;
|