@webiny/api-headless-cms-ddb 6.3.0-beta.4 → 6.4.0-beta.0

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 (100) hide show
  1. package/definitions/entry.js +7 -9
  2. package/definitions/entry.js.map +1 -1
  3. package/definitions/group.js +7 -9
  4. package/definitions/group.js.map +1 -1
  5. package/definitions/model.js +7 -9
  6. package/definitions/model.js.map +1 -1
  7. package/definitions/table.js +6 -7
  8. package/definitions/table.js.map +1 -1
  9. package/definitions/types.d.ts +1 -0
  10. package/definitions/types.js +0 -3
  11. package/dynamoDb/index.js +6 -1
  12. package/dynamoDb/index.js.map +1 -1
  13. package/dynamoDb/path/locationFolderId.js +16 -29
  14. package/dynamoDb/path/locationFolderId.js.map +1 -1
  15. package/dynamoDb/path/plainObject.js +11 -21
  16. package/dynamoDb/path/plainObject.js.map +1 -1
  17. package/dynamoDb/transformValue/datetime.js +21 -32
  18. package/dynamoDb/transformValue/datetime.js.map +1 -1
  19. package/index.js +67 -77
  20. package/index.js.map +1 -1
  21. package/operations/entry/dataLoader/DataLoaderCache.js +22 -26
  22. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  23. package/operations/entry/dataLoader/constants.js +2 -1
  24. package/operations/entry/dataLoader/constants.js.map +1 -1
  25. package/operations/entry/dataLoader/createBatchScheduleFn.js +6 -15
  26. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
  27. package/operations/entry/dataLoader/getAllEntryRevisions.js +18 -29
  28. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  29. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +31 -41
  30. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  31. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +31 -41
  32. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  33. package/operations/entry/dataLoader/getRevisionById.js +33 -47
  34. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  35. package/operations/entry/dataLoader/index.js +8 -9
  36. package/operations/entry/dataLoader/index.js.map +1 -1
  37. package/operations/entry/dataLoader/types.js +0 -3
  38. package/operations/entry/dataLoaders.js +81 -99
  39. package/operations/entry/dataLoaders.js.map +1 -1
  40. package/operations/entry/filtering/createExpressions.js +109 -157
  41. package/operations/entry/filtering/createExpressions.js.map +1 -1
  42. package/operations/entry/filtering/createFields.js +83 -96
  43. package/operations/entry/filtering/createFields.js.map +1 -1
  44. package/operations/entry/filtering/extractSort.js +50 -74
  45. package/operations/entry/filtering/extractSort.js.map +1 -1
  46. package/operations/entry/filtering/filter.js +72 -140
  47. package/operations/entry/filtering/filter.js.map +1 -1
  48. package/operations/entry/filtering/fullTextSearch.js +21 -38
  49. package/operations/entry/filtering/fullTextSearch.js.map +1 -1
  50. package/operations/entry/filtering/getValue.js +31 -53
  51. package/operations/entry/filtering/getValue.js.map +1 -1
  52. package/operations/entry/filtering/index.js +0 -2
  53. package/operations/entry/filtering/mapPlugins.js +15 -22
  54. package/operations/entry/filtering/mapPlugins.js.map +1 -1
  55. package/operations/entry/filtering/plugins/defaultFilterCreate.js +29 -33
  56. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
  57. package/operations/entry/filtering/plugins/index.js +7 -3
  58. package/operations/entry/filtering/plugins/index.js.map +1 -1
  59. package/operations/entry/filtering/plugins/objectFilterCreate.js +60 -76
  60. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
  61. package/operations/entry/filtering/plugins/refFilterCreate.js +55 -66
  62. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
  63. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +43 -56
  64. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -1
  65. package/operations/entry/filtering/sort.js +34 -60
  66. package/operations/entry/filtering/sort.js.map +1 -1
  67. package/operations/entry/filtering/systemFields.js +144 -126
  68. package/operations/entry/filtering/systemFields.js.map +1 -1
  69. package/operations/entry/filtering/transform.js +4 -8
  70. package/operations/entry/filtering/transform.js.map +1 -1
  71. package/operations/entry/filtering/types.js +0 -3
  72. package/operations/entry/filtering/values.js +11 -12
  73. package/operations/entry/filtering/values.js.map +1 -1
  74. package/operations/entry/filtering/where.js +17 -23
  75. package/operations/entry/filtering/where.js.map +1 -1
  76. package/operations/entry/index.js +894 -1148
  77. package/operations/entry/index.js.map +1 -1
  78. package/operations/entry/keys.js +54 -77
  79. package/operations/entry/keys.js.map +1 -1
  80. package/operations/group/index.js +113 -134
  81. package/operations/group/index.js.map +1 -1
  82. package/operations/model/index.js +100 -121
  83. package/operations/model/index.js.map +1 -1
  84. package/package.json +15 -15
  85. package/plugins/CmsEntryFieldFilterPathPlugin.js +23 -33
  86. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
  87. package/plugins/CmsEntryFieldFilterPlugin.js +16 -17
  88. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
  89. package/plugins/CmsEntryFieldSortingPlugin.js +16 -15
  90. package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
  91. package/plugins/CmsFieldFilterValueTransformPlugin.js +15 -12
  92. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -1
  93. package/plugins/index.js +0 -2
  94. package/types.js +6 -5
  95. package/types.js.map +1 -1
  96. package/definitions/types.js.map +0 -1
  97. package/operations/entry/dataLoader/types.js.map +0 -1
  98. package/operations/entry/filtering/index.js.map +0 -1
  99. package/operations/entry/filtering/types.js.map +0 -1
  100. package/plugins/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"names":["CmsEntryFieldFilterPlugin","extractWhereParams","WebinyError","transformValue","getBaseFieldType","objectFilterCreate","plugin","fieldType","create","params","value","objectValue","valueFilterRegistry","transformValuePlugins","getFilterCreatePlugin","field","parentField","fields","filters","key","undefined","whereParams","negate","fieldId","operation","fieldPath","parents","map","p","concat","join","filterCreatePlugin","transformValuePlugin","transformValueCallable","transform","result","compareValue","Array","isArray","push","name"],"sources":["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"],"mappings":"AAAA,SAASA,yBAAyB;AAClC,SAASC,kBAAkB;AAC3B,OAAOC,WAAW,MAAM,eAAe;AAEvC,SAASC,cAAc;AACvB,SAASC,gBAAgB,QAAQ,oDAAoD;AAErF,OAAO,MAAMC,kBAAkB,GAAGA,CAAA,KAAM;EACpC,MAAMC,MAAM,GAAG,IAAIN,yBAAyB,CAAC;IACzCO,SAAS,EAAE,QAAQ;IACnBC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QACFC,KAAK,EAAEC,WAAW;QAClBC,mBAAmB;QACnBC,qBAAqB;QACrBC,qBAAqB;QACrBC,KAAK,EAAEC,WAAW;QAClBC;MACJ,CAAC,GAAGR,MAAM;MAEV,MAAMS,OAAO,GAAG,EAAE;MAElB,KAAK,MAAMC,GAAG,IAAIR,WAAW,EAAE;QAC3B,MAAMD,KAAK,GAAGC,WAAW,CAACQ,GAAG,CAAC;QAC9B,IAAIT,KAAK,KAAKU,SAAS,EAAE;UACrB;QACJ;QACA,MAAMC,WAAW,GAAGpB,kBAAkB,CAACkB,GAAG,CAAC;QAC3C,IAAI,CAACE,WAAW,EAAE;UACd;QACJ;QACA,MAAM;UAAEC,MAAM;UAAEC,OAAO;UAAEC;QAAU,CAAC,GAAGH,WAAW;QAElD,MAAMI,SAAS,GAAGT,WAAW,CAACU,OAAO,CAChCC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACL,OAAO,CAAC,CACnBM,MAAM,CAAC,CAACb,WAAW,CAACO,OAAO,EAAEA,OAAO,CAAC,CAAC,CACtCO,IAAI,CAAC,GAAG,CAAC;QAEd,MAAMf,KAAK,GAAGE,MAAM,CAACQ,SAAS,CAAC;QAC/B,IAAI,CAACV,KAAK,EAAE;UACR,MAAM,IAAIb,WAAW,CACjB,0CAA0CuB,SAAS,IAAI,EACvD,aAAa,EACb;YACIF;UACJ,CACJ,CAAC;QACL;QAEA,MAAMhB,SAAS,GAAGH,gBAAgB,CAACW,KAAK,CAAC;QAEzC,MAAMgB,kBAAkB,GAAGjB,qBAAqB,CAACP,SAAS,CAAC;QAE3D,MAAMyB,oBAAwD,GAC1DnB,qBAAqB,CAACN,SAAS,CAAC;QAEpC,MAAM0B,sBAAsB,GAAIvB,KAAU,IAAK;UAC3C,IAAI,CAACsB,oBAAoB,EAAE;YACvB,OAAOtB,KAAK;UAChB;UACA,OAAOsB,oBAAoB,CAACE,SAAS,CAAC;YAClCnB,KAAK;YACLL;UACJ,CAAC,CAAC;QACN,CAAC;QAED,MAAMyB,MAAM,GAAGJ,kBAAkB,CAACvB,MAAM,CAAC;UACrCW,GAAG;UACHT,KAAK;UACLE,mBAAmB;UACnBC,qBAAqB;UACrBC,qBAAqB;UACrBU,SAAS;UACTF,MAAM;UACNP,KAAK;UACLE,MAAM;UACNmB,YAAY,EAAEjC,cAAc,CAAC;YACzBO,KAAK;YACLwB,SAAS,EAAED;UACf,CAAC,CAAC;UACF9B,cAAc,EAAE8B;QACpB,CAAC,CAAC;QACF,IAAI,CAACE,MAAM,EAAE;UACT;QACJ;QACA,IAAIE,KAAK,CAACC,OAAO,CAACH,MAAM,CAAC,EAAE;UACvBjB,OAAO,CAACqB,IAAI,CAAC,GAAGJ,MAAM,CAAC;UACvB;QACJ;QAEAjB,OAAO,CAACqB,IAAI,CAACJ,MAAM,CAAC;MACxB;MACA,OAAOjB,OAAO;IAClB;EACJ,CAAC,CAAC;EAEFZ,MAAM,CAACkC,IAAI,GAAG,gCAAgC;EAE9C,OAAOlC,MAAM;AACjB,CAAC","ignoreList":[]}
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"}
@@ -1,74 +1,63 @@
1
- import WebinyError from "@webiny/error";
1
+ import error from "@webiny/error";
2
2
  import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
