@webiny/api-headless-cms-ddb 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/definitions/entry.d.ts +6 -4
- package/definitions/entry.js +111 -20
- package/definitions/entry.js.map +1 -0
- package/definitions/group.d.ts +6 -4
- package/definitions/group.js +8 -16
- package/definitions/group.js.map +1 -0
- package/definitions/model.d.ts +6 -4
- package/definitions/model.js +30 -16
- package/definitions/model.js.map +1 -0
- package/definitions/system.d.ts +6 -4
- package/definitions/system.js +8 -16
- package/definitions/system.js.map +1 -0
- package/definitions/table.d.ts +7 -6
- package/definitions/table.js +7 -6
- package/definitions/table.js.map +1 -0
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +9 -18
- package/dynamoDb/index.js.map +1 -0
- package/dynamoDb/path/locationFolderId.d.ts +2 -0
- package/dynamoDb/path/locationFolderId.js +43 -0
- package/dynamoDb/path/locationFolderId.js.map +1 -0
- package/dynamoDb/path/plainObject.d.ts +2 -3
- package/dynamoDb/path/plainObject.js +26 -24
- package/dynamoDb/path/plainObject.js.map +1 -0
- package/dynamoDb/storage/longText.d.ts +7 -4
- package/dynamoDb/storage/longText.js +74 -63
- package/dynamoDb/storage/longText.js.map +1 -0
- package/dynamoDb/storage/richText.d.ts +2 -8
- package/dynamoDb/storage/richText.js +49 -98
- package/dynamoDb/storage/richText.js.map +1 -0
- package/dynamoDb/transformValue/datetime.d.ts +5 -3
- package/dynamoDb/transformValue/datetime.js +29 -29
- package/dynamoDb/transformValue/datetime.js.map +1 -0
- package/index.d.ts +2 -1
- package/index.js +56 -54
- package/index.js.map +1 -0
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +17 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +41 -0
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
- package/operations/entry/dataLoader/constants.d.ts +1 -0
- package/operations/entry/dataLoader/constants.js +10 -0
- package/operations/entry/dataLoader/constants.js.map +1 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js +25 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js +45 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +56 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +56 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
- package/operations/entry/dataLoader/getRevisionById.js +62 -0
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
- package/operations/entry/dataLoader/index.d.ts +8 -0
- package/operations/entry/dataLoader/index.js +40 -0
- package/operations/entry/dataLoader/index.js.map +1 -0
- package/operations/entry/dataLoader/types.d.ts +6 -0
- package/operations/entry/dataLoader/types.js +7 -0
- package/operations/entry/dataLoader/types.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +18 -29
- package/operations/entry/dataLoaders.js +59 -246
- package/operations/entry/dataLoaders.js.map +1 -0
- package/operations/entry/filtering/createExpressions.d.ts +26 -0
- package/operations/entry/filtering/createExpressions.js +178 -0
- package/operations/entry/filtering/createExpressions.js.map +1 -0
- package/operations/entry/filtering/createFields.d.ts +16 -0
- package/operations/entry/filtering/createFields.js +108 -0
- package/operations/entry/filtering/createFields.js.map +1 -0
- package/operations/entry/filtering/extractSort.d.ts +17 -0
- package/operations/entry/filtering/extractSort.js +69 -0
- package/operations/entry/filtering/extractSort.js.map +1 -0
- package/operations/entry/filtering/filter.d.ts +15 -0
- package/operations/entry/filtering/filter.js +158 -0
- package/operations/entry/filtering/filter.js.map +1 -0
- package/operations/entry/filtering/fullTextSearch.d.ts +14 -0
- package/operations/entry/filtering/fullTextSearch.js +50 -0
- package/operations/entry/filtering/fullTextSearch.js.map +1 -0
- package/operations/entry/filtering/getValue.d.ts +5 -0
- package/operations/entry/filtering/getValue.js +66 -0
- package/operations/entry/filtering/getValue.js.map +1 -0
- package/operations/entry/filtering/index.d.ts +2 -0
- package/operations/entry/filtering/index.js +21 -0
- package/operations/entry/filtering/index.js.map +1 -0
- package/operations/entry/filtering/mapPlugins.d.ts +8 -0
- package/operations/entry/filtering/mapPlugins.js +33 -0
- package/operations/entry/filtering/mapPlugins.js.map +1 -0
- package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +45 -0
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -0
- package/operations/entry/filtering/plugins/index.d.ts +1 -0
- package/operations/entry/filtering/plugins/index.js +16 -0
- package/operations/entry/filtering/plugins/index.js.map +1 -0
- package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/objectFilterCreate.js +90 -0
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -0
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +3 -0
- package/operations/entry/filtering/plugins/refFilterCreate.js +80 -0
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +65 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -0
- package/operations/entry/filtering/sort.d.ts +12 -0
- package/operations/entry/filtering/sort.js +71 -0
- package/operations/entry/filtering/sort.js.map +1 -0
- package/operations/entry/filtering/systemFields.d.ts +4 -0
- package/operations/entry/filtering/systemFields.js +90 -0
- package/operations/entry/filtering/systemFields.js.map +1 -0
- package/operations/entry/filtering/transform.d.ts +6 -0
- package/operations/entry/filtering/transform.js +18 -0
- package/operations/entry/filtering/transform.js.map +1 -0
- package/operations/entry/filtering/types.d.ts +40 -0
- package/operations/entry/filtering/types.js +7 -0
- package/operations/entry/filtering/types.js.map +1 -0
- package/operations/entry/filtering/values.d.ts +2 -0
- package/operations/entry/filtering/values.js +24 -0
- package/operations/entry/filtering/values.js.map +1 -0
- package/operations/entry/filtering/where.d.ts +5 -0
- package/operations/entry/filtering/where.js +35 -0
- package/operations/entry/filtering/where.js.map +1 -0
- package/operations/entry/index.d.ts +5 -5
- package/operations/entry/index.js +920 -437
- package/operations/entry/index.js.map +1 -0
- package/operations/entry/keys.js +9 -14
- package/operations/entry/keys.js.map +1 -0
- package/operations/group/index.d.ts +6 -5
- package/operations/group/index.js +35 -59
- package/operations/group/index.js.map +1 -0
- package/operations/model/index.d.ts +5 -4
- package/operations/model/index.js +35 -46
- package/operations/model/index.js.map +1 -0
- package/operations/system/index.d.ts +5 -4
- package/operations/system/index.js +20 -31
- package/operations/system/index.js.map +1 -0
- package/package.json +23 -29
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +23 -0
- package/plugins/CmsEntryFieldFilterPathPlugin.js +48 -0
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -0
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +43 -0
- package/plugins/CmsEntryFieldFilterPlugin.js +27 -0
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -0
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
- package/plugins/CmsEntryFieldSortingPlugin.js +27 -0
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js +23 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +4 -0
- package/plugins/index.js +51 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +21 -45
- package/types.js +5 -6
- package/types.js.map +1 -0
- package/definitions/settings.d.ts +0 -8
- package/definitions/settings.js +0 -62
- package/dynamoDb/path/ref.d.ts +0 -3
- package/dynamoDb/path/ref.js +0 -27
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -65
- package/operations/entry/systemFields.d.ts +0 -2
- package/operations/entry/systemFields.js +0 -50
- package/operations/entry/utils.d.ts +0 -31
- package/operations/entry/utils.js +0 -406
- package/operations/settings/index.d.ts +0 -6
- package/operations/settings/index.js +0 -141
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.sort = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
var _dotProp = _interopRequireDefault(require("dot-prop"));
|
|
10
|
+
var _sortBy = _interopRequireDefault(require("lodash/sortBy"));
|
|
11
|
+
var _extractSort = require("./extractSort");
|
|
12
|
+
const sort = params => {
|
|
13
|
+
const {
|
|
14
|
+
model,
|
|
15
|
+
items,
|
|
16
|
+
sort = [],
|
|
17
|
+
fields,
|
|
18
|
+
plugins
|
|
19
|
+
} = params;
|
|
20
|
+
if (items.length <= 1) {
|
|
21
|
+
return items;
|
|
22
|
+
} else if (sort.length === 0) {
|
|
23
|
+
sort.push("savedOn_DESC");
|
|
24
|
+
} else if (sort.length > 1) {
|
|
25
|
+
throw new _error.default("Sorting is limited to a single field on DynamoDB only system.", "SORT_MULTIPLE_FIELDS_ERROR", {
|
|
26
|
+
sort
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const [firstSort] = sort;
|
|
30
|
+
if (!firstSort) {
|
|
31
|
+
throw new _error.default("Empty sort array item.", "SORT_EMPTY_ERROR", {
|
|
32
|
+
sort
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const {
|
|
36
|
+
fieldId,
|
|
37
|
+
field,
|
|
38
|
+
valuePath,
|
|
39
|
+
reverse
|
|
40
|
+
} = (0, _extractSort.extractSort)({
|
|
41
|
+
model,
|
|
42
|
+
sortBy: firstSort,
|
|
43
|
+
fields,
|
|
44
|
+
plugins
|
|
45
|
+
});
|
|
46
|
+
const itemsToSort = items.map(item => {
|
|
47
|
+
return {
|
|
48
|
+
id: item.id,
|
|
49
|
+
value: field.transform(_dotProp.default.get(item, valuePath))
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
const sortedItems = (0, _sortBy.default)(itemsToSort, "value");
|
|
53
|
+
const newItems = sortedItems.map(s => {
|
|
54
|
+
const item = items.find(i => i.id === s.id);
|
|
55
|
+
if (item) {
|
|
56
|
+
return item;
|
|
57
|
+
}
|
|
58
|
+
throw new _error.default("Could not find item by given id after the sorting.", "SORTING_ITEMS_ERROR", {
|
|
59
|
+
id: s.id,
|
|
60
|
+
sortingBy: fieldId,
|
|
61
|
+
reverse
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
if (!reverse) {
|
|
65
|
+
return newItems;
|
|
66
|
+
}
|
|
67
|
+
return newItems.reverse();
|
|
68
|
+
};
|
|
69
|
+
exports.sort = sort;
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=sort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_dotProp","_sortBy","_extractSort","sort","params","model","items","fields","plugins","length","push","WebinyError","firstSort","fieldId","field","valuePath","reverse","extractSort","sortBy","itemsToSort","map","item","id","value","transform","dotProp","get","sortedItems","lodashSortBy","newItems","s","find","i","sortingBy","exports"],"sources":["sort.ts"],"sourcesContent":["import type { CmsEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\nimport dotProp from \"dot-prop\";\nimport lodashSortBy from \"lodash/sortBy\";\nimport { extractSort } from \"./extractSort\";\nimport type { Field } from \"./types\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\n\ninterface Params {\n model: CmsModel;\n items: CmsEntry[];\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 = (params: Params): CmsEntry[] => {\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 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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAiBO,MAAMI,IAAI,GAAIC,MAAc,IAAiB;EAChD,MAAM;IAAEC,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CAAC;IAC3C,IAAID,IAAI,EAAE;MACN,OAAOA,IAAI;IACf;IACA,MAAM,IAAIV,cAAW,CACjB,oDAAoD,EACpD,qBAAqB,EACrB;MACIW,EAAE,EAAEQ,CAAC,CAACR,EAAE;MACRW,SAAS,EAAEpB,OAAO;MAClBG;IACJ,CACJ,CAAC;EACL,CAAC,CAAC;EACF,IAAI,CAACA,OAAO,EAAE;IACV,OAAOa,QAAQ;EACnB;EACA,OAAOA,QAAQ,CAACb,OAAO,CAAC,CAAC;AAC7B,CAAC;AAACkB,OAAA,CAAA/B,IAAA,GAAAA,IAAA","ignoreList":[]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createSystemFields = void 0;
|
|
8
|
+
var _constants = require("@webiny/api-headless-cms/constants");
|
|
9
|
+
var _startCase = _interopRequireDefault(require("lodash/startCase"));
|
|
10
|
+
const createSystemFields = () => {
|
|
11
|
+
const onMetaFields = _constants.ENTRY_META_FIELDS.filter(_constants.isDateTimeEntryMetaField).map(fieldName => {
|
|
12
|
+
return {
|
|
13
|
+
id: fieldName,
|
|
14
|
+
type: "datetime",
|
|
15
|
+
storageId: fieldName,
|
|
16
|
+
fieldId: fieldName,
|
|
17
|
+
label: (0, _startCase.default)(fieldName)
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
const byMetaFields = _constants.ENTRY_META_FIELDS.filter(_constants.isIdentityEntryMetaField).map(fieldName => {
|
|
21
|
+
return {
|
|
22
|
+
id: fieldName,
|
|
23
|
+
type: "plainObject",
|
|
24
|
+
storageId: fieldName,
|
|
25
|
+
fieldId: fieldName,
|
|
26
|
+
label: (0, _startCase.default)(fieldName),
|
|
27
|
+
settings: {
|
|
28
|
+
path: `${fieldName}.id`
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
return [{
|
|
33
|
+
id: "id",
|
|
34
|
+
type: "text",
|
|
35
|
+
storageId: "id",
|
|
36
|
+
fieldId: "id",
|
|
37
|
+
label: "ID"
|
|
38
|
+
}, {
|
|
39
|
+
id: "entryId",
|
|
40
|
+
type: "text",
|
|
41
|
+
storageId: "entryId",
|
|
42
|
+
fieldId: "entryId",
|
|
43
|
+
label: "Entry ID"
|
|
44
|
+
}, ...onMetaFields, ...byMetaFields, {
|
|
45
|
+
id: "meta",
|
|
46
|
+
type: "plainObject",
|
|
47
|
+
storageId: "meta",
|
|
48
|
+
fieldId: "meta",
|
|
49
|
+
label: "Meta"
|
|
50
|
+
}, {
|
|
51
|
+
id: "wbyAco_location",
|
|
52
|
+
type: "object",
|
|
53
|
+
storageId: "location",
|
|
54
|
+
label: "Location",
|
|
55
|
+
fieldId: "wbyAco_location",
|
|
56
|
+
settings: {
|
|
57
|
+
fields: [{
|
|
58
|
+
id: "folderId",
|
|
59
|
+
type: "text",
|
|
60
|
+
fieldId: "folderId",
|
|
61
|
+
label: "Folder ID",
|
|
62
|
+
storageId: "folderId",
|
|
63
|
+
settings: {
|
|
64
|
+
path: "location.folderId"
|
|
65
|
+
}
|
|
66
|
+
}]
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
id: "version",
|
|
70
|
+
type: "number",
|
|
71
|
+
storageId: "version",
|
|
72
|
+
fieldId: "version",
|
|
73
|
+
label: "Version"
|
|
74
|
+
}, {
|
|
75
|
+
id: "status",
|
|
76
|
+
type: "text",
|
|
77
|
+
storageId: "status",
|
|
78
|
+
fieldId: "status",
|
|
79
|
+
label: "Status"
|
|
80
|
+
}, {
|
|
81
|
+
id: "wbyDeleted",
|
|
82
|
+
type: "boolean",
|
|
83
|
+
storageId: "wbyDeleted",
|
|
84
|
+
fieldId: "wbyDeleted",
|
|
85
|
+
label: "Deleted"
|
|
86
|
+
}];
|
|
87
|
+
};
|
|
88
|
+
exports.createSystemFields = createSystemFields;
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=systemFields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_constants","require","_startCase","_interopRequireDefault","createSystemFields","onMetaFields","ENTRY_META_FIELDS","filter","isDateTimeEntryMetaField","map","fieldName","id","type","storageId","fieldId","label","lodashStartCase","byMetaFields","isIdentityEntryMetaField","settings","path","fields","exports"],"sources":["systemFields.ts"],"sourcesContent":["import type { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport {\n ENTRY_META_FIELDS,\n isDateTimeEntryMetaField,\n isIdentityEntryMetaField\n} from \"@webiny/api-headless-cms/constants\";\nimport lodashStartCase from \"lodash/startCase\";\n\ntype Field = Pick<CmsModelField, \"id\" | \"type\" | \"storageId\" | \"fieldId\" | \"settings\" | \"label\">;\n\nexport const createSystemFields = (): Field[] => {\n const onMetaFields = ENTRY_META_FIELDS.filter(isDateTimeEntryMetaField).map(fieldName => {\n return {\n id: fieldName,\n type: \"datetime\",\n storageId: fieldName,\n fieldId: fieldName,\n label: lodashStartCase(fieldName)\n };\n });\n\n const byMetaFields = ENTRY_META_FIELDS.filter(isIdentityEntryMetaField).map(fieldName => {\n return {\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 return [\n {\n id: \"id\",\n type: \"text\",\n storageId: \"id\",\n fieldId: \"id\",\n label: \"ID\"\n },\n {\n id: \"entryId\",\n type: \"text\",\n storageId: \"entryId\",\n fieldId: \"entryId\",\n label: \"Entry ID\"\n },\n\n ...onMetaFields,\n ...byMetaFields,\n\n {\n id: \"meta\",\n type: \"plainObject\",\n storageId: \"meta\",\n fieldId: \"meta\",\n label: \"Meta\"\n },\n {\n id: \"wbyAco_location\",\n type: \"object\",\n storageId: \"location\",\n label: \"Location\",\n fieldId: \"wbyAco_location\",\n settings: {\n fields: [\n {\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 {\n id: \"version\",\n type: \"number\",\n storageId: \"version\",\n fieldId: \"version\",\n label: \"Version\"\n },\n {\n id: \"status\",\n type: \"text\",\n storageId: \"status\",\n fieldId: \"status\",\n label: \"Status\"\n },\n {\n id: \"wbyDeleted\",\n type: \"boolean\",\n storageId: \"wbyDeleted\",\n fieldId: \"wbyDeleted\",\n label: \"Deleted\"\n }\n ];\n};\n"],"mappings":";;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAIO,MAAMG,kBAAkB,GAAGA,CAAA,KAAe;EAC7C,MAAMC,YAAY,GAAGC,4BAAiB,CAACC,MAAM,CAACC,mCAAwB,CAAC,CAACC,GAAG,CAACC,SAAS,IAAI;IACrF,OAAO;MACHC,EAAE,EAAED,SAAS;MACbE,IAAI,EAAE,UAAU;MAChBC,SAAS,EAAEH,SAAS;MACpBI,OAAO,EAAEJ,SAAS;MAClBK,KAAK,EAAE,IAAAC,kBAAe,EAACN,SAAS;IACpC,CAAC;EACL,CAAC,CAAC;EAEF,MAAMO,YAAY,GAAGX,4BAAiB,CAACC,MAAM,CAACW,mCAAwB,CAAC,CAACT,GAAG,CAACC,SAAS,IAAI;IACrF,OAAO;MACHC,EAAE,EAAED,SAAS;MACbE,IAAI,EAAE,aAAa;MACnBC,SAAS,EAAEH,SAAS;MACpBI,OAAO,EAAEJ,SAAS;MAClBK,KAAK,EAAE,IAAAC,kBAAe,EAACN,SAAS,CAAC;MACjCS,QAAQ,EAAE;QACNC,IAAI,EAAE,GAAGV,SAAS;MACtB;IACJ,CAAC;EACL,CAAC,CAAC;EAEF,OAAO,CACH;IACIC,EAAE,EAAE,IAAI;IACRC,IAAI,EAAE,MAAM;IACZC,SAAS,EAAE,IAAI;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
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.transformValue = void 0;
|
|
7
|
+
const transformValue = ({
|
|
8
|
+
value,
|
|
9
|
+
transform
|
|
10
|
+
}) => {
|
|
11
|
+
if (Array.isArray(value)) {
|
|
12
|
+
return value.map(v => transform(v));
|
|
13
|
+
}
|
|
14
|
+
return transform(value);
|
|
15
|
+
};
|
|
16
|
+
exports.transformValue = transformValue;
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["transformValue","value","transform","Array","isArray","map","v","exports"],"sources":["transform.ts"],"sourcesContent":["import type { Field } from \"./types\";\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":";;;;;;AAKO,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;AAACM,OAAA,CAAAP,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import type { CreatePathCallable } from "../../../plugins";
|
|
3
|
+
interface FieldValueTransform {
|
|
4
|
+
(value: any): any;
|
|
5
|
+
}
|
|
6
|
+
export interface FieldParent {
|
|
7
|
+
fieldId: string;
|
|
8
|
+
multipleValues?: 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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport type { CreatePathCallable } from \"~/plugins\";\n\ninterface FieldValueTransform {\n (value: any): any;\n}\n\nexport interface FieldParent {\n fieldId: string;\n multipleValues?: 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":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getWhereValues = void 0;
|
|
8
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
+
const getWhereValues = (value, condition) => {
|
|
10
|
+
const values = value;
|
|
11
|
+
if (!Array.isArray(values)) {
|
|
12
|
+
throw new _error.default(`Trying to run filtering with "${condition}", but the value sent is not an array.`, `MALFORMED_${condition}_CONDITION`, {
|
|
13
|
+
value
|
|
14
|
+
});
|
|
15
|
+
} else if (values.length === 0) {
|
|
16
|
+
throw new _error.default(`Trying to run filtering with "${condition}", but the value sent is empty array.`, `MALFORMED_${condition}_CONDITION`, {
|
|
17
|
+
value
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return values;
|
|
21
|
+
};
|
|
22
|
+
exports.getWhereValues = getWhereValues;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","getWhereValues","value","condition","values","Array","isArray","WebinyError","length","exports"],"sources":["values.ts"],"sourcesContent":["import type { CmsEntryListWhere } from \"@webiny/api-headless-cms/types\";\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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,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,IAAIG,cAAW,CACjB,iCAAiCJ,SAAS,wCAAwC,EAClF,aAAaA,SAAS,YAAY,EAClC;MACID;IACJ,CACJ,CAAC;EACL,CAAC,MAAM,IAAIE,MAAM,CAACI,MAAM,KAAK,CAAC,EAAE;IAC5B,MAAM,IAAID,cAAW,CACjB,iCAAiCJ,SAAS,uCAAuC,EACjF,aAAaA,SAAS,YAAY,EAClC;MACID;IACJ,CACJ,CAAC;EACL;EACA,OAAOE,MAAM;AACjB,CAAC;AAACK,OAAA,CAAAR,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.extractWhereParams = void 0;
|
|
7
|
+
const extractWhereParams = key => {
|
|
8
|
+
const isWbyAco = key.match("wbyAco_") !== null;
|
|
9
|
+
const result = key.replace("wbyAco_", "").split("_");
|
|
10
|
+
const fieldId = result.shift();
|
|
11
|
+
if (!fieldId) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const rawOp = result.length === 0 ? "eq" : result.join("_");
|
|
15
|
+
/**
|
|
16
|
+
* When rawOp is not, it means it is equal negated so just return that.
|
|
17
|
+
*/
|
|
18
|
+
if (rawOp === "not") {
|
|
19
|
+
return {
|
|
20
|
+
fieldId,
|
|
21
|
+
operation: "eq",
|
|
22
|
+
negate: true
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const negate = rawOp.match("not_") !== null;
|
|
26
|
+
const operation = rawOp.replace("not_", "");
|
|
27
|
+
return {
|
|
28
|
+
fieldId: isWbyAco ? `wbyAco_${fieldId}` : fieldId,
|
|
29
|
+
operation,
|
|
30
|
+
negate
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
exports.extractWhereParams = extractWhereParams;
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=where.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["extractWhereParams","key","isWbyAco","match","result","replace","split","fieldId","shift","rawOp","length","join","operation","negate","exports"],"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":";;;;;;AAAO,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;AAACC,OAAA,CAAAd,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export interface
|
|
1
|
+
import type { Entity } from "@webiny/db-dynamodb/toolbox";
|
|
2
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
import type { CmsEntryStorageOperations } from "../../types";
|
|
4
|
+
export interface CreateEntriesStorageOperationsParams {
|
|
5
5
|
entity: Entity<any>;
|
|
6
6
|
plugins: PluginsContainer;
|
|
7
7
|
}
|
|
8
|
-
export declare const createEntriesStorageOperations: (params:
|
|
8
|
+
export declare const createEntriesStorageOperations: (params: CreateEntriesStorageOperationsParams) => CmsEntryStorageOperations;
|