@webiny/api-headless-cms-ddb 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.7be00a75a9

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 (172) hide show
  1. package/README.md +6 -20
  2. package/definitions/entry.d.ts +4 -5
  3. package/definitions/entry.js +9 -94
  4. package/definitions/entry.js.map +1 -1
  5. package/definitions/group.d.ts +4 -5
  6. package/definitions/group.js +9 -68
  7. package/definitions/group.js.map +1 -1
  8. package/definitions/model.d.ts +4 -5
  9. package/definitions/model.js +9 -90
  10. package/definitions/model.js.map +1 -1
  11. package/definitions/table.d.ts +4 -6
  12. package/definitions/table.js +8 -30
  13. package/definitions/table.js.map +1 -1
  14. package/definitions/types.d.ts +65 -0
  15. package/definitions/types.js +0 -0
  16. package/dynamoDb/index.d.ts +1 -1
  17. package/dynamoDb/index.js +11 -20
  18. package/dynamoDb/index.js.map +1 -1
  19. package/dynamoDb/path/locationFolderId.d.ts +2 -0
  20. package/dynamoDb/path/locationFolderId.js +21 -0
  21. package/dynamoDb/path/locationFolderId.js.map +1 -0
  22. package/dynamoDb/path/plainObject.d.ts +1 -1
  23. package/dynamoDb/path/plainObject.js +13 -37
  24. package/dynamoDb/path/plainObject.js.map +1 -1
  25. package/dynamoDb/transformValue/datetime.d.ts +1 -1
  26. package/dynamoDb/transformValue/datetime.js +27 -50
  27. package/dynamoDb/transformValue/datetime.js.map +1 -1
  28. package/index.d.ts +2 -3
  29. package/index.js +83 -139
  30. package/index.js.map +1 -1
  31. package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
  32. package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
  33. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  34. package/operations/entry/dataLoader/constants.d.ts +1 -0
  35. package/operations/entry/dataLoader/constants.js +5 -0
  36. package/operations/entry/dataLoader/constants.js.map +1 -0
  37. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  38. package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
  39. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  40. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  41. package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
  42. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  43. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  44. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +40 -0
  45. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  46. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  47. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +40 -0
  48. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  49. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  50. package/operations/entry/dataLoader/getRevisionById.js +42 -0
  51. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  52. package/operations/entry/dataLoader/index.d.ts +8 -0
  53. package/operations/entry/dataLoader/index.js +18 -0
  54. package/operations/entry/dataLoader/index.js.map +1 -0
  55. package/operations/entry/dataLoader/types.d.ts +6 -0
  56. package/operations/entry/dataLoader/types.js +0 -0
  57. package/operations/entry/dataLoaders.d.ts +14 -30
  58. package/operations/entry/dataLoaders.js +83 -314
  59. package/operations/entry/dataLoaders.js.map +1 -1
  60. package/operations/entry/filtering/createExpressions.d.ts +27 -0
  61. package/operations/entry/filtering/createExpressions.js +124 -0
  62. package/operations/entry/filtering/createExpressions.js.map +1 -0
  63. package/operations/entry/filtering/createFields.d.ts +16 -0
  64. package/operations/entry/filtering/createFields.js +93 -0
  65. package/operations/entry/filtering/createFields.js.map +1 -0
  66. package/operations/entry/filtering/extractSort.d.ts +17 -0
  67. package/operations/entry/filtering/extractSort.js +60 -0
  68. package/operations/entry/filtering/extractSort.js.map +1 -0
  69. package/operations/entry/filtering/filter.d.ts +16 -0
  70. package/operations/entry/filtering/filter.js +85 -0
  71. package/operations/entry/filtering/filter.js.map +1 -0
  72. package/operations/entry/filtering/fullTextSearch.d.ts +14 -0
  73. package/operations/entry/filtering/fullTextSearch.js +25 -0
  74. package/operations/entry/filtering/fullTextSearch.js.map +1 -0
  75. package/operations/entry/filtering/getValue.d.ts +5 -0
  76. package/operations/entry/filtering/getValue.js +37 -0
  77. package/operations/entry/filtering/getValue.js.map +1 -0
  78. package/operations/entry/filtering/index.d.ts +2 -0
  79. package/operations/entry/filtering/index.js +2 -0
  80. package/operations/entry/filtering/mapPlugins.d.ts +8 -0
  81. package/operations/entry/filtering/mapPlugins.js +18 -0
  82. package/operations/entry/filtering/mapPlugins.js.map +1 -0
  83. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +2 -0
  84. package/operations/entry/filtering/plugins/defaultFilterCreate.js +33 -0
  85. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -0
  86. package/operations/entry/filtering/plugins/index.d.ts +1 -0
  87. package/operations/entry/filtering/plugins/index.js +13 -0
  88. package/operations/entry/filtering/plugins/index.js.map +1 -0
  89. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +2 -0
  90. package/operations/entry/filtering/plugins/objectFilterCreate.js +68 -0
  91. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -0
  92. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +3 -0
  93. package/operations/entry/filtering/plugins/refFilterCreate.js +63 -0
  94. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -0
  95. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +2 -0
  96. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +49 -0
  97. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -0
  98. package/operations/entry/filtering/sort.d.ts +12 -0
  99. package/operations/entry/filtering/sort.js +41 -0
  100. package/operations/entry/filtering/sort.js.map +1 -0
  101. package/operations/entry/filtering/systemFields.d.ts +2 -0
  102. package/operations/entry/filtering/systemFields.js +149 -0
  103. package/operations/entry/filtering/systemFields.js.map +1 -0
  104. package/operations/entry/filtering/transform.d.ts +6 -0
  105. package/operations/entry/filtering/transform.js +7 -0
  106. package/operations/entry/filtering/transform.js.map +1 -0
  107. package/operations/entry/filtering/types.d.ts +40 -0
  108. package/operations/entry/filtering/types.js +0 -0
  109. package/operations/entry/filtering/values.d.ts +2 -0
  110. package/operations/entry/filtering/values.js +15 -0
  111. package/operations/entry/filtering/values.js.map +1 -0
  112. package/operations/entry/filtering/where.d.ts +5 -0
  113. package/operations/entry/filtering/where.js +22 -0
  114. package/operations/entry/filtering/where.js.map +1 -0
  115. package/operations/entry/index.d.ts +5 -4
  116. package/operations/entry/index.js +931 -845
  117. package/operations/entry/index.js.map +1 -1
  118. package/operations/entry/keys.d.ts +46 -2
  119. package/operations/entry/keys.js +53 -66
  120. package/operations/entry/keys.js.map +1 -1
  121. package/operations/group/index.d.ts +4 -5
  122. package/operations/group/index.js +116 -187
  123. package/operations/group/index.js.map +1 -1
  124. package/operations/model/index.d.ts +3 -3
  125. package/operations/model/index.js +102 -158
  126. package/operations/model/index.js.map +1 -1
  127. package/package.json +34 -33
  128. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +5 -4
  129. package/plugins/CmsEntryFieldFilterPathPlugin.js +25 -50
  130. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
  131. package/plugins/CmsEntryFieldFilterPlugin.d.ts +43 -0
  132. package/plugins/CmsEntryFieldFilterPlugin.js +20 -0
  133. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -0
  134. package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
  135. package/plugins/CmsEntryFieldSortingPlugin.js +20 -0
  136. package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
  137. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
  138. package/plugins/CmsFieldFilterValueTransformPlugin.js +19 -0
  139. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
  140. package/plugins/index.d.ts +4 -1
  141. package/plugins/index.js +4 -18
  142. package/types.d.ts +28 -21
  143. package/types.js +8 -15
  144. package/types.js.map +1 -1
  145. package/definitions/settings.d.ts +0 -9
  146. package/definitions/settings.js +0 -58
  147. package/definitions/settings.js.map +0 -1
  148. package/definitions/system.d.ts +0 -9
  149. package/definitions/system.js +0 -46
  150. package/definitions/system.js.map +0 -1
  151. package/dynamoDb/storage/date.d.ts +0 -2
  152. package/dynamoDb/storage/date.js +0 -99
  153. package/dynamoDb/storage/date.js.map +0 -1
  154. package/dynamoDb/storage/longText.d.ts +0 -10
  155. package/dynamoDb/storage/longText.js +0 -101
  156. package/dynamoDb/storage/longText.js.map +0 -1
  157. package/dynamoDb/storage/richText.d.ts +0 -2
  158. package/dynamoDb/storage/richText.js +0 -113
  159. package/dynamoDb/storage/richText.js.map +0 -1
  160. package/operations/entry/systemFields.d.ts +0 -2
  161. package/operations/entry/systemFields.js +0 -74
  162. package/operations/entry/systemFields.js.map +0 -1
  163. package/operations/entry/utils.d.ts +0 -36
  164. package/operations/entry/utils.js +0 -680
  165. package/operations/entry/utils.js.map +0 -1
  166. package/operations/settings/index.d.ts +0 -7
  167. package/operations/settings/index.js +0 -135
  168. package/operations/settings/index.js.map +0 -1
  169. package/operations/system/index.d.ts +0 -7
  170. package/operations/system/index.js +0 -99
  171. package/operations/system/index.js.map +0 -1
  172. package/plugins/index.js.map +0 -1