3
3
  import { extractWhereParams } from "../where.js";
4
4
  import { transformValue } from "../transform.js";
5
5
  import { getBaseFieldType } from "@webiny/api-headless-cms/utils/getBaseFieldType.js";
6
- export const createRefFilterCreate = () => {
7
- const plugin = new CmsEntryFieldFilterPlugin({
8
- fieldType: "ref",
9
- create: params => {
10
- const {
11
- valueFilterRegistry,
12
- transformValuePlugins,
13
- field
14
- } = params;
15
- let value = params.value;
16
- if (!value) {
17
- value = {
18
- entryId: null
19
- };
20
- }
21
- const propertyFilters = Object.keys(value);
22
- if (propertyFilters.length === 0) {
23
- return null;
24
- }
25
- const filters = [];
26
- for (const propertyFilter of propertyFilters) {
27
- const whereParams = extractWhereParams(propertyFilter);
28
- if (!whereParams) {
29
- continue;
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;
30
56
  }
31
- const {
32
- fieldId: propertyId,
33
- operation: propertyOperation,
34
- negate
35
- } = whereParams;
36
- const fieldType = getBaseFieldType(field);
37
- const transformValuePlugin = transformValuePlugins[fieldType];
38
- const transformValueCallable = value => {
39
- if (!transformValuePlugin) {
40
- return value;
41
- }
42
- return transformValuePlugin.transform({
43
- field,
44
- value
45
- });
46
- };
47
- const filter = valueFilterRegistry.get(propertyOperation);
48
- if (!filter) {
49
- throw new WebinyError(`Missing operation filter for "${propertyOperation}".`, "MISSING_OPERATION_FILTER");
50
- }
51
- const paths = [field.createPath({
52
- field
53
- }), propertyId];
54
- filters.push({
55
- field,
56
- path: paths.join("."),
57
- fieldPathId: [...field.parents.map(f => f.fieldId), field.fieldId].join("."),
58
- filter,
59
- negate,
60
- compareValue: transformValue({
61
- value: value[propertyFilter],
62
- transform: transformValueCallable
63
- }),
64
- transformValue: transformValueCallable
65
- });
66
- }
67
- return filters;
68
- }
69
- });
70
- plugin.name = `headless-cms.ddb.filter.ref`;
71
- return plugin;
57
+ });
58
+ plugin.name = "headless-cms.ddb.filter.ref";
59
+ return plugin;
72
60
  };
