@webiny/api-headless-cms-ddb 6.0.0-beta.0 → 6.0.0-rc.0
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/README.md +6 -20
- package/definitions/entry.d.ts +4 -5
- package/definitions/entry.js +5 -180
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +4 -5
- package/definitions/group.js +5 -58
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +4 -5
- package/definitions/model.js +5 -102
- package/definitions/model.js.map +1 -1
- package/definitions/table.d.ts +3 -5
- package/definitions/table.js +6 -28
- package/definitions/table.js.map +1 -1
- package/definitions/types.d.ts +59 -0
- package/definitions/types.js +3 -0
- package/definitions/types.js.map +1 -0
- package/dynamoDb/index.d.ts +1 -1
- package/dynamoDb/index.js +6 -14
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/path/locationFolderId.d.ts +1 -1
- package/dynamoDb/path/locationFolderId.js +5 -14
- package/dynamoDb/path/locationFolderId.js.map +1 -1
- package/dynamoDb/path/plainObject.d.ts +1 -1
- package/dynamoDb/path/plainObject.js +5 -14
- package/dynamoDb/path/plainObject.js.map +1 -1
- package/dynamoDb/storage/longText.js +11 -18
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.js +26 -71
- package/dynamoDb/storage/richText.js.map +1 -1
- package/dynamoDb/transformValue/datetime.d.ts +1 -1
- package/dynamoDb/transformValue/datetime.js +5 -12
- package/dynamoDb/transformValue/datetime.js.map +1 -1
- package/index.d.ts +2 -2
- package/index.js +38 -72
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -3
- package/operations/entry/dataLoader/DataLoaderCache.js +2 -9
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
- package/operations/entry/dataLoader/constants.js +1 -7
- package/operations/entry/dataLoader/constants.js.map +1 -1
- package/operations/entry/dataLoader/createBatchScheduleFn.js +4 -10
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
- package/operations/entry/dataLoader/getAllEntryRevisions.js +11 -24
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +22 -32
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +22 -32
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
- package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
- package/operations/entry/dataLoader/getRevisionById.js +24 -34
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
- package/operations/entry/dataLoader/index.d.ts +5 -5
- package/operations/entry/dataLoader/index.js +10 -31
- package/operations/entry/dataLoader/index.js.map +1 -1
- package/operations/entry/dataLoader/types.d.ts +3 -4
- package/operations/entry/dataLoader/types.js +1 -5
- package/operations/entry/dataLoader/types.js.map +1 -1
- package/operations/entry/dataLoaders.d.ts +11 -12
- package/operations/entry/dataLoaders.js +15 -25
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/filtering/createExpressions.d.ts +5 -5
- package/operations/entry/filtering/createExpressions.js +27 -30
- package/operations/entry/filtering/createExpressions.js.map +1 -1
- package/operations/entry/filtering/createFields.d.ts +3 -3
- package/operations/entry/filtering/createFields.js +20 -22
- package/operations/entry/filtering/createFields.js.map +1 -1
- package/operations/entry/filtering/extractSort.d.ts +6 -6
- package/operations/entry/filtering/extractSort.js +38 -23
- package/operations/entry/filtering/extractSort.js.map +1 -1
- package/operations/entry/filtering/filter.d.ts +6 -6
- package/operations/entry/filtering/filter.js +13 -21
- package/operations/entry/filtering/filter.js.map +1 -1
- package/operations/entry/filtering/fullTextSearch.d.ts +3 -3
- package/operations/entry/filtering/fullTextSearch.js +6 -14
- package/operations/entry/filtering/fullTextSearch.js.map +1 -1
- package/operations/entry/filtering/getValue.js +1 -8
- package/operations/entry/filtering/getValue.js.map +1 -1
- package/operations/entry/filtering/index.d.ts +2 -2
- package/operations/entry/filtering/index.js +2 -19
- package/operations/entry/filtering/index.js.map +1 -1
- package/operations/entry/filtering/mapPlugins.d.ts +2 -2
- package/operations/entry/filtering/mapPlugins.js +3 -11
- package/operations/entry/filtering/mapPlugins.js.map +1 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +2 -2
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +6 -14
- package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/index.d.ts +1 -1
- package/operations/entry/filtering/plugins/index.js +6 -12
- package/operations/entry/filtering/plugins/index.js.map +1 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +2 -2
- package/operations/entry/filtering/plugins/objectFilterCreate.js +13 -19
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +3 -2
- package/operations/entry/filtering/plugins/refFilterCreate.js +18 -19
- package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +2 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +57 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -0
- package/operations/entry/filtering/sort.d.ts +6 -6
- package/operations/entry/filtering/sort.js +16 -20
- package/operations/entry/filtering/sort.js.map +1 -1
- package/operations/entry/filtering/systemFields.d.ts +2 -4
- package/operations/entry/filtering/systemFields.js +55 -29
- package/operations/entry/filtering/systemFields.js.map +1 -1
- package/operations/entry/filtering/transform.d.ts +1 -1
- package/operations/entry/filtering/transform.js +1 -8
- package/operations/entry/filtering/transform.js.map +1 -1
- package/operations/entry/filtering/types.d.ts +3 -3
- package/operations/entry/filtering/types.js +1 -5
- package/operations/entry/filtering/types.js.map +1 -1
- package/operations/entry/filtering/values.d.ts +1 -1
- package/operations/entry/filtering/values.js +4 -12
- package/operations/entry/filtering/values.js.map +1 -1
- package/operations/entry/filtering/where.js +1 -8
- package/operations/entry/filtering/where.js.map +1 -1
- package/operations/entry/index.d.ts +3 -4
- package/operations/entry/index.js +447 -495
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.d.ts +40 -2
- package/operations/entry/keys.js +53 -30
- package/operations/entry/keys.js.map +1 -1
- package/operations/group/index.d.ts +4 -4
- package/operations/group/index.js +35 -64
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +3 -3
- package/operations/model/index.js +36 -58
- package/operations/model/index.js.map +1 -1
- package/package.json +20 -26
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +2 -2
- package/plugins/CmsEntryFieldFilterPathPlugin.js +4 -12
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +10 -10
- package/plugins/CmsEntryFieldFilterPlugin.js +2 -8
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +2 -2
- package/plugins/CmsEntryFieldSortingPlugin.js +3 -11
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +2 -2
- package/plugins/CmsFieldFilterValueTransformPlugin.js +2 -9
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -1
- package/plugins/index.d.ts +4 -4
- package/plugins/index.js +4 -49
- package/plugins/index.js.map +1 -1
- package/types.d.ts +17 -19
- package/types.js +1 -8
- package/types.js.map +1 -1
- package/definitions/system.d.ts +0 -9
- package/definitions/system.js +0 -42
- package/definitions/system.js.map +0 -1
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -84
- package/dynamoDb/storage/date.js.map +0 -1
- package/operations/system/index.d.ts +0 -7
- package/operations/system/index.js +0 -94
- package/operations/system/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["addArrayResult","target","result","r","some","t","push","find","input","paths","path","shift","undefined","value","length","Array","isArray","reduce","collection","v","getValue","split","Error","filtered","filter","Boolean","join"
|
|
1
|
+
{"version":3,"names":["addArrayResult","target","result","r","some","t","push","find","input","paths","path","shift","undefined","value","length","Array","isArray","reduce","collection","v","getValue","split","Error","filtered","filter","Boolean","join"],"sources":["getValue.ts"],"sourcesContent":["const addArrayResult = (target: any[], result: any[]): void => {\n for (const r of result) {\n if (target.some(t => r === t)) {\n continue;\n }\n target.push(r);\n }\n};\n/**\n * A recursive function which goes through given input paths and returns the value in it.\n * In case a path is an array, it goes through the array of those values to get values further down the path line.\n */\nconst find = (target: Record<string, any> | undefined, input: string[]): any[] | undefined => {\n const paths = [...input];\n const path = paths.shift();\n\n if (!path) {\n return undefined;\n }\n\n const value = target?.[path];\n if (value === undefined) {\n return undefined;\n }\n if (paths.length === 0) {\n return value;\n } else if (Array.isArray(value)) {\n if (value.length === 0) {\n return undefined;\n }\n return value.reduce<any[]>((collection, v) => {\n const result = find(v, paths);\n if (result === undefined) {\n return collection;\n } else if (Array.isArray(result)) {\n addArrayResult(collection, result);\n return collection;\n }\n collection.push(result);\n return collection;\n }, []);\n }\n return find(value, paths);\n};\n/**\n * A wrapper function for the find function.\n * Basically it transforms input paths to an array (and runs various checks).\n */\nexport const getValue = (target: Record<string, any>, input: string | string[]): any => {\n const paths = Array.isArray(input) ? input : input.split(\".\");\n if (paths.length === 0) {\n throw new Error(`Path is empty!`);\n }\n const filtered = paths.filter(Boolean);\n if (paths.length !== filtered.length) {\n throw new Error(\n `Input path is different than the filtered empty path string. (${paths.join(\n \".\"\n )} to ${filtered.join(\".\")})`\n );\n }\n\n return find(target, paths);\n};\n"],"mappings":"AAAA,MAAMA,cAAc,GAAGA,CAACC,MAAa,EAA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IAAI,CAACM,KAAK,EAAEJ,KAAK,CAAC;AAC7B,CAAC;AACD;AACA;AACA;AACA;AACA,OAAO,MAAMW,QAAQ,GAAGA,CAACnB,MAA2B,EAAEO,KAAwB,KAAU;EACpF,MAAMC,KAAK,GAAGM,KAAK,CAACC,OAAO,CAACR,KAAK,CAAC,GAAGA,KAAK,GAAGA,KAAK,CAACa,KAAK,CAAC,GAAG,CAAC;EAC7D,IAAIZ,KAAK,CAACK,MAAM,KAAK,CAAC,EAAE;IACpB,MAAM,IAAIQ,KAAK,CAAC,gBAAgB,CAAC;EACrC;EACA,MAAMC,QAAQ,GAAGd,KAAK,CAACe,MAAM,CAACC,OAAO,CAAC;EACtC,IAAIhB,KAAK,CAACK,MAAM,KAAKS,QAAQ,CAACT,MAAM,EAAE;IAClC,MAAM,IAAIQ,KAAK,CACX,iEAAiEb,KAAK,CAACiB,IAAI,CACvE,GACJ,CAAC,OAAOH,QAAQ,CAACG,IAAI,CAAC,GAAG,CAAC,GAC9B,CAAC;EACL;EAEA,OAAOnB,IAAI,CAACN,MAAM,EAAEQ,KAAK,CAAC;AAC9B,CAAC","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { filter } from "./filter";
|
|
2
|
-
export { sort } from "./sort";
|
|
1
|
+
export { filter } from "./filter.js";
|
|
2
|
+
export { sort } from "./sort.js";
|
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "filter", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _filter.filter;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "sort", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _sort.sort;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
var _filter = require("./filter");
|
|
19
|
-
var _sort = require("./sort");
|
|
1
|
+
export { filter } from "./filter.js";
|
|
2
|
+
export { sort } from "./sort.js";
|
|
20
3
|
|
|
21
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["filter","sort"],"sources":["index.ts"],"sourcesContent":["export { filter } from \"./filter.js\";\nexport { sort } from \"./sort.js\";\n"],"mappings":"AAAA,SAASA,MAAM;AACf,SAASC,IAAI","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Plugin, PluginsContainer } from "@webiny/plugins/types";
|
|
1
|
+
import type { Plugin, PluginsContainer } from "@webiny/plugins/types.js";
|
|
2
2
|
interface Params {
|
|
3
3
|
plugins: PluginsContainer;
|
|
4
4
|
type: string;
|
|
5
5
|
property: string;
|
|
6
6
|
}
|
|
7
|
-
export declare const getMappedPlugins: <T extends Plugin
|
|
7
|
+
export declare const getMappedPlugins: <T extends Plugin>(params: Params) => Record<string, T>;
|
|
8
8
|
export {};
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getMappedPlugins = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
const getMappedPlugins = params => {
|
|
1
|
+
import WebinyError from "@webiny/error";
|
|
2
|
+
export const getMappedPlugins = params => {
|
|
10
3
|
const {
|
|
11
4
|
plugins: pluginsContainer,
|
|
12
5
|
type,
|
|
@@ -19,7 +12,7 @@ const getMappedPlugins = params => {
|
|
|
19
12
|
return plugins.reduce((collection, plugin) => {
|
|
20
13
|
const key = plugin[property];
|
|
21
14
|
if (typeof key !== "string") {
|
|
22
|
-
throw new
|
|
15
|
+
throw new WebinyError("Property to map the plugins on must be a string.", "PLUGIN_PROPERTY_ERROR", {
|
|
23
16
|
type,
|
|
24
17
|
property
|
|
25
18
|
});
|
|
@@ -28,6 +21,5 @@ const getMappedPlugins = params => {
|
|
|
28
21
|
return collection;
|
|
29
22
|
}, {});
|
|
30
23
|
};
|
|
31
|
-
exports.getMappedPlugins = getMappedPlugins;
|
|
32
24
|
|
|
33
25
|
//# sourceMappingURL=mapPlugins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["WebinyError","getMappedPlugins","params","plugins","pluginsContainer","type","property","byType","length","reduce","collection","plugin","key"],"sources":["mapPlugins.ts"],"sourcesContent":["import type { Plugin, PluginsContainer } from \"@webiny/plugins/types.js\";\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,OAAOA,WAAW,MAAM,eAAe;AAOvC,OAAO,MAAMC,gBAAgB,GAAsBC,MAAc,IAAK;EAClE,MAAM;IAAEC,OAAO,EAAEC,gBAAgB;IAAEC,IAAI;IAAEC;EAAS,CAAC,GAAGJ,MAAM;EAC5D,MAAMC,OAAO,GAAGC,gBAAgB,CAACG,MAAM,CAAIF,IAAI,CAAC;EAChD,IAAIF,OAAO,CAACK,MAAM,KAAK,CAAC,EAAE;IACtB,OAAO,CAAC,CAAC;EACb;EACA,OAAOL,OAAO,CAACM,MAAM,CAAoB,CAACC,UAAU,EAAEC,MAAM,KAAK;IAC7D,MAAMC,GAAwB,GAAGD,MAAM,CAACL,QAAQ,CAAC;IACjD,IAAI,OAAOM,GAAG,KAAK,QAAQ,EAAE;MACzB,MAAM,IAAIZ,WAAW,CACjB,kDAAkD,EAClD,uBAAuB,EACvB;QACIK,IAAI;QACJC;MACJ,CACJ,CAAC;IACL;IACAI,UAAU,CAACE,GAAG,CAAC,GAAGD,MAAM;IACxB,OAAOD,UAAU;EACrB,CAAC,EAAE,CAAC,CAAC,CAAC;AACV,CAAC","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin";
|
|
2
|
-
export declare const createDefaultFilterCreate: () => CmsEntryFieldFilterPlugin
|
|
1
|
+
import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
|
|
2
|
+
export declare const createDefaultFilterCreate: () => CmsEntryFieldFilterPlugin<any>;
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
});
|
|
7
|
-
exports.createDefaultFilterCreate = void 0;
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _CmsEntryFieldFilterPlugin = require("../../../../plugins/CmsEntryFieldFilterPlugin");
|
|
10
|
-
const createDefaultFilterCreate = () => {
|
|
11
|
-
const plugin = new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
|
|
12
|
-
fieldType: _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin.ALL,
|
|
1
|
+
import WebinyError from "@webiny/error";
|
|
2
|
+
import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
|
|
3
|
+
export const createDefaultFilterCreate = () => {
|
|
4
|
+
const plugin = new CmsEntryFieldFilterPlugin({
|
|
5
|
+
fieldType: CmsEntryFieldFilterPlugin.ALL,
|
|
13
6
|
create: params => {
|
|
14
7
|
const {
|
|
15
8
|
negate,
|
|
@@ -20,7 +13,7 @@ const createDefaultFilterCreate = () => {
|
|
|
20
13
|
} = params;
|
|
21
14
|
const plugin = valueFilterPlugins[params.operation];
|
|
22
15
|
if (!plugin) {
|
|
23
|
-
throw new
|
|
16
|
+
throw new WebinyError(`Missing ValueFilterPlugin for operation "${params.operation}".`, "MISSING_OPERATION_PLUGIN", {
|
|
24
17
|
operation: params.operation
|
|
25
18
|
});
|
|
26
19
|
}
|
|
@@ -40,6 +33,5 @@ const createDefaultFilterCreate = () => {
|
|
|
40
33
|
plugin.name = `headless-cms.ddb.filter.default`;
|
|
41
34
|
return plugin;
|
|
42
35
|
};
|
|
43
|
-
exports.createDefaultFilterCreate = createDefaultFilterCreate;
|
|
44
36
|
|
|
45
37
|
//# sourceMappingURL=defaultFilterCreate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["WebinyError","CmsEntryFieldFilterPlugin","createDefaultFilterCreate","plugin","fieldType","ALL","create","params","negate","transformValue","field","compareValue","valueFilterPlugins","operation","fieldPathId","parents","map","f","fieldId","join","path","createPath","name"],"sources":["defaultFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\n\nexport const createDefaultFilterCreate = () => {\n const plugin = 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 plugin.name = `headless-cms.ddb.filter.default`;\n\n return plugin;\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,yBAAyB;AAElC,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,MAAMC,MAAM,GAAG,IAAIF,yBAAyB,CAAC;IACzCG,SAAS,EAAEH,yBAAyB,CAACI,GAAG;IACxCC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,MAAM;QAAEC,cAAc;QAAEC,KAAK;QAAEC,YAAY;QAAEC;MAAmB,CAAC,GAAGL,MAAM;MAClF,MAAMJ,MAAM,GAAGS,kBAAkB,CAACL,MAAM,CAACM,SAAS,CAAC;MACnD,IAAI,CAACV,MAAM,EAAE;QACT,MAAM,IAAIH,WAAW,CACjB,4CAA4CO,MAAM,CAACM,SAAS,IAAI,EAChE,0BAA0B,EAC1B;UACIA,SAAS,EAAEN,MAAM,CAACM;QACtB,CACJ,CAAC;MACL;MACA,OAAO;QACHL,MAAM;QACNC,cAAc;QACdC,KAAK;QACLC,YAAY;QACZG,WAAW,EAAE,CAAC,GAAGJ,KAAK,CAACK,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC,EAAER,KAAK,CAACQ,OAAO,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;QAC5EC,IAAI,EAAEV,KAAK,CAACW,UAAU,CAAC;UACnBX;QACJ,CAAC,CAAC;QACFP;MACJ,CAAC;IACL;EACJ,CAAC,CAAC;EAEFA,MAAM,CAACmB,IAAI,GAAG,iCAAiC;EAE/C,OAAOnB,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createFilterCreatePlugins: () => import("
|
|
1
|
+
export declare const createFilterCreatePlugins: () => import("../../../../index.js").CmsEntryFieldFilterPlugin<import("@webiny/api/types.js").GenericRecord | null | undefined>[];
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _defaultFilterCreate = require("./defaultFilterCreate");
|
|
8
|
-
var _refFilterCreate = require("./refFilterCreate");
|
|
9
|
-
var _objectFilterCreate = require("./objectFilterCreate");
|
|
10
|
-
const createFilterCreatePlugins = () => {
|
|
11
|
-
return [(0, _defaultFilterCreate.createDefaultFilterCreate)(), (0, _refFilterCreate.createRefFilterCreate)(), (0, _objectFilterCreate.objectFilterCreate)()];
|
|
1
|
+
import { createDefaultFilterCreate } from "./defaultFilterCreate.js";
|
|
2
|
+
import { createRefFilterCreate } from "./refFilterCreate.js";
|
|
3
|
+
import { objectFilterCreate } from "./objectFilterCreate.js";
|
|
4
|
+
import { searchableJsonFilterCreate } from "./searchableJsonFilterCreate.js";
|
|
5
|
+
export const createFilterCreatePlugins = () => {
|
|
6
|
+
return [createDefaultFilterCreate(), createRefFilterCreate(), objectFilterCreate(), searchableJsonFilterCreate()];
|
|
12
7
|
};
|
|
13
|
-
exports.createFilterCreatePlugins = createFilterCreatePlugins;
|
|
14
8
|
|
|
15
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createDefaultFilterCreate","createRefFilterCreate","objectFilterCreate","searchableJsonFilterCreate","createFilterCreatePlugins"],"sources":["index.ts"],"sourcesContent":["import { createDefaultFilterCreate } from \"./defaultFilterCreate.js\";\nimport { createRefFilterCreate } from \"./refFilterCreate.js\";\nimport { objectFilterCreate } from \"./objectFilterCreate.js\";\nimport { searchableJsonFilterCreate } from \"./searchableJsonFilterCreate.js\";\n\nexport const createFilterCreatePlugins = () => {\n return [\n createDefaultFilterCreate(),\n createRefFilterCreate(),\n objectFilterCreate(),\n searchableJsonFilterCreate()\n ];\n};\n"],"mappings":"AAAA,SAASA,yBAAyB;AAClC,SAASC,qBAAqB;AAC9B,SAASC,kBAAkB;AAC3B,SAASC,0BAA0B;AAEnC,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,CACHJ,yBAAyB,CAAC,CAAC,EAC3BC,qBAAqB,CAAC,CAAC,EACvBC,kBAAkB,CAAC,CAAC,EACpBC,0BAA0B,CAAC,CAAC,CAC/B;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin";
|
|
2
|
-
export declare const objectFilterCreate: () => CmsEntryFieldFilterPlugin
|
|
1
|
+
import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
|
|
2
|
+
export declare const objectFilterCreate: () => CmsEntryFieldFilterPlugin<any>;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _CmsEntryFieldFilterPlugin = require("../../../../plugins/CmsEntryFieldFilterPlugin");
|
|
9
|
-
var _where = require("../where");
|
|
10
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
var _transform = require("../transform");
|
|
12
|
-
const objectFilterCreate = () => {
|
|
13
|
-
const plugin = new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
|
|
1
|
+
import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
|
|
2
|
+
import { extractWhereParams } from "../where.js";
|
|
3
|
+
import WebinyError from "@webiny/error";
|
|
4
|
+
import { transformValue } from "../transform.js";
|
|
5
|
+
import { getBaseFieldType } from "@webiny/api-headless-cms/utils/getBaseFieldType.js";
|
|
6
|
+
export const objectFilterCreate = () => {
|
|
7
|
+
const plugin = new CmsEntryFieldFilterPlugin({
|
|
14
8
|
fieldType: "object",
|
|
15
9
|
create: params => {
|
|
16
10
|
const {
|
|
@@ -27,7 +21,7 @@ const objectFilterCreate = () => {
|
|
|
27
21
|
if (value === undefined) {
|
|
28
22
|
continue;
|
|
29
23
|
}
|
|
30
|
-
const whereParams =
|
|
24
|
+
const whereParams = extractWhereParams(key);
|
|
31
25
|
if (!whereParams) {
|
|
32
26
|
continue;
|
|
33
27
|
}
|
|
@@ -39,12 +33,13 @@ const objectFilterCreate = () => {
|
|
|
39
33
|
const fieldPath = parentField.parents.map(p => p.fieldId).concat([parentField.fieldId, fieldId]).join(".");
|
|
40
34
|
const field = fields[fieldPath];
|
|
41
35
|
if (!field) {
|
|
42
|
-
throw new
|
|
36
|
+
throw new WebinyError(`There is no field with the field path "${fieldPath}".`, "FIELD_ERROR", {
|
|
43
37
|
fieldId
|
|
44
38
|
});
|
|
45
39
|
}
|
|
46
|
-
const
|
|
47
|
-
const
|
|
40
|
+
const fieldType = getBaseFieldType(field);
|
|
41
|
+
const filterCreatePlugin = getFilterCreatePlugin(fieldType);
|
|
42
|
+
const transformValuePlugin = transformValuePlugins[fieldType];
|
|
48
43
|
const transformValueCallable = value => {
|
|
49
44
|
if (!transformValuePlugin) {
|
|
50
45
|
return value;
|
|
@@ -64,7 +59,7 @@ const objectFilterCreate = () => {
|
|
|
64
59
|
negate,
|
|
65
60
|
field,
|
|
66
61
|
fields,
|
|
67
|
-
compareValue:
|
|
62
|
+
compareValue: transformValue({
|
|
68
63
|
value,
|
|
69
64
|
transform: transformValueCallable
|
|
70
65
|
}),
|
|
@@ -85,6 +80,5 @@ const objectFilterCreate = () => {
|
|
|
85
80
|
plugin.name = `headless-cms.ddb.filter.object`;
|
|
86
81
|
return plugin;
|
|
87
82
|
};
|
|
88
|
-
exports.objectFilterCreate = objectFilterCreate;
|
|
89
83
|
|
|
90
84
|
//# sourceMappingURL=objectFilterCreate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["CmsEntryFieldFilterPlugin","extractWhereParams","WebinyError","transformValue","getBaseFieldType","objectFilterCreate","plugin","fieldType","create","params","value","objectValue","valueFilterPlugins","transformValuePlugins","getFilterCreatePlugin","field","parentField","fields","filters","key","undefined","whereParams","negate","fieldId","operation","fieldPath","parents","map","p","concat","join","filterCreatePlugin","transformValuePlugin","transformValueCallable","transform","result","compareValue","Array","isArray","push","name"],"sources":["objectFilterCreate.ts"],"sourcesContent":["import { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where.js\";\nimport WebinyError from \"@webiny/error\";\nimport type { CmsFieldFilterValueTransformPlugin } from \"~/types.js\";\nimport { transformValue } from \"~/operations/entry/filtering/transform.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\nexport const objectFilterCreate = () => {\n const plugin = new CmsEntryFieldFilterPlugin({\n fieldType: \"object\",\n create: params => {\n const {\n value: objectValue,\n valueFilterPlugins,\n transformValuePlugins,\n getFilterCreatePlugin,\n field: parentField,\n fields\n } = params;\n\n const filters = [];\n\n for (const key in objectValue) {\n const value = objectValue[key];\n if (value === undefined) {\n continue;\n }\n const whereParams = extractWhereParams(key);\n if (!whereParams) {\n continue;\n }\n const { negate, fieldId, operation } = whereParams;\n\n const fieldPath = parentField.parents\n .map(p => p.fieldId)\n .concat([parentField.fieldId, fieldId])\n .join(\".\");\n\n const field = fields[fieldPath];\n if (!field) {\n throw new WebinyError(\n `There is no field with the field path \"${fieldPath}\".`,\n \"FIELD_ERROR\",\n {\n fieldId\n }\n );\n }\n\n const fieldType = getBaseFieldType(field);\n\n const filterCreatePlugin = getFilterCreatePlugin(fieldType);\n\n const transformValuePlugin: CmsFieldFilterValueTransformPlugin =\n transformValuePlugins[fieldType];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const result = filterCreatePlugin.create({\n key,\n value,\n valueFilterPlugins,\n transformValuePlugins,\n getFilterCreatePlugin,\n operation,\n negate,\n field,\n fields,\n compareValue: transformValue({\n value,\n transform: transformValueCallable\n }),\n transformValue: transformValueCallable\n });\n if (!result) {\n continue;\n }\n if (Array.isArray(result)) {\n filters.push(...result);\n continue;\n }\n\n filters.push(result);\n }\n return filters;\n }\n });\n\n plugin.name = `headless-cms.ddb.filter.object`;\n\n return plugin;\n};\n"],"mappings":"AAAA,SAASA,yBAAyB;AAClC,SAASC,kBAAkB;AAC3B,OAAOC,WAAW,MAAM,eAAe;AAEvC,SAASC,cAAc;AACvB,SAASC,gBAAgB,QAAQ,oDAAoD;AAErF,OAAO,MAAMC,kBAAkB,GAAGA,CAAA,KAAM;EACpC,MAAMC,MAAM,GAAG,IAAIN,yBAAyB,CAAC;IACzCO,SAAS,EAAE,QAAQ;IACnBC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QACFC,KAAK,EAAEC,WAAW;QAClBC,kBAAkB;QAClBC,qBAAqB;QACrBC,qBAAqB;QACrBC,KAAK,EAAEC,WAAW;QAClBC;MACJ,CAAC,GAAGR,MAAM;MAEV,MAAMS,OAAO,GAAG,EAAE;MAElB,KAAK,MAAMC,GAAG,IAAIR,WAAW,EAAE;QAC3B,MAAMD,KAAK,GAAGC,WAAW,CAACQ,GAAG,CAAC;QAC9B,IAAIT,KAAK,KAAKU,SAAS,EAAE;UACrB;QACJ;QACA,MAAMC,WAAW,GAAGpB,kBAAkB,CAACkB,GAAG,CAAC;QAC3C,IAAI,CAACE,WAAW,EAAE;UACd;QACJ;QACA,MAAM;UAAEC,MAAM;UAAEC,OAAO;UAAEC;QAAU,CAAC,GAAGH,WAAW;QAElD,MAAMI,SAAS,GAAGT,WAAW,CAACU,OAAO,CAChCC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACL,OAAO,CAAC,CACnBM,MAAM,CAAC,CAACb,WAAW,CAACO,OAAO,EAAEA,OA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List":[]}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin";
|
|
2
|
-
|
|
1
|
+
import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
|
|
2
|
+
import type { GenericRecord } from "@webiny/api/types.js";
|
|
3
|
+
export declare const createRefFilterCreate: () => CmsEntryFieldFilterPlugin<GenericRecord | null | undefined>;
|
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
|
-
var _CmsEntryFieldFilterPlugin = require("../../../../plugins/CmsEntryFieldFilterPlugin");
|
|
10
|
-
var _where = require("../where");
|
|
11
|
-
var _transform = require("../transform");
|
|
12
|
-
const createRefFilterCreate = () => {
|
|
13
|
-
const plugin = new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
|
|
1
|
+
import WebinyError from "@webiny/error";
|
|
2
|
+
import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
|
|
3
|
+
import { extractWhereParams } from "../where.js";
|
|
4
|
+
import { transformValue } from "../transform.js";
|
|
5
|
+
import { getBaseFieldType } from "@webiny/api-headless-cms/utils/getBaseFieldType.js";
|
|
6
|
+
export const createRefFilterCreate = () => {
|
|
7
|
+
const plugin = new CmsEntryFieldFilterPlugin({
|
|
14
8
|
fieldType: "ref",
|
|
15
9
|
create: params => {
|
|
16
10
|
const {
|
|
17
|
-
value,
|
|
18
11
|
valueFilterPlugins,
|
|
19
12
|
transformValuePlugins,
|
|
20
13
|
field
|
|
21
14
|
} = params;
|
|
15
|
+
let value = params.value;
|
|
16
|
+
if (!value) {
|
|
17
|
+
value = {
|
|
18
|
+
entryId: null
|
|
19
|
+
};
|
|
20
|
+
}
|
|
22
21
|
const propertyFilters = Object.keys(value);
|
|
23
22
|
if (propertyFilters.length === 0) {
|
|
24
23
|
return null;
|
|
25
24
|
}
|
|
26
25
|
const filters = [];
|
|
27
26
|
for (const propertyFilter of propertyFilters) {
|
|
28
|
-
const whereParams =
|
|
27
|
+
const whereParams = extractWhereParams(propertyFilter);
|
|
29
28
|
if (!whereParams) {
|
|
30
29
|
continue;
|
|
31
30
|
}
|
|
@@ -34,7 +33,8 @@ const createRefFilterCreate = () => {
|
|
|
34
33
|
operation: propertyOperation,
|
|
35
34
|
negate
|
|
36
35
|
} = whereParams;
|
|
37
|
-
const
|
|
36
|
+
const fieldType = getBaseFieldType(field);
|
|
37
|
+
const transformValuePlugin = transformValuePlugins[fieldType];
|
|
38
38
|
const transformValueCallable = value => {
|
|
39
39
|
if (!transformValuePlugin) {
|
|
40
40
|
return value;
|
|
@@ -46,7 +46,7 @@ const createRefFilterCreate = () => {
|
|
|
46
46
|
};
|
|
47
47
|
const filterPlugin = valueFilterPlugins[propertyOperation];
|
|
48
48
|
if (!filterPlugin) {
|
|
49
|
-
throw new
|
|
49
|
+
throw new WebinyError(`Missing operation filter for "${propertyOperation}".`, "MISSING_OPERATION_FILTER");
|
|
50
50
|
}
|
|
51
51
|
const paths = [field.createPath({
|
|
52
52
|
field
|
|
@@ -57,7 +57,7 @@ const createRefFilterCreate = () => {
|
|
|
57
57
|
fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join("."),
|
|
58
58
|
plugin: filterPlugin,
|
|
59
59
|
negate,
|
|
60
|
-
compareValue:
|
|
60
|
+
compareValue: transformValue({
|
|
61
61
|
value: value[propertyFilter],
|
|
62
62
|
transform: transformValueCallable
|
|
63
63
|
}),
|
|
@@ -70,6 +70,5 @@ const createRefFilterCreate = () => {
|
|
|
70
70
|
plugin.name = `headless-cms.ddb.filter.ref`;
|
|
71
71
|
return plugin;
|
|
72
72
|
};
|
|
73
|
-
exports.createRefFilterCreate = createRefFilterCreate;
|
|
74
73
|
|
|
75
74
|
//# sourceMappingURL=refFilterCreate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["WebinyError","CmsEntryFieldFilterPlugin","extractWhereParams","transformValue","getBaseFieldType","createRefFilterCreate","plugin","fieldType","create","params","valueFilterPlugins","transformValuePlugins","field","value","entryId","propertyFilters","Object","keys","length","filters","propertyFilter","whereParams","fieldId","propertyId","operation","propertyOperation","negate","transformValuePlugin","transformValueCallable","transform","filterPlugin","paths","createPath","push","path","join","fieldPathId","parents","map","f","compareValue","name"],"sources":["refFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsEntryFieldFilterPluginCreateResponse } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where.js\";\nimport { transformValue } from \"~/operations/entry/filtering/transform.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\nexport const createRefFilterCreate = () => {\n const plugin = new CmsEntryFieldFilterPlugin<GenericRecord | null | undefined>({\n fieldType: \"ref\",\n create: params => {\n const { valueFilterPlugins, transformValuePlugins, field } = params;\n let value = params.value;\n if (!value) {\n value = {\n entryId: null\n };\n }\n const propertyFilters = Object.keys(value);\n if (propertyFilters.length === 0) {\n return null;\n }\n const filters: CmsEntryFieldFilterPluginCreateResponse[] = [];\n\n for (const propertyFilter of propertyFilters) {\n const whereParams = extractWhereParams(propertyFilter);\n if (!whereParams) {\n continue;\n }\n const { fieldId: propertyId, operation: propertyOperation, negate } = whereParams;\n\n const fieldType = getBaseFieldType(field);\n\n const transformValuePlugin = transformValuePlugins[fieldType];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const filterPlugin = valueFilterPlugins[propertyOperation];\n if (!filterPlugin) {\n throw new WebinyError(\n `Missing operation filter for \"${propertyOperation}\".`,\n \"MISSING_OPERATION_FILTER\"\n );\n }\n\n const paths = [\n field.createPath({\n field\n }),\n propertyId\n ];\n\n filters.push({\n field,\n path: paths.join(\".\"),\n fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join(\".\"),\n plugin: filterPlugin,\n negate,\n compareValue: transformValue({\n value: value[propertyFilter],\n transform: transformValueCallable\n }),\n transformValue: transformValueCallable\n });\n }\n\n return filters;\n }\n });\n\n plugin.name = `headless-cms.ddb.filter.ref`;\n\n return plugin;\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AAEvC,SAASC,yBAAyB;AAClC,SAASC,kBAAkB;AAC3B,SAASC,cAAc;AAEvB,SAASC,gBAAgB,QAAQ,oDAAoD;AAErF,OAAO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,MAAMC,MAAM,GAAG,IAAIL,yBAAyB,CAAmC;IAC3EM,SAAS,EAAE,KAAK;IAChBC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,kBAAkB;QAAEC,qBAAqB;QAAEC;MAAM,CAAC,GAAGH,MAAM;MACnE,IAAII,KAAK,GAAGJ,MAAM,CAACI,KAAK;MACxB,IAAI,CAACA,KAAK,EAAE;QACRA,KAAK,GAAG;UACJC,OAAO,EAAE;QACb,CAAC;MACL;MACA,MAAMC,eAAe,GAAGC,MAAM,CAACC,IAAI,CAACJ,KAAK,CAAC;MAC1C,IAAIE,eAAe,CAACG,MAAM,KAAK,CAAC,EAAE;QAC9B,OAAO,IAAI;MACf;MACA,MAAMC,OAAkD,GAAG,EAAE;MAE7D,KAAK,MAAMC,cAAc,IAAIL,eAAe,EAAE;QAC1C,MAAMM,WAAW,GAAGnB,kBAAkB,CAACkB,cAAc,CAAC;QACtD,IAAI,CAACC,WAAW,EAAE;UACd;QACJ;QACA,MAAM;UAAEC,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M;AACjB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import dot from "dot-object";
|
|
2
|
+
import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
|
|
3
|
+
import { extractWhereParams } from "../where.js";
|
|
4
|
+
export const searchableJsonFilterCreate = () => {
|
|
5
|
+
const plugin = new CmsEntryFieldFilterPlugin({
|
|
6
|
+
fieldType: "searchable-json",
|
|
7
|
+
create: params => {
|
|
8
|
+
const {
|
|
9
|
+
value: objectValue,
|
|
10
|
+
valueFilterPlugins,
|
|
11
|
+
field: parentField
|
|
12
|
+
} = params;
|
|
13
|
+
const filters = [];
|
|
14
|
+
const accessPatterns = dot.dot(objectValue);
|
|
15
|
+
for (const key in accessPatterns) {
|
|
16
|
+
const value = accessPatterns[key];
|
|
17
|
+
if (value === undefined) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const whereParams = extractWhereParams(key);
|
|
21
|
+
if (!whereParams) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const {
|
|
25
|
+
negate,
|
|
26
|
+
operation
|
|
27
|
+
} = whereParams;
|
|
28
|
+
const transformValueCallable = value => {
|
|
29
|
+
return value;
|
|
30
|
+
};
|
|
31
|
+
const fieldId = `${parentField.fieldId}.${whereParams.fieldId ?? key}`;
|
|
32
|
+
const result = {
|
|
33
|
+
field: parentField,
|
|
34
|
+
path: `values.${fieldId}`,
|
|
35
|
+
fieldPathId: `values.${fieldId}`,
|
|
36
|
+
negate,
|
|
37
|
+
plugin: valueFilterPlugins[operation],
|
|
38
|
+
compareValue: value,
|
|
39
|
+
transformValue: transformValueCallable
|
|
40
|
+
};
|
|
41
|
+
if (!result) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(result)) {
|
|
45
|
+
filters.push(...result);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
filters.push(result);
|
|
49
|
+
}
|
|
50
|
+
return filters;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
plugin.name = `headless-cms.ddb.filter.searchable-json`;
|
|
54
|
+
return plugin;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=searchableJsonFilterCreate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["dot","CmsEntryFieldFilterPlugin","extractWhereParams","searchableJsonFilterCreate","plugin","fieldType","create","params","value","objectValue","valueFilterPlugins","field","parentField","filters","accessPatterns","key","undefined","whereParams","negate","operation","transformValueCallable","fieldId","result","path","fieldPathId","compareValue","transformValue","Array","isArray","push","name"],"sources":["searchableJsonFilterCreate.ts"],"sourcesContent":["import dot from \"dot-object\";\nimport type { CmsEntryFieldFilterPluginCreateResponse } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where.js\";\n\nexport const searchableJsonFilterCreate = () => {\n const plugin = new CmsEntryFieldFilterPlugin({\n fieldType: \"searchable-json\",\n create: params => {\n const { value: objectValue, valueFilterPlugins, field: parentField } = params;\n\n const filters = [];\n\n const accessPatterns = dot.dot(objectValue);\n\n for (const key in accessPatterns) {\n const value = accessPatterns[key];\n if (value === undefined) {\n continue;\n }\n\n const whereParams = extractWhereParams(key);\n if (!whereParams) {\n continue;\n }\n const { negate, operation } = whereParams;\n\n const transformValueCallable = (value: any) => {\n return value;\n };\n\n const fieldId = `${parentField.fieldId}.${whereParams.fieldId ?? key}`;\n\n const result: CmsEntryFieldFilterPluginCreateResponse = {\n field: parentField,\n path: `values.${fieldId}`,\n fieldPathId: `values.${fieldId}`,\n negate,\n plugin: valueFilterPlugins[operation],\n compareValue: value,\n transformValue: transformValueCallable\n };\n\n if (!result) {\n continue;\n }\n if (Array.isArray(result)) {\n filters.push(...result);\n continue;\n }\n\n filters.push(result);\n }\n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,CAACE,MAAM,EAAE;UACT;QACJ;QACA,IAAIK,KAAK,CAACC,OAAO,CAACN,MAAM,CAAC,EAAE;UACvBT,OAAO,CAACgB,IAAI,CAAC,GAAGP,MAAM,CAAC;UACvB;QACJ;QAEAT,OAAO,CAACgB,IAAI,CAACP,MAAM,CAAC;MACxB;MACA,OAAOT,OAAO;IAClB;EACJ,CAAC,CAAC;EAEFT,MAAM,CAAC0B,IAAI,GAAG,yCAAyC;EAEvD,OAAO1B,MAAM;AACjB,CAAC","ignoreList":[]}
|
|
@@ -1,12 +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 {
|
|
1
|
+
import type { CmsEntry, CmsEntryValues, CmsModel } from "@webiny/api-headless-cms/types/index.js";
|
|
2
|
+
import type { Field } from "./types.js";
|
|
3
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
4
|
+
interface Params<T extends CmsEntryValues = CmsEntryValues> {
|
|
5
5
|
model: CmsModel;
|
|
6
|
-
items: CmsEntry[];
|
|
6
|
+
items: CmsEntry<T>[];
|
|
7
7
|
sort?: string[];
|
|
8
8
|
fields: Record<string, Field>;
|
|
9
9
|
plugins: PluginsContainer;
|
|
10
10
|
}
|
|
11
|
-
export declare const sort: (params: Params) => CmsEntry[];
|
|
11
|
+
export declare const sort: <T extends CmsEntryValues = CmsEntryValues>(params: Params<T>) => CmsEntry<T>[];
|
|
12
12
|
export {};
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 => {
|
|
1
|
+
import WebinyError from "@webiny/error";
|
|
2
|
+
import dotProp from "dot-prop";
|
|
3
|
+
import lodashSortBy from "lodash/sortBy.js";
|
|
4
|
+
import { extractSort } from "./extractSort.js";
|
|
5
|
+
export const sort = params => {
|
|
13
6
|
const {
|
|
14
7
|
model,
|
|
15
8
|
items,
|
|
@@ -22,13 +15,13 @@ const sort = params => {
|
|
|
22
15
|
} else if (sort.length === 0) {
|
|
23
16
|
sort.push("savedOn_DESC");
|
|
24
17
|
} else if (sort.length > 1) {
|
|
25
|
-
throw new
|
|
26
|
-
sort
|
|
18
|
+
throw new WebinyError("Sorting is limited to a single field on DynamoDB only system.", "SORT_MULTIPLE_FIELDS_ERROR", {
|
|
19
|
+
sort
|
|
27
20
|
});
|
|
28
21
|
}
|
|
29
22
|
const [firstSort] = sort;
|
|
30
23
|
if (!firstSort) {
|
|
31
|
-
throw new
|
|
24
|
+
throw new WebinyError("Empty sort array item.", "SORT_EMPTY_ERROR", {
|
|
32
25
|
sort
|
|
33
26
|
});
|
|
34
27
|
}
|
|
@@ -37,7 +30,7 @@ const sort = params => {
|
|
|
37
30
|
field,
|
|
38
31
|
valuePath,
|
|
39
32
|
reverse
|
|
40
|
-
} =
|
|
33
|
+
} = extractSort({
|
|
41
34
|
model,
|
|
42
35
|
sortBy: firstSort,
|
|
43
36
|
fields,
|
|
@@ -46,16 +39,20 @@ const sort = params => {
|
|
|
46
39
|
const itemsToSort = items.map(item => {
|
|
47
40
|
return {
|
|
48
41
|
id: item.id,
|
|
49
|
-
value: field.transform(
|
|
42
|
+
value: field.transform(dotProp.get(item, valuePath))
|
|
50
43
|
};
|
|
51
44
|
});
|
|
52
|
-
const sortedItems = (
|
|
45
|
+
const sortedItems = lodashSortBy(itemsToSort, "value");
|
|
53
46
|
const newItems = sortedItems.map(s => {
|
|
54
47
|
const item = items.find(i => i.id === s.id);
|
|
55
48
|
if (item) {
|
|
56
49
|
return item;
|
|
57
50
|
}
|
|
58
|
-
|
|
51
|
+
/**
|
|
52
|
+
* This is impossible to happen because sorting items does not remove the items.
|
|
53
|
+
* BUT, we need to have this check just in case for development purposes.
|
|
54
|
+
*/
|
|
55
|
+
throw new WebinyError("Could not find item by given id after the sorting.", "SORTING_ITEMS_ERROR", {
|
|
59
56
|
id: s.id,
|
|
60
57
|
sortingBy: fieldId,
|
|
61
58
|
reverse
|
|
@@ -66,6 +63,5 @@ const sort = params => {
|
|
|
66
63
|
}
|
|
67
64
|
return newItems.reverse();
|
|
68
65
|
};
|
|
69
|
-
exports.sort = sort;
|
|
70
66
|
|
|
71
67
|
//# sourceMappingURL=sort.js.map
|