@webiny/api-headless-cms-ddb 0.0.0-unstable.e3f4727c56 → 0.0.0-unstable.eb196ccd2f

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 (161) hide show
  1. package/definitions/entry.d.ts +4 -3
  2. package/definitions/entry.js +108 -16
  3. package/definitions/entry.js.map +1 -1
  4. package/definitions/group.d.ts +4 -3
  5. package/definitions/group.js +8 -12
  6. package/definitions/group.js.map +1 -1
  7. package/definitions/model.d.ts +4 -3
  8. package/definitions/model.js +25 -12
  9. package/definitions/model.js.map +1 -1
  10. package/definitions/system.d.ts +4 -3
  11. package/definitions/system.js +8 -12
  12. package/definitions/system.js.map +1 -1
  13. package/definitions/table.d.ts +5 -5
  14. package/definitions/table.js +7 -6
  15. package/definitions/table.js.map +1 -1
  16. package/dynamoDb/index.js +4 -9
  17. package/dynamoDb/index.js.map +1 -1
  18. package/dynamoDb/path/locationFolderId.d.ts +2 -0
  19. package/dynamoDb/path/locationFolderId.js +43 -0
  20. package/dynamoDb/path/locationFolderId.js.map +1 -0
  21. package/dynamoDb/path/plainObject.js +3 -8
  22. package/dynamoDb/path/plainObject.js.map +1 -1
  23. package/dynamoDb/storage/longText.js +4 -18
  24. package/dynamoDb/storage/longText.js.map +1 -1
  25. package/dynamoDb/storage/richText.js +23 -75
  26. package/dynamoDb/storage/richText.js.map +1 -1
  27. package/dynamoDb/transformValue/datetime.d.ts +1 -1
  28. package/dynamoDb/transformValue/datetime.js +3 -8
  29. package/dynamoDb/transformValue/datetime.js.map +1 -1
  30. package/index.d.ts +1 -1
  31. package/index.js +15 -44
  32. package/index.js.map +1 -1
  33. package/operations/entry/dataLoader/DataLoaderCache.d.ts +17 -0
  34. package/operations/entry/dataLoader/DataLoaderCache.js +41 -0
  35. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  36. package/operations/entry/dataLoader/constants.d.ts +1 -0
  37. package/operations/entry/dataLoader/constants.js +10 -0
  38. package/operations/entry/dataLoader/constants.js.map +1 -0
  39. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  40. package/operations/entry/dataLoader/createBatchScheduleFn.js +25 -0
  41. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  42. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  43. package/operations/entry/dataLoader/getAllEntryRevisions.js +45 -0
  44. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  45. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  46. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +56 -0
  47. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  48. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  49. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +56 -0
  50. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  51. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  52. package/operations/entry/dataLoader/getRevisionById.js +62 -0
  53. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  54. package/operations/entry/dataLoader/index.d.ts +8 -0
  55. package/operations/entry/dataLoader/index.js +40 -0
  56. package/operations/entry/dataLoader/index.js.map +1 -0
  57. package/operations/entry/dataLoader/types.d.ts +6 -0
  58. package/operations/entry/dataLoader/types.js +7 -0
  59. package/operations/entry/dataLoader/types.js.map +1 -0
  60. package/operations/entry/dataLoaders.d.ts +12 -27
  61. package/operations/entry/dataLoaders.js +55 -260
  62. package/operations/entry/dataLoaders.js.map +1 -1
  63. package/operations/entry/filtering/createExpressions.d.ts +4 -4
  64. package/operations/entry/filtering/createExpressions.js +4 -39
  65. package/operations/entry/filtering/createExpressions.js.map +1 -1
  66. package/operations/entry/filtering/createFields.d.ts +6 -4
  67. package/operations/entry/filtering/createFields.js +76 -91
  68. package/operations/entry/filtering/createFields.js.map +1 -1
  69. package/operations/entry/filtering/extractSort.d.ts +3 -3
  70. package/operations/entry/filtering/extractSort.js +2 -10
  71. package/operations/entry/filtering/extractSort.js.map +1 -1
  72. package/operations/entry/filtering/filter.d.ts +3 -3
  73. package/operations/entry/filtering/filter.js +24 -44
  74. package/operations/entry/filtering/filter.js.map +1 -1
  75. package/operations/entry/filtering/fullTextSearch.d.ts +3 -3
  76. package/operations/entry/filtering/fullTextSearch.js +2 -12
  77. package/operations/entry/filtering/fullTextSearch.js.map +1 -1
  78. package/operations/entry/filtering/getValue.js +5 -20
  79. package/operations/entry/filtering/getValue.js.map +1 -1
  80. package/operations/entry/filtering/index.js +2 -2
  81. package/operations/entry/filtering/index.js.map +1 -1
  82. package/operations/entry/filtering/mapPlugins.d.ts +2 -2
  83. package/operations/entry/filtering/mapPlugins.js +2 -8
  84. package/operations/entry/filtering/mapPlugins.js.map +1 -1
  85. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +1 -1
  86. package/operations/entry/filtering/plugins/defaultFilterCreate.js +5 -8
  87. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
  88. package/operations/entry/filtering/plugins/index.d.ts +1 -1
  89. package/operations/entry/filtering/plugins/index.js +4 -6
  90. package/operations/entry/filtering/plugins/index.js.map +1 -1
  91. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +1 -1
  92. package/operations/entry/filtering/plugins/objectFilterCreate.js +5 -22
  93. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
  94. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +2 -1
  95. package/operations/entry/filtering/plugins/refFilterCreate.js +11 -20
  96. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
  97. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +2 -0
  98. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +65 -0
  99. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -0
  100. package/operations/entry/filtering/sort.d.ts +3 -3
  101. package/operations/entry/filtering/sort.js +4 -17
  102. package/operations/entry/filtering/sort.js.map +1 -1
  103. package/operations/entry/filtering/systemFields.d.ts +2 -2
  104. package/operations/entry/filtering/systemFields.js +48 -30
  105. package/operations/entry/filtering/systemFields.js.map +1 -1
  106. package/operations/entry/filtering/transform.d.ts +1 -1
  107. package/operations/entry/filtering/transform.js +2 -3
  108. package/operations/entry/filtering/transform.js.map +1 -1
  109. package/operations/entry/filtering/types.d.ts +2 -2
  110. package/operations/entry/filtering/types.js +3 -1
  111. package/operations/entry/filtering/types.js.map +1 -1
  112. package/operations/entry/filtering/values.d.ts +1 -1
  113. package/operations/entry/filtering/values.js +2 -6
  114. package/operations/entry/filtering/values.js.map +1 -1
  115. package/operations/entry/filtering/where.js +5 -8
  116. package/operations/entry/filtering/where.js.map +1 -1
  117. package/operations/entry/index.d.ts +3 -3
  118. package/operations/entry/index.js +705 -273
  119. package/operations/entry/index.js.map +1 -1
  120. package/operations/entry/keys.js +2 -18
  121. package/operations/entry/keys.js.map +1 -1
  122. package/operations/group/index.d.ts +3 -3
  123. package/operations/group/index.js +33 -51
  124. package/operations/group/index.js.map +1 -1
  125. package/operations/model/index.d.ts +2 -2
  126. package/operations/model/index.js +25 -37
  127. package/operations/model/index.js.map +1 -1
  128. package/operations/system/index.d.ts +2 -2
  129. package/operations/system/index.js +18 -23
  130. package/operations/system/index.js.map +1 -1
  131. package/package.json +21 -26
  132. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +3 -2
  133. package/plugins/CmsEntryFieldFilterPathPlugin.js +11 -18
  134. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
  135. package/plugins/CmsEntryFieldFilterPlugin.d.ts +10 -10
  136. package/plugins/CmsEntryFieldFilterPlugin.js +8 -12
  137. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
  138. package/plugins/CmsEntryFieldSortingPlugin.d.ts +2 -2
  139. package/plugins/CmsEntryFieldSortingPlugin.js +3 -14
  140. package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
  141. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
  142. package/plugins/CmsFieldFilterValueTransformPlugin.js +23 -0
  143. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
  144. package/plugins/index.d.ts +1 -0
  145. package/plugins/index.js +14 -7
  146. package/plugins/index.js.map +1 -1
  147. package/types.d.ts +20 -13
  148. package/types.js +5 -6
  149. package/types.js.map +1 -1
  150. package/definitions/settings.d.ts +0 -9
  151. package/definitions/settings.js +0 -58
  152. package/definitions/settings.js.map +0 -1
  153. package/dynamoDb/storage/date.d.ts +0 -3
  154. package/dynamoDb/storage/date.js +0 -109
  155. package/dynamoDb/storage/date.js.map +0 -1
  156. package/operations/entry/systemFields.d.ts +0 -2
  157. package/operations/entry/systemFields.js +0 -74
  158. package/operations/entry/systemFields.js.map +0 -1
  159. package/operations/settings/index.d.ts +0 -7
  160. package/operations/settings/index.js +0 -135
  161. package/operations/settings/index.js.map +0 -1