@@ -0,0 +1,5 @@
1
+ /**
2
+ * A wrapper function for the find function.
3
+ * Basically it transforms input paths to an array (and runs various checks).
4
+ */
5
+ export declare const getValue: (target: Record<string, any>, input: string | string[]) => any;
@@ -0,0 +1,37 @@
1
+ const addArrayResult = (target, result)=>{
2
+ for (const r of result)if (!target.some((t)=>r === t)) target.push(r);
3
+ };
4
+ const find = (target, input)=>{
5
+ const paths = [
6
+ ...input
7
+ ];
8
+ const path = paths.shift();
9
+ if (!path) return;
10
+ const value = target?.[path];
11
+ if (void 0 === value) return;
12
+ if (0 === paths.length) return value;
13
+ if (Array.isArray(value)) {
14
+ if (0 === value.length) return;
15
+ return value.reduce((collection, v)=>{
16
+ const result = find(v, paths);
17
+ if (void 0 === result) return collection;
18
+ if (Array.isArray(result)) {
19
+ addArrayResult(collection, result);
20
+ return collection;
21
+ }
22
+ collection.push(result);
23
+ return collection;
24
+ }, []);
25
+ }
26
+ return find(value, paths);
27
+ };
28
+ const getValue = (target, input)=>{
29
+ const paths = Array.isArray(input) ? input : input.split(".");
30
+ if (0 === paths.length) throw new Error("Path is empty!");
31
+ const filtered = paths.filter(Boolean);
32
+ if (paths.length !== filtered.length) throw new Error(`Input path is different than the filtered empty path string. (${paths.join(".")} to ${filtered.join(".")})`);
33
+ return find(target, paths);
34
+ };
35
+ export { getValue };
36
+
37
+ //# sourceMappingURL=getValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/filtering/getValue.js","sources":["../../../../src/operations/entry/filtering/getValue.ts"],"sourcesContent":["const addArrayResult = (target: any[], result: any[]): void => {\n for (const r of result) {\n if (target.some(t => r === t)) {\n continue;\n }\n target.push(r);\n }\n};\n/**\n * A recursive function which goes through given input paths and returns the value in it.\n * In case a path is an array, it goes through the array of those values to get values further down the path line.\n */\nconst find = (target: Record<string, any> | undefined, input: string[]): any[] | undefined => {\n const paths = [...input];\n const path = paths.shift();\n\n if (!path) {\n return undefined;\n }\n\n const value = target?.[path];\n if (value === undefined) {\n return undefined;\n }\n if (paths.length === 0) {\n return value;\n } else if (Array.isArray(value)) {\n if (value.length === 0) {\n return undefined;\n }\n return value.reduce<any[]>((collection, v) => {\n const result = find(v, paths);\n if (result === undefined) {\n return collection;\n } else if (Array.isArray(result)) {\n addArrayResult(collection, result);\n return collection;\n }\n collection.push(result);\n return collection;\n }, []);\n }\n return find(value, paths);\n};\n/**\n * A wrapper function for the find function.\n * Basically it transforms input paths to an array (and runs various checks).\n */\nexport const getValue = (target: Record<string, any>, input: string | string[]): any => {\n const paths = Array.isArray(input) ? input : input.split(\".\");\n if (paths.length === 0) {\n throw new Error(`Path is empty!`);\n }\n const filtered = paths.filter(Boolean);\n if (paths.length !== filtered.length) {\n throw new Error(\n `Input path is different than the filtered empty path string. (${paths.join(\n \".\"\n )} to ${filtered.join(\".\")})`\n );\n }\n\n return find(target, paths);\n};\n"],"names":["addArrayResult","target","result","r","t","find","input","paths","path","value","undefined","Array","collection","v","getValue","Error","filtered","Boolean"],"mappings":"AAAA,MAAMA,iBAAiB,CAACC,QAAeC;IACnC,KAAK,MAAMC,KAAKD,OACZ,KAAID,OAAO,IAAI,CAACG,CAAAA,IAAKD,MAAMC,IAG3BH,OAAO,IAAI,CAACE;AAEpB;AAKA,MAAME,OAAO,CAACJ,QAAyCK;IACnD,MAAMC,QAAQ;WAAID;KAAM;IACxB,MAAME,OAAOD,MAAM,KAAK;IAExB,IAAI,CAACC,MACD;IAGJ,MAAMC,QAAQR,QAAQ,CAACO,KAAK;IAC5B,IAAIC,AAAUC,WAAVD,OACA;IAEJ,IAAIF,AAAiB,MAAjBA,MAAM,MAAM,EACZ,OAAOE;IACJ,IAAIE,MAAM,OAAO,CAACF,QAAQ;QAC7B,IAAIA,AAAiB,MAAjBA,MAAM,MAAM,EACZ;QAEJ,OAAOA,MAAM,MAAM,CAAQ,CAACG,YAAYC;YACpC,MAAMX,SAASG,KAAKQ,GAAGN;YACvB,IAAIL,AAAWQ,WAAXR,QACA,OAAOU;YACJ,IAAID,MAAM,OAAO,CAACT,SAAS;gBAC9BF,eAAeY,YAAYV;gBAC3B,OAAOU;YACX;YACAA,WAAW,IAAI,CAACV;YAChB,OAAOU;QACX,GAAG,EAAE;IACT;IACA,OAAOP,KAAKI,OAAOF;AACvB;AAKO,MAAMO,WAAW,CAACb,QAA6BK;IAClD,MAAMC,QAAQI,MAAM,OAAO,CAACL,SAASA,QAAQA,MAAM,KAAK,CAAC;IACzD,IAAIC,AAAiB,MAAjBA,MAAM,MAAM,EACZ,MAAM,IAAIQ,MAAM;IAEpB,MAAMC,WAAWT,MAAM,MAAM,CAACU;IAC9B,IAAIV,MAAM,MAAM,KAAKS,SAAS,MAAM,EAChC,MAAM,IAAID,MACN,CAAC,8DAA8D,EAAER,MAAM,IAAI,CACvE,KACF,IAAI,EAAES,SAAS,IAAI,CAAC,KAAK,CAAC,CAAC;IAIrC,OAAOX,KAAKJ,QAAQM;AACxB"}
@@ -0,0 +1,2 @@
1
+ export { filter } from "./filter.js";
2
+ export { sort } from "./sort.js";
@@ -0,0 +1,2 @@
1
+ export { filter } from "./filter.js";
2
+ export { sort } from "./sort.js";
@@ -0,0 +1,8 @@
1
+ import type { Plugin, PluginsContainer } from "@webiny/plugins/types.js";
2
+ interface Params {
3
+ plugins: PluginsContainer;
4
+ type: string;
5
+ property: string;
6
+ }
7
+ export declare const getMappedPlugins: <T extends Plugin>(params: Params) => Record<string, T>;
8
+ export {};
@@ -0,0 +1,18 @@
1
+ import error from "@webiny/error";
2
+ const getMappedPlugins = (params)=>{
3
+ const { plugins: pluginsContainer, type, property } = params;
4
+ const plugins = pluginsContainer.byType(type);
5
+ if (0 === plugins.length) return {};
6
+ return plugins.reduce((collection, plugin)=>{
7
+ const key = plugin[property];
8
+ if ("string" != typeof key) throw new error("Property to map the plugins on must be a string.", "PLUGIN_PROPERTY_ERROR", {
9
+ type,
10
+ property
11
+ });
12
+ collection[key] = plugin;
13
+ return collection;
14
+ }, {});
15
+ };
16
+ export { getMappedPlugins };
17
+
18
+ //# sourceMappingURL=mapPlugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/filtering/mapPlugins.js","sources":["../../../../src/operations/entry/filtering/mapPlugins.ts"],"sourcesContent":["import type { Plugin, PluginsContainer } from \"@webiny/plugins/types.js\";\nimport WebinyError from \"@webiny/error\";\n\ninterface Params {\n plugins: PluginsContainer;\n type: string;\n property: string;\n}\nexport const getMappedPlugins = <T extends Plugin>(params: Params) => {\n const { plugins: pluginsContainer, type, property } = params;\n const plugins = pluginsContainer.byType<T>(type);\n if (plugins.length === 0) {\n return {};\n }\n return plugins.reduce<Record<string, T>>((collection, plugin) => {\n const key: keyof typeof plugin = plugin[property];\n if (typeof key !== \"string\") {\n throw new WebinyError(\n \"Property to map the plugins on must be a string.\",\n \"PLUGIN_PROPERTY_ERROR\",\n {\n type,\n property\n }\n );\n }\n collection[key] = plugin;\n return collection;\n }, {});\n};\n"],"names":["getMappedPlugins","params","pluginsContainer","type","property","plugins","collection","plugin","key","WebinyError"],"mappings":";AAQO,MAAMA,mBAAmB,CAAmBC;IAC/C,MAAM,EAAE,SAASC,gBAAgB,EAAEC,IAAI,EAAEC,QAAQ,EAAE,GAAGH;IACtD,MAAMI,UAAUH,iBAAiB,MAAM,CAAIC;IAC3C,IAAIE,AAAmB,MAAnBA,QAAQ,MAAM,EACd,OAAO,CAAC;IAEZ,OAAOA,QAAQ,MAAM,CAAoB,CAACC,YAAYC;QAClD,MAAMC,MAA2BD,MAAM,CAACH,SAAS;QACjD,IAAI,AAAe,YAAf,OAAOI,KACP,MAAM,IAAIC,MACN,oDACA,yBACA;YACIN;YACAC;QACJ;QAGRE,UAAU,CAACE,IAAI,GAAGD;QAClB,OAAOD;IACX,GAAG,CAAC;AACR"}
@@ -0,0 +1,2 @@
1
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
2
+ export declare const createDefaultFilterCreate: () => CmsEntryFieldFilterPlugin<any>;
@@ -0,0 +1,33 @@
1
+ import error from "@webiny/error";
2
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
3
+ const createDefaultFilterCreate = ()=>{
4
+ const plugin = new CmsEntryFieldFilterPlugin({
5
+ fieldType: CmsEntryFieldFilterPlugin.ALL,
6
+ create: (params)=>{
7
+ const { negate, transformValue, field, compareValue, valueFilterRegistry } = params;
8
+ const filter = valueFilterRegistry.get(params.operation);
9
+ if (!filter) throw new error(`Missing ValueFilterPlugin for operation "${params.operation}".`, "MISSING_OPERATION_PLUGIN", {
10
+ operation: params.operation
11
+ });
12
+ return {
13
+ negate,
14
+ transformValue,
15
+ field,
16
+ compareValue,
17
+ fieldPathId: [
18
+ ...field.parents.map((f)=>f.fieldId),
19
+ field.fieldId
20
+ ].join("."),
21
+ path: field.createPath({
22
+ field
23
+ }),
24
+ filter
25
+ };
26
+ }
27
+ });
28
+ plugin.name = "headless-cms.ddb.filter.default";
29
+ return plugin;
30
+ };
31
+ export { createDefaultFilterCreate };
32
+
33
+ //# sourceMappingURL=defaultFilterCreate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/filtering/plugins/defaultFilterCreate.js","sources":["../../../../../src/operations/entry/filtering/plugins/defaultFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\n\nexport const createDefaultFilterCreate = () => {\n const plugin = new CmsEntryFieldFilterPlugin({\n fieldType: CmsEntryFieldFilterPlugin.ALL,\n create: params => {\n const { negate, transformValue, field, compareValue, valueFilterRegistry } = params;\n const filter = valueFilterRegistry.get(params.operation);\n if (!filter) {\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 filter\n };\n }\n });\n\n plugin.name = `headless-cms.ddb.filter.default`;\n\n return plugin;\n};\n"],"names":["createDefaultFilterCreate","plugin","CmsEntryFieldFilterPlugin","params","negate","transformValue","field","compareValue","valueFilterRegistry","filter","WebinyError","f"],"mappings":";;AAGO,MAAMA,4BAA4B;IACrC,MAAMC,SAAS,IAAIC,0BAA0B;QACzC,WAAWA,0BAA0B,GAAG;QACxC,QAAQC,CAAAA;YACJ,MAAM,EAAEC,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAAEC,YAAY,EAAEC,mBAAmB,EAAE,GAAGL;YAC7E,MAAMM,SAASD,oBAAoB,GAAG,CAACL,OAAO,SAAS;YACvD,IAAI,CAACM,QACD,MAAM,IAAIC,MACN,CAAC,yCAAyC,EAAEP,OAAO,SAAS,CAAC,EAAE,CAAC,EAChE,4BACA;gBACI,WAAWA,OAAO,SAAS;YAC/B;YAGR,OAAO;gBACHC;gBACAC;gBACAC;gBACAC;gBACA,aAAa;uBAAID,MAAM,OAAO,CAAC,GAAG,CAACK,CAAAA,IAAKA,EAAE,OAAO;oBAAGL,MAAM,OAAO;iBAAC,CAAC,IAAI,CAAC;gBACxE,MAAMA,MAAM,UAAU,CAAC;oBACnBA;gBACJ;gBACAG;YACJ;QACJ;IACJ;IAEAR,OAAO,IAAI,GAAG;IAEd,OAAOA;AACX"}
@@ -0,0 +1 @@
1
+ export declare const createFilterCreatePlugins: () => import("../../../../index.js").CmsEntryFieldFilterPlugin<import("@webiny/api/types.js").GenericRecord | null | undefined>[];
@@ -0,0 +1,13 @@
1
+ import { createDefaultFilterCreate } from "./defaultFilterCreate.js";
2
+ import { createRefFilterCreate } from "./refFilterCreate.js";
3
+ import { objectFilterCreate } from "./objectFilterCreate.js";
4
+ import { searchableJsonFilterCreate } from "./searchableJsonFilterCreate.js";
5
+ const createFilterCreatePlugins = ()=>[
6
+ createDefaultFilterCreate(),
7
+ createRefFilterCreate(),
8
+ objectFilterCreate(),
9
+ searchableJsonFilterCreate()
10
+ ];
11
+ export { createFilterCreatePlugins };
12
+
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/filtering/plugins/index.js","sources":["../../../../../src/operations/entry/filtering/plugins/index.ts"],"sourcesContent":["import { createDefaultFilterCreate } from \"./defaultFilterCreate.js\";\nimport { createRefFilterCreate } from \"./refFilterCreate.js\";\nimport { objectFilterCreate } from \"./objectFilterCreate.js\";\nimport { searchableJsonFilterCreate } from \"./searchableJsonFilterCreate.js\";\n\nexport const createFilterCreatePlugins = () => {\n return [\n createDefaultFilterCreate(),\n createRefFilterCreate(),\n objectFilterCreate(),\n searchableJsonFilterCreate()\n ];\n};\n"],"names":["createFilterCreatePlugins","createDefaultFilterCreate","createRefFilterCreate","objectFilterCreate","searchableJsonFilterCreate"],"mappings":";;;;AAKO,MAAMA,4BAA4B,IAC9B;QACHC;QACAC;QACAC;QACAC;KACH"}
@@ -0,0 +1,2 @@
1
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
2
+ export declare const objectFilterCreate: () => CmsEntryFieldFilterPlugin<any>;
@@ -0,0 +1,68 @@
1
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
2
+ import { extractWhereParams } from "../where.js";
3
+ import error from "@webiny/error";
4
+ import { transformValue } from "../transform.js";
5
+ import { getBaseFieldType } from "@webiny/api-headless-cms/utils/getBaseFieldType.js";
6
+ const objectFilterCreate = ()=>{
7
+ const plugin = new CmsEntryFieldFilterPlugin({
8
+ fieldType: "object",
9
+ create: (params)=>{
10
+ const { value: objectValue, valueFilterRegistry, transformValuePlugins, getFilterCreatePlugin, field: parentField, fields } = params;
11
+ const filters = [];
12
+ for(const key in objectValue){
13
+ const value = objectValue[key];
14
+ if (void 0 === value) continue;
15
+ const whereParams = extractWhereParams(key);
16
+ if (!whereParams) continue;
17
+ const { negate, fieldId, operation } = whereParams;
18
+ const fieldPath = parentField.parents.map((p)=>p.fieldId).concat([
19
+ parentField.fieldId,
20
+ fieldId
21
+ ]).join(".");
22
+ const field = fields[fieldPath];
23
+ if (!field) throw new error(`There is no field with the field path "${fieldPath}".`, "FIELD_ERROR", {
24
+ fieldId
25
+ });
26
+ const fieldType = getBaseFieldType(field);
27
+ const filterCreatePlugin = getFilterCreatePlugin(fieldType);
28
+ const transformValuePlugin = transformValuePlugins[fieldType];
29
+ const transformValueCallable = (value)=>{
30
+ if (!transformValuePlugin) return value;
31
+ return transformValuePlugin.transform({
32
+ field,
33
+ value
34
+ });
35
+ };
36
+ const result = filterCreatePlugin.create({
37
+ key,
38
+ value,
39
+ valueFilterRegistry,
40
+ transformValuePlugins,
41
+ getFilterCreatePlugin,
42
+ operation,
43
+ negate,
44
+ field,
45
+ fields,
46
+ compareValue: transformValue({
47
+ value,
48
+ transform: transformValueCallable
49
+ }),
50
+ transformValue: transformValueCallable
51
+ });
52
+ if (result) {
53
+ if (Array.isArray(result)) {
54
+ filters.push(...result);
55
+ continue;
56
+ }
57
+ filters.push(result);
58
+ }
59
+ }
60
+ return filters;
61
+ }
62
+ });
63
+ plugin.name = "headless-cms.ddb.filter.object";
64
+ return plugin;
65
+ };
66
+ export { objectFilterCreate };
67
+
68
+ //# sourceMappingURL=objectFilterCreate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/filtering/plugins/objectFilterCreate.js","sources":["../../../../../src/operations/entry/filtering/plugins/objectFilterCreate.ts"],"sourcesContent":["import { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where.js\";\nimport WebinyError from \"@webiny/error\";\nimport type { CmsFieldFilterValueTransformPlugin } from \"~/types.js\";\nimport { transformValue } from \"~/operations/entry/filtering/transform.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\nexport const objectFilterCreate = () => {\n const plugin = new CmsEntryFieldFilterPlugin({\n fieldType: \"object\",\n create: params => {\n const {\n value: objectValue,\n valueFilterRegistry,\n transformValuePlugins,\n getFilterCreatePlugin,\n field: parentField,\n fields\n } = params;\n\n const filters = [];\n\n for (const key in objectValue) {\n const value = objectValue[key];\n if (value === undefined) {\n continue;\n }\n const whereParams = extractWhereParams(key);\n if (!whereParams) {\n continue;\n }\n const { negate, fieldId, operation } = whereParams;\n\n const fieldPath = parentField.parents\n .map(p => p.fieldId)\n .concat([parentField.fieldId, fieldId])\n .join(\".\");\n\n const field = fields[fieldPath];\n if (!field) {\n throw new WebinyError(\n `There is no field with the field path \"${fieldPath}\".`,\n \"FIELD_ERROR\",\n {\n fieldId\n }\n );\n }\n\n const fieldType = getBaseFieldType(field);\n\n const filterCreatePlugin = getFilterCreatePlugin(fieldType);\n\n const transformValuePlugin: CmsFieldFilterValueTransformPlugin =\n transformValuePlugins[fieldType];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const result = filterCreatePlugin.create({\n key,\n value,\n valueFilterRegistry,\n transformValuePlugins,\n getFilterCreatePlugin,\n operation,\n negate,\n field,\n fields,\n compareValue: transformValue({\n value,\n transform: transformValueCallable\n }),\n transformValue: transformValueCallable\n });\n if (!result) {\n continue;\n }\n if (Array.isArray(result)) {\n filters.push(...result);\n continue;\n }\n\n filters.push(result);\n }\n return filters;\n }\n });\n\n plugin.name = `headless-cms.ddb.filter.object`;\n\n return plugin;\n};\n"],"names":["objectFilterCreate","plugin","CmsEntryFieldFilterPlugin","params","objectValue","valueFilterRegistry","transformValuePlugins","getFilterCreatePlugin","parentField","fields","filters","key","value","undefined","whereParams","extractWhereParams","negate","fieldId","operation","fieldPath","p","field","WebinyError","fieldType","getBaseFieldType","filterCreatePlugin","transformValuePlugin","transformValueCallable","result","transformValue","Array"],"mappings":";;;;;AAOO,MAAMA,qBAAqB;IAC9B,MAAMC,SAAS,IAAIC,0BAA0B;QACzC,WAAW;QACX,QAAQC,CAAAA;YACJ,MAAM,EACF,OAAOC,WAAW,EAClBC,mBAAmB,EACnBC,qBAAqB,EACrBC,qBAAqB,EACrB,OAAOC,WAAW,EAClBC,MAAM,EACT,GAAGN;YAEJ,MAAMO,UAAU,EAAE;YAElB,IAAK,MAAMC,OAAOP,YAAa;gBAC3B,MAAMQ,QAAQR,WAAW,CAACO,IAAI;gBAC9B,IAAIC,AAAUC,WAAVD,OACA;gBAEJ,MAAME,cAAcC,mBAAmBJ;gBACvC,IAAI,CAACG,aACD;gBAEJ,MAAM,EAAEE,MAAM,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGJ;gBAEvC,MAAMK,YAAYX,YAAY,OAAO,CAChC,GAAG,CAACY,CAAAA,IAAKA,EAAE,OAAO,EAClB,MAAM,CAAC;oBAACZ,YAAY,OAAO;oBAAES;iBAAQ,EACrC,IAAI,CAAC;gBAEV,MAAMI,QAAQZ,MAAM,CAACU,UAAU;gBAC/B,IAAI,CAACE,OACD,MAAM,IAAIC,MACN,CAAC,uCAAuC,EAAEH,UAAU,EAAE,CAAC,EACvD,eACA;oBACIF;gBACJ;gBAIR,MAAMM,YAAYC,iBAAiBH;gBAEnC,MAAMI,qBAAqBlB,sBAAsBgB;gBAEjD,MAAMG,uBACFpB,qBAAqB,CAACiB,UAAU;gBAEpC,MAAMI,yBAAyB,CAACf;oBAC5B,IAAI,CAACc,sBACD,OAAOd;oBAEX,OAAOc,qBAAqB,SAAS,CAAC;wBAClCL;wBACAT;oBACJ;gBACJ;gBAEA,MAAMgB,SAASH,mBAAmB,MAAM,CAAC;oBACrCd;oBACAC;oBACAP;oBACAC;oBACAC;oBACAW;oBACAF;oBACAK;oBACAZ;oBACA,cAAcoB,eAAe;wBACzBjB;wBACA,WAAWe;oBACf;oBACA,gBAAgBA;gBACpB;gBACA,IAAKC;oBAGL,IAAIE,MAAM,OAAO,CAACF,SAAS;wBACvBlB,QAAQ,IAAI,IAAIkB;wBAChB;oBACJ;oBAEAlB,QAAQ,IAAI,CAACkB;;YACjB;YACA,OAAOlB;QACX;IACJ;IAEAT,OAAO,IAAI,GAAG;IAEd,OAAOA;AACX"}
@@ -0,0 +1,3 @@
1
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
2
+ import type { GenericRecord } from "@webiny/api/types.js";
3
+ export declare const createRefFilterCreate: () => CmsEntryFieldFilterPlugin<GenericRecord | null | undefined>;
@@ -0,0 +1,63 @@
1
+ import error from "@webiny/error";
2
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
3
+ import { extractWhereParams } from "../where.js";
4
+ import { transformValue } from "../transform.js";
5
+ import { getBaseFieldType } from "@webiny/api-headless-cms/utils/getBaseFieldType.js";
6
+ const createRefFilterCreate = ()=>{
7
+ const plugin = new CmsEntryFieldFilterPlugin({
8
+ fieldType: "ref",
9
+ create: (params)=>{
10
+ const { valueFilterRegistry, transformValuePlugins, field } = params;
11
+ let value = params.value;
12
+ if (!value) value = {
13
+ entryId: null
14
+ };
15
+ const propertyFilters = Object.keys(value);
16
+ if (0 === propertyFilters.length) return null;
17
+ const filters = [];
18
+ for (const propertyFilter of propertyFilters){
19
+ const whereParams = extractWhereParams(propertyFilter);
20
+ if (!whereParams) continue;
21
+ const { fieldId: propertyId, operation: propertyOperation, negate } = whereParams;
22
+ const fieldType = getBaseFieldType(field);
23
+ const transformValuePlugin = transformValuePlugins[fieldType];
24
+ const transformValueCallable = (value)=>{
25
+ if (!transformValuePlugin) return value;
26
+ return transformValuePlugin.transform({
27
+ field,
28
+ value
29
+ });
30
+ };
31
+ const filter = valueFilterRegistry.get(propertyOperation);
32
+ if (!filter) throw new error(`Missing operation filter for "${propertyOperation}".`, "MISSING_OPERATION_FILTER");
33
+ const paths = [
34
+ field.createPath({
35
+ field
36
+ }),
37
+ propertyId
38
+ ];
39
+ filters.push({
40
+ field,
41
+ path: paths.join("."),
42
+ fieldPathId: [
43
+ ...field.parents.map((f)=>f.fieldId),
44
+ field.fieldId
45
+ ].join("."),
46
+ filter,
47
+ negate,
48
+ compareValue: transformValue({
49
+ value: value[propertyFilter],
50
+ transform: transformValueCallable
51
+ }),
52
+ transformValue: transformValueCallable
53
+ });
54
+ }
55
+ return filters;
56
+ }
57
+ });
58
+ plugin.name = "headless-cms.ddb.filter.ref";
59
+ return plugin;
60
+ };
61
+ export { createRefFilterCreate };
62
+
63
+ //# sourceMappingURL=refFilterCreate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/filtering/plugins/refFilterCreate.js","sources":["../../../../../src/operations/entry/filtering/plugins/refFilterCreate.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsEntryFieldFilterPluginCreateResponse } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where.js\";\nimport { transformValue } from \"~/operations/entry/filtering/transform.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\nexport const createRefFilterCreate = () => {\n const plugin = new CmsEntryFieldFilterPlugin<GenericRecord | null | undefined>({\n fieldType: \"ref\",\n create: params => {\n const { valueFilterRegistry, transformValuePlugins, field } = params;\n let value = params.value;\n if (!value) {\n value = {\n entryId: null\n };\n }\n const propertyFilters = Object.keys(value);\n if (propertyFilters.length === 0) {\n return null;\n }\n const filters: CmsEntryFieldFilterPluginCreateResponse[] = [];\n\n for (const propertyFilter of propertyFilters) {\n const whereParams = extractWhereParams(propertyFilter);\n if (!whereParams) {\n continue;\n }\n const { fieldId: propertyId, operation: propertyOperation, negate } = whereParams;\n\n const fieldType = getBaseFieldType(field);\n\n const transformValuePlugin = transformValuePlugins[fieldType];\n\n const transformValueCallable = (value: any) => {\n if (!transformValuePlugin) {\n return value;\n }\n return transformValuePlugin.transform({\n field,\n value\n });\n };\n\n const filter = valueFilterRegistry.get(propertyOperation);\n if (!filter) {\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 filter,\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"],"names":["createRefFilterCreate","plugin","CmsEntryFieldFilterPlugin","params","valueFilterRegistry","transformValuePlugins","field","value","propertyFilters","Object","filters","propertyFilter","whereParams","extractWhereParams","propertyId","propertyOperation","negate","fieldType","getBaseFieldType","transformValuePlugin","transformValueCallable","filter","WebinyError","paths","f","transformValue"],"mappings":";;;;;AAQO,MAAMA,wBAAwB;IACjC,MAAMC,SAAS,IAAIC,0BAA4D;QAC3E,WAAW;QACX,QAAQC,CAAAA;YACJ,MAAM,EAAEC,mBAAmB,EAAEC,qBAAqB,EAAEC,KAAK,EAAE,GAAGH;YAC9D,IAAII,QAAQJ,OAAO,KAAK;YACxB,IAAI,CAACI,OACDA,QAAQ;gBACJ,SAAS;YACb;YAEJ,MAAMC,kBAAkBC,OAAO,IAAI,CAACF;YACpC,IAAIC,AAA2B,MAA3BA,gBAAgB,MAAM,EACtB,OAAO;YAEX,MAAME,UAAqD,EAAE;YAE7D,KAAK,MAAMC,kBAAkBH,gBAAiB;gBAC1C,MAAMI,cAAcC,mBAAmBF;gBACvC,IAAI,CAACC,aACD;gBAEJ,MAAM,EAAE,SAASE,UAAU,EAAE,WAAWC,iBAAiB,EAAEC,MAAM,EAAE,GAAGJ;gBAEtE,MAAMK,YAAYC,iBAAiBZ;gBAEnC,MAAMa,uBAAuBd,qBAAqB,CAACY,UAAU;gBAE7D,MAAMG,yBAAyB,CAACb;oBAC5B,IAAI,CAACY,sBACD,OAAOZ;oBAEX,OAAOY,qBAAqB,SAAS,CAAC;wBAClCb;wBACAC;oBACJ;gBACJ;gBAEA,MAAMc,SAASjB,oBAAoB,GAAG,CAACW;gBACvC,IAAI,CAACM,QACD,MAAM,IAAIC,MACN,CAAC,8BAA8B,EAAEP,kBAAkB,EAAE,CAAC,EACtD;gBAIR,MAAMQ,QAAQ;oBACVjB,MAAM,UAAU,CAAC;wBACbA;oBACJ;oBACAQ;iBACH;gBAEDJ,QAAQ,IAAI,CAAC;oBACTJ;oBACA,MAAMiB,MAAM,IAAI,CAAC;oBACjB,aAAa;2BAAIjB,MAAM,OAAO,CAAC,GAAG,CAACkB,CAAAA,IAAKA,EAAE,OAAO;wBAAGlB,MAAM,OAAO;qBAAC,CAAC,IAAI,CAAC;oBACxEe;oBACAL;oBACA,cAAcS,eAAe;wBACzB,OAAOlB,KAAK,CAACI,eAAe;wBAC5B,WAAWS;oBACf;oBACA,gBAAgBA;gBACpB;YACJ;YAEA,OAAOV;QACX;IACJ;IAEAT,OAAO,IAAI,GAAG;IAEd,OAAOA;AACX"}
@@ -0,0 +1,2 @@
1
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
2
+ export declare const searchableJsonFilterCreate: () => CmsEntryFieldFilterPlugin<any>;
@@ -0,0 +1,49 @@
1
+ import dot_object from "dot-object";
2
+ import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
3
+ import { extractWhereParams } from "../where.js";
4
+ const searchableJsonFilterCreate = ()=>{
5
+ const plugin = new CmsEntryFieldFilterPlugin({
6
+ fieldType: "searchable-json",
7
+ create: (params)=>{
8
+ const { value: objectValue, valueFilterRegistry, field: parentField } = params;
9
+ const filters = [];
10
+ const accessPatterns = dot_object.dot(objectValue);
11
+ for(const key in accessPatterns){
12
+ const value = accessPatterns[key];
13
+ if (void 0 === value) continue;
14
+ const whereParams = extractWhereParams(key);
15
+ if (!whereParams) continue;
16
+ const { negate, operation } = whereParams;
17
+ const transformValueCallable = (value)=>value;
18
+ const fieldId = `${parentField.fieldId}.${whereParams.fieldId ?? key}`;
19
+ const filter = valueFilterRegistry.get(operation);
20
+ if (!filter) {
21
+ console.error(`Missing operation filter for "${operation}".`);
22
+ continue;
23
+ }
24
+ const result = {
25
+ field: parentField,
26
+ path: `values.${fieldId}`,
27
+ fieldPathId: `values.${fieldId}`,
28
+ negate,
29
+ filter,
30
+ compareValue: value,
31
+ transformValue: transformValueCallable
32
+ };
33
+ if (result) {
34
+ if (Array.isArray(result)) {
35
+ filters.push(...result);
36
+ continue;
37
+ }
38
+ filters.push(result);
39
+ }
40
+ }
41
+ return filters;
42
+ }
43
+ });
44
+ plugin.name = "headless-cms.ddb.filter.searchable-json";
45
+ return plugin;
46
+ };
47
+ export { searchableJsonFilterCreate };
48
+
49
+ //# sourceMappingURL=searchableJsonFilterCreate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/filtering/plugins/searchableJsonFilterCreate.js","sources":["../../../../../src/operations/entry/filtering/plugins/searchableJsonFilterCreate.ts"],"sourcesContent":["import dot from \"dot-object\";\nimport type { CmsEntryFieldFilterPluginCreateResponse } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where.js\";\n\nexport const searchableJsonFilterCreate = () => {\n const plugin = new CmsEntryFieldFilterPlugin({\n fieldType: \"searchable-json\",\n create: params => {\n const { value: objectValue, valueFilterRegistry, 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 filter = valueFilterRegistry.get(operation);\n if (!filter) {\n console.error(`Missing operation filter for \"${operation}\".`);\n continue;\n }\n\n const result: CmsEntryFieldFilterPluginCreateResponse = {\n field: parentField,\n path: `values.${fieldId}`,\n fieldPathId: `values.${fieldId}`,\n negate,\n filter,\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"],"names":["searchableJsonFilterCreate","plugin","CmsEntryFieldFilterPlugin","params","objectValue","valueFilterRegistry","parentField","filters","accessPatterns","dot","key","value","undefined","whereParams","extractWhereParams","negate","operation","transformValueCallable","fieldId","filter","console","result","Array"],"mappings":";;;AAKO,MAAMA,6BAA6B;IACtC,MAAMC,SAAS,IAAIC,0BAA0B;QACzC,WAAW;QACX,QAAQC,CAAAA;YACJ,MAAM,EAAE,OAAOC,WAAW,EAAEC,mBAAmB,EAAE,OAAOC,WAAW,EAAE,GAAGH;YAExE,MAAMI,UAAU,EAAE;YAElB,MAAMC,iBAAiBC,WAAAA,GAAO,CAACL;YAE/B,IAAK,MAAMM,OAAOF,eAAgB;gBAC9B,MAAMG,QAAQH,cAAc,CAACE,IAAI;gBACjC,IAAIC,AAAUC,WAAVD,OACA;gBAGJ,MAAME,cAAcC,mBAAmBJ;gBACvC,IAAI,CAACG,aACD;gBAEJ,MAAM,EAAEE,MAAM,EAAEC,SAAS,EAAE,GAAGH;gBAE9B,MAAMI,yBAAyB,CAACN,QACrBA;gBAGX,MAAMO,UAAU,GAAGZ,YAAY,OAAO,CAAC,CAAC,EAAEO,YAAY,OAAO,IAAIH,KAAK;gBAEtE,MAAMS,SAASd,oBAAoB,GAAG,CAACW;gBACvC,IAAI,CAACG,QAAQ;oBACTC,QAAQ,KAAK,CAAC,CAAC,8BAA8B,EAAEJ,UAAU,EAAE,CAAC;oBAC5D;gBACJ;gBAEA,MAAMK,SAAkD;oBACpD,OAAOf;oBACP,MAAM,CAAC,OAAO,EAAEY,SAAS;oBACzB,aAAa,CAAC,OAAO,EAAEA,SAAS;oBAChCH;oBACAI;oBACA,cAAcR;oBACd,gBAAgBM;gBACpB;gBAEA,IAAKI;oBAGL,IAAIC,MAAM,OAAO,CAACD,SAAS;wBACvBd,QAAQ,IAAI,IAAIc;wBAChB;oBACJ;oBAEAd,QAAQ,IAAI,CAACc;;YACjB;YACA,OAAOd;QACX;IACJ;IAEAN,OAAO,IAAI,GAAG;IAEd,OAAOA;AACX"}
@@ -0,0 +1,12 @@
1
+ import type { CmsEntry, CmsEntryValues, CmsModel } from "@webiny/api-headless-cms/types/index.js";
2
+ import type { Field } from "./types.js";
3
+ import type { PluginsContainer } from "@webiny/plugins";
4
+ interface Params<T extends CmsEntryValues = CmsEntryValues> {
5
+ model: CmsModel;
6
+ items: CmsEntry<T>[];
7
+ sort?: string[];
8
+ fields: Record<string, Field>;
9
+ plugins: PluginsContainer;
10
+ }
11
+ export declare const sort: <T extends CmsEntryValues = CmsEntryValues>(params: Params<T>) => CmsEntry<T>[];
12
+ export {};
@@ -0,0 +1,41 @@
1
+ import error from "@webiny/error";
2
+ import sortBy from "lodash/sortBy.js";
3
+ import { extractSort } from "./extractSort.js";
4
+ import * as __rspack_external_dot_prop_de53db47 from "dot-prop";
5
+ const sort_sort = (params)=>{
6
+ const { model, items, sort = [], fields, plugins } = params;
7
+ if (items.length <= 1) return items;
8
+ if (0 === sort.length) sort.push("savedOn_DESC");
9
+ else if (sort.length > 1) throw new error("Sorting is limited to a single field on DynamoDB only system.", "SORT_MULTIPLE_FIELDS_ERROR", {
10
+ sort
11
+ });
12
+ const [firstSort] = sort;
13
+ if (!firstSort) throw new error("Empty sort array item.", "SORT_EMPTY_ERROR", {
14
+ sort
15
+ });
16
+ const { fieldId, field, valuePath, reverse } = extractSort({
17
+ model,
18
+ sortBy: firstSort,
19
+ fields,
20
+ plugins
21
+ });
22
+ const itemsToSort = items.map((item)=>({
23
+ id: item.id,
24
+ value: field.transform(__rspack_external_dot_prop_de53db47.getProperty(item, valuePath))
25
+ }));
26
+ const sortedItems = sortBy(itemsToSort, "value");
27
+ const newItems = sortedItems.map((s)=>{
28
+ const item = items.find((i)=>i.id === s.id);
29
+ if (item) return item;
30
+ throw new error("Could not find item by given id after the sorting.", "SORTING_ITEMS_ERROR", {
31
+ id: s.id,
32
+ sortingBy: fieldId,
33
+ reverse
34
+ });
35
+ });
36
+ if (!reverse) return newItems;
37
+ return newItems.reverse();
38
+ };
39
+ export { sort_sort as sort };
40
+
41
+ //# sourceMappingURL=sort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/filtering/sort.js","sources":["../../../../src/operations/entry/filtering/sort.ts"],"sourcesContent":["import type { CmsEntry, CmsEntryValues, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport * as dotProp from \"dot-prop\";\nimport lodashSortBy from \"lodash/sortBy.js\";\nimport { extractSort } from \"./extractSort.js\";\nimport type { Field } from \"./types.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\n\ninterface Params<T extends CmsEntryValues = CmsEntryValues> {\n model: CmsModel;\n items: CmsEntry<T>[];\n sort?: string[];\n fields: Record<string, Field>;\n plugins: PluginsContainer;\n}\n\ninterface SortedItem {\n id: string;\n value: any;\n}\n\nexport const sort = <T extends CmsEntryValues = CmsEntryValues>(\n params: Params<T>\n): CmsEntry<T>[] => {\n const { model, items, sort = [], fields, plugins } = params;\n if (items.length <= 1) {\n return items;\n } else if (sort.length === 0) {\n sort.push(\"savedOn_DESC\");\n } else if (sort.length > 1) {\n throw new WebinyError(\n \"Sorting is limited to a single field on DynamoDB only system.\",\n \"SORT_MULTIPLE_FIELDS_ERROR\",\n {\n sort\n }\n );\n }\n const [firstSort] = sort;\n if (!firstSort) {\n throw new WebinyError(\"Empty sort array item.\", \"SORT_EMPTY_ERROR\", {\n sort\n });\n }\n\n const { fieldId, field, valuePath, reverse } = extractSort({\n model,\n sortBy: firstSort,\n fields,\n plugins\n });\n\n const itemsToSort = items.map(item => {\n return {\n id: item.id,\n value: field.transform(dotProp.getProperty(item, valuePath))\n };\n });\n const sortedItems: SortedItem[] = lodashSortBy(itemsToSort, \"value\");\n const newItems = sortedItems.map(s => {\n const item = items.find(i => i.id === s.id);\n if (item) {\n return item;\n }\n /**\n * This is impossible to happen because sorting items does not remove the items.\n * BUT, we need to have this check just in case for development purposes.\n */\n throw new WebinyError(\n \"Could not find item by given id after the sorting.\",\n \"SORTING_ITEMS_ERROR\",\n {\n id: s.id,\n sortingBy: fieldId,\n reverse\n }\n );\n });\n if (!reverse) {\n return newItems;\n }\n return newItems.reverse();\n};\n"],"names":["sort","params","model","items","fields","plugins","WebinyError","firstSort","fieldId","field","valuePath","reverse","extractSort","itemsToSort","item","dotProp","sortedItems","lodashSortBy","newItems","s","i"],"mappings":";;;;AAqBO,MAAMA,YAAO,CAChBC;IAEA,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEH,OAAO,EAAE,EAAEI,MAAM,EAAEC,OAAO,EAAE,GAAGJ;IACrD,IAAIE,MAAM,MAAM,IAAI,GAChB,OAAOA;IACJ,IAAIH,AAAgB,MAAhBA,KAAK,MAAM,EAClBA,KAAK,IAAI,CAAC;SACP,IAAIA,KAAK,MAAM,GAAG,GACrB,MAAM,IAAIM,MACN,iEACA,8BACA;QACIN;IACJ;IAGR,MAAM,CAACO,UAAU,GAAGP;IACpB,IAAI,CAACO,WACD,MAAM,IAAID,MAAY,0BAA0B,oBAAoB;QAChEN;IACJ;IAGJ,MAAM,EAAEQ,OAAO,EAAEC,KAAK,EAAEC,SAAS,EAAEC,OAAO,EAAE,GAAGC,YAAY;QACvDV;QACA,QAAQK;QACRH;QACAC;IACJ;IAEA,MAAMQ,cAAcV,MAAM,GAAG,CAACW,CAAAA,OACnB;YACH,IAAIA,KAAK,EAAE;YACX,OAAOL,MAAM,SAAS,CAACM,oCAAAA,WAAmB,CAACD,MAAMJ;QACrD;IAEJ,MAAMM,cAA4BC,OAAaJ,aAAa;IAC5D,MAAMK,WAAWF,YAAY,GAAG,CAACG,CAAAA;QAC7B,MAAML,OAAOX,MAAM,IAAI,CAACiB,CAAAA,IAAKA,EAAE,EAAE,KAAKD,EAAE,EAAE;QAC1C,IAAIL,MACA,OAAOA;QAMX,MAAM,IAAIR,MACN,sDACA,uBACA;YACI,IAAIa,EAAE,EAAE;YACR,WAAWX;YACXG;QACJ;IAER;IACA,IAAI,CAACA,SACD,OAAOO;IAEX,OAAOA,SAAS,OAAO;AAC3B"}
@@ -0,0 +1,2 @@
1
+ import type { CmsModelField } from "@webiny/api-headless-cms/types/index.js";
2
+ export declare const createSystemFields: () => CmsModelField[];
@@ -0,0 +1,149 @@
1
+ import { ENTRY_META_FIELDS, isDateTimeEntryMetaField, isIdentityEntryMetaField } from "@webiny/api-headless-cms/constants.js";
2
+ import startCase from "lodash/startCase.js";
3
+ import { createModelField } from "@webiny/api-headless-cms";
4
+ const createSystemFields = ()=>{
5
+ const onMetaFields = ENTRY_META_FIELDS.filter(isDateTimeEntryMetaField).map((fieldName)=>createModelField({
6
+ id: fieldName,
7
+ type: "datetime",
8
+ storageId: fieldName,
9
+ fieldId: fieldName,
10
+ label: startCase(fieldName)
11
+ }));
12
+ const byMetaFields = ENTRY_META_FIELDS.filter(isIdentityEntryMetaField).map((fieldName)=>createModelField({
13
+ id: fieldName,
14
+ type: "plainObject",
15
+ storageId: fieldName,
16
+ fieldId: fieldName,
17
+ label: startCase(fieldName),
18
+ settings: {
19
+ path: `${fieldName}.id`
20
+ }
21
+ }));
22
+ return [
23
+ createModelField({
24
+ id: "id",
25
+ type: "text",
26
+ storageId: "id",
27
+ fieldId: "id",
28
+ label: "ID"
29
+ }),
30
+ createModelField({
31
+ id: "entryId",
32
+ type: "text",
33
+ storageId: "entryId",
34
+ fieldId: "entryId",
35
+ label: "Entry ID"
36
+ }),
37
+ ...onMetaFields,
38
+ ...byMetaFields,
39
+ createModelField({
40
+ id: "meta",
41
+ type: "plainObject",
42
+ storageId: "meta",
43
+ fieldId: "meta",
44
+ label: "Meta"
45
+ }),
46
+ createModelField({
47
+ id: "wbyAco_location",
48
+ type: "object",
49
+ storageId: "location",
50
+ label: "Location",
51
+ fieldId: "wbyAco_location",
52
+ settings: {
53
+ fields: [
54
+ createModelField({
55
+ id: "folderId",
56
+ type: "text",
57
+ fieldId: "folderId",
58
+ label: "Folder ID",
59
+ storageId: "folderId",
60
+ settings: {
61
+ path: "location.folderId"
62
+ }
63
+ })
64
+ ]
65
+ }
66
+ }),
67
+ createModelField({
68
+ id: "version",
69
+ type: "number",
70
+ storageId: "version",
71
+ fieldId: "version",
72
+ label: "Version"
73
+ }),
74
+ createModelField({
75
+ id: "status",
76
+ type: "text",
77
+ storageId: "status",
78
+ fieldId: "status",
79
+ label: "Status"
80
+ }),
81
+ createModelField({
82
+ id: "wbyDeleted",
83
+ type: "boolean",
84
+ storageId: "wbyDeleted",
85
+ fieldId: "wbyDeleted",
86
+ label: "Deleted"
87
+ }),
88
+ createModelField({
89
+ id: "state",
90
+ type: "object",
91
+ storageId: "object@state",
92
+ fieldId: "state",
93
+ label: "State",
94
+ settings: {
95
+ fields: [
96
+ createModelField({
97
+ id: "stepId",
98
+ type: "text",
99
+ fieldId: "stepId",
100
+ label: "Step ID",
101
+ storageId: "stepId"
102
+ }),
103
+ createModelField({
104
+ id: "stepName",
105
+ type: "text",
106
+ fieldId: "stepName",
107
+ label: "Step Name",
108
+ storageId: "stepName"
109
+ }),
110
+ createModelField({
111
+ id: "state",
112
+ type: "text",
113
+ fieldId: "state",
114
+ label: "State",
115
+ storageId: "state"
116
+ })
117
+ ]
118
+ }
119
+ }),
120
+ createModelField({
121
+ id: "values",
122
+ type: "object",
123
+ storageId: "values",
124
+ fieldId: "values",
125
+ label: "Values"
126
+ }),
127
+ createModelField({
128
+ id: "live",
129
+ type: "object",
130
+ storageId: "live",
131
+ fieldId: "live",
132
+ label: "Live",
133
+ settings: {
134
+ fields: [
135
+ createModelField({
136
+ id: "version",
137
+ type: "number",
138
+ fieldId: "version",
139
+ label: "Version",
140
+ storageId: "version"
141
+ })
142
+ ]
143
+ }
144
+ })
145
+ ];
146
+ };
147
+ export { createSystemFields };
148
+
149
+ //# sourceMappingURL=systemFields.js.map