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

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 (109) hide show
  1. package/definitions/entry.js +3 -5
  2. package/definitions/entry.js.map +1 -1
  3. package/definitions/group.js +0 -5
  4. package/definitions/group.js.map +1 -1
  5. package/definitions/model.js +22 -5
  6. package/definitions/model.js.map +1 -1
  7. package/definitions/settings.js +0 -5
  8. package/definitions/settings.js.map +1 -1
  9. package/definitions/system.js +0 -5
  10. package/definitions/system.js.map +1 -1
  11. package/definitions/table.js +0 -3
  12. package/definitions/table.js.map +1 -1
  13. package/dynamoDb/index.d.ts +1 -1
  14. package/dynamoDb/index.js +0 -7
  15. package/dynamoDb/index.js.map +1 -1
  16. package/dynamoDb/path/plainObject.js +1 -8
  17. package/dynamoDb/path/plainObject.js.map +1 -1
  18. package/dynamoDb/storage/date.d.ts +2 -1
  19. package/dynamoDb/storage/date.js +1 -19
  20. package/dynamoDb/storage/date.js.map +1 -1
  21. package/dynamoDb/storage/longText.d.ts +1 -1
  22. package/dynamoDb/storage/longText.js +7 -17
  23. package/dynamoDb/storage/longText.js.map +1 -1
  24. package/dynamoDb/storage/richText.d.ts +1 -1
  25. package/dynamoDb/storage/richText.js +0 -18
  26. package/dynamoDb/storage/richText.js.map +1 -1
  27. package/dynamoDb/transformValue/datetime.js +1 -8
  28. package/dynamoDb/transformValue/datetime.js.map +1 -1
  29. package/index.js +5 -24
  30. package/index.js.map +1 -1
  31. package/operations/entry/dataLoaders.js +1 -44
  32. package/operations/entry/dataLoaders.js.map +1 -1
  33. package/operations/entry/filtering/{createFilters.d.ts → createExpressions.d.ts} +9 -3
  34. package/operations/entry/filtering/createExpressions.js +176 -0
  35. package/operations/entry/filtering/createExpressions.js.map +1 -0
  36. package/operations/entry/filtering/createFields.d.ts +3 -7
  37. package/operations/entry/filtering/createFields.js +2 -21
  38. package/operations/entry/filtering/createFields.js.map +1 -1
  39. package/operations/entry/filtering/extractSort.d.ts +4 -0
  40. package/operations/entry/filtering/extractSort.js +23 -11
  41. package/operations/entry/filtering/extractSort.js.map +1 -1
  42. package/operations/entry/filtering/filter.d.ts +2 -3
  43. package/operations/entry/filtering/filter.js +79 -73
  44. package/operations/entry/filtering/filter.js.map +1 -1
  45. package/operations/entry/filtering/fullTextSearch.d.ts +2 -6
  46. package/operations/entry/filtering/fullTextSearch.js +2 -18
  47. package/operations/entry/filtering/fullTextSearch.js.map +1 -1
  48. package/operations/entry/filtering/getValue.js +0 -18
  49. package/operations/entry/filtering/getValue.js.map +1 -1
  50. package/operations/entry/filtering/index.js +0 -2
  51. package/operations/entry/filtering/index.js.map +1 -1
  52. package/operations/entry/filtering/mapPlugins.js +0 -8
  53. package/operations/entry/filtering/mapPlugins.js.map +1 -1
  54. package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -7
  55. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
  56. package/operations/entry/filtering/plugins/index.d.ts +1 -1
  57. package/operations/entry/filtering/plugins/index.js +0 -5
  58. package/operations/entry/filtering/plugins/index.js.map +1 -1
  59. package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -21
  60. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
  61. package/operations/entry/filtering/plugins/refFilterCreate.js +0 -18
  62. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
  63. package/operations/entry/filtering/sort.d.ts +4 -1
  64. package/operations/entry/filtering/sort.js +6 -17
  65. package/operations/entry/filtering/sort.js.map +1 -1
  66. package/operations/entry/filtering/systemFields.js +0 -2
  67. package/operations/entry/filtering/systemFields.js.map +1 -1
  68. package/operations/entry/filtering/transform.js +0 -3
  69. package/operations/entry/filtering/transform.js.map +1 -1
  70. package/operations/entry/filtering/values.d.ts +2 -0
  71. package/operations/entry/filtering/values.js +22 -0
  72. package/operations/entry/filtering/values.js.map +1 -0
  73. package/operations/entry/filtering/where.js +0 -6
  74. package/operations/entry/filtering/where.js.map +1 -1
  75. package/operations/entry/index.js +30 -102
  76. package/operations/entry/index.js.map +1 -1
  77. package/operations/entry/keys.js +0 -18
  78. package/operations/entry/keys.js.map +1 -1
  79. package/operations/entry/systemFields.js +0 -2
  80. package/operations/entry/systemFields.js.map +1 -1
  81. package/operations/group/index.js +2 -32
  82. package/operations/group/index.js.map +1 -1
  83. package/operations/model/index.js +0 -25
  84. package/operations/model/index.js.map +1 -1
  85. package/operations/settings/index.js +0 -24
  86. package/operations/settings/index.js.map +1 -1
  87. package/operations/system/index.js +0 -17
  88. package/operations/system/index.js.map +1 -1
  89. package/package.json +13 -13
  90. package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -14
  91. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
  92. package/plugins/CmsEntryFieldFilterPlugin.js +0 -7
  93. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
  94. package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
  95. package/plugins/CmsEntryFieldSortingPlugin.js +28 -0
  96. package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
  97. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
  98. package/plugins/CmsFieldFilterValueTransformPlugin.js +24 -0
  99. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
  100. package/plugins/index.d.ts +3 -0
  101. package/plugins/index.js +33 -2
  102. package/plugins/index.js.map +1 -1
  103. package/types.js +0 -1
  104. package/types.js.map +1 -1
  105. package/operations/entry/filtering/createFilters.js +0 -155
  106. package/operations/entry/filtering/createFilters.js.map +0 -1
  107. package/operations/entry/utils.d.ts +0 -36
  108. package/operations/entry/utils.js +0 -684
  109. package/operations/entry/utils.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["addArrayResult","target","result","r","some","t","push","find","input","paths","path","shift","undefined","value","length","Array","isArray","reduce","collection","v","getValue","split","Error","filtered","filter","Boolean","join"],"sources":["getValue.ts"],"sourcesContent":["const addArrayResult = (target: any[], result: any[]): void => {\n for (const r of result) {\n if (target.some(t => r === t)) {\n continue;\n }\n target.push(r);\n }\n};\n/**\n * A recursive function which goes through given input paths and returns the value in it.\n * In case a path is an array, it goes through the array of those values to get values further down the path line.\n */\nconst find = (target: Record<string, any>, input: string[]): any[] | undefined => {\n const paths = [...input];\n const path = paths.shift();\n\n if (!path) {\n return undefined;\n } else if (target[path] === undefined) {\n return undefined;\n }\n const value = target[path];\n if (paths.length === 0) {\n return value;\n } else if (Array.isArray(value)) {\n if (value.length === 0) {\n return undefined;\n }\n return value.reduce<any[]>((collection, v) => {\n const result = find(v, paths);\n if (result === undefined) {\n return collection;\n } else if (Array.isArray(result)) {\n addArrayResult(collection, result);\n return collection;\n }\n collection.push(result);\n return collection;\n }, []);\n }\n return find(value, paths);\n};\n/**\n * A wrapper function for the find function.\n * Basically it transforms input paths to an array (and runs various checks).\n */\nexport const getValue = (target: Record<string, any>, input: string | string[]): any => {\n const paths = Array.isArray(input) ? input : input.split(\".\");\n if (paths.length === 0) {\n throw new Error(`Path is empty!`);\n }\n const filtered = paths.filter(Boolean);\n if (paths.length !== filtered.length) {\n throw new Error(\n `Input path is different than the filtered empty path string. (${paths.join(\n \".\"\n )} to ${filtered.join(\".\")})`\n );\n }\n\n return find(target, paths);\n};\n"],"mappings":";;;;;;;AAAA,MAAMA,cAAc,GAAG,CAACC,MAAD,EAAgBC,MAAhB,KAAwC;EAC3D,KAAK,MAAMC,CAAX,IAAgBD,MAAhB,EAAwB;IACpB,IAAID,MAAM,CAACG,IAAP,CAAYC,CAAC,IAAIF,CAAC,KAAKE,CAAvB,CAAJ,EAA+B;MAC3B;IACH;;IACDJ,MAAM,CAACK,IAAP,CAAYH,CAAZ;EACH;AACJ,CAPD;AAQA;AACA;AACA;AACA;;;AACA,MAAMI,IAAI,GAAG,CAACN,MAAD,EAA8BO,KAA9B,KAAqE;EAC9E,MAAMC,KAAK,GAAG,CAAC,GA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AAwB;IACpB,MAAM,IAAIQ,KAAJ,CAAW,gBAAX,CAAN;EACH;;EACD,MAAMC,QAAQ,GAAGd,KAAK,CAACe,MAAN,CAAaC,OAAb,CAAjB;;EACA,IAAIhB,KAAK,CAACK,MAAN,KAAiBS,QAAQ,CAACT,MAA9B,EAAsC;IAClC,MAAM,IAAIQ,KAAJ,CACD,iEAAgEb,KAAK,CAACiB,IAAN,CAC7D,GAD6D,CAE/D,OAAMH,QAAQ,CAACG,IAAT,CAAc,GAAd,CAAmB,GAHzB,CAAN;EAKH;;EAED,OAAOnB,IAAI,CAACN,MAAD,EAASQ,KAAT,CAAX;AACH,CAfM"}
