@webiny/api-headless-cms-ddb 0.0.0-unstable.97a151f74d → 0.0.0-unstable.99666aeb00

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.
Files changed (140) hide show
  1. package/definitions/entry.js +6 -5
  2. package/definitions/entry.js.map +1 -1
  3. package/definitions/group.js +0 -5
  4. package/definitions/group.js.map +1 -1
  5. package/definitions/model.js +17 -5
  6. package/definitions/model.js.map +1 -1
  7. package/definitions/settings.js +0 -5
  8. package/definitions/settings.js.map +1 -1
  9. package/definitions/system.js +0 -5
  10. package/definitions/system.js.map +1 -1
  11. package/definitions/table.js +0 -3
  12. package/definitions/table.js.map +1 -1
  13. package/dynamoDb/index.js +2 -8
  14. package/dynamoDb/index.js.map +1 -1
  15. package/dynamoDb/path/locationFolderId.d.ts +2 -0
  16. package/dynamoDb/path/locationFolderId.js +41 -0
  17. package/dynamoDb/path/locationFolderId.js.map +1 -0
  18. package/dynamoDb/path/plainObject.js +1 -8
  19. package/dynamoDb/path/plainObject.js.map +1 -1
  20. package/dynamoDb/storage/date.js +3 -30
  21. package/dynamoDb/storage/date.js.map +1 -1
  22. package/dynamoDb/storage/longText.js +7 -17
  23. package/dynamoDb/storage/longText.js.map +1 -1
  24. package/dynamoDb/storage/richText.js +0 -18
  25. package/dynamoDb/storage/richText.js.map +1 -1
  26. package/dynamoDb/transformValue/datetime.js +1 -8
  27. package/dynamoDb/transformValue/datetime.js.map +1 -1
  28. package/index.js +12 -28
  29. package/index.js.map +1 -1
  30. package/operations/entry/dataLoader/DataLoaderCache.d.ts +17 -0
  31. package/operations/entry/dataLoader/DataLoaderCache.js +43 -0
  32. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  33. package/operations/entry/dataLoader/constants.d.ts +1 -0
  34. package/operations/entry/dataLoader/constants.js +9 -0
  35. package/operations/entry/dataLoader/constants.js.map +1 -0
  36. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  37. package/operations/entry/dataLoader/createBatchScheduleFn.js +23 -0
  38. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  39. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  40. package/operations/entry/dataLoader/getAllEntryRevisions.js +43 -0
  41. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  42. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  43. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +57 -0
  44. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  45. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  46. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +57 -0
  47. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  48. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  49. package/operations/entry/dataLoader/getRevisionById.js +63 -0
  50. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  51. package/operations/entry/dataLoader/index.d.ts +8 -0
  52. package/operations/entry/dataLoader/index.js +38 -0
  53. package/operations/entry/dataLoader/index.js.map +1 -0
  54. package/operations/entry/dataLoader/types.d.ts +6 -0
  55. package/operations/entry/dataLoader/types.js +5 -0
  56. package/operations/entry/dataLoader/types.js.map +1 -0
  57. package/operations/entry/dataLoaders.d.ts +11 -26
  58. package/operations/entry/dataLoaders.js +43 -249
  59. package/operations/entry/dataLoaders.js.map +1 -1
  60. package/operations/entry/filtering/{createFilters.d.ts → createExpressions.d.ts} +9 -3
  61. package/operations/entry/filtering/createExpressions.js +176 -0
  62. package/operations/entry/filtering/createExpressions.js.map +1 -0
  63. package/operations/entry/filtering/createFields.d.ts +5 -7
  64. package/operations/entry/filtering/createFields.js +73 -92
  65. package/operations/entry/filtering/createFields.js.map +1 -1
  66. package/operations/entry/filtering/extractSort.d.ts +4 -0
  67. package/operations/entry/filtering/extractSort.js +23 -11
  68. package/operations/entry/filtering/extractSort.js.map +1 -1
  69. package/operations/entry/filtering/filter.d.ts +2 -3
  70. package/operations/entry/filtering/filter.js +79 -73
  71. package/operations/entry/filtering/filter.js.map +1 -1
  72. package/operations/entry/filtering/fullTextSearch.d.ts +2 -6
  73. package/operations/entry/filtering/fullTextSearch.js +2 -18
  74. package/operations/entry/filtering/fullTextSearch.js.map +1 -1
  75. package/operations/entry/filtering/getValue.js +0 -18
  76. package/operations/entry/filtering/getValue.js.map +1 -1
  77. package/operations/entry/filtering/index.js +0 -2
  78. package/operations/entry/filtering/index.js.map +1 -1
  79. package/operations/entry/filtering/mapPlugins.js +0 -8
  80. package/operations/entry/filtering/mapPlugins.js.map +1 -1
  81. package/operations/entry/filtering/plugins/defaultFilterCreate.js +3 -8
  82. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
  83. package/operations/entry/filtering/plugins/index.d.ts +1 -1
  84. package/operations/entry/filtering/plugins/index.js +0 -5
  85. package/operations/entry/filtering/plugins/index.js.map +1 -1
  86. package/operations/entry/filtering/plugins/objectFilterCreate.js +3 -22
  87. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
  88. package/operations/entry/filtering/plugins/refFilterCreate.js +3 -19
  89. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
  90. package/operations/entry/filtering/sort.d.ts +4 -1
  91. package/operations/entry/filtering/sort.js +6 -17
  92. package/operations/entry/filtering/sort.js.map +1 -1
  93. package/operations/entry/filtering/systemFields.js +18 -2
  94. package/operations/entry/filtering/systemFields.js.map +1 -1
  95. package/operations/entry/filtering/transform.js +0 -3
  96. package/operations/entry/filtering/transform.js.map +1 -1
  97. package/operations/entry/filtering/values.d.ts +2 -0
  98. package/operations/entry/filtering/values.js +22 -0
  99. package/operations/entry/filtering/values.js.map +1 -0
  100. package/operations/entry/filtering/where.js +3 -8
  101. package/operations/entry/filtering/where.js.map +1 -1
  102. package/operations/entry/index.d.ts +1 -1
  103. package/operations/entry/index.js +189 -130
  104. package/operations/entry/index.js.map +1 -1
  105. package/operations/entry/keys.js +0 -18
  106. package/operations/entry/keys.js.map +1 -1
  107. package/operations/group/index.js +2 -32
  108. package/operations/group/index.js.map +1 -1
  109. package/operations/model/index.js +0 -25
  110. package/operations/model/index.js.map +1 -1
  111. package/operations/settings/index.js +0 -24
  112. package/operations/settings/index.js.map +1 -1
  113. package/operations/system/index.js +0 -17
  114. package/operations/system/index.js.map +1 -1
  115. package/package.json +21 -21
  116. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +2 -1
  117. package/plugins/CmsEntryFieldFilterPathPlugin.js +3 -15
  118. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
  119. package/plugins/CmsEntryFieldFilterPlugin.js +0 -7
  120. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
  121. package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
  122. package/plugins/CmsEntryFieldSortingPlugin.js +28 -0
  123. package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
  124. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
  125. package/plugins/CmsFieldFilterValueTransformPlugin.js +24 -0
  126. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
  127. package/plugins/index.d.ts +3 -0
  128. package/plugins/index.js +33 -2
  129. package/plugins/index.js.map +1 -1
  130. package/types.d.ts +10 -1
  131. package/types.js +0 -1
  132. package/types.js.map +1 -1
  133. package/operations/entry/filtering/createFilters.js +0 -155
  134. package/operations/entry/filtering/createFilters.js.map +0 -1
  135. package/operations/entry/systemFields.d.ts +0 -2
  136. package/operations/entry/systemFields.js +0 -74
  137. package/operations/entry/systemFields.js.map +0 -1
  138. package/operations/entry/utils.d.ts +0 -36
  139. package/operations/entry/utils.js +0 -684
  140. package/operations/entry/utils.js.map +0 -1
