@webiny/api-headless-cms-ddb 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f

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 (168) hide show
  1. package/definitions/entry.d.ts +6 -4
  2. package/definitions/entry.js +111 -20
  3. package/definitions/entry.js.map +1 -0
  4. package/definitions/group.d.ts +6 -4
  5. package/definitions/group.js +8 -16
  6. package/definitions/group.js.map +1 -0
  7. package/definitions/model.d.ts +6 -4
  8. package/definitions/model.js +30 -16
  9. package/definitions/model.js.map +1 -0
  10. package/definitions/system.d.ts +6 -4
  11. package/definitions/system.js +8 -16
  12. package/definitions/system.js.map +1 -0
  13. package/definitions/table.d.ts +7 -6
  14. package/definitions/table.js +7 -6
  15. package/definitions/table.js.map +1 -0
  16. package/dynamoDb/index.d.ts +1 -1
  17. package/dynamoDb/index.js +9 -18
  18. package/dynamoDb/index.js.map +1 -0
  19. package/dynamoDb/path/locationFolderId.d.ts +2 -0
  20. package/dynamoDb/path/locationFolderId.js +43 -0
  21. package/dynamoDb/path/locationFolderId.js.map +1 -0
  22. package/dynamoDb/path/plainObject.d.ts +2 -3
  23. package/dynamoDb/path/plainObject.js +26 -24
  24. package/dynamoDb/path/plainObject.js.map +1 -0
  25. package/dynamoDb/storage/longText.d.ts +7 -4
  26. package/dynamoDb/storage/longText.js +74 -63
  27. package/dynamoDb/storage/longText.js.map +1 -0
  28. package/dynamoDb/storage/richText.d.ts +2 -8
  29. package/dynamoDb/storage/richText.js +49 -98
  30. package/dynamoDb/storage/richText.js.map +1 -0
  31. package/dynamoDb/transformValue/datetime.d.ts +5 -3
  32. package/dynamoDb/transformValue/datetime.js +29 -29
  33. package/dynamoDb/transformValue/datetime.js.map +1 -0
  34. package/index.d.ts +2 -1
  35. package/index.js +56 -54
  36. package/index.js.map +1 -0
  37. package/operations/entry/dataLoader/DataLoaderCache.d.ts +17 -0
  38. package/operations/entry/dataLoader/DataLoaderCache.js +41 -0
  39. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  40. package/operations/entry/dataLoader/constants.d.ts +1 -0
  41. package/operations/entry/dataLoader/constants.js +10 -0
  42. package/operations/entry/dataLoader/constants.js.map +1 -0
  43. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  44. package/operations/entry/dataLoader/createBatchScheduleFn.js +25 -0
  45. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  46. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  47. package/operations/entry/dataLoader/getAllEntryRevisions.js +45 -0
  48. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  49. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  50. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +56 -0
  51. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  52. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  53. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +56 -0
  54. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  55. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  56. package/operations/entry/dataLoader/getRevisionById.js +62 -0
  57. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  58. package/operations/entry/dataLoader/index.d.ts +8 -0
  59. package/operations/entry/dataLoader/index.js +40 -0
  60. package/operations/entry/dataLoader/index.js.map +1 -0
  61. package/operations/entry/dataLoader/types.d.ts +6 -0
  62. package/operations/entry/dataLoader/types.js +7 -0
  63. package/operations/entry/dataLoader/types.js.map +1 -0
  64. package/operations/entry/dataLoaders.d.ts +18 -29
  65. package/operations/entry/dataLoaders.js +59 -246
  66. package/operations/entry/dataLoaders.js.map +1 -0
  67. package/operations/entry/filtering/createExpressions.d.ts +26 -0
  68. package/operations/entry/filtering/createExpressions.js +178 -0
  69. package/operations/entry/filtering/createExpressions.js.map +1 -0
  70. package/operations/entry/filtering/createFields.d.ts +16 -0
  71. package/operations/entry/filtering/createFields.js +108 -0
  72. package/operations/entry/filtering/createFields.js.map +1 -0
  73. package/operations/entry/filtering/extractSort.d.ts +17 -0
  74. package/operations/entry/filtering/extractSort.js +69 -0
  75. package/operations/entry/filtering/extractSort.js.map +1 -0
  76. package/operations/entry/filtering/filter.d.ts +15 -0
  77. package/operations/entry/filtering/filter.js +158 -0
  78. package/operations/entry/filtering/filter.js.map +1 -0
  79. package/operations/entry/filtering/fullTextSearch.d.ts +14 -0
  80. package/operations/entry/filtering/fullTextSearch.js +50 -0
  81. package/operations/entry/filtering/fullTextSearch.js.map +1 -0
  82. package/operations/entry/filtering/getValue.d.ts +5 -0
  83. package/operations/entry/filtering/getValue.js +66 -0
  84. package/operations/entry/filtering/getValue.js.map +1 -0
  85. package/operations/entry/filtering/index.d.ts +2 -0
  86. package/operations/entry/filtering/index.js +21 -0
  87. package/operations/entry/filtering/index.js.map +1 -0
  88. package/operations/entry/filtering/mapPlugins.d.ts +8 -0
  89. package/operations/entry/filtering/mapPlugins.js +33 -0
  90. package/operations/entry/filtering/mapPlugins.js.map +1 -0
  91. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +2 -0
  92. package/operations/entry/filtering/plugins/defaultFilterCreate.js +45 -0
  93. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -0
  94. package/operations/entry/filtering/plugins/index.d.ts +1 -0
  95. package/operations/entry/filtering/plugins/index.js +16 -0
  96. package/operations/entry/filtering/plugins/index.js.map +1 -0
  97. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +2 -0
  98. package/operations/entry/filtering/plugins/objectFilterCreate.js +90 -0
  99. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -0
  100. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +3 -0
  101. package/operations/entry/filtering/plugins/refFilterCreate.js +80 -0
  102. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -0
  103. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +2 -0
  104. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +65 -0
  105. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -0
  106. package/operations/entry/filtering/sort.d.ts +12 -0
  107. package/operations/entry/filtering/sort.js +71 -0
  108. package/operations/entry/filtering/sort.js.map +1 -0
  109. package/operations/entry/filtering/systemFields.d.ts +4 -0
  110. package/operations/entry/filtering/systemFields.js +90 -0
  111. package/operations/entry/filtering/systemFields.js.map +1 -0
  112. package/operations/entry/filtering/transform.d.ts +6 -0
  113. package/operations/entry/filtering/transform.js +18 -0
  114. package/operations/entry/filtering/transform.js.map +1 -0
  115. package/operations/entry/filtering/types.d.ts +40 -0
  116. package/operations/entry/filtering/types.js +7 -0
  117. package/operations/entry/filtering/types.js.map +1 -0
  118. package/operations/entry/filtering/values.d.ts +2 -0
  119. package/operations/entry/filtering/values.js +24 -0
  120. package/operations/entry/filtering/values.js.map +1 -0
  121. package/operations/entry/filtering/where.d.ts +5 -0
  122. package/operations/entry/filtering/where.js +35 -0
  123. package/operations/entry/filtering/where.js.map +1 -0
  124. package/operations/entry/index.d.ts +5 -5
  125. package/operations/entry/index.js +920 -437
  126. package/operations/entry/index.js.map +1 -0
  127. package/operations/entry/keys.js +9 -14
  128. package/operations/entry/keys.js.map +1 -0
  129. package/operations/group/index.d.ts +6 -5
  130. package/operations/group/index.js +35 -59
  131. package/operations/group/index.js.map +1 -0
  132. package/operations/model/index.d.ts +5 -4
  133. package/operations/model/index.js +35 -46
  134. package/operations/model/index.js.map +1 -0
  135. package/operations/system/index.d.ts +5 -4
  136. package/operations/system/index.js +20 -31
  137. package/operations/system/index.js.map +1 -0
  138. package/package.json +23 -29
  139. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +23 -0
  140. package/plugins/CmsEntryFieldFilterPathPlugin.js +48 -0
  141. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -0
  142. package/plugins/CmsEntryFieldFilterPlugin.d.ts +43 -0
  143. package/plugins/CmsEntryFieldFilterPlugin.js +27 -0
  144. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -0
  145. package/plugins/CmsEntryFieldSortingPlugin.d.ts +42 -0
  146. package/plugins/CmsEntryFieldSortingPlugin.js +27 -0
  147. package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -0
  148. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +11 -0
  149. package/plugins/CmsFieldFilterValueTransformPlugin.js +23 -0
  150. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -0
  151. package/plugins/index.d.ts +4 -0
  152. package/plugins/index.js +51 -0
  153. package/plugins/index.js.map +1 -0
  154. package/types.d.ts +21 -45
  155. package/types.js +5 -6
  156. package/types.js.map +1 -0
  157. package/definitions/settings.d.ts +0 -8
  158. package/definitions/settings.js +0 -62
  159. package/dynamoDb/path/ref.d.ts +0 -3
  160. package/dynamoDb/path/ref.js +0 -27
  161. package/dynamoDb/storage/date.d.ts +0 -3
  162. package/dynamoDb/storage/date.js +0 -65
  163. package/operations/entry/systemFields.d.ts +0 -2
  164. package/operations/entry/systemFields.js +0 -50
  165. package/operations/entry/utils.d.ts +0 -31
  166. package/operations/entry/utils.js +0 -406
  167. package/operations/settings/index.d.ts +0 -6
  168. package/operations/settings/index.js +0 -141
