@webiny/api-headless-cms-ddb 0.0.0-unstable.615a930a68 → 0.0.0-unstable.61c048f412

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 (177) hide show
  1. package/README.md +6 -20
  2. package/definitions/entry.d.ts +4 -5
  3. package/definitions/entry.js +6 -89
  4. package/definitions/entry.js.map +1 -1
  5. package/definitions/group.d.ts +4 -5
  6. package/definitions/group.js +6 -63
  7. package/definitions/group.js.map +1 -1
  8. package/definitions/model.d.ts +4 -5
  9. package/definitions/model.js +6 -85
  10. package/definitions/model.js.map +1 -1
  11. package/definitions/table.d.ts +4 -6
  12. package/definitions/table.js +7 -28
  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 +8 -20
  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 +6 -20
  25. package/dynamoDb/path/plainObject.js.map +1 -1
  26. package/dynamoDb/storage/longText.d.ts +1 -1
  27. package/dynamoDb/storage/longText.js +19 -34
  28. package/dynamoDb/storage/longText.js.map +1 -1
  29. package/dynamoDb/storage/richText.d.ts +1 -1
  30. package/dynamoDb/storage/richText.js +27 -88
  31. package/dynamoDb/storage/richText.js.map +1 -1
  32. package/dynamoDb/transformValue/datetime.d.ts +1 -1
  33. package/dynamoDb/transformValue/datetime.js +7 -19
  34. package/dynamoDb/transformValue/datetime.js.map +1 -1
  35. package/index.d.ts +2 -2
  36. package/index.js +47 -105
  37. package/index.js.map +1 -1
  38. package/operations/entry/dataLoader/DataLoaderCache.d.ts +15 -0
  39. package/operations/entry/dataLoader/DataLoaderCache.js +34 -0
  40. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  41. package/operations/entry/dataLoader/constants.d.ts +1 -0
  42. package/operations/entry/dataLoader/constants.js +4 -0
  43. package/operations/entry/dataLoader/constants.js.map +1 -0
  44. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  45. package/operations/entry/dataLoader/createBatchScheduleFn.js +19 -0
  46. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  47. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  48. package/operations/entry/dataLoader/getAllEntryRevisions.js +32 -0
  49. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  50. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  51. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +46 -0
  52. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  53. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  54. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +46 -0
  55. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  56. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  57. package/operations/entry/dataLoader/getRevisionById.js +52 -0
  58. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  59. package/operations/entry/dataLoader/index.d.ts +8 -0
  60. package/operations/entry/dataLoader/index.js +19 -0
  61. package/operations/entry/dataLoader/index.js.map +1 -0
  62. package/operations/entry/dataLoader/types.d.ts +5 -0
  63. package/operations/entry/dataLoader/types.js +3 -0
  64. package/operations/entry/dataLoader/types.js.map +1 -0
  65. package/operations/entry/dataLoaders.d.ts +14 -30
  66. package/operations/entry/dataLoaders.js +56 -271
  67. package/operations/entry/dataLoaders.js.map +1 -1
  68. package/operations/entry/filtering/createExpressions.d.ts +26 -0
  69. package/operations/entry/filtering/createExpressions.js +175 -0
  70. package/operations/entry/filtering/createExpressions.js.map +1 -0
  71. package/operations/entry/filtering/createFields.d.ts +7 -9
  72. package/operations/entry/filtering/createFields.js +87 -105
  73. package/operations/entry/filtering/createFields.js.map +1 -1
  74. package/operations/entry/filtering/extractSort.d.ts +8 -4
  75. package/operations/entry/filtering/extractSort.js +60 -31
  76. package/operations/entry/filtering/extractSort.js.map +1 -1
  77. package/operations/entry/filtering/filter.d.ts +6 -7
  78. package/operations/entry/filtering/filter.js +102 -89
  79. package/operations/entry/filtering/filter.js.map +1 -1
  80. package/operations/entry/filtering/fullTextSearch.d.ts +4 -8
  81. package/operations/entry/filtering/fullTextSearch.js +8 -30
  82. package/operations/entry/filtering/fullTextSearch.js.map +1 -1
  83. package/operations/entry/filtering/getValue.js +5 -27
  84. package/operations/entry/filtering/getValue.js.map +1 -1
  85. package/operations/entry/filtering/index.d.ts +2 -2
  86. package/operations/entry/filtering/index.js +3 -20
  87. package/operations/entry/filtering/index.js.map +1 -1
  88. package/operations/entry/filtering/mapPlugins.d.ts +2 -2
  89. package/operations/entry/filtering/mapPlugins.js +4 -18
  90. package/operations/entry/filtering/mapPlugins.js.map +1 -1
  91. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +2 -2
  92. package/operations/entry/filtering/plugins/defaultFilterCreate.js +9 -20
  93. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
  94. package/operations/entry/filtering/plugins/index.d.ts +1 -1
  95. package/operations/entry/filtering/plugins/index.js +7 -16
  96. package/operations/entry/filtering/plugins/index.js.map +1 -1
  97. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +2 -2
  98. package/operations/entry/filtering/plugins/objectFilterCreate.js +16 -39
  99. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
  100. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +3 -2
  101. package/operations/entry/filtering/plugins/refFilterCreate.js +21 -36
  102. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
  103. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +2 -0
  104. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +57 -0
  105. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -0
  106. package/operations/entry/filtering/sort.d.ts +8 -5
  107. package/operations/entry/filtering/sort.js +23 -36
  108. package/operations/entry/filtering/sort.js.map +1 -1
  109. package/operations/entry/filtering/systemFields.d.ts +2 -4
  110. package/operations/entry/filtering/systemFields.js +87 -43
  111. package/operations/entry/filtering/systemFields.js.map +1 -1
  112. package/operations/entry/filtering/transform.d.ts +1 -1
  113. package/operations/entry/filtering/transform.js +2 -10
  114. package/operations/entry/filtering/transform.js.map +1 -1
  115. package/operations/entry/filtering/types.d.ts +2 -2
  116. package/operations/entry/filtering/types.js +2 -4
  117. package/operations/entry/filtering/types.js.map +1 -1
  118. package/operations/entry/filtering/values.d.ts +2 -0
  119. package/operations/entry/filtering/values.js +16 -0
  120. package/operations/entry/filtering/values.js.map +1 -0
  121. package/operations/entry/filtering/where.js +5 -15
  122. package/operations/entry/filtering/where.js.map +1 -1
  123. package/operations/entry/index.d.ts +3 -4
  124. package/operations/entry/index.js +751 -414
  125. package/operations/entry/index.js.map +1 -1
  126. package/operations/entry/keys.d.ts +40 -2
  127. package/operations/entry/keys.js +54 -47
  128. package/operations/entry/keys.js.map +1 -1
  129. package/operations/group/index.d.ts +4 -4
  130. package/operations/group/index.js +44 -91
  131. package/operations/group/index.js.map +1 -1
  132. package/operations/model/index.d.ts +3 -3
  133. package/operations/model/index.js +36 -70
  134. package/operations/model/index.js.map +1 -1
  135. package/package.json +22 -29
  136. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +4 -3
  137. package/plugins/CmsEntryFieldFilterPathPlugin.js +14 -29
  138. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
  139. package/plugins/CmsEntryFieldFilterPlugin.d.ts +10 -10
  140. package/plugins/CmsEntryFieldFilterPlugin.js +9 -19
  141. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
  142. package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
  143. package/plugins/CmsEntryFieldSortingPlugin.js +19 -0
  144. package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
  145. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
  146. package/plugins/CmsFieldFilterValueTransformPlugin.js +16 -0
  147. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
  148. package/plugins/index.d.ts +4 -1
  149. package/plugins/index.js +5 -17
  150. package/plugins/index.js.map +1 -1
  151. package/types.d.ts +24 -19
  152. package/types.js +5 -13
  153. package/types.js.map +1 -1
  154. package/definitions/settings.d.ts +0 -9
  155. package/definitions/settings.js +0 -58
  156. package/definitions/settings.js.map +0 -1
  157. package/definitions/system.d.ts +0 -9
  158. package/definitions/system.js +0 -46
  159. package/definitions/system.js.map +0 -1
  160. package/dynamoDb/storage/date.d.ts +0 -2
  161. package/dynamoDb/storage/date.js +0 -109
  162. package/dynamoDb/storage/date.js.map +0 -1
  163. package/operations/entry/filtering/createFilters.d.ts +0 -20
  164. package/operations/entry/filtering/createFilters.js +0 -155
  165. package/operations/entry/filtering/createFilters.js.map +0 -1
  166. package/operations/entry/systemFields.d.ts +0 -2
  167. package/operations/entry/systemFields.js +0 -74
  168. package/operations/entry/systemFields.js.map +0 -1
  169. package/operations/entry/utils.d.ts +0 -36
  170. package/operations/entry/utils.js +0 -684
  171. package/operations/entry/utils.js.map +0 -1
  172. package/operations/settings/index.d.ts +0 -7
  173. package/operations/settings/index.js +0 -135
  174. package/operations/settings/index.js.map +0 -1
  175. package/operations/system/index.d.ts +0 -7
  176. package/operations/system/index.js +0 -99
  177. package/operations/system/index.js.map +0 -1
