@webiny/api-headless-cms-ddb 0.0.0-unstable.a4637c5ce6 → 0.0.0-unstable.a4f3e4ea8b

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 (158) hide show
  1. package/README.md +6 -20
  2. package/definitions/entry.d.ts +4 -6
  3. package/definitions/entry.js +8 -185
  4. package/definitions/entry.js.map +1 -1
  5. package/definitions/group.d.ts +4 -6
  6. package/definitions/group.js +8 -63
  7. package/definitions/group.js.map +1 -1
  8. package/definitions/model.d.ts +4 -6
  9. package/definitions/model.js +8 -107
  10. package/definitions/model.js.map +1 -1
  11. package/definitions/table.d.ts +3 -5
  12. package/definitions/table.js +6 -29
  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 +7 -13
  18. package/dynamoDb/index.js.map +1 -1
  19. package/index.d.ts +2 -3
  20. package/index.js +85 -121
  21. package/index.js.map +1 -1
  22. package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -2
  23. package/operations/entry/dataLoader/DataLoaderCache.js +21 -35
  24. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  25. package/operations/entry/dataLoader/constants.js +2 -7
  26. package/operations/entry/dataLoader/constants.js.map +1 -1
  27. package/operations/entry/dataLoader/createBatchScheduleFn.js +7 -22
  28. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
  29. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
  30. package/operations/entry/dataLoader/getAllEntryRevisions.js +20 -41
  31. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  32. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
  33. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +36 -52
  34. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  35. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
  36. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +36 -52
  37. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  38. package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
  39. package/operations/entry/dataLoader/getRevisionById.js +38 -58
  40. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  41. package/operations/entry/dataLoader/index.d.ts +3 -3
  42. package/operations/entry/dataLoader/index.js +13 -35
  43. package/operations/entry/dataLoader/index.js.map +1 -1
  44. package/operations/entry/dataLoader/types.d.ts +4 -4
  45. package/operations/entry/dataLoader/types.js +0 -7
  46. package/operations/entry/dataLoaders.d.ts +11 -12
  47. package/operations/entry/dataLoaders.js +83 -109
  48. package/operations/entry/dataLoaders.js.map +1 -1
  49. package/operations/entry/index.d.ts +4 -3
  50. package/operations/entry/index.js +908 -1277
  51. package/operations/entry/index.js.map +1 -1
  52. package/operations/entry/keys.d.ts +46 -2
  53. package/operations/entry/keys.js +52 -49
  54. package/operations/entry/keys.js.map +1 -1
  55. package/operations/group/index.d.ts +4 -5
  56. package/operations/group/index.js +113 -166
  57. package/operations/group/index.js.map +1 -1
  58. package/operations/model/index.d.ts +3 -3
  59. package/operations/model/index.js +99 -143
  60. package/operations/model/index.js.map +1 -1
  61. package/package.json +29 -25
  62. package/plugins/index.d.ts +2 -4
  63. package/plugins/index.js +1 -51
  64. package/types.d.ts +19 -42
  65. package/types.js +6 -12
  66. package/types.js.map +1 -1
  67. package/definitions/system.d.ts +0 -10
  68. package/definitions/system.js +0 -42
  69. package/definitions/system.js.map +0 -1
  70. package/dynamoDb/path/locationFolderId.d.ts +0 -2
  71. package/dynamoDb/path/locationFolderId.js +0 -43
  72. package/dynamoDb/path/locationFolderId.js.map +0 -1
  73. package/dynamoDb/path/plainObject.d.ts +0 -2
  74. package/dynamoDb/path/plainObject.js +0 -35
  75. package/dynamoDb/path/plainObject.js.map +0 -1
  76. package/dynamoDb/storage/longText.d.ts +0 -10
  77. package/dynamoDb/storage/longText.js +0 -94
  78. package/dynamoDb/storage/longText.js.map +0 -1
  79. package/dynamoDb/storage/richText.d.ts +0 -2
  80. package/dynamoDb/storage/richText.js +0 -61
  81. package/dynamoDb/storage/richText.js.map +0 -1
  82. package/dynamoDb/transformValue/datetime.d.ts +0 -5
  83. package/dynamoDb/transformValue/datetime.js +0 -47
  84. package/dynamoDb/transformValue/datetime.js.map +0 -1
  85. package/operations/entry/dataLoader/types.js.map +0 -1
  86. package/operations/entry/filtering/createExpressions.d.ts +0 -26
  87. package/operations/entry/filtering/createExpressions.js +0 -178
  88. package/operations/entry/filtering/createExpressions.js.map +0 -1
  89. package/operations/entry/filtering/createFields.d.ts +0 -16
  90. package/operations/entry/filtering/createFields.js +0 -108
  91. package/operations/entry/filtering/createFields.js.map +0 -1
  92. package/operations/entry/filtering/extractSort.d.ts +0 -17
  93. package/operations/entry/filtering/extractSort.js +0 -69
  94. package/operations/entry/filtering/extractSort.js.map +0 -1
  95. package/operations/entry/filtering/filter.d.ts +0 -15
  96. package/operations/entry/filtering/filter.js +0 -158
  97. package/operations/entry/filtering/filter.js.map +0 -1
  98. package/operations/entry/filtering/fullTextSearch.d.ts +0 -14
  99. package/operations/entry/filtering/fullTextSearch.js +0 -50
  100. package/operations/entry/filtering/fullTextSearch.js.map +0 -1
  101. package/operations/entry/filtering/getValue.d.ts +0 -5
  102. package/operations/entry/filtering/getValue.js +0 -66
  103. package/operations/entry/filtering/getValue.js.map +0 -1
  104. package/operations/entry/filtering/index.d.ts +0 -2
  105. package/operations/entry/filtering/index.js +0 -21
  106. package/operations/entry/filtering/index.js.map +0 -1
  107. package/operations/entry/filtering/mapPlugins.d.ts +0 -8
  108. package/operations/entry/filtering/mapPlugins.js +0 -33
  109. package/operations/entry/filtering/mapPlugins.js.map +0 -1
  110. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +0 -2
  111. package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -45
  112. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +0 -1
  113. package/operations/entry/filtering/plugins/index.d.ts +0 -1
  114. package/operations/entry/filtering/plugins/index.js +0 -16
  115. package/operations/entry/filtering/plugins/index.js.map +0 -1
  116. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +0 -2
  117. package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -90
  118. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +0 -1
  119. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +0 -3
  120. package/operations/entry/filtering/plugins/refFilterCreate.js +0 -80
  121. package/operations/entry/filtering/plugins/refFilterCreate.js.map +0 -1
  122. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +0 -2
  123. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +0 -65
  124. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +0 -1
  125. package/operations/entry/filtering/sort.d.ts +0 -12
  126. package/operations/entry/filtering/sort.js +0 -71
  127. package/operations/entry/filtering/sort.js.map +0 -1
  128. package/operations/entry/filtering/systemFields.d.ts +0 -4
  129. package/operations/entry/filtering/systemFields.js +0 -90
  130. package/operations/entry/filtering/systemFields.js.map +0 -1
  131. package/operations/entry/filtering/transform.d.ts +0 -6
  132. package/operations/entry/filtering/transform.js +0 -18
  133. package/operations/entry/filtering/transform.js.map +0 -1
  134. package/operations/entry/filtering/types.d.ts +0 -40
  135. package/operations/entry/filtering/types.js +0 -7
  136. package/operations/entry/filtering/types.js.map +0 -1
  137. package/operations/entry/filtering/values.d.ts +0 -2
  138. package/operations/entry/filtering/values.js +0 -24
  139. package/operations/entry/filtering/values.js.map +0 -1
  140. package/operations/entry/filtering/where.d.ts +0 -5
  141. package/operations/entry/filtering/where.js +0 -35
  142. package/operations/entry/filtering/where.js.map +0 -1
  143. package/operations/system/index.d.ts +0 -7
  144. package/operations/system/index.js +0 -94
  145. package/operations/system/index.js.map +0 -1
  146. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +0 -23
  147. package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -48
  148. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +0 -1
  149. package/plugins/CmsEntryFieldFilterPlugin.d.ts +0 -43
  150. package/plugins/CmsEntryFieldFilterPlugin.js +0 -27
  151. package/plugins/CmsEntryFieldFilterPlugin.js.map +0 -1
  152. package/plugins/CmsEntryFieldSortingPlugin.d.ts +0 -42
  153. package/plugins/CmsEntryFieldSortingPlugin.js +0 -27
  154. package/plugins/CmsEntryFieldSortingPlugin.js.map +0 -1
  155. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +0 -11
  156. package/plugins/CmsFieldFilterValueTransformPlugin.js +0 -23
  157. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +0 -1
  158. package/plugins/index.js.map +0 -1
