@webiny/api-headless-cms-ddb 0.0.0-unstable.aa00eecd97 → 0.0.0-unstable.ac6ebf63c6

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 (167) hide show
  1. package/README.md +6 -20
  2. package/definitions/entry.d.ts +4 -5
  3. package/definitions/entry.js +7 -88
  4. package/definitions/entry.js.map +1 -1
  5. package/definitions/group.d.ts +4 -5
  6. package/definitions/group.js +7 -59
  7. package/definitions/group.js.map +1 -1
  8. package/definitions/model.d.ts +4 -5
  9. package/definitions/model.js +7 -103
  10. package/definitions/model.js.map +1 -1
  11. package/definitions/table.d.ts +4 -6
  12. package/definitions/table.js +8 -26
  13. package/definitions/table.js.map +1 -1
  14. package/definitions/types.d.ts +59 -0
  15. package/definitions/types.js +3 -0
  16. package/definitions/types.js.map +1 -0
  17. package/dynamoDb/index.d.ts +1 -1
  18. package/dynamoDb/index.js +7 -12
  19. package/dynamoDb/index.js.map +1 -1
  20. package/dynamoDb/path/locationFolderId.d.ts +2 -0
  21. package/dynamoDb/path/locationFolderId.js +34 -0
  22. package/dynamoDb/path/locationFolderId.js.map +1 -0
  23. package/dynamoDb/path/plainObject.d.ts +1 -1
  24. package/dynamoDb/path/plainObject.js +7 -14
  25. package/dynamoDb/path/plainObject.js.map +1 -1
  26. package/dynamoDb/storage/longText.js +13 -18
  27. package/dynamoDb/storage/longText.js.map +1 -1
  28. package/dynamoDb/storage/richText.js +28 -71
  29. package/dynamoDb/storage/richText.js.map +1 -1
  30. package/dynamoDb/transformValue/datetime.d.ts +1 -1
  31. package/dynamoDb/transformValue/datetime.js +7 -12
  32. package/dynamoDb/transformValue/datetime.js.map +1 -1
  33. package/index.d.ts +2 -2
  34. package/index.js +40 -82
  35. package/index.js.map +1 -1
  36. package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -3
  37. package/operations/entry/dataLoader/DataLoaderCache.js +8 -17
  38. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  39. package/operations/entry/dataLoader/constants.js +3 -8
  40. package/operations/entry/dataLoader/constants.js.map +1 -1
  41. package/operations/entry/dataLoader/createBatchScheduleFn.js +6 -10
  42. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
  43. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
  44. package/operations/entry/dataLoader/getAllEntryRevisions.js +13 -24
  45. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  46. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
  47. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +24 -35
  48. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  49. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
  50. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +24 -35
  51. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  52. package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
  53. package/operations/entry/dataLoader/getRevisionById.js +26 -37
  54. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  55. package/operations/entry/dataLoader/index.d.ts +5 -5
  56. package/operations/entry/dataLoader/index.js +12 -31
  57. package/operations/entry/dataLoader/index.js.map +1 -1
  58. package/operations/entry/dataLoader/types.d.ts +3 -4
  59. package/operations/entry/dataLoader/types.js +2 -4
  60. package/operations/entry/dataLoader/types.js.map +1 -1
  61. package/operations/entry/dataLoaders.d.ts +11 -12
  62. package/operations/entry/dataLoaders.js +25 -34
  63. package/operations/entry/dataLoaders.js.map +1 -1
  64. package/operations/entry/filtering/createExpressions.d.ts +5 -5
  65. package/operations/entry/filtering/createExpressions.js +29 -30
  66. package/operations/entry/filtering/createExpressions.js.map +1 -1
  67. package/operations/entry/filtering/createFields.d.ts +6 -4
  68. package/operations/entry/filtering/createFields.js +87 -86
  69. package/operations/entry/filtering/createFields.js.map +1 -1
  70. package/operations/entry/filtering/extractSort.d.ts +6 -6
  71. package/operations/entry/filtering/extractSort.js +40 -23
  72. package/operations/entry/filtering/extractSort.js.map +1 -1
  73. package/operations/entry/filtering/filter.d.ts +6 -6
  74. package/operations/entry/filtering/filter.js +36 -29
  75. package/operations/entry/filtering/filter.js.map +1 -1
  76. package/operations/entry/filtering/fullTextSearch.d.ts +3 -3
  77. package/operations/entry/filtering/fullTextSearch.js +8 -14
  78. package/operations/entry/filtering/fullTextSearch.js.map +1 -1
  79. package/operations/entry/filtering/getValue.js +6 -10
  80. package/operations/entry/filtering/getValue.js.map +1 -1
  81. package/operations/entry/filtering/index.d.ts +2 -2
  82. package/operations/entry/filtering/index.js +3 -18
  83. package/operations/entry/filtering/index.js.map +1 -1
  84. package/operations/entry/filtering/mapPlugins.d.ts +2 -2
  85. package/operations/entry/filtering/mapPlugins.js +5 -11
  86. package/operations/entry/filtering/mapPlugins.js.map +1 -1
  87. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +2 -2
  88. package/operations/entry/filtering/plugins/defaultFilterCreate.js +10 -14
  89. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
  90. package/operations/entry/filtering/plugins/index.d.ts +1 -1
  91. package/operations/entry/filtering/plugins/index.js +8 -12
  92. package/operations/entry/filtering/plugins/index.js.map +1 -1
  93. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +2 -2
  94. package/operations/entry/filtering/plugins/objectFilterCreate.js +17 -19
  95. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
  96. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +3 -2
  97. package/operations/entry/filtering/plugins/refFilterCreate.js +22 -19
  98. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
  99. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +2 -0
  100. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +57 -0
  101. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -0
  102. package/operations/entry/filtering/sort.d.ts +6 -6
  103. package/operations/entry/filtering/sort.js +18 -20
  104. package/operations/entry/filtering/sort.js.map +1 -1
  105. package/operations/entry/filtering/systemFields.d.ts +2 -4
  106. package/operations/entry/filtering/systemFields.js +88 -42
  107. package/operations/entry/filtering/systemFields.js.map +1 -1
  108. package/operations/entry/filtering/transform.d.ts +1 -1
  109. package/operations/entry/filtering/transform.js +3 -8
  110. package/operations/entry/filtering/transform.js.map +1 -1
  111. package/operations/entry/filtering/types.d.ts +3 -3
  112. package/operations/entry/filtering/types.js +2 -4
  113. package/operations/entry/filtering/types.js.map +1 -1
  114. package/operations/entry/filtering/values.d.ts +1 -1
  115. package/operations/entry/filtering/values.js +6 -12
  116. package/operations/entry/filtering/values.js.map +1 -1
  117. package/operations/entry/filtering/where.js +6 -10
  118. package/operations/entry/filtering/where.js.map +1 -1
  119. package/operations/entry/index.d.ts +3 -4
  120. package/operations/entry/index.js +635 -339
  121. package/operations/entry/index.js.map +1 -1
  122. package/operations/entry/keys.d.ts +40 -2
  123. package/operations/entry/keys.js +55 -30
  124. package/operations/entry/keys.js.map +1 -1
  125. package/operations/group/index.d.ts +4 -4
  126. package/operations/group/index.js +44 -61
  127. package/operations/group/index.js.map +1 -1
  128. package/operations/model/index.d.ts +3 -3
  129. package/operations/model/index.js +37 -46
  130. package/operations/model/index.js.map +1 -1
  131. package/package.json +21 -28
  132. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +4 -3
  133. package/plugins/CmsEntryFieldFilterPathPlugin.js +15 -16
  134. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
  135. package/plugins/CmsEntryFieldFilterPlugin.d.ts +10 -10
  136. package/plugins/CmsEntryFieldFilterPlugin.js +11 -14
  137. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
  138. package/plugins/CmsEntryFieldSortingPlugin.d.ts +2 -2
  139. package/plugins/CmsEntryFieldSortingPlugin.js +6 -15
  140. package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
  141. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +2 -2
  142. package/plugins/CmsFieldFilterValueTransformPlugin.js +5 -13
  143. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -1
  144. package/plugins/index.d.ts +4 -4
  145. package/plugins/index.js +5 -48
  146. package/plugins/index.js.map +1 -1
  147. package/types.d.ts +18 -22
  148. package/types.js +5 -12
  149. package/types.js.map +1 -1
  150. package/definitions/settings.d.ts +0 -9
  151. package/definitions/settings.js +0 -53
  152. package/definitions/settings.js.map +0 -1
  153. package/definitions/system.d.ts +0 -9
  154. package/definitions/system.js +0 -41
  155. package/definitions/system.js.map +0 -1
  156. package/dynamoDb/storage/date.d.ts +0 -3
  157. package/dynamoDb/storage/date.js +0 -91
  158. package/dynamoDb/storage/date.js.map +0 -1
  159. package/operations/entry/systemFields.d.ts +0 -2
  160. package/operations/entry/systemFields.js +0 -72
  161. package/operations/entry/systemFields.js.map +0 -1
  162. package/operations/settings/index.d.ts +0 -7
  163. package/operations/settings/index.js +0 -111
  164. package/operations/settings/index.js.map +0 -1
  165. package/operations/system/index.d.ts +0 -7
  166. package/operations/system/index.js +0 -82
  167. package/operations/system/index.js.map +0 -1