1
+ {"version":3,"names":["addArrayResult","target","result","r","some","t","push","find","input","paths","path","shift","undefined","value","length","Array","isArray","reduce","collection","v","getValue","split","Error","filtered","filter","Boolean","join"],"sources":["getValue.ts"],"sourcesContent":["const addArrayResult = (target: any[], result: any[]): void => {\n for (const r of result) {\n if (target.some(t => r === t)) {\n continue;\n }\n target.push(r);\n }\n};\n/**\n * A recursive function which goes through given input paths and returns the value in it.\n * In case a path is an array, it goes through the array of those values to get values further down the path line.\n */\nconst find = (target: Record<string, any>, input: string[]): any[] | undefined => {\n const paths = [...input];\n const path = paths.shift();\n\n if (!path) {\n return undefined;\n } else if (target[path] === undefined) {\n return undefined;\n }\n const value = target[path];\n if (paths.length === 0) {\n return value;\n } else if (Array.isArray(value)) {\n if (value.length === 0) {\n return undefined;\n }\n return value.reduce<any[]>((collection, v) => {\n const result = find(v, paths);\n if (result === undefined) {\n return collection;\n } else if (Array.isArray(result)) {\n addArrayResult(collection, result);\n return collection;\n }\n collection.push(result);\n return collection;\n }, []);\n }\n return find(value, paths);\n};\n/**\n * A wrapper function for the find function.\n * Basically it transforms input paths to an array (and runs various checks).\n */\nexport const getValue = (target: Record<string, any>, input: string | string[]): any => {\n const paths = Array.isArray(input) ? input : input.split(\".\");\n if (paths.length === 0) {\n throw new Error(`Path is empty!`);\n }\n const filtered = paths.filter(Boolean);\n if (paths.length !== filtered.length) {\n throw new Error(\n `Input path is different than the filtered empty path string. (${paths.join(\n \".\"\n )} to ${filtered.join(\".\")})`\n );\n }\n\n return find(target, paths);\n};\n"],"mappings":";;;;;;AAAA,MAAMA,cAAc,GAAG,CAACC,MAAa,EAAEC,MAAa,KAAW;EAC3D,KAAK,MAAMC,CAAC,IAAID,MAAM,EAAE;IACpB,IAAID,MAAM,CAACG,IAAI,CAACC,CAAC,IAAIF,CAAC,KAAKE,CAAC,CAAC,EAAE;MAC3B;IACJ;IACAJ,MAAM,CAACK,IAAI,CAACH,CAAC,CAAC;EAClB;AACJ,CAAC;AACD;AACA;AACA;AACA;AACA,MAAMI,IAAI,GAAG,CAACN,MAA2B,EAAEO,KAAe,KAAwB;EAC9E,MAAMC,KAAK,GAAG,CAAC,GAAGD,KAAK,CAAC;EACxB,MAAME,IAAI,GAAGD,KAAK,CAACE,KAAK,EAAE;EAE1B,IAAI,CAACD,IAAI,EAAE;IACP,OAAOE,SAAS;EACpB,CAAC,MAAM,IAAIX,MAAM,CAACS,IAAI,CAAC,KAAKE,SAAS,EAAE;IACnC,OAAOA,SAAS;EACpB;EACA,MAAMC,KAAK,GAAGZ,MAAM,CAACS,IAAI,CAAC;EAC1B,IAAID,KAAK,CAACK,MAAM,KAAK,CAAC,EAAE;IACpB,OAAOD,KAAK;EAChB,CAAC,MAAM,IAAIE,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,EAAE;IAC7B,IAAIA,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE;MACpB,OAAOF,SAAS;IACpB;IACA,OAAOC,KAAK,CAACI,MAAM,CAAQ,CAACC,UAAU,EAAEC,CAAC,KAAK;MAC1C,MAAMjB,MAAM,GAAGK,IAAI,CAACY,CAAC,EAAEV,KAAK,CAAC;MAC7B,IAAIP,MAAM,KAAKU,SAAS,EAAE;QACtB,OAAOM,UAAU;MACrB,CAAC,MAAM,IAAIH,KAAK,CAACC,OAAO,CAACd,MAAM,CAAC,EAAE;QAC9BF,cAAc,CAACkB,UAAU,EAAEhB,MAAM,CAAC;QAClC,OAAOgB,UAAU;MACrB;MACAA,UAAU,CAACZ,IAAI,CAACJ,MAAM,CAAC;MACvB,OAAOgB,UAAU;IACrB,CAAC,EAAE,EAAE,CAAC;EACV;EACA,OAAOX,IAAI,CAACM,KAAK,EAAEJ,KAAK,CAAC;AAC7B,CAAC;AACD;AACA;AACA;AACA;AACO,MAAMW,QAAQ,GAAG,CAACnB,MAA2B,EAAEO,KAAwB,KAAU;EACpF,MAAMC,KAAK,GAAGM,KAAK,CAACC,OAAO,CAACR,KAAK,CAAC,GAAGA,KAAK,GAAGA,KAAK,CAACa,KAAK,CAAC,GAAG,CAAC;EAC7D,IAAIZ,KAAK,CAACK,MAAM,KAAK,CAAC,EAAE;IACpB,MAAM,IAAIQ,KAAK,CAAE,gBAAe,CAAC;EACrC;EACA,MAAMC,QAAQ,GAAGd,KAAK,CAACe,MAAM,CAACC,OAAO,CAAC;EACtC,IAAIhB,KAAK,CAACK,MAAM,KAAKS,QAAQ,CAACT,MAAM,EAAE;IAClC,MAAM,IAAIQ,KAAK,CACV,iEAAgEb,KAAK,CAACiB,IAAI,CACvE,GAAG,CACL,OAAMH,QAAQ,CAACG,IAAI,CAAC,GAAG,CAAE,GAAE,CAChC;EACL;EAEA,OAAOnB,IAAI,CAACN,MAAM,EAAEQ,KAAK,CAAC;AAC9B,CAAC;AAAC"}
@@ -15,7 +15,5 @@ Object.defineProperty(exports, "sort", {
15
15
  return _sort.sort;
16
16
  }
17
17
  });