61
+ export { createRefFilterCreate };
73
62
 
74
63
  //# sourceMappingURL=refFilterCreate.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","CmsEntryFieldFilterPlugin","extractWhereParams","transformValue","getBaseFieldType","createRefFilterCreate","plugin","fieldType","create","params","valueFilterRegistry","transformValuePlugins","field","value","entryId","propertyFilters","Object","keys","length","filters","propertyFilter","whereParams","fieldId","propertyId","operation","propertyOperation","negate","transformValuePlugin","transformValueCallable","transform","filter","get","paths","createPath","push","path","join","fieldPathId","parents","map","f","compareValue","name"],"sources":["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"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AAEvC,SAASC,yBAAyB;AAClC,SAASC,kBAAkB;AAC3B,SAASC,cAAc;AAEvB,SAASC,gBAAgB,QAAQ,oDAAoD;AAErF,OAAO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,MAAMC,MAAM,GAAG,IAAIL,yBAAyB,CAAmC;IAC3EM,SAAS,EAAE,KAAK;IAChBC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,mBAAmB;QAAEC,qBAAqB;QAAEC;MAAM,CAAC,GAAGH,MAAM;MACpE,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,KAAK,MAAMC,cAAc,IAAIL,eAAe,EAAE;QAC1C,MAAMM,WAAW,GAAGnB,kBAAkB,CAACkB,cAAc,CAAC;QACtD,IAAI,CAACC,WAAW,EAAE;UACd;QACJ;QACA,MAAM;UAAEC,OAAO,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CAAC","ignoreList":[]}
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"}
@@ -1,62 +1,49 @@
1
- import dot from "dot-object";
1
+ import dot_object from "dot-object";
2
2
  import { CmsEntryFieldFilterPlugin } from "../../../../plugins/CmsEntryFieldFilterPlugin.js";