@@ -1,80 +1,67 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.sort = void 0;
9
-
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
- var _dotProp = _interopRequireDefault(require("dot-prop"));
13
-
14
- var _sortBy = _interopRequireDefault(require("lodash/sortBy"));
15
-
16
- var _extractSort = require("./extractSort");
17
-
18
- const sort = params => {
1
+ import WebinyError from "@webiny/error";
2
+ import dotProp from "dot-prop";
3
+ import lodashSortBy from "lodash/sortBy.js";
4
+ import { extractSort } from "./extractSort.js";
5
+ export const sort = params => {
19
6
  const {
7
+ model,
20
8
  items,
21
9
  sort = [],
22
- fields
10
+ fields,
11
+ plugins
23
12
  } = params;
24
-
25
13
  if (items.length <= 1) {
26
14
  return items;
27
15
  } else if (sort.length === 0) {
28
16
  sort.push("savedOn_DESC");
29
17
  } else if (sort.length > 1) {
30
- throw new _error.default("Sorting is limited to a single field.", "SORT_MULTIPLE_FIELDS_ERROR", {
31
- sort: sort
18
+ throw new WebinyError("Sorting is limited to a single field on DynamoDB only system.", "SORT_MULTIPLE_FIELDS_ERROR", {
19
+ sort
32
20
  });
33
21
  }
34
-
35
22
  const [firstSort] = sort;
36
-
37
23
  if (!firstSort) {
38
- throw new _error.default("Empty sort array item.", "SORT_EMPTY_ERROR", {
24
+ throw new WebinyError("Empty sort array item.", "SORT_EMPTY_ERROR", {
39
25
  sort
40
26
  });
41
27
  }
42
-
43
28
  const {
44
29
  fieldId,
45
30
  field,
46
31
  valuePath,
47
32
  reverse
48
- } = (0, _extractSort.extractSort)({
33
+ } = extractSort({
34
+ model,
49
35
  sortBy: firstSort,
50
- fields
36
+ fields,
37
+ plugins
51
38
  });
52
39
  const itemsToSort = items.map(item => {
53
40
  return {
54
41
  id: item.id,
55
- value: field.transform(_dotProp.default.get(item, valuePath))
42
+ value: field.transform(dotProp.get(item, valuePath))
56
43
  };
57
44
  });
58
- const sortedItems = (0, _sortBy.default)(itemsToSort, "value");
45
+ const sortedItems = lodashSortBy(itemsToSort, "value");
59
46
  const newItems = sortedItems.map(s => {
60
47
  const item = items.find(i => i.id === s.id);
61
-
62
48
  if (item) {
63
49
  return item;
64
50
  }
65
-
66
- throw new _error.default("Could not find item by given id after the sorting.", "SORTING_ITEMS_ERROR", {
51
+ /**
52
+ * This is impossible to happen because sorting items does not remove the items.
53
+ * BUT, we need to have this check just in case for development purposes.
54
+ */
55
+ throw new WebinyError("Could not find item by given id after the sorting.", "SORTING_ITEMS_ERROR", {
67
56
  id: s.id,
68
57
  sortingBy: fieldId,
69
58
  reverse
70
59
  });
71
60
  });
72
-
73
61
  if (!reverse) {
74
62
  return newItems;
75
63
  }
76
-
77
64
  return newItems.reverse();
78
65
  };
79
66
 
80
- exports.sort = sort;
67
+ //# sourceMappingURL=sort.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["sort","params","items","fields","length","push","WebinyError","firstSort","fieldId","field","valuePath","reverse","extractSort","sortBy","itemsToSort","map","item","id","value","transform","dotProp","get","sortedItems","lodashSortBy","newItems","s","find","i","sortingBy"],"sources":["sort.ts"],"sourcesContent":["import { CmsEntry } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\nimport dotProp from \"dot-prop\";\nimport lodashSortBy from \"lodash/sortBy\";\nimport { extractSort } from \"./extractSort\";\nimport { Field } from \"./types\";\n\ninterface Params {\n items: CmsEntry[];\n sort?: string[];\n fields: Record<string, Field>;\n}\n\ninterface SortedItem {\n id: string;\n value: any;\n}\n\nexport const sort = (params: Params): CmsEntry[] => {\n const { items, sort = [], fields } = params;\n if (items.length <= 1) {\n return items;\n } else if (sort.length === 0) {\n sort.push(\"savedOn_DESC\");\n } else if (sort.length > 1) {\n throw new WebinyError(\n \"Sorting is limited to a single field.\",\n \"SORT_MULTIPLE_FIELDS_ERROR\",\n {\n sort: sort\n }\n );\n }\n const [firstSort] = sort;\n if (!firstSort) {\n throw new WebinyError(\"Empty sort array item.\", \"SORT_EMPTY_ERROR\", {\n sort\n });\n }\n\n const { fieldId, field, valuePath, reverse } = extractSort({\n sortBy: firstSort,\n fields\n });\n\n const itemsToSort = items.map(item => {\n return {\n id: item.id,\n value: field.transform(dotProp.get(item, valuePath))\n };\n });\n const sortedItems: SortedItem[] = lodashSortBy(itemsToSort, \"value\");\n const newItems = sortedItems.map(s => {\n const item = items.find(i => i.id === s.id);\n if (item) {\n return item;\n }\n throw new WebinyError(\n \"Could not find item by given id after the sorting.\",\n \"SORTING_ITEMS_ERROR\",\n {\n id: s.id,\n sortingBy: fieldId,\n reverse\n }\n );\n });\n if (!reverse) {\n return newItems;\n }\n return newItems.reverse();\n};\n"],"mappings":";;;;;;;;;AACA;;AACA;;AACA;;AACA;;AAcO,MAAMA,IAAI,GAAIC,MAAD,IAAgC;EAChD,MAAM;IAAEC,KAAF;IAASF,IAAI,GAAG,EAAhB;IAAoBG;EAApB,IAA+BF,MAArC;;EACA,IAAIC,KAAK,CAACE,MAAN,IAAgB,CAApB,EAAuB;IACnB,OAAOF,KAAP;EACH,CAFD,MAEO,IAAIF,IAAI,CAACI,MAAL,KAAgB,CAApB,EAAuB;IAC1BJ,IAAI,CAACK,IAAL,CAAU,cAAV;EACH,CAFM,MAEA,IAAIL,IAAI,CAACI,MAAL,GAAc,CAAlB,EAAqB;IACxB,MAAM,IAAIE,cAAJ,CACF,uCADE,EAEF,4BAFE,EAGF;MACIN,IAAI,EAAEA;IADV,CAHE,CAAN;EAOH;;EACD,MAAM,CAACO,SAAD,IAAcP,IAApB;;EACA,IAAI,CAACO,SAAL,EAAgB;IACZ,MAAM,IAAID,cAAJ,CAAgB,wBAAhB,EAA0C,kBAA1C,EAA8D;MAChEN;IADgE,CAA9D,CAAN;EAGH;;EAED,MAAM;IAAEQ,OAAF;IAAWC,KAAX;IAAkBC,SAAlB;IAA6BC;EAA7B,IAAyC,IAAAC,wBAAA,EAAY;IACvDC,MAAM,EAAEN,SAD+C;IAEvDJ;EAFuD,CAAZ,CAA/C;EAKA,MAAMW,WAAW,GAAGZ,KAAK,CAACa,GAAN,CAAUC,IAAI,IAAI;IAClC,OAAO;MACHC,EAAE,EAAED,IAAI,CAACC,EADN;MAEHC,KAAK,EAAET,KAAK,CAACU,SAAN,CAAgBC,gBAAA,CAAQC,GAAR,CAAYL,IAAZ,EAAkBN,SAAlB,CAAhB;IAFJ,CAAP;EAIH,CALmB,CAApB;EAMA,MAAMY,WAAyB,GAAG,IAAAC,eAAA,EAAaT,WAAb,EAA0B,OAA1B,CAAlC;EACA,MAAMU,QAAQ,GAAGF,WAAW,CAACP,GAAZ,CAAgBU,CAAC,IAAI;IAClC,MAAMT,IAAI,GAAGd,KAAK,CAACwB,IAAN,CAAWC,CAAC,IAAIA,CAAC,CAACV,EAAF,KAASQ,CAAC,CAACR,EAA3B,CAAb;;IACA,IAAID,IAAJ,EAAU;MACN,OAAOA,IAAP;IACH;;IACD,MAAM,IAAIV,cAAJ,CACF,oDADE,EAEF,qBAFE,EAGF;MACIW,EAAE,EAAEQ,CAAC,CAACR,EADV;MAEIW,SAAS,EAAEpB,OAFf;MAGIG;IAHJ,CAHE,CAAN;EASH,CAdgB,CAAjB;;EAeA,IAAI,CAACA,OAAL,EAAc;IACV,OAAOa,QAAP;EACH;;EACD,OAAOA,QAAQ,CAACb,OAAT,EAAP;AACH,CArDM"}
1
+ {"version":3,"names":["WebinyError","dotProp","lodashSortBy","extractSort","sort","params","model","items","fields","plugins","length","push","firstSort","fieldId","field","valuePath","reverse","sortBy","itemsToSort","map","item","id","value","transform","get","sortedItems","newItems","s","find","i","sortingBy"],"sources":["sort.ts"],"sourcesContent":["import type { CmsEntry, CmsEntryValues, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport dotProp from \"dot-prop\";\nimport lodashSortBy from \"lodash/sortBy.js\";\nimport { extractSort } from \"./extractSort.js\";\nimport type { Field } from \"./types.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\n\ninterface Params<T extends CmsEntryValues = CmsEntryValues> {\n model: CmsModel;\n items: CmsEntry<T>[];\n sort?: string[];\n fields: Record<string, Field>;\n plugins: PluginsContainer;\n}\n\ninterface SortedItem {\n id: string;\n value: any;\n}\n\nexport const sort = <T extends CmsEntryValues = CmsEntryValues>(\n params: Params<T>\n): CmsEntry<T>[] => {\n const { model, items, sort = [], fields, plugins } = params;\n if (items.length <= 1) {\n return items;\n } else if (sort.length === 0) {\n sort.push(\"savedOn_DESC\");\n } else if (sort.length > 1) {\n throw new WebinyError(\n \"Sorting is limited to a single field on DynamoDB only system.\",\n \"SORT_MULTIPLE_FIELDS_ERROR\",\n {\n sort\n }\n );\n }\n const [firstSort] = sort;\n if (!firstSort) {\n throw new WebinyError(\"Empty sort array item.\", \"SORT_EMPTY_ERROR\", {\n sort\n });\n }\n\n const { fieldId, field, valuePath, reverse } = extractSort({\n model,\n sortBy: firstSort,\n fields,\n plugins\n });\n\n const itemsToSort = items.map(item => {\n return {\n id: item.id,\n value: field.transform(dotProp.get(item, valuePath))\n };\n });\n const sortedItems: SortedItem[] = lodashSortBy(itemsToSort, \"value\");\n const newItems = sortedItems.map(s => {\n const item = items.find(i => i.id === s.id);\n if (item) {\n return item;\n }\n /**\n * This is impossible to happen because sorting items does not remove the items.\n * BUT, we need to have this check just in case for development purposes.\n */\n throw new WebinyError(\n \"Could not find item by given id after the sorting.\",\n \"SORTING_ITEMS_ERROR\",\n {\n id: s.id,\n sortingBy: fieldId,\n reverse\n }\n );\n });\n if (!reverse) {\n return newItems;\n }\n return newItems.reverse();\n};\n"],"mappings":"AACA,OAAOA,WAAW,MAAM,eAAe;AACvC,OAAOC,OAAO,MAAM,UAAU;AAC9B,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,SAASC,WAAW;AAiBpB,OAAO,MAAMC,IAAI,GACbC,MAAiB,IACD;EAChB,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEH,IAAI,GAAG,EAAE;IAAEI,MAAM;IAAEC;EAAQ,CAAC,GAAGJ,MAAM;EAC3D,IAAIE,KAAK,CAACG,MAAM,IAAI,CAAC,EAAE;IACnB,OAAOH,KAAK;EAChB,CAAC,MAAM,IAAIH,IAAI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AO;MAClBG;IACJ,CACJ,CAAC;EACL,CAAC,CAAC;EACF,IAAI,CAACA,OAAO,EAAE;IACV,OAAOU,QAAQ;EACnB;EACA,OAAOA,QAAQ,CAACV,OAAO,CAAC,CAAC;AAC7B,CAAC","ignoreList":[]}
@@ -1,4 +1,2 @@
1
- import { CmsModelField } from "@webiny/api-headless-cms/types";
2
- declare type Field = Pick<CmsModelField, "id" | "type" | "storageId" | "fieldId" | "settings" | "label">;
3
- export declare const createSystemFields: () => Field[];
4
- export {};
1
+ import type { CmsModelField } from "@webiny/api-headless-cms/types/index.js";
2
+ export declare const createSystemFields: () => CmsModelField[];
@@ -1,72 +1,116 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createSystemFields = void 0;
7
-
8
- const createSystemFields = () => {
9
- return [{
1
+ import { ENTRY_META_FIELDS, isDateTimeEntryMetaField, isIdentityEntryMetaField } from "@webiny/api-headless-cms/constants.js";
2
+ import lodashStartCase from "lodash/startCase.js";
3
+ import { createModelField } from "@webiny/api-headless-cms";
4
+ export const createSystemFields = () => {
5
+ const onMetaFields = ENTRY_META_FIELDS.filter(isDateTimeEntryMetaField).map(fieldName => {
6
+ return createModelField({
7
+ id: fieldName,
8
+ type: "datetime",
9
+ storageId: fieldName,
10
+ fieldId: fieldName,
11
+ label: lodashStartCase(fieldName)
12
+ });
13
+ });
14
+ const byMetaFields = ENTRY_META_FIELDS.filter(isIdentityEntryMetaField).map(fieldName => {
15
+ return createModelField({
16
+ id: fieldName,
17
+ type: "plainObject",
18
+ storageId: fieldName,
19
+ fieldId: fieldName,
20
+ label: lodashStartCase(fieldName),
21
+ settings: {
22
+ path: `${fieldName}.id`
23
+ }
24
+ });
25
+ });
26
+ return [createModelField({
10
27
  id: "id",
11
28
  type: "text",
12
29
  storageId: "id",
13
30
  fieldId: "id",
14
31
  label: "ID"
15
- }, {
32
+ }), createModelField({
16
33
  id: "entryId",
17
34
  type: "text",
18
35
  storageId: "entryId",
19
36
  fieldId: "entryId",
20
37
  label: "Entry ID"
21
- }, {
22
- id: "createdOn",
23
- type: "datetime",
24
- storageId: "createdOn",
25
- fieldId: "createdOn",
26
- label: "Created On"
27
- }, {
28
- id: "savedOn",
29
- type: "datetime",
30
- storageId: "savedOn",
31
- fieldId: "savedOn",
32
- label: "Saved On"
33
- }, {
34
- id: "createdBy",
35
- type: "plainObject",
36
- storageId: "createdBy",
37
- fieldId: "createdBy",
38
- label: "Created By",
39
- settings: {
40
- path: "createdBy.id"
41
- }
42
- }, {
38
+ }), ...onMetaFields, ...byMetaFields, createModelField({
43
39
  id: "meta",
44
40
  type: "plainObject",
45
41
  storageId: "meta",
46
42
  fieldId: "meta",
47
43
  label: "Meta"
48
- }, {
49
- id: "ownedBy",
50
- type: "plainObject",
51
- storageId: "ownedBy",
52
- fieldId: "ownedBy",
53
- label: "Owned By",
44
+ }), createModelField({
45
+ id: "wbyAco_location",
46
+ type: "object",
47
+ storageId: "location",
48
+ label: "Location",
49
+ fieldId: "wbyAco_location",
54
50
  settings: {
55
- path: "ownedBy.id"
51
+ fields: [createModelField({
52
+ id: "folderId",
53
+ type: "text",
54
+ fieldId: "folderId",
55
+ label: "Folder ID",
56
+ storageId: "folderId",
57
+ settings: {
58
+ path: "location.folderId"
59
+ }
60
+ })]
56
61
  }
57
- }, {
62
+ }), createModelField({
58
63
  id: "version",
59
64
  type: "number",
60
65
  storageId: "version",
61
66
  fieldId: "version",
62
67
  label: "Version"
63
- }, {
68
+ }), createModelField({
64
69
  id: "status",
65
70
  type: "text",
66
71
  storageId: "status",
67
72
  fieldId: "status",
68
73
  label: "Status"
69
- }];
74
+ }), createModelField({
75
+ id: "wbyDeleted",
76
+ type: "boolean",
77
+ storageId: "wbyDeleted",
78
+ fieldId: "wbyDeleted",
79
+ label: "Deleted"
80
+ }), createModelField({
81
+ id: "state",
82
+ type: "object",
83
+ storageId: "object@state",
84
+ fieldId: "state",
85
+ label: "State",
86
+ settings: {
87
+ fields: [createModelField({
88
+ id: "stepId",
89
+ type: "text",
90
+ fieldId: "stepId",
91
+ label: "Step ID",
92
+ storageId: "stepId"
93
+ }), createModelField({
94
+ id: "stepName",
95
+ type: "text",
96
+ fieldId: "stepName",
97
+ label: "Step Name",
98
+ storageId: "stepName"
99
+ }), createModelField({
100
+ id: "state",
101
+ type: "text",
102
+ fieldId: "state",
103
+ label: "State",
104
+ storageId: "state"
105
+ })]
106
+ }
107
+ }), createModelField({
108
+ id: "values",
109
+ type: "object",
110
+ storageId: "values",
111
+ fieldId: "values",
112
+ label: "Values"
113
+ })];
70
114
  };
71
115
 
72
- exports.createSystemFields = createSystemFields;
116
+ //# sourceMappingURL=systemFields.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createSystemFields","id","type","storageId","fieldId","label","settings","path"],"sources":["systemFields.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\ntype Field = Pick<CmsModelField, \"id\" | \"type\" | \"storageId\" | \"fieldId\" | \"settings\" | \"label\">;\n\nexport const createSystemFields = (): Field[] => {\n return [\n {\n id: \"id\",\n type: \"text\",\n storageId: \"id\",\n fieldId: \"id\",\n label: \"ID\"\n },\n {\n id: \"entryId\",\n type: \"text\",\n storageId: \"entryId\",\n fieldId: \"entryId\",\n label: \"Entry ID\"\n },\n {\n id: \"createdOn\",\n type: \"datetime\",\n storageId: \"createdOn\",\n fieldId: \"createdOn\",\n label: \"Created On\"\n },\n {\n id: \"savedOn\",\n type: \"datetime\",\n storageId: \"savedOn\",\n fieldId: \"savedOn\",\n label: \"Saved On\"\n },\n {\n id: \"createdBy\",\n type: \"plainObject\",\n storageId: \"createdBy\",\n fieldId: \"createdBy\",\n label: \"Created By\",\n settings: {\n path: \"createdBy.id\"\n }\n },\n {\n id: \"meta\",\n type: \"plainObject\",\n storageId: \"meta\",\n fieldId: \"meta\",\n label: \"Meta\"\n },\n {\n id: \"ownedBy\",\n type: \"plainObject\",\n storageId: \"ownedBy\",\n fieldId: \"ownedBy\",\n label: \"Owned By\",\n settings: {\n path: \"ownedBy.id\"\n }\n },\n {\n id: \"version\",\n type: \"number\",\n storageId: \"version\",\n fieldId: \"version\",\n label: \"Version\"\n },\n {\n id: \"status\",\n type: \"text\",\n storageId: \"status\",\n fieldId: \"status\",\n label: \"Status\"\n }\n ];\n};\n"],"mappings":";;;;;;;AAIO,MAAMA,kBAAkB,GAAG,MAAe;EAC7C,OAAO,CACH;IACIC,EAAE,EAAE,IADR;IAEIC,IAAI,EAAE,MAFV;IAGIC,SAAS,EAAE,IAHf;IAIIC,OAAO,EAAE,IAJb;IAKIC,KAAK,EAAE;EALX,CADG,EAQH;IACIJ,EAAE,EAAE,SADR;IAEIC,IAAI,EAAE,MAFV;IAGIC,SAAS,EAAE,SAHf;IAIIC,OAAO,EAAE,SAJb;IAKIC,KAAK,EAAE;EALX,CARG,EAeH;IACIJ,EAAE,EAAE,WADR;IAEIC,IAAI,EAAE,UAFV;IAGIC,SAAS,EAAE,WAHf;IAIIC,OAAO,EAAE,WAJb;IAKIC,KAAK,EAAE;EALX,CAfG,EAsBH;IACIJ,EAAE,EAAE,SADR;IAEIC,IAAI,EAAE,UAFV;IAGIC,SAAS,EAAE,SAHf;IAIIC,OAAO,EAAE,SAJb;IAKIC,KAAK,EAAE;EALX,CAtBG,EA6BH;IACIJ,EAAE,EAAE,WADR;IAEIC,IAAI,EAAE,aAFV;IAGIC,SAAS,EAAE,WAHf;IAIIC,OAAO,EAAE,WAJb;IAKIC,KAAK,EAAE,YALX;IAMIC,QAAQ,EAAE;MACNC,IAAI,EAAE;IADA;EANd,CA7BG,EAuCH;IACIN,EAAE,EAAE,MADR;IAEIC,IAAI,EAAE,aAFV;IAGIC,SAAS,EAAE,MAHf;IAIIC,OAAO,EAAE,MAJb;IAKIC,KAAK,EAAE;EALX,CAvCG,EA8CH;IACIJ,EAAE,EAAE,SADR;IAEIC,IAAI,EAAE,aAFV;IAGIC,SAAS,EAAE,SAHf;IAIIC,OAAO,EAAE,SAJb;IAKIC,KAAK,EAAE,UALX;IAMIC,QAAQ,EAAE;MACNC,IAAI,EAAE;IADA;EANd,CA9CG,EAwDH;IACIN,EAAE,EAAE,SADR;IAEIC,IAAI,EAAE,QAFV;IAGIC,SAAS,EAAE,SAHf;IAIIC,OAAO,EAAE,SAJb;IAKIC,KAAK,EAAE;EALX,CAxDG,EA+DH;IACIJ,EAAE,EAAE,QADR;IAEIC,IAAI,EAAE,MAFV;IAGIC,SAAS,EAAE,QAHf;IAIIC,OAAO,EAAE,QAJb;IAKIC,KAAK,EAAE;EALX,CA/DG,CAAP;AAuEH,CAxEM"}
1
+ {"version":3,"names":["ENTRY_META_FIELDS","isDateTimeEntryMetaField","isIdentityEntryMetaField","lodashStartCase","createModelField","createSystemFields","onMetaFields","filter","map","fieldName","id","type","storageId","fieldId","label","byMetaFields","settings","path","fields"],"sources":["systemFields.ts"],"sourcesContent":["import type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport {\n ENTRY_META_FIELDS,\n isDateTimeEntryMetaField,\n isIdentityEntryMetaField\n} from \"@webiny/api-headless-cms/constants.js\";\nimport lodashStartCase from \"lodash/startCase.js\";\nimport { createModelField } from \"@webiny/api-headless-cms\";\n\nexport const createSystemFields = (): CmsModelField[] => {\n const onMetaFields = ENTRY_META_FIELDS.filter(isDateTimeEntryMetaField).map<CmsModelField>(\n fieldName => {\n return createModelField({\n id: fieldName,\n type: \"datetime\",\n storageId: fieldName,\n fieldId: fieldName,\n label: lodashStartCase(fieldName)\n });\n }\n );\n\n const byMetaFields = ENTRY_META_FIELDS.filter(isIdentityEntryMetaField).map<CmsModelField>(\n fieldName => {\n return createModelField({\n id: fieldName,\n type: \"plainObject\",\n storageId: fieldName,\n fieldId: fieldName,\n label: lodashStartCase(fieldName),\n settings: {\n path: `${fieldName}.id`\n }\n });\n }\n );\n\n return [\n createModelField({\n id: \"id\",\n type: \"text\",\n storageId: \"id\",\n fieldId: \"id\",\n label: \"ID\"\n }),\n createModelField({\n id: \"entryId\",\n type: \"text\",\n storageId: \"entryId\",\n fieldId: \"entryId\",\n label: \"Entry ID\"\n }),\n\n ...onMetaFields,\n ...byMetaFields,\n\n createModelField({\n id: \"meta\",\n type: \"plainObject\",\n storageId: \"meta\",\n fieldId: \"meta\",\n label: \"Meta\"\n }),\n createModelField({\n id: \"wbyAco_location\",\n type: \"object\",\n storageId: \"location\",\n label: \"Location\",\n fieldId: \"wbyAco_location\",\n settings: {\n fields: [\n createModelField({\n id: \"folderId\",\n type: \"text\",\n fieldId: \"folderId\",\n label: \"Folder ID\",\n storageId: \"folderId\",\n settings: {\n path: \"location.folderId\"\n }\n })\n ]\n }\n }),\n\n createModelField({\n id: \"version\",\n type: \"number\",\n storageId: \"version\",\n fieldId: \"version\",\n label: \"Version\"\n }),\n createModelField({\n id: \"status\",\n type: \"text\",\n storageId: \"status\",\n fieldId: \"status\",\n label: \"Status\"\n }),\n createModelField({\n id: \"wbyDeleted\",\n type: \"boolean\",\n storageId: \"wbyDeleted\",\n fieldId: \"wbyDeleted\",\n label: \"Deleted\"\n }),\n createModelField({\n id: \"state\",\n type: \"object\",\n storageId: \"object@state\",\n fieldId: \"state\",\n label: \"State\",\n settings: {\n fields: [\n createModelField({\n id: \"stepId\",\n type: \"text\",\n fieldId: \"stepId\",\n label: \"Step ID\",\n storageId: \"stepId\"\n }),\n createModelField({\n id: \"stepName\",\n type: \"text\",\n fieldId: \"stepName\",\n label: \"Step Name\",\n storageId: \"stepName\"\n }),\n createModelField({\n id: \"state\",\n type: \"text\",\n fieldId: \"state\",\n label: \"State\",\n storageId: \"state\"\n })\n ]\n }\n }),\n createModelField({\n id: \"values\",\n type: \"object\",\n storageId: \"values\",\n fieldId: \"values\",\n label: \"Values\"\n })\n ];\n};\n"],"mappings":"AACA,SACIA,iBAAiB,EACjBC,wBAAwB,EACxBC,wBAAwB,QACrB,uCAAuC;AAC9C,OAAOC,eAAe,MAAM,qBAAqB;AACjD,SAASC,gBAAgB,QAAQ,0BA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AAgB,CAAC;QACbM,EAAE,EAAE,UAAU;QACdC,IAAI,EAAE,MAAM;QACZE,OAAO,EAAE,UAAU;QACnBC,KAAK,EAAE,WAAW;QAClBF,SAAS,EAAE;MACf,CAAC,CAAC,EACFR,gBAAgB,CAAC;QACbM,EAAE,EAAE,OAAO;QACXC,IAAI,EAAE,MAAM;QACZE,OAAO,EAAE,OAAO;QAChBC,KAAK,EAAE,OAAO;QACdF,SAAS,EAAE;MACf,CAAC,CAAC;IAEV;EACJ,CAAC,CAAC,EACFR,gBAAgB,CAAC;IACbM,EAAE,EAAE,QAAQ;IACZC,IAAI,EAAE,QAAQ;IACdC,SAAS,EAAE,QAAQ;IACnBC,OAAO,EAAE,QAAQ;IACjBC,KAAK,EAAE;EACX,CAAC,CAAC,CACL;AACL,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { Field } from "./types";
1
+ import type { Field } from "./types.js";
2
2
  interface Params extends Pick<Field, "transform"> {
3
3
  value: any;
4
4
  }
@@ -1,19 +1,11 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.transformValue = void 0;
7
-
8
- const transformValue = ({
1
+ export const transformValue = ({
9
2
  value,
10
3
  transform
11
4
  }) => {
12
5
  if (Array.isArray(value)) {
13
6
  return value.map(v => transform(v));
14
7
  }
15
-
16
8
  return transform(value);
17
9
  };
18
10
 
19
- exports.transformValue = transformValue;
11
+ //# sourceMappingURL=transform.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["transformValue","value","transform","Array","isArray","map","v"],"sources":["transform.ts"],"sourcesContent":["import { Field } from \"./types\";\n\ninterface Params extends Pick<Field, \"transform\"> {\n value: any;\n}\nexport const transformValue = ({ value, transform }: Params): any => {\n if (Array.isArray(value)) {\n return value.map(v => transform(v));\n }\n return transform(value);\n};\n"],"mappings":";;;;;;;AAKO,MAAMA,cAAc,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAAuC;EACjE,IAAIC,KAAK,CAACC,OAAN,CAAcH,KAAd,CAAJ,EAA0B;IACtB,OAAOA,KAAK,CAACI,GAAN,CAAUC,CAAC,IAAIJ,SAAS,CAACI,CAAD,CAAxB,CAAP;EACH;;EACD,OAAOJ,SAAS,CAACD,KAAD,CAAhB;AACH,CALM"}
1
+ {"version":3,"names":["transformValue","value","transform","Array","isArray","map","v"],"sources":["transform.ts"],"sourcesContent":["import type { Field } from \"./types.js\";\n\ninterface Params extends Pick<Field, \"transform\"> {\n value: any;\n}\nexport const transformValue = ({ value, transform }: Params): any => {\n if (Array.isArray(value)) {\n return value.map(v => transform(v));\n }\n return transform(value);\n};\n"],"mappings":"AAKA,OAAO,MAAMA,cAAc,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAkB,CAAC,KAAU;EACjE,IAAIC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;IACtB,OAAOA,KAAK,CAACI,GAAG,CAACC,CAAC,IAAIJ,SAAS,CAACI,CAAC,CAAC,CAAC;EACvC;EACA,OAAOJ,SAAS,CAACD,KAAK,CAAC;AAC3B,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { CmsModelField } from "@webiny/api-headless-cms/types";
2
- import { CreatePathCallable } from "../../../plugins";
1
+ import type { CmsModelField } from "@webiny/api-headless-cms/types/index.js";
2
+ import type { CreatePathCallable } from "../../../plugins/index.js";
3
3
  interface FieldValueTransform {
4
4
  (value: any): any;
5
5
  }
@@ -1,5 +1,3 @@
1
- "use strict";
1
+ export {};
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
3
+ //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { CreatePathCallable } from \"~/plugins\";\n\ninterface FieldValueTransform {\n (value: any): any;\n}\n\nexport interface FieldParent {\n fieldId: string;\n multipleValues?: boolean;\n}\n\nexport interface Field\n extends Partial<Omit<CmsModelField, \"id\" | \"type\" | \"storageId\" | \"fieldId\">>,\n Pick<CmsModelField, \"id\" | \"type\" | \"storageId\" | \"fieldId\"> {\n /**\n * A list od fieldId of all parents of the current field.\n *\n * This is used to check if we need to iterate through an array of parent values.\n */\n parents: FieldParent[];\n /**\n * The method which creates a path for the filtering.\n *\n * Always exists. In most cases it will return some fixed value.\n * When having a CmsEntryFieldFilterPathPlugin then it is executed to create a path.\n */\n createPath: CreatePathCallable;\n /**\n * In most cases, return value of this method is what ever is the input.\n *\n * In some cases there might be a CmsFieldFilterValueTransformPlugin, which transforms value to a comparable one.\n * For example, time in format 15:45:58 is not comparable, so we transform it into the seconds and then compare.\n */\n transform: FieldValueTransform;\n /**\n * Is the field a system field?\n * System fields are built into the code and cannot be changed.\n */\n system: boolean;\n}\n\nexport interface FilterItemFromStorage {\n <T = any>(\n field: Partial<CmsModelField> &\n Pick<CmsModelField, \"fieldId\" | \"storageId\" | \"id\" | \"settings\" | \"type\">,\n value: any\n ): Promise<T>;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CreatePathCallable } from \"~/plugins/index.js\";\n\ninterface FieldValueTransform {\n (value: any): any;\n}\n\nexport interface FieldParent {\n fieldId: string;\n multipleValues?: boolean;\n}\n\nexport interface Field\n extends Partial<Omit<CmsModelField, \"id\" | \"type\" | \"storageId\" | \"fieldId\">>,\n Pick<CmsModelField, \"id\" | \"type\" | \"storageId\" | \"fieldId\"> {\n /**\n * A list od fieldId of all parents of the current field.\n *\n * This is used to check if we need to iterate through an array of parent values.\n */\n parents: FieldParent[];\n /**\n * The method which creates a path for the filtering.\n *\n * Always exists. In most cases it will return some fixed value.\n * When having a CmsEntryFieldFilterPathPlugin then it is executed to create a path.\n */\n createPath: CreatePathCallable;\n /**\n * In most cases, return value of this method is what ever is the input.\n *\n * In some cases there might be a CmsFieldFilterValueTransformPlugin, which transforms value to a comparable one.\n * For example, time in format 15:45:58 is not comparable, so we transform it into the seconds and then compare.\n */\n transform: FieldValueTransform;\n /**\n * Is the field a system field?\n * System fields are built into the code and cannot be changed.\n */\n system: boolean;\n}\n\nexport interface FilterItemFromStorage {\n <T = any>(\n field: Partial<CmsModelField> &\n Pick<CmsModelField, \"fieldId\" | \"storageId\" | \"id\" | \"settings\" | \"type\">,\n value: any\n ): Promise<T>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import type { CmsEntryListWhere } from "@webiny/api-headless-cms/types/index.js";
2
+ export declare const getWhereValues: (value: unknown, condition: "AND" | "OR") => CmsEntryListWhere[];
@@ -0,0 +1,16 @@
1
+ import WebinyError from "@webiny/error";
2
+ export const getWhereValues = (value, condition) => {
3
+ const values = value;
4
+ if (!Array.isArray(values)) {
5
+ throw new WebinyError(`Trying to run filtering with "${condition}", but the value sent is not an array.`, `MALFORMED_${condition}_CONDITION`, {
6
+ value
7
+ });
8
+ } else if (values.length === 0) {
9
+ throw new WebinyError(`Trying to run filtering with "${condition}", but the value sent is empty array.`, `MALFORMED_${condition}_CONDITION`, {
10
+ value
11
+ });
12
+ }
13
+ return values;
14
+ };
15
+
16
+ //# sourceMappingURL=values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["WebinyError","getWhereValues","value","condition","values","Array","isArray","length"],"sources":["values.ts"],"sourcesContent":["import type { CmsEntryListWhere } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\n\nexport const getWhereValues = (value: unknown, condition: \"AND\" | \"OR\") => {\n const values = value as CmsEntryListWhere[] | undefined;\n if (!Array.isArray(values)) {\n throw new WebinyError(\n `Trying to run filtering with \"${condition}\", but the value sent is not an array.`,\n `MALFORMED_${condition}_CONDITION`,\n {\n value\n }\n );\n } else if (values.length === 0) {\n throw new WebinyError(\n `Trying to run filtering with \"${condition}\", but the value sent is empty array.`,\n `MALFORMED_${condition}_CONDITION`,\n {\n value\n }\n );\n }\n return values;\n};\n"],"mappings":"AACA,OAAOA,WAAW,MAAM,eAAe;AAEvC,OAAO,MAAMC,cAAc,GAAGA,CAACC,KAAc,EAAEC,SAAuB,KAAK;EACvE,MAAMC,MAAM,GAAGF,KAAwC;EACvD,IAAI,CAACG,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;IACxB,MAAM,IAAIJ,WAAW,CACjB,iCAAiCG,SAAS,wCAAwC,EAClF,aAAaA,SAAS,YAAY,EAClC;MACID;IACJ,CACJ,CAAC;EACL,CAAC,MAAM,IAAIE,MAAM,CAACG,MAAM,KAAK,CAAC,EAAE;IAC5B,MAAM,IAAIP,WAAW,CACjB,iCAAiCG,SAAS,uCAAuC,EACjF,aAAaA,SAAS,YAAY,EAClC;MACID;IACJ,CACJ,CAAC;EACL;EACA,OAAOE,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -1,23 +1,14 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.extractWhereParams = void 0;
7
-
8
- const extractWhereParams = key => {
9
- const result = key.split("_");
1
+ export const extractWhereParams = key => {
2
+ const isWbyAco = key.match("wbyAco_") !== null;
3
+ const result = key.replace("wbyAco_", "").split("_");
10
4
  const fieldId = result.shift();
11
-
12
5
  if (!fieldId) {
13
6
  return null;
14
7
  }
15
-
16
8
  const rawOp = result.length === 0 ? "eq" : result.join("_");
17
9
  /**
18
10
  * When rawOp is not, it means it is equal negated so just return that.
19
11
  */
20
-
21
12
  if (rawOp === "not") {
22
13
  return {
23
14
  fieldId,
@@ -25,14 +16,13 @@ const extractWhereParams = key => {
25
16
  negate: true
26
17
  };
27
18
  }
28
-
29
19
  const negate = rawOp.match("not_") !== null;
30
20
  const operation = rawOp.replace("not_", "");
31
21
  return {
32
- fieldId,
22
+ fieldId: isWbyAco ? `wbyAco_${fieldId}` : fieldId,
33
23
  operation,
34
24
  negate
35
25
  };
36
26
  };
37
27
 
38
- exports.extractWhereParams = extractWhereParams;
28
+ //# sourceMappingURL=where.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["extractWhereParams","key","result","split","fieldId","shift","rawOp","length","join","operation","negate","match","replace"],"sources":["where.ts"],"sourcesContent":["export const extractWhereParams = (key: string) => {\n const result = key.split(\"_\");\n const fieldId = result.shift();\n if (!fieldId) {\n return null;\n }\n const rawOp = result.length === 0 ? \"eq\" : result.join(\"_\");\n /**\n * When rawOp is not, it means it is equal negated so just return that.\n */\n if (rawOp === \"not\") {\n return {\n fieldId,\n operation: \"eq\",\n negate: true\n };\n }\n const negate = rawOp.match(\"not_\") !== null;\n const operation = rawOp.replace(\"not_\", \"\");\n return {\n fieldId,\n operation,\n negate\n };\n};\n"],"mappings":";;;;;;;AAAO,MAAMA,kBAAkB,GAAIC,GAAD,IAAiB;EAC/C,MAAMC,MAAM,GAAGD,GAAG,CAACE,KAAJ,CAAU,GAAV,CAAf;EACA,MAAMC,OAAO,GAAGF,MAAM,CAACG,KAAP,EAAhB;;EACA,IAAI,CAACD,OAAL,EAAc;IACV,OAAO,IAAP;EACH;;EACD,MAAME,KAAK,GAAGJ,MAAM,CAACK,MAAP,KAAkB,CAAlB,GAAsB,IAAtB,GAA6BL,MAAM,CAACM,IAAP,CAAY,GAAZ,CAA3C;EACA;AACJ;AACA;;EACI,IAAIF,KAAK,KAAK,KAAd,EAAqB;IACjB,OAAO;MACHF,OADG;MAEHK,SAAS,EAAE,IAFR;MAGHC,MAAM,EAAE;IAHL,CAAP;EAKH;;EACD,MAAMA,MAAM,GAAGJ,KAAK,CAACK,KAAN,CAAY,MAAZ,MAAwB,IAAvC;EACA,MAAMF,SAAS,GAAGH,KAAK,CAACM,OAAN,CAAc,MAAd,EAAsB,EAAtB,CAAlB;EACA,OAAO;IACHR,OADG;IAEHK,SAFG;IAGHC;EAHG,CAAP;AAKH,CAxBM"}
1
+ {"version":3,"names":["extractWhereParams","key","isWbyAco","match","result","replace","split","fieldId","shift","rawOp","length","join","operation","negate"],"sources":["where.ts"],"sourcesContent":["export const extractWhereParams = (key: string) => {\n const isWbyAco = key.match(\"wbyAco_\") !== null;\n const result = key.replace(\"wbyAco_\", \"\").split(\"_\");\n const fieldId = result.shift();\n if (!fieldId) {\n return null;\n }\n const rawOp = result.length === 0 ? \"eq\" : result.join(\"_\");\n /**\n * When rawOp is not, it means it is equal negated so just return that.\n */\n if (rawOp === \"not\") {\n return {\n fieldId,\n operation: \"eq\",\n negate: true\n };\n }\n const negate = rawOp.match(\"not_\") !== null;\n const operation = rawOp.replace(\"not_\", \"\");\n return {\n fieldId: isWbyAco ? `wbyAco_${fieldId}` : fieldId,\n operation,\n negate\n };\n};\n"],"mappings":"AAAA,OAAO,MAAMA,kBAAkB,GAAIC,GAAW,IAAK;EAC/C,MAAMC,QAAQ,GAAGD,GAAG,CAACE,KAAK,CAAC,SAAS,CAAC,KAAK,IAAI;EAC9C,MAAMC,MAAM,GAAGH,GAAG,CAACI,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAACC,KAAK,CAAC,GAAG,CAAC;EACpD,MAAMC,OAAO,GAAGH,MAAM,CAACI,KAAK,CAAC,CAAC;EAC9B,IAAI,CAACD,OAAO,EAAE;IACV,OAAO,IAAI;EACf;EACA,MAAME,KAAK,GAAGL,MAAM,CAACM,MAAM,KAAK,CAAC,GAAG,IAAI,GAAGN,MAAM,CAACO,IAAI,CAAC,GAAG,CAAC;EAC3D;AACJ;AACA;EACI,IAAIF,KAAK,KAAK,KAAK,EAAE;IACjB,OAAO;MACHF,OAAO;MACPK,SAAS,EAAE,IAAI;MACfC,MAAM,EAAE;IACZ,CAAC;EACL;EACA,MAAMA,MAAM,GAAGJ,KAAK,CAACN,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI;EAC3C,MAAMS,SAAS,GAAGH,KAAK,CAACJ,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;EAC3C,OAAO;IACHE,OAAO,EAAEL,QAAQ,GAAG,UAAUK,OAAO,EAAE,GAAGA,OAAO;IACjDK,SAAS;IACTC;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1,8 +1,7 @@
1
- import { CmsEntryStorageOperations } from "@webiny/api-headless-cms/types";
2
- import { Entity } from "dynamodb-toolbox";
3
- import { PluginsContainer } from "@webiny/plugins";
1
+ import type { PluginsContainer } from "@webiny/plugins";
2
+ import type { CmsEntryStorageOperations, IEntryEntity } from "../../types.js";
4
3
  export interface CreateEntriesStorageOperationsParams {
5
- entity: Entity<any>;
4
+ entity: IEntryEntity;
6
5
  plugins: PluginsContainer;
7
6
  }
8
7
  export declare const createEntriesStorageOperations: (params: CreateEntriesStorageOperationsParams) => CmsEntryStorageOperations;