18
-
19
18
  var _filter = require("./filter");
20
-
21
19
  var _sort = require("./sort");
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { filter } from \"./filter\";\nexport { sort } from \"./sort\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AACA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { filter } from \"./filter\";\nexport { sort } from \"./sort\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA"}
@@ -1,14 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.getMappedPlugins = void 0;
9
-
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
9
  const getMappedPlugins = params => {
13
10
  const {
14
11
  plugins: pluginsContainer,
@@ -16,24 +13,19 @@ const getMappedPlugins = params => {
16
13
  property
17
14
  } = params;
18
15
  const plugins = pluginsContainer.byType(type);
19
-
20
16
  if (plugins.length === 0) {
21
17
  return {};
22
18
  }
23
-
24
19
  return plugins.reduce((collection, plugin) => {
25
20
  const key = plugin[property];
26
-
27
21
  if (typeof key !== "string") {
28
22
  throw new _error.default("Property to map the plugins on must be a string.", "PLUGIN_PROPERTY_ERROR", {
29
23
  type,
30
24
  property
31
25
  });
32
26
  }
33
-
34
27
  collection[key] = plugin;
35
28
  return collection;
36
29
  }, {});
37
30
  };
38
-
39
31
  exports.getMappedPlugins = getMappedPlugins;
@@ -1 +1 @@
1
- {"version":3,"names":["getMappedPlugins","params","plugins","pluginsContainer","type","property","byType","length","reduce","collection","plugin","key","WebinyError"],"sources":["mapPlugins.ts"],"sourcesContent":["import { Plugin, PluginsContainer } from \"@webiny/plugins/types\";\nimport WebinyError from \"@webiny/error\";\n\ninterface Params {\n plugins: PluginsContainer;\n type: string;\n property: string;\n}\nexport const getMappedPlugins = <T extends Plugin>(params: Params) => {\n const { plugins: pluginsContainer, type, property } = params;\n const plugins = pluginsContainer.byType<T>(type);\n if (plugins.length === 0) {\n return {};\n }\n return plugins.reduce<Record<string, T>>((collection, plugin) => {\n const key: keyof typeof plugin = plugin[property];\n if (typeof key !== \"string\") {\n throw new WebinyError(\n \"Property to map the plugins on must be a string.\",\n \"PLUGIN_PROPERTY_ERROR\",\n {\n type,\n property\n }\n );\n }\n collection[key] = plugin;\n return collection;\n }, {});\n};\n"],"mappings":";;;;;;;;;AACA;;AAOO,MAAMA,gBAAgB,GAAsBC,MAAnB,IAAsC;EAClE,MAAM;IAAEC,OAAO,EAAEC,gBAAX;IAA6BC,IAA7B;IAAmCC;EAAnC,IAAgDJ,MAAtD;EACA,MAAMC,OAAO,GAAGC,gBAAgB,CAACG,MAAjB,CAA2BF,IAA3B,CAAhB;;EACA,IAAIF,OAAO,CAACK,MAAR,KAAmB,CAAvB,EAA0B;IACtB,OAAO,EAAP;EACH;;EACD,OAAOL,OAAO,CAACM,MAAR,CAAkC,CAACC,UAAD,EAAaC,MAAb,KAAwB;IAC7D,MAAMC,GAAwB,GAAGD,MAAM,CAACL,QAAD,CAAvC;;IACA,IAAI,OAAOM,GAAP,KAAe,QAAnB,EAA6B;MACzB,MAAM,IAAIC,cAAJ,CACF,kDADE,EAEF,uBAFE,EAGF;QACIR,IADJ;QAEIC;MAFJ,CAHE,CAAN;IAQH;;IACDI,UAAU,CAACE,GAAD,CAAV,GAAkBD,MAAlB;IACA,OAAOD,UAAP;EACH,CAdM,EAcJ,EAdI,CAAP;AAeH,CArBM"}
1
+ {"version":3,"names":["getMappedPlugins","params","plugins","pluginsContainer","type","property","byType","length","reduce","collection","plugin","key","WebinyError"],"sources":["mapPlugins.ts"],"sourcesContent":["import { Plugin, PluginsContainer } from \"@webiny/plugins/types\";\nimport WebinyError from \"@webiny/error\";\n\ninterface Params {\n plugins: PluginsContainer;\n type: string;\n property: string;\n}\nexport const getMappedPlugins = <T extends Plugin>(params: Params) => {\n const { plugins: pluginsContainer, type, property } = params;\n const plugins = pluginsContainer.byType<T>(type);\n if (plugins.length === 0) {\n return {};\n }\n return plugins.reduce<Record<string, T>>((collection, plugin) => {\n const key: keyof typeof plugin = plugin[property];\n if (typeof key !== \"string\") {\n throw new WebinyError(\n \"Property to map the plugins on must be a string.\",\n \"PLUGIN_PROPERTY_ERROR\",\n {\n type,\n property\n }\n );\n }\n collection[key] = plugin;\n return collection;\n }, {});\n};\n"],"mappings":";;;;;;;AACA;AAOO,MAAMA,gBAAgB,GAAsBC,MAAc,IAAK;EAClE,MAAM;IAAEC,OAAO,EAAEC,gBAAgB;IAAEC,IAAI;IAAEC;EAAS,CAAC,GAAGJ,MAAM;EAC5D,MAAMC,OAAO,GAAGC,gBAAgB,CAACG,MAAM,CAAIF,IAAI,CAAC;EAChD,IAAIF,OAAO,CAACK,MAAM,KAAK,CAAC,EAAE;IACtB,OAAO,CAAC,CAAC;EACb;EACA,OAAOL,OAAO,CAACM,MAAM,CAAoB,CAACC,UAAU,EAAEC,MAAM,KAAK;IAC7D,MAAMC,GAAwB,GAAGD,MAAM,CAACL,QAAQ,CAAC;IACjD,IAAI,OAAOM,GAAG,KAAK,QAAQ,EAAE;MACzB,MAAM,IAAIC,cAAW,CACjB,kDAAkD,EAClD,uBAAuB,EACvB;QACIR,IAAI;QACJC;MACJ,CAAC,CACJ;IACL;IACAI,UAAU,CAACE,GAAG,CAAC,GAAGD,MAAM;IACxB,OAAOD,UAAU;EACrB,CAAC,EAAE,CAAC,CAAC,CAAC;AACV,CAAC;AAAC"}
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createDefaultFilterCreate = void 0;
9
-
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
9
  var _CmsEntryFieldFilterPlugin = require("../../../../plugins/CmsEntryFieldFilterPlugin");
13
-
14
10
  const createDefaultFilterCreate = () => {
15
11
  return new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
16
12
  fieldType: _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin.ALL,
@@ -23,13 +19,11 @@ const createDefaultFilterCreate = () => {
23
19
  valueFilterPlugins
24
20
  } = params;
25
21
  const plugin = valueFilterPlugins[params.operation];
26
-
27
22
  if (!plugin) {
28
23
  throw new _error.default(`Missing ValueFilterPlugin for operation "${params.operation}".`, "MISSING_OPERATION_PLUGIN", {
29
24
  operation: params.operation
30
25
  });
31
26
  }
32
-
33
27
  return {
34
28
  negate,
35
29
  transformValue,
@@ -44,5 +38,4 @@ const createDefaultFilterCreate = () => {
44
38
  }
45
39
  });
46
40
  };
