@webiny/api-headless-cms-ddb 0.0.0-unstable.2af142b57e → 0.0.0-unstable.3bc8100a7f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/definitions/entry.d.ts +4 -3
- package/definitions/entry.js +109 -12
- package/definitions/entry.js.map +1 -1
- package/definitions/group.d.ts +4 -3
- package/definitions/group.js +9 -8
- package/definitions/group.js.map +1 -1
- package/definitions/model.d.ts +4 -3
- package/definitions/model.js +26 -8
- package/definitions/model.js.map +1 -1
- package/definitions/system.d.ts +4 -3
- package/definitions/system.js +9 -8
- package/definitions/system.js.map +1 -1
- package/definitions/table.d.ts +5 -5
- package/definitions/table.js +8 -4
- package/definitions/table.js.map +1 -1
- package/dynamoDb/index.js +5 -3
- package/dynamoDb/index.js.map +1 -1
- package/dynamoDb/path/locationFolderId.d.ts +2 -0
- package/dynamoDb/path/locationFolderId.js +43 -0
- package/dynamoDb/path/locationFolderId.js.map +1 -0
- package/dynamoDb/path/plainObject.js +3 -1
- package/dynamoDb/path/plainObject.js.map +1 -1
- package/dynamoDb/storage/longText.js +4 -1
- package/dynamoDb/storage/longText.js.map +1 -1
- package/dynamoDb/storage/richText.js +24 -58
- package/dynamoDb/storage/richText.js.map +1 -1
- package/dynamoDb/transformValue/datetime.d.ts +1 -1
- package/dynamoDb/transformValue/datetime.js +3 -1
- package/dynamoDb/transformValue/datetime.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +16 -23
- package/index.js.map +1 -1
- package/operations/entry/dataLoader/DataLoaderCache.d.ts +17 -0
- package/operations/entry/dataLoader/DataLoaderCache.js +41 -0
- package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
- package/operations/entry/dataLoader/constants.d.ts +1 -0
- package/operations/entry/dataLoader/constants.js +10 -0
- package/operations/entry/dataLoader/constants.js.map +1 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js +25 -0
- package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js +45 -0
- package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +56 -0
- package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +56 -0
- package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
- package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
- package/operations/entry/dataLoader/getRevisionById.js +62 -0
- package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
- package/operations/entry/dataLoader/index.d.ts +8 -0
- package/operations/entry/dataLoader/index.js +40 -0
- package/operations/entry/dataLoader/index.js.map +1 -0
- package/operations/entry/dataLoader/types.d.ts +6 -0
- package/operations/entry/dataLoader/types.js +7 -0
- package/operations/entry/dataLoader/types.js.map +1 -0
- package/operations/entry/dataLoaders.d.ts +12 -27
- package/operations/entry/dataLoaders.js +55 -217
- package/operations/entry/dataLoaders.js.map +1 -1
- package/operations/entry/filtering/createExpressions.d.ts +4 -4
- package/operations/entry/filtering/createExpressions.js +3 -1
- package/operations/entry/filtering/createExpressions.js.map +1 -1
- package/operations/entry/filtering/createFields.d.ts +6 -4
- package/operations/entry/filtering/createFields.js +77 -74
- package/operations/entry/filtering/createFields.js.map +1 -1
- package/operations/entry/filtering/extractSort.d.ts +3 -3
- package/operations/entry/filtering/extractSort.js +3 -1
- package/operations/entry/filtering/extractSort.js.map +1 -1
- package/operations/entry/filtering/filter.d.ts +3 -3
- package/operations/entry/filtering/filter.js +24 -9
- package/operations/entry/filtering/filter.js.map +1 -1
- package/operations/entry/filtering/fullTextSearch.d.ts +3 -3
- package/operations/entry/filtering/fullTextSearch.js +3 -1
- package/operations/entry/filtering/fullTextSearch.js.map +1 -1
- package/operations/entry/filtering/getValue.js +6 -3
- package/operations/entry/filtering/getValue.js.map +1 -1
- package/operations/entry/filtering/index.js +3 -1
- 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 -1
- package/operations/entry/filtering/mapPlugins.js.map +1 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +1 -1
- package/operations/entry/filtering/plugins/defaultFilterCreate.js +6 -2
- 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 +5 -2
- package/operations/entry/filtering/plugins/index.js.map +1 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +1 -1
- package/operations/entry/filtering/plugins/objectFilterCreate.js +6 -2
- package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
- package/operations/entry/filtering/plugins/refFilterCreate.d.ts +2 -1
- package/operations/entry/filtering/plugins/refFilterCreate.js +12 -3
- 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 +65 -0
- package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -0
- package/operations/entry/filtering/sort.d.ts +3 -3
- package/operations/entry/filtering/sort.js +5 -3
- package/operations/entry/filtering/sort.js.map +1 -1
- package/operations/entry/filtering/systemFields.d.ts +2 -2
- package/operations/entry/filtering/systemFields.js +49 -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 +3 -1
- package/operations/entry/filtering/transform.js.map +1 -1
- package/operations/entry/filtering/types.d.ts +2 -2
- package/operations/entry/filtering/types.js +3 -1
- package/operations/entry/filtering/types.js.map +1 -1
- package/operations/entry/filtering/values.d.ts +1 -1
- package/operations/entry/filtering/values.js +3 -1
- package/operations/entry/filtering/values.js.map +1 -1
- package/operations/entry/filtering/where.js +6 -3
- package/operations/entry/filtering/where.js.map +1 -1
- package/operations/entry/index.d.ts +3 -3
- package/operations/entry/index.js +712 -193
- package/operations/entry/index.js.map +1 -1
- package/operations/entry/keys.js +3 -1
- package/operations/entry/keys.js.map +1 -1
- package/operations/group/index.d.ts +3 -3
- package/operations/group/index.js +33 -21
- package/operations/group/index.js.map +1 -1
- package/operations/model/index.d.ts +2 -2
- package/operations/model/index.js +26 -13
- package/operations/model/index.js.map +1 -1
- package/operations/system/index.d.ts +2 -2
- package/operations/system/index.js +19 -7
- package/operations/system/index.js.map +1 -1
- package/package.json +21 -26
- package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +3 -2
- package/plugins/CmsEntryFieldFilterPathPlugin.js +11 -4
- package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldFilterPlugin.d.ts +10 -10
- package/plugins/CmsEntryFieldFilterPlugin.js +9 -6
- package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
- package/plugins/CmsEntryFieldSortingPlugin.d.ts +2 -2
- package/plugins/CmsEntryFieldSortingPlugin.js +4 -5
- package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
- package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js +23 -0
- package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
- package/plugins/index.d.ts +1 -0
- package/plugins/index.js +14 -1
- package/plugins/index.js.map +1 -1
- package/types.d.ts +20 -13
- package/types.js +5 -5
- package/types.js.map +1 -1
- package/definitions/settings.d.ts +0 -9
- package/definitions/settings.js +0 -53
- package/definitions/settings.js.map +0 -1
- package/dynamoDb/storage/date.d.ts +0 -3
- package/dynamoDb/storage/date.js +0 -91
- package/dynamoDb/storage/date.js.map +0 -1
- package/operations/entry/systemFields.d.ts +0 -2
- package/operations/entry/systemFields.js +0 -72
- package/operations/entry/systemFields.js.map +0 -1
- package/operations/settings/index.d.ts +0 -7
- package/operations/settings/index.js +0 -111
- package/operations/settings/index.js.map +0 -1
|
@@ -1,14 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.createFields = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
7
|
var _systemFields = require("./systemFields");
|
|
10
8
|
var _plugins = require("../../../plugins");
|
|
11
9
|
var _mapPlugins = require("./mapPlugins");
|
|
10
|
+
const createFieldCollection = params => {
|
|
11
|
+
const {
|
|
12
|
+
fields,
|
|
13
|
+
parents,
|
|
14
|
+
transformValuePlugins,
|
|
15
|
+
valuePathPlugins,
|
|
16
|
+
system
|
|
17
|
+
} = params;
|
|
18
|
+
return fields.reduce((collection, field) => {
|
|
19
|
+
const transformPlugin = transformValuePlugins[field.type];
|
|
20
|
+
const valuePathPlugin = valuePathPlugins[field.type];
|
|
21
|
+
const basePath = system ? [] : ["values"];
|
|
22
|
+
/**
|
|
23
|
+
* The required fieldId is a product of all of its parents and its own fieldId.
|
|
24
|
+
*/
|
|
25
|
+
const fieldId = [...parents, {
|
|
26
|
+
fieldId: field.fieldId,
|
|
27
|
+
multipleValues: field.multipleValues
|
|
28
|
+
}].map(f => f.fieldId).join(".");
|
|
29
|
+
collection[fieldId] = {
|
|
30
|
+
...field,
|
|
31
|
+
parents,
|
|
32
|
+
system,
|
|
33
|
+
createPath: params => {
|
|
34
|
+
if (valuePathPlugin && valuePathPlugin.canUse(field, parents.map(p => p.fieldId))) {
|
|
35
|
+
return valuePathPlugin.createPath(params);
|
|
36
|
+
}
|
|
37
|
+
return basePath.concat(parents.map(parent => parent.fieldId)).concat([params.field.fieldId]).join(".");
|
|
38
|
+
},
|
|
39
|
+
transform: value => {
|
|
40
|
+
if (!transformPlugin) {
|
|
41
|
+
return value;
|
|
42
|
+
}
|
|
43
|
+
return transformPlugin.transform({
|
|
44
|
+
field,
|
|
45
|
+
value
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const childFields = field.settings?.fields;
|
|
50
|
+
if (!childFields?.length) {
|
|
51
|
+
return collection;
|
|
52
|
+
}
|
|
53
|
+
const result = createFieldCollection({
|
|
54
|
+
fields: childFields,
|
|
55
|
+
parents: [...parents, {
|
|
56
|
+
fieldId: field.fieldId,
|
|
57
|
+
multipleValues: field.multipleValues
|
|
58
|
+
}],
|
|
59
|
+
transformValuePlugins,
|
|
60
|
+
valuePathPlugins,
|
|
61
|
+
system
|
|
62
|
+
});
|
|
63
|
+
Object.assign(collection, result);
|
|
64
|
+
return collection;
|
|
65
|
+
}, {});
|
|
66
|
+
};
|
|
12
67
|
/**
|
|
13
68
|
* This method will map the fieldId (fieldId -> field) to the actual field.
|
|
14
69
|
*
|
|
@@ -29,77 +84,25 @@ const createFields = params => {
|
|
|
29
84
|
type: _plugins.CmsEntryFieldFilterPathPlugin.type,
|
|
30
85
|
property: "fieldType"
|
|
31
86
|
});
|
|
32
|
-
const collection = (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
value
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
return fields;
|
|
54
|
-
}, {});
|
|
55
|
-
const addFieldsToCollection = (fields, parents = []) => {
|
|
56
|
-
/**
|
|
57
|
-
* Exit early if no fields are sent.
|
|
58
|
-
*/
|
|
59
|
-
if (fields.length === 0) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
for (const field of fields) {
|
|
63
|
-
var _field$settings2;
|
|
64
|
-
const transformPlugin = transformValuePlugins[field.type];
|
|
65
|
-
const valuePathPlugin = valuePathPlugins[field.type];
|
|
66
|
-
/**
|
|
67
|
-
* The required fieldId is a product of all of its parents and its own fieldId.
|
|
68
|
-
*/
|
|
69
|
-
const fieldId = [...parents, {
|
|
70
|
-
fieldId: field.fieldId,
|
|
71
|
-
multipleValues: field.multipleValues
|
|
72
|
-
}].map(f => f.fieldId).join(".");
|
|
73
|
-
collection[fieldId] = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, field), {}, {
|
|
74
|
-
parents,
|
|
75
|
-
system: false,
|
|
76
|
-
createPath: params => {
|
|
77
|
-
if (valuePathPlugin) {
|
|
78
|
-
return valuePathPlugin.createPath(params);
|
|
79
|
-
}
|
|
80
|
-
return ["values"].concat(parents.map(parent => parent.fieldId)).concat([params.field.fieldId]).join(".");
|
|
81
|
-
},
|
|
82
|
-
transform: value => {
|
|
83
|
-
if (!transformPlugin) {
|
|
84
|
-
return value;
|
|
85
|
-
}
|
|
86
|
-
return transformPlugin.transform({
|
|
87
|
-
field,
|
|
88
|
-
value
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
const childFields = (_field$settings2 = field.settings) === null || _field$settings2 === void 0 ? void 0 : _field$settings2.fields;
|
|
93
|
-
if (!childFields || childFields.length === 0) {
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
addFieldsToCollection(childFields, [...parents, {
|
|
97
|
-
fieldId: field.fieldId,
|
|
98
|
-
multipleValues: field.multipleValues
|
|
99
|
-
}]);
|
|
100
|
-
}
|
|
87
|
+
const collection = createFieldCollection({
|
|
88
|
+
fields: (0, _systemFields.createSystemFields)(),
|
|
89
|
+
transformValuePlugins,
|
|
90
|
+
valuePathPlugins,
|
|
91
|
+
parents: [],
|
|
92
|
+
system: true
|
|
93
|
+
});
|
|
94
|
+
const result = createFieldCollection({
|
|
95
|
+
fields,
|
|
96
|
+
transformValuePlugins,
|
|
97
|
+
valuePathPlugins,
|
|
98
|
+
parents: [],
|
|
99
|
+
system: false
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
...collection,
|
|
103
|
+
...result
|
|
101
104
|
};
|
|
102
|
-
addFieldsToCollection(fields);
|
|
103
|
-
return collection;
|
|
104
105
|
};
|
|
105
|
-
exports.createFields = createFields;
|
|
106
|
+
exports.createFields = createFields;
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=createFields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_systemFields","require","_plugins","_mapPlugins","createFieldCollection","params","fields","parents","transformValuePlugins","valuePathPlugins","system","reduce","collection","field","transformPlugin","type","valuePathPlugin","basePath","fieldId","multipleValues","map","f","join","createPath","canUse","p","concat","parent","transform","value","childFields","settings","length","result","Object","assign","createFields","plugins","getMappedPlugins","property","CmsEntryFieldFilterPathPlugin","createSystemFields","exports"],"sources":["createFields.ts"],"sourcesContent":["import type { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { createSystemFields } from \"./systemFields\";\nimport type { Field, FieldParent } from \"./types\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { CmsFieldFilterValueTransformPlugin } from \"~/types\";\nimport { CmsEntryFieldFilterPathPlugin } from \"~/plugins\";\nimport { getMappedPlugins } from \"./mapPlugins\";\n\ninterface Params {\n fields: CmsModelField[];\n plugins: PluginsContainer;\n}\n\ninterface FieldCollection {\n [key: string]: Field;\n}\n\ninterface AddFieldsToCollectionParams {\n fields: CmsModelField[];\n parents: FieldParent[];\n transformValuePlugins: Record<string, CmsFieldFilterValueTransformPlugin>;\n valuePathPlugins: Record<string, CmsEntryFieldFilterPathPlugin>;\n system: boolean;\n}\n\nconst createFieldCollection = (params: AddFieldsToCollectionParams): FieldCollection => {\n const { fields, parents, transformValuePlugins, valuePathPlugins, system } = params;\n return fields.reduce<FieldCollection>((collection, field) => {\n const transformPlugin = transformValuePlugins[field.type];\n const valuePathPlugin = valuePathPlugins[field.type];\n\n const basePath = system ? [] : [\"values\"];\n /**\n * The required fieldId is a product of all of its parents and its own fieldId.\n */\n const fieldId = [\n ...parents,\n {\n fieldId: field.fieldId,\n multipleValues: field.multipleValues\n }\n ]\n .map(f => f.fieldId)\n .join(\".\");\n\n collection[fieldId] = {\n ...field,\n parents,\n system,\n createPath: params => {\n if (\n valuePathPlugin &&\n valuePathPlugin.canUse(\n field,\n parents.map(p => p.fieldId)\n )\n ) {\n return valuePathPlugin.createPath(params);\n }\n\n return basePath\n .concat(parents.map(parent => parent.fieldId))\n .concat([params.field.fieldId])\n .join(\".\");\n },\n transform: value => {\n if (!transformPlugin) {\n return value;\n }\n return transformPlugin.transform({\n field,\n value\n });\n }\n };\n const childFields = field.settings?.fields;\n if (!childFields?.length) {\n return collection;\n }\n\n const result = createFieldCollection({\n fields: childFields,\n parents: [\n ...parents,\n {\n fieldId: field.fieldId,\n multipleValues: field.multipleValues\n }\n ],\n transformValuePlugins,\n valuePathPlugins,\n system\n });\n Object.assign(collection, result);\n return collection;\n }, {});\n};\n/**\n * This method will map the fieldId (fieldId -> field) to the actual field.\n *\n * In case of nested fields, fieldId is all the parent fieldIds + current one, joined by the dot (.).\n */\nexport const createFields = (params: Params) => {\n const { fields, plugins } = params;\n\n const transformValuePlugins = getMappedPlugins<CmsFieldFilterValueTransformPlugin>({\n plugins,\n type: \"cms-field-filter-value-transform\",\n property: \"fieldType\"\n });\n const valuePathPlugins = getMappedPlugins<CmsEntryFieldFilterPathPlugin>({\n plugins,\n type: CmsEntryFieldFilterPathPlugin.type,\n property: \"fieldType\"\n });\n\n const collection = createFieldCollection({\n fields: createSystemFields(),\n transformValuePlugins,\n valuePathPlugins,\n parents: [],\n system: true\n });\n\n const result = createFieldCollection({\n fields,\n transformValuePlugins,\n valuePathPlugins,\n parents: [],\n system: false\n });\n\n return {\n ...collection,\n ...result\n };\n};\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AAIA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAmBA,MAAMG,qBAAqB,GAAIC,MAAmC,IAAsB;EACpF,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC,qBAAqB;IAAEC,gBAAgB;IAAEC;EAAO,CAAC,GAAGL,MAAM;EACnF,OAAOC,MAAM,CAACK,MAAM,CAAkB,CAACC,UAAU,EAAEC,KAAK,KAAK;IACzD,MAAMC,eAAe,GAAGN,qBAAqB,CAACK,KAAK,CAACE,IAAI,CAAC;IACzD,MAAMC,eAAe,GAAGP,gBAAgB,CAACI,KAAK,CAACE,IAAI,CAAC;IAEpD,MAAME,QAAQ,GAAGP,MAAM,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC;IACzC;AACR;AACA;IACQ,MAAMQ,OAAO,GAAG,CACZ,GAAGX,OAAO,EACV;MACIW,OAAO,EAAEL,KAAK,CAACK,OAAO;MACtBC,cAAc,EAAEN,KAAK,CAACM;IAC1B,CAAC,CACJ,CACIC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACH,OAAO,CAAC,CACnBI,IAAI,CAAC,GAAG,CAAC;IAEdV,UAAU,CAACM,OAAO,CAAC,GAAG;MAClB,GAAGL,KAAK;MACRN,OAAO;MACPG,MAAM;MACNa,UAAU,EAAElB,MAAM,IAAI;QAClB,IACIW,eAAe,IACfA,eAAe,CAACQ,MAAM,CAClBX,KAAK,EACLN,OAAO,CAACa,GAAG,CAACK,CAAC,IAAIA,CAAC,CAACP,OAAO,CAC9B,CAAC,EACH;UACE,OAAOF,eAAe,CAACO,UAAU,CAAClB,MAAM,CAAC;QAC7C;QAEA,OAAOY,QAAQ,CACVS,MAAM,CAACnB,OAAO,CAACa,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AAI;IACxCwB,QAAQ,EAAE;EACd,CAAC,CAAC;EAEF,MAAM3B,UAAU,GAAGR,qBAAqB,CAAC;IACrCE,MAAM,EAAE,IAAAmC,gCAAkB,EAAC,CAAC;IAC5BjC,qBAAqB;IACrBC,gBAAgB;IAChBF,OAAO,EAAE,EAAE;IACXG,MAAM,EAAE;EACZ,CAAC,CAAC;EAEF,MAAMuB,MAAM,GAAG7B,qBAAqB,CAAC;IACjCE,MAAM;IACNE,qBAAqB;IACrBC,gBAAgB;IAChBF,OAAO,EAAE,EAAE;IACXG,MAAM,EAAE;EACZ,CAAC,CAAC;EAEF,OAAO;IACH,GAAGE,UAAU;IACb,GAAGqB;EACP,CAAC;AACL,CAAC;AAACS,OAAA,CAAAN,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Field } from "./types";
|
|
2
|
-
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
-
import { CmsModel } from "@webiny/api-headless-cms/types";
|
|
1
|
+
import type { Field } from "./types";
|
|
2
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
import type { CmsModel } from "@webiny/api-headless-cms/types";
|
|
4
4
|
interface Result {
|
|
5
5
|
valuePath: string;
|
|
6
6
|
reverse: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["extractSort","params","model","sortBy","fields","plugins","result","split","length","WebinyError","fieldId","order","field","Object","values","find","parents","plugin","byType","CmsEntryFieldSortingPlugin","type","reverse","canUse","createSort","valuePath","createPath"],"sources":["extractSort.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Field } from \"./types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryFieldSortingPlugin } from \"~/plugins\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\ninterface Result {\n valuePath: string;\n reverse: boolean;\n fieldId: string;\n field: Field;\n}\n\ninterface Params {\n model: CmsModel;\n sortBy: string;\n fields: Record<string, Field>;\n plugins: PluginsContainer;\n}\n\nexport const extractSort = (params: Params): Result => {\n const { model, sortBy, fields, plugins } = params;\n const result = sortBy.split(\"_\");\n if (result.length !== 2) {\n throw new WebinyError(\n \"Problem in determining the sorting for the entry items.\",\n \"SORT_EXTRACT_ERROR\",\n {\n sortBy\n }\n );\n }\n const [fieldId, order] = result as [string, \"ASC\" | \"DESC\"];\n\n const field = Object.values(fields).find(field => {\n /**\n * We do not support sorting by nested fields.\n */\n if (field.parents.length > 0) {\n return false;\n }\n return field.fieldId === fieldId;\n });\n\n const plugin = plugins\n .byType<CmsEntryFieldSortingPlugin>(CmsEntryFieldSortingPlugin.type)\n .reverse()\n .find(plugin => {\n return plugin.canUse({\n model,\n field,\n fieldId,\n order,\n sortBy\n });\n });\n\n if (plugin) {\n return plugin.createSort({\n model,\n fieldId,\n order,\n sortBy,\n field,\n fields\n });\n } else if (!field) {\n throw new WebinyError(\n \"Sorting field does not exist in the content model.\",\n \"SORTING_FIELD_ERROR\",\n {\n fieldId,\n fields\n }\n );\n }\n const valuePath = field.createPath({\n field\n });\n return {\n field,\n fieldId,\n valuePath,\n reverse: order === \"DESC\"\n };\n};\n"],"mappings":";;;;;;;AAAA;AAGA;AAiBO,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_plugins","extractSort","params","model","sortBy","fields","plugins","result","split","length","WebinyError","fieldId","order","field","Object","values","find","parents","plugin","byType","CmsEntryFieldSortingPlugin","type","reverse","canUse","createSort","valuePath","createPath","exports"],"sources":["extractSort.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { Field } from \"./types\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsEntryFieldSortingPlugin } from \"~/plugins\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types\";\n\ninterface Result {\n valuePath: string;\n reverse: boolean;\n fieldId: string;\n field: Field;\n}\n\ninterface Params {\n model: CmsModel;\n sortBy: string;\n fields: Record<string, Field>;\n plugins: PluginsContainer;\n}\n\nexport const extractSort = (params: Params): Result => {\n const { model, sortBy, fields, plugins } = params;\n const result = sortBy.split(\"_\");\n if (result.length !== 2) {\n throw new WebinyError(\n \"Problem in determining the sorting for the entry items.\",\n \"SORT_EXTRACT_ERROR\",\n {\n sortBy\n }\n );\n }\n const [fieldId, order] = result as [string, \"ASC\" | \"DESC\"];\n\n const field = Object.values(fields).find(field => {\n /**\n * We do not support sorting by nested fields.\n */\n if (field.parents.length > 0) {\n return false;\n }\n return field.fieldId === fieldId;\n });\n\n const plugin = plugins\n .byType<CmsEntryFieldSortingPlugin>(CmsEntryFieldSortingPlugin.type)\n .reverse()\n .find(plugin => {\n return plugin.canUse({\n model,\n field,\n fieldId,\n order,\n sortBy\n });\n });\n\n if (plugin) {\n return plugin.createSort({\n model,\n fieldId,\n order,\n sortBy,\n field,\n fields\n });\n } else if (!field) {\n throw new WebinyError(\n \"Sorting field does not exist in the content model.\",\n \"SORTING_FIELD_ERROR\",\n {\n fieldId,\n fields\n }\n );\n }\n const valuePath = field.createPath({\n field\n });\n return {\n field,\n fieldId,\n valuePath,\n reverse: order === \"DESC\"\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,QAAA,GAAAD,OAAA;AAiBO,MAAME,WAAW,GAAIC,MAAc,IAAa;EACnD,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGJ,MAAM;EACjD,MAAMK,MAAM,GAAGH,MAAM,CAACI,KAAK,CAAC,GAAG,CAAC;EAChC,IAAID,MAAM,CAACE,MAAM,KAAK,CAAC,EAAE;IACrB,MAAM,IAAIC,cAAW,CACjB,yDAAyD,EACzD,oBAAoB,EACpB;MACIN;IACJ,CACJ,CAAC;EACL;EACA,MAAM,CAACO,OAAO,EAAEC,KAAK,CAAC,GAAGL,MAAkC;EAE3D,MAAMM,KAAK,GAAGC,MAAM,CAACC,MAAM,CAACV,MAAM,CAAC,CAACW,IAAI,CAACH,KAAK,IAAI;IAC9C;AACR;AACA;IACQ,IAAIA,KAAK,CAACI,OAAO,CAACR,MAAM,GAAG,CAAC,EAAE;MAC1B,OAAO,KAAK;IAChB;IACA,OAAOI,KAAK,CAACF,OAAO,KAAKA,OAAO;EACpC,CAAC,CAAC;EAEF,MAAMO,MAAM,GAAGZ,OAAO,CACjBa,MAAM,CAA6BC,mCAA0B,CAACC,IAAI,CAAC,CACnEC,OAAO,CAAC,CAAC,CACTN,IAAI,CAACE,MAAM,IAAI;IACZ,OAAOA,MAAM,CAACK,MAAM,CAAC;MACjBpB,KAAK;MACLU,KAAK;MACLF,OAAO;MACPC,KAAK;MACLR;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;EAEN,IAAIc,MAAM,EAAE;IACR,OAAOA,MAAM,CAACM,UAAU,CAAC;MACrBrB,KAAK;MACLQ,OAAO;MACPC,KAAK;MACLR,MAAM;MACNS,KAAK;MACLR;IACJ,CAAC,CAAC;EACN,CAAC,MAAM,IAAI,CAACQ,KAAK,EAAE;IACf,MAAM,IAAIH,cAAW,CACjB,oDAAoD,EACpD,qBAAqB,EACrB;MACIC,OAAO;MACPN;IACJ,CACJ,CAAC;EACL;EACA,MAAMoB,SAAS,GAAGZ,KAAK,CAACa,UAAU,CAAC;IAC/Bb;EACJ,CAAC,CAAC;EACF,OAAO;IACHA,KAAK;IACLF,OAAO;IACPc,SAAS;IACTH,OAAO,EAAEV,KAAK,KAAK;EACvB,CAAC;AACL,CAAC;AAACe,OAAA,CAAA1B,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CmsEntry, CmsEntryListWhere } from "@webiny/api-headless-cms/types";
|
|
2
|
-
import { PluginsContainer } from "@webiny/plugins";
|
|
3
|
-
import { Field } from "./types";
|
|
1
|
+
import type { CmsEntry, CmsEntryListWhere } from "@webiny/api-headless-cms/types";
|
|
2
|
+
import type { PluginsContainer } from "@webiny/plugins";
|
|
3
|
+
import type { Field } from "./types";
|
|
4
4
|
interface Params {
|
|
5
5
|
items: CmsEntry[];
|
|
6
6
|
where: Partial<CmsEntryListWhere>;
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.filter = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
8
|
var _ValueFilterPlugin = require("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin");
|
|
10
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
10
|
var _fullTextSearch = require("./fullTextSearch");
|
|
@@ -17,6 +16,18 @@ const executeFilter = params => {
|
|
|
17
16
|
value,
|
|
18
17
|
filter
|
|
19
18
|
} = params;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* We need to check if the filter can be used.
|
|
22
|
+
* If it cannot, we will just return true.
|
|
23
|
+
*/
|
|
24
|
+
const canUse = filter.plugin.canUse({
|
|
25
|
+
value,
|
|
26
|
+
compareValue: filter.compareValue
|
|
27
|
+
});
|
|
28
|
+
if (!canUse) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
20
31
|
const matched = filter.plugin.matches({
|
|
21
32
|
value,
|
|
22
33
|
compareValue: filter.compareValue
|
|
@@ -57,9 +68,10 @@ const executeExpressions = params => {
|
|
|
57
68
|
* Then we move onto expressions, which are basically nested upon nested filters with different conditions.
|
|
58
69
|
*/
|
|
59
70
|
for (const expression of expressions) {
|
|
60
|
-
const result = executeExpressions(
|
|
71
|
+
const result = executeExpressions({
|
|
72
|
+
...expression,
|
|
61
73
|
getCachedValue
|
|
62
|
-
})
|
|
74
|
+
});
|
|
63
75
|
if (result && condition === "OR") {
|
|
64
76
|
return true;
|
|
65
77
|
} else if (!result && condition == "AND") {
|
|
@@ -94,7 +106,7 @@ const filter = params => {
|
|
|
94
106
|
/**
|
|
95
107
|
* No point in going further if there are no expressions to be applied and no full text search to be executed.
|
|
96
108
|
*/
|
|
97
|
-
if (expression.filters.length === 0 && expression.expressions.length === 0 && !
|
|
109
|
+
if (expression.filters.length === 0 && expression.expressions.length === 0 && !fullTextSearch?.term) {
|
|
98
110
|
return records;
|
|
99
111
|
}
|
|
100
112
|
/**
|
|
@@ -105,8 +117,8 @@ const filter = params => {
|
|
|
105
117
|
throw new _error.default(`Missing "contains" plugin to run the full-text search.`, "MISSING_PLUGIN");
|
|
106
118
|
}
|
|
107
119
|
const search = (0, _fullTextSearch.createFullTextSearch)({
|
|
108
|
-
term: fullTextSearch
|
|
109
|
-
targetFields: fullTextSearch
|
|
120
|
+
term: fullTextSearch?.term,
|
|
121
|
+
targetFields: fullTextSearch?.fields,
|
|
110
122
|
fields,
|
|
111
123
|
plugin: fullTextSearchPlugin
|
|
112
124
|
});
|
|
@@ -127,9 +139,10 @@ const filter = params => {
|
|
|
127
139
|
cachedValues[path] = rawValue;
|
|
128
140
|
return rawValue;
|
|
129
141
|
};
|
|
130
|
-
const exprResult = executeExpressions(
|
|
142
|
+
const exprResult = executeExpressions({
|
|
143
|
+
...expression,
|
|
131
144
|
getCachedValue
|
|
132
|
-
})
|
|
145
|
+
});
|
|
133
146
|
/**
|
|
134
147
|
* If expression result is false we do not need to continue further.
|
|
135
148
|
* Also, if there is no full text search defined, just return the expression result.
|
|
@@ -140,4 +153,6 @@ const filter = params => {
|
|
|
140
153
|
return search(record);
|
|
141
154
|
});
|
|
142
155
|
};
|
|
143
|
-
exports.filter = filter;
|
|
156
|
+
exports.filter = filter;
|
|
157
|
+
|
|
158
|
+
//# sourceMappingURL=filter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["executeFilter","params","value","filter","
|
|
1
|
+
{"version":3,"names":["_ValueFilterPlugin","require","_error","_interopRequireDefault","_fullTextSearch","_createExpressions","_transform","_getValue","executeFilter","params","value","filter","canUse","plugin","compareValue","matched","matches","negate","executeExpressions","expressions","getCachedValue","filters","condition","length","result","expression","items","records","where","plugins","fields","fullTextSearch","keys","Object","createExpressions","term","fullTextSearchPlugin","byType","ValueFilterPlugin","type","find","getOperation","WebinyError","search","createFullTextSearch","targetFields","record","cachedValues","path","undefined","plainValue","getValue","rawValue","transformValue","transform","exprResult","exports"],"sources":["filter.ts"],"sourcesContent":["import type { CmsEntry, CmsEntryListWhere } from \"@webiny/api-headless-cms/types\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport WebinyError from \"@webiny/error\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport type { Field } from \"./types\";\nimport { createFullTextSearch } from \"./fullTextSearch\";\nimport type { Expression, ExpressionCondition, Filter } from \"./createExpressions\";\nimport { createExpressions } from \"./createExpressions\";\nimport { transformValue } from \"./transform\";\nimport { getValue } from \"~/operations/entry/filtering/getValue\";\n\ninterface ExecuteFilterParams {\n value: any;\n filter: Filter;\n}\n\nconst executeFilter = (params: ExecuteFilterParams) => {\n const { value, filter } = params;\n\n /**\n * We need to check if the filter can be used.\n * If it cannot, we will just return true.\n */\n const canUse = filter.plugin.canUse({\n value,\n compareValue: filter.compareValue\n });\n if (!canUse) {\n return true;\n }\n\n const matched = filter.plugin.matches({\n value,\n compareValue: filter.compareValue\n });\n if (filter.negate) {\n return matched === false;\n }\n return matched;\n};\n\ninterface ExecuteExpressionsParams {\n getCachedValue: (filter: Filter) => Promise<any>;\n expressions: Expression[];\n filters: Filter[];\n condition: ExpressionCondition;\n}\n\nconst executeExpressions = (params: ExecuteExpressionsParams): boolean => {\n const { expressions, getCachedValue, filters, condition } = params;\n if (expressions.length === 0 && filters.length === 0) {\n return true;\n }\n /**\n * Always run filters first as they might trigger an early return.\n */\n for (const filter of filters) {\n const value = getCachedValue(filter);\n\n const result = executeFilter({\n value,\n filter\n });\n /**\n * Filters are ALWAYS executed as an AND.\n * So if even one is false, everything false.\n */\n if (!result) {\n return false;\n }\n }\n /**\n * Then we move onto expressions, which are basically nested upon nested filters with different conditions.\n */\n for (const expression of expressions) {\n const result = executeExpressions({\n ...expression,\n getCachedValue\n });\n if (result && condition === \"OR\") {\n return true;\n } else if (!result && condition == \"AND\") {\n return false;\n }\n }\n /**\n * If condition is an OR, we can fail the expressions check because the code would return a lot earlier than this line.\n *\n * Also, if condition is not an OR, we can say that the expressions check is ok, because it would fail a lot earlier than this line.\n */\n return condition === \"OR\" ? false : true;\n};\n\ninterface Params {\n items: CmsEntry[];\n where: Partial<CmsEntryListWhere>;\n plugins: PluginsContainer;\n fields: Record<string, Field>;\n fullTextSearch?: {\n term?: string;\n fields?: string[];\n };\n}\n\nexport const filter = (params: Params): CmsEntry[] => {\n const { items: records, where, plugins, fields, fullTextSearch } = params;\n\n const keys = Object.keys(where);\n if (keys.length === 0 && !fullTextSearch) {\n return records;\n }\n const expression = createExpressions({\n plugins,\n where,\n fields\n });\n\n /**\n * No point in going further if there are no expressions to be applied and no full text search to be executed.\n */\n if (\n expression.filters.length === 0 &&\n expression.expressions.length === 0 &&\n !fullTextSearch?.term\n ) {\n return records;\n }\n /**\n * We need the contains plugin to run the full text search.\n */\n const fullTextSearchPlugin = plugins\n .byType<ValueFilterPlugin>(ValueFilterPlugin.type)\n .find(plugin => plugin.getOperation() === \"contains\");\n if (!fullTextSearchPlugin) {\n throw new WebinyError(\n `Missing \"contains\" plugin to run the full-text search.`,\n \"MISSING_PLUGIN\"\n );\n }\n\n const search = createFullTextSearch({\n term: fullTextSearch?.term,\n targetFields: fullTextSearch?.fields,\n fields,\n plugin: fullTextSearchPlugin\n });\n\n return records.filter(record => {\n const cachedValues: Record<string, any> = {};\n\n const getCachedValue = (filter: Filter) => {\n const { path } = filter;\n if (cachedValues[path] !== undefined) {\n return cachedValues[path];\n }\n const plainValue = getValue(record, path);\n\n const rawValue = transformValue({\n value: plainValue,\n transform: filter.transformValue\n });\n\n cachedValues[path] = rawValue;\n return rawValue;\n };\n\n const exprResult = executeExpressions({ ...expression, getCachedValue });\n /**\n * If expression result is false we do not need to continue further.\n * Also, if there is no full text search defined, just return the expression result.\n */\n if (!exprResult || !search) {\n return exprResult;\n }\n\n return search(record);\n });\n};\n"],"mappings":";;;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAGA,IAAAG,eAAA,GAAAH,OAAA;AAEA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAOA,MAAMO,aAAa,GAAIC,MAA2B,IAAK;EACnD,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAGF,MAAM;;EAEhC;AACJ;AACA;AACA;EACI,MAAMG,MAAM,GAAGD,MAAM,CAACE,MAAM,CAACD,MAAM,CAAC;IAChCF,KAAK;IACLI,YAAY,EAAEH,MAAM,CAACG;EACzB,CAAC,CAAC;EACF,IAAI,CAACF,MAAM,EAAE;IACT,OAAO,IAAI;EACf;EAEA,MAAMG,OAAO,GAAGJ,MAAM,CAACE,MAAM,CAACG,OAAO,CAAC;IAClCN,KAAK;IACLI,YAAY,EAAEH,MAAM,CAACG;EACzB,CAAC,CAAC;EACF,IAAIH,MAAM,CAACM,MAAM,EAAE;IACf,OAAOF,OAAO,KAAK,KAAK;EAC5B;EACA,OAAOA,OAAO;AAClB,CAAC;AASD,MAAMG,kBAAkB,GAAIT,MAAgC,IAAc;EACtE,MAAM;IAAEU,WAAW;IAAEC,cAAc;IAAEC,OAAO;IAAEC;EAAU,CAAC,GAAGb,MAAM;EAClE,IAAIU,WAAW,CAACI,MAAM,KAAK,CAAC,IAAIF,OAAO,CAACE,MAAM,KAAK,CAAC,EAAE;IAClD,OAAO,IAAI;EACf;EACA;AACJ;AACA;EACI,KAAK,MAAMZ,MAAM,IAAIU,OAAO,EAAE;IAC1B,MAAMX,KAAK,GAAGU,cAAc,CAACT,MAAM,CAAC;IAEpC,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":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ValueFilterPlugin } from "@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin";
|
|
2
|
-
import { CmsEntry } from "@webiny/api-headless-cms/types";
|
|
3
|
-
import { Field } from "./types";
|
|
1
|
+
import type { ValueFilterPlugin } from "@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin";
|
|
2
|
+
import type { CmsEntry } from "@webiny/api-headless-cms/types";
|
|
3
|
+
import type { Field } from "./types";
|
|
4
4
|
interface Params {
|
|
5
5
|
term?: string;
|
|
6
6
|
targetFields?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createFullTextSearch","params","term","targetFields","fields","fieldDefinitions","plugin","trim","length","item","target","field","WebinyError","value","getValue","values","matches","compareValue"],"sources":["fullTextSearch.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport { CmsEntry } from \"@webiny/api-headless-cms/types\";\nimport { Field } from \"./types\";\nimport { getValue } from \"./getValue\";\n\ninterface Params {\n term?: string;\n targetFields?: string[];\n fields: Record<string, Field>;\n plugin: ValueFilterPlugin;\n}\n\n/**\n * Unfortunately we must use the contains plugin directly as plugins do not support multi field searching.\n */\nexport const createFullTextSearch = (params: Params) => {\n const { term, targetFields, fields: fieldDefinitions, plugin } = params;\n if (!term || term.trim().length === 0 || !targetFields || targetFields.length === 0) {\n return null;\n }\n return (item: CmsEntry) => {\n for (const target of targetFields) {\n /**\n * As fields is a mapped Field objects where key is a path to the value, we can directly find the related field.\n */\n const field = fieldDefinitions[target];\n\n if (!field) {\n throw new WebinyError(`Unknown field \"${target}\" in the model.`, \"UNKNOWN_FIELD\", {\n target\n });\n }\n const value = getValue(item.values, target);\n if (!value) {\n continue;\n }\n if (plugin.matches({ value, compareValue: term }) === true) {\n return true;\n }\n }\n return false;\n };\n};\n"],"mappings":";;;;;;;AAAA;AAIA;AASA;AACA;AACA;AACO,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_getValue","createFullTextSearch","params","term","targetFields","fields","fieldDefinitions","plugin","trim","length","item","target","field","WebinyError","value","getValue","values","matches","compareValue","exports"],"sources":["fullTextSearch.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport type { CmsEntry } from \"@webiny/api-headless-cms/types\";\nimport type { Field } from \"./types\";\nimport { getValue } from \"./getValue\";\n\ninterface Params {\n term?: string;\n targetFields?: string[];\n fields: Record<string, Field>;\n plugin: ValueFilterPlugin;\n}\n\n/**\n * Unfortunately we must use the contains plugin directly as plugins do not support multi field searching.\n */\nexport const createFullTextSearch = (params: Params) => {\n const { term, targetFields, fields: fieldDefinitions, plugin } = params;\n if (!term || term.trim().length === 0 || !targetFields || targetFields.length === 0) {\n return null;\n }\n return (item: CmsEntry) => {\n for (const target of targetFields) {\n /**\n * As fields is a mapped Field objects where key is a path to the value, we can directly find the related field.\n */\n const field = fieldDefinitions[target];\n\n if (!field) {\n throw new WebinyError(`Unknown field \"${target}\" in the model.`, \"UNKNOWN_FIELD\", {\n target\n });\n }\n const value = getValue(item.values, target);\n if (!value) {\n continue;\n }\n if (plugin.matches({ value, compareValue: term }) === true) {\n return true;\n }\n }\n return false;\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,SAAA,GAAAD,OAAA;AASA;AACA;AACA;AACO,MAAME,oBAAoB,GAAIC,MAAc,IAAK;EACpD,MAAM;IAAEC,IAAI;IAAEC,YAAY;IAAEC,MAAM,EAAEC,gBAAgB;IAAEC;EAAO,CAAC,GAAGL,MAAM;EACvE,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACK,IAAI,CAAC,CAAC,CAACC,MAAM,KAAK,CAAC,IAAI,CAACL,YAAY,IAAIA,YAAY,CAACK,MAAM,KAAK,CAAC,EAAE;IACjF,OAAO,IAAI;EACf;EACA,OAAQC,IAAc,IAAK;IACvB,KAAK,MAAMC,MAAM,IAAIP,YAAY,EAAE;MAC/B;AACZ;AACA;MACY,MAAMQ,KAAK,GAAGN,gBAAgB,CAACK,MAAM,CAAC;MAEtC,IAAI,CAACC,KAAK,EAAE;QACR,MAAM,IAAIC,cAAW,CAAC,kBAAkBF,MAAM,iBAAiB,EAAE,eAAe,EAAE;UAC9EA;QACJ,CAAC,CAAC;MACN;MACA,MAAMG,KAAK,GAAG,IAAAC,kBAAQ,EAACL,IAAI,CAACM,MAAM,EAAEL,MAAM,CAAC;MAC3C,IAAI,CAACG,KAAK,EAAE;QACR;MACJ;MACA,IAAIP,MAAM,CAACU,OAAO,CAAC;QAAEH,KAAK;QAAEI,YAAY,EAAEf;MAAK,CAAC,CAAC,KAAK,IAAI,EAAE;QACxD,OAAO,IAAI;MACf;IACJ;IACA,OAAO,KAAK;EAChB,CAAC;AACL,CAAC;AAACgB,OAAA,CAAAlB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -21,10 +21,11 @@ const find = (target, input) => {
|
|
|
21
21
|
const path = paths.shift();
|
|
22
22
|
if (!path) {
|
|
23
23
|
return undefined;
|
|
24
|
-
}
|
|
24
|
+
}
|
|
25
|
+
const value = target?.[path];
|
|
26
|
+
if (value === undefined) {
|
|
25
27
|
return undefined;
|
|
26
28
|
}
|
|
27
|
-
const value = target[path];
|
|
28
29
|
if (paths.length === 0) {
|
|
29
30
|
return value;
|
|
30
31
|
} else if (Array.isArray(value)) {
|
|
@@ -60,4 +61,6 @@ const getValue = (target, input) => {
|
|
|
60
61
|
}
|
|
61
62
|
return find(target, paths);
|
|
62
63
|
};
|
|
63
|
-
exports.getValue = getValue;
|
|
64
|
+
exports.getValue = getValue;
|
|
65
|
+
|
|
66
|
+
//# sourceMappingURL=getValue.js.map
|
|
@@ -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"],"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
|
|
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","exports"],"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 ${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CAACZ,IAAI,CAACJ,MAAM,CAAC;MACvB,OAAOgB,UAAU;IACrB,CAAC,EAAE,EAAE,CAAC;EACV;EACA,OAAOX,IAAI,CAACM,KAAK,EAAEJ,KAAK,CAAC;AAC7B,CAAC;AACD;AACA;AACA;AACA;AACO,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;AAACkB,OAAA,CAAAP,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { filter } from \"./filter\";\nexport { sort } from \"./sort\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA"}
|
|
1
|
+
{"version":3,"names":["_filter","require","_sort"],"sources":["index.ts"],"sourcesContent":["export { filter } from \"./filter\";\nexport { sort } from \"./sort\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Plugin, PluginsContainer } from "@webiny/plugins/types";
|
|
1
|
+
import type { Plugin, PluginsContainer } from "@webiny/plugins/types";
|
|
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 +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,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","getMappedPlugins","params","plugins","pluginsContainer","type","property","byType","length","reduce","collection","plugin","key","WebinyError","exports"],"sources":["mapPlugins.ts"],"sourcesContent":["import type { 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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAOO,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,IAAIC,cAAW,CACjB,kDAAkD,EAClD,uBAAuB,EACvB;QACIR,IAAI;QACJC;MACJ,CACJ,CAAC;IACL;IACAI,UAAU,CAACE,GAAG,CAAC,GAAGD,MAAM;IACxB,OAAOD,UAAU;EACrB,CAAC,EAAE,CAAC,CAAC,CAAC;AACV,CAAC;AAACI,OAAA,CAAAb,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin";
|
|
2
|
-
export declare const createDefaultFilterCreate: () => CmsEntryFieldFilterPlugin
|
|
2
|
+
export declare const createDefaultFilterCreate: () => CmsEntryFieldFilterPlugin<any>;
|
|
@@ -8,7 +8,7 @@ exports.createDefaultFilterCreate = void 0;
|
|
|
8
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
9
9
|
var _CmsEntryFieldFilterPlugin = require("../../../../plugins/CmsEntryFieldFilterPlugin");
|
|
10
10
|
const createDefaultFilterCreate = () => {
|
|
11
|
-
|
|
11
|
+
const plugin = new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
|
|
12
12
|
fieldType: _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin.ALL,
|
|
13
13
|
create: params => {
|
|
14
14
|
const {
|
|
@@ -37,5 +37,9 @@ const createDefaultFilterCreate = () => {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
|
+
plugin.name = `headless-cms.ddb.filter.default`;
|
|
41
|
+
return plugin;
|
|
40
42
|
};
|
|
41
|
-
exports.createDefaultFilterCreate = createDefaultFilterCreate;
|
|
43
|
+
exports.createDefaultFilterCreate = createDefaultFilterCreate;
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=defaultFilterCreate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createDefaultFilterCreate","CmsEntryFieldFilterPlugin","fieldType","ALL","create","params","negate","transformValue","field","compareValue","valueFilterPlugins","
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_CmsEntryFieldFilterPlugin","createDefaultFilterCreate","plugin","CmsEntryFieldFilterPlugin","fieldType","ALL","create","params","negate","transformValue","field","compareValue","valueFilterPlugins","operation","WebinyError","fieldPathId","parents","map","f","fieldId","join","path","createPath","name","exports"],"sources":["defaultFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin\";\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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,0BAAA,GAAAD,OAAA;AAEO,MAAME,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,MAAMC,MAAM,GAAG,IAAIC,oDAAyB,CAAC;IACzCC,SAAS,EAAED,oDAAyB,CAACE,GAAG;IACxCC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,MAAM;QAAEC,cAAc;QAAEC,KAAK;QAAEC,YAAY;QAAEC;MAAmB,CAAC,GAAGL,MAAM;MAClF,MAAML,MAAM,GAAGU,kBAAkB,CAACL,MAAM,CAACM,SAAS,CAAC;MACnD,IAAI,CAACX,MAAM,EAAE;QACT,MAAM,IAAIY,cAAW,CACjB,4CAA4CP,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;QACZI,WAAW,EAAE,CAAC,GAAGL,KAAK,CAACM,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC,EAAET,KAAK,CAACS,OAAO,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;QAC5EC,IAAI,EAAEX,KAAK,CAACY,UAAU,CAAC;UACnBZ;QACJ,CAAC,CAAC;QACFR;MACJ,CAAC;IACL;EACJ,CAAC,CAAC;EAEFA,MAAM,CAACqB,IAAI,GAAG,iCAAiC;EAE/C,OAAOrB,MAAM;AACjB,CAAC;AAACsB,OAAA,CAAAvB,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createFilterCreatePlugins: () => import("../../../..").CmsEntryFieldFilterPlugin[];
|
|
1
|
+
export declare const createFilterCreatePlugins: () => import("../../../..").CmsEntryFieldFilterPlugin<import("@webiny/api/types").GenericRecord | null | undefined>[];
|
|
@@ -7,7 +7,10 @@ exports.createFilterCreatePlugins = void 0;
|
|
|
7
7
|
var _defaultFilterCreate = require("./defaultFilterCreate");
|
|
8
8
|
var _refFilterCreate = require("./refFilterCreate");
|
|
9
9
|
var _objectFilterCreate = require("./objectFilterCreate");
|
|
10
|
+
var _searchableJsonFilterCreate = require("./searchableJsonFilterCreate");
|
|
10
11
|
const createFilterCreatePlugins = () => {
|
|
11
|
-
return [(0, _defaultFilterCreate.createDefaultFilterCreate)(), (0, _refFilterCreate.createRefFilterCreate)(), (0, _objectFilterCreate.objectFilterCreate)()];
|
|
12
|
+
return [(0, _defaultFilterCreate.createDefaultFilterCreate)(), (0, _refFilterCreate.createRefFilterCreate)(), (0, _objectFilterCreate.objectFilterCreate)(), (0, _searchableJsonFilterCreate.searchableJsonFilterCreate)()];
|
|
12
13
|
};
|
|
13
|
-
exports.createFilterCreatePlugins = createFilterCreatePlugins;
|
|
14
|
+
exports.createFilterCreatePlugins = createFilterCreatePlugins;
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +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()
|
|
1
|
+
{"version":3,"names":["_defaultFilterCreate","require","_refFilterCreate","_objectFilterCreate","_searchableJsonFilterCreate","createFilterCreatePlugins","createDefaultFilterCreate","createRefFilterCreate","objectFilterCreate","searchableJsonFilterCreate","exports"],"sources":["index.ts"],"sourcesContent":["import { createDefaultFilterCreate } from \"./defaultFilterCreate\";\nimport { createRefFilterCreate } from \"./refFilterCreate\";\nimport { objectFilterCreate } from \"./objectFilterCreate\";\nimport { searchableJsonFilterCreate } from \"./searchableJsonFilterCreate\";\n\nexport const createFilterCreatePlugins = () => {\n return [\n createDefaultFilterCreate(),\n createRefFilterCreate(),\n objectFilterCreate(),\n searchableJsonFilterCreate()\n ];\n};\n"],"mappings":";;;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,2BAAA,GAAAH,OAAA;AAEO,MAAMI,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,CACH,IAAAC,8CAAyB,EAAC,CAAC,EAC3B,IAAAC,sCAAqB,EAAC,CAAC,EACvB,IAAAC,sCAAkB,EAAC,CAAC,EACpB,IAAAC,sDAA0B,EAAC,CAAC,CAC/B;AACL,CAAC;AAACC,OAAA,CAAAL,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin";
|
|
2
|
-
export declare const objectFilterCreate: () => CmsEntryFieldFilterPlugin
|
|
2
|
+
export declare const objectFilterCreate: () => CmsEntryFieldFilterPlugin<any>;
|