3
3
  import { extractWhereParams } from "../where.js";
4
- export const searchableJsonFilterCreate = () => {
5
- const plugin = new CmsEntryFieldFilterPlugin({
6
- fieldType: "searchable-json",
7
- create: params => {
8
- const {
9
- value: objectValue,
10
- valueFilterRegistry,
11
- field: parentField
12
- } = params;
13
- const filters = [];
14
- const accessPatterns = dot.dot(objectValue);
15
- for (const key in accessPatterns) {
16
- const value = accessPatterns[key];
17
- if (value === undefined) {
18
- continue;
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;
19
42
  }
20
- const whereParams = extractWhereParams(key);
21
- if (!whereParams) {
22
- continue;
23
- }
24
- const {
25
- negate,
26
- operation
27
- } = whereParams;
28
- const transformValueCallable = value => {
29
- return value;
30
- };
31
- const fieldId = `${parentField.fieldId}.${whereParams.fieldId ?? key}`;
32
- const filter = valueFilterRegistry.get(operation);
33
- if (!filter) {
34
- console.error(`Missing operation filter for "${operation}".`);
35
- continue;
36
- }
37
- const result = {
38
- field: parentField,
39
- path: `values.${fieldId}`,
40
- fieldPathId: `values.${fieldId}`,
41
- negate,
42
- filter,
43
- compareValue: value,
44
- transformValue: transformValueCallable
45
- };
46
- if (!result) {
47
- continue;
48
- }
49
- if (Array.isArray(result)) {
50
- filters.push(...result);
51
- continue;
52
- }
53
- filters.push(result);
54
- }
55
- return filters;
56
- }
57
- });
58
- plugin.name = `headless-cms.ddb.filter.searchable-json`;
59
- return plugin;
43
+ });
44
+ plugin.name = "headless-cms.ddb.filter.searchable-json";
45
+ return plugin;
60
46
  };
47
+ export { searchableJsonFilterCreate };
61
48
 
62
49
  //# sourceMappingURL=searchableJsonFilterCreate.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["dot","CmsEntryFieldFilterPlugin","extractWhereParams","searchableJsonFilterCreate","plugin","fieldType","create","params","value","objectValue","valueFilterRegistry","field","parentField","filters","accessPatterns","key","undefined","whereParams","negate","operation","transformValueCallable","fieldId","filter","get","console","error","result","path","fieldPathId","compareValue","transformValue","Array","isArray","push","name"],"sources":["searchableJsonFilterCreate.ts"],"sourcesContent":["import dot from \"dot-object\";\nimport type { CmsEntryFieldFilterPluginCreateResponse } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { CmsEntryFieldFilterPlugin } from \"~/plugins/CmsEntryFieldFilterPlugin.js\";\nimport { extractWhereParams } from \"~/operations/entry/filtering/where.js\";\n\nexport const searchableJsonFilterCreate = () => {\n const plugin = new CmsEntryFieldFilterPlugin({\n fieldType: \"searchable-json\",\n create: params => {\n const { value: objectValue, 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"],"mappings":"AAAA,OAAOA,GAAG,MAAM,YAAY;AAE5B,SAASC,yBAAyB;AAClC,SAASC,kBAAkB;AAE3B,OAAO,MAAMC,0BAA0B,GAAGA,CAAA,KAAM;EAC5C,MAAMC,MAAM,GAAG,IAAIH,yBAAyB,CAAC;IACzCI,SAAS,EAAE,iBAAiB;IAC5BC,MAAM,EAAEC,MAAM,IAAI;MACd,MAAM;QAAEC,KAAK,EAAEC,WAAW;QAAE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IAClB;EACJ,CAAC,CAAC;EAEFT,MAAM,CAAC8B,IAAI,GAAG,yCAAyC;EAEvD,OAAO9B,MAAM;AACjB,CAAC","ignoreList":[]}
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"}
@@ -1,67 +1,41 @@
1
- import WebinyError from "@webiny/error";
2
- import * as dotProp from "dot-prop";
3
- import lodashSortBy from "lodash/sortBy.js";
1
+ import error from "@webiny/error";
2
+ import sortBy from "lodash/sortBy.js";
4
3
  import { extractSort } from "./extractSort.js";
