@webiny/api-headless-cms-ddb 6.0.0-beta.0 → 6.0.0-rc.1

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 -5
  3. package/definitions/entry.js +5 -180
  4. package/definitions/entry.js.map +1 -1
  5. package/definitions/group.d.ts +4 -5
  6. package/definitions/group.js +5 -58
  7. package/definitions/group.js.map +1 -1
  8. package/definitions/model.d.ts +4 -5
  9. package/definitions/model.js +5 -102
  10. package/definitions/model.js.map +1 -1
  11. package/definitions/table.d.ts +3 -5
  12. package/definitions/table.js +6 -28
  13. package/definitions/table.js.map +1 -1
  14. package/definitions/types.d.ts +59 -0
  15. package/definitions/types.js +3 -0
  16. package/definitions/types.js.map +1 -0
  17. package/dynamoDb/index.d.ts +1 -1
  18. package/dynamoDb/index.js +6 -14
  19. package/dynamoDb/index.js.map +1 -1
  20. package/dynamoDb/path/locationFolderId.d.ts +1 -1
  21. package/dynamoDb/path/locationFolderId.js +5 -14
  22. package/dynamoDb/path/locationFolderId.js.map +1 -1
  23. package/dynamoDb/path/plainObject.d.ts +1 -1
  24. package/dynamoDb/path/plainObject.js +5 -14
  25. package/dynamoDb/path/plainObject.js.map +1 -1
  26. package/dynamoDb/storage/longText.js +11 -18
  27. package/dynamoDb/storage/longText.js.map +1 -1
  28. package/dynamoDb/storage/richText.js +26 -71
  29. package/dynamoDb/storage/richText.js.map +1 -1
  30. package/dynamoDb/transformValue/datetime.d.ts +1 -1
  31. package/dynamoDb/transformValue/datetime.js +5 -12
  32. package/dynamoDb/transformValue/datetime.js.map +1 -1
  33. package/index.d.ts +2 -2
  34. package/index.js +38 -72
  35. package/index.js.map +1 -1
  36. package/operations/entry/dataLoader/DataLoaderCache.d.ts +1 -3
  37. package/operations/entry/dataLoader/DataLoaderCache.js +2 -9
  38. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  39. package/operations/entry/dataLoader/constants.js +1 -7
  40. package/operations/entry/dataLoader/constants.js.map +1 -1
  41. package/operations/entry/dataLoader/createBatchScheduleFn.js +4 -10
  42. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
  43. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
  44. package/operations/entry/dataLoader/getAllEntryRevisions.js +11 -24
  45. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  46. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
  47. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +22 -32
  48. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  49. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
  50. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +22 -32
  51. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  52. package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
  53. package/operations/entry/dataLoader/getRevisionById.js +24 -34
  54. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  55. package/operations/entry/dataLoader/index.d.ts +5 -5
  56. package/operations/entry/dataLoader/index.js +10 -31
  57. package/operations/entry/dataLoader/index.js.map +1 -1
  58. package/operations/entry/dataLoader/types.d.ts +3 -4
  59. package/operations/entry/dataLoader/types.js +1 -5
  60. package/operations/entry/dataLoader/types.js.map +1 -1
  61. package/operations/entry/dataLoaders.d.ts +11 -12
  62. package/operations/entry/dataLoaders.js +15 -25
  63. package/operations/entry/dataLoaders.js.map +1 -1
  64. package/operations/entry/filtering/createExpressions.d.ts +5 -5
  65. package/operations/entry/filtering/createExpressions.js +27 -30
  66. package/operations/entry/filtering/createExpressions.js.map +1 -1
  67. package/operations/entry/filtering/createFields.d.ts +3 -3
  68. package/operations/entry/filtering/createFields.js +20 -22
  69. package/operations/entry/filtering/createFields.js.map +1 -1
  70. package/operations/entry/filtering/extractSort.d.ts +6 -6
  71. package/operations/entry/filtering/extractSort.js +38 -23
  72. package/operations/entry/filtering/extractSort.js.map +1 -1
  73. package/operations/entry/filtering/filter.d.ts +6 -6
  74. package/operations/entry/filtering/filter.js +13 -21
  75. package/operations/entry/filtering/filter.js.map +1 -1
  76. package/operations/entry/filtering/fullTextSearch.d.ts +3 -3
  77. package/operations/entry/filtering/fullTextSearch.js +6 -14
  78. package/operations/entry/filtering/fullTextSearch.js.map +1 -1
  79. package/operations/entry/filtering/getValue.js +1 -8
  80. package/operations/entry/filtering/getValue.js.map +1 -1
  81. package/operations/entry/filtering/index.d.ts +2 -2
  82. package/operations/entry/filtering/index.js +2 -19
  83. package/operations/entry/filtering/index.js.map +1 -1
  84. package/operations/entry/filtering/mapPlugins.d.ts +2 -2
  85. package/operations/entry/filtering/mapPlugins.js +3 -11
  86. package/operations/entry/filtering/mapPlugins.js.map +1 -1
  87. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +2 -2
  88. package/operations/entry/filtering/plugins/defaultFilterCreate.js +6 -14
  89. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +1 -1
  90. package/operations/entry/filtering/plugins/index.d.ts +1 -1
  91. package/operations/entry/filtering/plugins/index.js +6 -12
  92. package/operations/entry/filtering/plugins/index.js.map +1 -1
  93. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +2 -2
  94. package/operations/entry/filtering/plugins/objectFilterCreate.js +13 -19
  95. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +1 -1
  96. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +3 -2
  97. package/operations/entry/filtering/plugins/refFilterCreate.js +18 -19
  98. package/operations/entry/filtering/plugins/refFilterCreate.js.map +1 -1
  99. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +2 -0
  100. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +57 -0
  101. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +1 -0
  102. package/operations/entry/filtering/sort.d.ts +6 -6
  103. package/operations/entry/filtering/sort.js +16 -20
  104. package/operations/entry/filtering/sort.js.map +1 -1
  105. package/operations/entry/filtering/systemFields.d.ts +2 -4
  106. package/operations/entry/filtering/systemFields.js +55 -29
  107. package/operations/entry/filtering/systemFields.js.map +1 -1
  108. package/operations/entry/filtering/transform.d.ts +1 -1
  109. package/operations/entry/filtering/transform.js +1 -8
  110. package/operations/entry/filtering/transform.js.map +1 -1
  111. package/operations/entry/filtering/types.d.ts +3 -3
  112. package/operations/entry/filtering/types.js +1 -5
  113. package/operations/entry/filtering/types.js.map +1 -1
  114. package/operations/entry/filtering/values.d.ts +1 -1
  115. package/operations/entry/filtering/values.js +4 -12
  116. package/operations/entry/filtering/values.js.map +1 -1
  117. package/operations/entry/filtering/where.js +1 -8
  118. package/operations/entry/filtering/where.js.map +1 -1
  119. package/operations/entry/index.d.ts +3 -4
  120. package/operations/entry/index.js +447 -495
  121. package/operations/entry/index.js.map +1 -1
  122. package/operations/entry/keys.d.ts +40 -2
  123. package/operations/entry/keys.js +53 -30
  124. package/operations/entry/keys.js.map +1 -1
  125. package/operations/group/index.d.ts +4 -4
  126. package/operations/group/index.js +35 -64
  127. package/operations/group/index.js.map +1 -1
  128. package/operations/model/index.d.ts +3 -3
  129. package/operations/model/index.js +36 -58
  130. package/operations/model/index.js.map +1 -1
  131. package/package.json +20 -26
  132. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +2 -2
  133. package/plugins/CmsEntryFieldFilterPathPlugin.js +4 -12
  134. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +1 -1
  135. package/plugins/CmsEntryFieldFilterPlugin.d.ts +10 -10
  136. package/plugins/CmsEntryFieldFilterPlugin.js +2 -8
  137. package/plugins/CmsEntryFieldFilterPlugin.js.map +1 -1
  138. package/plugins/CmsEntryFieldSortingPlugin.d.ts +2 -2
  139. package/plugins/CmsEntryFieldSortingPlugin.js +3 -11
  140. package/plugins/CmsEntryFieldSortingPlugin.js.map +1 -1
  141. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +2 -2
  142. package/plugins/CmsFieldFilterValueTransformPlugin.js +2 -9
  143. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +1 -1
  144. package/plugins/index.d.ts +4 -4
  145. package/plugins/index.js +4 -49
  146. package/plugins/index.js.map +1 -1
  147. package/types.d.ts +17 -19
  148. package/types.js +1 -8
  149. package/types.js.map +1 -1
  150. package/definitions/system.d.ts +0 -9
  151. package/definitions/system.js +0 -42
  152. package/definitions/system.js.map +0 -1
  153. package/dynamoDb/storage/date.d.ts +0 -3
  154. package/dynamoDb/storage/date.js +0 -84
  155. package/dynamoDb/storage/date.js.map +0 -1
  156. package/operations/system/index.d.ts +0 -7
  157. package/operations/system/index.js +0 -94
  158. package/operations/system/index.js.map +0 -1