package/dynamoDb/index.js CHANGED
@@ -1,15 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _richText = require("./storage/richText");
8
- var _longText = require("./storage/longText");
9
- var _plainObject = require("./path/plainObject");
10
- var _datetime = require("./transformValue/datetime");
11
- var _locationFolderId = require("./path/locationFolderId");
12
- var _default = () => [(0, _richText.createRichTextStorageTransformPlugin)(), (0, _longText.createLongTextStorageTransformPlugin)(), (0, _plainObject.createPlainObjectPathPlugin)(), (0, _locationFolderId.createLocationFolderIdPathPlugin)(), (0, _datetime.createDatetimeTransformValuePlugin)()];
13
- exports.default = _default;
1
+ import { createDatetimeTransformValuePlugin, createLocationFolderIdPathPlugin, createPlainObjectPathPlugin } from "@webiny/api-headless-cms-storage";
2
+ const dynamoDb = ()=>[
3
+ createPlainObjectPathPlugin(),
4
+ createLocationFolderIdPathPlugin(),
5
+ createDatetimeTransformValuePlugin()
6
+ ];
7
+ export default dynamoDb;
14
8
 
15
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_richText","require","_longText","_plainObject","_datetime","_locationFolderId","_default","createRichTextStorageTransformPlugin","createLongTextStorageTransformPlugin","createPlainObjectPathPlugin","createLocationFolderIdPathPlugin","createDatetimeTransformValuePlugin","exports","default"],"sources":["index.ts"],"sourcesContent":["import { createRichTextStorageTransformPlugin } from \"./storage/richText\";\nimport { createLongTextStorageTransformPlugin } from \"./storage/longText\";\nimport { createPlainObjectPathPlugin } from \"./path/plainObject\";\nimport { createDatetimeTransformValuePlugin } from \"./transformValue/datetime\";\nimport { createLocationFolderIdPathPlugin } from \"~/dynamoDb/path/locationFolderId\";\n\nexport default () => [\n createRichTextStorageTransformPlugin(),\n createLongTextStorageTransformPlugin(),\n createPlainObjectPathPlugin(),\n createLocationFolderIdPathPlugin(),\n createDatetimeTransformValuePlugin()\n];\n"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAAoF,IAAAK,QAAA,GAErEA,CAAA,KAAM,CACjB,IAAAC,8CAAoC,EAAC,CAAC,EACtC,IAAAC,8CAAoC,EAAC,CAAC,EACtC,IAAAC,wCAA2B,EAAC,CAAC,EAC7B,IAAAC,kDAAgC,EAAC,CAAC,EAClC,IAAAC,4CAAkC,EAAC,CAAC,CACvC;AAAAC,OAAA,CAAAC,OAAA,GAAAP,QAAA","ignoreList":[]}
1
+ {"version":3,"file":"dynamoDb/index.js","sources":["../../src/dynamoDb/index.ts"],"sourcesContent":["import { createPlainObjectPathPlugin } from \"@webiny/api-headless-cms-storage\";\nimport { createLocationFolderIdPathPlugin } from \"@webiny/api-headless-cms-storage\";\nimport { createDatetimeTransformValuePlugin } from \"@webiny/api-headless-cms-storage\";\n\nexport default () => [\n createPlainObjectPathPlugin(),\n createLocationFolderIdPathPlugin(),\n createDatetimeTransformValuePlugin()\n];\n"],"names":["createPlainObjectPathPlugin","createLocationFolderIdPathPlugin","createDatetimeTransformValuePlugin"],"mappings":";AAIA,iBAAgB,IAAK;QACjBA;QACAC;QACAC;KACJ"}
package/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- import type { 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,127 +1,91 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- var _exportNames = {
8
- createStorageOperations: true
1
+ import dynamoDb from "./dynamoDb/index.js";
2
+ import { ENTITIES } from "./types.js";
3
+ import { createGroupEntity } from "./definitions/group.js";
4
+ import { createModelEntity } from "./definitions/model.js";
5
+ import { createEntryEntity } from "./definitions/entry.js";
6
+ import { createGroupsStorageOperations } from "./operations/group/index.js";
7
+ import { createModelsStorageOperations } from "./operations/model/index.js";
8
+ import { createEntriesStorageOperations } from "./operations/entry/index.js";
9
+ import { createFilterCreatePlugins } from "@webiny/api-headless-cms-storage";
10
+ import { createTable } from "./definitions/table.js";
11
+ import { createRegisterExtensionPlugin } from "@webiny/handler";
12
+ import { createFeature } from "@webiny/feature/api/index.js";
13
+ import { StorageOperationsFactory } from "@webiny/api-headless-cms/exports/api/cms/storage.js";
14
+ import { DynamoDBClient } from "@webiny/db-dynamodb";
15
+ export * from "./plugins/index.js";
16
+ const createDynamoDbStorageOperations = (params)=>{
17
+ const { table, plugins, container } = params;
18
+ const db = container.resolve(DynamoDBClient);
19
+ const documentClient = db.client;
20
+ const tableInstance = createTable({
21
+ name: table,
22
+ documentClient
23
+ });
24
+ const entities = {
25
+ groups: createGroupEntity({
26
+ entityName: ENTITIES.GROUPS,
27
+ table: tableInstance
28
+ }),
29
+ models: createModelEntity({
30
+ entityName: ENTITIES.MODELS,
31
+ table: tableInstance
32
+ }),
33
+ entries: createEntryEntity({
34
+ entityName: ENTITIES.ENTRIES,
35
+ table: tableInstance
36
+ })
37
+ };
38
+ plugins.register([
39
+ dynamoDb(),
40
+ createFilterCreatePlugins()
41
+ ]);
42
+ const entries = createEntriesStorageOperations({
43
+ entity: entities.entries,
44
+ container,
45
+ plugins
46
+ });
47
+ return {
48
+ name: "dynamodb",
49
+ beforeInit: async ()=>{
50
+ entries.dataLoaders.clearAll();
51
+ },
52
+ getEntities: ()=>entities,
53
+ getTable: ()=>tableInstance,
54
+ groups: createGroupsStorageOperations({
55
+ entity: entities.groups,
56
+ container
57
+ }),
58
+ models: createModelsStorageOperations({
59
+ entity: entities.models
60
+ }),
61
+ entries
62
+ };
9
63
  };
10
- exports.createStorageOperations = void 0;
11
- var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
12
- var _dynamoDb = _interopRequireDefault(require("./dynamoDb"));
13
- var _types = require("./types");
14
- var _table = require("./definitions/table");
15
- var _system = require("./definitions/system");
16
- var _group = require("./definitions/group");
17
- var _model = require("./definitions/model");
18
- var _entry = require("./definitions/entry");
19
- var _plugins = require("@webiny/plugins");
20
- var _system2 = require("./operations/system");
21
- var _group2 = require("./operations/group");
22
- var _model2 = require("./operations/model");
23
- var _entry2 = require("./operations/entry");
24
- var _plugins2 = require("./operations/entry/filtering/plugins");
25
- var _plugins3 = require("./plugins");
26
- Object.keys(_plugins3).forEach(function (key) {
27
- if (key === "default" || key === "__esModule") return;
28
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
29
- if (key in exports && exports[key] === _plugins3[key]) return;
30
- Object.defineProperty(exports, key, {
31
- enumerable: true,
32
- get: function () {
33
- return _plugins3[key];
64
+ class DynamoDbStorageOperationsFactoryImpl {
65
+ async create(context) {
66
+ return createDynamoDbStorageOperations({
67
+ plugins: context.plugins,
68
+ container: context.container
69
+ });
70
+ }
71
+ }
72
+ const DynamoDbStorageOperationsFactory = StorageOperationsFactory.createImplementation({
73
+ implementation: DynamoDbStorageOperationsFactoryImpl,
74
+ dependencies: []
75
+ });
76
+ const storageOperationsFeature = createFeature({
77
+ name: "cms.storageOperations.openSearch",
78
+ register: (container)=>{
79
+ container.register(DynamoDbStorageOperationsFactory).inSingletonScope();
34
80
  }
35
- });
36
81
  });
37
- var _ValueFilterPlugin = require("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin");
38
- var _apiHeadlessCms = require("@webiny/api-headless-cms");
39
- var _api = require("@webiny/api");
40
- const createStorageOperations = params => {
41
- const {
42
- attributes,
43
- table,
44
- documentClient,
45
- plugins: userPlugins
46
- } = params;
47
- const tableInstance = (0, _table.createTable)({
48
- table,
49
- documentClient
50
- });
51
- const entities = {
52
- system: (0, _system.createSystemEntity)({
53
- entityName: _types.ENTITIES.SYSTEM,
54
- table: tableInstance,
55
- attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
56
- }),
57
- groups: (0, _group.createGroupEntity)({
58
- entityName: _types.ENTITIES.GROUPS,
59
- table: tableInstance,
60
- attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
61
- }),
62
- models: (0, _model.createModelEntity)({
63
- entityName: _types.ENTITIES.MODELS,
64
- table: tableInstance,
65
- attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
66
- }),
67
- entries: (0, _entry.createEntryEntity)({
68
- entityName: _types.ENTITIES.ENTRIES,
69
- table: tableInstance,
70
- attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
71
- })
72
- };
73
- const plugins = new _plugins.PluginsContainer([
74
- /**
75
- * DynamoDB filter plugins for the where conditions.
76
- */
77
- (0, _filters.default)(),
78
- /**
79
- * Field plugins for DynamoDB.
80
- */
81
- (0, _dynamoDb.default)(),
82
- /**
83
- * Filter create plugins.
84
- */
85
- (0, _plugins2.createFilterCreatePlugins)(),
86
- /**
87
- * User defined custom plugins.
88
- */
89
- ...(userPlugins || [])]);
90
- const entries = (0, _entry2.createEntriesStorageOperations)({
91
- entity: entities.entries,
92
- plugins
93
- });
94
- return {
95
- name: "dynamodb",
96
- beforeInit: async context => {
97
- const types = ["cms-model-field-to-graphql", _plugins3.CmsEntryFieldFilterPathPlugin.type, _plugins3.CmsFieldFilterValueTransformPlugin.type, _plugins3.CmsEntryFieldFilterPlugin.type, _plugins3.CmsEntryFieldSortingPlugin.type, _ValueFilterPlugin.ValueFilterPlugin.type, _apiHeadlessCms.StorageOperationsCmsModelPlugin.type, _apiHeadlessCms.StorageTransformPlugin.type, _api.CompressorPlugin.type];
98
- /**
99
- * Collect all required plugins from parent context.
100
- */
101
- for (const type of types) {
102
- plugins.mergeByType(context.plugins, type);
103
- }
104
- /**
105
- * Pass the plugins to the parent context.
106
- */
107
- context.plugins.register([(0, _dynamoDb.default)()]);
108
- entries.dataLoaders.clearAll();
109
- },
110
- getEntities: () => entities,
111
- getTable: () => tableInstance,
112
- system: (0, _system2.createSystemStorageOperations)({
113
- entity: entities.system
114
- }),
115
- groups: (0, _group2.createGroupsStorageOperations)({
116
- entity: entities.groups,
117
- plugins
118
- }),
119
- models: (0, _model2.createModelsStorageOperations)({
120
- entity: entities.models
121
- }),
122
- entries
123
- };
82
+ const registerDynamoDbStorageOperations = ()=>{
83
+ const plugin = createRegisterExtensionPlugin((context)=>storageOperationsFeature.register(context.container));
84
+ plugin.name = "cms.registerDynamoDbStorageOperations";
85
+ return [
86
+ plugin
87
+ ];
124
88
  };
125
- exports.createStorageOperations = createStorageOperations;
89
+ export { registerDynamoDbStorageOperations };
126
90
 
127
91
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_filters","_interopRequireDefault","require","_dynamoDb","_types","_table","_system","_group","_model","_entry","_plugins","_system2","_group2","_model2","_entry2","_plugins2","_plugins3","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_ValueFilterPlugin","_apiHeadlessCms","_api","createStorageOperations","params","attributes","table","documentClient","plugins","userPlugins","tableInstance","createTable","entities","system","createSystemEntity","entityName","ENTITIES","SYSTEM","groups","createGroupEntity","GROUPS","models","createModelEntity","MODELS","entries","createEntryEntity","ENTRIES","PluginsContainer","dynamoDbValueFilters","dynamoDbPlugins","createFilterCreatePlugins","createEntriesStorageOperations","entity","name","beforeInit","context","types","CmsEntryFieldFilterPathPlugin","type","CmsFieldFilterValueTransformPlugin","CmsEntryFieldFilterPlugin","CmsEntryFieldSortingPlugin","ValueFilterPlugin","StorageOperationsCmsModelPlugin","StorageTransformPlugin","CompressorPlugin","mergeByType","register","dataLoaders","clearAll","getEntities","getTable","createSystemStorageOperations","createGroupsStorageOperations","createModelsStorageOperations"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters\";\nimport dynamoDbPlugins from \"./dynamoDb\";\nimport type { StorageOperationsFactory } from \"~/types\";\nimport { ENTITIES } from \"~/types\";\nimport { createTable } from \"~/definitions/table\";\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 { createGroupsStorageOperations } from \"~/operations/group\";\nimport { createModelsStorageOperations } from \"~/operations/model\";\nimport { createEntriesStorageOperations } from \"./operations/entry\";\n\nimport { createFilterCreatePlugins } from \"~/operations/entry/filtering/plugins\";\nimport {\n CmsEntryFieldFilterPathPlugin,\n CmsEntryFieldFilterPlugin,\n CmsEntryFieldSortingPlugin,\n CmsFieldFilterValueTransformPlugin\n} from \"~/plugins\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin\";\nimport { StorageOperationsCmsModelPlugin, StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CompressorPlugin } from \"@webiny/api\";\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 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 * Filter create plugins.\n */\n createFilterCreatePlugins(),\n /**\n * User defined custom plugins.\n */\n ...(userPlugins || [])\n ]);\n\n const entries = createEntriesStorageOperations({\n entity: entities.entries,\n plugins\n });\n\n return {\n name: \"dynamodb\",\n beforeInit: async context => {\n const types: string[] = [\n \"cms-model-field-to-graphql\",\n CmsEntryFieldFilterPathPlugin.type,\n CmsFieldFilterValueTransformPlugin.type,\n CmsEntryFieldFilterPlugin.type,\n CmsEntryFieldSortingPlugin.type,\n ValueFilterPlugin.type,\n StorageOperationsCmsModelPlugin.type,\n StorageTransformPlugin.type,\n CompressorPlugin.type\n ];\n /**\n * Collect all required plugins from parent context.\n */\n for (const type of types) {\n plugins.mergeByType(context.plugins, type);\n }\n /**\n * Pass the plugins to the parent context.\n */\n context.plugins.register([dynamoDbPlugins()]);\n\n entries.dataLoaders.clearAll();\n },\n getEntities: () => entities,\n getTable: () => tableInstance,\n system: createSystemStorageOperations({\n entity: entities.system\n }),\n groups: createGroupsStorageOperations({\n entity: entities.groups,\n plugins\n }),\n models: createModelsStorageOperations({\n entity: entities.models\n }),\n entries\n };\n};\n"],"mappings":"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","ignoreList":[]}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import 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 \"@webiny/api-headless-cms-storage\";\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 { DynamoDBClient } from \"@webiny/db-dynamodb\";\n\nexport * from \"./plugins/index.js\";\n\nconst createDynamoDbStorageOperations: StorageOperationsFactory = params => {\n const { table, plugins, container } = params;\n\n const db = container.resolve(DynamoDBClient);\n const documentClient = db.client;\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 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 const plugin = createRegisterExtensionPlugin(context => {\n return storageOperationsFeature.register(context.container);\n });\n plugin.name = \"cms.registerDynamoDbStorageOperations\";\n\n return [plugin];\n};\n"],"names":["createDynamoDbStorageOperations","params","table","plugins","container","db","DynamoDBClient","documentClient","tableInstance","createTable","entities","createGroupEntity","ENTITIES","createModelEntity","createEntryEntity","dynamoDbPlugins","createFilterCreatePlugins","entries","createEntriesStorageOperations","createGroupsStorageOperations","createModelsStorageOperations","DynamoDbStorageOperationsFactoryImpl","context","DynamoDbStorageOperationsFactory","StorageOperationsFactoryAbstraction","storageOperationsFeature","createFeature","registerDynamoDbStorageOperations","plugin","createRegisterExtensionPlugin"],"mappings":";;;;;;;;;;;;;;;AAkBA,MAAMA,kCAA4DC,CAAAA;IAC9D,MAAM,EAAEC,KAAK,EAAEC,OAAO,EAAEC,SAAS,EAAE,GAAGH;IAEtC,MAAMI,KAAKD,UAAU,OAAO,CAACE;IAC7B,MAAMC,iBAAiBF,GAAG,MAAM;IAEhC,MAAMG,gBAAgBC,YAAY;QAC9B,MAAMP;QACNK;IACJ;IAEA,MAAMG,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;IAEAL,QAAQ,QAAQ,CAAC;QAIbY;QAIAC;KACH;IAED,MAAMC,UAAUC,+BAA+B;QAC3C,QAAQR,SAAS,OAAO;QACxBN;QACAD;IACJ;IAEA,OAAO;QACH,MAAM;QACN,YAAY;YACRc,QAAQ,WAAW,CAAC,QAAQ;QAChC;QACA,aAAa,IAAMP;QACnB,UAAU,IAAMF;QAChB,QAAQW,8BAA8B;YAClC,QAAQT,SAAS,MAAM;YACvBN;QACJ;QACA,QAAQgB,8BAA8B;YAClC,QAAQV,SAAS,MAAM;QAC3B;QACAO;IACJ;AACJ;AAEA,MAAMI;IAGF,MAAa,OAAOC,OAAmB,EAAE;QACrC,OAAOtB,gCAAgC;YACnC,SAASsB,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,UAAUtB,CAAAA;QACNA,UAAU,QAAQ,CAACmB,kCAAkC,gBAAgB;IACzE;AACJ;AAEO,MAAMI,oCAAoC;IAC7C,MAAMC,SAASC,8BAA8BP,CAAAA,UAClCG,yBAAyB,QAAQ,CAACH,QAAQ,SAAS;IAE9DM,OAAO,IAAI,GAAG;IAEd,OAAO;QAACA;KAAO;AACnB"}
@@ -2,11 +2,10 @@ import type DataLoader from "dataloader";
2
2
  export interface CacheKeyParams {
3
3
  name: string;
4
4
  tenant: string;
5
- locale: string;
5
+ modelId: string;
6
6
  }
7
7
  export interface ClearAllParams {
8
8
  tenant: string;
9
- locale: string;
10
9
  }
11
10
  export declare class DataLoaderCache {
12
11
  private readonly cache;
@@ -1,41 +1,27 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DataLoaderCache = void 0;
7
1
  class DataLoaderCache {
8
- cache = {};
9
- getDataLoader(params) {
10
- const key = this.createKey(params);
11
- return this.cache[key] || null;
12
- }
13
- setDataLoader(params, dataLoader) {
14
- const key = this.createKey(params);
15
- this.cache[key] = dataLoader;
16
- }
17
- clearAll(params) {
18
- if (!params) {
19
- for (const current in this.cache) {
20
- this.cache[current].clearAll();
21
- }
22
- return;
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}`;
23
20
  }
24
- const key = this.createKey({
25
- ...params,
26
- name: ""
27
- });
28
- for (const current in this.cache) {
29
- if (current.startsWith(key) === false) {
30
- continue;
31
- }
32
- this.cache[current].clearAll();
21
+ constructor(){
22
+ this.cache = {};
33
23
  }
34
- }
35
- createKey(params) {
36
- return `${params.tenant}_${params.locale}_${params.name}`;
37
- }
38
24
  }
39
- exports.DataLoaderCache = DataLoaderCache;
25
+ export { DataLoaderCache };
40
26
 
41
27
  //# sourceMappingURL=DataLoaderCache.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["DataLoaderCache","cache","getDataLoader","params","key","createKey","setDataLoader","dataLoader","clearAll","current","name","startsWith","tenant","locale","exports"],"sources":["DataLoaderCache.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: string;\n locale: string;\n}\n\nexport interface ClearAllParams {\n tenant: string;\n locale: 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 = this.createKey({\n ...params,\n name: \"\"\n });\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.locale}_${params.name}`;\n }\n}\n"],"mappings":";;;;;;AAaO,MAAMA,eAAe,CAAC;EACRC,KAAK,GAAyC,CAAC,CAAC;EAE1DC,aAAaA,CAAmBC,MAAsB,EAA2B;IACpF,MAAMC,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAElC,OAAO,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,IAAI,IAAI;EAClC;EAEOE,aAAaA,CAACH,MAAsB,EAAEI,UAAgC,EAAQ;IACjF,MAAMH,GAAG,GAAG,IAAI,CAACC,SAAS,CAACF,MAAM,CAAC;IAClC,IAAI,CAACF,KAAK,CAACG,GAAG,CAAC,GAAGG,UAAU;EAChC;EAEOC,QAAQA,CAACL,MAAuB,EAAQ;IAC3C,IAAI,CAACA,MAAM,EAAE;MACT,KAAK,MAAMM,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;QAC9B,IAAI,CAACA,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;MAClC;MACA;IACJ;IACA,MAAMJ,GAAG,GAAG,IAAI,CAACC,SAAS,CAAC;MACvB,GAAGF,MAAM;MACTO,IAAI,EAAE;IACV,CAAC,CAAC;IACF,KAAK,MAAMD,OAAO,IAAI,IAAI,CAACR,KAAK,EAAE;MAC9B,IAAIQ,OAAO,CAACE,UAAU,CAACP,GAAG,CAAC,KAAK,KAAK,EAAE;QACnC;MACJ;MACA,IAAI,CAACH,KAAK,CAACQ,OAAO,CAAC,CAACD,QAAQ,CAAC,CAAC;IAClC;EACJ;EAEQH,SAASA,CAACF,MAAsB,EAAU;IAC9C,OAAO,GAAGA,MAAM,CAACS,MAAM,IAAIT,MAAM,CAACU,MAAM,IAAIV,MAAM,CAACO,IAAI,EAAE;EAC7D;AACJ;AAACI,OAAA,CAAAd,eAAA,GAAAA,eAAA","ignoreList":[]}
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"}
@@ -1,10 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CMS_ENTRY_BATCH_SCHEDULE_WAIT = void 0;
7
1
  const batchScheduleWaitEnv = Number(process.env.WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT || "0");
8
- const CMS_ENTRY_BATCH_SCHEDULE_WAIT = exports.CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;
2
+ const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;
3
+ export { CMS_ENTRY_BATCH_SCHEDULE_WAIT };
9
4
 
10
5
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["batchScheduleWaitEnv","Number","process","env","WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT","CMS_ENTRY_BATCH_SCHEDULE_WAIT","exports","isNaN"],"sources":["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"],"mappings":";;;;;;AAAA,MAAMA,oBAAoB,GAAGC,MAAM,CAACC,OAAO,CAACC,GAAG,CAACC,wCAAwC,IAAI,GAAG,CAAC;AACzF,MAAMC,6BAA6B,GAAAC,OAAA,CAAAD,6BAAA,GAAGE,KAAK,CAACP,oBAAoB,CAAC,GAAG,CAAC,GAAGA,oBAAoB","ignoreList":[]}
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"}
@@ -1,25 +1,10 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createBatchScheduleFn = void 0;
7
- var _constants = require("./constants");
8
- /**
9
- * This is to be used when user wants to wait for a number of milliseconds before the batch is executed.
10
- * Intended to be used internally or for a specific user case.
11
- * Not to be documented and exposed to publish as it can slow the data loading a lot.
12
- *
13
- * https://github.com/graphql/dataloader#batch-scheduling
14
- */
15
- const createBatchScheduleFn = () => {
16
- if (_constants.CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) {
17
- return undefined;
18
- }
19
- return callback => {
20
- setTimeout(callback, _constants.CMS_ENTRY_BATCH_SCHEDULE_WAIT);
21
- };
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
+ };
22
7
  };
23
- exports.createBatchScheduleFn = createBatchScheduleFn;
8
+ export { createBatchScheduleFn };
24
9
 
25
10
  //# sourceMappingURL=createBatchScheduleFn.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_constants","require","createBatchScheduleFn","CMS_ENTRY_BATCH_SCHEDULE_WAIT","undefined","callback","setTimeout","exports"],"sources":["createBatchScheduleFn.ts"],"sourcesContent":["import { CMS_ENTRY_BATCH_SCHEDULE_WAIT } from \"./constants\";\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"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,IAAIC,wCAA6B,IAAI,CAAC,EAAE;IACpC,OAAOC,SAAS;EACpB;EACA,OAAQC,QAAoB,IAAK;IAC7BC,UAAU,CAACD,QAAQ,EAAEF,wCAA6B,CAAC;EACvD,CAAC;AACL,CAAC;AAACI,OAAA,CAAAL,qBAAA,GAAAA,qBAAA","ignoreList":[]}
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"}
@@ -1,4 +1,4 @@
1
1
  import DataLoader from "dataloader";
2
- import type { CmsStorageEntry } from "@webiny/api-headless-cms/types";
3
- import type { DataLoaderParams } from "./types";
4
- export declare const createGetAllEntryRevisions: (params: DataLoaderParams) => DataLoader<string, CmsStorageEntry[], string>;
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>;
@@ -1,45 +1,24 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createGetAllEntryRevisions = void 0;
8
- var _dataloader = _interopRequireDefault(require("dataloader"));
9
- var _query = require("@webiny/db-dynamodb/utils/query");
10
- var _keys = require("../keys");
11
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
12
- var _createBatchScheduleFn = require("./createBatchScheduleFn");
13
- const createGetAllEntryRevisions = params => {
14
- const {
15
- entity,
16
- locale,
17
- tenant
18
- } = params;
19
- return new _dataloader.default(async ids => {
20
- const results = {};
21
- for (const id of ids) {
22
- const queryAllParams = {
23
- entity,
24
- partitionKey: (0, _keys.createPartitionKey)({
25
- tenant,
26
- locale,
27
- id
28
- }),
29
- options: {
30
- beginsWith: "REV#"
31
- }
32
- };
33
- const items = await (0, _query.queryAll)(queryAllParams);
34
- results[id] = (0, _cleanup.cleanupItems)(entity, items);
35
- }
36
- return ids.map(id => {
37
- return results[id] || [];
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()
38
20
  });
39
- }, {
40
- batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
41
- });
42
21
  };
43
- exports.createGetAllEntryRevisions = createGetAllEntryRevisions;
22
+ export { createGetAllEntryRevisions };
44
23
 
45
24
  //# sourceMappingURL=getAllEntryRevisions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_dataloader","_interopRequireDefault","require","_query","_keys","_cleanup","_createBatchScheduleFn","createGetAllEntryRevisions","params","entity","locale","tenant","DataLoader","ids","results","id","queryAllParams","partitionKey","createPartitionKey","options","beginsWith","items","queryAll","cleanupItems","map","batchScheduleFn","createBatchScheduleFn","exports"],"sources":["getAllEntryRevisions.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport type { QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { queryAll } from \"@webiny/db-dynamodb/utils/query\";\nimport { createPartitionKey } from \"~/operations/entry/keys\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport type { DataLoaderParams } from \"./types\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\n\nexport const createGetAllEntryRevisions = (params: DataLoaderParams) => {\n const { entity, locale, tenant } = params;\n return new DataLoader<string, CmsStorageEntry[]>(\n async (ids: readonly string[]) => {\n const results: Record<string, CmsStorageEntry[]> = {};\n for (const id of ids) {\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createPartitionKey({\n tenant,\n locale,\n id\n }),\n options: {\n beginsWith: \"REV#\"\n }\n };\n const items = await queryAll<CmsStorageEntry>(queryAllParams);\n results[id] = cleanupItems(entity, items);\n }\n\n return ids.map(id => {\n return results[id] || [];\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEA,IAAAI,sBAAA,GAAAJ,OAAA;AAEO,MAAMK,0BAA0B,GAAIC,MAAwB,IAAK;EACpE,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EACzC,OAAO,IAAII,mBAAU,CACjB,MAAOC,GAAsB,IAAK;IAC9B,MAAMC,OAA0C,GAAG,CAAC,CAAC;IACrD,KAAK,MAAMC,EAAE,IAAIF,GAAG,EAAE;MAClB,MAAMG,cAA8B,GAAG;QACnCP,MAAM;QACNQ,YAAY,EAAE,IAAAC,wBAAkB,EAAC;UAC7BP,MAAM;UACND,MAAM;UACNK;QACJ,CAAC,CAAC;QACFI,OAAO,EAAE;UACLC,UAAU,EAAE;QAChB;MACJ,CAAC;MACD,MAAMC,KAAK,GAAG,MAAM,IAAAC,eAAQ,EAAkBN,cAAc,CAAC;MAC7DF,OAAO,CAACC,EAAE,CAAC,GAAG,IAAAQ,qBAAY,EAACd,MAAM,EAAEY,KAAK,CAAC;IAC7C;IAEA,OAAOR,GAAG,CAACW,GAAG,CAACT,EAAE,IAAI;MACjB,OAAOD,OAAO,CAACC,EAAE,CAAC,IAAI,EAAE;IAC5B,CAAC,CAAC;EACN,CAAC,EACD;IACIU,eAAe,EAAE,IAAAC,4CAAqB,EAAC;EAC3C,CACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAApB,0BAAA,GAAAA,0BAAA","ignoreList":[]}
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"}
@@ -1,4 +1,4 @@
1
1
  import DataLoader from "dataloader";
2
- import type { CmsStorageEntry } from "@webiny/api-headless-cms/types";
3
- import type { DataLoaderParams } from "./types";
4
- export declare const createGetLatestRevisionByEntryId: (params: DataLoaderParams) => DataLoader<string, CmsStorageEntry[], string>;
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>;