47
-
48
41
  exports.createDefaultFilterCreate = createDefaultFilterCreate;
@@ -1 +1 @@
1
- {"version":3,"names":["createDefaultFilterCreate","CmsEntryFieldFilterPlugin","fieldType","ALL","create","params","negate","transformValue","field","compareValue","valueFilterPlugins","plugin","operation","WebinyError","fieldPathId","parents","map","f","fieldId","join","path","createPath"],"sources":["defaultFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin\";\n\nexport const createDefaultFilterCreate = () => {\n return new CmsEntryFieldFilterPlugin({\n fieldType: CmsEntryFieldFilterPlugin.ALL,\n create: params => {\n const { negate, transformValue, field, compareValue, valueFilterPlugins } = params;\n const plugin = valueFilterPlugins[params.operation];\n if (!plugin) {\n throw new WebinyError(\n `Missing ValueFilterPlugin for operation \"${params.operation}\".`,\n \"MISSING_OPERATION_PLUGIN\",\n {\n operation: params.operation\n }\n );\n }\n return {\n negate,\n transformValue,\n field,\n compareValue,\n fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join(\".\"),\n path: field.createPath({\n field\n }),\n plugin\n };\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEO,MAAMA,yBAAyB,GAAG,MAAM;EAC3C,OAAO,IAAIC,oDAAJ,CAA8B;IACjCC,SAAS,EAAED,oDAAA,CAA0BE,GADJ;IAEjCC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,MAAF;QAAUC,cAAV;QAA0BC,KAA1B;QAAiCC,YAAjC;QAA+CC;MAA/C,IAAsEL,MAA5E;MACA,MAAMM,MAAM,GAAGD,kBAAkB,CAACL,MAAM,CAACO,SAAR,CAAjC;;MACA,IAAI,CAACD,MAAL,EAAa;QACT,MAAM,IAAIE,cAAJ,CACD,4CAA2CR,MAAM,CAACO,SAAU,IAD3D,EAEF,0BAFE,EAGF;UACIA,SAAS,EAAEP,MAAM,CAACO;QADtB,CAHE,CAAN;MAOH;;MACD,OAAO;QACHN,MADG;QAEHC,cAFG;QAGHC,KAHG;QAIHC,YAJG;QAKHK,WAAW,EAAE,CAAC,GAAGN,KAAK,CAACO,OAAN,CAAcC,GAAd,CAAkBC,CAAC,IAAIA,CAAC,CAACC,OAAzB,CAAJ,EAAuCV,KAAK,CAACU,OAA7C,EAAsDC,IAAtD,CAA2D,GAA3D,CALV;QAMHC,IAAI,EAAEZ,KAAK,CAACa,UAAN,CAAiB;UACnBb;QADmB,CAAjB,CANH;QASHG;MATG,CAAP;IAWH;EAzBgC,CAA9B,CAAP;AA2BH,CA5BM"}
1
+ {"version":3,"names":["createDefaultFilterCreate","CmsEntryFieldFilterPlugin","fieldType","ALL","create","params","negate","transformValue","field","compareValue","valueFilterPlugins","plugin","operation","WebinyError","fieldPathId","parents","map","f","fieldId","join","path","createPath"],"sources":["defaultFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin\";\n\nexport const createDefaultFilterCreate = () => {\n return new CmsEntryFieldFilterPlugin({\n fieldType: CmsEntryFieldFilterPlugin.ALL,\n create: params => {\n const { negate, transformValue, field, compareValue, valueFilterPlugins } = params;\n const plugin = valueFilterPlugins[params.operation];\n if (!plugin) {\n throw new WebinyError(\n `Missing ValueFilterPlugin for operation \"${params.operation}\".`,\n \"MISSING_OPERATION_PLUGIN\",\n {\n operation: params.operation\n }\n );\n }\n return {\n negate,\n transformValue,\n field,\n compareValue,\n fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join(\".\"),\n path: field.createPath({\n field\n }),\n plugin\n };\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAEO,MAAMA,yBAAyB,GAAG,MAAM;EAC3C,OAAO,IAAIC,oDAAyB,CAAC;IACjCC,SAAS,EAAED,oDAAyB,CAACE,GAAG;IACxCC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,MAAM;QAAEC,cAAc;QAAEC,KAAK;QAAEC,YAAY;QAAEC;MAAmB,CAAC,GAAGL,MAAM;MAClF,MAAMM,MAAM,GAAGD,kBAAkB,CAACL,MAAM,CAACO,SAAS,CAAC;MACnD,IAAI,CAACD,MAAM,EAAE;QACT,MAAM,IAAIE,cAAW,CAChB,4CAA2CR,MAAM,CAACO,SAAU,IAAG,EAChE,0BAA0B,EAC1B;UACIA,SAAS,EAAEP,MAAM,CAACO;QACtB,CAAC,CACJ;MACL;MACA,OAAO;QACHN,MAAM;QACNC,cAAc;QACdC,KAAK;QACLC,YAAY;QACZK,WAAW,EAAE,CAAC,GAAGN,KAAK,CAACO,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC,EAAEV,KAAK,CAACU,OAAO,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;QAC5EC,IAAI,EAAEZ,KAAK,CAACa,UAAU,CAAC;UACnBb;QACJ,CAAC,CAAC;QACFG;MACJ,CAAC;IACL;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -1 +1 @@
1
- export declare const createFilterCreatePlugins: () => import("../../../../plugins/CmsEntryFieldFilterPlugin").CmsEntryFieldFilterPlugin[];
1
+ export declare const createFilterCreatePlugins: () => import("../../../..").CmsEntryFieldFilterPlugin[];
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createFilterCreatePlugins = void 0;
7
-
8
7
  var _defaultFilterCreate = require("./defaultFilterCreate");
9
-
10
8
  var _refFilterCreate = require("./refFilterCreate");
11
-
12
9
  var _objectFilterCreate = require("./objectFilterCreate");
13
-
14
10
  const createFilterCreatePlugins = () => {
15
11
  return [(0, _defaultFilterCreate.createDefaultFilterCreate)(), (0, _refFilterCreate.createRefFilterCreate)(), (0, _objectFilterCreate.objectFilterCreate)()];
16
12
  };
17
-
18
13
  exports.createFilterCreatePlugins = createFilterCreatePlugins;
@@ -1 +1 @@
1
- {"version":3,"names":["createFilterCreatePlugins","createDefaultFilterCreate","createRefFilterCreate","objectFilterCreate"],"sources":["index.ts"],"sourcesContent":["import { createDefaultFilterCreate } from \"./defaultFilterCreate\";\nimport { createRefFilterCreate } from \"./refFilterCreate\";\nimport { objectFilterCreate } from \"./objectFilterCreate\";\n\nexport const createFilterCreatePlugins = () => {\n return [createDefaultFilterCreate(), createRefFilterCreate(), objectFilterCreate()];\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEO,MAAMA,yBAAyB,GAAG,MAAM;EAC3C,OAAO,CAAC,IAAAC,8CAAA,GAAD,EAA8B,IAAAC,sCAAA,GAA9B,EAAuD,IAAAC,sCAAA,GAAvD,CAAP;AACH,CAFM"}
1
+ {"version":3,"names":["createFilterCreatePlugins","createDefaultFilterCreate","createRefFilterCreate","objectFilterCreate"],"sources":["index.ts"],"sourcesContent":["import { createDefaultFilterCreate } from \"./defaultFilterCreate\";\nimport { createRefFilterCreate } from \"./refFilterCreate\";\nimport { objectFilterCreate } from \"./objectFilterCreate\";\n\nexport const createFilterCreatePlugins = () => {\n return [createDefaultFilterCreate(), createRefFilterCreate(), objectFilterCreate()];\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEO,MAAMA,yBAAyB,GAAG,MAAM;EAC3C,OAAO,CAAC,IAAAC,8CAAyB,GAAE,EAAE,IAAAC,sCAAqB,GAAE,EAAE,IAAAC,sCAAkB,GAAE,CAAC;AACvF,CAAC;AAAC"}
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.objectFilterCreate = void 0;
9
-
10
8
  var _CmsEntryFieldFilterPlugin = require("../../../../plugins/CmsEntryFieldFilterPlugin");
11
-
12
9
  var _where = require("../where");
13
-
14
10
  var _error = _interopRequireDefault(require("@webiny/error"));
15
-
16
11
  var _transform = require("../transform");
17
-
18
12
  const objectFilterCreate = () => {
19
13
  return new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
20
14
  fieldType: "object",
@@ -28,20 +22,15 @@ const objectFilterCreate = () => {
28
22
  fields
29
23
  } = params;
30
24
  const filters = [];
31
-
32
25
  for (const key in objectValue) {
33
26
  const value = objectValue[key];
34
-
35
27
  if (value === undefined) {
36
28
  continue;
37
29
  }
38
-
39
30
  const whereParams = (0, _where.extractWhereParams)(key);
40
-
41
31
  if (!whereParams) {
42
32
  continue;
43
33
  }
44
-
45
34
  const {
46
35
  negate,
47
36
  fieldId,
@@ -49,27 +38,22 @@ const objectFilterCreate = () => {
49
38
  } = whereParams;
50
39
  const fieldPath = parentField.parents.map(p => p.fieldId).concat([parentField.fieldId, fieldId]).join(".");
51
40
  const field = fields[fieldPath];
52
-
53
41
  if (!field) {
54
42
  throw new _error.default(`There is no field with the field path "${fieldPath}".`, "FIELD_ERROR", {
55
43
  fieldId
56
44
  });
57
45
  }
58
-
59
46
  const filterCreatePlugin = getFilterCreatePlugin(field.type);
60
47
  const transformValuePlugin = transformValuePlugins[field.type];
61
-
62
48
  const transformValueCallable = value => {
63
49
  if (!transformValuePlugin) {
64
50
  return value;
65
51
  }
66
-
67
52
  return transformValuePlugin.transform({
68
53
  field,
69
54
  value
70
55
  });
71
56
  };
72
-
73
57
  const result = filterCreatePlugin.create({
74
58
  key,
75
59
  value,
@@ -86,22 +70,17 @@ const objectFilterCreate = () => {
86
70
  }),
87
71
  transformValue: transformValueCallable
88
72
  });
89
-
90
73
  if (!result) {
91
74
  continue;
92
75
  }
93
-
94
76
  if (Array.isArray(result)) {
95
77
  filters.push(...result);
96
78
  continue;
97
79
  }
98
-
99
80
  filters.push(result);
100
81
  }
101
-
102
82
  return filters;
103
83
  }
104
84
  });
105
85
  };
106
-
107
86
  exports.objectFilterCreate = objectFilterCreate;
@@ -1 +1 @@
1
- {"version":3,"names":["objectFilterCreate","CmsEntryFieldFilterPlugin","fieldType","create","params","value","objectValue","valueFilterPlugins","transformValuePlugins","getFilterCreatePlugin","field","parentField","fields","filters","key","undefined","whereParams","extractWhereParams","negate","fieldId","operation","fieldPath","parents","map","p","concat","join","WebinyError","filterCreatePlugin","type","transformValuePlugin","transformValueCallable","transform","result","compareValue","transformValue","Array","isArray","push"],"sources":["objectFilterCreate.ts"],"sourcesContent":["import { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsFieldFilterValueTransformPlugin } from \"~/types\";\nimport { transformValue } from \"~/operations/entry/filtering/transform\";\n\nexport const objectFilterCreate = () => {\n return new CmsEntryFieldFilterPlugin({\n fieldType: \"object\",\n create: params => {\n const {\n value: objectValue,\n valueFilterPlugins,\n transformValuePlugins,\n getFilterCreatePlugin,\n field: parentField,\n fields\n } = params;\n\n const filters = [];\n\n for (const key in objectValue) {\n const value = objectValue[key];\n if (value === undefined) {\n continue;\n }\n const whereParams = extractWhereParams(key);\n if (!whereParams) {\n continue;\n }\n const { negate, fieldId, operation } = whereParams;\n\n const fieldPath = parentField.parents\n .map(p => p.fieldId)\n .concat([parentField.fieldId, fieldId])\n .join(\".\");\n\n const field = fields[fieldPath];\n if (!field) {\n throw new WebinyError(\n `There is no field with the field path \"${fieldPath}\".`,\n \"FIELD_ERROR\",\n {\n fieldId\n }\n );\n }\n\n const filterCreatePlugin = getFilterCreatePlugin(field.type);\n\n const transformValuePlugin: CmsFieldFilterValueTransformPlugin =\n transformValuePlugins[field.type];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const result = filterCreatePlugin.create({\n key,\n value,\n valueFilterPlugins,\n transformValuePlugins,\n getFilterCreatePlugin,\n operation,\n negate,\n field,\n fields,\n compareValue: transformValue({\n value,\n transform: transformValueCallable\n }),\n transformValue: transformValueCallable\n });\n if (!result) {\n continue;\n }\n if (Array.isArray(result)) {\n filters.push(...result);\n continue;\n }\n\n filters.push(result);\n }\n return filters;\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AAEO,MAAMA,kBAAkB,GAAG,MAAM;EACpC,OAAO,IAAIC,oDAAJ,CAA8B;IACjCC,SAAS,EAAE,QADsB;IAEjCC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QACFC,KAAK,EAAEC,WADL;QAEFC,kBAFE;QAGFC,qBAHE;QAIFC,qBAJE;QAKFC,KAAK,EAAEC,WALL;QAMFC;MANE,IAOFR,MAPJ;MASA,MAAMS,OAAO,GAAG,EAAhB;;MAEA,KAAK,MAAMC,GAAX,IAAkBR,WAAlB,EAA+B;QAC3B,MAAMD,KAAK,GAAGC,WAAW,CAACQ,GAAD,CAAzB;;QACA,IAAIT,KAAK,KAAKU,SAAd,EAAyB;UACrB;QACH;;QACD,MAAMC,WAAW,GAAG,IAAAC,yBAAA,EAAmBH,GAAnB,CAApB;;QACA,IAAI,CAACE,WAAL,EAAkB;UACd;QACH;;QACD,MAAM;UAAEE,MAAF;UAAUC,OAAV;UAAmBC;QAAnB,IAAiCJ,WAAvC;QAEA,MAAMK,SAAS,GAAGV,WAAW,CAACW,OAAZ,CACbC,GADa,CACTC,CAAC,IAAIA,CAAC,CAACL,OADE,EAEbM,MAFa,CAEN,CAACd,WAAW,CAACQ,OAAb,EAAsBA,OAAtB,CAFM,EAGbO,IAHa,CAGR,GAHQ,CAAlB;QAKA,MAAMhB,KAAK,GAAGE,MAAM,CAACS,SAAD,CAApB;;QACA,IAAI,CAACX,KAAL,EAAY;UACR,MAAM,IAAIiB,cAAJ,CACD,0CAAyCN,SAAU,IADlD,EAEF,aAFE,EAGF;YACIF;UADJ,CAHE,CAAN;QAOH;;QAED,MAAMS,kBAAkB,GAAGnB,qBAAqB,CAACC,KAAK,CAACmB,IAAP,CAAhD;QAEA,MAAMC,oBAAwD,GAC1DtB,qBAAqB,CAACE,KAAK,CAACmB,IAAP,CADzB;;QAGA,MAAME,sBAAsB,GAAI1B,KAAD,IAAgB;UAC3C,IAAI,CAACyB,oBAAL,EAA2B;YACvB,OAAOzB,KAAP;UACH;;UACD,OAAOyB,oBAAoB,CAACE,SAArB,CAA+B;YAClCtB,KADkC;YAElCL;UAFkC,CAA/B,CAAP;QAIH,CARD;;QAUA,MAAM4B,MAAM,GAAGL,kBAAkB,CAACzB,MAAnB,CAA0B;UACrCW,GADqC;UAErCT,KAFqC;UAGrCE,kBAHqC;UAIrCC,qBAJqC;UAKrCC,qBALqC;UAMrCW,SANqC;UAOrCF,MAPqC;UAQrCR,KARqC;UASrCE,MATqC;UAUrCsB,YAAY,EAAE,IAAAC,yBAAA,EAAe;YACzB9B,KADyB;YAEzB2B,SAAS,EAAED;UAFc,CAAf,CAVuB;UAcrCI,cAAc,EAAEJ;QAdqB,CAA1B,CAAf;;QAgBA,IAAI,CAACE,MAAL,EAAa;UACT;QACH;;QACD,IAAIG,KAAK,CAACC,OAAN,CAAcJ,MAAd,CAAJ,EAA2B;UACvBpB,OAAO,CAACyB,IAAR,CAAa,GAAGL,MAAhB;UACA;QACH;;QAEDpB,OAAO,CAACyB,IAAR,CAAaL,MAAb;MACH;;MACD,OAAOpB,OAAP;IACH;EAnFgC,CAA9B,CAAP;AAqFH,CAtFM"}
1
+ {"version":3,"names":["objectFilterCreate","CmsEntryFieldFilterPlugin","fieldType","create","params","value","objectValue","valueFilterPlugins","transformValuePlugins","getFilterCreatePlugin","field","parentField","fields","filters","key","undefined","whereParams","extractWhereParams","negate","fieldId","operation","fieldPath","parents","map","p","concat","join","WebinyError","filterCreatePlugin","type","transformValuePlugin","transformValueCallable","transform","result","compareValue","transformValue","Array","isArray","push"],"sources":["objectFilterCreate.ts"],"sourcesContent":["import { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsFieldFilterValueTransformPlugin } from \"~/types\";\nimport { transformValue } from \"~/operations/entry/filtering/transform\";\n\nexport const objectFilterCreate = () => {\n return new CmsEntryFieldFilterPlugin({\n fieldType: \"object\",\n create: params => {\n const {\n value: objectValue,\n valueFilterPlugins,\n transformValuePlugins,\n getFilterCreatePlugin,\n field: parentField,\n fields\n } = params;\n\n const filters = [];\n\n for (const key in objectValue) {\n const value = objectValue[key];\n if (value === undefined) {\n continue;\n }\n const whereParams = extractWhereParams(key);\n if (!whereParams) {\n continue;\n }\n const { negate, fieldId, operation } = whereParams;\n\n const fieldPath = parentField.parents\n .map(p => p.fieldId)\n .concat([parentField.fieldId, fieldId])\n .join(\".\");\n\n const field = fields[fieldPath];\n if (!field) {\n throw new WebinyError(\n `There is no field with the field path \"${fieldPath}\".`,\n \"FIELD_ERROR\",\n {\n fieldId\n }\n );\n }\n\n const filterCreatePlugin = getFilterCreatePlugin(field.type);\n\n const transformValuePlugin: CmsFieldFilterValueTransformPlugin =\n transformValuePlugins[field.type];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const result = filterCreatePlugin.create({\n key,\n value,\n valueFilterPlugins,\n transformValuePlugins,\n getFilterCreatePlugin,\n operation,\n negate,\n field,\n fields,\n compareValue: transformValue({\n value,\n transform: transformValueCallable\n }),\n transformValue: transformValueCallable\n });\n if (!result) {\n continue;\n }\n if (Array.isArray(result)) {\n filters.push(...result);\n continue;\n }\n\n filters.push(result);\n }\n return filters;\n }\n });\n};\n"],"mappings":";;;;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oBAAoB,EAAE;YACvB,OAAOzB,KAAK;UAChB;UACA,OAAOyB,oBAAoB,CAACE,SAAS,CAAC;YAClCtB,KAAK;YACLL;UACJ,CAAC,CAAC;QACN,CAAC;QAED,MAAM4B,MAAM,GAAGL,kBAAkB,CAACzB,MAAM,CAAC;UACrCW,GAAG;UACHT,KAAK;UACLE,kBAAkB;UAClBC,qBAAqB;UACrBC,qBAAqB;UACrBW,SAAS;UACTF,MAAM;UACNR,KAAK;UACLE,MAAM;UACNsB,YAAY,EAAE,IAAAC,yBAAc,EAAC;YACzB9B,KAAK;YACL2B,SAAS,EAAED;UACf,CAAC,CAAC;UACFI,cAAc,EAAEJ;QACpB,CAAC,CAAC;QACF,IAAI,CAACE,MAAM,EAAE;UACT;QACJ;QACA,IAAIG,KAAK,CAACC,OAAO,CAACJ,MAAM,CAAC,EAAE;UACvBpB,OAAO,CAACyB,IAAI,CAAC,GAAGL,MAAM,CAAC;UACvB;QACJ;QAEApB,OAAO,CAACyB,IAAI,CAACL,MAAM,CAAC;MACxB;MACA,OAAOpB,OAAO;IAClB;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createRefFilterCreate = void 0;
9
-
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
9
  var _CmsEntryFieldFilterPlugin = require("../../../../plugins/CmsEntryFieldFilterPlugin");
13
-
14
10
  var _where = require("../where");
15
-
16
11
  var _transform = require("../transform");
17
-
18
12
  const createRefFilterCreate = () => {
19
13
  return new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
20
14
  fieldType: "ref",
@@ -26,44 +20,34 @@ const createRefFilterCreate = () => {
26
20
  field
27
21
  } = params;
28
22
  const propertyFilters = Object.keys(value);
29
-
30
23
  if (propertyFilters.length === 0) {
31
24
  return null;
32
25
  }
33
-
34
26
  const filters = [];
35
-
36
27
  for (const propertyFilter of propertyFilters) {
37
28
  const whereParams = (0, _where.extractWhereParams)(propertyFilter);
38
-
39
29
  if (!whereParams) {
40
30
  continue;
41
31
  }
42
-
43
32
  const {
44
33
  fieldId: propertyId,
45
34
  operation: propertyOperation,
46
35
  negate
47
36
  } = whereParams;
48
37
  const transformValuePlugin = transformValuePlugins[field.type];
49
-
50
38
  const transformValueCallable = value => {
51
39
  if (!transformValuePlugin) {
52
40
  return value;
53
41
  }
54
-
55
42
  return transformValuePlugin.transform({
56
43
  field,
57
44
  value
58
45
  });
59
46
  };
60
-
61
47
  const filterPlugin = valueFilterPlugins[propertyOperation];
62
-
63
48
  if (!filterPlugin) {
64
49
  throw new _error.default(`Missing operation filter for "${propertyOperation}".`, "MISSING_OPERATION_FILTER");
65
50
  }
66
-
67
51
  const paths = [field.createPath({
68
52
  field
69
53
  }), propertyId];
@@ -80,10 +64,8 @@ const createRefFilterCreate = () => {
80
64
  transformValue: transformValueCallable
81
65
  });
82
66
  }
83
-
84
67
  return filters;
85
68
  }
86
69
  });
87
70
  };
