@webiny/api-headless-cms-ddb 5.34.8 → 5.35.0-beta.1
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.js +3 -5
- package/definitions/entry.js.map +1 -1
- package/definitions/group.js +0 -5
- package/definitions/group.js.map +1 -1
- package/definitions/model.js +17 -5
- package/definitions/model.js.map +1 -1
- package/definitions/settings.js +0 -5
- package/definitions/settings.js.map +1 -1
- package/definitions/system.js +0 -5
- package/definitions/system.js.map +1 -1
- package/definitions/table.js +0 -3
- package/definitions/table.js.map +1 -1
- package/dynamoDb/index.js +0 -7
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/path/plainObject.js +1 -8
- package/dynamoDb/path/plainObject.js.map +1 -1
- package/dynamoDb/storage/date.js +1 -19
- package/dynamoDb/storage/date.js.map +1 -1
- package/dynamoDb/storage/longText.js +1 -18
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.js +0 -18
- package/dynamoDb/storage/richText.js.map +1 -1
- package/dynamoDb/transformValue/datetime.js +1 -8
- package/dynamoDb/transformValue/datetime.js.map +1 -1
- package/index.js +6 -30
- package/index.js.map +1 -1
- package/operations/entry/dataLoaders.js +1 -44
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/filtering/createExpressions.js +2 -39
- package/operations/entry/filtering/createExpressions.js.map +1 -1
- package/operations/entry/filtering/createFields.js +0 -18
- package/operations/entry/filtering/createFields.js.map +1 -1
- package/operations/entry/filtering/extractSort.js +0 -10
- package/operations/entry/filtering/extractSort.js.map +1 -1
- package/operations/entry/filtering/filter.js +1 -36
- package/operations/entry/filtering/filter.js.map +1 -1
- package/operations/entry/filtering/fullTextSearch.js +0 -12
- package/operations/entry/filtering/fullTextSearch.js.map +1 -1
- package/operations/entry/filtering/getValue.js +0 -18
- package/operations/entry/filtering/getValue.js.map +1 -1
- package/operations/entry/filtering/index.js +0 -2
- package/operations/entry/filtering/index.js.map +1 -1
- package/operations/entry/filtering/mapPlugins.js +0 -8
- package/operations/entry/filtering/mapPlugins.js.map +1 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -7
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/index.js +0 -5
- package/operations/entry/filtering/plugins/index.js.map +1 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -21
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/refFilterCreate.js +0 -18
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
- package/operations/entry/filtering/sort.js +0 -15
- package/operations/entry/filtering/sort.js.map +1 -1
- package/operations/entry/filtering/systemFields.js +0 -2
- package/operations/entry/filtering/systemFields.js.map +1 -1
- package/operations/entry/filtering/transform.js +0 -3
- package/operations/entry/filtering/transform.js.map +1 -1
- package/operations/entry/filtering/values.js +0 -6
- package/operations/entry/filtering/values.js.map +1 -1
- package/operations/entry/filtering/where.js +0 -6
- package/operations/entry/filtering/where.js.map +1 -1
- package/operations/entry/index.js +58 -116
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.js +0 -18
- package/operations/entry/keys.js.map +1 -1
- package/operations/entry/systemFields.js +0 -2
- package/operations/entry/systemFields.js.map +1 -1
- package/operations/group/index.js +2 -32
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.js +0 -25
- package/operations/model/index.js.map +1 -1
- package/operations/settings/index.js +0 -24
- package/operations/settings/index.js.map +1 -1
- package/operations/system/index.js +0 -17
- package/operations/system/index.js.map +1 -1
- package/package.json +13 -13
- package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -14
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldFilterPlugin.js +0 -7
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldSortingPlugin.js +0 -10
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js +24 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +1 -0
- package/plugins/index.js +11 -6
- package/plugins/index.js.map +1 -1
- package/types.js +0 -1
- package/types.js.map +1 -1
|
@@ -1 +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":"
|
|
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,oDAAyB,CAAC;IACjCC,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,KAAK,KAAKU,SAAS,EAAE;UACrB;QACJ;QACA,MAAMC,WAAW,GAAG,IAAAC,yBAAkB,EAACH,GAAG,CAAC;QAC3C,IAAI,CAACE,WAAW,EAAE;UACd;QACJ;QACA,MAAM;UAAEE,MAAM;UAAEC,OAAO;UAAEC;QAAU,CAAC,GAAGJ,WAAW;QAElD,MAAMK,SAAS,GAAGV,WAAW,CAACW,OAAO,CAChCC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACL,OAAO,CAAC,CACnBM,MAAM,CAAC,CAACd,WAAW,CAACQ,OAAO,EAAEA,OAAO,CAAC,CAAC,CACtCO,IAAI,CAAC,GAAG,CAAC;QAEd,MAAMhB,KAAK,GAAGE,MAAM,CAACS,SAAS,CAAC;QAC/B,IAAI,CAACX,KAAK,EAAE;UACR,MAAM,IAAIiB,cAAW,CAChB,0CAAyCN,SAAU,IAAG,EACvD,aAAa,EACb;YACIF;UACJ,CAAC,CACJ;QACL;QAEA,MAAMS,kBAAkB,GAAGnB,qBAAqB,CAACC,KAAK,CAACmB,IAAI,CAAC;QAE5D,MAAMC,oBAAwD,GAC1DtB,qBAAqB,CAACE,KAAK,CAACmB,IAAI,CAAC;QAErC,MAAME,sBAAsB,GAAI1B,KAAU,IAAK;UAC3C,IAAI,CAACyB,oBAAoB,EAAE;YACvB,OAAOzB,KAAK;UAChB;UACA,OAAOyB,oBAAoB,CAACE,SAAS,CAAC;YAClCtB,KAAK;YACLL;UACJ,CAAC,CAAC;QACN,CAAC;QAED,MAAM4B,MAAM,GAAGL,kBAAkB,CAACzB,MAAM,CAAC;UACrCW,GAAG;UACHT,KAAK;UACLE,kBAAkB;UAClBC,qBAAqB;UACrBC,qBAAqB;UACrBW,SAAS;UACTF,MAAM;UACNR,KAAK;UACLE,MAAM;UACNsB,YAAY,EAAE,IAAAC,yBAAc,EAAC;YACzB9B,KAAK;YACL2B,SAAS,EAAED;UACf,CAAC,CAAC;UACFI,cAAc,EAAEJ;QACpB,CAAC,CAAC;QACF,IAAI,CAACE,MAAM,EAAE;UACT;QACJ;QACA,IAAIG,KAAK,CAACC,OAAO,CAACJ,MAAM,CAAC,EAAE;UACvBpB,OAAO,CAACyB,IAAI,CAAC,GAAGL,MAAM,CAAC;UACvB;QACJ;QAEApB,OAAO,CAACyB,IAAI,CAACL,MAAM,CAAC;MACxB;MACA,OAAOpB,OAAO;IAClB;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createRefFilterCreate = void 0;
|
|
9
|
-
|
|
10
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
9
|
var _CmsEntryFieldFilterPlugin = require("../../../../plugins/CmsEntryFieldFilterPlugin");
|
|
13
|
-
|
|
14
10
|
var _where = require("../where");
|
|
15
|
-
|
|
16
11
|
var _transform = require("../transform");
|
|
17
|
-
|
|
18
12
|
const createRefFilterCreate = () => {
|
|
19
13
|
return new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
|
|
20
14
|
fieldType: "ref",
|
|
@@ -26,44 +20,34 @@ const createRefFilterCreate = () => {
|
|
|
26
20
|
field
|
|
27
21
|
} = params;
|
|
28
22
|
const propertyFilters = Object.keys(value);
|
|
29
|
-
|
|
30
23
|
if (propertyFilters.length === 0) {
|
|
31
24
|
return null;
|
|
32
25
|
}
|
|
33
|
-
|
|
34
26
|
const filters = [];
|
|
35
|
-
|
|
36
27
|
for (const propertyFilter of propertyFilters) {
|
|
37
28
|
const whereParams = (0, _where.extractWhereParams)(propertyFilter);
|
|
38
|
-
|
|
39
29
|
if (!whereParams) {
|
|
40
30
|
continue;
|
|
41
31
|
}
|
|
42
|
-
|
|
43
32
|
const {
|
|
44
33
|
fieldId: propertyId,
|
|
45
34
|
operation: propertyOperation,
|
|
46
35
|
negate
|
|
47
36
|
} = whereParams;
|
|
48
37
|
const transformValuePlugin = transformValuePlugins[field.type];
|
|
49
|
-
|
|
50
38
|
const transformValueCallable = value => {
|
|
51
39
|
if (!transformValuePlugin) {
|
|
52
40
|
return value;
|
|
53
41
|
}
|
|
54
|
-
|
|
55
42
|
return transformValuePlugin.transform({
|
|
56
43
|
field,
|
|
57
44
|
value
|
|
58
45
|
});
|
|
59
46
|
};
|
|
60
|
-
|
|
61
47
|
const filterPlugin = valueFilterPlugins[propertyOperation];
|
|
62
|
-
|
|
63
48
|
if (!filterPlugin) {
|
|
64
49
|
throw new _error.default(`Missing operation filter for "${propertyOperation}".`, "MISSING_OPERATION_FILTER");
|
|
65
50
|
}
|
|
66
|
-
|
|
67
51
|
const paths = [field.createPath({
|
|
68
52
|
field
|
|
69
53
|
}), propertyId];
|
|
@@ -80,10 +64,8 @@ const createRefFilterCreate = () => {
|
|
|
80
64
|
transformValue: transformValueCallable
|
|
81
65
|
});
|
|
82
66
|
}
|
|
83
|
-
|
|
84
67
|
return filters;
|
|
85
68
|
}
|
|
86
69
|
});
|
|
87
70
|
};
|
|
88
|
-
|
|
89
71
|
exports.createRefFilterCreate = createRefFilterCreate;
|
|
@@ -1 +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":"
|
|
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,oDAAyB,CAAC;IACjCC,SAAS,EAAE,KAAK;IAChBC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,KAAK;QAAEC,kBAAkB;QAAEC,qBAAqB;QAAEC;MAAM,CAAC,GAAGJ,MAAM;MAC1E,MAAMK,eAAe,GAAGC,MAAM,CAACC,IAAI,CAACN,KAAK,CAAC;MAC1C,IAAII,eAAe,CAACG,MAAM,KAAK,CAAC,EAAE;QAC9B,OAAO,IAAI;MACf;MAEA,MAAMC,OAAkD,GAAG,EAAE;MAE7D,KAAK,MAAMC,cAAc,IAAIL,eAAe,EAAE;QAC1C,MAAMM,WAAW,GAAG,IAAAC,yBAAkB,EAACF,cAAc,CAAC;QACtD,IAAI,CAACC,WAAW,EAAE;UACd;QACJ;QACA,MAAM;UAAEE,OAAO,EAAEC,UAAU;UAAEC,SAAS,EAAEC,iBAAiB;UAAEC;QAAO,CAAC,GAAGN,WAAW;QAEjF,MAAMO,oBAAoB,GAAGf,qBAAqB,CAACC,KAAK,CAACe,IAAI,CAAC;QAE9D,MAAMC,sBAAsB,GAAInB,KAAU,IAAK;UAC3C,IAAI,CAACiB,oBAAoB,EAAE;YACvB,OAAOjB,KAAK;UAChB;UACA,OAAOiB,oBAAoB,CAACG,SAAS,CAAC;YAClCjB,KAAK;YACLH;UACJ,CAAC,CAAC;QACN,CAAC;QAED,MAAMqB,YAAY,GAAGpB,kBAAkB,CAACc,iBAAiB,CAAC;QAC1D,IAAI,CAACM,YAAY,EAAE;UACf,MAAM,IAAIC,cAAW,CAChB,iCAAgCP,iBAAkB,IAAG,EACtD,0BAA0B,CAC7B;QACL;QAEA,MAAMQ,KAAK,GAAG,CACVpB,KAAK,CAACqB,UAAU,CAAC;UACbrB;QACJ,CAAC,CAAC,EACFU,UAAU,CACb;QAEDL,OAAO,CAACiB,IAAI,CAAC;UACTtB,KAAK;UACLuB,IAAI,EAAEH,KAAK,CAACI,IAAI,CAAC,GAAG,CAAC;UACrBC,WAAW,EAAE,CAAC,GAAGzB,KAAK,CAAC0B,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACnB,OAAO,CAAC,EAAET,KAAK,CAACS,OAAO,CAAC,CAACe,IAAI,CAAC,GAAG,CAAC;UAC5EK,MAAM,EAAEX,YAAY;UACpBL,MAAM;UACNiB,YAAY,EAAE,IAAAC,yBAAc,EAAC;YACzBlC,KAAK,EAAEA,KAAK,CAACS,cAAc,CAAC;YAC5BW,SAAS,EAAED;UACf,CAAC,CAAC;UACFe,cAAc,EAAEf;QACpB,CAAC,CAAC;MACN;MAEA,OAAOX,OAAO;IAClB;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.sort = void 0;
|
|
9
|
-
|
|
10
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
9
|
var _dotProp = _interopRequireDefault(require("dot-prop"));
|
|
13
|
-
|
|
14
10
|
var _sortBy = _interopRequireDefault(require("lodash/sortBy"));
|
|
15
|
-
|
|
16
11
|
var _extractSort = require("./extractSort");
|
|
17
|
-
|
|
18
12
|
const sort = params => {
|
|
19
13
|
const {
|
|
20
14
|
model,
|
|
@@ -23,7 +17,6 @@ const sort = params => {
|
|
|
23
17
|
fields,
|
|
24
18
|
plugins
|
|
25
19
|
} = params;
|
|
26
|
-
|
|
27
20
|
if (items.length <= 1) {
|
|
28
21
|
return items;
|
|
29
22
|
} else if (sort.length === 0) {
|
|
@@ -33,15 +26,12 @@ const sort = params => {
|
|
|
33
26
|
sort: sort
|
|
34
27
|
});
|
|
35
28
|
}
|
|
36
|
-
|
|
37
29
|
const [firstSort] = sort;
|
|
38
|
-
|
|
39
30
|
if (!firstSort) {
|
|
40
31
|
throw new _error.default("Empty sort array item.", "SORT_EMPTY_ERROR", {
|
|
41
32
|
sort
|
|
42
33
|
});
|
|
43
34
|
}
|
|
44
|
-
|
|
45
35
|
const {
|
|
46
36
|
fieldId,
|
|
47
37
|
field,
|
|
@@ -62,23 +52,18 @@ const sort = params => {
|
|
|
62
52
|
const sortedItems = (0, _sortBy.default)(itemsToSort, "value");
|
|
63
53
|
const newItems = sortedItems.map(s => {
|
|
64
54
|
const item = items.find(i => i.id === s.id);
|
|
65
|
-
|
|
66
55
|
if (item) {
|
|
67
56
|
return item;
|
|
68
57
|
}
|
|
69
|
-
|
|
70
58
|
throw new _error.default("Could not find item by given id after the sorting.", "SORTING_ITEMS_ERROR", {
|
|
71
59
|
id: s.id,
|
|
72
60
|
sortingBy: fieldId,
|
|
73
61
|
reverse
|
|
74
62
|
});
|
|
75
63
|
});
|
|
76
|
-
|
|
77
64
|
if (!reverse) {
|
|
78
65
|
return newItems;
|
|
79
66
|
}
|
|
80
|
-
|
|
81
67
|
return newItems.reverse();
|
|
82
68
|
};
|
|
83
|
-
|
|
84
69
|
exports.sort = sort;
|
|
@@ -1 +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 }\n );\n });\n if (!reverse) {\n return newItems;\n }\n return newItems.reverse();\n};\n"],"mappings":"
|
|
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 }\n );\n });\n if (!reverse) {\n return newItems;\n }\n return newItems.reverse();\n};\n"],"mappings":";;;;;;;AACA;AACA;AACA;AACA;AAiBO,MAAMA,IAAI,GAAIC,MAAc,IAAiB;EAChD,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEH,IAAI,GAAG,EAAE;IAAEI,MAAM;IAAEC;EAAQ,CAAC,GAAGJ,MAAM;EAC3D,IAAIE,KAAK,CAACG,MAAM,IAAI,CAAC,EAAE;IACnB,OAAOH,KAAK;EAChB,CAAC,MAAM,IAAIH,IAAI,CAACM,MAAM,KAAK,CAAC,EAAE;IAC1BN,IAAI,CAACO,IAAI,CAAC,cAAc,CAAC;EAC7B,CAAC,MAAM,IAAIP,IAAI,CAACM,MAAM,GAAG,CAAC,EAAE;IACxB,MAAM,IAAIE,cAAW,CACjB,uCAAuC,EACvC,4BAA4B,EAC5B;MACIR,IAAI,EAAEA;IACV,CAAC,CACJ;EACL;EACA,MAAM,CAACS,SAAS,CAAC,GAAGT,IAAI;EACxB,IAAI,CAACS,SAAS,EAAE;IACZ,MAAM,IAAID,cAAW,CAAC,wBAAwB,EAAE,kBAAkB,EAAE;MAChER;IACJ,CAAC,CAAC;EACN;EAEA,MAAM;IAAEU,OAAO;IAAEC,KAAK;IAAEC,SAAS;IAAEC;EAAQ,CAAC,GAAG,IAAAC,wBAAW,EAAC;IACvDZ,KAAK;IACLa,MAAM,EAAEN,SAAS;IACjBL,MAAM;IACNC;EACJ,CAAC,CAAC;EAEF,MAAMW,WAAW,GAAGb,KAAK,CAACc,GAAG,CAACC,IAAI,IAAI;IAClC,OAAO;MACHC,EAAE,EAAED,IAAI,CAACC,EAAE;MACXC,KAAK,EAAET,KAAK,CAACU,SAAS,CAACC,gBAAO,CAACC,GAAG,CAACL,IAAI,EAAEN,SAAS,CAAC;IACvD,CAAC;EACL,CAAC,CAAC;EACF,MAAMY,WAAyB,GAAG,IAAAC,eAAY,EAACT,WAAW,EAAE,OAAO,CAAC;EACpE,MAAMU,QAAQ,GAAGF,WAAW,CAACP,GAAG,CAACU,CAAC,IAAI;IAClC,MAAMT,IAAI,GAAGf,KAAK,CAACyB,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACV,EAAE,KAAKQ,CAAC,CAACR,EAAE,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,CAAC,CACJ;EACL,CAAC,CAAC;EACF,IAAI,CAACA,OAAO,EAAE;IACV,OAAOa,QAAQ;EACnB;EACA,OAAOA,QAAQ,CAACb,OAAO,EAAE;AAC7B,CAAC;AAAC"}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createSystemFields = void 0;
|
|
7
|
-
|
|
8
7
|
const createSystemFields = () => {
|
|
9
8
|
return [{
|
|
10
9
|
id: "id",
|
|
@@ -68,5 +67,4 @@ const createSystemFields = () => {
|
|
|
68
67
|
label: "Status"
|
|
69
68
|
}];
|
|
70
69
|
};
|
|
71
|
-
|
|
72
70
|
exports.createSystemFields = createSystemFields;
|
|
@@ -1 +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":"
|
|
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,IAAI;IACRC,IAAI,EAAE,MAAM;IACZC,SAAS,EAAE,IAAI;IACfC,OAAO,EAAE,IAAI;IACbC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,MAAM;IACZC,SAAS,EAAE,SAAS;IACpBC,OAAO,EAAE,SAAS;IAClBC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,WAAW;IACfC,IAAI,EAAE,UAAU;IAChBC,SAAS,EAAE,WAAW;IACtBC,OAAO,EAAE,WAAW;IACpBC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,UAAU;IAChBC,SAAS,EAAE,SAAS;IACpBC,OAAO,EAAE,SAAS;IAClBC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,WAAW;IACfC,IAAI,EAAE,aAAa;IACnBC,SAAS,EAAE,WAAW;IACtBC,OAAO,EAAE,WAAW;IACpBC,KAAK,EAAE,YAAY;IACnBC,QAAQ,EAAE;MACNC,IAAI,EAAE;IACV;EACJ,CAAC,EACD;IACIN,EAAE,EAAE,MAAM;IACVC,IAAI,EAAE,aAAa;IACnBC,SAAS,EAAE,MAAM;IACjBC,OAAO,EAAE,MAAM;IACfC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,aAAa;IACnBC,SAAS,EAAE,SAAS;IACpBC,OAAO,EAAE,SAAS;IAClBC,KAAK,EAAE,UAAU;IACjBC,QAAQ,EAAE;MACNC,IAAI,EAAE;IACV;EACJ,CAAC,EACD;IACIN,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,QAAQ;IACdC,SAAS,EAAE,SAAS;IACpBC,OAAO,EAAE,SAAS;IAClBC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,QAAQ;IACZC,IAAI,EAAE,MAAM;IACZC,SAAS,EAAE,QAAQ;IACnBC,OAAO,EAAE,QAAQ;IACjBC,KAAK,EAAE;EACX,CAAC,CACJ;AACL,CAAC;AAAC"}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.transformValue = void 0;
|
|
7
|
-
|
|
8
7
|
const transformValue = ({
|
|
9
8
|
value,
|
|
10
9
|
transform
|
|
@@ -12,8 +11,6 @@ const transformValue = ({
|
|
|
12
11
|
if (Array.isArray(value)) {
|
|
13
12
|
return value.map(v => transform(v));
|
|
14
13
|
}
|
|
15
|
-
|
|
16
14
|
return transform(value);
|
|
17
15
|
};
|
|
18
|
-
|
|
19
16
|
exports.transformValue = transformValue;
|
|
@@ -1 +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":"
|
|
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,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;AAAC"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.getWhereValues = void 0;
|
|
9
|
-
|
|
10
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
9
|
const getWhereValues = (value, condition) => {
|
|
13
10
|
const values = value;
|
|
14
|
-
|
|
15
11
|
if (!Array.isArray(values)) {
|
|
16
12
|
throw new _error.default(`Trying to run filtering with "${condition}", but the value sent is not an array.`, `MALFORMED_${condition}_CONDITION`, {
|
|
17
13
|
value
|
|
@@ -21,8 +17,6 @@ const getWhereValues = (value, condition) => {
|
|
|
21
17
|
value
|
|
22
18
|
});
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
return values;
|
|
26
21
|
};
|
|
27
|
-
|
|
28
22
|
exports.getWhereValues = getWhereValues;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getWhereValues","value","condition","values","Array","isArray","WebinyError","length"],"sources":["values.ts"],"sourcesContent":["import { 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":"
|
|
1
|
+
{"version":3,"names":["getWhereValues","value","condition","values","Array","isArray","WebinyError","length"],"sources":["values.ts"],"sourcesContent":["import { 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;AAEO,MAAMA,cAAc,GAAG,CAACC,KAAc,EAAEC,SAAuB,KAAK;EACvE,MAAMC,MAAM,GAAGF,KAAwC;EACvD,IAAI,CAACG,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;IACxB,MAAM,IAAIG,cAAW,CAChB,iCAAgCJ,SAAU,wCAAuC,EACjF,aAAYA,SAAU,YAAW,EAClC;MACID;IACJ,CAAC,CACJ;EACL,CAAC,MAAM,IAAIE,MAAM,CAACI,MAAM,KAAK,CAAC,EAAE;IAC5B,MAAM,IAAID,cAAW,CAChB,iCAAgCJ,SAAU,uCAAsC,EAChF,aAAYA,SAAU,YAAW,EAClC;MACID;IACJ,CAAC,CACJ;EACL;EACA,OAAOE,MAAM;AACjB,CAAC;AAAC"}
|
|
@@ -4,20 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.extractWhereParams = void 0;
|
|
7
|
-
|
|
8
7
|
const extractWhereParams = key => {
|
|
9
8
|
const result = key.split("_");
|
|
10
9
|
const fieldId = result.shift();
|
|
11
|
-
|
|
12
10
|
if (!fieldId) {
|
|
13
11
|
return null;
|
|
14
12
|
}
|
|
15
|
-
|
|
16
13
|
const rawOp = result.length === 0 ? "eq" : result.join("_");
|
|
17
14
|
/**
|
|
18
15
|
* When rawOp is not, it means it is equal negated so just return that.
|
|
19
16
|
*/
|
|
20
|
-
|
|
21
17
|
if (rawOp === "not") {
|
|
22
18
|
return {
|
|
23
19
|
fieldId,
|
|
@@ -25,7 +21,6 @@ const extractWhereParams = key => {
|
|
|
25
21
|
negate: true
|
|
26
22
|
};
|
|
27
23
|
}
|
|
28
|
-
|
|
29
24
|
const negate = rawOp.match("not_") !== null;
|
|
30
25
|
const operation = rawOp.replace("not_", "");
|
|
31
26
|
return {
|
|
@@ -34,5 +29,4 @@ const extractWhereParams = key => {
|
|
|
34
29
|
negate
|
|
35
30
|
};
|
|
36
31
|
};
|
|
37
|
-
|
|
38
32
|
exports.extractWhereParams = extractWhereParams;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["extractWhereParams","key","result","split","fieldId","shift","rawOp","length","join","operation","negate","match","replace"],"sources":["where.ts"],"sourcesContent":["export const extractWhereParams = (key: string) => {\n const result = key.split(\"_\");\n const fieldId = result.shift();\n if (!fieldId) {\n return null;\n }\n const rawOp = result.length === 0 ? \"eq\" : result.join(\"_\");\n /**\n * When rawOp is not, it means it is equal negated so just return that.\n */\n if (rawOp === \"not\") {\n return {\n fieldId,\n operation: \"eq\",\n negate: true\n };\n }\n const negate = rawOp.match(\"not_\") !== null;\n const operation = rawOp.replace(\"not_\", \"\");\n return {\n fieldId,\n operation,\n negate\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["extractWhereParams","key","result","split","fieldId","shift","rawOp","length","join","operation","negate","match","replace"],"sources":["where.ts"],"sourcesContent":["export const extractWhereParams = (key: string) => {\n const result = key.split(\"_\");\n const fieldId = result.shift();\n if (!fieldId) {\n return null;\n }\n const rawOp = result.length === 0 ? \"eq\" : result.join(\"_\");\n /**\n * When rawOp is not, it means it is equal negated so just return that.\n */\n if (rawOp === \"not\") {\n return {\n fieldId,\n operation: \"eq\",\n negate: true\n };\n }\n const negate = rawOp.match(\"not_\") !== null;\n const operation = rawOp.replace(\"not_\", \"\");\n return {\n fieldId,\n operation,\n negate\n };\n};\n"],"mappings":";;;;;;AAAO,MAAMA,kBAAkB,GAAIC,GAAW,IAAK;EAC/C,MAAMC,MAAM,GAAGD,GAAG,CAACE,KAAK,CAAC,GAAG,CAAC;EAC7B,MAAMC,OAAO,GAAGF,MAAM,CAACG,KAAK,EAAE;EAC9B,IAAI,CAACD,OAAO,EAAE;IACV,OAAO,IAAI;EACf;EACA,MAAME,KAAK,GAAGJ,MAAM,CAACK,MAAM,KAAK,CAAC,GAAG,IAAI,GAAGL,MAAM,CAACM,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,CAACK,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI;EAC3C,MAAMF,SAAS,GAAGH,KAAK,CAACM,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;EAC3C,OAAO;IACHR,OAAO;IACPK,SAAS;IACTC;EACJ,CAAC;AACL,CAAC;AAAC"}
|