@@ -1,29 +1,79 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createFields = void 0;
9
-
10
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
9
  var _systemFields = require("./systemFields");
13
-
14
10
  var _plugins = require("../../../plugins");
15
-
16
11
  var _mapPlugins = require("./mapPlugins");
17
-
12
+ const createFieldCollection = params => {
13
+ const {
14
+ fields,
15
+ parents,
16
+ transformValuePlugins,
17
+ valuePathPlugins,
18
+ system
19
+ } = params;
20
+ return fields.reduce((collection, field) => {
21
+ var _field$settings;
22
+ const transformPlugin = transformValuePlugins[field.type];
23
+ const valuePathPlugin = valuePathPlugins[field.type];
24
+ const basePath = system ? [] : ["values"];
25
+ /**
26
+ * The required fieldId is a product of all of its parents and its own fieldId.
27
+ */
28
+ const fieldId = [...parents, {
29
+ fieldId: field.fieldId,
30
+ multipleValues: field.multipleValues
31
+ }].map(f => f.fieldId).join(".");
32
+ collection[fieldId] = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, field), {}, {
33
+ parents,
34
+ system,
35
+ createPath: params => {
36
+ if (valuePathPlugin && valuePathPlugin.canUse(field, parents.map(p => p.fieldId))) {
37
+ return valuePathPlugin.createPath(params);
38
+ }
39
+ return basePath.concat(parents.map(parent => parent.fieldId)).concat([params.field.fieldId]).join(".");
40
+ },
41
+ transform: value => {
42
+ if (!transformPlugin) {
43
+ return value;
44
+ }
45
+ return transformPlugin.transform({
46
+ field,
47
+ value
48
+ });
49
+ }
50
+ });
51
+ const childFields = (_field$settings = field.settings) === null || _field$settings === void 0 ? void 0 : _field$settings.fields;
52
+ if (!(childFields !== null && childFields !== void 0 && childFields.length)) {
53
+ return collection;
54
+ }
55
+ const result = createFieldCollection({
56
+ fields: childFields,
57
+ parents: [...parents, {
58
+ fieldId: field.fieldId,
59
+ multipleValues: field.multipleValues
60
+ }],
61
+ transformValuePlugins,
62
+ valuePathPlugins,
63
+ system
64
+ });
65
+ Object.assign(collection, result);
66
+ return collection;
67
+ }, {});
68
+ };
18
69
  /**
19
70
  * This method will map the fieldId (fieldId -> field) to the actual field.
20
71
  *
21
72
  * In case of nested fields, fieldId is all the parent fieldIds + current one, joined by the dot (.).
22
- * @param params
23
73
  */