88
-
89
71
  exports.createRefFilterCreate = createRefFilterCreate;
@@ -1 +1 @@
1
- {"version":3,"names":["createRefFilterCreate","CmsEntryFieldFilterPlugin","fieldType","create","params","value","valueFilterPlugins","transformValuePlugins","field","propertyFilters","Object","keys","length","filters","propertyFilter","whereParams","extractWhereParams","fieldId","propertyId","operation","propertyOperation","negate","transformValuePlugin","type","transformValueCallable","transform","filterPlugin","WebinyError","paths","createPath","push","path","join","fieldPathId","parents","map","f","plugin","compareValue","transformValue"],"sources":["refFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n CmsEntryFieldFilterPlugin,\n CmsEntryFieldFilterPluginCreateResponse\n} from \"~/plugins/CmsEntryFieldFilterPlugin\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where\";\nimport { transformValue } from \"~/operations/entry/filtering/transform\";\n\nexport const createRefFilterCreate = () => {\n return new CmsEntryFieldFilterPlugin({\n fieldType: \"ref\",\n create: params => {\n const { value, valueFilterPlugins, transformValuePlugins, field } = params;\n const propertyFilters = Object.keys(value);\n if (propertyFilters.length === 0) {\n return null;\n }\n\n const filters: CmsEntryFieldFilterPluginCreateResponse[] = [];\n\n for (const propertyFilter of propertyFilters) {\n const whereParams = extractWhereParams(propertyFilter);\n if (!whereParams) {\n continue;\n }\n const { fieldId: propertyId, operation: propertyOperation, negate } = whereParams;\n\n const transformValuePlugin = transformValuePlugins[field.type];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const filterPlugin = valueFilterPlugins[propertyOperation];\n if (!filterPlugin) {\n throw new WebinyError(\n `Missing operation filter for \"${propertyOperation}\".`,\n \"MISSING_OPERATION_FILTER\"\n );\n }\n\n const paths = [\n field.createPath({\n field\n }),\n propertyId\n ];\n\n filters.push({\n field,\n path: paths.join(\".\"),\n fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join(\".\"),\n plugin: filterPlugin,\n negate,\n compareValue: transformValue({\n value: value[propertyFilter],\n transform: transformValueCallable\n }),\n transformValue: transformValueCallable\n });\n }\n\n return filters;\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAIA;;AACA;;AAEO,MAAMA,qBAAqB,GAAG,MAAM;EACvC,OAAO,IAAIC,oDAAJ,CAA8B;IACjCC,SAAS,EAAE,KADsB;IAEjCC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,KAAF;QAASC,kBAAT;QAA6BC,qBAA7B;QAAoDC;MAApD,IAA8DJ,MAApE;MACA,MAAMK,eAAe,GAAGC,MAAM,CAACC,IAAP,CAAYN,KAAZ,CAAxB;;MACA,IAAII,eAAe,CAACG,MAAhB,KAA2B,CAA/B,EAAkC;QAC9B,OAAO,IAAP;MACH;;MAED,MAAMC,OAA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ED;UAFc,CAAf,CANL;UAUTe,cAAc,EAAEf;QAVP,CAAb;MAYH;;MAED,OAAOX,OAAP;IACH;EA5DgC,CAA9B,CAAP;AA8DH,CA/DM"}
1
+ {"version":3,"names":["createRefFilterCreate","CmsEntryFieldFilterPlugin","fieldType","create","params","value","valueFilterPlugins","transformValuePlugins","field","propertyFilters","Object","keys","length","filters","propertyFilter","whereParams","extractWhereParams","fieldId","propertyId","operation","propertyOperation","negate","transformValuePlugin","type","transformValueCallable","transform","filterPlugin","WebinyError","paths","createPath","push","path","join","fieldPathId","parents","map","f","plugin","compareValue","transformValue"],"sources":["refFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n CmsEntryFieldFilterPlugin,\n CmsEntryFieldFilterPluginCreateResponse\n} from \"~/plugins/CmsEntryFieldFilterPlugin\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where\";\nimport { transformValue } from \"~/operations/entry/filtering/transform\";\n\nexport const createRefFilterCreate = () => {\n return new CmsEntryFieldFilterPlugin({\n fieldType: \"ref\",\n create: params => {\n const { value, valueFilterPlugins, transformValuePlugins, field } = params;\n const propertyFilters = Object.keys(value);\n if (propertyFilters.length === 0) {\n return null;\n }\n\n const filters: CmsEntryFieldFilterPluginCreateResponse[] = [];\n\n for (const propertyFilter of propertyFilters) {\n const whereParams = extractWhereParams(propertyFilter);\n if (!whereParams) {\n continue;\n }\n const { fieldId: propertyId, operation: propertyOperation, negate } = whereParams;\n\n const transformValuePlugin = transformValuePlugins[field.type];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const filterPlugin = valueFilterPlugins[propertyOperation];\n if (!filterPlugin) {\n throw new WebinyError(\n `Missing operation filter for \"${propertyOperation}\".`,\n \"MISSING_OPERATION_FILTER\"\n );\n }\n\n const paths = [\n field.createPath({\n field\n }),\n propertyId\n ];\n\n filters.push({\n field,\n path: paths.join(\".\"),\n fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join(\".\"),\n plugin: filterPlugin,\n negate,\n compareValue: transformValue({\n value: value[propertyFilter],\n transform: transformValueCallable\n }),\n transformValue: transformValueCallable\n });\n }\n\n return filters;\n }\n });\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAIA;AACA;AAEO,MAAMA,qBAAqB,GAAG,MAAM;EACvC,OAAO,IAAIC,oDAAyB,CAAC;IACjCC,SAAS,EAAE,KAAK;IAChBC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,KAAK;QAAEC,kBAAkB;QAAEC,qBAAqB;QAAEC;MAAM,CAAC,GAAGJ,MAAM;MAC1E,MAAMK,eAAe,GAAGC,MAAM,CAACC,IAAI,CAACN,KAAK,CAAC;MAC1C,IAAII,eAAe,CAACG,MAAM,KAAK,CAAC,EAAE;QAC9B,OAAO,IAAI;MACf;MAEA,MAAMC,OAAkD,GAAG,EAAE;MAE7D,KAAK,MAAMC,cAAc,IAAIL,eAAe,EAAE;QAC1C,MAAMM,WAAW,GAAG,IAAAC,yBAAkB,EAACF,cAAc,CAAC;QACtD,IAAI,CAACC,WAAW,EAAE;UACd;QACJ;QACA,MAAM;UAAEE,OAAO,EAAEC,UAAU;UAAEC,SAAS,EAAEC,iBAAiB;UAAEC;QAAO,CAAC,GAAGN,WAAW;QAEjF,MAAMO,oBAAoB,GAAGf,qBAAqB,CAACC,KAAK,CAACe,IAAI,CAAC;QAE9D,MAAMC,sBAAsB,GAAInB,KAAU,IAAK;UAC3C,IAAI,CAACiB,oBAAoB,EAAE;YACvB,OAAOjB,KAAK;UAChB;UACA,OAAOiB,oBAAoB,CAACG,SAAS,CAAC;YAClCjB,KAAK;YACLH;UACJ,CAAC,CAAC;QACN,CAAC;QAED,MAAMqB,YAAY,GAAGpB,kBAAkB,CAACc,iBAAiB,CAAC;QAC1D,IAAI,CAACM,YAAY,EAAE;UACf,MAAM,IAAIC,cAAW,CAChB,iCAAgCP,iBAAkB,IAAG,EACtD,0BAA0B,CAC7B;QACL;QAEA,MAAMQ,KAAK,GAAG,CACVpB,KAAK,CAACqB,UAAU,CAAC;UACbrB;QACJ,CAAC,CAAC,EACFU,UAAU,CACb;QAEDL,OAAO,CAACiB,IAAI,CAAC;UACTtB,KAAK;UACLuB,IAAI,EAAEH,KAAK,CAACI,IAAI,CAAC,GAAG,CAAC;UACrBC,WAAW,EAAE,CAAC,GAAGzB,KAAK,CAAC0B,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACnB,OAAO,CAAC,EAAET,KAAK,CAACS,OAAO,CAAC,CAACe,IAAI,CAAC,GAAG,CAAC;UAC5EK,MAAM,EAAEX,YAAY;UACpBL,MAAM;UACNiB,YAAY,EAAE,IAAAC,yBAAc,EAAC;YACzBlC,KAAK,EAAEA,KAAK,CAACS,cAAc,CAAC;YAC5BW,SAAS,EAAED;UACf,CAAC,CAAC;UACFe,cAAc,EAAEf;QACpB,CAAC,CAAC;MACN;MAEA,OAAOX,OAAO;IAClB;EACJ,CAAC,CAAC;AACN,CAAC;AAAC"}
@@ -1,9 +1,12 @@
1
- import { CmsEntry } from "@webiny/api-headless-cms/types";
1
+ import { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
2
2
  import { Field } from "./types";
3
+ import { PluginsContainer } from "@webiny/plugins";
3
4
  interface Params {
5
+ model: CmsModel;
4
6
  items: CmsEntry[];
5
7
  sort?: string[];
6
8
  fields: Record<string, Field>;
9
+ plugins: PluginsContainer;
7
10
  }
8
11
  export declare const sort: (params: Params) => CmsEntry[];
9
12
  export {};
@@ -1,27 +1,22 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.sort = void 0;
9
-
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
9
  var _dotProp = _interopRequireDefault(require("dot-prop"));
13
-
14
10
  var _sortBy = _interopRequireDefault(require("lodash/sortBy"));
15
-
16
11
  var _extractSort = require("./extractSort");
17
-
18
12
  const sort = params => {
19
13
  const {
14
+ model,
20
15
  items,
21
16
  sort = [],
22
- fields
17
+ fields,
18
+ plugins
23
19
  } = params;
24
-
25
20
  if (items.length <= 1) {
26
21
  return items;
27
22
  } else if (sort.length === 0) {
@@ -31,23 +26,22 @@ const sort = params => {
31
26
  sort: sort
32
27
  });
33
28
  }
34
-
35
29
  const [firstSort] = sort;
36
-
37
30
  if (!firstSort) {
38
31
  throw new _error.default("Empty sort array item.", "SORT_EMPTY_ERROR", {
39
32
  sort
40
33
  });
41
34
  }
42
-
43
35
  const {
44
36
  fieldId,
45
37
  field,
46
38
  valuePath,
47
39
  reverse
48
40
  } = (0, _extractSort.extractSort)({
41
+ model,
49
42
  sortBy: firstSort,
50
- fields
43
+ fields,
44
+ plugins
51
45
  });
52
46
  const itemsToSort = items.map(item => {
53
47
  return {
@@ -58,23 +52,18 @@ const sort = params => {
58
52
  const sortedItems = (0, _sortBy.default)(itemsToSort, "value");
59
53
  const newItems = sortedItems.map(s => {
60
54
  const item = items.find(i => i.id === s.id);
61
-
62
55
  if (item) {
63
56
  return item;
64
57
  }
65
-
66
58
  throw new _error.default("Could not find item by given id after the sorting.", "SORTING_ITEMS_ERROR", {
67
59
  id: s.id,
68
60
  sortingBy: fieldId,
69
61
  reverse
70
62
  });
71
63
  });
72
-
73
64
  if (!reverse) {
74
65
  return newItems;
75
66
  }
76
-
77
67
  return newItems.reverse();
78
68
  };
79
-
80
69
  exports.sort = sort;
@@ -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,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AP;EACH;;EACD,OAAOA,QAAQ,CAACb,OAAT,EAAP;AACH,CArDM"}
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 (!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AAW,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"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createSystemFields = void 0;
7
-
8
7
  const createSystemFields = () => {
9
8
  return [{
10
9
  id: "id",
@@ -68,5 +67,4 @@ const createSystemFields = () => {
68
67
  label: "Status"
69
68
  }];
70
69
  };
71
-
72
70
  exports.createSystemFields = createSystemFields;
@@ -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":["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"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.transformValue = void 0;
7
-
8
7
  const transformValue = ({
9
8
  value,
10
9
  transform
@@ -12,8 +11,6 @@ const transformValue = ({
12
11
  if (Array.isArray(value)) {
13
12
  return value.map(v => transform(v));
14
13
  }
15
-
16
14
  return transform(value);
17
15
  };
18
-
19
16
  exports.transformValue = transformValue;
@@ -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 { 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"}
@@ -0,0 +1,2 @@
1
+ import { CmsEntryListWhere } from "@webiny/api-headless-cms/types";
2
+ export declare const getWhereValues: (value: unknown, condition: "AND" | "OR") => CmsEntryListWhere[];