@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
@@ -0,0 +1 @@
1
+ {"version":3,"names":["dot","CmsEntryFieldFilterPlugin","extractWhereParams","searchableJsonFilterCreate","plugin","fieldType","create","params","value","objectValue","valueFilterPlugins","field","parentField","filters","accessPatterns","key","undefined","whereParams","negate","operation","transformValueCallable","fieldId","result","path","fieldPathId","compareValue","transformValue","Array","isArray","push","name"],"sources":["searchableJsonFilterCreate.ts"],"sourcesContent":["import dot from \"dot-object\";\nimport type { CmsEntryFieldFilterPluginCreateResponse } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where.js\";\n\nexport const searchableJsonFilterCreate = () => {\n const plugin = new CmsEntryFieldFilterPlugin({\n fieldType: \"searchable-json\",\n create: params => {\n const { value: objectValue, valueFilterPlugins, field: parentField } = params;\n\n const filters = [];\n\n const accessPatterns = dot.dot(objectValue);\n\n for (const key in accessPatterns) {\n const value = accessPatterns[key];\n if (value === undefined) {\n continue;\n }\n\n const whereParams = extractWhereParams(key);\n if (!whereParams) {\n continue;\n }\n const { negate, operation } = whereParams;\n\n const transformValueCallable = (value: any) => {\n return value;\n };\n\n const fieldId = `${parentField.fieldId}.${whereParams.fieldId ?? key}`;\n\n const result: CmsEntryFieldFilterPluginCreateResponse = {\n field: parentField,\n path: `values.${fieldId}`,\n fieldPathId: `values.${fieldId}`,\n negate,\n plugin: valueFilterPlugins[operation],\n compareValue: value,\n transformValue: transformValueCallable\n };\n\n if (!result) {\n continue;\n }\n if (Array.isArray(result)) {\n filters.push(...result);\n continue;\n }\n\n filters.push(result);\n }\n return filters;\n }\n });\n\n plugin.name = `headless-cms.ddb.filter.searchable-json`;\n\n return plugin;\n};\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,YAAY;AAE5B,SAASC,yBAAyB;AAClC,SAASC,kBAAkB;AAE3B,OAAO,MAAMC,0BAA0B,GAAGA,CAAA,KAAM;EAC5C,MAAMC,MAAM,GAAG,IAAIH,yBAAyB,CAAC;IACzCI,SAAS,EAAE,iBAAiB;IAC5BC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,KAAK,EAAEC,WAAW;QAAEC,kBAAkB;QAAEC,KAAK,EAAEC;MAAY,CAAC,GAAGL,MAAM;MAE7E,MAAMM,OAAO,GAAG,EAAE;MAElB,MAAMC,cAAc,GAAGd,GAAG,CAACA,GAAG,CAACS,WAAW,CAAC;MAE3C,KAAK,MAAMM,GAAG,IAAID,cAAc,EAAE;QAC9B,MAAMN,KAAK,GAAGM,cAAc,CAACC,GAAG,CAAC;QACjC,IAAIP,KAAK,KAAKQ,SAAS,EAAE;UACrB;QACJ;QAEA,MAAMC,WAAW,GAAGf,kBAAkB,CAACa,GAAG,CAAC;QAC3C,IAAI,CAACE,WAAW,EAAE;UACd;QACJ;QACA,MAAM;UAAEC,MAAM;UAAEC;QAAU,CAAC,GAAGF,WAAW;QAEzC,MAAMG,sBAAsB,GAAIZ,KAAU,IAAK;UAC3C,OAAOA,KAAK;QAChB,CAAC;QAED,MAAMa,OAAO,GAAG,GAAGT,WAAW,CAACS,OAAO,IAAIJ,WAAW,CAACI,OAAO,IAAIN,GAAG,EAAE;QAEtE,MAAMO,MAA+C,GAAG;UACpDX,KAAK,EAAEC,WAAW;UAClBW,IAAI,EAAE,UAAUF,OAAO,EAAE;UACzBG,WAAW,EAAE,UAAUH,OAAO,EAAE;UAChCH,MAAM;UACNd,MAAM,EAAEM,kBAAkB,CAACS,SAAS,CAAC;UACrCM,YAAY,EAAEjB,KAAK;UACnBkB,cAAc,EAAEN;QACpB,CAAC;QAED,IAAI,CAACE,MAAM,EAAE;UACT;QACJ;QACA,IAAIK,KAAK,CAACC,OAAO,CAACN,MAAM,CAAC,EAAE;UACvBT,OAAO,CAACgB,IAAI,CAAC,GAAGP,MAAM,CAAC;UACvB;QACJ;QAEAT,OAAO,CAACgB,IAAI,CAACP,MAAM,CAAC;MACxB;MACA,OAAOT,OAAO;IAClB;EACJ,CAAC,CAAC;EAEFT,MAAM,CAAC0B,IAAI,GAAG,yCAAyC;EAEvD,OAAO1B,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -1,12 +1,12 @@
1
- import { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
2
- import { Field } from "./types";
3
- import { PluginsContainer } from "@webiny/plugins";
4
- interface Params {
1
+ import type { CmsEntry, CmsEntryValues, CmsModel } from "@webiny/api-headless-cms/types/index.js";
2
+ import type { Field } from "./types.js";
3
+ import type { PluginsContainer } from "@webiny/plugins";
4
+ interface Params<T extends CmsEntryValues = CmsEntryValues> {
5
5
  model: CmsModel;
6
- items: CmsEntry[];
6
+ items: CmsEntry<T>[];
7
7
  sort?: string[];
8
8
  fields: Record<string, Field>;
9
9
  plugins: PluginsContainer;
10
10
  }
11
- export declare const sort: (params: Params) => CmsEntry[];
11
+ export declare const sort: <T extends CmsEntryValues = CmsEntryValues>(params: Params<T>) => CmsEntry<T>[];
12
12
  export {};
@@ -1,15 +1,8 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.sort = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- var _dotProp = _interopRequireDefault(require("dot-prop"));
10
- var _sortBy = _interopRequireDefault(require("lodash/sortBy"));
11
- var _extractSort = require("./extractSort");
12
- const sort = params => {
1
+ import WebinyError from "@webiny/error";
2
+ import dotProp from "dot-prop";
3
+ import lodashSortBy from "lodash/sortBy.js";
4
+ import { extractSort } from "./extractSort.js";
5
+ export const sort = params => {
13
6
  const {
14
7
  model,
15
8
  items,
@@ -22,13 +15,13 @@ const sort = params => {
22
15
  } else if (sort.length === 0) {
23
16
  sort.push("savedOn_DESC");
24
17
  } else if (sort.length > 1) {
25
- throw new _error.default("Sorting is limited to a single field.", "SORT_MULTIPLE_FIELDS_ERROR", {
26
- sort: sort
18
+ throw new WebinyError("Sorting is limited to a single field on DynamoDB only system.", "SORT_MULTIPLE_FIELDS_ERROR", {
19
+ sort
27
20
  });
28
21
  }
29
22
  const [firstSort] = sort;
30
23
  if (!firstSort) {
31
- throw new _error.default("Empty sort array item.", "SORT_EMPTY_ERROR", {
24
+ throw new WebinyError("Empty sort array item.", "SORT_EMPTY_ERROR", {
32
25
  sort
33
26
  });
34
27
  }
@@ -37,7 +30,7 @@ const sort = params => {
37
30
  field,
38
31
  valuePath,
39
32
  reverse
40
- } = (0, _extractSort.extractSort)({
33
+ } = extractSort({
41
34
  model,
42
35
  sortBy: firstSort,
43
36
  fields,
@@ -46,16 +39,20 @@ const sort = params => {
46
39
  const itemsToSort = items.map(item => {
47
40
  return {
48
41
  id: item.id,
49
- value: field.transform(_dotProp.default.get(item, valuePath))
42
+ value: field.transform(dotProp.get(item, valuePath))
50
43
  };
51
44
  });
52
- const sortedItems = (0, _sortBy.default)(itemsToSort, "value");
45
+ const sortedItems = lodashSortBy(itemsToSort, "value");
53
46
  const newItems = sortedItems.map(s => {
54
47
  const item = items.find(i => i.id === s.id);
55
48
  if (item) {
56
49
  return item;
57
50
  }
58
- 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", {
59
56
  id: s.id,
60
57
  sortingBy: fieldId,
61
58
  reverse
@@ -66,4 +63,5 @@ const sort = params => {
66
63
  }
67
64
  return newItems.reverse();
68
65
  };
69
- exports.sort = sort;
66
+
67
+ //# sourceMappingURL=sort.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["sort","params","model","items","fields","plugins","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, CmsModel } 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\";\nimport { PluginsContainer } from \"@webiny/plugins\";\n\ninterface Params {\n model: CmsModel;\n items: CmsEntry[];\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 = (params: Params): CmsEntry[] => {\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.\",\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 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 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;AAiBO,MAAMA,IAAI,GAAIC,MAAc,IAAiB;EAChD,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,CAACM,MAAM,KAAK,CAAC,EAAE;IAC1BN,IAAI,CAACO,IAAI,CAAC,cAAc,CAAC;EAC7B,CAAC,MAAM,IAAIP,IAAI,CAACM,MAAM,GAAG,CAAC,EAAE;IACxB,MAAM,IAAIE,cAAW,CACjB,uCAAuC,EACvC,4BAA4B,EAC5B;MACIR,IAAI,EAAEA;IACV,CAAC,CACJ;EACL;EACA,MAAM,CAACS,SAAS,CAAC,GAAGT,IAAI;EACxB,IAAI,CAACS,SAAS,EAAE;IACZ,MAAM,IAAID,cAAW,CAAC,wBAAwB,EAAE,kBAAkB,EAAE;MAChER;IACJ,CAAC,CAAC;EACN;EAEA,MAAM;IAAEU,OAAO;IAAEC,KAAK;IAAEC,SAAS;IAAEC;EAAQ,CAAC,GAAG,IAAAC,wBAAW,EAAC;IACvDZ,KAAK;IACLa,MAAM,EAAEN,SAAS;IACjBL,MAAM;IACNC;EACJ,CAAC,CAAC;EAEF,MAAMW,WAAW,GAAGb,KAAK,CAACc,GAAG,CAACC,IAAI,IAAI;IAClC,OAAO;MACHC,EAAE,EAAED,IAAI,CAACC,EAAE;MACXC,KAAK,EAAET,KAAK,CAACU,SAAS,CAACC,gBAAO,CAACC,GAAG,CAACL,IAAI,EAAEN,SAAS,CAAC;IACvD,CAAC;EACL,CAAC,CAAC;EACF,MAAMY,WAAyB,GAAG,IAAAC,eAAY,EAACT,WAAW,EAAE,OAAO,CAAC;EACpE,MAAMU,QAAQ,GAAGF,WAAW,CAACP,GAAG,CAACU,CAAC,IAAI;IAClC,MAAMT,IAAI,GAAGf,KAAK,CAACyB,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACV,EAAE,KAAKQ,CAAC,CAACR,EAAE,CAAC;IAC3C,IAAID,IAAI,EAAE;MACN,OAAOA,IAAI;IACf;IACA,MAAM,IAAIV,cAAW,CACjB,oDAAoD,EACpD,qBAAqB,EACrB;MACIW,EAAE,EAAEQ,CAAC,CAACR,EAAE;MACRW,SAAS,EAAEpB,OAAO;MAClBG;IACJ,CAAC,CACJ;EACL,CAAC,CAAC;EACF,IAAI,CAACA,OAAO,EAAE;IACV,OAAOa,QAAQ;EACnB;EACA,OAAOA,QAAQ,CAACb,OAAO,EAAE;AAC7B,CAAC;AAAC"}
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,CAACM,MAAM,KAAK,CAAC,EAAE;IAC1BN,IAAI,CAACO,IAAI,CAAC,cAAc,CAAC;EAC7B,CAAC,MAAM,IAAIP,IAAI,CAACM,MAAM,GAAG,CAAC,EAAE;IACxB,MAAM,IAAIV,WAAW,CACjB,+DAA+D,EAC/D,4BAA4B,EAC5B;MACII;IACJ,CACJ,CAAC;EACL;EACA,MAAM,CAACQ,SAAS,CAAC,GAAGR,IAAI;EACxB,IAAI,CAACQ,SAAS,EAAE;IACZ,MAAM,IAAIZ,WAAW,CAAC,wBAAwB,EAAE,kBAAkB,EAAE;MAChEI;IACJ,CAAC,CAAC;EACN;EAEA,MAAM;IAAES,OAAO;IAAEC,KAAK;IAAEC,SAAS;IAAEC;EAAQ,CAAC,GAAGb,WAAW,CAAC;IACvDG,KAAK;IACLW,MAAM,EAAEL,SAAS;IACjBJ,MAAM;IACNC;EACJ,CAAC,CAAC;EAEF,MAAMS,WAAW,GAAGX,KAAK,CAACY,GAAG,CAACC,IAAI,IAAI;IAClC,OAAO;MACHC,EAAE,EAAED,IAAI,CAACC,EAAE;MACXC,KAAK,EAAER,KAAK,CAACS,SAAS,CAACtB,OAAO,CAACuB,GAAG,CAACJ,IAAI,EAAEL,SAAS,CAAC;IACvD,CAAC;EACL,CAAC,CAAC;EACF,MAAMU,WAAyB,GAAGvB,YAAY,CAACgB,WAAW,EAAE,OAAO,CAAC;EACpE,MAAMQ,QAAQ,GAAGD,WAAW,CAACN,GAAG,CAACQ,CAAC,IAAI;IAClC,MAAMP,IAAI,GAAGb,KAAK,CAACqB,IAAI,CAACC,CAAC,IAAIA,CAAC,CAACR,EAAE,KAAKM,CAAC,CAACN,EAAE,CAAC;IAC3C,IAAID,IAAI,EAAE;MACN,OAAOA,IAAI;IACf;IACA;AACR;AACA;AACA;IACQ,MAAM,IAAIpB,WAAW,CACjB,oDAAoD,EACpD,qBAAqB,EACrB;MACIqB,EAAE,EAAEM,CAAC,CAACN,EAAE;MACRS,SAAS,EAAEjB,OAAO;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,70 +1,116 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createSystemFields = void 0;
7
- const createSystemFields = () => {
8
- 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({
9
27
  id: "id",
10
28
  type: "text",
11
29
  storageId: "id",
12
30
  fieldId: "id",
13
31
  label: "ID"
14
- }, {
32
+ }), createModelField({
15
33
  id: "entryId",
16
34
  type: "text",
17
35
  storageId: "entryId",
18
36
  fieldId: "entryId",
19
37
  label: "Entry ID"
20
- }, {
21
- id: "createdOn",
22
- type: "datetime",
23
- storageId: "createdOn",
24
- fieldId: "createdOn",
25
- label: "Created On"
26
- }, {
27
- id: "savedOn",
28
- type: "datetime",
29
- storageId: "savedOn",
30
- fieldId: "savedOn",
31
- label: "Saved On"
32
- }, {
33
- id: "createdBy",
34
- type: "plainObject",
35
- storageId: "createdBy",
36
- fieldId: "createdBy",
37
- label: "Created By",
38
- settings: {
39
- path: "createdBy.id"
40
- }
41
- }, {
38
+ }), ...onMetaFields, ...byMetaFields, createModelField({
42
39
  id: "meta",
43
40
  type: "plainObject",
44
41
  storageId: "meta",
45
42
  fieldId: "meta",
46
43
  label: "Meta"
47
- }, {
48
- id: "ownedBy",
49
- type: "plainObject",
50
- storageId: "ownedBy",
51
- fieldId: "ownedBy",
52
- label: "Owned By",
44
+ }), createModelField({
45
+ id: "wbyAco_location",
46
+ type: "object",
47
+ storageId: "location",
48
+ label: "Location",
49
+ fieldId: "wbyAco_location",
53
50
  settings: {
54
- 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
+ })]
55
61
  }
56
- }, {
62
+ }), createModelField({
57
63
  id: "version",
58
64
  type: "number",
59
65
  storageId: "version",
60
66
  fieldId: "version",
61
67
  label: "Version"
62
- }, {
68
+ }), createModelField({
63
69
  id: "status",
64
70
  type: "text",
65
71
  storageId: "status",
66
72
  fieldId: "status",
67
73
  label: "Status"
68
- }];
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
+ })];
69
114
  };
70
- exports.createSystemFields = createSystemFields;
115
+
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,IAAI;IACRC,IAAI,EAAE,MAAM;IACZC,SAAS,EAAE,IAAI;IACfC,OAAO,EAAE,IAAI;IACbC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,MAAM;IACZC,SAAS,EAAE,SAAS;IACpBC,OAAO,EAAE,SAAS;IAClBC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,WAAW;IACfC,IAAI,EAAE,UAAU;IAChBC,SAAS,EAAE,WAAW;IACtBC,OAAO,EAAE,WAAW;IACpBC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,UAAU;IAChBC,SAAS,EAAE,SAAS;IACpBC,OAAO,EAAE,SAAS;IAClBC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,WAAW;IACfC,IAAI,EAAE,aAAa;IACnBC,SAAS,EAAE,WAAW;IACtBC,OAAO,EAAE,WAAW;IACpBC,KAAK,EAAE,YAAY;IACnBC,QAAQ,EAAE;MACNC,IAAI,EAAE;IACV;EACJ,CAAC,EACD;IACIN,EAAE,EAAE,MAAM;IACVC,IAAI,EAAE,aAAa;IACnBC,SAAS,EAAE,MAAM;IACjBC,OAAO,EAAE,MAAM;IACfC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,aAAa;IACnBC,SAAS,EAAE,SAAS;IACpBC,OAAO,EAAE,SAAS;IAClBC,KAAK,EAAE,UAAU;IACjBC,QAAQ,EAAE;MACNC,IAAI,EAAE;IACV;EACJ,CAAC,EACD;IACIN,EAAE,EAAE,SAAS;IACbC,IAAI,EAAE,QAAQ;IACdC,SAAS,EAAE,SAAS;IACpBC,OAAO,EAAE,SAAS;IAClBC,KAAK,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,QAAQ;IACZC,IAAI,EAAE,MAAM;IACZC,SAAS,EAAE,QAAQ;IACnBC,OAAO,EAAE,QAAQ;IACjBC,KAAK,EAAE;EACX,CAAC,CACJ;AACL,CAAC;AAAC"}
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":"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","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,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.transformValue = void 0;
7
- const transformValue = ({
1
+ export const transformValue = ({
8
2
  value,
9
3
  transform
10
4
  }) => {
@@ -13,4 +7,5 @@ const transformValue = ({
13
7
  }
14
8
  return transform(value);
15
9
  };
16
- exports.transformValue = transformValue;
10
+
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,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;AAAC"}
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,11 +1,11 @@
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
  }
6
6
  export interface FieldParent {
7
7
  fieldId: string;
8
- multipleValues?: boolean;
8
+ list?: boolean;
9
9
  }
10
10
  export interface Field extends Partial<Omit<CmsModelField, "id" | "type" | "storageId" | "fieldId">>, Pick<CmsModelField, "id" | "type" | "storageId" | "fieldId"> {
11
11
  /**
@@ -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 list?: 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":[]}
@@ -1,2 +1,2 @@
1
- import { CmsEntryListWhere } from "@webiny/api-headless-cms/types";
1
+ import type { CmsEntryListWhere } from "@webiny/api-headless-cms/types/index.js";
2
2
  export declare const getWhereValues: (value: unknown, condition: "AND" | "OR") => CmsEntryListWhere[];
@@ -1,22 +1,16 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.getWhereValues = void 0;
8
- var _error = _interopRequireDefault(require("@webiny/error"));
9
- const getWhereValues = (value, condition) => {
1
+ import WebinyError from "@webiny/error";
2
+ export const getWhereValues = (value, condition) => {
10
3
  const values = value;
11
4
  if (!Array.isArray(values)) {
12
- throw new _error.default(`Trying to run filtering with "${condition}", but the value sent is not an array.`, `MALFORMED_${condition}_CONDITION`, {
5
+ throw new WebinyError(`Trying to run filtering with "${condition}", but the value sent is not an array.`, `MALFORMED_${condition}_CONDITION`, {
13
6
  value
14
7
  });
15
8
  } else if (values.length === 0) {
16
- throw new _error.default(`Trying to run filtering with "${condition}", but the value sent is empty array.`, `MALFORMED_${condition}_CONDITION`, {
9
+ throw new WebinyError(`Trying to run filtering with "${condition}", but the value sent is empty array.`, `MALFORMED_${condition}_CONDITION`, {
17
10
  value
18
11
  });
19
12
  }
20
13
  return values;
21
14
  };
22
- exports.getWhereValues = getWhereValues;
15
+
16
+ //# sourceMappingURL=values.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getWhereValues","value","condition","values","Array","isArray","WebinyError","length"],"sources":["values.ts"],"sourcesContent":["import { CmsEntryListWhere } from \"@webiny/api-headless-cms/types\";\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;AAEO,MAAMA,cAAc,GAAG,CAACC,KAAc,EAAEC,SAAuB,KAAK;EACvE,MAAMC,MAAM,GAAGF,KAAwC;EACvD,IAAI,CAACG,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;IACxB,MAAM,IAAIG,cAAW,CAChB,iCAAgCJ,SAAU,wCAAuC,EACjF,aAAYA,SAAU,YAAW,EAClC;MACID;IACJ,CAAC,CACJ;EACL,CAAC,MAAM,IAAIE,MAAM,CAACI,MAAM,KAAK,CAAC,EAAE;IAC5B,MAAM,IAAID,cAAW,CAChB,iCAAgCJ,SAAU,uCAAsC,EAChF,aAAYA,SAAU,YAAW,EAClC;MACID;IACJ,CAAC,CACJ;EACL;EACA,OAAOE,MAAM;AACjB,CAAC;AAAC"}
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,11 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.extractWhereParams = void 0;
7
- const extractWhereParams = key => {
8
- const result = key.split("_");
1
+ export const extractWhereParams = key => {
2
+ const isWbyAco = key.match("wbyAco_") !== null;
3
+ const result = key.replace("wbyAco_", "").split("_");
9
4
  const fieldId = result.shift();
10
5
  if (!fieldId) {
11
6
  return null;
@@ -24,9 +19,10 @@ const extractWhereParams = key => {
24
19
  const negate = rawOp.match("not_") !== null;
25
20
  const operation = rawOp.replace("not_", "");
26
21
  return {
27
- fieldId,
22
+ fieldId: isWbyAco ? `wbyAco_${fieldId}` : fieldId,
28
23
  operation,
29
24
  negate
30
25
  };
31
26
  };
32
- exports.extractWhereParams = extractWhereParams;
27
+
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,GAAW,IAAK;EAC/C,MAAMC,MAAM,GAAGD,GAAG,CAACE,KAAK,CAAC,GAAG,CAAC;EAC7B,MAAMC,OAAO,GAAGF,MAAM,CAACG,KAAK,EAAE;EAC9B,IAAI,CAACD,OAAO,EAAE;IACV,OAAO,IAAI;EACf;EACA,MAAME,KAAK,GAAGJ,MAAM,CAACK,MAAM,KAAK,CAAC,GAAG,IAAI,GAAGL,MAAM,CAACM,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,CAACK,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI;EAC3C,MAAMF,SAAS,GAAGH,KAAK,CAACM,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;EAC3C,OAAO;IACHR,OAAO;IACPK,SAAS;IACTC;EACJ,CAAC;AACL,CAAC;AAAC"}
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 { Entity } from "dynamodb-toolbox";
2
- import { PluginsContainer } from "@webiny/plugins";
3
- import { CmsEntryStorageOperations } from "../../types";
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;