5
- export const sort = params => {
6
- const {
7
- model,
8
- items,
9
- sort = [],
10
- fields,
11
- plugins
12
- } = params;
13
- if (items.length <= 1) {
14
- return items;
15
- } else if (sort.length === 0) {
16
- sort.push("savedOn_DESC");
17
- } else if (sort.length > 1) {
18
- throw new WebinyError("Sorting is limited to a single field on DynamoDB only system.", "SORT_MULTIPLE_FIELDS_ERROR", {
19
- sort
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
20
11
  });
21
- }
22
- const [firstSort] = sort;
23
- if (!firstSort) {
24
- throw new WebinyError("Empty sort array item.", "SORT_EMPTY_ERROR", {
25
- sort
12
+ const [firstSort] = sort;
13
+ if (!firstSort) throw new error("Empty sort array item.", "SORT_EMPTY_ERROR", {
14
+ sort
26
15
  });
27
- }
28
- const {
29
- fieldId,
30
- field,
31
- valuePath,
32
- reverse
33
- } = extractSort({
34
- model,
35
- sortBy: firstSort,
36
- fields,
37
- plugins
38
- });
39
- const itemsToSort = items.map(item => {
40
- return {
41
- id: item.id,
42
- value: field.transform(dotProp.getProperty(item, valuePath))
43
- };
44
- });
45
- const sortedItems = lodashSortBy(itemsToSort, "value");
46
- const newItems = sortedItems.map(s => {
47
- const item = items.find(i => i.id === s.id);
48
- if (item) {
49
- return item;
50
- }
51
- /**
52
- * This is impossible to happen because sorting items does not remove the items.
53
- * BUT, we need to have this check just in case for development purposes.
54
- */
55
- throw new WebinyError("Could not find item by given id after the sorting.", "SORTING_ITEMS_ERROR", {
56
- id: s.id,
57
- sortingBy: fieldId,
58
- reverse
16
+ const { fieldId, field, valuePath, reverse } = extractSort({
17
+ model,
18
+ sortBy: firstSort,
19
+ fields,
20
+ plugins
59
21
  });
60
- });
61
- if (!reverse) {
62
- return newItems;
63
- }
64
- return newItems.reverse();
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();
65
38
  };
39
+ export { sort_sort as sort };
66
40
 
67
41
  //# sourceMappingURL=sort.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","dotProp","lodashSortBy","extractSort","sort","params","model","items","fields","plugins","length","push","firstSort","fieldId","field","valuePath","reverse","sortBy","itemsToSort","map","item","id","value","transform","getProperty","sortedItems","newItems","s","find","i","sortingBy"],"sources":["sort.ts"],"sourcesContent":["import type { CmsEntry, CmsEntryValues, CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport * 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"],"mappings":"AACA,OAAOA,WAAW,MAAM,eAAe;AACvC,OAAO,KAAKC,OAAO,MAAM,UAAU;AACnC,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,SAASC,WAAW;AAiBpB,OAAO,MAAMC,IAAI,GACbC,MAAiB,IACD;EAChB,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEH,IAAI,GAAG,EAAE;IAAEI,MAAM;IAAEC;EAAQ,CAAC,GAAGJ,MAAM;EAC3D,IAAIE,KAAK,CAACG,MAAM,IAAI,CAAC,EAAE;IACnB,OAAOH,KAAK;EAChB,CAAC,MAAM,IAAIH,IAAI,CAACM,MAAM,KAAK,CAAC,EAAE;IAC1BN,IAAI,CAACO,IAAI,CAAC,cAAc,CAAC;EAC7B,CAAC,MAAM,IAAIP,IAAI,CAACM,MAAM,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CAACV,OAAO,CAAC,CAAC;AAC7B,CAAC","ignoreList":[]}
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"}