@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
@@ -1,40 +1,16 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.createPlainObjectPathPlugin = void 0;
9
-
10
- var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
- var _CmsEntryFieldFilterPathPlugin = require("../../plugins/CmsEntryFieldFilterPathPlugin");
13
-
14
- /**
15
- * File is @internal
16
- */
17
- const createPath = ({
18
- field
19
- }) => {
20
- const {
21
- path
22
- } = field.settings || {};
23
-
24
- if (!path) {
25
- throw new _error.default("Missing path settings value.", "FIELD_SETTINGS_ERROR", {
26
- field
1
+ import error from "@webiny/error";
2
+ import { CmsEntryFieldFilterPathPlugin } from "../../plugins/CmsEntryFieldFilterPathPlugin.js";
3
+ const createPath = ({ field })=>{
4
+ const { path } = field.settings || {};
5
+ if (!path) throw new error("Missing path settings value.", "FIELD_SETTINGS_ERROR", {
6
+ field
27
7
  });
28
- }
29
-
30
- return path;
31
- };
32
-
33
- const createPlainObjectPathPlugin = () => {
34
- return new _CmsEntryFieldFilterPathPlugin.CmsEntryFieldFilterPathPlugin({
35
- fieldType: "plainObject",
36
- path: createPath
37
- });
8
+ return path;
38
9
  };
10
+ const createPlainObjectPathPlugin = ()=>new CmsEntryFieldFilterPathPlugin({
11
+ fieldType: "plainObject",
12
+ path: createPath
13
+ });
14
+ export { createPlainObjectPathPlugin };
39
15
 
40
- exports.createPlainObjectPathPlugin = createPlainObjectPathPlugin;
16
+ //# sourceMappingURL=plainObject.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createPath","field","path","settings","WebinyError","createPlainObjectPathPlugin","CmsEntryFieldFilterPathPlugin","fieldType"],"sources":["plainObject.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsEntryFieldFilterPathPlugin,\n CreatePathCallable\n} from \"~/plugins/CmsEntryFieldFilterPathPlugin\";\n\nconst createPath: CreatePathCallable = ({ field }) => {\n const { path } = field.settings || {};\n if (!path) {\n throw new WebinyError(\"Missing path settings value.\", \"FIELD_SETTINGS_ERROR\", {\n field\n });\n }\n return path;\n};\n\nexport const createPlainObjectPathPlugin = (): CmsEntryFieldFilterPathPlugin => {\n return new CmsEntryFieldFilterPathPlugin({\n fieldType: \"plainObject\",\n path: createPath\n });\n};\n"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAOA,MAAMA,UAA8B,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAe;EAClD,MAAM;IAAEC;EAAF,IAAWD,KAAK,CAACE,QAAN,IAAkB,EAAnC;;EACA,IAAI,CAACD,IAAL,EAAW;IACP,MAAM,IAAIE,cAAJ,CAAgB,8BAAhB,EAAgD,sBAAhD,EAAwE;MAC1EH;IAD0E,CAAxE,CAAN;EAGH;;EACD,OAAOC,IAAP;AACH,CARD;;AAUO,MAAMG,2BAA2B,GAAG,MAAqC;EAC5E,OAAO,IAAIC,4DAAJ,CAAkC;IACrCC,SAAS,EAAE,aAD0B;IAErCL,IAAI,EAAEF;EAF+B,CAAlC,CAAP;AAIH,CALM"}
1
+ {"version":3,"file":"dynamoDb/path/plainObject.js","sources":["../../../src/dynamoDb/path/plainObject.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport type { CreatePathCallable } from \"~/plugins/CmsEntryFieldFilterPathPlugin.js\";\nimport { CmsEntryFieldFilterPathPlugin } from \"~/plugins/CmsEntryFieldFilterPathPlugin.js\";\n\nconst createPath: CreatePathCallable = ({ field }) => {\n const { path } = field.settings || {};\n if (!path) {\n throw new WebinyError(\"Missing path settings value.\", \"FIELD_SETTINGS_ERROR\", {\n field\n });\n }\n return path;\n};\n\nexport const createPlainObjectPathPlugin = (): CmsEntryFieldFilterPathPlugin => {\n return new CmsEntryFieldFilterPathPlugin({\n fieldType: \"plainObject\",\n path: createPath\n });\n};\n"],"names":["createPath","field","path","WebinyError","createPlainObjectPathPlugin","CmsEntryFieldFilterPathPlugin"],"mappings":";;AAOA,MAAMA,aAAiC,CAAC,EAAEC,KAAK,EAAE;IAC7C,MAAM,EAAEC,IAAI,EAAE,GAAGD,MAAM,QAAQ,IAAI,CAAC;IACpC,IAAI,CAACC,MACD,MAAM,IAAIC,MAAY,gCAAgC,wBAAwB;QAC1EF;IACJ;IAEJ,OAAOC;AACX;AAEO,MAAME,8BAA8B,IAChC,IAAIC,8BAA8B;QACrC,WAAW;QACX,MAAML;IACV"}
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * File is @internal
3
3
  */
4
- import { CmsFieldFilterValueTransformPlugin } from "../../types";
4
+ import type { CmsFieldFilterValueTransformPlugin } from "../../types.js";
5
5
  export declare const createDatetimeTransformValuePlugin: () => CmsFieldFilterValueTransformPlugin;
@@ -1,52 +1,29 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createDatetimeTransformValuePlugin = void 0;
7
-
8
- var _TimeTransformPlugin = require("@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin");
9
-
10
- var _DateTimeTransformPlugin = require("@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin");
11
-
12
- /**
13
- * File is @internal
14
- */
15
- const timeTransformer = new _TimeTransformPlugin.TimeTransformPlugin({
16
- fields: ["*"]
1
+ import { TimeTransformPlugin } from "@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin.js";
2
+ import { DateTimeTransformPlugin } from "@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin.js";
3
+ const timeTransformer = new TimeTransformPlugin({
4
+ fields: [
5
+ "*"
6
+ ]
17
7
  });
18
- const dateTimeTransformer = new _DateTimeTransformPlugin.DateTimeTransformPlugin({
19
- fields: ["*"]
8
+ const dateTimeTransformer = new DateTimeTransformPlugin({
9
+ fields: [
10
+ "*"
11
+ ]
20
12
  });
21
-
22
- const createDatetimeTransformValuePlugin = () => {
23
- return {
24
- type: "cms-field-filter-value-transform",
25
- name: "cms-field-value-filter-transform-datetime",
26
- fieldType: "datetime",
27
-
28
- /**
29
- * Always transform into the milliseconds.
30
- */
31
- transform: ({
32
- field,
33
- value
34
- }) => {
35
- const {
36
- type
37
- } = field.settings || {};
38
-
39
- if (type === "time") {
40
- return timeTransformer.transform({
41
- value
42
- });
43
- }
44
-
45
- return dateTimeTransformer.transform({
46
- value
47
- });
48
- }
49
- };
50
- };
51
-
52
- exports.createDatetimeTransformValuePlugin = createDatetimeTransformValuePlugin;
13
+ const createDatetimeTransformValuePlugin = ()=>({
14
+ type: "cms-field-filter-value-transform",
15
+ name: "cms-field-value-filter-transform-datetime",
16
+ fieldType: "datetime",
17
+ transform: ({ field, value })=>{
18
+ const { type } = field.settings || {};
19
+ if ("time" === type) return timeTransformer.transform({
20
+ value
21
+ });
22
+ return dateTimeTransformer.transform({
23
+ value
24
+ });
25
+ }
26
+ });
27
+ export { createDatetimeTransformValuePlugin };
28
+
29
+ //# sourceMappingURL=datetime.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["timeTransformer","TimeTransformPlugin","fields","dateTimeTransformer","DateTimeTransformPlugin","createDatetimeTransformValuePlugin","type","name","fieldType","transform","field","value","settings"],"sources":["datetime.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport { CmsFieldFilterValueTransformPlugin } from \"~/types\";\nimport { TimeTransformPlugin } from \"@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin\";\nimport { DateTimeTransformPlugin } from \"@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin\";\n\nconst timeTransformer = new TimeTransformPlugin({\n fields: [\"*\"]\n});\nconst dateTimeTransformer = new DateTimeTransformPlugin({\n fields: [\"*\"]\n});\n\nexport const createDatetimeTransformValuePlugin = (): CmsFieldFilterValueTransformPlugin => {\n return {\n type: \"cms-field-filter-value-transform\",\n name: \"cms-field-value-filter-transform-datetime\",\n fieldType: \"datetime\",\n /**\n * Always transform into the milliseconds.\n */\n transform: ({ field, value }) => {\n const { type } = field.settings || {};\n if (type === \"time\") {\n return timeTransformer.transform({\n value\n });\n }\n return dateTimeTransformer.transform({\n value\n });\n }\n };\n};\n"],"mappings":";;;;;;;AAIA;;AACA;;AALA;AACA;AACA;AAKA,MAAMA,eAAe,GAAG,IAAIC,wCAAJ,CAAwB;EAC5CC,MAAM,EAAE,CAAC,GAAD;AADoC,CAAxB,CAAxB;AAGA,MAAMC,mBAAmB,GAAG,IAAIC,gDAAJ,CAA4B;EACpDF,MAAM,EAAE,CAAC,GAAD;AAD4C,CAA5B,CAA5B;;AAIO,MAAMG,kCAAkC,GAAG,MAA0C;EACxF,OAAO;IACHC,IAAI,EAAE,kCADH;IAEHC,IAAI,EAAE,2CAFH;IAGHC,SAAS,EAAE,UAHR;;IAIH;AACR;AACA;IACQC,SAAS,EAAE,CAAC;MAAEC,KAAF;MAASC;IAAT,CAAD,KAAsB;MAC7B,MAAM;QAAEL;MAAF,IAAWI,KAAK,CAACE,QAAN,IAAkB,EAAnC;;MACA,IAAIN,IAAI,KAAK,MAAb,EAAqB;QACjB,OAAON,eAAe,CAACS,SAAhB,CAA0B;UAC7BE;QAD6B,CAA1B,CAAP;MAGH;;MACD,OAAOR,mBAAmB,CAACM,SAApB,CAA8B;QACjCE;MADiC,CAA9B,CAAP;IAGH;EAjBE,CAAP;AAmBH,CApBM"}
1
+ {"version":3,"file":"dynamoDb/transformValue/datetime.js","sources":["../../../src/dynamoDb/transformValue/datetime.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport type { CmsFieldFilterValueTransformPlugin } from \"~/types.js\";\nimport { TimeTransformPlugin } from \"@webiny/db-dynamodb/plugins/definitions/TimeTransformPlugin.js\";\nimport { DateTimeTransformPlugin } from \"@webiny/db-dynamodb/plugins/definitions/DateTimeTransformPlugin.js\";\n\nconst timeTransformer = new TimeTransformPlugin({\n fields: [\"*\"]\n});\nconst dateTimeTransformer = new DateTimeTransformPlugin({\n fields: [\"*\"]\n});\n\nexport const createDatetimeTransformValuePlugin = (): CmsFieldFilterValueTransformPlugin => {\n return {\n type: \"cms-field-filter-value-transform\",\n name: \"cms-field-value-filter-transform-datetime\",\n fieldType: \"datetime\",\n /**\n * Always transform into the milliseconds.\n */\n transform: ({ field, value }) => {\n const { type } = field.settings || {};\n if (type === \"time\") {\n return timeTransformer.transform({\n value\n });\n }\n return dateTimeTransformer.transform({\n value\n });\n }\n };\n};\n"],"names":["timeTransformer","TimeTransformPlugin","dateTimeTransformer","DateTimeTransformPlugin","createDatetimeTransformValuePlugin","field","value","type"],"mappings":";;AAOA,MAAMA,kBAAkB,IAAIC,oBAAoB;IAC5C,QAAQ;QAAC;KAAI;AACjB;AACA,MAAMC,sBAAsB,IAAIC,wBAAwB;IACpD,QAAQ;QAAC;KAAI;AACjB;AAEO,MAAMC,qCAAqC,IACvC;QACH,MAAM;QACN,MAAM;QACN,WAAW;QAIX,WAAW,CAAC,EAAEC,KAAK,EAAEC,KAAK,EAAE;YACxB,MAAM,EAAEC,IAAI,EAAE,GAAGF,MAAM,QAAQ,IAAI,CAAC;YACpC,IAAIE,AAAS,WAATA,MACA,OAAOP,gBAAgB,SAAS,CAAC;gBAC7BM;YACJ;YAEJ,OAAOJ,oBAAoB,SAAS,CAAC;gBACjCI;YACJ;QACJ;IACJ"}
package/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- import { StorageOperationsFactory } from "./types";
2
- export * from "./plugins";
3
- export declare const createStorageOperations: StorageOperationsFactory;
1
+ export * from "./plugins/index.js";
2
+ export declare const registerDynamoDbStorageOperations: () => import("@webiny/handler").RegisterExtensionPlugin<import("@webiny/handler/types.js").Context>[];
package/index.js CHANGED
@@ -1,143 +1,87 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- var _exportNames = {
9
- createStorageOperations: true
1
+ import { registerExtension } from "@webiny/db-dynamodb";
2
+ import dynamoDb from "./dynamoDb/index.js";
3
+ import { ENTITIES } from "./types.js";
4
+ import { createGroupEntity } from "./definitions/group.js";
5
+ import { createModelEntity } from "./definitions/model.js";
6
+ import { createEntryEntity } from "./definitions/entry.js";
7
+ import { createGroupsStorageOperations } from "./operations/group/index.js";
8
+ import { createModelsStorageOperations } from "./operations/model/index.js";
9
+ import { createEntriesStorageOperations } from "./operations/entry/index.js";
10
+ import { createFilterCreatePlugins } from "./operations/entry/filtering/plugins/index.js";
11
+ import { createTable } from "./definitions/table.js";
12
+ import { createRegisterExtensionPlugin } from "@webiny/handler";
13
+ import { createFeature } from "@webiny/feature/api/index.js";
14
+ import { StorageOperationsFactory } from "@webiny/api-headless-cms/exports/api/cms/storage.js";
15
+ export * from "./plugins/index.js";
16
+ const createDynamoDbStorageOperations = (params)=>{
17
+ const { table, documentClient, plugins, container } = params;
18
+ const tableInstance = createTable({
19
+ name: table,
20
+ documentClient
21
+ });
22
+ const entities = {
23
+ groups: createGroupEntity({
24
+ entityName: ENTITIES.GROUPS,
25
+ table: tableInstance
26
+ }),
27
+ models: createModelEntity({
28
+ entityName: ENTITIES.MODELS,
29
+ table: tableInstance
30
+ }),
31
+ entries: createEntryEntity({
32
+ entityName: ENTITIES.ENTRIES,
33
+ table: tableInstance
34
+ })
35
+ };
36
+ plugins.register([
37
+ dynamoDb(),
38
+ createFilterCreatePlugins()
39
+ ]);
40
+ const entries = createEntriesStorageOperations({
41
+ entity: entities.entries,
42
+ container,
43
+ plugins
44
+ });
45
+ return {
46
+ name: "dynamodb",
47
+ beforeInit: async ()=>{
48
+ entries.dataLoaders.clearAll();
49
+ },
50
+ getEntities: ()=>entities,
51
+ getTable: ()=>tableInstance,
52
+ groups: createGroupsStorageOperations({
53
+ entity: entities.groups,
54
+ container
55
+ }),
56
+ models: createModelsStorageOperations({
57
+ entity: entities.models
58
+ }),
59
+ entries
60
+ };
10
61
  };
11
- exports.createStorageOperations = void 0;
12
-
13
- var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
14
-
15
- var _dynamoDb = _interopRequireDefault(require("./dynamoDb"));
16
-
17
- var _types = require("./types");
18
-
19
- var _table = require("./definitions/table");
20
-
21
- var _settings = require("./definitions/settings");
22
-
23
- var _system = require("./definitions/system");
24
-
25
- var _group = require("./definitions/group");
26
-
27
- var _model = require("./definitions/model");
28
-
29
- var _entry = require("./definitions/entry");
30
-
31
- var _plugins = require("@webiny/plugins");
32
-
33
- var _system2 = require("./operations/system");
34
-
35
- var _settings2 = require("./operations/settings");
36
-
37
- var _group2 = require("./operations/group");
38
-
39
- var _model2 = require("./operations/model");
40
-
41
- var _entry2 = require("./operations/entry");
42
-
43
- var _plugins2 = require("./plugins");
44
-
45
- Object.keys(_plugins2).forEach(function (key) {
46
- if (key === "default" || key === "__esModule") return;
47
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
48
- if (key in exports && exports[key] === _plugins2[key]) return;
49
- Object.defineProperty(exports, key, {
50
- enumerable: true,
51
- get: function () {
52
- return _plugins2[key];
62
+ class DynamoDbStorageOperationsFactoryImpl {
63
+ async create(context) {
64
+ return createDynamoDbStorageOperations({
65
+ documentClient: context.db.driver.getClient(),
66
+ plugins: context.plugins,
67
+ container: context.container
68
+ });
53
69
  }
54
- });
70
+ }
71
+ const DynamoDbStorageOperationsFactory = StorageOperationsFactory.createImplementation({
72
+ implementation: DynamoDbStorageOperationsFactoryImpl,
73
+ dependencies: []
55
74
  });
75
+ const storageOperationsFeature = createFeature({
76
+ name: "cms.storageOperations.openSearch",
77
+ register: (container)=>{
78
+ container.register(DynamoDbStorageOperationsFactory).inSingletonScope();
79
+ }
80
+ });
81
+ const registerDynamoDbStorageOperations = ()=>[
82
+ registerExtension(),
83
+ createRegisterExtensionPlugin((context)=>storageOperationsFeature.register(context.container))
84
+ ];
85
+ export { registerDynamoDbStorageOperations };
56
86
 
57
- const createStorageOperations = params => {
58
- const {
59
- attributes,
60
- table,
61
- documentClient,
62
- plugins: userPlugins
63
- } = params;
64
- const tableInstance = (0, _table.createTable)({
65
- table,
66
- documentClient
67
- });
68
- const entities = {
69
- settings: (0, _settings.createSettingsEntity)({
70
- entityName: _types.ENTITIES.SETTINGS,
71
- table: tableInstance,
72
- attributes: attributes ? attributes[_types.ENTITIES.SETTINGS] : {}
73
- }),
74
- system: (0, _system.createSystemEntity)({
75
- entityName: _types.ENTITIES.SYSTEM,
76
- table: tableInstance,
77
- attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
78
- }),
79
- groups: (0, _group.createGroupEntity)({
80
- entityName: _types.ENTITIES.GROUPS,
81
- table: tableInstance,
82
- attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
83
- }),
84
- models: (0, _model.createModelEntity)({
85
- entityName: _types.ENTITIES.MODELS,
86
- table: tableInstance,
87
- attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
88
- }),
89
- entries: (0, _entry.createEntryEntity)({
90
- entityName: _types.ENTITIES.ENTRIES,
91
- table: tableInstance,
92
- attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
93
- })
94
- };
95
- const plugins = new _plugins.PluginsContainer([
96
- /**
97
- * DynamoDB filter plugins for the where conditions.
98
- */
99
- (0, _filters.default)(),
100
- /**
101
- * Field plugins for DynamoDB.
102
- */
103
- (0, _dynamoDb.default)(),
104
- /**
105
- * User defined custom plugins.
106
- */
107
- ...(userPlugins || [])]);
108
- return {
109
- beforeInit: async context => {
110
- /**
111
- * Collect all required plugins from parent context.
112
- */
113
- const fieldPlugins = context.plugins.byType("cms-model-field-to-graphql");
114
- plugins.register(fieldPlugins);
115
- /**
116
- * Pass the plugins to the parent context.
117
- */
118
-
119
- context.plugins.register([(0, _dynamoDb.default)()]);
120
- },
121
- getEntities: () => entities,
122
- getTable: () => tableInstance,
123
- system: (0, _system2.createSystemStorageOperations)({
124
- entity: entities.system
125
- }),
126
- settings: (0, _settings2.createSettingsStorageOperations)({
127
- entity: entities.settings
128
- }),
129
- groups: (0, _group2.createGroupsStorageOperations)({
130
- entity: entities.groups,
131
- plugins
132
- }),
133
- models: (0, _model2.createModelsStorageOperations)({
134
- entity: entities.models
135
- }),
136
- entries: (0, _entry2.createEntriesStorageOperations)({
137
- entity: entities.entries,
138
- plugins
139
- })
140
- };
141
- };
142
-
143
- exports.createStorageOperations = createStorageOperations;
87
+ //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["createStorageOperations","params","attributes","table","documentClient","plugins","userPlugins","tableInstance","createTable","entities","settings","createSettingsEntity","entityName","ENTITIES","SETTINGS","system","createSystemEntity","SYSTEM","groups","createGroupEntity","GROUPS","models","createModelEntity","MODELS","entries","createEntryEntity","ENTRIES","PluginsContainer","dynamoDbValueFilters","dynamoDbPlugins","beforeInit","context","fieldPlugins","byType","register","getEntities","getTable","createSystemStorageOperations","entity","createSettingsStorageOperations","createGroupsStorageOperations","createModelsStorageOperations","createEntriesStorageOperations"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport dynamoDbPlugins from \"./dynamoDb\";\nimport { ENTITIES, StorageOperationsFactory } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\nimport { createSettingsEntity } from \"~/definitions/settings\";\nimport { createSystemEntity } from \"~/definitions/system\";\nimport { createGroupEntity } from \"~/definitions/group\";\nimport { createModelEntity } from \"~/definitions/model\";\nimport { createEntryEntity } from \"~/definitions/entry\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createSystemStorageOperations } from \"~/operations/system\";\nimport { createSettingsStorageOperations } from \"~/operations/settings\";\nimport { createGroupsStorageOperations } from \"~/operations/group\";\nimport { createModelsStorageOperations } from \"~/operations/model\";\nimport { createEntriesStorageOperations } from \"./operations/entry\";\nimport { CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\n\nexport * from \"./plugins\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const { attributes, table, documentClient, plugins: userPlugins } = params;\n\n const tableInstance = createTable({\n table,\n documentClient\n });\n\n const entities = {\n settings: createSettingsEntity({\n entityName: ENTITIES.SETTINGS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SETTINGS] : {}\n }),\n system: createSystemEntity({\n entityName: ENTITIES.SYSTEM,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.SYSTEM] : {}\n }),\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.GROUPS] : {}\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.MODELS] : {}\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance,\n attributes: attributes ? attributes[ENTITIES.ENTRIES] : {}\n })\n };\n\n const plugins = new PluginsContainer([\n /**\n * DynamoDB filter plugins for the where conditions.\n */\n dynamoDbValueFilters(),\n /**\n * Field plugins for DynamoDB.\n */\n dynamoDbPlugins(),\n /**\n * User defined custom plugins.\n */\n ...(userPlugins || [])\n ]);\n\n return {\n beforeInit: async context => {\n /**\n * Collect all required plugins from parent context.\n */\n const fieldPlugins = context.plugins.byType<CmsModelFieldToGraphQLPlugin>(\n \"cms-model-field-to-graphql\"\n );\n plugins.register(fieldPlugins);\n\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([dynamoDbPlugins()]);\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n system: createSystemStorageOperations({\n entity: entities.system\n }),\n settings: createSettingsStorageOperations({\n entity: entities.settings\n }),\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models\n }),\n entries: createEntriesStorageOperations({\n entity: entities.entries,\n plugins\n })\n };\n};\n"],"mappings":"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"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import { registerExtension as registerDynamoDbExtension } from \"@webiny/db-dynamodb\";\nimport dynamoDbPlugins from \"./dynamoDb/index.js\";\nimport type { CmsContext, StorageOperationsFactory } from \"~/types.js\";\nimport { ENTITIES } from \"~/types.js\";\nimport { createGroupEntity } from \"~/definitions/group.js\";\nimport { createModelEntity } from \"~/definitions/model.js\";\nimport { createEntryEntity } from \"~/definitions/entry.js\";\nimport { createGroupsStorageOperations } from \"~/operations/group/index.js\";\nimport { createModelsStorageOperations } from \"~/operations/model/index.js\";\nimport { createEntriesStorageOperations } from \"./operations/entry/index.js\";\nimport { createFilterCreatePlugins } from \"~/operations/entry/filtering/plugins/index.js\";\nimport { createTable } from \"~/definitions/table.js\";\nimport { createRegisterExtensionPlugin } from \"@webiny/handler\";\nimport { createFeature } from \"@webiny/feature/api/index.js\";\nimport { StorageOperationsFactory as StorageOperationsFactoryAbstraction } from \"@webiny/api-headless-cms/exports/api/cms/storage.js\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb/index.js\";\n\nexport * from \"./plugins/index.js\";\n\nconst createDynamoDbStorageOperations: StorageOperationsFactory = params => {\n const { table, documentClient, plugins, container } = params;\n\n const tableInstance = createTable({\n name: table,\n documentClient\n });\n\n const entities = {\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance\n })\n };\n\n plugins.register([\n /**\n * Field plugins for DynamoDB.\n */\n dynamoDbPlugins(),\n /**\n * Filter create plugins.\n */\n createFilterCreatePlugins()\n ]);\n\n const entries = createEntriesStorageOperations({\n entity: entities.entries,\n container,\n plugins\n });\n\n return {\n name: \"dynamodb\",\n beforeInit: async () => {\n entries.dataLoaders.clearAll();\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n container\n }),\n models: createModelsStorageOperations({\n entity: entities.models\n }),\n entries\n };\n};\n\nclass DynamoDbStorageOperationsFactoryImpl\n implements StorageOperationsFactoryAbstraction.Interface\n{\n public async create(context: CmsContext) {\n return createDynamoDbStorageOperations({\n documentClient: context.db.driver.getClient() as DynamoDBDocument,\n plugins: context.plugins,\n container: context.container\n });\n }\n}\n\nconst DynamoDbStorageOperationsFactory = StorageOperationsFactoryAbstraction.createImplementation({\n implementation: DynamoDbStorageOperationsFactoryImpl,\n dependencies: []\n});\n\nconst storageOperationsFeature = createFeature({\n name: \"cms.storageOperations.openSearch\",\n register: container => {\n container.register(DynamoDbStorageOperationsFactory).inSingletonScope();\n }\n});\n\nexport const registerDynamoDbStorageOperations = () => {\n return [\n registerDynamoDbExtension(),\n createRegisterExtensionPlugin(context => {\n return storageOperationsFeature.register(context.container);\n })\n ];\n};\n"],"names":["createDynamoDbStorageOperations","params","table","documentClient","plugins","container","tableInstance","createTable","entities","createGroupEntity","ENTITIES","createModelEntity","createEntryEntity","dynamoDbPlugins","createFilterCreatePlugins","entries","createEntriesStorageOperations","createGroupsStorageOperations","createModelsStorageOperations","DynamoDbStorageOperationsFactoryImpl","context","DynamoDbStorageOperationsFactory","StorageOperationsFactoryAbstraction","storageOperationsFeature","createFeature","registerDynamoDbStorageOperations","registerDynamoDbExtension","createRegisterExtensionPlugin"],"mappings":";;;;;;;;;;;;;;;AAmBA,MAAMA,kCAA4DC,CAAAA;IAC9D,MAAM,EAAEC,KAAK,EAAEC,cAAc,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGJ;IAEtD,MAAMK,gBAAgBC,YAAY;QAC9B,MAAML;QACNC;IACJ;IAEA,MAAMK,WAAW;QACb,QAAQC,kBAAkB;YACtB,YAAYC,SAAS,MAAM;YAC3B,OAAOJ;QACX;QACA,QAAQK,kBAAkB;YACtB,YAAYD,SAAS,MAAM;YAC3B,OAAOJ;QACX;QACA,SAASM,kBAAkB;YACvB,YAAYF,SAAS,OAAO;YAC5B,OAAOJ;QACX;IACJ;IAEAF,QAAQ,QAAQ,CAAC;QAIbS;QAIAC;KACH;IAED,MAAMC,UAAUC,+BAA+B;QAC3C,QAAQR,SAAS,OAAO;QACxBH;QACAD;IACJ;IAEA,OAAO;QACH,MAAM;QACN,YAAY;YACRW,QAAQ,WAAW,CAAC,QAAQ;QAChC;QACA,aAAa,IAAMP;QACnB,UAAU,IAAMF;QAChB,QAAQW,8BAA8B;YAClC,QAAQT,SAAS,MAAM;YACvBH;QACJ;QACA,QAAQa,8BAA8B;YAClC,QAAQV,SAAS,MAAM;QAC3B;QACAO;IACJ;AACJ;AAEA,MAAMI;IAGF,MAAa,OAAOC,OAAmB,EAAE;QACrC,OAAOpB,gCAAgC;YACnC,gBAAgBoB,QAAQ,EAAE,CAAC,MAAM,CAAC,SAAS;YAC3C,SAASA,QAAQ,OAAO;YACxB,WAAWA,QAAQ,SAAS;QAChC;IACJ;AACJ;AAEA,MAAMC,mCAAmCC,yBAAAA,oBAAwD,CAAC;IAC9F,gBAAgBH;IAChB,cAAc,EAAE;AACpB;AAEA,MAAMI,2BAA2BC,cAAc;IAC3C,MAAM;IACN,UAAUnB,CAAAA;QACNA,UAAU,QAAQ,CAACgB,kCAAkC,gBAAgB;IACzE;AACJ;AAEO,MAAMI,oCAAoC,IACtC;QACHC;QACAC,8BAA8BP,CAAAA,UACnBG,yBAAyB,QAAQ,CAACH,QAAQ,SAAS;KAEjE"}
@@ -0,0 +1,16 @@
1
+ import type DataLoader from "dataloader";
2
+ export interface CacheKeyParams {
3
+ name: string;
4
+ tenant: string;
5
+ modelId: string;
6
+ }
7
+ export interface ClearAllParams {
8
+ tenant: string;
9
+ }
10
+ export declare class DataLoaderCache {
11
+ private readonly cache;
12
+ getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null;
13
+ setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void;
14
+ clearAll(params?: ClearAllParams): void;
15
+ private createKey;
16
+ }
@@ -0,0 +1,27 @@
1
+ class DataLoaderCache {
2
+ getDataLoader(params) {
3
+ const key = this.createKey(params);
4
+ return this.cache[key] || null;
5
+ }
6
+ setDataLoader(params, dataLoader) {
7
+ const key = this.createKey(params);
8
+ this.cache[key] = dataLoader;
9
+ }
10
+ clearAll(params) {
11
+ if (!params) {
12
+ for(const current in this.cache)this.cache[current].clearAll();
13
+ return;
14
+ }
15
+ const key = `${params.tenant}_`;
16
+ for(const current in this.cache)if (false !== current.startsWith(key)) this.cache[current].clearAll();
17
+ }
18
+ createKey(params) {
19
+ return `${params.tenant}_${params.modelId}_${params.name}`;
20
+ }
21
+ constructor(){
22
+ this.cache = {};
23
+ }
24
+ }
25
+ export { DataLoaderCache };
26
+
27
+ //# sourceMappingURL=DataLoaderCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/dataLoader/DataLoaderCache.js","sources":["../../../../src/operations/entry/dataLoader/DataLoaderCache.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: string;\n modelId: string;\n}\n\nexport interface ClearAllParams {\n tenant: string;\n}\n\nexport class DataLoaderCache {\n private readonly cache: Record<string, DataLoader<any, any>> = {};\n\n public getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null {\n const key = this.createKey(params);\n\n return this.cache[key] || null;\n }\n\n public setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void {\n const key = this.createKey(params);\n this.cache[key] = dataLoader;\n }\n\n public clearAll(params?: ClearAllParams): void {\n if (!params) {\n for (const current in this.cache) {\n this.cache[current].clearAll();\n }\n return;\n }\n const key = `${params.tenant}_`;\n for (const current in this.cache) {\n if (current.startsWith(key) === false) {\n continue;\n }\n this.cache[current].clearAll();\n }\n }\n\n private createKey(params: CacheKeyParams): string {\n return `${params.tenant}_${params.modelId}_${params.name}`;\n }\n}\n"],"names":["DataLoaderCache","params","key","dataLoader","current"],"mappings":"AAYO,MAAMA;IAGF,cAAgCC,MAAsB,EAA2B;QACpF,MAAMC,MAAM,IAAI,CAAC,SAAS,CAACD;QAE3B,OAAO,IAAI,CAAC,KAAK,CAACC,IAAI,IAAI;IAC9B;IAEO,cAAcD,MAAsB,EAAEE,UAAgC,EAAQ;QACjF,MAAMD,MAAM,IAAI,CAAC,SAAS,CAACD;QAC3B,IAAI,CAAC,KAAK,CAACC,IAAI,GAAGC;IACtB;IAEO,SAASF,MAAuB,EAAQ;QAC3C,IAAI,CAACA,QAAQ;YACT,IAAK,MAAMG,WAAW,IAAI,CAAC,KAAK,CAC5B,IAAI,CAAC,KAAK,CAACA,QAAQ,CAAC,QAAQ;YAEhC;QACJ;QACA,MAAMF,MAAM,GAAGD,OAAO,MAAM,CAAC,CAAC,CAAC;QAC/B,IAAK,MAAMG,WAAW,IAAI,CAAC,KAAK,CAC5B,IAAIA,AAA4B,UAA5BA,QAAQ,UAAU,CAACF,MAGvB,IAAI,CAAC,KAAK,CAACE,QAAQ,CAAC,QAAQ;IAEpC;IAEQ,UAAUH,MAAsB,EAAU;QAC9C,OAAO,GAAGA,OAAO,MAAM,CAAC,CAAC,EAAEA,OAAO,OAAO,CAAC,CAAC,EAAEA,OAAO,IAAI,EAAE;IAC9D;;aA/BiB,KAAK,GAAyC,CAAC;;AAgCpE"}
@@ -0,0 +1 @@
1
+ export declare const CMS_ENTRY_BATCH_SCHEDULE_WAIT: number;
@@ -0,0 +1,5 @@
1
+ const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || "0");
2
+ const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;
3
+ export { CMS_ENTRY_BATCH_SCHEDULE_WAIT };
4
+
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/dataLoader/constants.js","sources":["../../../../src/operations/entry/dataLoader/constants.ts"],"sourcesContent":["const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || \"0\");\nexport const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;\n"],"names":["batchScheduleWaitEnv","Number","process","CMS_ENTRY_BATCH_SCHEDULE_WAIT","isNaN"],"mappings":"AAAA,MAAMA,uBAAuBC,OAAOC,QAAQ,GAAG,CAAC,wCAAwC,IAAI;AACrF,MAAMC,gCAAgCC,MAAMJ,wBAAwB,IAAIA"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This is to be used when user wants to wait for a number of milliseconds before the batch is executed.
3
+ * Intended to be used internally or for a specific user case.
4
+ * Not to be documented and exposed to publish as it can slow the data loading a lot.
5
+ *
6
+ * https://github.com/graphql/dataloader#batch-scheduling
7
+ */
8
+ export declare const createBatchScheduleFn: () => ((callback: () => void) => void) | undefined;
@@ -0,0 +1,10 @@
1
+ import { CMS_ENTRY_BATCH_SCHEDULE_WAIT } from "./constants.js";
2
+ const createBatchScheduleFn = ()=>{
3
+ if (CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) return;
4
+ return (callback)=>{
5
+ setTimeout(callback, CMS_ENTRY_BATCH_SCHEDULE_WAIT);
6
+ };
7
+ };
8
+ export { createBatchScheduleFn };
9
+
10
+ //# sourceMappingURL=createBatchScheduleFn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/dataLoader/createBatchScheduleFn.js","sources":["../../../../src/operations/entry/dataLoader/createBatchScheduleFn.ts"],"sourcesContent":["import { CMS_ENTRY_BATCH_SCHEDULE_WAIT } from \"./constants.js\";\n\n/**\n * This is to be used when user wants to wait for a number of milliseconds before the batch is executed.\n * Intended to be used internally or for a specific user case.\n * Not to be documented and exposed to publish as it can slow the data loading a lot.\n *\n * https://github.com/graphql/dataloader#batch-scheduling\n */\nexport const createBatchScheduleFn = () => {\n if (CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) {\n return undefined;\n }\n return (callback: () => void) => {\n setTimeout(callback, CMS_ENTRY_BATCH_SCHEDULE_WAIT);\n };\n};\n"],"names":["createBatchScheduleFn","CMS_ENTRY_BATCH_SCHEDULE_WAIT","callback","setTimeout"],"mappings":";AASO,MAAMA,wBAAwB;IACjC,IAAIC,iCAAiC,GACjC;IAEJ,OAAO,CAACC;QACJC,WAAWD,UAAUD;IACzB;AACJ"}
@@ -0,0 +1,4 @@
1
+ import DataLoader from "dataloader";
2
+ import type { CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
3
+ import type { IDataLoaderParams } from "./types.js";
4
+ export declare const createGetAllEntryRevisions: (params: IDataLoaderParams) => DataLoader<string, CmsStorageEntry<import("@webiny/api-headless-cms/types/types.js").CmsEntryValues>[], string>;
@@ -0,0 +1,24 @@
1
+ import dataloader from "dataloader";
2
+ import { createPartitionKey } from "../keys.js";
3
+ import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
4
+ const createGetAllEntryRevisions = (params)=>{
5
+ const { entity, tenant, modelId } = params;
6
+ return new dataloader(async (ids)=>{
7
+ const results = {};
8
+ for (const id of ids)results[id] = (await entity.queryAllClean({
9
+ partitionKey: createPartitionKey({
10
+ tenant,
11
+ id
12
+ }),
13
+ options: {
14
+ beginsWith: "REV#"
15
+ }
16
+ })).map((result)=>result.data);
17
+ return ids.map((id)=>(results[id] || []).filter((item)=>item.modelId === modelId));
18
+ }, {
19
+ batchScheduleFn: createBatchScheduleFn()
20
+ });
21
+ };
22
+ export { createGetAllEntryRevisions };
23
+
24
+ //# sourceMappingURL=getAllEntryRevisions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/dataLoader/getAllEntryRevisions.js","sources":["../../../../src/operations/entry/dataLoader/getAllEntryRevisions.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetAllEntryRevisions = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const results: Record<string, CmsStorageEntry[]> = {};\n\n for (const id of ids) {\n results[id] = (\n await entity.queryAllClean({\n partitionKey: createPartitionKey({\n tenant,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n })\n ).map(result => {\n return result.data;\n });\n }\n\n return ids.map(id => {\n return (results[id] || []).filter(item => {\n return item.modelId === modelId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"names":["createGetAllEntryRevisions","params","entity","tenant","modelId","DataLoader","ids","results","id","createPartitionKey","result","item","createBatchScheduleFn"],"mappings":";;;AAMO,MAAMA,6BAA6B,CAACC;IACvC,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGH;IACpC,OAAO,IAAII,WACP,OAAMC;QACF,MAAMC,UAA6C,CAAC;QAEpD,KAAK,MAAMC,MAAMF,IACbC,OAAO,CAACC,GAAG,GACP,OAAMN,OAAO,aAAa,CAAC;YACvB,cAAcO,mBAAmB;gBAC7BN;gBACAK;YACJ;YACA,SAAS;gBACL,YAAY;YAChB;QACJ,EAAC,EACH,GAAG,CAACE,CAAAA,SACKA,OAAO,IAAI;QAI1B,OAAOJ,IAAI,GAAG,CAACE,CAAAA,KACHD,AAAAA,CAAAA,OAAO,CAACC,GAAG,IAAI,EAAC,EAAG,MAAM,CAACG,CAAAA,OACvBA,KAAK,OAAO,KAAKP;IAGpC,GACA;QACI,iBAAiBQ;IACrB;AAER"}
@@ -0,0 +1,4 @@
1
+ import DataLoader from "dataloader";
2
+ import type { CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
3
+ import type { IDataLoaderParams } from "./types.js";
4
+ export declare const createGetLatestRevisionByEntryId: (params: IDataLoaderParams) => DataLoader<string, CmsStorageEntry<import("@webiny/api-headless-cms/types/types.js").CmsEntryValues>[], string>;
@@ -0,0 +1,40 @@
1
+ import dataloader from "dataloader";
2
+ import { cleanupItems } from "@webiny/db-dynamodb/utils/cleanup.js";
3
+ import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
4
+ import { createLatestSortKey, createPartitionKey } from "../keys.js";
5
+ import { parseIdentifier } from "@webiny/utils";
6
+ const createGetLatestRevisionByEntryId = (params)=>{
7
+ const { entity, tenant, modelId } = params;
8
+ const latestKey = createLatestSortKey();
9
+ return new dataloader(async (ids)=>{
10
+ const reader = entity.createEntityReader();
11
+ const keys = new Set();
12
+ for (const id of ids){
13
+ const partitionKey = createPartitionKey({
14
+ tenant,
15
+ id
16
+ });
17
+ if (!keys.has(partitionKey)) {
18
+ keys.add(partitionKey);
19
+ reader.get({
20
+ PK: partitionKey,
21
+ SK: latestKey
22
+ });
23
+ }
24
+ }
25
+ const records = await reader.execute();
26
+ const items = cleanupItems(entity.entity, records).map((item)=>item.data);
27
+ return ids.map((id)=>{
28
+ const { id: entryId } = parseIdentifier(id);
29
+ return items.filter((item)=>{
30
+ if (item.modelId !== modelId) return false;
31
+ return entryId === item.entryId;
32
+ });
33
+ });
34
+ }, {
35
+ batchScheduleFn: createBatchScheduleFn()
36
+ });
37
+ };
38
+ export { createGetLatestRevisionByEntryId };
39
+
40
+ //# sourceMappingURL=getLatestRevisionByEntryId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/dataLoader/getLatestRevisionByEntryId.js","sources":["../../../../src/operations/entry/dataLoader/getLatestRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup.js\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\nimport { createLatestSortKey, createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport const createGetLatestRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n if (keys.has(partitionKey)) {\n continue;\n }\n keys.add(partitionKey);\n\n reader.get({\n PK: partitionKey,\n SK: latestKey\n });\n }\n\n const records = await reader.execute();\n const items = cleanupItems(entity.entity, records).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n if (item.modelId !== modelId) {\n return false;\n }\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"names":["createGetLatestRevisionByEntryId","params","entity","tenant","modelId","latestKey","createLatestSortKey","DataLoader","ids","reader","keys","Set","id","partitionKey","createPartitionKey","records","items","cleanupItems","item","entryId","parseIdentifier","createBatchScheduleFn"],"mappings":";;;;;AAQO,MAAMA,mCAAmC,CAACC;IAC7C,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGH;IAEpC,MAAMI,YAAYC;IAElB,OAAO,IAAIC,WACP,OAAMC;QACF,MAAMC,SAASP,OAAO,kBAAkB;QAExC,MAAMQ,OAAO,IAAIC;QAEjB,KAAK,MAAMC,MAAMJ,IAAK;YAClB,MAAMK,eAAeC,mBAAmB;gBACpCX;gBACAS;YACJ;YACA,KAAIF,KAAK,GAAG,CAACG;gBAGbH,KAAK,GAAG,CAACG;gBAETJ,OAAO,GAAG,CAAC;oBACP,IAAII;oBACJ,IAAIR;gBACR;;QACJ;QAEA,MAAMU,UAAU,MAAMN,OAAO,OAAO;QACpC,MAAMO,QAAQC,aAAaf,OAAO,MAAM,EAAEa,SAAS,GAAG,CAACG,CAAAA,OAC5CA,KAAK,IAAI;QAGpB,OAAOV,IAAI,GAAG,CAACI,CAAAA;YACX,MAAM,EAAE,IAAIO,OAAO,EAAE,GAAGC,gBAAgBR;YACxC,OAAOI,MAAM,MAAM,CAACE,CAAAA;gBAChB,IAAIA,KAAK,OAAO,KAAKd,SACjB,OAAO;gBAEX,OAAOe,YAAYD,KAAK,OAAO;YACnC;QACJ;IACJ,GACA;QACI,iBAAiBG;IACrB;AAER"}