package/index.js CHANGED
@@ -1,113 +1,117 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
7
+ var _exportNames = {
8
+ createStorageOperations: true
9
+ };
8
10
  exports.createStorageOperations = void 0;
9
-
10
11
  var _filters = _interopRequireDefault(require("@webiny/db-dynamodb/plugins/filters"));
11
-
12
12
  var _dynamoDb = _interopRequireDefault(require("./dynamoDb"));
13
-
14
13
  var _types = require("./types");
15
-
16
14
  var _table = require("./definitions/table");
17
-
18
- var _settings = require("./definitions/settings");
19
-
20
15
  var _system = require("./definitions/system");
21
-
22
16
  var _group = require("./definitions/group");
23
-
24
17
  var _model = require("./definitions/model");
25
-
26
18
  var _entry = require("./definitions/entry");
27
-
28
19
  var _plugins = require("@webiny/plugins");
29
-
30
20
  var _system2 = require("./operations/system");
31
-
32
- var _settings2 = require("./operations/settings");
33
-
34
21
  var _group2 = require("./operations/group");
35
-
36
22
  var _model2 = require("./operations/model");
37
-
38
23
  var _entry2 = require("./operations/entry");
39
-
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];
34
+ }
35
+ });
36
+ });
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
40
  const createStorageOperations = params => {
41
41
  const {
42
- attributes = {},
42
+ attributes,
43
43
  table,
44
44
  documentClient,
45
- plugins: customPlugins,
46
- modelFieldToGraphQLPlugins
45
+ plugins: userPlugins
47
46
  } = params;
48
47
  const tableInstance = (0, _table.createTable)({
49
48
  table,
50
49
  documentClient
51
50
  });
52
51
  const entities = {
53
- settings: (0, _settings.createSettingsEntity)({
54
- entityName: _types.ENTITIES.SETTINGS,
55
- table: tableInstance,
56
- attributes: attributes[_types.ENTITIES.SETTINGS]
57
- }),
58
52
  system: (0, _system.createSystemEntity)({
59
53
  entityName: _types.ENTITIES.SYSTEM,
60
54
  table: tableInstance,
61
- attributes: attributes[_types.ENTITIES.SYSTEM]
55
+ attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
62
56
  }),
63
57
  groups: (0, _group.createGroupEntity)({
64
58
  entityName: _types.ENTITIES.GROUPS,
65
59
  table: tableInstance,
66
- attributes: attributes[_types.ENTITIES.GROUPS]
60
+ attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
67
61
  }),
68
62
  models: (0, _model.createModelEntity)({
69
63
  entityName: _types.ENTITIES.MODELS,
70
64
  table: tableInstance,
71
- attributes: attributes[_types.ENTITIES.MODELS]
65
+ attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
72
66
  }),
73
67
  entries: (0, _entry.createEntryEntity)({
74
68
  entityName: _types.ENTITIES.ENTRIES,
75
69
  table: tableInstance,
76
- attributes: attributes[_types.ENTITIES.ENTRIES]
70
+ attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
77
71
  })
78
72
  };
79
73
  const plugins = new _plugins.PluginsContainer([
80
74
  /**
81
- * User defined custom plugins.
75
+ * DynamoDB filter plugins for the where conditions.
82
76
  */
83
- ...(customPlugins || []),
77
+ (0, _filters.default)(),
84
78
  /**
85
- * Plugins of type CmsModelFieldToGraphQLPlugin.
79
+ * Field plugins for DynamoDB.
86
80
  */
87
- modelFieldToGraphQLPlugins,
81
+ (0, _dynamoDb.default)(),
88
82
  /**
89
- * DynamoDB filter plugins for the where conditions.
83
+ * Filter create plugins.
90
84
  */
91
- (0, _filters.default)(),
85
+ (0, _plugins2.createFilterCreatePlugins)(),
92
86
  /**
93
- * Field plugins for DynamoDB.
87
+ * User defined custom plugins.
94
88
  */
95
- (0, _dynamoDb.default)()]);
89
+ ...(userPlugins || [])]);
90
+ const entries = (0, _entry2.createEntriesStorageOperations)({
91
+ entity: entities.entries,
92
+ plugins
93
+ });
96
94
  return {
97
- plugins: [
98
- /**
99
- * Field plugins for DynamoDB.
100
- * We must pass them to the base application.
101
- */
102
- (0, _dynamoDb.default)()],
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
+ },
103
110
  getEntities: () => entities,
