@webiny/api-headless-cms-ddb 0.0.0-unstable.d4f203fa97 → 0.0.0-unstable.d65ec29d44
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/model.js +5 -0
- package/definitions/model.js.map +1 -1
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/storage/date.d.ts +2 -1
- package/dynamoDb/storage/date.js +13 -3
- package/dynamoDb/storage/date.js.map +1 -1
- package/dynamoDb/storage/longText.d.ts +1 -1
- package/dynamoDb/storage/longText.js +7 -0
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.d.ts +1 -1
- package/dynamoDb/storage/richText.js.map +1 -1
- package/index.js +16 -4
- package/index.js.map +1 -1
- package/operations/entry/filtering/createExpressions.d.ts +26 -0
- package/operations/entry/filtering/createExpressions.js +213 -0
- package/operations/entry/filtering/createExpressions.js.map +1 -0
- package/operations/entry/filtering/createFields.d.ts +14 -0
- package/operations/entry/filtering/createFields.js +123 -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 +77 -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 +178 -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 +60 -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 +81 -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 +39 -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 +48 -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 +18 -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 +107 -0
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -0
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/refFilterCreate.js +89 -0
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -0
- package/operations/entry/filtering/sort.d.ts +12 -0
- package/operations/entry/filtering/sort.js +84 -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 +72 -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 +19 -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 +5 -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 +28 -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 +38 -0
- package/operations/entry/filtering/where.js.map +1 -0
- package/operations/entry/index.js +36 -19
- package/operations/entry/index.js.map +1 -1
- package/package.json +13 -13
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +2 -2
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +43 -0
- package/plugins/CmsEntryFieldFilterPlugin.js +31 -0
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -0
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
- package/plugins/CmsEntryFieldSortingPlugin.js +38 -0
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
- package/plugins/index.d.ts +2 -0
- package/plugins/index.js +26 -0
- package/plugins/index.js.map +1 -1
- package/types.d.ts +1 -1
- package/types.js.map +1 -1
- package/operations/entry/utils.d.ts +0 -36
- package/operations/entry/utils.js +0 -690
- package/operations/entry/utils.js.map +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Plugin, PluginsContainer } from "@webiny/plugins/types";
|
|
2
|
+
interface Params {
|
|
3
|
+
plugins: PluginsContainer;
|
|
4
|
+
type: string;
|
|
5
|
+
property: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const getMappedPlugins: <T extends Plugin<Record<string, any>>>(params: Params) => Record<string, T>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.getMappedPlugins = void 0;
|
|
9
|
+
|
|
10
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
+
|
|
12
|
+
const getMappedPlugins = params => {
|
|
13
|
+
const {
|
|
14
|
+
plugins: pluginsContainer,
|
|
15
|
+
type,
|
|
16
|
+
property
|
|
17
|
+
} = params;
|
|
18
|
+
const plugins = pluginsContainer.byType(type);
|
|
19
|
+
|
|
20
|
+
if (plugins.length === 0) {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return plugins.reduce((collection, plugin) => {
|
|
25
|
+
const key = plugin[property];
|
|
26
|
+
|
|
27
|
+
if (typeof key !== "string") {
|
|
28
|
+
throw new _error.default("Property to map the plugins on must be a string.", "PLUGIN_PROPERTY_ERROR", {
|
|
29
|
+
type,
|
|
30
|
+
property
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
collection[key] = plugin;
|
|
35
|
+
return collection;
|
|
36
|
+
}, {});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.getMappedPlugins = getMappedPlugins;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getMappedPlugins","params","plugins","pluginsContainer","type","property","byType","length","reduce","collection","plugin","key","WebinyError"],"sources":["mapPlugins.ts"],"sourcesContent":["import { Plugin, PluginsContainer } from \"@webiny/plugins/types\";\nimport WebinyError from \"@webiny/error\";\n\ninterface Params {\n plugins: PluginsContainer;\n type: string;\n property: string;\n}\nexport const getMappedPlugins = <T extends Plugin>(params: Params) => {\n const { plugins: pluginsContainer, type, property } = params;\n const plugins = pluginsContainer.byType<T>(type);\n if (plugins.length === 0) {\n return {};\n }\n return plugins.reduce<Record<string, T>>((collection, plugin) => {\n const key: keyof typeof plugin = 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 }, {});\n};\n"],"mappings":";;;;;;;;;AACA;;AAOO,MAAMA,gBAAgB,GAAsBC,MAAnB,IAAsC;EAClE,MAAM;IAAEC,OAAO,EAAEC,gBAAX;IAA6BC,IAA7B;IAAmCC;EAAnC,IAAgDJ,MAAtD;EACA,MAAMC,OAAO,GAAGC,gBAAgB,CAACG,MAAjB,CAA2BF,IAA3B,CAAhB;;EACA,IAAIF,OAAO,CAACK,MAAR,KAAmB,CAAvB,EAA0B;IACtB,OAAO,EAAP;EACH;;EACD,OAAOL,OAAO,CAACM,MAAR,CAAkC,CAACC,UAAD,EAAaC,MAAb,KAAwB;IAC7D,MAAMC,GAAwB,GAAGD,MAAM,CAACL,QAAD,CAAvC;;IACA,IAAI,OAAOM,GAAP,KAAe,QAAnB,EAA6B;MACzB,MAAM,IAAIC,cAAJ,CACF,kDADE,EAEF,uBAFE,EAGF;QACIR,IADJ;QAEIC;MAFJ,CAHE,CAAN;IAQH;;IACDI,UAAU,CAACE,GAAD,CAAV,GAAkBD,MAAlB;IACA,OAAOD,UAAP;EACH,CAdM,EAcJ,EAdI,CAAP;AAeH,CArBM"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createDefaultFilterCreate = void 0;
|
|
9
|
+
|
|
10
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
+
|
|
12
|
+
var _CmsEntryFieldFilterPlugin = require("../../../../plugins/CmsEntryFieldFilterPlugin");
|
|
13
|
+
|
|
14
|
+
const createDefaultFilterCreate = () => {
|
|
15
|
+
return new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
|
|
16
|
+
fieldType: _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin.ALL,
|
|
17
|
+
create: params => {
|
|
18
|
+
const {
|
|
19
|
+
negate,
|
|
20
|
+
transformValue,
|
|
21
|
+
field,
|
|
22
|
+
compareValue,
|
|
23
|
+
valueFilterPlugins
|
|
24
|
+
} = params;
|
|
25
|
+
const plugin = valueFilterPlugins[params.operation];
|
|
26
|
+
|
|
27
|
+
if (!plugin) {
|
|
28
|
+
throw new _error.default(`Missing ValueFilterPlugin for operation "${params.operation}".`, "MISSING_OPERATION_PLUGIN", {
|
|
29
|
+
operation: params.operation
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
negate,
|
|
35
|
+
transformValue,
|
|
36
|
+
field,
|
|
37
|
+
compareValue,
|
|
38
|
+
fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join("."),
|
|
39
|
+
path: field.createPath({
|
|
40
|
+
field
|
|
41
|
+
}),
|
|
42
|
+
plugin
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.createDefaultFilterCreate = createDefaultFilterCreate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createDefaultFilterCreate","CmsEntryFieldFilterPlugin","fieldType","ALL","create","params","negate","transformValue","field","compareValue","valueFilterPlugins","plugin","operation","WebinyError","fieldPathId","parents","map","f","fieldId","join","path","createPath"],"sources":["defaultFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin\";\n\nexport const createDefaultFilterCreate = () => {\n return new CmsEntryFieldFilterPlugin({\n fieldType: CmsEntryFieldFilterPlugin.ALL,\n create: params => {\n const { negate, transformValue, field, compareValue, valueFilterPlugins } = params;\n const plugin = valueFilterPlugins[params.operation];\n if (!plugin) {\n throw new WebinyError(\n `Missing ValueFilterPlugin for operation \"${params.operation}\".`,\n \"MISSING_OPERATION_PLUGIN\",\n {\n operation: params.operation\n }\n );\n }\n return {\n negate,\n transformValue,\n field,\n compareValue,\n fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join(\".\"),\n path: field.createPath({\n field\n }),\n plugin\n };\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEO,MAAMA,yBAAyB,GAAG,MAAM;EAC3C,OAAO,IAAIC,oDAAJ,CAA8B;IACjCC,SAAS,EAAED,oDAAA,CAA0BE,GADJ;IAEjCC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,MAAF;QAAUC,cAAV;QAA0BC,KAA1B;QAAiCC,YAAjC;QAA+CC;MAA/C,IAAsEL,MAA5E;MACA,MAAMM,MAAM,GAAGD,kBAAkB,CAACL,MAAM,CAACO,SAAR,CAAjC;;MACA,IAAI,CAACD,MAAL,EAAa;QACT,MAAM,IAAIE,cAAJ,CACD,4CAA2CR,MAAM,CAACO,SAAU,IAD3D,EAEF,0BAFE,EAGF;UACIA,SAAS,EAAEP,MAAM,CAACO;QADtB,CAHE,CAAN;MAOH;;MACD,OAAO;QACHN,MADG;QAEHC,cAFG;QAGHC,KAHG;QAIHC,YAJG;QAKHK,WAAW,EAAE,CAAC,GAAGN,KAAK,CAACO,OAAN,CAAcC,GAAd,CAAkBC,CAAC,IAAIA,CAAC,CAACC,OAAzB,CAAJ,EAAuCV,KAAK,CAACU,OAA7C,EAAsDC,IAAtD,CAA2D,GAA3D,CALV;QAMHC,IAAI,EAAEZ,KAAK,CAACa,UAAN,CAAiB;UACnBb;QADmB,CAAjB,CANH;QASHG;MATG,CAAP;IAWH;EAzBgC,CAA9B,CAAP;AA2BH,CA5BM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const createFilterCreatePlugins: () => import("../../../..").CmsEntryFieldFilterPlugin[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createFilterCreatePlugins = void 0;
|
|
7
|
+
|
|
8
|
+
var _defaultFilterCreate = require("./defaultFilterCreate");
|
|
9
|
+
|
|
10
|
+
var _refFilterCreate = require("./refFilterCreate");
|
|
11
|
+
|
|
12
|
+
var _objectFilterCreate = require("./objectFilterCreate");
|
|
13
|
+
|
|
14
|
+
const createFilterCreatePlugins = () => {
|
|
15
|
+
return [(0, _defaultFilterCreate.createDefaultFilterCreate)(), (0, _refFilterCreate.createRefFilterCreate)(), (0, _objectFilterCreate.objectFilterCreate)()];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.createFilterCreatePlugins = createFilterCreatePlugins;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFilterCreatePlugins","createDefaultFilterCreate","createRefFilterCreate","objectFilterCreate"],"sources":["index.ts"],"sourcesContent":["import { createDefaultFilterCreate } from \"./defaultFilterCreate\";\nimport { createRefFilterCreate } from \"./refFilterCreate\";\nimport { objectFilterCreate } from \"./objectFilterCreate\";\n\nexport const createFilterCreatePlugins = () => {\n return [createDefaultFilterCreate(), createRefFilterCreate(), objectFilterCreate()];\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEO,MAAMA,yBAAyB,GAAG,MAAM;EAC3C,OAAO,CAAC,IAAAC,8CAAA,GAAD,EAA8B,IAAAC,sCAAA,GAA9B,EAAuD,IAAAC,sCAAA,GAAvD,CAAP;AACH,CAFM"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.objectFilterCreate = void 0;
|
|
9
|
+
|
|
10
|
+
var _CmsEntryFieldFilterPlugin = require("../../../../plugins/CmsEntryFieldFilterPlugin");
|
|
11
|
+
|
|
12
|
+
var _where = require("../where");
|
|
13
|
+
|
|
14
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
+
|
|
16
|
+
var _transform = require("../transform");
|
|
17
|
+
|
|
18
|
+
const objectFilterCreate = () => {
|
|
19
|
+
return new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
|
|
20
|
+
fieldType: "object",
|
|
21
|
+
create: params => {
|
|
22
|
+
const {
|
|
23
|
+
value: objectValue,
|
|
24
|
+
valueFilterPlugins,
|
|
25
|
+
transformValuePlugins,
|
|
26
|
+
getFilterCreatePlugin,
|
|
27
|
+
field: parentField,
|
|
28
|
+
fields
|
|
29
|
+
} = params;
|
|
30
|
+
const filters = [];
|
|
31
|
+
|
|
32
|
+
for (const key in objectValue) {
|
|
33
|
+
const value = objectValue[key];
|
|
34
|
+
|
|
35
|
+
if (value === undefined) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const whereParams = (0, _where.extractWhereParams)(key);
|
|
40
|
+
|
|
41
|
+
if (!whereParams) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
negate,
|
|
47
|
+
fieldId,
|
|
48
|
+
operation
|
|
49
|
+
} = whereParams;
|
|
50
|
+
const fieldPath = parentField.parents.map(p => p.fieldId).concat([parentField.fieldId, fieldId]).join(".");
|
|
51
|
+
const field = fields[fieldPath];
|
|
52
|
+
|
|
53
|
+
if (!field) {
|
|
54
|
+
throw new _error.default(`There is no field with the field path "${fieldPath}".`, "FIELD_ERROR", {
|
|
55
|
+
fieldId
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const filterCreatePlugin = getFilterCreatePlugin(field.type);
|
|
60
|
+
const transformValuePlugin = transformValuePlugins[field.type];
|
|
61
|
+
|
|
62
|
+
const transformValueCallable = value => {
|
|
63
|
+
if (!transformValuePlugin) {
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return transformValuePlugin.transform({
|
|
68
|
+
field,
|
|
69
|
+
value
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const result = filterCreatePlugin.create({
|
|
74
|
+
key,
|
|
75
|
+
value,
|
|
76
|
+
valueFilterPlugins,
|
|
77
|
+
transformValuePlugins,
|
|
78
|
+
getFilterCreatePlugin,
|
|
79
|
+
operation,
|
|
80
|
+
negate,
|
|
81
|
+
field,
|
|
82
|
+
fields,
|
|
83
|
+
compareValue: (0, _transform.transformValue)({
|
|
84
|
+
value,
|
|
85
|
+
transform: transformValueCallable
|
|
86
|
+
}),
|
|
87
|
+
transformValue: transformValueCallable
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
if (!result) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (Array.isArray(result)) {
|
|
95
|
+
filters.push(...result);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
filters.push(result);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return filters;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
exports.objectFilterCreate = objectFilterCreate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["objectFilterCreate","CmsEntryFieldFilterPlugin","fieldType","create","params","value","objectValue","valueFilterPlugins","transformValuePlugins","getFilterCreatePlugin","field","parentField","fields","filters","key","undefined","whereParams","extractWhereParams","negate","fieldId","operation","fieldPath","parents","map","p","concat","join","WebinyError","filterCreatePlugin","type","transformValuePlugin","transformValueCallable","transform","result","compareValue","transformValue","Array","isArray","push"],"sources":["objectFilterCreate.ts"],"sourcesContent":["import { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsFieldFilterValueTransformPlugin } from \"~/types\";\nimport { transformValue } from \"~/operations/entry/filtering/transform\";\n\nexport const objectFilterCreate = () => {\n return 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 filterCreatePlugin = getFilterCreatePlugin(field.type);\n\n const transformValuePlugin: CmsFieldFilterValueTransformPlugin =\n transformValuePlugins[field.type];\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"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEO,MAAMA,kBAAkB,GAAG,MAAM;EACpC,OAAO,IAAIC,oDAAJ,CAA8B;IACjCC,SAAS,EAAE,QADsB;IAEjCC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QACFC,KAAK,EAAEC,WADL;QAEFC,kBAFE;QAGFC,qBAHE;QAIFC,qBAJE;QAKFC,KAAK,EAAEC,WALL;QAMFC;MANE,IAOFR,MAPJ;MASA,MAAMS,OAAO,GAAG,EAAhB;;MAEA,KAAK,MAAMC,GAAX,IAAkBR,WAAlB,EAA+B;QAC3B,MAAMD,KAAK,GAAGC,WAAW,CAACQ,GAAD,CAAzB;;QACA,IAAIT,KAAK,KAAKU,SAAd,EAAyB;UACrB;QACH;;QACD,MAAMC,WAAW,GAAG,IAAAC,yBAAA,EAAmBH,GAAnB,CAApB;;QACA,IAAI,CAACE,WAAL,EAAkB;UACd;QACH;;QACD,MAAM;UAAEE,MAAF;UAAUC,OAAV;UAAmBC;QAAnB,IAAiCJ,WAAvC;QAEA,MAA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AaL,MAAb;MACH;;MACD,OAAOpB,OAAP;IACH;EAnFgC,CAA9B,CAAP;AAqFH,CAtFM"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createRefFilterCreate = void 0;
|
|
9
|
+
|
|
10
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
+
|
|
12
|
+
var _CmsEntryFieldFilterPlugin = require("../../../../plugins/CmsEntryFieldFilterPlugin");
|
|
13
|
+
|
|
14
|
+
var _where = require("../where");
|
|
15
|
+
|
|
16
|
+
var _transform = require("../transform");
|
|
17
|
+
|
|
18
|
+
const createRefFilterCreate = () => {
|
|
19
|
+
return new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
|
|
20
|
+
fieldType: "ref",
|
|
21
|
+
create: params => {
|
|
22
|
+
const {
|
|
23
|
+
value,
|
|
24
|
+
valueFilterPlugins,
|
|
25
|
+
transformValuePlugins,
|
|
26
|
+
field
|
|
27
|
+
} = params;
|
|
28
|
+
const propertyFilters = Object.keys(value);
|
|
29
|
+
|
|
30
|
+
if (propertyFilters.length === 0) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const filters = [];
|
|
35
|
+
|
|
36
|
+
for (const propertyFilter of propertyFilters) {
|
|
37
|
+
const whereParams = (0, _where.extractWhereParams)(propertyFilter);
|
|
38
|
+
|
|
39
|
+
if (!whereParams) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
fieldId: propertyId,
|
|
45
|
+
operation: propertyOperation,
|
|
46
|
+
negate
|
|
47
|
+
} = whereParams;
|
|
48
|
+
const transformValuePlugin = transformValuePlugins[field.type];
|
|
49
|
+
|
|
50
|
+
const transformValueCallable = value => {
|
|
51
|
+
if (!transformValuePlugin) {
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return transformValuePlugin.transform({
|
|
56
|
+
field,
|
|
57
|
+
value
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const filterPlugin = valueFilterPlugins[propertyOperation];
|
|
62
|
+
|
|
63
|
+
if (!filterPlugin) {
|
|
64
|
+
throw new _error.default(`Missing operation filter for "${propertyOperation}".`, "MISSING_OPERATION_FILTER");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const paths = [field.createPath({
|
|
68
|
+
field
|
|
69
|
+
}), propertyId];
|
|
70
|
+
filters.push({
|
|
71
|
+
field,
|
|
72
|
+
path: paths.join("."),
|
|
73
|
+
fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join("."),
|
|
74
|
+
plugin: filterPlugin,
|
|
75
|
+
negate,
|
|
76
|
+
compareValue: (0, _transform.transformValue)({
|
|
77
|
+
value: value[propertyFilter],
|
|
78
|
+
transform: transformValueCallable
|
|
79
|
+
}),
|
|
80
|
+
transformValue: transformValueCallable
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return filters;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
exports.createRefFilterCreate = createRefFilterCreate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createRefFilterCreate","CmsEntryFieldFilterPlugin","fieldType","create","params","value","valueFilterPlugins","transformValuePlugins","field","propertyFilters","Object","keys","length","filters","propertyFilter","whereParams","extractWhereParams","fieldId","propertyId","operation","propertyOperation","negate","transformValuePlugin","type","transformValueCallable","transform","filterPlugin","WebinyError","paths","createPath","push","path","join","fieldPathId","parents","map","f","plugin","compareValue","transformValue"],"sources":["refFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n CmsEntryFieldFilterPlugin,\n CmsEntryFieldFilterPluginCreateResponse\n} from \"~/plugins/CmsEntryFieldFilterPlugin\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where\";\nimport { transformValue } from \"~/operations/entry/filtering/transform\";\n\nexport const createRefFilterCreate = () => {\n return new CmsEntryFieldFilterPlugin({\n fieldType: \"ref\",\n create: params => {\n const { value, valueFilterPlugins, transformValuePlugins, field } = params;\n const propertyFilters = Object.keys(value);\n if (propertyFilters.length === 0) {\n return null;\n }\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 transformValuePlugin = transformValuePlugins[field.type];\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"],"mappings":";;;;;;;;;AAAA;;AACA;;AAIA;;AACA;;AAEO,MAAMA,qBAAqB,GAAG,MAAM;EACvC,OAAO,IAAIC,oDAAJ,CAA8B;IACjCC,SAAS,EAAE,KADsB;IAEjCC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,KAAF;QAASC,kBAAT;QAA6BC,qBAA7B;QAAoDC;MAApD,IAA8DJ,MAApE;MACA,MAA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D,CAHJ;UAITK,MAAM,EAAEX,YAJC;UAKTL,MALS;UAMTiB,YAAY,EAAE,IAAAC,yBAAA,EAAe;YACzBlC,KAAK,EAAEA,KAAK,CAACS,cAAD,CADa;YAEzBW,SAAS,EAAED;UAFc,CAAf,CANL;UAUTe,cAAc,EAAEf;QAVP,CAAb;MAYH;;MAED,OAAOX,OAAP;IACH;EA5DgC,CAA9B,CAAP;AA8DH,CA/DM"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import { Field } from "./types";
|
|
3
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
4
|
+
interface Params {
|
|
5
|
+
model: CmsModel;
|
|
6
|
+
items: CmsEntry[];
|
|
7
|
+
sort?: string[];
|
|
8
|
+
fields: Record<string, Field>;
|
|
9
|
+
plugins: PluginsContainer;
|
|
10
|
+
}
|
|
11
|
+
export declare const sort: (params: Params) => CmsEntry[];
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.sort = void 0;
|
|
9
|
+
|
|
10
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
+
|
|
12
|
+
var _dotProp = _interopRequireDefault(require("dot-prop"));
|
|
13
|
+
|
|
14
|
+
var _sortBy = _interopRequireDefault(require("lodash/sortBy"));
|
|
15
|
+
|
|
16
|
+
var _extractSort = require("./extractSort");
|
|
17
|
+
|
|
18
|
+
const sort = params => {
|
|
19
|
+
const {
|
|
20
|
+
model,
|
|
21
|
+
items,
|
|
22
|
+
sort = [],
|
|
23
|
+
fields,
|
|
24
|
+
plugins
|
|
25
|
+
} = params;
|
|
26
|
+
|
|
27
|
+
if (items.length <= 1) {
|
|
28
|
+
return items;
|
|
29
|
+
} else if (sort.length === 0) {
|
|
30
|
+
sort.push("savedOn_DESC");
|
|
31
|
+
} else if (sort.length > 1) {
|
|
32
|
+
throw new _error.default("Sorting is limited to a single field.", "SORT_MULTIPLE_FIELDS_ERROR", {
|
|
33
|
+
sort: sort
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const [firstSort] = sort;
|
|
38
|
+
|
|
39
|
+
if (!firstSort) {
|
|
40
|
+
throw new _error.default("Empty sort array item.", "SORT_EMPTY_ERROR", {
|
|
41
|
+
sort
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const {
|
|
46
|
+
fieldId,
|
|
47
|
+
field,
|
|
48
|
+
valuePath,
|
|
49
|
+
reverse
|
|
50
|
+
} = (0, _extractSort.extractSort)({
|
|
51
|
+
model,
|
|
52
|
+
sortBy: firstSort,
|
|
53
|
+
fields,
|
|
54
|
+
plugins
|
|
55
|
+
});
|
|
56
|
+
const itemsToSort = items.map(item => {
|
|
57
|
+
return {
|
|
58
|
+
id: item.id,
|
|
59
|
+
value: field.transform(_dotProp.default.get(item, valuePath))
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
const sortedItems = (0, _sortBy.default)(itemsToSort, "value");
|
|
63
|
+
const newItems = sortedItems.map(s => {
|
|
64
|
+
const item = items.find(i => i.id === s.id);
|
|
65
|
+
|
|
66
|
+
if (item) {
|
|
67
|
+
return item;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
throw new _error.default("Could not find item by given id after the sorting.", "SORTING_ITEMS_ERROR", {
|
|
71
|
+
id: s.id,
|
|
72
|
+
sortingBy: fieldId,
|
|
73
|
+
reverse
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
if (!reverse) {
|
|
78
|
+
return newItems;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return newItems.reverse();
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
exports.sort = sort;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["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"],"sources":["sort.ts"],"sourcesContent":["import { 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 { Field } from \"./types\";\nimport { 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.\",\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({\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 }\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B,OAA1B,CAAlC;EACA,MAAMU,QAAQ,GAAGF,WAAW,CAACP,GAAZ,CAAgBU,CAAC,IAAI;IAClC,MAAMT,IAAI,GAAGf,KAAK,CAACyB,IAAN,CAAWC,CAAC,IAAIA,CAAC,CAACV,EAAF,KAASQ,CAAC,CAACR,EAA3B,CAAb;;IACA,IAAID,IAAJ,EAAU;MACN,OAAOA,IAAP;IACH;;IACD,MAAM,IAAIV,cAAJ,CACF,oDADE,EAEF,qBAFE,EAGF;MACIW,EAAE,EAAEQ,CAAC,CAACR,EADV;MAEIW,SAAS,EAAEpB,OAFf;MAGIG;IAHJ,CAHE,CAAN;EASH,CAdgB,CAAjB;;EAeA,IAAI,CAACA,OAAL,EAAc;IACV,OAAOa,QAAP;EACH;;EACD,OAAOA,QAAQ,CAACb,OAAT,EAAP;AACH,CAvDM"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createSystemFields = void 0;
|
|
7
|
+
|
|
8
|
+
const createSystemFields = () => {
|
|
9
|
+
return [{
|
|
10
|
+
id: "id",
|
|
11
|
+
type: "text",
|
|
12
|
+
storageId: "id",
|
|
13
|
+
fieldId: "id",
|
|
14
|
+
label: "ID"
|
|
15
|
+
}, {
|
|
16
|
+
id: "entryId",
|
|
17
|
+
type: "text",
|
|
18
|
+
storageId: "entryId",
|
|
19
|
+
fieldId: "entryId",
|
|
20
|
+
label: "Entry ID"
|
|
21
|
+
}, {
|
|
22
|
+
id: "createdOn",
|
|
23
|
+
type: "datetime",
|
|
24
|
+
storageId: "createdOn",
|
|
25
|
+
fieldId: "createdOn",
|
|
26
|
+
label: "Created On"
|
|
27
|
+
}, {
|
|
28
|
+
id: "savedOn",
|
|
29
|
+
type: "datetime",
|
|
30
|
+
storageId: "savedOn",
|
|
31
|
+
fieldId: "savedOn",
|
|
32
|
+
label: "Saved On"
|
|
33
|
+
}, {
|
|
34
|
+
id: "createdBy",
|
|
35
|
+
type: "plainObject",
|
|
36
|
+
storageId: "createdBy",
|
|
37
|
+
fieldId: "createdBy",
|
|
38
|
+
label: "Created By",
|
|
39
|
+
settings: {
|
|
40
|
+
path: "createdBy.id"
|
|
41
|
+
}
|
|
42
|
+
}, {
|
|
43
|
+
id: "meta",
|
|
44
|
+
type: "plainObject",
|
|
45
|
+
storageId: "meta",
|
|
46
|
+
fieldId: "meta",
|
|
47
|
+
label: "Meta"
|
|
48
|
+
}, {
|
|
49
|
+
id: "ownedBy",
|
|
50
|
+
type: "plainObject",
|
|
51
|
+
storageId: "ownedBy",
|
|
52
|
+
fieldId: "ownedBy",
|
|
53
|
+
label: "Owned By",
|
|
54
|
+
settings: {
|
|
55
|
+
path: "ownedBy.id"
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
id: "version",
|
|
59
|
+
type: "number",
|
|
60
|
+
storageId: "version",
|
|
61
|
+
fieldId: "version",
|
|
62
|
+
label: "Version"
|
|
63
|
+
}, {
|
|
64
|
+
id: "status",
|
|
65
|
+
type: "text",
|
|
66
|
+
storageId: "status",
|
|
67
|
+
fieldId: "status",
|
|
68
|
+
label: "Status"
|
|
69
|
+
}];
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
exports.createSystemFields = createSystemFields;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createSystemFields","id","type","storageId","fieldId","label","settings","path"],"sources":["systemFields.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\ntype Field = Pick<CmsModelField, \"id\" | \"type\" | \"storageId\" | \"fieldId\" | \"settings\" | \"label\">;\n\nexport const createSystemFields = (): Field[] => {\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 id: \"createdOn\",\n type: \"datetime\",\n storageId: \"createdOn\",\n fieldId: \"createdOn\",\n label: \"Created On\"\n },\n {\n id: \"savedOn\",\n type: \"datetime\",\n storageId: \"savedOn\",\n fieldId: \"savedOn\",\n label: \"Saved On\"\n },\n {\n id: \"createdBy\",\n type: \"plainObject\",\n storageId: \"createdBy\",\n fieldId: \"createdBy\",\n label: \"Created By\",\n settings: {\n path: \"createdBy.id\"\n }\n },\n {\n id: \"meta\",\n type: \"plainObject\",\n storageId: \"meta\",\n fieldId: \"meta\",\n label: \"Meta\"\n },\n {\n id: \"ownedBy\",\n type: \"plainObject\",\n storageId: \"ownedBy\",\n fieldId: \"ownedBy\",\n label: \"Owned By\",\n settings: {\n path: \"ownedBy.id\"\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};\n"],"mappings":";;;;;;;AAIO,MAAMA,kBAAkB,GAAG,MAAe;EAC7C,OAAO,CACH;IACIC,EAAE,EAAE,IADR;IAEIC,IAAI,EAAE,MAFV;IAGIC,SAAS,EAAE,IAHf;IAIIC,OAAO,EAAE,IAJb;IAKIC,KAAK,EAAE;EALX,CADG,EAQH;IACIJ,EAAE,EAAE,SADR;IAEIC,IAAI,EAAE,MAFV;IAGIC,SAAS,EAAE,SAHf;IAIIC,OAAO,EAAE,SAJb;IAKIC,KAAK,EAAE;EALX,CARG,EAeH;IACIJ,EAAE,EAAE,WADR;IAEIC,IAAI,EAAE,UAFV;IAGIC,SAAS,EAAE,WAHf;IAIIC,OAAO,EAAE,WAJb;IAKIC,KAAK,EAAE;EALX,CAfG,EAsBH;IACIJ,EAAE,EAAE,SADR;IAEIC,IAAI,EAAE,UAFV;IAGIC,SAAS,EAAE,SAHf;IAIIC,OAAO,EAAE,SAJb;IAKIC,KAAK,EAAE;EALX,CAtBG,EA6BH;IACIJ,EAAE,EAAE,WADR;IAEIC,IAAI,EAAE,aAFV;IAGIC,SAAS,EAAE,WAHf;IAIIC,OAAO,EAAE,WAJb;IAKIC,KAAK,EAAE,YALX;IAMIC,QAAQ,EAAE;MACNC,IAAI,EAAE;IADA;EANd,CA7BG,EAuCH;IACIN,EAAE,EAAE,MADR;IAEIC,IAAI,EAAE,aAFV;IAGIC,SAAS,EAAE,MAHf;IAIIC,OAAO,EAAE,MAJb;IAKIC,KAAK,EAAE;EALX,CAvCG,EA8CH;IACIJ,EAAE,EAAE,SADR;IAEIC,IAAI,EAAE,aAFV;IAGIC,SAAS,EAAE,SAHf;IAIIC,OAAO,EAAE,SAJb;IAKIC,KAAK,EAAE,UALX;IAMIC,QAAQ,EAAE;MACNC,IAAI,EAAE;IADA;EANd,CA9CG,EAwDH;IACIN,EAAE,EAAE,SADR;IAEIC,IAAI,EAAE,QAFV;IAGIC,SAAS,EAAE,SAHf;IAIIC,OAAO,EAAE,SAJb;IAKIC,KAAK,EAAE;EALX,CAxDG,EA+DH;IACIJ,EAAE,EAAE,QADR;IAEIC,IAAI,EAAE,MAFV;IAGIC,SAAS,EAAE,QAHf;IAIIC,OAAO,EAAE,QAJb;IAKIC,KAAK,EAAE;EALX,CA/DG,CAAP;AAuEH,CAxEM"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.transformValue = void 0;
|
|
7
|
+
|
|
8
|
+
const transformValue = ({
|
|
9
|
+
value,
|
|
10
|
+
transform
|
|
11
|
+
}) => {
|
|
12
|
+
if (Array.isArray(value)) {
|
|
13
|
+
return value.map(v => transform(v));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return transform(value);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.transformValue = transformValue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["transformValue","value","transform","Array","isArray","map","v"],"sources":["transform.ts"],"sourcesContent":["import { 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,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAAuC;EACjE,IAAIC,KAAK,CAACC,OAAN,CAAcH,KAAd,CAAJ,EAA0B;IACtB,OAAOA,KAAK,CAACI,GAAN,CAAUC,CAAC,IAAIJ,SAAS,CAACI,CAAD,CAAxB,CAAP;EACH;;EACD,OAAOJ,SAAS,CAACD,KAAD,CAAhB;AACH,CALM"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { CmsModelField } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import { 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 {};
|