24
74
  const createFields = params => {
25
75
  const {
26
- model,
76
+ fields,
27
77
  plugins
28
78
  } = params;
29
79
  const transformValuePlugins = (0, _mapPlugins.getMappedPlugins)({
@@ -36,89 +86,20 @@ const createFields = params => {
36
86
  type: _plugins.CmsEntryFieldFilterPathPlugin.type,
37
87
  property: "fieldType"
38
88
  });
39
- const collection = (0, _systemFields.createSystemFields)().reduce((fields, field) => {
40
- const transformPlugin = transformValuePlugins[field.type];
41
- fields[field.fieldId] = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, field), {}, {
42
- parents: [],
43
- system: true,
44
- createPath: ({
45
- field
46
- }) => {
47
- var _field$settings;
48
-
49
- return ((_field$settings = field.settings) === null || _field$settings === void 0 ? void 0 : _field$settings.path) || field.fieldId;
50
- },
51
- transform: value => {
52
- if (!transformPlugin) {
53
- return value;
54
- }
55
-
56
- return transformPlugin.transform({
57
- field,
58
- value
59
- });
60
- }
61
- });
62
- return fields;
63
- }, {});
64
-
65
- const addFieldsToCollection = (fields, parents = []) => {
66
- /**
67
- * Exit early if no fields are sent.
68
- */
69
- if (fields.length === 0) {
70
- return;
71
- }
72
-
73
- for (const field of fields) {
74
- var _field$settings2;
75
-
76
- const transformPlugin = transformValuePlugins[field.type];
77
- const valuePathPlugin = valuePathPlugins[field.type];
78
- /**
79
- * The required fieldId is a product of all of its parents and its own fieldId.
80
- */
81
-
82
- const fieldId = [...parents, {
83
- fieldId: field.fieldId,
84
- multipleValues: field.multipleValues
85
- }].map(f => f.fieldId).join(".");
86
- collection[fieldId] = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, field), {}, {
87
- parents,
88
- system: false,
89
- createPath: params => {
90
- if (valuePathPlugin) {
91
- return valuePathPlugin.createPath(params);
92
- }
93
-
94
- return ["values"].concat(parents.map(parent => parent.fieldId)).concat([params.field.fieldId]).join(".");
95
- },
96
- transform: value => {
97
- if (!transformPlugin) {
98
- return value;
99
- }
100
-
101
- return transformPlugin.transform({
102
- field,
103
- value
104
- });
105
- }
106
- });
107
- const childFields = (_field$settings2 = field.settings) === null || _field$settings2 === void 0 ? void 0 : _field$settings2.fields;
108
-
109
- if (!childFields || childFields.length === 0) {
110
- continue;
111
- }
112
-
113
- addFieldsToCollection(childFields, [...parents, {
114
- fieldId: field.fieldId,
115
- multipleValues: field.multipleValues
116
- }]);
117
- }
118
- };
119
-
120
- addFieldsToCollection(model.fields);
121
- return collection;
89
+ const collection = createFieldCollection({
90
+ fields: (0, _systemFields.createSystemFields)(),
91
+ transformValuePlugins,
92
+ valuePathPlugins,
93
+ parents: [],
94
+ system: true
95
+ });
96
+ const result = createFieldCollection({
97
+ fields,
98
+ transformValuePlugins,
99
+ valuePathPlugins,
100
+ parents: [],
101
+ system: false
102
+ });
103
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, collection), result);
122
104
  };
123
-
124
105
  exports.createFields = createFields;