@@ -1,16 +1,9 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createFullTextSearch = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- var _getValue = require("./getValue");
1
+ import WebinyError from "@webiny/error";
2
+ import { getValue } from "./getValue.js";
10
3
  /**
11
4
  * Unfortunately we must use the contains plugin directly as plugins do not support multi field searching.
12
5
  */
13
- const createFullTextSearch = params => {
6
+ export const createFullTextSearch = params => {
14
7
  const {
15
8
  term,
16
9
  targetFields,
@@ -25,13 +18,13 @@ const createFullTextSearch = params => {
25
18
  /**
26
19
  * As fields is a mapped Field objects where key is a path to the value, we can directly find the related field.
27
20
  */
28
- const field = fieldDefinitions[target];
21
+ const field = fieldDefinitions[`values.${target}`] || fieldDefinitions[target];
29
22
  if (!field) {
30
- throw new _error.default(`Unknown field "${target}" in the model.`, "UNKNOWN_FIELD", {
23
+ throw new WebinyError(`Unknown field "${target}" in the model.`, "UNKNOWN_FIELD", {
31
24
  target
32
25
  });
33
26
  }
34
- const value = (0, _getValue.getValue)(item.values, target);
27
+ const value = getValue(item.values, target);
35
28
  if (!value) {
36
29
  continue;
37
30
  }
@@ -45,4 +38,5 @@ const createFullTextSearch = params => {
45
38
  return false;
46
39
  };
47
40
  };
48
- exports.createFullTextSearch = createFullTextSearch;
41
+
42
+ //# sourceMappingURL=fullTextSearch.js.map
@@ -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,MAAMA,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,EAAE,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,CAAE,kBAAiBF,MAAO,iBAAgB,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;AAAC"}
1
+ {"version":3,"names":["WebinyError","getValue","createFullTextSearch","params","term","targetFields","fields","fieldDefinitions","plugin","trim","length","item","target","field","value","values","matches","compareValue"],"sources":["fullTextSearch.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin.js\";\nimport type { CmsEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { Field } from \"./types.js\";\nimport { getValue } from \"./getValue.js\";\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[`values.${target}`] || 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,OAAOA,WAAW,MAAM,eAAe;AAIvC,SAASC,QAAQ;AASjB;AACA;AACA;AACA,OAAO,MAAMC,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,CAAC,UAAUK,MAAM,EAAE,CAAC,IAAIL,gBAAgB,CAACK,MAAM,CAAC;MAE9E,IAAI,CAACC,KAAK,EAAE;QACR,MAAM,IAAIb,WAAW,CAAC,kBAAkBY,MAAM,iBAAiB,EAAE,eAAe,EAAE;UAC9EA;QACJ,CAAC,CAAC;MACN;MACA,MAAME,KAAK,GAAGb,QAAQ,CAACU,IAAI,CAACI,MAAM,EAAEH,MAAM,CAAC;MAC3C,IAAI,CAACE,KAAK,EAAE;QACR;MACJ;MACA,IAAIN,MAAM,CAACQ,OAAO,CAAC;QAAEF,KAAK;QAAEG,YAAY,EAAEb;MAAK,CAAC,CAAC,KAAK,IAAI,EAAE;QACxD,OAAO,IAAI;MACf;IACJ;IACA,OAAO,KAAK;EAChB,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1,9 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getValue = void 0;
7
1
  const addArrayResult = (target, result) => {
8
2
  for (const r of result) {
9
3
  if (target.some(t => r === t)) {
@@ -21,10 +15,11 @@ const find = (target, input) => {
21
15
  const path = paths.shift();
22
16
  if (!path) {
23
17
  return undefined;
24
- } else if (target[path] === undefined) {
18
+ }
19
+ const value = target?.[path];
20
+ if (value === undefined) {
25
21
  return undefined;
26
22
  }
27
- const value = target[path];
28
23
  if (paths.length === 0) {
29
24
  return value;
30
25
  } else if (Array.isArray(value)) {
@@ -49,7 +44,7 @@ const find = (target, input) => {
49
44
  * A wrapper function for the find function.
50
45
  * Basically it transforms input paths to an array (and runs various checks).
51
46
  */
52
- const getValue = (target, input) => {
47
+ export const getValue = (target, input) => {
53
48
  const paths = Array.isArray(input) ? input : input.split(".");
54
49
  if (paths.length === 0) {
55
50
  throw new Error(`Path is empty!`);
@@ -60,4 +55,5 @@ const getValue = (target, input) => {
60
55
  }
61
56
  return find(target, paths);
62
57
  };
63
- exports.getValue = getValue;
58
+
59
+ //# 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>, input: string[]): any[] | undefined => {\n const paths = [...input];\n const path = paths.shift();\n\n if (!path) {\n return undefined;\n } else if (target[path] === undefined) {\n return undefined;\n }\n const value = target[path];\n if (paths.length === 0) {\n return value;\n } else if (Array.isArray(value)) {\n if (value.length === 0) {\n return undefined;\n }\n return value.reduce<any[]>((collection, v) => {\n const result = find(v, paths);\n if (result === undefined) {\n return collection;\n } else if (Array.isArray(result)) {\n addArrayResult(collection, result);\n return collection;\n }\n collection.push(result);\n return collection;\n }, []);\n }\n return find(value, paths);\n};\n/**\n * A wrapper function for the find function.\n * Basically it transforms input paths to an array (and runs various checks).\n */\nexport const getValue = (target: Record<string, any>, input: string | string[]): any => {\n const paths = Array.isArray(input) ? input : input.split(\".\");\n if (paths.length === 0) {\n throw new Error(`Path is empty!`);\n }\n const filtered = paths.filter(Boolean);\n if (paths.length !== filtered.length) {\n throw new Error(\n `Input path is different than the filtered empty path string. (${paths.join(\n \".\"\n )} to ${filtered.join(\".\")})`\n );\n }\n\n return find(target, paths);\n};\n"],"mappings":";;;;;;AAAA,MAAMA,cAAc,GAAG,CAACC,MAAa,EAAEC,MAAa,KAAW;EAC3D,KAAK,MAAMC,CAAC,IAAID,MAAM,EAAE;IACpB,IAAID,MAAM,CAACG,IAAI,CAACC,CAAC,IAAIF,CAAC,KAAKE,CAAC,CAAC,EAAE;MAC3B;IACJ;IACAJ,MAAM,CAACK,IAAI,CAACH,CAAC,CAAC;EAClB;AACJ,CAAC;AACD;AACA;AACA;AACA;AACA,MAAMI,IAAI,GAAG,CAACN,MAA2B,EAAEO,KAAe,KAAwB;EAC9E,MAAMC,KAAK,GAAG,CAAC,GAAGD,KAAK,CAAC;EACxB,MAAME,IAAI,GAAGD,KAAK,CA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C,QAAQ,GAAGd,KAAK,CAACe,MAAM,CAACC,OAAO,CAAC;EACtC,IAAIhB,KAAK,CAACK,MAAM,KAAKS,QAAQ,CAACT,MAAM,EAAE;IAClC,MAAM,IAAIQ,KAAK,CACV,iEAAgEb,KAAK,CAACiB,IAAI,CACvE,GAAG,CACL,OAAMH,QAAQ,CAACG,IAAI,CAAC,GAAG,CAAE,GAAE,CAChC;EACL;EAEA,OAAOnB,IAAI,CAACN,MAAM,EAAEQ,KAAK,CAAC;AAC9B,CAAC;AAAC"}
1
+ {"version":3,"names":["addArrayResult","target","result","r","some","t","push","find","input","paths","path","shift","undefined","value","length","Array","isArray","reduce","collection","v","getValue","split","Error","filtered","filter","Boolean","join"],"sources":["getValue.ts"],"sourcesContent":["const addArrayResult = (target: any[], result: any[]): void => {\n for (const r of result) {\n if (target.some(t => r === t)) {\n continue;\n }\n target.push(r);\n }\n};\n/**\n * A recursive function which goes through given input paths and returns the value in it.\n * In case a path is an array, it goes through the array of those values to get values further down the path line.\n */\nconst find = (target: Record<string, any> | undefined, input: string[]): any[] | undefined => {\n const paths = [...input];\n const path = paths.shift();\n\n if (!path) {\n return undefined;\n }\n\n const value = target?.[path];\n if (value === undefined) {\n return undefined;\n }\n if (paths.length === 0) {\n return value;\n } else if (Array.isArray(value)) {\n if (value.length === 0) {\n return undefined;\n }\n return value.reduce<any[]>((collection, v) => {\n const result = find(v, paths);\n if (result === undefined) {\n return collection;\n } else if (Array.isArray(result)) {\n addArrayResult(collection, result);\n return collection;\n }\n collection.push(result);\n return collection;\n }, []);\n }\n return find(value, paths);\n};\n/**\n * A wrapper function for the find function.\n * Basically it transforms input paths to an array (and runs various checks).\n */\nexport const getValue = (target: Record<string, any>, input: string | string[]): any => {\n const paths = Array.isArray(input) ? input : input.split(\".\");\n if (paths.length === 0) {\n throw new Error(`Path is empty!`);\n }\n const filtered = paths.filter(Boolean);\n if (paths.length !== filtered.length) {\n throw new Error(\n `Input path is different than the filtered empty path string. (${paths.join(\n \".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AAU,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;AACA,OAAO,MAAMW,QAAQ,GAAGA,CAACnB,MAA2B,EAAEO,KAAwB,KAAU;EACpF,MAAMC,KAAK,GAAGM,KAAK,CAACC,OAAO,CAACR,KAAK,CAAC,GAAGA,KAAK,GAAGA,KAAK,CAACa,KAAK,CAAC,GAAG,CAAC;EAC7D,IAAIZ,KAAK,CAACK,MAAM,KAAK,CAAC,EAAE;IACpB,MAAM,IAAIQ,KAAK,CAAC,gBAAgB,CAAC;EACrC;EACA,MAAMC,QAAQ,GAAGd,KAAK,CAACe,MAAM,CAACC,OAAO,CAAC;EACtC,IAAIhB,KAAK,CAACK,MAAM,KAAKS,QAAQ,CAACT,MAAM,EAAE;IAClC,MAAM,IAAIQ,KAAK,CACX,iEAAiEb,KAAK,CAACiB,IAAI,CACvE,GACJ,CAAC,OAAOH,QAAQ,CAACG,IAAI,CAAC,GAAG,CAAC,GAC9B,CAAC;EACL;EAEA,OAAOnB,IAAI,CAACN,MAAM,EAAEQ,KAAK,CAAC;AAC9B,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- export { filter } from "./filter";
2
- export { sort } from "./sort";
1
+ export { filter } from "./filter.js";
2
+ export { sort } from "./sort.js";
@@ -1,19 +1,4 @@
1
- "use strict";
1
+ export { filter } from "./filter.js";
2
+ export { sort } from "./sort.js";
2
3
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "filter", {
7
- enumerable: true,
8
- get: function () {
9
- return _filter.filter;
10
- }
11
- });
12
- Object.defineProperty(exports, "sort", {
13
- enumerable: true,
14
- get: function () {
15
- return _sort.sort;
16
- }
17
- });
18
- var _filter = require("./filter");
19
- var _sort = require("./sort");
4
+ //# sourceMappingURL=index.js.map
@@ -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","sort"],"sources":["index.ts"],"sourcesContent":["export { filter } from \"./filter.js\";\nexport { sort } from \"./sort.js\";\n"],"mappings":"AAAA,SAASA,MAAM;AACf,SAASC,IAAI","ignoreList":[]}
@@ -1,8 +1,8 @@
1
- import { Plugin, PluginsContainer } from "@webiny/plugins/types";
1
+ import type { Plugin, PluginsContainer } from "@webiny/plugins/types.js";
2
2
  interface Params {
3
3
  plugins: PluginsContainer;
4
4
  type: string;
5
5
  property: string;
6
6
  }
7
- export declare const getMappedPlugins: <T extends Plugin<Record<string, any>>>(params: Params) => Record<string, T>;
7
+ export declare const getMappedPlugins: <T extends Plugin>(params: Params) => Record<string, T>;
8
8
  export {};
@@ -1,12 +1,5 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.getMappedPlugins = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- const getMappedPlugins = params => {
1
+ import WebinyError from "@webiny/error";
2
+ export const getMappedPlugins = params => {
10
3
  const {
11
4
  plugins: pluginsContainer,
12
5
  type,
@@ -19,7 +12,7 @@ const getMappedPlugins = params => {
19
12
  return plugins.reduce((collection, plugin) => {
20
13
  const key = plugin[property];
21
14
  if (typeof key !== "string") {
22
- throw new _error.default("Property to map the plugins on must be a string.", "PLUGIN_PROPERTY_ERROR", {
15
+ throw new WebinyError("Property to map the plugins on must be a string.", "PLUGIN_PROPERTY_ERROR", {
23
16
  type,
24
17
  property
25
18
  });
@@ -28,4 +21,5 @@ const getMappedPlugins = params => {
28
21
  return collection;
29
22
  }, {});
30
23
  };
31
- exports.getMappedPlugins = getMappedPlugins;
24
+
25
+ //# sourceMappingURL=mapPlugins.js.map
@@ -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,MAAMA,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,CAAC,CACJ;IACL;IACAI,UAAU,CAACE,GAAG,CAAC,GAAGD,MAAM;IACxB,OAAOD,UAAU;EACrB,CAAC,EAAE,CAAC,CAAC,CAAC;AACV,CAAC;AAAC"}
1
+ {"version":3,"names":["WebinyError","getMappedPlugins","params","plugins","pluginsContainer","type","property","byType","length","reduce","collection","plugin","key"],"sources":["mapPlugins.ts"],"sourcesContent":["import type { Plugin, PluginsContainer } from \"@webiny/plugins/types.js\";\nimport WebinyError from \"@webiny/error\";\n\ninterface Params {\n plugins: PluginsContainer;\n type: string;\n property: string;\n}\nexport const getMappedPlugins = <T extends Plugin>(params: Params) => {\n const { plugins: pluginsContainer, type, property } = params;\n const plugins = pluginsContainer.byType<T>(type);\n if (plugins.length === 0) {\n return {};\n }\n return plugins.reduce<Record<string, T>>((collection, plugin) => {\n const key: keyof typeof plugin = plugin[property];\n if (typeof key !== \"string\") {\n throw new WebinyError(\n \"Property to map the plugins on must be a string.\",\n \"PLUGIN_PROPERTY_ERROR\",\n {\n type,\n property\n }\n );\n }\n collection[key] = plugin;\n return collection;\n }, {});\n};\n"],"mappings":"AACA,OAAOA,WAAW,MAAM,eAAe;AAOvC,OAAO,MAAMC,gBAAgB,GAAsBC,MAAc,IAAK;EAClE,MAAM;IAAEC,OAAO,EAAEC,gBAAgB;IAAEC,IAAI;IAAEC;EAAS,CAAC,GAAGJ,MAAM;EAC5D,MAAMC,OAAO,GAAGC,gBAAgB,CAACG,MAAM,CAAIF,IAAI,CAAC;EAChD,IAAIF,OAAO,CAACK,MAAM,KAAK,CAAC,EAAE;IACtB,OAAO,CAAC,CAAC;EACb;EACA,OAAOL,OAAO,CAACM,MAAM,CAAoB,CAACC,UAAU,EAAEC,MAAM,KAAK;IAC7D,MAAMC,GAAwB,GAAGD,MAAM,CAACL,QAAQ,CAAC;IACjD,IAAI,OAAOM,GAAG,KAAK,QAAQ,EAAE;MACzB,MAAM,IAAIZ,WAAW,CACjB,kDAAkD,EAClD,uBAAuB,EACvB;QACIK,IAAI;QACJC;MACJ,CACJ,CAAC;IACL;IACAI,UAAU,CAACE,GAAG,CAAC,GAAGD,MAAM;IACxB,OAAOD,UAAU;EACrB,CAAC,EAAE,CAAC,CAAC,CAAC;AACV,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin";
2
- export declare const createDefaultFilterCreate: () => CmsEntryFieldFilterPlugin;
1
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
2
+ export declare const createDefaultFilterCreate: () => CmsEntryFieldFilterPlugin<any>;
@@ -1,15 +1,8 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createDefaultFilterCreate = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- var _CmsEntryFieldFilterPlugin = require("../../../../plugins/CmsEntryFieldFilterPlugin");
10
- const createDefaultFilterCreate = () => {
11
- return new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
12
- fieldType: _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin.ALL,
1
+ import WebinyError from "@webiny/error";
2
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
3
+ export const createDefaultFilterCreate = () => {
4
+ const plugin = new CmsEntryFieldFilterPlugin({
5
+ fieldType: CmsEntryFieldFilterPlugin.ALL,
13
6
  create: params => {
14
7
  const {
15
8
  negate,
@@ -20,7 +13,7 @@ const createDefaultFilterCreate = () => {
20
13
  } = params;
21
14
  const plugin = valueFilterPlugins[params.operation];
22
15
  if (!plugin) {
23
- throw new _error.default(`Missing ValueFilterPlugin for operation "${params.operation}".`, "MISSING_OPERATION_PLUGIN", {
16
+ throw new WebinyError(`Missing ValueFilterPlugin for operation "${params.operation}".`, "MISSING_OPERATION_PLUGIN", {
24
17
  operation: params.operation
25
18
  });
26
19
  }
@@ -37,5 +30,8 @@ const createDefaultFilterCreate = () => {
37
30
  };
38
31
  }
39
32
  });
33
+ plugin.name = `headless-cms.ddb.filter.default`;
34
+ return plugin;
40
35
  };
41
- exports.createDefaultFilterCreate = createDefaultFilterCreate;
36
+
37
+ //# sourceMappingURL=defaultFilterCreate.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createDefaultFilterCreate","CmsEntryFieldFilterPlugin","fieldType","ALL","create","params","negate","transformValue","field","compareValue","valueFilterPlugins","plugin","operation","WebinyError","fieldPathId","parents","map","f","fieldId","join","path","createPath"],"sources":["defaultFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin\";\n\nexport const createDefaultFilterCreate = () => {\n return new CmsEntryFieldFilterPlugin({\n fieldType: CmsEntryFieldFilterPlugin.ALL,\n create: params => {\n const { negate, transformValue, field, compareValue, valueFilterPlugins } = params;\n const plugin = valueFilterPlugins[params.operation];\n if (!plugin) {\n throw new WebinyError(\n `Missing ValueFilterPlugin for operation \"${params.operation}\".`,\n \"MISSING_OPERATION_PLUGIN\",\n {\n operation: params.operation\n }\n );\n }\n return {\n negate,\n transformValue,\n field,\n compareValue,\n fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join(\".\"),\n path: field.createPath({\n field\n }),\n plugin\n };\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAEO,MAAMA,yBAAyB,GAAG,MAAM;EAC3C,OAAO,IAAIC,oDAAyB,CAAC;IACjCC,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,MAAMM,MAAM,GAAGD,kBAAkB,CAACL,MAAM,CAACO,SAAS,CAAC;MACnD,IAAI,CAACD,MAAM,EAAE;QACT,MAAM,IAAIE,cAAW,CAChB,4CAA2CR,MAAM,CAACO,SAAU,IAAG,EAChE,0BAA0B,EAC1B;UACIA,SAAS,EAAEP,MAAM,CAACO;QACtB,CAAC,CACJ;MACL;MACA,OAAO;QACHN,MAAM;QACNC,cAAc;QACdC,KAAK;QACLC,YAAY;QACZK,WAAW,EAAE,CAAC,GAAGN,KAAK,CAACO,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC,EAAEV,KAAK,CAACU,OAAO,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;QAC5EC,IAAI,EAAEZ,KAAK,CAACa,UAAU,CAAC;UACnBb;QACJ,CAAC,CAAC;QACFG;MACJ,CAAC;IACL;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
1
+ {"version":3,"names":["WebinyError","CmsEntryFieldFilterPlugin","createDefaultFilterCreate","plugin","fieldType","ALL","create","params","negate","transformValue","field","compareValue","valueFilterPlugins","operation","fieldPathId","parents","map","f","fieldId","join","path","createPath","name"],"sources":["defaultFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\n\nexport const createDefaultFilterCreate = () => {\n const plugin = new CmsEntryFieldFilterPlugin({\n fieldType: CmsEntryFieldFilterPlugin.ALL,\n create: params => {\n const { negate, transformValue, field, compareValue, valueFilterPlugins } = params;\n const plugin = valueFilterPlugins[params.operation];\n if (!plugin) {\n throw new WebinyError(\n `Missing ValueFilterPlugin for operation \"${params.operation}\".`,\n \"MISSING_OPERATION_PLUGIN\",\n {\n operation: params.operation\n }\n );\n }\n return {\n negate,\n transformValue,\n field,\n compareValue,\n fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join(\".\"),\n path: field.createPath({\n field\n }),\n plugin\n };\n }\n });\n\n plugin.name = `headless-cms.ddb.filter.default`;\n\n return plugin;\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,yBAAyB;AAElC,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,MAAMC,MAAM,GAAG,IAAIF,yBAAyB,CAAC;IACzCG,SAAS,EAAEH,yBAAyB,CAACI,GAAG;IACxCC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,MAAM;QAAEC,cAAc;QAAEC,KAAK;QAAEC,YAAY;QAAEC;MAAmB,CAAC,GAAGL,MAAM;MAClF,MAAMJ,MAAM,GAAGS,kBAAkB,CAACL,MAAM,CAACM,SAAS,CAAC;MACnD,IAAI,CAACV,MAAM,EAAE;QACT,MAAM,IAAIH,WAAW,CACjB,4CAA4CO,MAAM,CAACM,SAAS,IAAI,EAChE,0BAA0B,EAC1B;UACIA,SAAS,EAAEN,MAAM,CAACM;QACtB,CACJ,CAAC;MACL;MACA,OAAO;QACHL,MAAM;QACNC,cAAc;QACdC,KAAK;QACLC,YAAY;QACZG,WAAW,EAAE,CAAC,GAAGJ,KAAK,CAACK,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC,EAAER,KAAK,CAACQ,OAAO,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;QAC5EC,IAAI,EAAEV,KAAK,CAACW,UAAU,CAAC;UACnBX;QACJ,CAAC,CAAC;QACFP;MACJ,CAAC;IACL;EACJ,CAAC,CAAC;EAEFA,MAAM,CAACmB,IAAI,GAAG,iCAAiC;EAE/C,OAAOnB,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- export declare const createFilterCreatePlugins: () => import("../../../..").CmsEntryFieldFilterPlugin[];
1
+ export declare const createFilterCreatePlugins: () => import("../../../../index.js").CmsEntryFieldFilterPlugin<import("@webiny/api/types.js").GenericRecord | null | undefined>[];
@@ -1,13 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createFilterCreatePlugins = void 0;
7
- var _defaultFilterCreate = require("./defaultFilterCreate");
8
- var _refFilterCreate = require("./refFilterCreate");
9
- var _objectFilterCreate = require("./objectFilterCreate");
10
- const createFilterCreatePlugins = () => {
11
- return [(0, _defaultFilterCreate.createDefaultFilterCreate)(), (0, _refFilterCreate.createRefFilterCreate)(), (0, _objectFilterCreate.objectFilterCreate)()];
1
+ import { createDefaultFilterCreate } from "./defaultFilterCreate.js";
2
+ import { createRefFilterCreate } from "./refFilterCreate.js";
3
+ import { objectFilterCreate } from "./objectFilterCreate.js";
4
+ import { searchableJsonFilterCreate } from "./searchableJsonFilterCreate.js";
5
+ export const createFilterCreatePlugins = () => {
6
+ return [createDefaultFilterCreate(), createRefFilterCreate(), objectFilterCreate(), searchableJsonFilterCreate()];
12
7
  };
13
- exports.createFilterCreatePlugins = createFilterCreatePlugins;
8
+
9
+ //# 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(), createRefFilterCreate(), objectFilterCreate()];\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEO,MAAMA,yBAAyB,GAAG,MAAM;EAC3C,OAAO,CAAC,IAAAC,8CAAyB,GAAE,EAAE,IAAAC,sCAAqB,GAAE,EAAE,IAAAC,sCAAkB,GAAE,CAAC;AACvF,CAAC;AAAC"}
1
+ {"version":3,"names":["createDefaultFilterCreate","createRefFilterCreate","objectFilterCreate","searchableJsonFilterCreate","createFilterCreatePlugins"],"sources":["index.ts"],"sourcesContent":["import { createDefaultFilterCreate } from \"./defaultFilterCreate.js\";\nimport { createRefFilterCreate } from \"./refFilterCreate.js\";\nimport { objectFilterCreate } from \"./objectFilterCreate.js\";\nimport { searchableJsonFilterCreate } from \"./searchableJsonFilterCreate.js\";\n\nexport const createFilterCreatePlugins = () => {\n return [\n createDefaultFilterCreate(),\n createRefFilterCreate(),\n objectFilterCreate(),\n searchableJsonFilterCreate()\n ];\n};\n"],"mappings":"AAAA,SAASA,yBAAyB;AAClC,SAASC,qBAAqB;AAC9B,SAASC,kBAAkB;AAC3B,SAASC,0BAA0B;AAEnC,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAM;EAC3C,OAAO,CACHJ,yBAAyB,CAAC,CAAC,EAC3BC,qBAAqB,CAAC,CAAC,EACvBC,kBAAkB,CAAC,CAAC,EACpBC,0BAA0B,CAAC,CAAC,CAC/B;AACL,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin";
2
- export declare const objectFilterCreate: () => CmsEntryFieldFilterPlugin;
1
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
2
+ export declare const objectFilterCreate: () => CmsEntryFieldFilterPlugin<any>;
@@ -1,16 +1,10 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.objectFilterCreate = void 0;
8
- var _CmsEntryFieldFilterPlugin = require("../../../../plugins/CmsEntryFieldFilterPlugin");
9
- var _where = require("../where");
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
- var _transform = require("../transform");
12
- const objectFilterCreate = () => {
13
- return new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
1
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
2
+ import { extractWhereParams } from "../where.js";
3
+ import WebinyError from "@webiny/error";
4
+ import { transformValue } from "../transform.js";
5
+ import { getBaseFieldType } from "@webiny/api-headless-cms/utils/getBaseFieldType.js";
6
+ export const objectFilterCreate = () => {
7
+ const plugin = new CmsEntryFieldFilterPlugin({
14
8
  fieldType: "object",
15
9
  create: params => {
16
10
  const {
@@ -27,7 +21,7 @@ const objectFilterCreate = () => {
27
21
  if (value === undefined) {
28
22
  continue;
29
23
  }
30
- const whereParams = (0, _where.extractWhereParams)(key);
24
+ const whereParams = extractWhereParams(key);
31
25
  if (!whereParams) {
32
26
  continue;
33
27
  }
@@ -39,12 +33,13 @@ const objectFilterCreate = () => {
39
33
  const fieldPath = parentField.parents.map(p => p.fieldId).concat([parentField.fieldId, fieldId]).join(".");
40
34
  const field = fields[fieldPath];
41
35
  if (!field) {
42
- throw new _error.default(`There is no field with the field path "${fieldPath}".`, "FIELD_ERROR", {
36
+ throw new WebinyError(`There is no field with the field path "${fieldPath}".`, "FIELD_ERROR", {
43
37
  fieldId
44
38
  });
45
39
  }
46
- const filterCreatePlugin = getFilterCreatePlugin(field.type);
47
- const transformValuePlugin = transformValuePlugins[field.type];
40
+ const fieldType = getBaseFieldType(field);
41
+ const filterCreatePlugin = getFilterCreatePlugin(fieldType);
42
+ const transformValuePlugin = transformValuePlugins[fieldType];
48
43
  const transformValueCallable = value => {
49
44
  if (!transformValuePlugin) {
50
45
  return value;
@@ -64,7 +59,7 @@ const objectFilterCreate = () => {
64
59
  negate,
65
60
  field,
66
61
  fields,
67
- compareValue: (0, _transform.transformValue)({
62
+ compareValue: transformValue({
68
63
  value,
69
64
  transform: transformValueCallable
70
65
  }),
@@ -82,5 +77,8 @@ const objectFilterCreate = () => {
82
77
  return filters;
83
78
  }
84
79
  });
80
+ plugin.name = `headless-cms.ddb.filter.object`;
81
+ return plugin;
85
82
  };
86
- exports.objectFilterCreate = objectFilterCreate;
83
+
84
+ //# sourceMappingURL=objectFilterCreate.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["objectFilterCreate","CmsEntryFieldFilterPlugin","fieldType","create","params","value","objectValue","valueFilterPlugins","transformValuePlugins","getFilterCreatePlugin","field","parentField","fields","filters","key","undefined","whereParams","extractWhereParams","negate","fieldId","operation","fieldPath","parents","map","p","concat","join","WebinyError","filterCreatePlugin","type","transformValuePlugin","transformValueCallable","transform","result","compareValue","transformValue","Array","isArray","push"],"sources":["objectFilterCreate.ts"],"sourcesContent":["import { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsFieldFilterValueTransformPlugin } from \"~/types\";\nimport { transformValue } from \"~/operations/entry/filtering/transform\";\n\nexport const objectFilterCreate = () => {\n return new CmsEntryFieldFilterPlugin({\n fieldType: \"object\",\n create: params => {\n const {\n value: objectValue,\n valueFilterPlugins,\n transformValuePlugins,\n getFilterCreatePlugin,\n field: parentField,\n fields\n } = params;\n\n const filters = [];\n\n for (const key in objectValue) {\n const value = objectValue[key];\n if (value === undefined) {\n continue;\n }\n const whereParams = extractWhereParams(key);\n if (!whereParams) {\n continue;\n }\n const { negate, fieldId, operation } = whereParams;\n\n const fieldPath = parentField.parents\n .map(p => p.fieldId)\n .concat([parentField.fieldId, fieldId])\n .join(\".\");\n\n const field = fields[fieldPath];\n if (!field) {\n throw new WebinyError(\n `There is no field with the field path \"${fieldPath}\".`,\n \"FIELD_ERROR\",\n {\n fieldId\n }\n );\n }\n\n const filterCreatePlugin = getFilterCreatePlugin(field.type);\n\n const transformValuePlugin: CmsFieldFilterValueTransformPlugin =\n transformValuePlugins[field.type];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const result = filterCreatePlugin.create({\n key,\n value,\n valueFilterPlugins,\n transformValuePlugins,\n getFilterCreatePlugin,\n operation,\n negate,\n field,\n fields,\n compareValue: transformValue({\n value,\n transform: transformValueCallable\n }),\n transformValue: transformValueCallable\n });\n if (!result) {\n continue;\n }\n if (Array.isArray(result)) {\n filters.push(...result);\n continue;\n }\n\n filters.push(result);\n }\n return filters;\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;A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AE;YACvB,OAAOzB,KAAK;UAChB;UACA,OAAOyB,oBAAoB,CAACE,SAAS,CAAC;YAClCtB,KAAK;YACLL;UACJ,CAAC,CAAC;QACN,CAAC;QAED,MAAM4B,MAAM,GAAGL,kBAAkB,CAACzB,MAAM,CAAC;UACrCW,GAAG;UACHT,KAAK;UACLE,kBAAkB;UAClBC,qBAAqB;UACrBC,qBAAqB;UACrBW,SAAS;UACTF,MAAM;UACNR,KAAK;UACLE,MAAM;UACNsB,YAAY,EAAE,IAAAC,yBAAc,EAAC;YACzB9B,KAAK;YACL2B,SAAS,EAAED;UACf,CAAC,CAAC;UACFI,cAAc,EAAEJ;QACpB,CAAC,CAAC;QACF,IAAI,CAACE,MAAM,EAAE;UACT;QACJ;QACA,IAAIG,KAAK,CAACC,OAAO,CAACJ,MAAM,CAAC,EAAE;UACvBpB,OAAO,CAACyB,IAAI,CAAC,GAAGL,MAAM,CAAC;UACvB;QACJ;QAEApB,OAAO,CAACyB,IAAI,CAACL,MAAM,CAAC;MACxB;MACA,OAAOpB,OAAO;IAClB;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
1
+ {"version":3,"names":["CmsEntryFieldFilterPlugin","extractWhereParams","WebinyError","transformValue","getBaseFieldType","objectFilterCreate","plugin","fieldType","create","params","value","objectValue","valueFilterPlugins","transformValuePlugins","getFilterCreatePlugin","field","parentField","fields","filters","key","undefined","whereParams","negate","fieldId","operation","fieldPath","parents","map","p","concat","join","filterCreatePlugin","transformValuePlugin","transformValueCallable","transform","result","compareValue","Array","isArray","push","name"],"sources":["objectFilterCreate.ts"],"sourcesContent":["import { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where.js\";\nimport WebinyError from \"@webiny/error\";\nimport type { CmsFieldFilterValueTransformPlugin } from \"~/types.js\";\nimport { transformValue } from \"~/operations/entry/filtering/transform.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\nexport const objectFilterCreate = () => {\n const plugin = new CmsEntryFieldFilterPlugin({\n fieldType: \"object\",\n create: params => {\n const {\n value: objectValue,\n valueFilterPlugins,\n transformValuePlugins,\n getFilterCreatePlugin,\n field: parentField,\n fields\n } = params;\n\n const filters = [];\n\n for (const key in objectValue) {\n const value = objectValue[key];\n if (value === undefined) {\n continue;\n }\n const whereParams = extractWhereParams(key);\n if (!whereParams) {\n continue;\n }\n const { negate, fieldId, operation } = whereParams;\n\n const fieldPath = parentField.parents\n .map(p => p.fieldId)\n .concat([parentField.fieldId, fieldId])\n .join(\".\");\n\n const field = fields[fieldPath];\n if (!field) {\n throw new WebinyError(\n `There is no field with the field path \"${fieldPath}\".`,\n \"FIELD_ERROR\",\n {\n fieldId\n }\n );\n }\n\n const fieldType = getBaseFieldType(field);\n\n const filterCreatePlugin = getFilterCreatePlugin(fieldType);\n\n const transformValuePlugin: CmsFieldFilterValueTransformPlugin =\n transformValuePlugins[fieldType];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const result = filterCreatePlugin.create({\n key,\n value,\n valueFilterPlugins,\n transformValuePlugins,\n getFilterCreatePlugin,\n operation,\n negate,\n field,\n fields,\n compareValue: transformValue({\n value,\n transform: transformValueCallable\n }),\n transformValue: transformValueCallable\n });\n if (!result) {\n continue;\n }\n if (Array.isArray(result)) {\n filters.push(...result);\n continue;\n }\n\n filters.push(result);\n }\n return filters;\n }\n });\n\n plugin.name = `headless-cms.ddb.filter.object`;\n\n return plugin;\n};\n"],"mappings":"AAAA,SAASA,yBAAyB;AAClC,SAASC,kBAAkB;AAC3B,OAAOC,WAAW,MAAM,eAAe;AAEvC,SAASC,cAAc;AACvB,SAASC,gBAAgB,QAAQ,oDAAoD;AAErF,OAAO,MAAMC,kBAAkB,GAAGA,CAAA,KAAM;EACpC,MAAMC,MAAM,GAAG,IAAIN,yBAAyB,CAAC;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AACE,SAAS,CAAC;YAClCnB,KAAK;YACLL;UACJ,CAAC,CAAC;QACN,CAAC;QAED,MAAMyB,MAAM,GAAGJ,kBAAkB,CAACvB,MAAM,CAAC;UACrCW,GAAG;UACHT,KAAK;UACLE,kBAAkB;UAClBC,qBAAqB;UACrBC,qBAAqB;UACrBU,SAAS;UACTF,MAAM;UACNP,KAAK;UACLE,MAAM;UACNmB,YAAY,EAAEjC,cAAc,CAAC;YACzBO,KAAK;YACLwB,SAAS,EAAED;UACf,CAAC,CAAC;UACF9B,cAAc,EAAE8B;QACpB,CAAC,CAAC;QACF,IAAI,CAACE,MAAM,EAAE;UACT;QACJ;QACA,IAAIE,KAAK,CAACC,OAAO,CAACH,MAAM,CAAC,EAAE;UACvBjB,OAAO,CAACqB,IAAI,CAAC,GAAGJ,MAAM,CAAC;UACvB;QACJ;QAEAjB,OAAO,CAACqB,IAAI,CAACJ,MAAM,CAAC;MACxB;MACA,OAAOjB,OAAO;IAClB;EACJ,CAAC,CAAC;EAEFZ,MAAM,CAACkC,IAAI,GAAG,gCAAgC;EAE9C,OAAOlC,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -1,2 +1,3 @@
1
- import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin";
2
- export declare const createRefFilterCreate: () => CmsEntryFieldFilterPlugin;
1
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
2
+ import type { GenericRecord } from "@webiny/api/types.js";
3
+ export declare const createRefFilterCreate: () => CmsEntryFieldFilterPlugin<GenericRecord | null | undefined>;
@@ -1,31 +1,30 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createRefFilterCreate = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- var _CmsEntryFieldFilterPlugin = require("../../../../plugins/CmsEntryFieldFilterPlugin");
10
- var _where = require("../where");
11
- var _transform = require("../transform");
12
- const createRefFilterCreate = () => {
13
- return new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
1
+ import WebinyError from "@webiny/error";
2
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
3
+ import { extractWhereParams } from "../where.js";
4
+ import { transformValue } from "../transform.js";
5
+ import { getBaseFieldType } from "@webiny/api-headless-cms/utils/getBaseFieldType.js";
6
+ export const createRefFilterCreate = () => {
7
+ const plugin = new CmsEntryFieldFilterPlugin({
14
8
  fieldType: "ref",
15
9
  create: params => {
16
10
  const {
17
- value,
18
11
  valueFilterPlugins,
19
12
  transformValuePlugins,
20
13
  field
21
14
  } = params;
15
+ let value = params.value;
16
+ if (!value) {
17
+ value = {
18
+ entryId: null
19
+ };
20
+ }
22
21
  const propertyFilters = Object.keys(value);
23
22
  if (propertyFilters.length === 0) {
24
23
  return null;
25
24
  }
26
25
  const filters = [];
27
26
  for (const propertyFilter of propertyFilters) {
28
- const whereParams = (0, _where.extractWhereParams)(propertyFilter);
27
+ const whereParams = extractWhereParams(propertyFilter);
29
28
  if (!whereParams) {
30
29
  continue;
31
30
  }
@@ -34,7 +33,8 @@ const createRefFilterCreate = () => {
34
33
  operation: propertyOperation,
35
34
  negate
36
35
  } = whereParams;
37
- const transformValuePlugin = transformValuePlugins[field.type];
36
+ const fieldType = getBaseFieldType(field);
37
+ const transformValuePlugin = transformValuePlugins[fieldType];
38
38
  const transformValueCallable = value => {
39
39
  if (!transformValuePlugin) {
40
40
  return value;
@@ -46,7 +46,7 @@ const createRefFilterCreate = () => {
46
46
  };
47
47
  const filterPlugin = valueFilterPlugins[propertyOperation];
48
48
  if (!filterPlugin) {
49
- throw new _error.default(`Missing operation filter for "${propertyOperation}".`, "MISSING_OPERATION_FILTER");
49
+ throw new WebinyError(`Missing operation filter for "${propertyOperation}".`, "MISSING_OPERATION_FILTER");
50
50
  }
51
51
  const paths = [field.createPath({
52
52
  field
@@ -57,7 +57,7 @@ const createRefFilterCreate = () => {
57
57
  fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join("."),
58
58
  plugin: filterPlugin,
59
59
  negate,
60
- compareValue: (0, _transform.transformValue)({
60
+ compareValue: transformValue({
61
61
  value: value[propertyFilter],
62
62
  transform: transformValueCallable
63
63
  }),
@@ -67,5 +67,8 @@ const createRefFilterCreate = () => {
67
67
  return filters;
68
68
  }
69
69
  });
70
+ plugin.name = `headless-cms.ddb.filter.ref`;
71
+ return plugin;
70
72
  };
71
- exports.createRefFilterCreate = createRefFilterCreate;
73
+
74
+ //# sourceMappingURL=refFilterCreate.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createRefFilterCreate","CmsEntryFieldFilterPlugin","fieldType","create","params","value","valueFilterPlugins","transformValuePlugins","field","propertyFilters","Object","keys","length","filters","propertyFilter","whereParams","extractWhereParams","fieldId","propertyId","operation","propertyOperation","negate","transformValuePlugin","type","transformValueCallable","transform","filterPlugin","WebinyError","paths","createPath","push","path","join","fieldPathId","parents","map","f","plugin","compareValue","transformValue"],"sources":["refFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n CmsEntryFieldFilterPlugin,\n CmsEntryFieldFilterPluginCreateResponse\n} from \"~/plugins/CmsEntryFieldFilterPlugin\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where\";\nimport { transformValue } from \"~/operations/entry/filtering/transform\";\n\nexport const createRefFilterCreate = () => {\n return new CmsEntryFieldFilterPlugin({\n fieldType: \"ref\",\n create: params => {\n const { value, valueFilterPlugins, transformValuePlugins, field } = params;\n const propertyFilters = Object.keys(value);\n if (propertyFilters.length === 0) {\n return null;\n }\n\n const filters: CmsEntryFieldFilterPluginCreateResponse[] = [];\n\n for (const propertyFilter of propertyFilters) {\n const whereParams = extractWhereParams(propertyFilter);\n if (!whereParams) {\n continue;\n }\n const { fieldId: propertyId, operation: propertyOperation, negate } = whereParams;\n\n const transformValuePlugin = transformValuePlugins[field.type];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const filterPlugin = valueFilterPlugins[propertyOperation];\n if (!filterPlugin) {\n throw new WebinyError(\n `Missing operation filter for \"${propertyOperation}\".`,\n \"MISSING_OPERATION_FILTER\"\n );\n }\n\n const paths = [\n field.createPath({\n field\n }),\n propertyId\n ];\n\n filters.push({\n field,\n path: paths.join(\".\"),\n fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join(\".\"),\n plugin: filterPlugin,\n negate,\n compareValue: transformValue({\n value: value[propertyFilter],\n transform: transformValueCallable\n }),\n transformValue: transformValueCallable\n });\n }\n\n return filters;\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAIA;AACA;AAEO,MAAMA,qBAAqB,GAAG,MAAM;EACvC,OAAO,IAAIC,oDAAyB,CAAC;IACjCC,SAAS,EAAE,KAAK;IAChBC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,KAAK;QAAEC,kBAAkB;QAAEC,qBAAqB;QAAEC;MAAM,CAAC,GAAGJ,MAAM;MAC1E,MAAMK,eAAe,GAAGC,MAAM,CAACC,IAAI,CAACN,KAAK,CAAC;MAC1C,IAAII,eAAe,CAACG,MAAM,KAAK,CAAC,EAAE;QAC9B,OAAO,IAAI;MACf;MAEA,MAAMC,OAAkD,GAAG,EAAE;MAE7D,KAAK,MAAMC,cAAc,IAAIL,eAAe,EAAE;QAC1C,MAAMM,WAAW,GAAG,IAAAC,yBAAkB,EAACF,cAAc,CAAC;QACtD,IAAI,CAACC,WAAW,EAAE;UACd;QACJ;QACA,MAAM;UAAEE,OAAO,EAAEC,UAAU;UAAEC,SAAS,EAAEC,iBAAiB;UAAEC;QAAO,CAAC,GAAGN,WAAW;QAEjF,MAAMO,oBAAoB,GAAGf,qBAAqB,CAACC,KAAK,CAACe,IAAI,CAAC;QAE9D,MAAMC,sBAAsB,GAAInB,KAAU,IAAK;UAC3C,IAAI,CAACiB,oBAAoB,EAAE;YACvB,OAAOjB,KAAK;UAChB;UACA,OAAOiB,oBAAoB,CAACG,SAAS,CAAC;YAClCjB,KAAK;YACLH;UACJ,CAAC,CAAC;QACN,CAAC;QAED,MAAMqB,YAAY,GAAGpB,kBAAkB,CAACc,iBAAiB,CAAC;QAC1D,IAAI,CAACM,YAAY,EAAE;UACf,MAAM,IAAIC,cAAW,CAChB,iCAAgCP,iBAAkB,IAAG,EACtD,0BAA0B,CAC7B;QACL;QAEA,MAAMQ,KAAK,GAAG,CACVpB,KAAK,CAACqB,UAAU,CAAC;UACbrB;QACJ,CAAC,CAAC,EACFU,UAAU,CACb;QAEDL,OAAO,CAACiB,IAAI,CAAC;UACTtB,KAAK;UACLuB,IAAI,EAAEH,KAAK,CAACI,IAAI,CAAC,GAAG,CAAC;UACrBC,WAAW,EAAE,CAAC,GAAGzB,KAAK,CAAC0B,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACnB,OAAO,CAAC,EAAET,KAAK,CAACS,OAAO,CAAC,CAACe,IAAI,CAAC,GAAG,CAAC;UAC5EK,MAAM,EAAEX,YAAY;UACpBL,MAAM;UACNiB,YAAY,EAAE,IAAAC,yBAAc,EAAC;YACzBlC,KAAK,EAAEA,KAAK,CAACS,cAAc,CAAC;YAC5BW,SAAS,EAAED;UACf,CAAC,CAAC;UACFe,cAAc,EAAEf;QACpB,CAAC,CAAC;MACN;MAEA,OAAOX,OAAO;IAClB;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
1
+ {"version":3,"names":["WebinyError","CmsEntryFieldFilterPlugin","extractWhereParams","transformValue","getBaseFieldType","createRefFilterCreate","plugin","fieldType","create","params","valueFilterPlugins","transformValuePlugins","field","value","entryId","propertyFilters","Object","keys","length","filters","propertyFilter","whereParams","fieldId","propertyId","operation","propertyOperation","negate","transformValuePlugin","transformValueCallable","transform","filterPlugin","paths","createPath","push","path","join","fieldPathId","parents","map","f","compareValue","name"],"sources":["refFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsEntryFieldFilterPluginCreateResponse } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where.js\";\nimport { transformValue } from \"~/operations/entry/filtering/transform.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\nexport const createRefFilterCreate = () => {\n const plugin = new CmsEntryFieldFilterPlugin<GenericRecord | null | undefined>({\n fieldType: \"ref\",\n create: params => {\n const { valueFilterPlugins, transformValuePlugins, field } = params;\n let value = params.value;\n if (!value) {\n value = {\n entryId: null\n };\n }\n const propertyFilters = Object.keys(value);\n if (propertyFilters.length === 0) {\n return null;\n }\n const filters: CmsEntryFieldFilterPluginCreateResponse[] = [];\n\n for (const propertyFilter of propertyFilters) {\n const whereParams = extractWhereParams(propertyFilter);\n if (!whereParams) {\n continue;\n }\n const { fieldId: propertyId, operation: propertyOperation, negate } = whereParams;\n\n const fieldType = getBaseFieldType(field);\n\n const transformValuePlugin = transformValuePlugins[fieldType];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const filterPlugin = valueFilterPlugins[propertyOperation];\n if (!filterPlugin) {\n throw new WebinyError(\n `Missing operation filter for \"${propertyOperation}\".`,\n \"MISSING_OPERATION_FILTER\"\n );\n }\n\n const paths = [\n field.createPath({\n field\n }),\n propertyId\n ];\n\n filters.push({\n field,\n path: paths.join(\".\"),\n fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join(\".\"),\n plugin: filterPlugin,\n negate,\n compareValue: transformValue({\n value: value[propertyFilter],\n transform: transformValueCallable\n }),\n transformValue: transformValueCallable\n });\n }\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B,KAAK;YACLC;UACJ,CAAC,CAAC;QACN,CAAC;QAED,MAAMiB,YAAY,GAAGpB,kBAAkB,CAACe,iBAAiB,CAAC;QAC1D,IAAI,CAACK,YAAY,EAAE;UACf,MAAM,IAAI9B,WAAW,CACjB,iCAAiCyB,iBAAiB,IAAI,EACtD,0BACJ,CAAC;QACL;QAEA,MAAMM,KAAK,GAAG,CACVnB,KAAK,CAACoB,UAAU,CAAC;UACbpB;QACJ,CAAC,CAAC,EACFW,UAAU,CACb;QAEDJ,OAAO,CAACc,IAAI,CAAC;UACTrB,KAAK;UACLsB,IAAI,EAAEH,KAAK,CAACI,IAAI,CAAC,GAAG,CAAC;UACrBC,WAAW,EAAE,CAAC,GAAGxB,KAAK,CAACyB,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACjB,OAAO,CAAC,EAAEV,KAAK,CAACU,OAAO,CAAC,CAACa,IAAI,CAAC,GAAG,CAAC;UAC5E7B,MAAM,EAAEwB,YAAY;UACpBJ,MAAM;UACNc,YAAY,EAAErC,cAAc,CAAC;YACzBU,KAAK,EAAEA,KAAK,CAACO,cAAc,CAAC;YAC5BS,SAAS,EAAED;UACf,CAAC,CAAC;UACFzB,cAAc,EAAEyB;QACpB,CAAC,CAAC;MACN;MAEA,OAAOT,OAAO;IAClB;EACJ,CAAC,CAAC;EAEFb,MAAM,CAACmC,IAAI,GAAG,6BAA6B;EAE3C,OAAOnC,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
2
+ export declare const searchableJsonFilterCreate: () => CmsEntryFieldFilterPlugin<any>;
@@ -0,0 +1,57 @@
1
+ import dot from "dot-object";
2
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
3
+ import { extractWhereParams } from "../where.js";
4
+ export const searchableJsonFilterCreate = () => {
5
+ const plugin = new CmsEntryFieldFilterPlugin({
6
+ fieldType: "searchable-json",
7
+ create: params => {
8
+ const {
9
+ value: objectValue,
10
+ valueFilterPlugins,
11
+ field: parentField
12
+ } = params;
13
+ const filters = [];
14
+ const accessPatterns = dot.dot(objectValue);
15
+ for (const key in accessPatterns) {
16
+ const value = accessPatterns[key];
17
+ if (value === undefined) {
18
+ continue;
19
+ }
20
+ const whereParams = extractWhereParams(key);
21
+ if (!whereParams) {
22
+ continue;
23
+ }
24
+ const {
25
+ negate,
26
+ operation
27
+ } = whereParams;
28
+ const transformValueCallable = value => {
29
+ return value;
30
+ };
31
+ const fieldId = `${parentField.fieldId}.${whereParams.fieldId ?? key}`;
32
+ const result = {
33
+ field: parentField,
34
+ path: `values.${fieldId}`,
35
+ fieldPathId: `values.${fieldId}`,
36
+ negate,
37
+ plugin: valueFilterPlugins[operation],
38
+ compareValue: value,
39
+ transformValue: transformValueCallable
40
+ };
41
+ if (!result) {
42
+ continue;
43
+ }
44
+ if (Array.isArray(result)) {
45
+ filters.push(...result);
46
+ continue;
47
+ }
48
+ filters.push(result);
49
+ }
50
+ return filters;
51
+ }
52
+ });
53
+ plugin.name = `headless-cms.ddb.filter.searchable-json`;
54
+ return plugin;
55
+ };
56
+
57
+ //# sourceMappingURL=searchableJsonFilterCreate.js.map