@@ -1,69 +1,58 @@
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
- return new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
13
+ const plugin = new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
20
14
  fieldType: "ref",
21
15
  create: params => {
22
16
  const {
23
- value,
24
17
  valueFilterPlugins,
25
18
  transformValuePlugins,
26
19
  field
27
20
  } = params;
21
+ let value = params.value;
22
+ if (!value) {
23
+ value = {
24
+ entryId: null
25
+ };
26
+ }
28
27
  const propertyFilters = Object.keys(value);
29
-
30
28
  if (propertyFilters.length === 0) {
31
29
  return null;
32
30
  }
33
-
34
31
  const filters = [];
35
-
36
32
  for (const propertyFilter of propertyFilters) {
37
33
  const whereParams = (0, _where.extractWhereParams)(propertyFilter);
38
-
39
34
  if (!whereParams) {
40
35
  continue;
41
36
  }
42
-
43
37
  const {
44
38
  fieldId: propertyId,
45
39
  operation: propertyOperation,
46
40
  negate
47
41
  } = whereParams;
48
42
  const transformValuePlugin = transformValuePlugins[field.type];
49
-
50
43
  const transformValueCallable = value => {
51
44
  if (!transformValuePlugin) {
52
45
  return value;
53
46
  }
54
-
55
47
  return transformValuePlugin.transform({
56
48
  field,
57
49
  value
58
50
  });
59
51
  };
60
-
61
52
  const filterPlugin = valueFilterPlugins[propertyOperation];
62
-
63
53
  if (!filterPlugin) {
64
54
  throw new _error.default(`Missing operation filter for "${propertyOperation}".`, "MISSING_OPERATION_FILTER");
65
55
  }
66
-
67
56
  const paths = [field.createPath({
68
57
  field
69
58
  }), propertyId];
@@ -80,10 +69,12 @@ const createRefFilterCreate = () => {
80
69
  transformValue: transformValueCallable
81
70
  });
82
71
  }
83
-
84
72
  return filters;
85
73
  }
86
74
  });
75
+ plugin.name = `headless-cms.ddb.filter.ref`;
76
+ return plugin;
87
77
  };
78
+ exports.createRefFilterCreate = createRefFilterCreate;
88
79
 