@@ -1 +1 @@
1
- {"version":3,"names":["createFields","params","model","plugins","transformValuePlugins","getMappedPlugins","type","property","valuePathPlugins","CmsEntryFieldFilterPathPlugin","collection","createSystemFields","reduce","fields","field","transformPlugin","fieldId","parents","system","createPath","settings","path","transform","value","addFieldsToCollection","length","valuePathPlugin","multipleValues","map","f","join","concat","parent","childFields"],"sources":["createFields.ts"],"sourcesContent":["import { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { createSystemFields } from \"./systemFields\";\nimport { Field, FieldParent } from \"./types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsFieldFilterValueTransformPlugin } from \"~/types\";\nimport { CmsEntryFieldFilterPathPlugin } from \"~/plugins\";\nimport { getMappedPlugins } from \"./mapPlugins\";\n\ninterface Params {\n model: CmsModel;\n plugins: PluginsContainer;\n}\n\ninterface Fields {\n [key: string]: Field;\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 * @param params\n */\nexport const createFields = (params: Params) => {\n const { model, 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 = createSystemFields().reduce<Fields>((fields, field) => {\n const transformPlugin = transformValuePlugins[field.type];\n\n fields[field.fieldId] = {\n ...field,\n parents: [],\n system: true,\n createPath: ({ field }) => {\n return field.settings?.path || field.fieldId;\n },\n transform: value => {\n if (!transformPlugin) {\n return value;\n }\n return transformPlugin.transform({\n field,\n value\n });\n }\n };\n\n return fields;\n }, {});\n\n const addFieldsToCollection = (fields: CmsModelField[], parents: FieldParent[] = []): void => {\n /**\n * Exit early if no fields are sent.\n */\n if (fields.length === 0) {\n return;\n }\n for (const field of fields) {\n const transformPlugin = transformValuePlugins[field.type];\n const valuePathPlugin = valuePathPlugins[field.type];\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: false,\n createPath: params => {\n if (valuePathPlugin) {\n return valuePathPlugin.createPath(params);\n }\n\n return [\"values\"]\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 || childFields.length === 0) {\n continue;\n }\n addFieldsToCollection(childFields, [\n ...parents,\n {\n fieldId: field.fieldId,\n multipleValues: field.multipleValues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AZ,KAAuB,CAA3C,EAA8C;QAC1C;MACH;;MACDD,qBAAqB,CAACS,WAAD,EAAc,CAC/B,GAAGhB,OAD4B,EAE/B;QACID,OAAO,EAAEF,KAAK,CAACE,OADnB;QAEIW,cAAc,EAAEb,KAAK,CAACa;MAF1B,CAF+B,CAAd,CAArB;IAOH;EACJ,CA3DD;;EA6DAH,qBAAqB,CAACtB,KAAK,CAACW,MAAP,CAArB;EAEA,OAAOH,UAAP;AACH,CAtGM"}
1
+ {"version":3,"names":["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"],"sources":["createFields.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { createSystemFields } from \"./systemFields\";\nimport { Field, FieldParent } from \"./types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { 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;AAIA;AACA;AAmBA,MAAMA,qBAAqB,GAAIC,MAAmC,IAAsB;EACpF,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC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AAM;IACNE,qBAAqB;IACrBC,gBAAgB;IAChBF,OAAO,EAAE,EAAE;IACXG,MAAM,EAAE;EACZ,CAAC,CAAC;EAEF,mEACOE,UAAU,GACVqB,MAAM;AAEjB,CAAC;AAAC"}
@@ -1,4 +1,6 @@
1
1
  import { Field } from "./types";
2
+ import { PluginsContainer } from "@webiny/plugins";
3
+ import { CmsModel } from "@webiny/api-headless-cms/types";
2
4
  interface Result {
3
5
  valuePath: string;
4
6
  reverse: boolean;
@@ -6,8 +8,10 @@ interface Result {
6
8
  field: Field;
7
9
  }
8
10
  interface Params {
11
+ model: CmsModel;
9
12
  sortBy: string;
10
13
  fields: Record<string, Field>;
14
+ plugins: PluginsContainer;
11
15
  }
12
16
  export declare const extractSort: (params: Params) => Result;
13
17
  export {};
@@ -1,27 +1,25 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.extractSort = void 0;
9
-
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
9
+ var _plugins = require("../../../plugins");
12
10
  const extractSort = params => {
13
11
  const {
12
+ model,
14
13
  sortBy,
15
- fields
14
+ fields,
15
+ plugins
16
16
  } = params;
17
17
  const result = sortBy.split("_");
18
-
19
18
  if (result.length !== 2) {
20
19
  throw new _error.default("Problem in determining the sorting for the entry items.", "SORT_EXTRACT_ERROR", {
21
20
  sortBy
22
21
  });
23
22
  }
24
-
25
23
  const [fieldId, order] = result;
26
24
  const field = Object.values(fields).find(field => {
27
25
  /**
@@ -30,17 +28,32 @@ const extractSort = params => {
30
28
  if (field.parents.length > 0) {
31
29
  return false;
32
30
  }
33
-
34
31
  return field.fieldId === fieldId;
35
32
  });
36
-
37
- if (!field) {
33
+ const plugin = plugins.byType(_plugins.CmsEntryFieldSortingPlugin.type).reverse().find(plugin => {
34
+ return plugin.canUse({
35
+ model,
36
+ field,
37
+ fieldId,
38
+ order,
39
+ sortBy
40
+ });
41
+ });
42
+ if (plugin) {
43
+ return plugin.createSort({
44
+ model,
45
+ fieldId,
46
+ order,
47
+ sortBy,
48
+ field,
49
+ fields
50
+ });
51
+ } else if (!field) {
38
52
  throw new _error.default("Sorting field does not exist in the content model.", "SORTING_FIELD_ERROR", {
39
53
  fieldId,
40
54
  fields
41
55
  });
42
56
  }
43
-
44
57
  const valuePath = field.createPath({
45
58
  field
46
59
  });
@@ -51,5 +64,4 @@ const extractSort = params => {
51
64
  reverse: order === "DESC"
52
65
  };
53
66
  };
54
-
55
67
  exports.extractSort = extractSort;
@@ -1 +1 @@
1
- {"version":3,"names":["extractSort","params","sortBy","fields","result","split","length","WebinyError","fieldId","order","field","Object","values","find","parents","valuePath","createPath","reverse"],"sources":["extractSort.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Field } from \"./types\";\n\ninterface Result {\n valuePath: string;\n reverse: boolean;\n fieldId: string;\n field: Field;\n}\n\ninterface Params {\n sortBy: string;\n fields: Record<string, Field>;\n}\n\nexport const extractSort = (params: Params): Result => {\n const { sortBy, fields } = 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;\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 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;;AAeO,MAAMA,WAAW,GAAIC,MAAD,IAA4B;EACnD,MAAM;IAAEC,MAAF;IAAUC;EAAV,IAAqBF,MAA3B;EACA,MAAMG,MAAM,GAAGF,MAAM,CAACG,KAAP,CAAa,GAAb,CAAf;;EACA,IAAID,MAAM,CAACE,MAAP,KAAkB,CAAtB,EAAyB;IACrB,MAAM,IAAIC,cAAJ,CACF,yDADE,EAEF,oBAFE,EAGF;MACIL;IADJ,CAHE,CAAN;EAOH;;EACD,MAAM,CAACM,OAAD,EAAUC,KAAV,IAAmBL,MAAzB;EAEA,MAAMM,KAAK,GAAGC,MAAM,CAACC,MAAP,CAAcT,MAAd,EAAsBU,IAAtB,CAA2BH,KAAK,IAAI;IAC9C;AACR;AACA;IACQ,IAAIA,KAAK,CAACI,OAAN,CAAcR,MAAd,GAAuB,CAA3B,EAA8B;MAC1B,OAAO,KAAP;IACH;;IACD,OAAOI,KAAK,CAACF,OAAN,KAAkBA,OAAzB;EACH,CARa,CAAd;;EAUA,IAAI,CAACE,KAAL,EAAY;IACR,MAAM,IAAIH,cAAJ,CACF,oDADE,EAEF,qBAFE,EAGF;MACIC,OADJ;MAEIL;IAFJ,CAHE,CAAN;EAQH;;EACD,MAAMY,SAAS,GAAGL,KAAK,CAACM,UAAN,CAAiB;IAC/BN;EAD+B,CAAjB,CAAlB;EAGA,OAAO;IACHA,KADG;IAEHF,OAFG;IAGHO,SAHG;IAIHE,OAAO,EAAER,KAAK,KAAK;EAJhB,CAAP;AAMH,CA3CM"}
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,MAAMA,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,CAAC,CACJ;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,EAAE,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,CAAC,CACJ;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;AAAC"}
@@ -1,16 +1,15 @@
1
1
  import { CmsEntry, CmsEntryListWhere } from "@webiny/api-headless-cms/types";
2
2
  import { PluginsContainer } from "@webiny/plugins";
3
- import { Field, FilterItemFromStorage } from "./types";
3
+ import { Field } from "./types";
4
4
  interface Params {
5
5
  items: CmsEntry[];
6
6
  where: Partial<CmsEntryListWhere>;
7
7
  plugins: PluginsContainer;
8
8
  fields: Record<string, Field>;
9
- fromStorage: FilterItemFromStorage;
10
9
  fullTextSearch?: {
11
10
  term?: string;
12
11
  fields?: string[];
13
12
  };
14
13
  }
15
- export declare const filter: (params: Params) => Promise<CmsEntry[]>;
14
+ export declare const filter: (params: Params) => CmsEntry[];
16
15
  export {};
@@ -1,137 +1,143 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.filter = void 0;
9
-
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
9
  var _ValueFilterPlugin = require("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin");
11
-
12
10
  var _error = _interopRequireDefault(require("@webiny/error"));
13
-
14
11
  var _fullTextSearch = require("./fullTextSearch");
15
-
16
- var _createFilters = require("./createFilters");
17
-
12
+ var _createExpressions = require("./createExpressions");
18
13
  var _transform = require("./transform");
19
-
20
14
  var _getValue = require("./getValue");
21
-
22
- const execFilter = params => {
15
+ const executeFilter = params => {
23
16
  const {
24
- value: plainValue,
17
+ value,
25
18
  filter
26
19
  } = params;
27
- const value = (0, _transform.transformValue)({
28
- value: plainValue,
29
- transform: filter.transformValue
30
- });
31
20
  const matched = filter.plugin.matches({
32
21
  value,
33
22
  compareValue: filter.compareValue
34
23
  });
35
-
36
24
  if (filter.negate) {
37
25
  return matched === false;
38
26
  }
39
-
40
27
  return matched;
41
28
  };
42
-
43
- const filter = async params => {
29
+ const executeExpressions = params => {
30
+ const {
31
+ expressions,
32
+ getCachedValue,
33
+ filters,
34
+ condition
35
+ } = params;
36
+ if (expressions.length === 0 && filters.length === 0) {
37
+ return true;
38
+ }
39
+ /**
40
+ * Always run filters first as they might trigger an early return.
41
+ */
42
+ for (const filter of filters) {
43
+ const value = getCachedValue(filter);
44
+ const result = executeFilter({
45
+ value,
46
+ filter
47
+ });
48
+ /**
49
+ * Filters are ALWAYS executed as an AND.
50
+ * So if even one is false, everything false.
51
+ */
52
+ if (!result) {
53
+ return false;
54
+ }
55
+ }
56
+ /**
57
+ * Then we move onto expressions, which are basically nested upon nested filters with different conditions.
58
+ */
59
+ for (const expression of expressions) {
60
+ const result = executeExpressions((0, _objectSpread2.default)((0, _objectSpread2.default)({}, expression), {}, {
61
+ getCachedValue
62
+ }));
63
+ if (result && condition === "OR") {
64
+ return true;
65
+ } else if (!result && condition == "AND") {
66
+ return false;
67
+ }
68
+ }
69
+ /**
70
+ * If condition is an OR, we can fail the expressions check because the code would return a lot earlier than this line.
71
+ *
72
+ * 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.
73
+ */
74
+ return condition === "OR" ? false : true;
75
+ };
76
+ const filter = params => {
44
77
  const {
45
78
  items: records,
46
79
  where,
47
80
  plugins,
48
81
  fields,
49
- fromStorage,
50
82
  fullTextSearch
51
83
  } = params;
52
84
  const keys = Object.keys(where);
53
-
54
85
  if (keys.length === 0 && !fullTextSearch) {
55
86
  return records;
56
87
  }
57
-
58
- const filters = (0, _createFilters.createFilters)({
88
+ const expression = (0, _createExpressions.createExpressions)({
59
89
  plugins,
60
90
  where,
61
91
  fields
62
92
  });
93
+
63
94
  /**
64
- * No point in going further if there are no filters to be applied and no full text search to be executed.
95
+ * No point in going further if there are no expressions to be applied and no full text search to be executed.
65
96
  */
66
-
67
- if (filters.length === 0 && !fullTextSearch) {
97
+ if (expression.filters.length === 0 && expression.expressions.length === 0 && !(fullTextSearch !== null && fullTextSearch !== void 0 && fullTextSearch.term)) {
68
98
  return records;
69
99
  }
70
100
  /**
71
101
  * We need the contains plugin to run the full text search.
72
- * TODO check out to maybe implement fuzzy search.
73
102
  */
74
-
75
-
76
103
  const fullTextSearchPlugin = plugins.byType(_ValueFilterPlugin.ValueFilterPlugin.type).find(plugin => plugin.getOperation() === "contains");
77
-
78
104
  if (!fullTextSearchPlugin) {
79
105
  throw new _error.default(`Missing "contains" plugin to run the full-text search.`, "MISSING_PLUGIN");
80
106
  }
81
-
82
107
  const search = (0, _fullTextSearch.createFullTextSearch)({
83
108
  term: fullTextSearch === null || fullTextSearch === void 0 ? void 0 : fullTextSearch.term,
84
109
  targetFields: fullTextSearch === null || fullTextSearch === void 0 ? void 0 : fullTextSearch.fields,
85
110
  fields,
86
- fromStorage,
87
111
  plugin: fullTextSearchPlugin
88
112
  });
89
- const promises = records.map(async record => {
90
- /**
91
- * We need to go through all the filters and apply them to the given record.
92
- */
93
- for (const filter of filters) {
94
- const rawValue = (0, _getValue.getValue)(record, filter.path);
95
- const field = fields[filter.fieldPathId];
96
- const plainValue = await fromStorage(field, rawValue);
97
- const result = execFilter({
113
+ return records.filter(record => {
114
+ const cachedValues = {};
115
+ const getCachedValue = filter => {
116
+ const {
117
+ path
118
+ } = filter;
119
+ if (cachedValues[path] !== undefined) {
120
+ return cachedValues[path];
121
+ }
122
+ const plainValue = (0, _getValue.getValue)(record, path);
123
+ const rawValue = (0, _transform.transformValue)({
98
124
  value: plainValue,
99
- filter
125
+ transform: filter.transformValue
100
126
  });
101
-
102
- if (result === false) {
103
- return null;
104
- }
105
- }
127
+ cachedValues[path] = rawValue;
128
+ return rawValue;
129
+ };
130
+ const exprResult = executeExpressions((0, _objectSpread2.default)((0, _objectSpread2.default)({}, expression), {}, {
131
+ getCachedValue
132
+ }));
106
133
  /**
107
- * If we have full text search defined, run it. Just return the given record if not full text search.
134
+ * If expression result is false we do not need to continue further.
135
+ * Also, if there is no full text search defined, just return the expression result.
108
136
  */
109
-
110
-
111
- if (!search) {
112
- return record;
113
- }
114
-
115
- const result = await search({
116
- item: record
117
- });
118
-
119
- if (!result) {
120
- return null;
137
+ if (!exprResult || !search) {
138
+ return exprResult;
121
139
  }
122
-
123
- return record;
140
+ return search(record);
124
141
  });
125
- /**
126
- * We run filtering as promises, so it is a bit faster than in for ... of loop.
127
- */
128
-
129
- const results = await Promise.all(promises);
130
- /**
131
- * And filter out the null values which are returned when filter is not satisfied.
132
- */
133
-
134
- return results.filter(Boolean);
135
142
  };
136
-
137
143
  exports.filter = filter;
@@ -1 +1 @@
1
- {"version":3,"names":["execFilter","params","value","plainValue","filter","transformValue","transform","matched","plugin","matches","compareValue","negate","items","records","where","plugins","fields","fromStorage","fullTextSearch","keys","Object","length","filters","createFilters","fullTextSearchPlugin","byType","ValueFilterPlugin","type","find","getOperation","WebinyError","search","createFullTextSearch","term","targetFields","promises","map","record","rawValue","getValue","path","field","fieldPathId","result","item","results","Promise","all","Boolean"],"sources":["filter.ts"],"sourcesContent":["import { CmsEntry, CmsEntryListWhere } from \"@webiny/api-headless-cms/types\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport WebinyError from \"@webiny/error\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { Field, FilterItemFromStorage } from \"./types\";\nimport { createFullTextSearch } from \"./fullTextSearch\";\nimport { createFilters, ItemFilter } from \"./createFilters\";\nimport { transformValue } from \"./transform\";\nimport { getValue } from \"~/operations/entry/filtering/getValue\";\n\ninterface ExecFilterParams {\n value: any;\n filter: ItemFilter;\n}\nconst execFilter = (params: ExecFilterParams) => {\n const { value: plainValue, filter } = params;\n\n const value = transformValue({\n value: plainValue,\n transform: filter.transformValue\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 Params {\n items: CmsEntry[];\n where: Partial<CmsEntryListWhere>;\n plugins: PluginsContainer;\n fields: Record<string, Field>;\n fromStorage: FilterItemFromStorage;\n fullTextSearch?: {\n term?: string;\n fields?: string[];\n };\n}\n\nexport const filter = async (params: Params): Promise<CmsEntry[]> => {\n const { items: records, where, plugins, fields, fromStorage, fullTextSearch } = params;\n\n const keys = Object.keys(where);\n if (keys.length === 0 && !fullTextSearch) {\n return records;\n }\n const filters = createFilters({\n plugins,\n where,\n fields\n });\n\n /**\n * No point in going further if there are no filters to be applied and no full text search to be executed.\n */\n if (filters.length === 0 && !fullTextSearch) {\n return records;\n }\n /**\n * We need the contains plugin to run the full text search.\n * TODO check out to maybe implement fuzzy 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 fromStorage,\n plugin: fullTextSearchPlugin\n });\n\n const promises: Promise<CmsEntry | null>[] = records.map(async record => {\n /**\n * We need to go through all the filters and apply them to the given record.\n */\n for (const filter of filters) {\n const rawValue = getValue(record, filter.path);\n\n const field = fields[filter.fieldPathId];\n const plainValue = await fromStorage(field, rawValue);\n\n const result = execFilter({\n value: plainValue,\n filter\n });\n if (result === false) {\n return null;\n }\n }\n /**\n * If we have full text search defined, run it. Just return the given record if not full text search.\n */\n if (!search) {\n return record;\n }\n const result = await search({\n item: record\n });\n if (!result) {\n return null;\n }\n\n return record;\n });\n\n /**\n * We run filtering as promises, so it is a bit faster than in for ... of loop.\n */\n const results: (CmsEntry | null)[] = await Promise.all(promises);\n\n /**\n * And filter out the null values which are returned when filter is not satisfied.\n */\n return results.filter(Boolean) as CmsEntry[];\n};\n"],"mappings":";;;;;;;;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AAMA,MAAMA,UAAU,GAAIC,MAAD,IAA8B;EAC7C,MAAM;IAAEC,KAAK,EAAEC,UAAT;IAAqBC;EAArB,IAAgCH,MAAtC;EAEA,MAAMC,KAAK,GAAG,IAAAG,yBAAA,EAAe;IACzBH,KAAK,EAAEC,UADkB;IAEzBG,SAAS,EAAEF,MAAM,CAACC;EAFO,CAAf,CAAd;EAIA,MAAME,OAAO,GAAGH,MAAM,CAACI,MAAP,CAAcC,OAAd,CAAsB;IAClCP,KADkC;IAElCQ,YAAY,EAAEN,MAAM,CAACM;EAFa,CAAtB,CAAh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OAAO,CAACuB,GAAR,CAAY,MAAMC,MAAN,IAAgB;IACrE;AACR;AACA;IACQ,KAAK,MAAMjC,MAAX,IAAqBkB,OAArB,EAA8B;MAC1B,MAAMgB,QAAQ,GAAG,IAAAC,kBAAA,EAASF,MAAT,EAAiBjC,MAAM,CAACoC,IAAxB,CAAjB;MAEA,MAAMC,KAAK,GAAGzB,MAAM,CAACZ,MAAM,CAACsC,WAAR,CAApB;MACA,MAAMvC,UAAU,GAAG,MAAMc,WAAW,CAACwB,KAAD,EAAQH,QAAR,CAApC;MAEA,MAAMK,MAAM,GAAG3C,UAAU,CAAC;QACtBE,KAAK,EAAEC,UADe;QAEtBC;MAFsB,CAAD,CAAzB;;MAIA,IAAIuC,MAAM,KAAK,KAAf,EAAsB;QAClB,OAAO,IAAP;MACH;IACJ;IACD;AACR;AACA;;;IACQ,IAAI,CAACZ,MAAL,EAAa;MACT,OAAOM,MAAP;IACH;;IACD,MAAMM,MAAM,GAAG,MAAMZ,MAAM,CAAC;MACxBa,IAAI,EAAEP;IADkB,CAAD,CAA3B;;IAGA,IAAI,CAACM,MAAL,EAAa;MACT,OAAO,IAAP;IACH;;IAED,OAAON,MAAP;EACH,CAhC4C,CAA7C;EAkCA;AACJ;AACA;;EACI,MAAMQ,OAA4B,GAAG,MAAMC,OAAO,CAACC,GAAR,CAAYZ,QAAZ,CAA3C;EAEA;AACJ;AACA;;EACI,OAAOU,OAAO,CAACzC,MAAR,CAAe4C,OAAf,CAAP;AACH,CApFM"}
1
+ {"version":3,"names":["executeFilter","params","value","filter","matched","plugin","matches","compareValue","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"],"sources":["filter.ts"],"sourcesContent":["import { CmsEntry, CmsEntryListWhere } from \"@webiny/api-headless-cms/types\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport WebinyError from \"@webiny/error\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { Field } from \"./types\";\nimport { createFullTextSearch } from \"./fullTextSearch\";\nimport { createExpressions, Expression, ExpressionCondition, Filter } 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 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;AACA;AAGA;AACA;AACA;AACA;AAOA,MAAMA,aAAa,GAAIC,MAA2B,IAAK;EACnD,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAEhC,MAAMG,OAAO,GAAGD,MAAM,CAACE,MAAM,CAACC,OAAO,CAAC;IAClCJ,KAAK;IACLK,YAAY,EAAEJ,MAAM,CAACI;EACzB,CAAC,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