104
111
  getTable: () => tableInstance,
105
112
  system: (0, _system2.createSystemStorageOperations)({
106
113
  entity: entities.system
107
114
  }),
108
- settings: (0, _settings2.createSettingsStorageOperations)({
109
- entity: entities.settings
110
- }),
111
115
  groups: (0, _group2.createGroupsStorageOperations)({
112
116
  entity: entities.groups,
113
117
  plugins
@@ -115,11 +119,9 @@ const createStorageOperations = params => {
115
119
  models: (0, _model2.createModelsStorageOperations)({
116
120
  entity: entities.models
117
121
  }),
118
- entries: (0, _entry2.createEntriesStorageOperations)({
119
- entity: entities.entries,
120
- plugins
121
- })
122
+ entries
122
123
  };
123
124
  };
125
+ exports.createStorageOperations = createStorageOperations;
124
126
 
125
- exports.createStorageOperations = createStorageOperations;
127
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +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"],"m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export interface CacheKeyParams {
3
+ name: string;
4
+ tenant: string;
5
+ locale: string;
6
+ }
7
+ export interface ClearAllParams {
8
+ tenant: string;
9
+ locale: string;
10
+ }
11
+ export declare class DataLoaderCache {
12
+ private readonly cache;
13
+ getDataLoader<I = any, R = any>(params: CacheKeyParams): DataLoader<I, R> | null;
14
+ setDataLoader(params: CacheKeyParams, dataLoader: DataLoader<any, any>): void;
15
+ clearAll(params?: ClearAllParams): void;
16
+ private createKey;
17
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DataLoaderCache = void 0;
7
+ 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;
23
+ }
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();
33
+ }
34
+ }
35
+ createKey(params) {
36
+ return `${params.tenant}_${params.locale}_${params.name}`;
37
+ }
38
+ }
39
+ exports.DataLoaderCache = DataLoaderCache;
40
+
41
+ //# sourceMappingURL=DataLoaderCache.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1 @@
1
+ export declare const CMS_ENTRY_BATCH_SCHEDULE_WAIT: number;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CMS_ENTRY_BATCH_SCHEDULE_WAIT = void 0;
7
+ 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;
9
+
10
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +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":[]}
@@ -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,25 @@
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
+ };
22
+ };
23
+ exports.createBatchScheduleFn = createBatchScheduleFn;
24
+
25
+ //# sourceMappingURL=createBatchScheduleFn.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,4 @@
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>;
@@ -0,0 +1,45 @@
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] || [];
38
+ });
39
+ }, {
40
+ batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
41
+ });
42
+ };
43
+ exports.createGetAllEntryRevisions = createGetAllEntryRevisions;
44
+
45
+ //# sourceMappingURL=getAllEntryRevisions.js.map
@@ -0,0 +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":[]}
@@ -0,0 +1,4 @@
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>;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createGetLatestRevisionByEntryId = void 0;
8
+ var _dataloader = _interopRequireDefault(require("dataloader"));
9
+ var _dbDynamodb = require("@webiny/db-dynamodb");
10
+ var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
11
+ var _createBatchScheduleFn = require("./createBatchScheduleFn");
12
+ var _keys = require("../keys");
13
+ var _utils = require("@webiny/utils");
14
+ const createGetLatestRevisionByEntryId = params => {
15
+ const {
16
+ entity,
17
+ locale,
18
+ tenant
19
+ } = params;
20
+ const latestKey = (0, _keys.createLatestSortKey)();
21
+ return new _dataloader.default(async ids => {
22
+ const queries = ids.reduce((collection, id) => {
23
+ const partitionKey = (0, _keys.createPartitionKey)({
24
+ tenant,
25
+ locale,
26
+ id
27
+ });
28
+ if (collection[partitionKey]) {
29
+ return collection;
30
+ }
31
+ collection[partitionKey] = entity.getBatch({
32
+ PK: partitionKey,
33
+ SK: latestKey
34
+ });
35
+ return collection;
36
+ }, {});
37
+ const records = await (0, _dbDynamodb.batchReadAll)({
38
+ table: entity.table,
39
+ items: Object.values(queries)
40
+ });
41
+ const items = (0, _cleanup.cleanupItems)(entity, records);
42
+ return ids.map(id => {
43
+ const {
44
+ id: entryId
45
+ } = (0, _utils.parseIdentifier)(id);
46
+ return items.filter(item => {
47
+ return entryId === item.entryId;
48
+ });
49
+ });
50
+ }, {
51
+ batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
52
+ });
53
+ };
54
+ exports.createGetLatestRevisionByEntryId = createGetLatestRevisionByEntryId;
55
+
56
+ //# sourceMappingURL=getLatestRevisionByEntryId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_dataloader","_interopRequireDefault","require","_dbDynamodb","_cleanup","_createBatchScheduleFn","_keys","_utils","createGetLatestRevisionByEntryId","params","entity","locale","tenant","latestKey","createLatestSortKey","DataLoader","ids","queries","reduce","collection","id","partitionKey","createPartitionKey","getBatch","PK","SK","records","batchReadAll","table","items","Object","values","cleanupItems","map","entryId","parseIdentifier","filter","item","batchScheduleFn","createBatchScheduleFn","exports"],"sources":["getLatestRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { batchReadAll } from \"@webiny/db-dynamodb\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\nimport { createLatestSortKey, createPartitionKey } from \"~/operations/entry/keys\";\nimport type { DataLoaderParams } from \"./types\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport const createGetLatestRevisionByEntryId = (params: DataLoaderParams) => {\n const { entity, locale, tenant } = params;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async (ids: readonly string[]) => {\n const queries = ids.reduce<Record<string, any>>((collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: latestKey\n });\n return collection;\n }, {});\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AAEO,MAAMM,gCAAgC,GAAIC,MAAwB,I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gCAAA","ignoreList":[]}
@@ -0,0 +1,4 @@
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 createGetPublishedRevisionByEntryId: (params: DataLoaderParams) => DataLoader<string, CmsStorageEntry[], string>;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createGetPublishedRevisionByEntryId = void 0;
8
+ var _dataloader = _interopRequireDefault(require("dataloader"));
9
+ var _dbDynamodb = require("@webiny/db-dynamodb");
10
+ var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
11
+ var _keys = require("../keys");
12
+ var _utils = require("@webiny/utils");
13
+ var _createBatchScheduleFn = require("./createBatchScheduleFn");
14
+ const createGetPublishedRevisionByEntryId = params => {
15
+ const {
16
+ entity,
17
+ locale,
18
+ tenant
19
+ } = params;
20
+ const publishedKey = (0, _keys.createPublishedSortKey)();
21
+ return new _dataloader.default(async ids => {
22
+ const queries = ids.reduce((collection, id) => {
23
+ const partitionKey = (0, _keys.createPartitionKey)({
24
+ tenant,
25
+ locale,
26
+ id
27
+ });
28
+ if (collection[partitionKey]) {
29
+ return collection;
30
+ }
31
+ collection[partitionKey] = entity.getBatch({
32
+ PK: partitionKey,
33
+ SK: publishedKey
34
+ });
35
+ return collection;
36
+ }, {});
37
+ const records = await (0, _dbDynamodb.batchReadAll)({
38
+ table: entity.table,
39
+ items: Object.values(queries)
40
+ });
41
+ const items = (0, _cleanup.cleanupItems)(entity, records);
42
+ return ids.map(id => {
43
+ const {
44
+ id: entryId
45
+ } = (0, _utils.parseIdentifier)(id);
46
+ return items.filter(item => {
47
+ return entryId === item.entryId;
48
+ });
49
+ });
50
+ }, {
51
+ batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
52
+ });
53
+ };
54
+ exports.createGetPublishedRevisionByEntryId = createGetPublishedRevisionByEntryId;
55
+
56
+ //# sourceMappingURL=getPublishedRevisionByEntryId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_dataloader","_interopRequireDefault","require","_dbDynamodb","_cleanup","_keys","_utils","_createBatchScheduleFn","createGetPublishedRevisionByEntryId","params","entity","locale","tenant","publishedKey","createPublishedSortKey","DataLoader","ids","queries","reduce","collection","id","partitionKey","createPartitionKey","getBatch","PK","SK","records","batchReadAll","table","items","Object","values","cleanupItems","map","entryId","parseIdentifier","filter","item","batchScheduleFn","createBatchScheduleFn","exports"],"sources":["getPublishedRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { batchReadAll } from \"@webiny/db-dynamodb\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { createPartitionKey, createPublishedSortKey } from \"~/operations/entry/keys\";\nimport type { DataLoaderParams } from \"./types\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\n\nexport const createGetPublishedRevisionByEntryId = (params: DataLoaderParams) => {\n const { entity, locale, tenant } = params;\n\n const publishedKey = createPublishedSortKey();\n return new DataLoader<string, CmsStorageEntry[]>(\n async (ids: readonly string[]) => {\n const queries = ids.reduce<Record<string, ReturnType<typeof entity.getBatch>>>(\n (collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n if (collection[partitionKey]) {\n return collection;\n }\n collection[partitionKey] = entity.getBatch({\n PK: partitionKey,\n SK: publishedKey\n });\n return collection;\n },\n {}\n );\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchSchedule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sBAAe,EAACf,EAAE,CAAC;MAC3C,OAAOS,KAAK,CAACO,MAAM,CAACC,IAAI,IAAI;QACxB,OAAOH,OAAO,KAAKG,IAAI,CAACH,OAAO;MACnC,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACII,eAAe,EAAE,IAAAC,4CAAqB,EAAC;EAC3C,CACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAhC,mCAAA,GAAAA,mCAAA","ignoreList":[]}
@@ -0,0 +1,4 @@
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 createGetRevisionById: (params: DataLoaderParams) => DataLoader<string, CmsStorageEntry[], string>;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createGetRevisionById = void 0;
8
+ var _dataloader = _interopRequireDefault(require("dataloader"));
9
+ var _dbDynamodb = require("@webiny/db-dynamodb");
10
+ var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
11
+ var _keys = require("../keys");
12
+ var _utils = require("@webiny/utils");
13
+ var _createBatchScheduleFn = require("./createBatchScheduleFn");
14
+ const createGetRevisionById = params => {
15
+ const {
16
+ entity,
17
+ locale,
18
+ tenant
19
+ } = params;
20
+ return new _dataloader.default(async ids => {
21
+ const queries = ids.reduce((collection, id) => {
22
+ const partitionKey = (0, _keys.createPartitionKey)({
23
+ tenant,
24
+ locale,
25
+ id
26
+ });
27
+ const {
28
+ version
29
+ } = (0, _utils.parseIdentifier)(id);
30
+ if (version === null) {
31
+ return collection;
32
+ }
33
+ const sortKey = (0, _keys.createRevisionSortKey)({
34
+ version
35
+ });
36
+ const keys = `${partitionKey}__${sortKey}`;
37
+ if (collection[keys]) {
38
+ return collection;
39
+ }
40
+ collection[keys] = entity.getBatch({
41
+ PK: partitionKey,
42
+ SK: sortKey
43
+ });
44
+ return collection;
45
+ }, {});
46
+ const records = await (0, _dbDynamodb.batchReadAll)({
47
+ table: entity.table,
48
+ items: Object.values(queries)
49
+ });
50
+ const items = (0, _cleanup.cleanupItems)(entity, records);
51
+ return ids.map(id => {
52
+ return items.filter(item => {
53
+ return id === item.id;
54
+ });
55
+ });
56
+ }, {
57
+ batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
58
+ });
59
+ };
60
+ exports.createGetRevisionById = createGetRevisionById;
61
+
62
+ //# sourceMappingURL=getRevisionById.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_dataloader","_interopRequireDefault","require","_dbDynamodb","_cleanup","_keys","_utils","_createBatchScheduleFn","createGetRevisionById","params","entity","locale","tenant","DataLoader","ids","queries","reduce","collection","id","partitionKey","createPartitionKey","version","parseIdentifier","sortKey","createRevisionSortKey","keys","getBatch","PK","SK","records","batchReadAll","table","items","Object","values","cleanupItems","map","filter","item","batchScheduleFn","createBatchScheduleFn","exports"],"sources":["getRevisionById.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { batchReadAll } from \"@webiny/db-dynamodb\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { createPartitionKey, createRevisionSortKey } from \"~/operations/entry/keys\";\nimport type { DataLoaderParams } from \"./types\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\n\nexport const createGetRevisionById = (params: DataLoaderParams) => {\n const { entity, locale, tenant } = params;\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async (ids: readonly string[]) => {\n const queries = ids.reduce<Record<string, ReturnType<typeof entity.getBatch>>>(\n (collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n const { version } = parseIdentifier(id);\n if (version === null) {\n return collection;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const keys = `${partitionKey}__${sortKey}`;\n if (collection[keys]) {\n return collection;\n }\n\n collection[keys] = entity.getBatch({\n PK: partitionKey,\n SK: sortKey\n });\n\n return collection;\n },\n {}\n );\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n return items.filter(item => {\n return id === item.id;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,sBAAA,GAAAL,OAAA;AAEO,MAAMM,qBAAqB,GAAIC,MAAwB,IAAK;EAC/D,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAEzC,OAAO,IAAII,mBAAU,CACjB,MAAOC,GAAsB,IAAK;IAC9B,MAAMC,OAAO,GAAGD,GAAG,CAACE,MAAM,CACtB,CAACC,UAAU,EAAEC,EAAE,KAAK;MAChB,MAAMC,YAAY,GAAG,IAAAC,wBAAkB,EAAC;QACpCR,MAAM;QACND,MAAM;QACNO;MACJ,CAAC,CAAC;MACF,MAAM;QAAEG;MAAQ,CAAC,GAAG,IAAAC,sBAAe,EAACJ,EAAE,CAAC;MACvC,IAAIG,OAAO,KAAK,IAAI,EAAE;QAClB,OAAOJ,UAAU;MACrB;MACA,MAAMM,OAAO,GAAG,IAAAC,2BAAqB,EAAC;QAClCH;MACJ,CAAC,CAAC;MACF,MAAMI,IAAI,GAAG,GAAGN,YAAY,KAAKI,OAAO,EAAE;MAC1C,IAAIN,UAAU,CAACQ,IAAI,CAAC,EAAE;QAClB,OAAOR,UAAU;MACrB;MAEAA,UAAU,CAACQ,IAAI,CAAC,GAAGf,MAAM,CAACgB,QAAQ,CAAC;QAC/BC,EAAE,EAAER,YAAY;QAChBS,EAAE,EAAEL;MACR,CAAC,CAAC;MAEF,OAAON,UAAU;IACrB,CAAC,EACD,CAAC,CACL,CAAC;IAED,MAAMY,OAAO,GAAG,MAAM,IAAAC,wBAAY,EAAkB;MAChDC,KAAK,EAAErB,MAAM,CAACqB,KAAK;MACnBC,KAAK,EAAEC,MAAM,CAACC,MAAM,CAACnB,OAAO;IAChC,CAAC,CAAC;IACF,MAAMiB,KAAK,GAAG,IAAAG,qBAAY,EAACzB,MAAM,EAAEmB,OAAO,CAAC;IAE3C,OAAOf,GAAG,CAACsB,GAAG,CAAClB,EAAE,IAAI;MACjB,OAAOc,KAAK,CAACK,MAAM,CAACC,IAAI,IAAI;QACxB,OAAOpB,EAAE,KAAKoB,IAAI,CAACpB,EAAE;MACzB,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIqB,eAAe,EAAE,IAAAC,4CAAqB,EAAC;EAC3C,CACJ,CAAC;AACL,CAAC;AAACC,OAAA,CAAAjC,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import type DataLoader from "dataloader";
2
+ import type { DataLoaderParams } from "./types";
3
+ export * from "./DataLoaderCache";
4
+ interface Callable {
5
+ (params: DataLoaderParams): DataLoader<any, any>;
6
+ }
7
+ export type DataLoaders = "getAllEntryRevisions" | "getRevisionById" | "getPublishedRevisionByEntryId" | "getLatestRevisionByEntryId";
8
+ export declare const getDataLoaderFactory: (name: string) => Callable;