package/index.js CHANGED
@@ -1,99 +1,69 @@
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
9
- };
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];
34
- }
35
- });
36
- });
37
- var _ValueFilterPlugin = require("@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin");
38
- var _apiHeadlessCms = require("@webiny/api-headless-cms");
39
- const createStorageOperations = params => {
1
+ import dynamoDbValueFilters from "@webiny/db-dynamodb/plugins/filters/index.js";
2
+ import dynamoDbPlugins from "./dynamoDb/index.js";
3
+ import { ENTITIES } from "./types.js";
4
+ import { createGroupEntity } from "./definitions/group.js";
5
+ import { createModelEntity } from "./definitions/model.js";
6
+ import { createEntryEntity } from "./definitions/entry.js";
7
+ import { PluginsContainer } from "@webiny/plugins";
8
+ import { createGroupsStorageOperations } from "./operations/group/index.js";
9
+ import { createModelsStorageOperations } from "./operations/model/index.js";
10
+ import { createEntriesStorageOperations } from "./operations/entry/index.js";
11
+ import { createFilterCreatePlugins } from "./operations/entry/filtering/plugins/index.js";
12
+ import { CmsEntryFieldFilterPathPlugin, CmsEntryFieldFilterPlugin, CmsEntryFieldSortingPlugin, CmsFieldFilterValueTransformPlugin } from "./plugins/index.js";
13
+ import { ValueFilterPlugin } from "@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin.js";
14
+ import { StorageOperationsCmsModelPlugin, StorageTransformPlugin } from "@webiny/api-headless-cms";
15
+ import { CompressorPlugin } from "@webiny/api";
16
+ import { createTable } from "./definitions/table.js";
17
+ export * from "./plugins/index.js";
18
+ export const createStorageOperations = params => {
40
19
  const {
41
- attributes,
42
20
  table,
43
21
  documentClient,
44
22
  plugins: userPlugins
45
23
  } = params;
46
- const tableInstance = (0, _table.createTable)({
47
- table,
24
+ const tableInstance = createTable({
25
+ name: table,
48
26
  documentClient
49
27
  });
50
28
  const entities = {
51
- system: (0, _system.createSystemEntity)({
52
- entityName: _types.ENTITIES.SYSTEM,
53
- table: tableInstance,
54
- attributes: attributes ? attributes[_types.ENTITIES.SYSTEM] : {}
55
- }),
56
- groups: (0, _group.createGroupEntity)({
57
- entityName: _types.ENTITIES.GROUPS,
58
- table: tableInstance,
59
- attributes: attributes ? attributes[_types.ENTITIES.GROUPS] : {}
29
+ groups: createGroupEntity({
30
+ entityName: ENTITIES.GROUPS,
31
+ table: tableInstance
60
32
  }),
61
- models: (0, _model.createModelEntity)({
62
- entityName: _types.ENTITIES.MODELS,
63
- table: tableInstance,
64
- attributes: attributes ? attributes[_types.ENTITIES.MODELS] : {}
33
+ models: createModelEntity({
34
+ entityName: ENTITIES.MODELS,
35
+ table: tableInstance
65
36
  }),
66
- entries: (0, _entry.createEntryEntity)({
67
- entityName: _types.ENTITIES.ENTRIES,
68
- table: tableInstance,
69
- attributes: attributes ? attributes[_types.ENTITIES.ENTRIES] : {}
37
+ entries: createEntryEntity({
38
+ entityName: ENTITIES.ENTRIES,
39
+ table: tableInstance
70
40
  })
71
41
  };
72
- const plugins = new _plugins.PluginsContainer([
42
+ const plugins = new PluginsContainer([
73
43
  /**
74
44
  * DynamoDB filter plugins for the where conditions.
75
45
  */
76
- (0, _filters.default)(),
46
+ dynamoDbValueFilters(),
77
47
  /**
78
48
  * Field plugins for DynamoDB.
79
49
  */
80
- (0, _dynamoDb.default)(),
50
+ dynamoDbPlugins(),
81
51
  /**
82
52
  * Filter create plugins.
83
53
  */
84
- (0, _plugins2.createFilterCreatePlugins)(),
54
+ createFilterCreatePlugins(),
85
55
  /**
86
56
  * User defined custom plugins.
87
57
  */
88
58
  ...(userPlugins || [])]);
89
- const entries = (0, _entry2.createEntriesStorageOperations)({
59
+ const entries = createEntriesStorageOperations({
90
60
  entity: entities.entries,
91
61
  plugins
92
62
  });
93
63
  return {
94
64
  name: "dynamodb",
95
65
  beforeInit: async context => {
96
- 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];
66
+ const types = ["cms-model-field-to-graphql", CmsEntryFieldFilterPathPlugin.type, CmsFieldFilterValueTransformPlugin.type, CmsEntryFieldFilterPlugin.type, CmsEntryFieldSortingPlugin.type, ValueFilterPlugin.type, StorageOperationsCmsModelPlugin.type, StorageTransformPlugin.type, CompressorPlugin.type];
97
67
  /**
98
68
  * Collect all required plugins from parent context.
99
69
  */
@@ -103,24 +73,20 @@ const createStorageOperations = params => {
103
73
  /**
104
74
  * Pass the plugins to the parent context.
105
75
  */
106
- context.plugins.register([(0, _dynamoDb.default)()]);
76
+ context.plugins.register([dynamoDbPlugins()]);
107
77
  entries.dataLoaders.clearAll();
108
78
  },
109
79
  getEntities: () => entities,
110
80
  getTable: () => tableInstance,
111
- system: (0, _system2.createSystemStorageOperations)({
112
- entity: entities.system
113
- }),
114
- groups: (0, _group2.createGroupsStorageOperations)({
81
+ groups: createGroupsStorageOperations({
115
82
  entity: entities.groups,
116
83
  plugins
117
84
  }),
118
- models: (0, _model2.createModelsStorageOperations)({
85
+ models: createModelsStorageOperations({
119
86
  entity: entities.models
120
87
  }),
121
88
  entries
122
89
  };
123
90
  };
124
- exports.createStorageOperations = createStorageOperations;
125
91
 
126
92
  //# 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","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","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 { ENTITIES, StorageOperationsFactory } 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 } from \"@webiny/api-headless-cms\";\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 ];\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":";;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AACA,IAAAY,OAAA,GAAAZ,OAAA;AAEA,IAAAa,SAAA,GAAAb,OAAA;AACA,IAAAc,SAAA,GAAAd,OAAA;AASAe,MAAA,CAAAC,IAAA,CAAAF,SAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,SAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,SAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAHA,IAAAS,kBAAA,GAAA3B,OAAA;AACA,IAAA4B,eAAA,GAAA5B,OAAA;AAIO,MAAM6B,uBAAiD,GAAGC,MAAM,IAAI;EACvE,MAAM;IAAEC,UAAU;IAAEC,KAAK;IAAEC,cAAc;IAAEC,OAAO,EAAEC;EAAY,CAAC,GAAGL,MAAM;EAE1E,MAAMM,aAAa,GAAG,IAAAC,kBAAW,EAAC;IAC9BL,KAAK;IACLC;EACJ,CAAC,CAAC;EAEF,MAAMK,QAAQ,GAAG;IACbC,MAAM,EAAE,IAAAC,0BAAkB,EAAC;MACvBC,UAAU,EAAEC,eAAQ,CAACC,MAAM;MAC3BX,KAAK,EAAEI,aAAa;MACpBL,UAAU,EAAEA,UAAU,GAAGA,UAAU,CAACW,eAAQ,CAACC,MAAM,CAAC,GAAG,CAAC;IAC5D,CAAC,CAAC;IACFC,MAAM,EAAE,IAAAC,wBAAiB,EAAC;MACtBJ,UAAU,EAAEC,eAAQ,CAACI,MAAM;MAC3Bd,KAAK,EAAEI,aAAa;MACpBL,UAAU,EAAEA,UAAU,GAAGA,UAAU,CAACW,eAAQ,CAACI,MAAM,CAAC,GAAG,CAAC;IAC5D,CAAC,CAAC;IACFC,MAAM,EAAE,IAAAC,wBAAiB,EAAC;MACtBP,UAAU,EAAEC,eAAQ,CAACO,MAAM;MAC3BjB,KAAK,EAAEI,aAAa;MACpBL,UAAU,EAAEA,UAAU,GAAGA,UAAU,CAACW,eAAQ,CAACO,MAAM,CAAC,GAAG,CAAC;IAC5D,CAAC,CAAC;IACFC,OAAO,EAAE,IAAAC,wBAAiB,EAAC;MACvBV,UAAU,EAAEC,eAAQ,CAACU,OAAO;MAC5BpB,KAAK,EAAEI,aAAa;MACpBL,UAAU,EAAEA,UAAU,GAAGA,UAAU,CAACW,eAAQ,CAACU,OAAO,CAAC,GAAG,CAAC;IAC7D,CAAC;EACL,CAAC;EAED,MAAMlB,OAAO,GAAG,IAAImB,yBAAgB,CAAC;EACjC;AACR;AACA;EACQ,IAAAC,gBAAoB,EAAC,CAAC;EACtB;AACR;AACA;EACQ,IAAAC,iBAAe,EAAC,CAAC;EACjB;AACR;AACA;EACQ,IAAAC,mCAAyB,EAAC,CAAC;EAC3B;AACR;AACA;EACQ,IAAIrB,WAAW,IAAI,EAAE,CAAC,CACzB,CAAC;EAEF,MAAMe,OAAO,GAAG,IAAAO,sCAA8B,EAAC;IAC3CC,MAAM,EAAEpB,QAAQ,CAACY,OAAO;IACxBhB;EACJ,CAAC,CAAC;EAEF,OAAO;IACHyB,IAAI,EAAE,UAAU;IAChBC,UAAU,EAAE,MAAMC,OAAO,IAAI;MACzB,MAAMC,KAAe,GAAG,CACpB,4BAA4B,EAC5BC,uCAA6B,CAACC,IAAI,EAClCC,4CAAkC,CAACD,IAAI,EACvCE,mCAAyB,CAACF,IAAI,EAC9BG,oCAA0B,CAACH,IAAI,EAC/BI,oCAAiB,CAACJ,IAAI,EACtBK,+CAA+B,CAACL,IAAI,CACvC;MACD;AACZ;AACA;MACY,KAAK,MAAMA,IAAI,IAAIF,KAAK,EAAE;QACtB5B,OAAO,CAACoC,WAAW,CAACT,OAAO,CAAC3B,OAAO,EAAE8B,IAAI,CAAC;MAC9C;MACA;AACZ;AACA;MACYH,OAAO,CAAC3B,OAAO,CAACqC,QAAQ,CAAC,CAAC,IAAAhB,iBAAe,EAAC,CAAC,CAAC,CAAC;MAE7CL,OAAO,CAACsB,WAAW,CAACC,QAAQ,CAAC,CAAC;IAClC,CAAC;IACDC,WAAW,EAAEA,CAAA,KAAMpC,QAAQ;IAC3BqC,QAAQ,EAAEA,CAAA,KAAMvC,aAAa;IAC7BG,MAAM,EAAE,IAAAqC,sCAA6B,EAAC;MAClClB,MAAM,EAAEpB,QAAQ,CAACC;IACrB,CAAC,CAAC;IACFK,MAAM,EAAE,IAAAiC,qCAA6B,EAAC;MAClCnB,MAAM,EAAEpB,QAAQ,CAACM,MAAM;MACvBV;IACJ,CAAC,CAAC;IACFa,MAAM,EAAE,IAAA+B,qCAA6B,EAAC;MAClCpB,MAAM,EAAEpB,QAAQ,CAACS;IACrB,CAAC,CAAC;IACFG;EACJ,CAAC;AACL,CAAC;AAAC3B,OAAA,CAAAM,uBAAA,GAAAA,uBAAA","ignoreList":[]}
1
+ {"version":3,"names":["dynamoDbValueFilters","dynamoDbPlugins","ENTITIES","createGroupEntity","createModelEntity","createEntryEntity","PluginsContainer","createGroupsStorageOperations","createModelsStorageOperations","createEntriesStorageOperations","createFilterCreatePlugins","CmsEntryFieldFilterPathPlugin","CmsEntryFieldFilterPlugin","CmsEntryFieldSortingPlugin","CmsFieldFilterValueTransformPlugin","ValueFilterPlugin","StorageOperationsCmsModelPlugin","StorageTransformPlugin","CompressorPlugin","createTable","createStorageOperations","params","table","documentClient","plugins","userPlugins","tableInstance","name","entities","groups","entityName","GROUPS","models","MODELS","entries","ENTRIES","entity","beforeInit","context","types","type","mergeByType","register","dataLoaders","clearAll","getEntities","getTable"],"sources":["index.ts"],"sourcesContent":["import dynamoDbValueFilters from \"@webiny/db-dynamodb/plugins/filters/index.js\";\nimport dynamoDbPlugins from \"./dynamoDb/index.js\";\nimport type { 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 { PluginsContainer } from \"@webiny/plugins\";\nimport { createGroupsStorageOperations } from \"~/operations/group/index.js\";\nimport { createModelsStorageOperations } from \"~/operations/model/index.js\";\nimport { createEntriesStorageOperations } from \"./operations/entry/index.js\";\n\nimport { createFilterCreatePlugins } from \"~/operations/entry/filtering/plugins/index.js\";\nimport {\n CmsEntryFieldFilterPathPlugin,\n CmsEntryFieldFilterPlugin,\n CmsEntryFieldSortingPlugin,\n CmsFieldFilterValueTransformPlugin\n} from \"~/plugins/index.js\";\nimport { ValueFilterPlugin } from \"@webiny/db-dynamodb/plugins/definitions/ValueFilterPlugin.js\";\nimport { StorageOperationsCmsModelPlugin, StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CompressorPlugin } from \"@webiny/api\";\nimport { createTable } from \"~/definitions/table.js\";\n\nexport * from \"./plugins/index.js\";\n\nexport const createStorageOperations: StorageOperationsFactory = params => {\n const { table, documentClient, plugins: userPlugins } = params;\n\n const tableInstance = createTable({\n name: table,\n documentClient\n });\n\n const entities = {\n groups: createGroupEntity({\n entityName: ENTITIES.GROUPS,\n table: tableInstance\n }),\n models: createModelEntity({\n entityName: ENTITIES.MODELS,\n table: tableInstance\n }),\n entries: createEntryEntity({\n entityName: ENTITIES.ENTRIES,\n table: tableInstance\n })\n };\n\n 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 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,12 +1,10 @@
1
- import DataLoader from "dataloader";
1
+ import type DataLoader from "dataloader";
2
2
  export interface CacheKeyParams {
3
3
  name: string;
4
4
  tenant: string;
5
- locale: string;
6
5
  }
7
6
  export interface ClearAllParams {
8
7
  tenant: string;
9
- locale: string;
10
8
  }
11
9
  export declare class DataLoaderCache {
12
10
  private readonly cache;
@@ -1,10 +1,4 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.DataLoaderCache = void 0;
7
- class DataLoaderCache {
1
+ export class DataLoaderCache {
8
2
  cache = {};
9
3
  getDataLoader(params) {
10
4
  const key = this.createKey(params);
@@ -33,9 +27,8 @@ class DataLoaderCache {
33
27
  }
34
28
  }
35
29
  createKey(params) {
36
- return `${params.tenant}_${params.locale}_${params.name}`;
30
+ return `${params.tenant}_${params.name}`;
37
31
  }
38
32
  }
39
- exports.DataLoaderCache = DataLoaderCache;
40
33
 
41
34
  //# 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 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,OAAQ,GAAEA,MAAM,CAACS,MAAO,IAAGT,MAAM,CAACU,MAAO,IAAGV,MAAM,CAACO,IAAK,EAAC;EAC7D;AACJ;AAACI,OAAA,CAAAd,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["DataLoaderCache","cache","getDataLoader","params","key","createKey","setDataLoader","dataLoader","clearAll","current","name","startsWith","tenant"],"sources":["DataLoaderCache.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\n\nexport interface CacheKeyParams {\n name: string;\n tenant: 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 = 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.name}`;\n }\n}\n"],"mappings":"AAWA,OAAO,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,CAACO,IAAI,EAAE;EAC5C;AACJ","ignoreList":[]}
@@ -1,10 +1,4 @@
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
+ export const CMS_ENTRY_BATCH_SCHEDULE_WAIT = isNaN(batchScheduleWaitEnv) ? 0 : batchScheduleWaitEnv;
9
3
 
10
4
  //# 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,"names":["batchScheduleWaitEnv","Number","process","env","WEBINY_API_CMS_ENTRY_BATCH_SCHEDULE_WAIT","CMS_ENTRY_BATCH_SCHEDULE_WAIT","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;AAChG,OAAO,MAAMC,6BAA6B,GAAGC,KAAK,CAACN,oBAAoB,CAAC,GAAG,CAAC,GAAGA,oBAAoB","ignoreList":[]}
@@ -1,10 +1,5 @@
1
- "use strict";
1
+ import { CMS_ENTRY_BATCH_SCHEDULE_WAIT } from "./constants.js";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createBatchScheduleFn = void 0;
7
- var _constants = require("./constants");
8
3
  /**
9
4
  * This is to be used when user wants to wait for a number of milliseconds before the batch is executed.
10
5
  * Intended to be used internally or for a specific user case.
@@ -12,14 +7,13 @@ var _constants = require("./constants");
12
7
  *
13
8
  * https://github.com/graphql/dataloader#batch-scheduling
14
9
  */
15
- const createBatchScheduleFn = () => {
16
- if (_constants.CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) {
10
+ export const createBatchScheduleFn = () => {
11
+ if (CMS_ENTRY_BATCH_SCHEDULE_WAIT <= 0) {
17
12
  return undefined;
18
13
  }
19
14
  return callback => {
20
- setTimeout(callback, _constants.CMS_ENTRY_BATCH_SCHEDULE_WAIT);
15
+ setTimeout(callback, CMS_ENTRY_BATCH_SCHEDULE_WAIT);
21
16
  };
22
17
  };
23
- exports.createBatchScheduleFn = createBatchScheduleFn;
24
18
 
25
19
  //# 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,"names":["CMS_ENTRY_BATCH_SCHEDULE_WAIT","createBatchScheduleFn","undefined","callback","setTimeout"],"sources":["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"],"mappings":"AAAA,SAASA,6BAA6B;;AAEtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,GAAGA,CAAA,KAAM;EACvC,IAAID,6BAA6B,IAAI,CAAC,EAAE;IACpC,OAAOE,SAAS;EACpB;EACA,OAAQC,QAAoB,IAAK;IAC7BC,UAAU,CAACD,QAAQ,EAAEH,6BAA6B,CAAC;EACvD,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  import DataLoader from "dataloader";
2
- import { CmsStorageEntry } from "@webiny/api-headless-cms/types";
3
- import { 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,32 @@
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 => {
1
+ import DataLoader from "dataloader";
2
+ import { createPartitionKey } from "../keys.js";
3
+ import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
4
+ export const createGetAllEntryRevisions = params => {
14
5
  const {
15
6
  entity,
16
- locale,
17
7
  tenant
18
8
  } = params;
19
- return new _dataloader.default(async ids => {
9
+ return new DataLoader(async ids => {
20
10
  const results = {};
21
11
  for (const id of ids) {
22
- const queryAllParams = {
23
- entity,
24
- partitionKey: (0, _keys.createPartitionKey)({
12
+ results[id] = (await entity.queryAllClean({
13
+ partitionKey: createPartitionKey({
25
14
  tenant,
26
- locale,
27
15
  id
28
16
  }),
29
17
  options: {
30
18
  beginsWith: "REV#"
31
19
  }
32
- };
33
- const items = await (0, _query.queryAll)(queryAllParams);
34
- results[id] = (0, _cleanup.cleanupItems)(entity, items);
20
+ })).map(result => {
21
+ return result.data;
22
+ });
35
23
  }
36
24
  return ids.map(id => {
37
25
  return results[id] || [];
38
26
  });
39
27
  }, {
40
- batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
28
+ batchScheduleFn: createBatchScheduleFn()
41
29
  });
42
30
  };
43
- exports.createGetAllEntryRevisions = createGetAllEntryRevisions;
44
31
 
45
32
  //# 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 { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { createPartitionKey } from \"~/operations/entry/keys\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { 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;AAEA,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,"names":["DataLoader","createPartitionKey","createBatchScheduleFn","createGetAllEntryRevisions","params","entity","tenant","ids","results","id","queryAllClean","partitionKey","options","beginsWith","map","result","data","batchScheduleFn"],"sources":["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 } = 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] || [];\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AAEnC,SAASC,kBAAkB;AAE3B,SAASC,qBAAqB;AAE9B,OAAO,MAAMC,0BAA0B,GAAIC,MAAyB,IAAK;EACrE,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EACjC,OAAO,IAAIJ,UAAU,CACjB,MAAMO,GAAG,IAAI;IACT,MAAMC,OAA0C,GAAG,CAAC,CAAC;IAErD,KAAK,MAAMC,EAAE,IAAIF,GAAG,EAAE;MAClBC,OAAO,CAACC,EAAE,CAAC,GAAG,CACV,MAAMJ,MAAM,CAACK,aAAa,CAAC;QACvBC,YAAY,EAAEV,kBAAkB,CAAC;UAC7BK,MAAM;UACNG;QACJ,CAAC,CAAC;QACFG,OAAO,EAAE;UACLC,UAAU,EAAE;QAChB;MACJ,CAAC,CAAC,EACJC,GAAG,CAACC,MAAM,IAAI;QACZ,OAAOA,MAAM,CAACC,IAAI;MACtB,CAAC,CAAC;IACN;IAEA,OAAOT,GAAG,CAACO,GAAG,CAACL,EAAE,IAAI;MACjB,OAAOD,OAAO,CAACC,EAAE,CAAC,IAAI,EAAE;IAC5B,CAAC,CAAC;EACN,CAAC,EACD;IACIQ,eAAe,EAAEf,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  import DataLoader from "dataloader";
2
- import { CmsStorageEntry } from "@webiny/api-headless-cms/types";
3
- import { 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>;
@@ -1,56 +1,46 @@
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 _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
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 => {
1
+ import DataLoader from "dataloader";
2
+ import { cleanupItems } from "@webiny/db-dynamodb/utils/cleanup.js";
3
+ import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
4
+ import { createLatestSortKey, createPartitionKey } from "../keys.js";
5
+ import { parseIdentifier } from "@webiny/utils";
6
+ export const createGetLatestRevisionByEntryId = params => {
15
7
  const {
16
8
  entity,
17
- locale,
18
9
  tenant
19
10
  } = 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)({
11
+ const latestKey = createLatestSortKey();
12
+ return new DataLoader(async ids => {
13
+ const reader = entity.createEntityReader();
14
+ const keys = new Set();
15
+ for (const id of ids) {
16
+ const partitionKey = createPartitionKey({
24
17
  tenant,
25
- locale,
26
18
  id
27
19
  });
28
- if (collection[partitionKey]) {
29
- return collection;
20
+ if (keys.has(partitionKey)) {
21
+ continue;
30
22
  }
31
- collection[partitionKey] = entity.getBatch({
23
+ keys.add(partitionKey);
24
+ reader.get({
32
25
  PK: partitionKey,
33
26
  SK: latestKey
34
27
  });
35
- return collection;
36
- }, {});
37
- const records = await (0, _batchRead.batchReadAll)({
38
- table: entity.table,
39
- items: Object.values(queries)
28
+ }
29
+ const records = await reader.execute();
30
+ const items = cleanupItems(entity.entity, records).map(item => {
31
+ return item.data;
40
32
  });
41
- const items = (0, _cleanup.cleanupItems)(entity, records);
42
33
  return ids.map(id => {
43
34
  const {
44
35
  id: entryId
45
- } = (0, _utils.parseIdentifier)(id);
36
+ } = parseIdentifier(id);
46
37
  return items.filter(item => {
47
38
  return entryId === item.entryId;
48
39
  });
49
40
  });
50
41
  }, {
51
- batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
42
+ batchScheduleFn: createBatchScheduleFn()
52
43
  });
53
44
  };
54
- exports.createGetLatestRevisionByEntryId = createGetLatestRevisionByEntryId;
55
45
 
56
46
  //# sourceMappingURL=getLatestRevisionByEntryId.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_dataloader","_interopRequireDefault","require","_batchRead","_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/utils/batchRead\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\nimport { createLatestSortKey, createPartitionKey } from \"~/operations/entry/keys\";\nimport { 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,UAAA,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,IAAK;EAC1E,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAEzC,MAAMI,SAAS,GAAG,IAAAC,yBAAmB,EAAC,CAAC;EAEvC,OAAO,IAAIC,mBAAU,CACjB,MAAOC,GAAsB,IAAK;IAC9B,MAAMC,OAAO,GAAGD,GAAG,CAACE,MAAM,CAAsB,CAACC,UAAU,EAAEC,EAAE,KAAK;MAChE,MAAMC,YAAY,GAAG,IAAAC,wBAAkB,EAAC;QACpCV,MAAM;QACND,MAAM;QACNS;MACJ,CAAC,CAAC;MACF,IAAID,UAAU,CAACE,YAAY,CAAC,EAAE;QAC1B,OAAOF,UAAU;MACrB;MACAA,UAAU,CAACE,YAAY,CAAC,GAAGX,MAAM,CAACa,QAAQ,CAAC;QACvCC,EAAE,EAAEH,YAAY;QAChBI,EAAE,EAAEZ;MACR,CAAC,CAAC;MACF,OAAOM,UAAU;IACrB,CAAC,EAAE,CAAC,CAAC,CAAC;IAEN,MAAMO,OAAO,GAAG,MAAM,IAAAC,uBAAY,EAAkB;MAChDC,KAAK,EAAElB,MAAM,CAACkB,KAAK;MACnBC,KAAK,EAAEC,MAAM,CAACC,MAAM,CAACd,OAAO;IAChC,CAAC,CAAC;IACF,MAAMY,KAAK,GAAG,IAAAG,qBAAY,EAACtB,MAAM,EAAEgB,OAAO,CAAC;IAE3C,OAAOV,GAAG,CAACiB,GAAG,CAACb,EAAE,IAAI;MACjB,MAAM;QAAEA,EAAE,EAAEc;MAAQ,CAAC,GAAG,IAAAC,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,gCAAA,GAAAA,gCAAA","ignoreList":[]}
1
+ {"version":3,"names":["DataLoader","cleanupItems","createBatchScheduleFn","createLatestSortKey","createPartitionKey","parseIdentifier","createGetLatestRevisionByEntryId","params","entity","tenant","latestKey","ids","reader","createEntityReader","keys","Set","id","partitionKey","has","add","get","PK","SK","records","execute","items","map","item","data","entryId","filter","batchScheduleFn"],"sources":["getLatestRevisionByEntryId.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup.js\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\nimport { createLatestSortKey, createPartitionKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\nexport const createGetLatestRevisionByEntryId = (params: IDataLoaderParams) => {\n const { entity, tenant } = params;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async ids => {\n const reader = entity.createEntityReader();\n\n const keys = new Set<string>();\n\n for (const id of ids) {\n const partitionKey = createPartitionKey({\n tenant,\n id\n });\n if (keys.has(partitionKey)) {\n continue;\n }\n keys.add(partitionKey);\n\n reader.get({\n PK: partitionKey,\n SK: latestKey\n });\n }\n\n const records = await reader.execute();\n const items = cleanupItems(entity.entity, records).map(item => {\n return item.data;\n });\n\n return ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return items.filter(item => {\n return entryId === item.entryId;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AACnC,SAASC,YAAY,QAAQ,sCAAsC;AAEnE,SAASC,qBAAqB;AAC9B,SAASC,mBAAmB,EAAEC,kBAAkB;AAEhD,SAASC,eAAe,QAAQ,eAAe;AAE/C,OAAO,MAAMC,gCAAgC,GAAIC,MAAyB,IAAK;EAC3E,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAEjC,MAAMG,SAAS,GAAGP,mBAAmB,CAAC,CAAC;EAEvC,OAAO,IAAIH,UAAU,CACjB,MAAMW,GAAG,IAAI;IACT,MAAMC,MAAM,GAAGJ,MAAM,CAACK,kBAAkB,CAAC,CAAC;IAE1C,MAAMC,IAAI,GAAG,IAAIC,GAAG,CAAS,CAAC;IAE9B,KAAK,MAAMC,EAAE,IAAIL,GAAG,EAAE;MAClB,MAAMM,YAAY,GAAGb,kBAAkB,CAAC;QACpCK,MAAM;QACNO;MACJ,CAAC,CAAC;MACF,IAAIF,IAAI,CAACI,GAAG,CAACD,YAAY,CAAC,EAAE;QACxB;MACJ;MACAH,IAAI,CAACK,GAAG,CAACF,YAAY,CAAC;MAEtBL,MAAM,CAACQ,GAAG,CAAC;QACPC,EAAE,EAAEJ,YAAY;QAChBK,EAAE,EAAEZ;MACR,CAAC,CAAC;IACN;IAEA,MAAMa,OAAO,GAAG,MAAMX,MAAM,CAACY,OAAO,CAAC,CAAC;IACtC,MAAMC,KAAK,GAAGxB,YAAY,CAACO,MAAM,CAACA,MAAM,EAAEe,OAAO,CAAC,CAACG,GAAG,CAACC,IAAI,IAAI;MAC3D,OAAOA,IAAI,CAACC,IAAI;IACpB,CAAC,CAAC;IAEF,OAAOjB,GAAG,CAACe,GAAG,CAACV,EAAE,IAAI;MACjB,MAAM;QAAEA,EAAE,EAAEa;MAAQ,CAAC,GAAGxB,eAAe,CAACW,EAAE,CAAC;MAC3C,OAAOS,KAAK,CAACK,MAAM,CAACH,IAAI,IAAI;QACxB,OAAOE,OAAO,KAAKF,IAAI,CAACE,OAAO;MACnC,CAAC,CAAC;IACN,CAAC,CAAC;EACN,CAAC,EACD;IACIE,eAAe,EAAE7B,qBAAqB,CAAC;EAC3C,CACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  import DataLoader from "dataloader";
2
- import { CmsStorageEntry } from "@webiny/api-headless-cms/types";
3
- import { DataLoaderParams } from "./types";
4
- export declare const createGetPublishedRevisionByEntryId: (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 createGetPublishedRevisionByEntryId: (params: IDataLoaderParams) => DataLoader<string, CmsStorageEntry<import("@webiny/api-headless-cms/types/types.js").CmsEntryValues>[], string>;
@@ -1,56 +1,46 @@
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 _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
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 => {
1
+ import DataLoader from "dataloader";
2
+ import { cleanupItems } from "@webiny/db-dynamodb/utils/cleanup.js";
3
+ import { createPartitionKey, createPublishedSortKey } from "../keys.js";
4
+ import { parseIdentifier } from "@webiny/utils";
5
+ import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
6
+ export const createGetPublishedRevisionByEntryId = params => {
15
7
  const {
16
8
  entity,
17
- locale,
18
9
  tenant
19
10
  } = 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)({
11
+ const publishedKey = createPublishedSortKey();
12
+ return new DataLoader(async ids => {
13
+ const reader = entity.createEntityReader();
14
+ const keys = new Set();
15
+ for (const id of ids) {
16
+ const partitionKey = createPartitionKey({
24
17
  tenant,
25
- locale,
26
18
  id
27
19
  });
28
- if (collection[partitionKey]) {
29
- return collection;
20
+ if (keys.has(partitionKey)) {
21
+ continue;
30
22
  }
31
- collection[partitionKey] = entity.getBatch({
23
+ keys.add(partitionKey);
24
+ reader.get({
32
25
  PK: partitionKey,
33
26
  SK: publishedKey
34
27
  });
35
- return collection;
36
- }, {});
37
- const records = await (0, _batchRead.batchReadAll)({
38
- table: entity.table,
39
- items: Object.values(queries)
28
+ }
29
+ const records = await reader.execute();
30
+ const items = cleanupItems(entity.entity, records).map(item => {
31
+ return item.data;
40
32
  });
41
- const items = (0, _cleanup.cleanupItems)(entity, records);
42
33
  return ids.map(id => {
43
34
  const {
44
35
  id: entryId
45
- } = (0, _utils.parseIdentifier)(id);
36
+ } = parseIdentifier(id);
46
37
  return items.filter(item => {
47
38
  return entryId === item.entryId;
48
39
  });
49
40
  });
50
41
  }, {
51
- batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
42
+ batchScheduleFn: createBatchScheduleFn()
52
43
  });
53
44
  };
54
- exports.createGetPublishedRevisionByEntryId = createGetPublishedRevisionByEntryId;
55
45
 
56
46
  //# sourceMappingURL=getPublishedRevisionByEntryId.js.map