89
- exports.createRefFilterCreate = createRefFilterCreate;
80
+ //# sourceMappingURL=refFilterCreate.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createRefFilterCreate","CmsEntryFieldFilterPlugin","fieldType","create","params","value","valueFilterPlugins","transformValuePlugins","field","propertyFilters","Object","keys","length","filters","propertyFilter","whereParams","extractWhereParams","fieldId","propertyId","operation","propertyOperation","negate","transformValuePlugin","type","transformValueCallable","transform","filterPlugin","WebinyError","paths","createPath","push","path","join","fieldPathId","parents","map","f","plugin","compareValue","transformValue"],"sources":["refFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport {\n CmsEntryFieldFilterPlugin,\n CmsEntryFieldFilterPluginCreateResponse\n} from \"~/plugins/CmsEntryFieldFilterPlugin\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where\";\nimport { transformValue } from \"~/operations/entry/filtering/transform\";\n\nexport const createRefFilterCreate = () => {\n return new CmsEntryFieldFilterPlugin({\n fieldType: \"ref\",\n create: params => {\n const { value, valueFilterPlugins, transformValuePlugins, field } = params;\n const propertyFilters = Object.keys(value);\n if (propertyFilters.length === 0) {\n return null;\n }\n\n const filters: CmsEntryFieldFilterPluginCreateResponse[] = [];\n\n for (const propertyFilter of propertyFilters) {\n const whereParams = extractWhereParams(propertyFilter);\n if (!whereParams) {\n continue;\n }\n const { fieldId: propertyId, operation: propertyOperation, negate } = whereParams;\n\n const transformValuePlugin = transformValuePlugins[field.type];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const filterPlugin = valueFilterPlugins[propertyOperation];\n if (!filterPlugin) {\n throw new WebinyError(\n `Missing operation filter for \"${propertyOperation}\".`,\n \"MISSING_OPERATION_FILTER\"\n );\n }\n\n const paths = [\n field.createPath({\n field\n }),\n propertyId\n ];\n\n filters.push({\n field,\n path: paths.join(\".\"),\n fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join(\".\"),\n plugin: filterPlugin,\n negate,\n compareValue: transformValue({\n value: value[propertyFilter],\n transform: transformValueCallable\n }),\n transformValue: transformValueCallable\n });\n }\n\n return filters;\n }\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAIA;;AACA;;AAEO,MAAMA,qBAAqB,GAAG,MAAM;EACvC,OAAO,IAAIC,oDAAJ,CAA8B;IACjCC,SAAS,EAAE,KADsB;IAEjCC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,KAAF;QAASC,kBAAT;QAA6BC,qBAA7B;QAAoDC;MAApD,IAA8DJ,MAApE;MAC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,GAA3D,CAHJ;UAITK,MAAM,EAAEX,YAJC;UAKTL,MALS;UAMTiB,YAAY,EAAE,IAAAC,yBAAA,EAAe;YACzBlC,KAAK,EAAEA,KAAK,CAACS,cAAD,CADa;YAEzBW,SAAS,EAAED;UAFc,CAAf,CANL;UAUTe,cAAc,EAAEf;QAVP,CAAb;MAYH;;MAED,OAAOX,OAAP;IACH;EA5DgC,CAA9B,CAAP;AA8DH,CA/DM"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_CmsEntryFieldFilterPlugin","_where","_transform","createRefFilterCreate","plugin","CmsEntryFieldFilterPlugin","fieldType","create","params","valueFilterPlugins","transformValuePlugins","field","value","entryId","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","compareValue","transformValue","name","exports"],"sources":["refFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsEntryFieldFilterPluginCreateResponse } from \"~/plugins/CmsEntryFieldFilterPlugin\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where\";\nimport { transformValue } from \"~/operations/entry/filtering/transform\";\nimport type { GenericRecord } from \"@webiny/api/types\";\n\nexport const createRefFilterCreate = () => {\n const plugin = new CmsEntryFieldFilterPlugin<GenericRecord | null | undefined>({\n fieldType: \"ref\",\n create: params => {\n const { valueFilterPlugins, transformValuePlugins, field } = params;\n let value = params.value;\n if (!value) {\n value = {\n entryId: null\n };\n }\n const propertyFilters = Object.keys(value);\n if (propertyFilters.length === 0) {\n return null;\n }\n const filters: CmsEntryFieldFilterPluginCreateResponse[] = [];\n\n for (const propertyFilter of propertyFilters) {\n const whereParams = extractWhereParams(propertyFilter);\n if (!whereParams) {\n continue;\n }\n const { fieldId: propertyId, operation: propertyOperation, negate } = whereParams;\n\n const 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 plugin.name = `headless-cms.ddb.filter.ref`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,0BAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAGO,MAAMI,qBAAqB,GAAGA,CAAA,KAAM;EACvC,MAAMC,MAAM,GAAG,IAAIC,oDAAyB,CAAmC;IAC3EC,SAAS,EAAE,KAAK;IAChBC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,kBAAkB;QAAEC,qBAAqB;QAAEC;MAAM,CAAC,GAAGH,MAAM;MACnE,IAAII,KAAK,GAAGJ,MAAM,CAACI,KAAK;MACxB,IAAI,CAACA,KAAK,EAAE;QACRA,KAAK,GAAG;UACJC,OAAO,EAAE;QACb,CAAC;MACL;MACA,MAAMC,eAAe,GAAGC,MAAM,CAACC,IAAI,CAACJ,KAAK,CAAC;MAC1C,IAAIE,eAAe,CAACG,MAAM,KAAK,CAAC,EAAE;QAC9B,OAAO,IAAI;MACf;MACA,MAAMC,OAAkD,GAAG,EAAE;MAE7D,KA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AAC,CAAC;MACN;MAEA,OAAOX,OAAO;IAClB;EACJ,CAAC,CAAC;EAEFd,MAAM,CAACwC,IAAI,GAAG,6BAA6B;EAE3C,OAAOxC,MAAM;AACjB,CAAC;AAACyC,OAAA,CAAA1C,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin";
2
+ export declare const searchableJsonFilterCreate: () => CmsEntryFieldFilterPlugin<any>;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.searchableJsonFilterCreate = void 0;
8
+ var _dotObject = _interopRequireDefault(require("dot-object"));
9
+ var _CmsEntryFieldFilterPlugin = require("../../../../plugins/CmsEntryFieldFilterPlugin");
10
+ var _where = require("../where");
11
+ const searchableJsonFilterCreate = () => {
12
+ const plugin = new _CmsEntryFieldFilterPlugin.CmsEntryFieldFilterPlugin({
13
+ fieldType: "searchable-json",
14
+ create: params => {
15
+ const {
16
+ value: objectValue,
17
+ valueFilterPlugins,
18
+ field: parentField
19
+ } = params;
20
+ const filters = [];
21
+ const accessPatterns = _dotObject.default.dot(objectValue);
22
+ for (const key in accessPatterns) {
23
+ const value = accessPatterns[key];
24
+ if (value === undefined) {
25
+ continue;
26
+ }
27
+ const whereParams = (0, _where.extractWhereParams)(key);
28
+ if (!whereParams) {
29
+ continue;
30
+ }
31
+ const {
32
+ negate,
33
+ operation
34
+ } = whereParams;
35
+ const transformValueCallable = value => {
36
+ return value;
37
+ };
38
+ const fieldId = `${parentField.fieldId}.${whereParams.fieldId ?? key}`;
39
+ const result = {
40
+ field: parentField,
41
+ path: `values.${fieldId}`,
42
+ fieldPathId: `values.${fieldId}`,
43
+ negate,
44
+ plugin: valueFilterPlugins[operation],
45
+ compareValue: value,
46
+ transformValue: transformValueCallable
47
+ };
48
+ if (!result) {
49
+ continue;
50
+ }
51
+ if (Array.isArray(result)) {
52
+ filters.push(...result);
53
+ continue;
54
+ }
55
+ filters.push(result);
56
+ }
57
+ return filters;
58
+ }
59
+ });
60
+ plugin.name = `headless-cms.ddb.filter.searchable-json`;
61
+ return plugin;
62
+ };
63
+ exports.searchableJsonFilterCreate = searchableJsonFilterCreate;
64
+
65
+ //# sourceMappingURL=searchableJsonFilterCreate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_dotObject","_interopRequireDefault","require","_CmsEntryFieldFilterPlugin","_where","searchableJsonFilterCreate","plugin","CmsEntryFieldFilterPlugin","fieldType","create","params","value","objectValue","valueFilterPlugins","field","parentField","filters","accessPatterns","dot","key","undefined","whereParams","extractWhereParams","negate","operation","transformValueCallable","fieldId","result","path","fieldPathId","compareValue","transformValue","Array","isArray","push","name","exports"],"sources":["searchableJsonFilterCreate.ts"],"sourcesContent":["import dot from \"dot-object\";\nimport type { CmsEntryFieldFilterPluginCreateResponse } from \"~/plugins/CmsEntryFieldFilterPlugin\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where\";\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,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,0BAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,MAAMG,0BAA0B,GAAGA,CAAA,KAAM;EAC5C,MAAMC,MAAM,GAAG,IAAIC,oDAAyB,CAAC;IACzCC,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,GAAGC,kBAAG,CAACA,GAAG,CAACN,WAAW,CAAC;MAE3C,KAAK,MAAMO,GAAG,IAAIF,cAAc,EAAE;QAC9B,MAAMN,KAAK,GAAGM,cAAc,CAACE,GAAG,CAAC;QACjC,IAAIR,KAAK,KAAKS,SAAS,EAAE;UACrB;QACJ;QAEA,MAAMC,WAAW,GAAG,IAAAC,yBAAkB,EAACH,GAAG,CAAC;QAC3C,IAAI,CAACE,WAAW,EAAE;UACd;QACJ;QACA,MAAM;UAAEE,MAAM;UAAEC;QAAU,CAAC,GAAGH,WAAW;QAEzC,MAAMI,sBAAsB,GAAId,KAAU,IAAK;UAC3C,OAAOA,KAAK;QAChB,CAAC;QAED,MAAMe,OAAO,GAAG,GAAGX,WAAW,CAACW,OAAO,IAAIL,WAAW,CAACK,OAAO,IAAIP,GAAG,EAAE;QAEtE,MAAMQ,MAA+C,GAAG;UACpDb,KAAK,EAAEC,WAAW;UAClBa,IAAI,EAAE,UAAUF,OAAO,EAAE;UACzBG,WAAW,EAAE,UAAUH,OAAO,EAAE;UAChCH,MAAM;UACNjB,MAAM,EAAEO,kBAAkB,CAACW,SAAS,CAAC;UACrCM,YAAY,EAAEnB,KAAK;UACnBoB,cAAc,EAAEN;QACpB,CAAC;QAED,IAAI,CAACE,MAAM,EAAE;UACT;QACJ;QACA,IAAIK,KAAK,CAACC,OAAO,CAACN,MAAM,CAAC,EAAE;UACvBX,OAAO,CAACkB,IAAI,CAAC,GAAGP,MAAM,CAAC;UACvB;QACJ;QAEAX,OAAO,CAACkB,IAAI,CAACP,MAAM,CAAC;MACxB;MACA,OAAOX,OAAO;IAClB;EACJ,CAAC,CAAC;EAEFV,MAAM,CAAC6B,IAAI,GAAG,yCAAyC;EAEvD,OAAO7B,MAAM;AACjB,CAAC;AAAC8B,OAAA,CAAA/B,0BAAA,GAAAA,0BAAA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
2
- import { Field } from "./types";
3
- import { PluginsContainer } from "@webiny/plugins";
1
+ import type { CmsEntry, CmsModel } from "@webiny/api-headless-cms/types";
2
+ import type { Field } from "./types";
3
+ import type { PluginsContainer } from "@webiny/plugins";
4
4
  interface Params {
5
5
  model: CmsModel;
6
6
  items: CmsEntry[];
@@ -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.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 {
20
14
  model,
@@ -23,25 +17,21 @@ const sort = params => {
23
17
  fields,
24
18
  plugins
25
19
  } = params;
26
-
27
20
  if (items.length <= 1) {
28
21
  return items;
29
22
  } else if (sort.length === 0) {
30
23
  sort.push("savedOn_DESC");
31
24
  } else if (sort.length > 1) {
32
- throw new _error.default("Sorting is limited to a single field.", "SORT_MULTIPLE_FIELDS_ERROR", {
33
- sort: sort
25
+ throw new _error.default("Sorting is limited to a single field on DynamoDB only system.", "SORT_MULTIPLE_FIELDS_ERROR", {
26
+ sort
34
27
  });
35
28
  }
36
-
37
29
  const [firstSort] = sort;
38
-
39
30
  if (!firstSort) {
40
31
  throw new _error.default("Empty sort array item.", "SORT_EMPTY_ERROR", {
41
32
  sort
42
33
  });
43
34
  }
44
-
45
35
  const {
46
36
  fieldId,
47
37
  field,
@@ -62,23 +52,20 @@ const sort = params => {
62
52
  const sortedItems = (0, _sortBy.default)(itemsToSort, "value");
63
53
  const newItems = sortedItems.map(s => {
64
54
  const item = items.find(i => i.id === s.id);
65
-
66
55
  if (item) {
67
56
  return item;
68
57
  }
69
-
70
58
  throw new _error.default("Could not find item by given id after the sorting.", "SORTING_ITEMS_ERROR", {
71
59
  id: s.id,
72
60
  sortingBy: fieldId,
73
61
  reverse
74
62
  });
75
63
  });
76
-
77
64
  if (!reverse) {
78
65
  return newItems;
79
66
  }
80
-
81
67
  return newItems.reverse();
82
68
  };
69
+ exports.sort = sort;
83
70
 
84
- exports.sort = sort;
71
+ //# 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,MAAD,IAAgC;EAChD,MAAM;IAAEC,KAAF;IAASC,KAAT;IAAgBH,IAAI,GAAG,EAAvB;IAA2BI,MAA3B;IAAmCC;EAAnC,IAA+CJ,MAArD;;EACA,IAAIE,KAAK,CAACG,MAAN,IAAgB,CAApB,EAAuB;IACnB,OAAOH,KAAP;EACH,CAFD,MAEO,IAAIH,IAAI,CAACM,MAAL,KAAgB,CAApB,EAAuB;IAC1BN,IAAI,CAACO,IAAL,CAAU,cAAV;EACH,CAFM,MA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ACA,OAAL,EAAc;IACV,OAAOa,QAAP;EACH;;EACD,OAAOA,QAAQ,CAACb,OAAT,EAAP;AACH,CAvDM"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_dotProp","_sortBy","_extractSort","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","exports"],"sources":["sort.ts"],"sourcesContent":["import type { 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 type { Field } from \"./types\";\nimport type { 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 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 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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAiBO,MAAMI,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,+DAA+D,EAC/D,4BAA4B,EAC5B;MACIR;IACJ,CACJ,CAAC;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,CACJ,CAAC;EACL,CAAC,CAAC;EACF,IAAI,CAACA,OAAO,EAAE;IACV,OAAOa,QAAQ;EACnB;EACA,OAAOA,QAAQ,CAACb,OAAO,CAAC,CAAC;AAC7B,CAAC;AAACkB,OAAA,CAAA/B,IAAA,GAAAA,IAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { CmsModelField } from "@webiny/api-headless-cms/types";
2
- declare type Field = Pick<CmsModelField, "id" | "type" | "storageId" | "fieldId" | "settings" | "label">;
1
+ import type { CmsModelField } from "@webiny/api-headless-cms/types";
2
+ type Field = Pick<CmsModelField, "id" | "type" | "storageId" | "fieldId" | "settings" | "label">;
3
3
  export declare const createSystemFields: () => Field[];
4
4
  export {};
@@ -1,11 +1,34 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.createSystemFields = void 0;
7
-
8
+ var _constants = require("@webiny/api-headless-cms/constants");
9
+ var _startCase = _interopRequireDefault(require("lodash/startCase"));
8
10
  const createSystemFields = () => {
11
+ const onMetaFields = _constants.ENTRY_META_FIELDS.filter(_constants.isDateTimeEntryMetaField).map(fieldName => {
12
+ return {
13
+ id: fieldName,
14
+ type: "datetime",
15
+ storageId: fieldName,
16
+ fieldId: fieldName,
17
+ label: (0, _startCase.default)(fieldName)
18
+ };
19
+ });
20
+ const byMetaFields = _constants.ENTRY_META_FIELDS.filter(_constants.isIdentityEntryMetaField).map(fieldName => {
21
+ return {
22
+ id: fieldName,
23
+ type: "plainObject",
24
+ storageId: fieldName,
25
+ fieldId: fieldName,
26
+ label: (0, _startCase.default)(fieldName),
27
+ settings: {
28
+ path: `${fieldName}.id`
29
+ }
30
+ };
31
+ });
9
32
  return [{
10
33
  id: "id",
11
34
  type: "text",
@@ -18,41 +41,29 @@ const createSystemFields = () => {
18
41
  storageId: "entryId",
19
42
  fieldId: "entryId",
20
43
  label: "Entry ID"
21
- }, {
22
- id: "createdOn",
23
- type: "datetime",
24
- storageId: "createdOn",
25
- fieldId: "createdOn",
26
- label: "Created On"
27
- }, {
28
- id: "savedOn",
29
- type: "datetime",
30
- storageId: "savedOn",
31
- fieldId: "savedOn",
32
- label: "Saved On"
33
- }, {
34
- id: "createdBy",
35
- type: "plainObject",
36
- storageId: "createdBy",
37
- fieldId: "createdBy",
38
- label: "Created By",
39
- settings: {
40
- path: "createdBy.id"
41
- }
42
- }, {
44
+ }, ...onMetaFields, ...byMetaFields, {
43
45
  id: "meta",
44
46
  type: "plainObject",
45
47
  storageId: "meta",
46
48
  fieldId: "meta",
47
49
  label: "Meta"
48
50
  }, {
49
- id: "ownedBy",
50
- type: "plainObject",
51
- storageId: "ownedBy",
52
- fieldId: "ownedBy",
53
- label: "Owned By",
51
+ id: "wbyAco_location",
52
+ type: "object",
53
+ storageId: "location",
54
+ label: "Location",
55
+ fieldId: "wbyAco_location",
54
56
  settings: {
55
- path: "ownedBy.id"
57
+ fields: [{
58
+ id: "folderId",
59
+ type: "text",
60
+ fieldId: "folderId",
61
+ label: "Folder ID",
62
+ storageId: "folderId",
63
+ settings: {
64
+ path: "location.folderId"
65
+ }
66
+ }]
56
67
  }
57
68
  }, {
58
69
  id: "version",
@@ -66,7 +77,14 @@ const createSystemFields = () => {
66
77
  storageId: "status",
67
78
  fieldId: "status",
68
79
  label: "Status"
80
+ }, {
81
+ id: "wbyDeleted",
82
+ type: "boolean",
83
+ storageId: "wbyDeleted",
84
+ fieldId: "wbyDeleted",
85
+ label: "Deleted"
69
86
  }];
70
87
  };
88
+ exports.createSystemFields = createSystemFields;
71
89
 
72
- exports.createSystemFields = createSystemFields;
90
+ //# sourceMappingURL=systemFields.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createSystemFields","id","type","storageId","fieldId","label","settings","path"],"sources":["systemFields.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\ntype Field = Pick<CmsModelField, \"id\" | \"type\" | \"storageId\" | \"fieldId\" | \"settings\" | \"label\">;\n\nexport const createSystemFields = (): Field[] => {\n return [\n {\n id: \"id\",\n type: \"text\",\n storageId: \"id\",\n fieldId: \"id\",\n label: \"ID\"\n },\n {\n id: \"entryId\",\n type: \"text\",\n storageId: \"entryId\",\n fieldId: \"entryId\",\n label: \"Entry ID\"\n },\n {\n id: \"createdOn\",\n type: \"datetime\",\n storageId: \"createdOn\",\n fieldId: \"createdOn\",\n label: \"Created On\"\n },\n {\n id: \"savedOn\",\n type: \"datetime\",\n storageId: \"savedOn\",\n fieldId: \"savedOn\",\n label: \"Saved On\"\n },\n {\n id: \"createdBy\",\n type: \"plainObject\",\n storageId: \"createdBy\",\n fieldId: \"createdBy\",\n label: \"Created By\",\n settings: {\n path: \"createdBy.id\"\n }\n },\n {\n id: \"meta\",\n type: \"plainObject\",\n storageId: \"meta\",\n fieldId: \"meta\",\n label: \"Meta\"\n },\n {\n id: \"ownedBy\",\n type: \"plainObject\",\n storageId: \"ownedBy\",\n fieldId: \"ownedBy\",\n label: \"Owned By\",\n settings: {\n path: \"ownedBy.id\"\n }\n },\n {\n id: \"version\",\n type: \"number\",\n storageId: \"version\",\n fieldId: \"version\",\n label: \"Version\"\n },\n {\n id: \"status\",\n type: \"text\",\n storageId: \"status\",\n fieldId: \"status\",\n label: \"Status\"\n }\n ];\n};\n"],"mappings":";;;;;;;AAIO,MAAMA,kBAAkB,GAAG,MAAe;EAC7C,OAAO,CACH;IACIC,EAAE,EAAE,IADR;IAEIC,IAAI,EAAE,MAFV;IAGIC,SAAS,EAAE,IAHf;IAIIC,OAAO,EAAE,IAJb;IAKIC,KAAK,EAAE;EALX,CADG,EAQH;IACIJ,EAAE,EAAE,SADR;IAEIC,IAAI,EAAE,MAFV;IAGIC,SAAS,EAAE,SAHf;IAIIC,OAAO,EAAE,SAJb;IAKIC,KAAK,EAAE;EALX,CARG,EAeH;IACIJ,EAAE,EAAE,WADR;IAEIC,IAAI,EAAE,UAFV;IAGIC,SAAS,EAAE,WAHf;IAIIC,OAAO,EAAE,WAJb;IAKIC,KAAK,EAAE;EALX,CAfG,EAsBH;IACIJ,EAAE,EAAE,SADR;IAEIC,IAAI,EAAE,UAFV;IAGIC,SAAS,EAAE,SAHf;IAIIC,OAAO,EAAE,SAJb;IAKIC,KAAK,EAAE;EALX,CAtBG,EA6BH;IACIJ,EAAE,EAAE,WADR;IAEIC,IAAI,EAAE,aAFV;IAGIC,SAAS,EAAE,WAHf;IAIIC,OAAO,EAAE,WAJb;IAKIC,KAAK,EAAE,YALX;IAMIC,QAAQ,EAAE;MACNC,IAAI,EAAE;IADA;EANd,CA7BG,EAuCH;IACIN,EAAE,EAAE,MADR;IAEIC,IAAI,EAAE,aAFV;IAGIC,SAAS,EAAE,MAHf;IAIIC,OAAO,EAAE,MAJb;IAKIC,KAAK,EAAE;EALX,CAvCG,EA8CH;IACIJ,EAAE,EAAE,SADR;IAEIC,IAAI,EAAE,aAFV;IAGIC,SAAS,EAAE,SAHf;IAIIC,OAAO,EAAE,SAJb;IAKIC,KAAK,EAAE,UALX;IAMIC,QAAQ,EAAE;MACNC,IAAI,EAAE;IADA;EANd,CA9CG,EAwDH;IACIN,EAAE,EAAE,SADR;IAEIC,IAAI,EAAE,QAFV;IAGIC,SAAS,EAAE,SAHf;IAIIC,OAAO,EAAE,SAJb;IAKIC,KAAK,EAAE;EALX,CAxDG,EA+DH;IACIJ,EAAE,EAAE,QADR;IAEIC,IAAI,EAAE,MAFV;IAGIC,SAAS,EAAE,QAHf;IAIIC,OAAO,EAAE,QAJb;IAKIC,KAAK,EAAE;EALX,CA/DG,CAAP;AAuEH,CAxEM"}
1
+ {"version":3,"names":["_constants","require","_startCase","_interopRequireDefault","createSystemFields","onMetaFields","ENTRY_META_FIELDS","filter","isDateTimeEntryMetaField","map","fieldName","id","type","storageId","fieldId","label","lodashStartCase","byMetaFields","isIdentityEntryMetaField","settings","path","fields","exports"],"sources":["systemFields.ts"],"sourcesContent":["import type { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport {\n ENTRY_META_FIELDS,\n isDateTimeEntryMetaField,\n isIdentityEntryMetaField\n} from \"@webiny/api-headless-cms/constants\";\nimport lodashStartCase from \"lodash/startCase\";\n\ntype Field = Pick<CmsModelField, \"id\" | \"type\" | \"storageId\" | \"fieldId\" | \"settings\" | \"label\">;\n\nexport const createSystemFields = (): Field[] => {\n const onMetaFields = ENTRY_META_FIELDS.filter(isDateTimeEntryMetaField).map(fieldName => {\n return {\n id: fieldName,\n type: \"datetime\",\n storageId: fieldName,\n fieldId: fieldName,\n label: lodashStartCase(fieldName)\n };\n });\n\n const byMetaFields = ENTRY_META_FIELDS.filter(isIdentityEntryMetaField).map(fieldName => {\n return {\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 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 ...onMetaFields,\n ...byMetaFields,\n\n {\n id: \"meta\",\n type: \"plainObject\",\n storageId: \"meta\",\n fieldId: \"meta\",\n label: \"Meta\"\n },\n {\n id: \"wbyAco_location\",\n type: \"object\",\n storageId: \"location\",\n label: \"Location\",\n fieldId: \"wbyAco_location\",\n settings: {\n fields: [\n {\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 {\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 id: \"wbyDeleted\",\n type: \"boolean\",\n storageId: \"wbyDeleted\",\n fieldId: \"wbyDeleted\",\n label: \"Deleted\"\n }\n ];\n};\n"],"mappings":";;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAKA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAIO,MAAMG,kBAAkB,GAAGA,CAAA,KAAe;EAC7C,MAAMC,YAAY,GAAGC,4BAAiB,CAACC,MAAM,CAACC,mCAAwB,CAAC,CAACC,GAAG,CAACC,SAAS,IAAI;IACrF,OAAO;MACHC,EAAE,EAAED,SAAS;MACbE,IAAI,EAAE,UAAU;MAChBC,SAAS,EAAEH,SAAS;MACpBI,OAAO,EAAEJ,SAAS;MAClBK,KAAK,EAAE,IAAAC,kBAAe,EAACN,SAAS;IACpC,CAAC;EACL,CAAC,CAAC;EAEF,MAAMO,YAAY,GAAGX,4BAAiB,CAACC,MAAM,CAACW,mCAAwB,CAAC,CAACT,GAAG,CAACC,SAAS,IAAI;IACrF,OAAO;MACHC,EAAE,EAAED,SAAS;MACbE,IAAI,EAAE,aAAa;MACnBC,SAAS,EAAEH,SAAS;MACpBI,O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,EAAE;EACX,CAAC,EACD;IACIJ,EAAE,EAAE,YAAY;IAChBC,IAAI,EAAE,SAAS;IACfC,SAAS,EAAE,YAAY;IACvBC,OAAO,EAAE,YAAY;IACrBC,KAAK,EAAE;EACX,CAAC,CACJ;AACL,CAAC;AAACO,OAAA,CAAAlB,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { Field } from "./types";
1
+ import type { Field } from "./types";
2
2
  interface Params extends Pick<Field, "transform"> {
3
3
  value: any;
4
4
  }
@@ -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,8 @@ 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
  };
16
+ exports.transformValue = transformValue;
18
17
 
19
- exports.transformValue = transformValue;
18
+ //# sourceMappingURL=transform.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["transformValue","value","transform","Array","isArray","map","v"],"sources":["transform.ts"],"sourcesContent":["import { Field } from \"./types\";\n\ninterface Params extends Pick<Field, \"transform\"> {\n value: any;\n}\nexport const transformValue = ({ value, transform }: Params): any => {\n if (Array.isArray(value)) {\n return value.map(v => transform(v));\n }\n return transform(value);\n};\n"],"mappings":";;;;;;;AAKO,MAAMA,cAAc,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAAuC;EACjE,IAAIC,KAAK,CAACC,OAAN,CAAcH,KAAd,CAAJ,EAA0B;IACtB,OAAOA,KAAK,CAACI,GAAN,CAAUC,CAAC,IAAIJ,SAAS,CAACI,CAAD,CAAxB,CAAP;EACH;;EACD,OAAOJ,SAAS,CAACD,KAAD,CAAhB;AACH,CALM"}
1
+ {"version":3,"names":["transformValue","value","transform","Array","isArray","map","v","exports"],"sources":["transform.ts"],"sourcesContent":["import type { 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,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;AAACM,OAAA,CAAAP,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { CmsModelField } from "@webiny/api-headless-cms/types";
2
- import { CreatePathCallable } from "../../../plugins";
1
+ import type { CmsModelField } from "@webiny/api-headless-cms/types";
2
+ import type { CreatePathCallable } from "../../../plugins";
3
3
  interface FieldValueTransform {
4
4
  (value: any): any;
5
5
  }
@@ -2,4 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
- });
5
+ });
6
+
7
+ //# 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\";\nimport type { 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":"","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { CmsEntryListWhere } from "@webiny/api-headless-cms/types";
1
+ import type { CmsEntryListWhere } from "@webiny/api-headless-cms/types";
2
2
  export declare const getWhereValues: (value: unknown, condition: "AND" | "OR") => CmsEntryListWhere[];
@@ -1,17 +1,13 @@
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.getWhereValues = void 0;
9
-
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
9
  const getWhereValues = (value, condition) => {
13
10
  const values = value;
14
-
15
11
  if (!Array.isArray(values)) {
16
12
  throw new _error.default(`Trying to run filtering with "${condition}", but the value sent is not an array.`, `MALFORMED_${condition}_CONDITION`, {
17
13
  value
@@ -21,8 +17,8 @@ const getWhereValues = (value, condition) => {
21
17
  value
22
18
  });
23
19
  }
24
-
25
20
  return values;
26
21
  };
22
+ exports.getWhereValues = getWhereValues;
27
23
 
28
- exports.getWhereValues = getWhereValues;
24
+ //# 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,KAAD,EAAiBC,SAAjB,KAA6C;EACvE,MAAMC,MAAM,GAAGF,KAAf;;EACA,IAAI,CAACG,KAAK,CAACC,OAAN,CAAcF,MAAd,CAAL,EAA4B;IACxB,MAAM,IAAIG,cAAJ,CACD,iCAAgCJ,SAAU,wCADzC,EAED,aAAYA,SAAU,YAFrB,EAGF;MACID;IADJ,CAHE,CAAN;EAOH,CARD,MAQO,IAAIE,MAAM,CAACI,MAAP,KAAkB,CAAtB,EAAyB;IAC5B,MAAM,IAAID,cAAJ,CACD,iCAAgCJ,SAAU,uCADzC,EAED,aAAYA,SAAU,YAFrB,EAGF;MACID;IADJ,CAHE,CAAN;EAOH;;EACD,OAAOE,MAAP;AACH,CApBM"}
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","getWhereValues","value","condition","values","Array","isArray","WebinyError","length","exports"],"sources":["values.ts"],"sourcesContent":["import type { 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,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,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,IAAIG,cAAW,CACjB,iCAAiCJ,SAAS,wCAAwC,EAClF,aAAaA,SAAS,YAAY,EAClC;MACID;IACJ,CACJ,CAAC;EACL,CAAC,MAAM,IAAIE,MAAM,CAACI,MAAM,KAAK,CAAC,EAAE;IAC5B,MAAM,IAAID,cAAW,CACjB,iCAAiCJ,SAAS,uCAAuC,EACjF,aAAaA,SAAS,YAAY,EAClC;MACID;IACJ,CACJ,CAAC;EACL;EACA,OAAOE,MAAM;AACjB,CAAC;AAACK,OAAA,CAAAR,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -4,20 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.extractWhereParams = void 0;
7
-
8
7
  const extractWhereParams = key => {
9
- const result = key.split("_");
8
+ const isWbyAco = key.match("wbyAco_") !== null;
9
+ const result = key.replace("wbyAco_", "").split("_");
10
10
  const fieldId = result.shift();
11
-
12
11
  if (!fieldId) {
13
12
  return null;
14
13
  }
15
-
16
14
  const rawOp = result.length === 0 ? "eq" : result.join("_");
17
15
  /**
18
16
  * When rawOp is not, it means it is equal negated so just return that.
19
17
  */
20
-
21
18
  if (rawOp === "not") {
22
19
  return {
23
20
  fieldId,
@@ -25,14 +22,14 @@ const extractWhereParams = key => {
25
22
  negate: true
26
23
  };
27
24
  }
28
-
29
25
  const negate = rawOp.match("not_") !== null;
30
26
  const operation = rawOp.replace("not_", "");
31
27
  return {
32
- fieldId,
28
+ fieldId: isWbyAco ? `wbyAco_${fieldId}` : fieldId,
33
29
  operation,
34
30
  negate
35
31
  };
36
32
  };
33
+ exports.extractWhereParams = extractWhereParams;
37
34
 
38
- exports.extractWhereParams = extractWhereParams;
35
+ //# sourceMappingURL=where.js.map