@webiny/api-headless-cms-ddb 0.0.0-unstable.496cf268ac → 0.0.0-unstable.5387e5f7c8

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 (294) hide show
  1. package/README.md +6 -20
  2. package/abstractions/CmsDdbDataLoaders.d.ts +5 -0
  3. package/abstractions/CmsDdbDataLoaders.js +5 -0
  4. package/abstractions/CmsDdbDataLoaders.js.map +1 -0
  5. package/abstractions/CmsDdbEntryEntity.d.ts +5 -0
  6. package/abstractions/CmsDdbEntryEntity.js +5 -0
  7. package/abstractions/CmsDdbEntryEntity.js.map +1 -0
  8. package/abstractions/CmsDdbGroupEntity.d.ts +5 -0
  9. package/abstractions/CmsDdbGroupEntity.js +5 -0
  10. package/abstractions/CmsDdbGroupEntity.js.map +1 -0
  11. package/abstractions/CmsDdbModelEntity.d.ts +5 -0
  12. package/abstractions/CmsDdbModelEntity.js +5 -0
  13. package/abstractions/CmsDdbModelEntity.js.map +1 -0
  14. package/abstractions/CmsDdbTable.d.ts +5 -0
  15. package/abstractions/CmsDdbTable.js +5 -0
  16. package/abstractions/CmsDdbTable.js.map +1 -0
  17. package/definitions/entry.d.ts +4 -5
  18. package/definitions/entry.js +10 -93
  19. package/definitions/entry.js.map +1 -1
  20. package/definitions/group.d.ts +4 -5
  21. package/definitions/group.js +10 -64
  22. package/definitions/group.js.map +1 -1
  23. package/definitions/model.d.ts +4 -5
  24. package/definitions/model.js +10 -108
  25. package/definitions/model.js.map +1 -1
  26. package/definitions/table.d.ts +4 -6
  27. package/definitions/table.js +7 -26
  28. package/definitions/table.js.map +1 -1
  29. package/definitions/types.d.ts +65 -0
  30. package/definitions/types.js +0 -0
  31. package/index.d.ts +10 -3
  32. package/index.js +45 -129
  33. package/index.js.map +1 -1
  34. package/operations/entry/DdbCreateEntry.d.ts +16 -0
  35. package/operations/entry/DdbCreateEntry.js +77 -0
  36. package/operations/entry/DdbCreateEntry.js.map +1 -0
  37. package/operations/entry/DdbCreateEntryRevisionFrom.d.ts +16 -0
  38. package/operations/entry/DdbCreateEntryRevisionFrom.js +85 -0
  39. package/operations/entry/DdbCreateEntryRevisionFrom.js.map +1 -0
  40. package/operations/entry/DdbDeleteEntry.d.ts +16 -0
  41. package/operations/entry/DdbDeleteEntry.js +65 -0
  42. package/operations/entry/DdbDeleteEntry.js.map +1 -0
  43. package/operations/entry/DdbDeleteEntryRevision.d.ts +17 -0
  44. package/operations/entry/DdbDeleteEntryRevision.js +91 -0
  45. package/operations/entry/DdbDeleteEntryRevision.js.map +1 -0
  46. package/operations/entry/DdbDeleteMultipleEntries.d.ts +16 -0
  47. package/operations/entry/DdbDeleteMultipleEntries.js +59 -0
  48. package/operations/entry/DdbDeleteMultipleEntries.js.map +1 -0
  49. package/operations/entry/DdbGetEntriesByIds.d.ts +14 -0
  50. package/operations/entry/DdbGetEntriesByIds.js +31 -0
  51. package/operations/entry/DdbGetEntriesByIds.js.map +1 -0
  52. package/operations/entry/DdbGetEntry.d.ts +14 -0
  53. package/operations/entry/DdbGetEntry.js +27 -0
  54. package/operations/entry/DdbGetEntry.js.map +1 -0
  55. package/operations/entry/DdbGetLatestEntriesByIds.d.ts +14 -0
  56. package/operations/entry/DdbGetLatestEntriesByIds.js +31 -0
  57. package/operations/entry/DdbGetLatestEntriesByIds.js.map +1 -0
  58. package/operations/entry/DdbGetLatestRevisionByEntryId.d.ts +14 -0
  59. package/operations/entry/DdbGetLatestRevisionByEntryId.js +35 -0
  60. package/operations/entry/DdbGetLatestRevisionByEntryId.js.map +1 -0
  61. package/operations/entry/DdbGetPreviousRevision.d.ts +14 -0
  62. package/operations/entry/DdbGetPreviousRevision.js +53 -0
  63. package/operations/entry/DdbGetPreviousRevision.js.map +1 -0
  64. package/operations/entry/DdbGetPublishedEntriesByIds.d.ts +14 -0
  65. package/operations/entry/DdbGetPublishedEntriesByIds.js +31 -0
  66. package/operations/entry/DdbGetPublishedEntriesByIds.js.map +1 -0
  67. package/operations/entry/DdbGetPublishedRevisionByEntryId.d.ts +14 -0
  68. package/operations/entry/DdbGetPublishedRevisionByEntryId.js +35 -0
  69. package/operations/entry/DdbGetPublishedRevisionByEntryId.js.map +1 -0
  70. package/operations/entry/DdbGetRevisionById.d.ts +14 -0
  71. package/operations/entry/DdbGetRevisionById.js +34 -0
  72. package/operations/entry/DdbGetRevisionById.js.map +1 -0
  73. package/operations/entry/DdbGetRevisions.d.ts +14 -0
  74. package/operations/entry/DdbGetRevisions.js +33 -0
  75. package/operations/entry/DdbGetRevisions.js.map +1 -0
  76. package/operations/entry/DdbGetUniqueFieldValues.d.ts +12 -0
  77. package/operations/entry/DdbGetUniqueFieldValues.js +31 -0
  78. package/operations/entry/DdbGetUniqueFieldValues.js.map +1 -0
  79. package/operations/entry/DdbListEntries.d.ts +28 -0
  80. package/operations/entry/DdbListEntries.js +124 -0
  81. package/operations/entry/DdbListEntries.js.map +1 -0
  82. package/operations/entry/DdbMoveEntry.d.ts +14 -0
  83. package/operations/entry/DdbMoveEntry.js +57 -0
  84. package/operations/entry/DdbMoveEntry.js.map +1 -0
  85. package/operations/entry/DdbMoveToBin.d.ts +16 -0
  86. package/operations/entry/DdbMoveToBin.js +77 -0
  87. package/operations/entry/DdbMoveToBin.js.map +1 -0
  88. package/operations/entry/DdbPublishEntry.d.ts +18 -0
  89. package/operations/entry/DdbPublishEntry.js +162 -0
  90. package/operations/entry/DdbPublishEntry.js.map +1 -0
  91. package/operations/entry/DdbRestoreFromBin.d.ts +16 -0
  92. package/operations/entry/DdbRestoreFromBin.js +78 -0
  93. package/operations/entry/DdbRestoreFromBin.js.map +1 -0
  94. package/operations/entry/DdbUnpublishEntry.d.ts +17 -0
  95. package/operations/entry/DdbUnpublishEntry.js +112 -0
  96. package/operations/entry/DdbUnpublishEntry.js.map +1 -0
  97. package/operations/entry/DdbUpdateEntry.d.ts +17 -0
  98. package/operations/entry/DdbUpdateEntry.js +105 -0
  99. package/operations/entry/DdbUpdateEntry.js.map +1 -0
  100. package/operations/entry/dataLoader/DataLoaderCache.d.ts +16 -0
  101. package/operations/entry/dataLoader/DataLoaderCache.js +27 -0
  102. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -0
  103. package/operations/entry/dataLoader/constants.d.ts +1 -0
  104. package/operations/entry/dataLoader/constants.js +5 -0
  105. package/operations/entry/dataLoader/constants.js.map +1 -0
  106. package/operations/entry/dataLoader/createBatchScheduleFn.d.ts +8 -0
  107. package/operations/entry/dataLoader/createBatchScheduleFn.js +10 -0
  108. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -0
  109. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +4 -0
  110. package/operations/entry/dataLoader/getAllEntryRevisions.js +24 -0
  111. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -0
  112. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +4 -0
  113. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +40 -0
  114. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -0
  115. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +4 -0
  116. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +40 -0
  117. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -0
  118. package/operations/entry/dataLoader/getRevisionById.d.ts +4 -0
  119. package/operations/entry/dataLoader/getRevisionById.js +42 -0
  120. package/operations/entry/dataLoader/getRevisionById.js.map +1 -0
  121. package/operations/entry/dataLoader/index.d.ts +8 -0
  122. package/operations/entry/dataLoader/index.js +18 -0
  123. package/operations/entry/dataLoader/index.js.map +1 -0
  124. package/operations/entry/dataLoader/types.d.ts +6 -0
  125. package/operations/entry/dataLoader/types.js +0 -0
  126. package/operations/entry/dataLoaders.d.ts +16 -31
  127. package/operations/entry/dataLoaders.js +92 -272
  128. package/operations/entry/dataLoaders.js.map +1 -1
  129. package/operations/entry/feature.d.ts +4 -0
  130. package/operations/entry/feature.js +55 -0
  131. package/operations/entry/feature.js.map +1 -0
  132. package/operations/entry/keys.d.ts +46 -2
  133. package/operations/entry/keys.js +54 -49
  134. package/operations/entry/keys.js.map +1 -1
  135. package/operations/entry/storageEntryUtils.d.ts +8 -0
  136. package/operations/entry/storageEntryUtils.js +25 -0
  137. package/operations/entry/storageEntryUtils.js.map +1 -0
  138. package/operations/group/DdbCreateGroup.d.ts +12 -0
  139. package/operations/group/DdbCreateGroup.js +35 -0
  140. package/operations/group/DdbCreateGroup.js.map +1 -0
  141. package/operations/group/DdbDeleteGroup.d.ts +12 -0
  142. package/operations/group/DdbDeleteGroup.js +31 -0
  143. package/operations/group/DdbDeleteGroup.js.map +1 -0
  144. package/operations/group/DdbGetGroup.d.ts +12 -0
  145. package/operations/group/DdbGetGroup.js +31 -0
  146. package/operations/group/DdbGetGroup.js.map +1 -0
  147. package/operations/group/DdbListGroups.d.ts +14 -0
  148. package/operations/group/DdbListGroups.js +52 -0
  149. package/operations/group/DdbListGroups.js.map +1 -0
  150. package/operations/group/DdbUpdateGroup.d.ts +12 -0
  151. package/operations/group/DdbUpdateGroup.js +35 -0
  152. package/operations/group/DdbUpdateGroup.js.map +1 -0
  153. package/operations/group/feature.d.ts +4 -0
  154. package/operations/group/feature.js +19 -0
  155. package/operations/group/feature.js.map +1 -0
  156. package/operations/group/keys.d.ts +15 -0
  157. package/operations/group/keys.js +17 -0
  158. package/operations/group/keys.js.map +1 -0
  159. package/operations/model/DdbCreateModel.d.ts +12 -0
  160. package/operations/model/DdbCreateModel.js +37 -0
  161. package/operations/model/DdbCreateModel.js.map +1 -0
  162. package/operations/model/DdbDeleteModel.d.ts +12 -0
  163. package/operations/model/DdbDeleteModel.js +31 -0
  164. package/operations/model/DdbDeleteModel.js.map +1 -0
  165. package/operations/model/DdbGetModel.d.ts +12 -0
  166. package/operations/model/DdbGetModel.js +30 -0
  167. package/operations/model/DdbGetModel.js.map +1 -0
  168. package/operations/model/DdbListModels.d.ts +12 -0
  169. package/operations/model/DdbListModels.js +36 -0
  170. package/operations/model/DdbListModels.js.map +1 -0
  171. package/operations/model/DdbUpdateModel.d.ts +12 -0
  172. package/operations/model/DdbUpdateModel.js +36 -0
  173. package/operations/model/DdbUpdateModel.js.map +1 -0
  174. package/operations/model/feature.d.ts +4 -0
  175. package/operations/model/feature.js +19 -0
  176. package/operations/model/feature.js.map +1 -0
  177. package/operations/model/keys.d.ts +15 -0
  178. package/operations/model/keys.js +16 -0
  179. package/operations/model/keys.js.map +1 -0
  180. package/package.json +30 -33
  181. package/types.d.ts +12 -45
  182. package/types.js +8 -14
  183. package/types.js.map +1 -1
  184. package/definitions/settings.d.ts +0 -9
  185. package/definitions/settings.js +0 -53
  186. package/definitions/settings.js.map +0 -1
  187. package/definitions/system.d.ts +0 -9
  188. package/definitions/system.js +0 -41
  189. package/definitions/system.js.map +0 -1
  190. package/dynamoDb/index.d.ts +0 -2
  191. package/dynamoDb/index.js +0 -13
  192. package/dynamoDb/index.js.map +0 -1
  193. package/dynamoDb/path/plainObject.d.ts +0 -2
  194. package/dynamoDb/path/plainObject.js +0 -33
  195. package/dynamoDb/path/plainObject.js.map +0 -1
  196. package/dynamoDb/storage/date.d.ts +0 -3
  197. package/dynamoDb/storage/date.js +0 -91
  198. package/dynamoDb/storage/date.js.map +0 -1
  199. package/dynamoDb/storage/longText.d.ts +0 -10
  200. package/dynamoDb/storage/longText.js +0 -91
  201. package/dynamoDb/storage/longText.js.map +0 -1
  202. package/dynamoDb/storage/richText.d.ts +0 -2
  203. package/dynamoDb/storage/richText.js +0 -95
  204. package/dynamoDb/storage/richText.js.map +0 -1
  205. package/dynamoDb/transformValue/datetime.d.ts +0 -5
  206. package/dynamoDb/transformValue/datetime.js +0 -45
  207. package/dynamoDb/transformValue/datetime.js.map +0 -1
  208. package/operations/entry/filtering/createExpressions.d.ts +0 -26
  209. package/operations/entry/filtering/createExpressions.js +0 -176
  210. package/operations/entry/filtering/createExpressions.js.map +0 -1
  211. package/operations/entry/filtering/createFields.d.ts +0 -14
  212. package/operations/entry/filtering/createFields.js +0 -105
  213. package/operations/entry/filtering/createFields.js.map +0 -1
  214. package/operations/entry/filtering/extractSort.d.ts +0 -17
  215. package/operations/entry/filtering/extractSort.js +0 -67
  216. package/operations/entry/filtering/extractSort.js.map +0 -1
  217. package/operations/entry/filtering/filter.d.ts +0 -15
  218. package/operations/entry/filtering/filter.js +0 -143
  219. package/operations/entry/filtering/filter.js.map +0 -1
  220. package/operations/entry/filtering/fullTextSearch.d.ts +0 -14
  221. package/operations/entry/filtering/fullTextSearch.js +0 -48
  222. package/operations/entry/filtering/fullTextSearch.js.map +0 -1
  223. package/operations/entry/filtering/getValue.d.ts +0 -5
  224. package/operations/entry/filtering/getValue.js +0 -63
  225. package/operations/entry/filtering/getValue.js.map +0 -1
  226. package/operations/entry/filtering/index.d.ts +0 -2
  227. package/operations/entry/filtering/index.js +0 -19
  228. package/operations/entry/filtering/index.js.map +0 -1
  229. package/operations/entry/filtering/mapPlugins.d.ts +0 -8
  230. package/operations/entry/filtering/mapPlugins.js +0 -31
  231. package/operations/entry/filtering/mapPlugins.js.map +0 -1
  232. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +0 -2
  233. package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -41
  234. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +0 -1
  235. package/operations/entry/filtering/plugins/index.d.ts +0 -1
  236. package/operations/entry/filtering/plugins/index.js +0 -13
  237. package/operations/entry/filtering/plugins/index.js.map +0 -1
  238. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +0 -2
  239. package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -86
  240. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +0 -1
  241. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +0 -2
  242. package/operations/entry/filtering/plugins/refFilterCreate.js +0 -71
  243. package/operations/entry/filtering/plugins/refFilterCreate.js.map +0 -1
  244. package/operations/entry/filtering/sort.d.ts +0 -12
  245. package/operations/entry/filtering/sort.js +0 -69
  246. package/operations/entry/filtering/sort.js.map +0 -1
  247. package/operations/entry/filtering/systemFields.d.ts +0 -4
  248. package/operations/entry/filtering/systemFields.js +0 -70
  249. package/operations/entry/filtering/systemFields.js.map +0 -1
  250. package/operations/entry/filtering/transform.d.ts +0 -6
  251. package/operations/entry/filtering/transform.js +0 -16
  252. package/operations/entry/filtering/transform.js.map +0 -1
  253. package/operations/entry/filtering/types.d.ts +0 -40
  254. package/operations/entry/filtering/types.js +0 -5
  255. package/operations/entry/filtering/types.js.map +0 -1
  256. package/operations/entry/filtering/values.d.ts +0 -2
  257. package/operations/entry/filtering/values.js +0 -22
  258. package/operations/entry/filtering/values.js.map +0 -1
  259. package/operations/entry/filtering/where.d.ts +0 -5
  260. package/operations/entry/filtering/where.js +0 -32
  261. package/operations/entry/filtering/where.js.map +0 -1
  262. package/operations/entry/index.d.ts +0 -8
  263. package/operations/entry/index.js +0 -787
  264. package/operations/entry/index.js.map +0 -1
  265. package/operations/entry/systemFields.d.ts +0 -2
  266. package/operations/entry/systemFields.js +0 -72
  267. package/operations/entry/systemFields.js.map +0 -1
  268. package/operations/group/index.d.ts +0 -9
  269. package/operations/group/index.js +0 -162
  270. package/operations/group/index.js.map +0 -1
  271. package/operations/model/index.d.ts +0 -7
  272. package/operations/model/index.js +0 -137
  273. package/operations/model/index.js.map +0 -1
  274. package/operations/settings/index.d.ts +0 -7
  275. package/operations/settings/index.js +0 -111
  276. package/operations/settings/index.js.map +0 -1
  277. package/operations/system/index.d.ts +0 -7
  278. package/operations/system/index.js +0 -82
  279. package/operations/system/index.js.map +0 -1
  280. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +0 -22
  281. package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -41
  282. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +0 -1
  283. package/plugins/CmsEntryFieldFilterPlugin.d.ts +0 -43
  284. package/plugins/CmsEntryFieldFilterPlugin.js +0 -24
  285. package/plugins/CmsEntryFieldFilterPlugin.js.map +0 -1
  286. package/plugins/CmsEntryFieldSortingPlugin.d.ts +0 -42
  287. package/plugins/CmsEntryFieldSortingPlugin.js +0 -28
  288. package/plugins/CmsEntryFieldSortingPlugin.js.map +0 -1
  289. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +0 -11
  290. package/plugins/CmsFieldFilterValueTransformPlugin.js +0 -24
  291. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +0 -1
  292. package/plugins/index.d.ts +0 -4
  293. package/plugins/index.js +0 -49
  294. package/plugins/index.js.map +0 -1
@@ -1,278 +1,98 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.DataLoadersHandler = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _dataloader = _interopRequireDefault(require("dataloader"));
11
- var _error = _interopRequireDefault(require("@webiny/error"));
12
- var _query = require("@webiny/db-dynamodb/utils/query");
13
- var _keys = require("./keys");
14
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
15
- var _utils = require("@webiny/utils");
16
- var _batchRead = require("@webiny/db-dynamodb/utils/batchRead");
17
- const getAllEntryRevisions = params => {
18
- const {
19
- entity,
20
- model
21
- } = params;
22
- const {
23
- tenant,
24
- locale
25
- } = model;
26
- return new _dataloader.default(async ids => {
27
- const results = {};
28
- for (const id of ids) {
29
- const queryAllParams = {
30
- entity,
31
- partitionKey: (0, _keys.createPartitionKey)({
32
- tenant,
33
- locale,
34
- id
35
- }),
36
- options: {
37
- beginsWith: "REV#"
38
- }
39
- };
40
- const items = await (0, _query.queryAll)(queryAllParams);
41
- results[id] = (0, _cleanup.cleanupItems)(entity, items);
1
+ import error from "@webiny/error";
2
+ import { DataLoaderCache } from "./dataLoader/DataLoaderCache.js";
3
+ import { getDataLoaderFactory } from "./dataLoader/index.js";
4
+ import { parseIdentifier } from "@webiny/utils";
5
+ import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
6
+ import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
7
+ class DataLoadersHandlerImpl {
8
+ constructor(entity){
9
+ this.entity = entity;
10
+ this.cache = new DataLoaderCache();
42
11
  }
43
- return ids.map(id => {
44
- return results[id] || [];
45
- });
46
- });
47
- };
48
- const getRevisionById = params => {
49
- const {
50
- entity,
51
- model
52
- } = params;
53
- const {
54
- locale,
55
- tenant
56
- } = model;
57
- return new _dataloader.default(async ids => {
58
- const queries = ids.reduce((collection, id) => {
59
- const partitionKey = (0, _keys.createPartitionKey)({
60
- tenant,
61
- locale,
62
- id
63
- });
64
- const {
65
- version
66
- } = (0, _utils.parseIdentifier)(id);
67
- if (version === null) {
68
- return collection;
69
- }
70
- const sortKey = (0, _keys.createRevisionSortKey)({
71
- version
72
- });
73
- const keys = `${partitionKey}__${sortKey}`;
74
- if (collection[keys]) {
75
- return collection;
76
- }
77
- collection[keys] = entity.getBatch({
78
- PK: partitionKey,
79
- SK: sortKey
80
- });
81
- return collection;
82
- /**
83
- * We cast as any because there is no return type defined.
84
- */
85
- }, {});
86
- const records = await (0, _batchRead.batchReadAll)({
87
- table: entity.table,
88
- items: Object.values(queries)
89
- });
90
- const items = (0, _cleanup.cleanupItems)(entity, records);
91
- return ids.map(id => {
92
- return items.filter(item => {
93
- return id === item.id;
94
- });
95
- });
96
- });
97
- };
98
- const getPublishedRevisionByEntryId = params => {
99
- const {
100
- entity,
101
- model
102
- } = params;
103
- const {
104
- locale,
105
- tenant
106
- } = model;
107
- const publishedKey = (0, _keys.createPublishedSortKey)();
108
- return new _dataloader.default(async ids => {
109
- const queries = ids.reduce((collection, id) => {
110
- const partitionKey = (0, _keys.createPartitionKey)({
111
- tenant,
112
- locale,
113
- id
114
- });
115
- if (collection[partitionKey]) {
116
- return collection;
117
- }
118
- collection[partitionKey] = entity.getBatch({
119
- PK: partitionKey,
120
- SK: publishedKey
121
- });
122
- return collection;
123
- /**
124
- * We cast as any because there is no return type defined.
125
- */
126
- }, {});
127
- const records = await (0, _batchRead.batchReadAll)({
128
- table: entity.table,
129
- items: Object.values(queries)
130
- });
131
- const items = (0, _cleanup.cleanupItems)(entity, records);
132
- return ids.map(id => {
133
- const {
134
- id: entryId
135
- } = (0, _utils.parseIdentifier)(id);
136
- return items.filter(item => {
137
- return entryId === item.entryId;
138
- });
139
- });
140
- });
141
- };
142
- const getLatestRevisionByEntryId = params => {
143
- const {
144
- entity,
145
- model
146
- } = params;
147
- const {
148
- locale,
149
- tenant
150
- } = model;
151
- const latestKey = (0, _keys.createLatestSortKey)();
152
- return new _dataloader.default(async ids => {
153
- const queries = ids.reduce((collection, id) => {
154
- const partitionKey = (0, _keys.createPartitionKey)({
155
- tenant,
156
- locale,
157
- id
158
- });
159
- if (collection[partitionKey]) {
160
- return collection;
161
- }
162
- collection[partitionKey] = entity.getBatch({
163
- PK: partitionKey,
164
- SK: latestKey
165
- });
166
- return collection;
167
- /**
168
- * We cast as any because there is no return type defined.
169
- */
170
- }, {});
171
- const records = await (0, _batchRead.batchReadAll)({
172
- table: entity.table,
173
- items: Object.values(queries)
174
- });
175
- const items = (0, _cleanup.cleanupItems)(entity, records);
176
- return ids.map(id => {
177
- const {
178
- id: entryId
179
- } = (0, _utils.parseIdentifier)(id);
180
- return items.filter(item => {
181
- return entryId === item.entryId;
182
- });
183
- });
184
- });
185
- };
186
- const dataLoaders = {
187
- getAllEntryRevisions,
188
- getRevisionById,
189
- getPublishedRevisionByEntryId,
190
- getLatestRevisionByEntryId
191
- };
192
- const loaderNames = Object.keys(dataLoaders);
193
- class DataLoadersHandler {
194
- constructor(params) {
195
- (0, _defineProperty2.default)(this, "loaders", new Map());
196
- (0, _defineProperty2.default)(this, "entity", void 0);
197
- this.entity = params.entity;
198
- }
199
- async getAllEntryRevisions(params) {
200
- return await this.loadMany("getAllEntryRevisions", params, params.ids);
201
- }
202
- async getRevisionById(params) {
203
- return await this.loadMany("getRevisionById", params, params.ids);
204
- }
205
- async getPublishedRevisionByEntryId(params) {
206
- return await this.loadMany("getPublishedRevisionByEntryId", params, params.ids);
207
- }
208
- async getLatestRevisionByEntryId(params) {
209
- return await this.loadMany("getLatestRevisionByEntryId", params, params.ids);
210
- }
211
-
212
- /**
213
- * TODO @ts-refactor
214
- * Maybe pass on the generics to DataLoader definition?
215
- */
216
- getLoader(name, params) {
217
- if (!dataLoaders[name]) {
218
- throw new _error.default("Unknown data loader.", "UNKNOWN_DATA_LOADER", {
219
- name
220
- });
12
+ async getAllEntryRevisions(params) {
13
+ const ids = params.ids.map((id)=>{
14
+ const { id: entryId } = parseIdentifier(id);
15
+ return entryId;
16
+ });
17
+ return await this.loadMany("getAllEntryRevisions", params, ids);
18
+ }
19
+ async getRevisionById(params) {
20
+ return await this.loadMany("getRevisionById", params, params.ids);
221
21
  }
222
- const {
223
- model
224
- } = params;
225
- const {
226
- tenant,
227
- locale
228
- } = model;
229
- const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;
230
- if (!this.loaders.has(loaderKey)) {
231
- this.loaders.set(loaderKey, dataLoaders[name]((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
232
- entity: this.entity
233
- })));
22
+ async getPublishedRevisionByEntryId(params) {
23
+ const ids = params.ids.map((id)=>{
24
+ const { id: entryId } = parseIdentifier(id);
25
+ return entryId;
26
+ });
27
+ return await this.loadMany("getPublishedRevisionByEntryId", params, ids);
234
28
  }
235
- return this.loaders.get(loaderKey);
236
- }
237
- async loadMany(loader, params, ids) {
238
- let results;
239
- try {
240
- results = await this.getLoader(loader, params).loadMany(ids);
241
- if (Array.isArray(results) === true) {
242
- return results.reduce((acc, res) => {
243
- if (Array.isArray(res) === false) {
244
- if (res && res.message) {
245
- throw new _error.default(res.message, res.code, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, res), {}, {
246
- data: JSON.stringify(res.data || {})
247
- }));
248
- }
249
- throw new _error.default("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
250
- loader
251
- }));
252
- }
253
- acc.push(...res);
254
- return acc;
255
- }, []);
256
- }
257
- } catch (ex) {
258
- throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", (0, _objectSpread2.default)((0, _objectSpread2.default)({
259
- error: ex
260
- }, params), {}, {
261
- loader,
262
- ids
263
- }));
29
+ async getLatestRevisionByEntryId(params) {
30
+ const ids = params.ids.map((id)=>{
31
+ const { id: entryId } = parseIdentifier(id);
32
+ return entryId;
33
+ });
34
+ return await this.loadMany("getLatestRevisionByEntryId", params, ids);
264
35
  }
265
- throw new _error.default(`Data loader did not return array of items or empty array.`, "INVALID_DATA_LOADER_RESULT", {
266
- loader,
267
- ids,
268
- results
269
- });
270
- }
271
- clearAll(params) {
272
- for (const name of loaderNames) {
273
- const loader = this.getLoader(name, params);
274
- loader.clearAll();
36
+ getLoader(name, params) {
37
+ const { model } = params;
38
+ const cacheParams = {
39
+ tenant: model.tenant,
40
+ modelId: model.modelId,
41
+ name
42
+ };
43
+ let loader = this.cache.getDataLoader(cacheParams);
44
+ if (loader) return loader;
45
+ const factory = getDataLoaderFactory(name);
46
+ loader = factory({
47
+ entity: this.entity,
48
+ tenant: model.tenant,
49
+ modelId: model.modelId
50
+ });
51
+ this.cache.setDataLoader(cacheParams, loader);
52
+ return loader;
53
+ }
54
+ async loadMany(loader, params, ids) {
55
+ let results = [];
56
+ try {
57
+ results = await this.getLoader(loader, params).loadMany(ids);
58
+ if (true === Array.isArray(results)) return results.reduce((acc, res)=>{
59
+ if (false === Array.isArray(res)) {
60
+ if (res && res.message) throw new error(res.message, res.code, {
61
+ ...res,
62
+ data: JSON.stringify(res.data || {})
63
+ });
64
+ throw new error("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", {
65
+ ...params,
66
+ loader
67
+ });
68
+ }
69
+ acc.push(...res);
70
+ return acc;
71
+ }, []);
72
+ } catch (ex) {
73
+ throw new error(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", {
74
+ error: ex,
75
+ ...params,
76
+ loader,
77
+ ids
78
+ });
79
+ }
80
+ throw new error("Data loader did not return array of items or empty array.", "INVALID_DATA_LOADER_RESULT", {
81
+ loader,
82
+ ids,
83
+ results
84
+ });
85
+ }
86
+ clearAll(params) {
87
+ this.cache.clearAll(params);
275
88
  }
276
- }
277
89
  }
278
- exports.DataLoadersHandler = DataLoadersHandler;
90
+ const DataLoadersHandler = CmsDdbDataLoaders.createImplementation({
91
+ implementation: DataLoadersHandlerImpl,
92
+ dependencies: [
93
+ CmsDdbEntryEntity
94
+ ]
95
+ });
96
+ export { DataLoadersHandler };
97
+
98
+ //# sourceMappingURL=dataLoaders.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getAllEntryRevisions","params","entity","model","tenant","locale","DataLoader","ids","results","id","queryAllParams","partitionKey","createPartitionKey","options","beginsWith","items","queryAll","cleanupItems","map","getRevisionById","queries","reduce","collection","version","parseIdentifier","sortKey","createRevisionSortKey","keys","getBatch","PK","SK","records","batchReadAll","table","Object","values","filter","item","getPublishedRevisionByEntryId","publishedKey","createPublishedSortKey","entryId","getLatestRevisionByEntryId","latestKey","createLatestSortKey","dataLoaders","loaderNames","DataLoadersHandler","constructor","Map","loadMany","getLoader","name","WebinyError","loaderKey","modelId","loaders","has","set","get","loader","Array","isArray","acc","res","message","code","data","JSON","stringify","push","ex","error","clearAll"],"sources":["dataLoaders.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { CmsStorageEntry, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\nimport { Entity } from \"dynamodb-toolbox\";\nimport { queryAll, QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport {\n createLatestSortKey,\n createPartitionKey,\n createPublishedSortKey,\n createRevisionSortKey\n} from \"./keys\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { batchReadAll } from \"@webiny/db-dynamodb/utils/batchRead\";\n\nconst getAllEntryRevisions = (params: LoaderParams) => {\n const { entity, model } = params;\n const { tenant, locale } = model;\n return new DataLoader<string, CmsStorageEntry[]>(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\nconst getRevisionById = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n return new DataLoader<string, CmsStorageEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((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 * We cast as any because there is no return type defined.\n */\n }, {} as Record<string, any>);\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\nconst getPublishedRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const publishedKey = createPublishedSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((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 * We cast as any because there is no return type defined.\n */\n }, {} as Record<string, any>);\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\nconst getLatestRevisionByEntryId = (params: LoaderParams) => {\n const { entity, model } = params;\n const { locale, tenant } = model;\n\n const latestKey = createLatestSortKey();\n\n return new DataLoader<string, CmsStorageEntry[]>(async (ids: readonly string[]) => {\n const queries = ids.reduce((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 * We cast as any because there is no return type defined.\n */\n }, {} as Record<string, any>);\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\nconst dataLoaders: Record<Loaders, any> = {\n getAllEntryRevisions,\n getRevisionById,\n getPublishedRevisionByEntryId,\n getLatestRevisionByEntryId\n};\n\nexport interface GetAllEntryRevisionsParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetRevisionByIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetPublishedRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\nexport interface GetLatestRevisionByEntryIdParams {\n ids: readonly string[];\n model: CmsModel;\n}\n\ninterface LoaderParams {\n entity: Entity<any>;\n model: CmsModel;\n}\n\ninterface GetLoaderParams {\n model: CmsModel;\n}\n\ninterface ClearLoaderParams {\n model: CmsModel;\n entry?: CmsStorageEntry;\n}\n\ntype Loaders =\n | \"getAllEntryRevisions\"\n | \"getRevisionById\"\n | \"getPublishedRevisionByEntryId\"\n | \"getLatestRevisionByEntryId\";\n\nconst loaderNames = Object.keys(dataLoaders) as Loaders[];\n\ninterface DataLoadersHandlerParams {\n entity: Entity<any>;\n}\nexport class DataLoadersHandler {\n private readonly loaders: Map<string, DataLoader<any, any>> = new Map();\n private readonly entity: Entity<any>;\n\n public constructor(params: DataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions(\n params: GetAllEntryRevisionsParams\n ): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getAllEntryRevisions\", params, params.ids);\n }\n\n public async getRevisionById(params: GetRevisionByIdParams): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId(\n params: GetPublishedRevisionByEntryIdParams\n ): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getPublishedRevisionByEntryId\", params, params.ids);\n }\n\n public async getLatestRevisionByEntryId(\n params: GetLatestRevisionByEntryIdParams\n ): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getLatestRevisionByEntryId\", params, params.ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: Loaders, params: GetLoaderParams): DataLoader<any, any> {\n if (!dataLoaders[name]) {\n throw new WebinyError(\"Unknown data loader.\", \"UNKNOWN_DATA_LOADER\", {\n name\n });\n }\n const { model } = params;\n const { tenant, locale } = model;\n const loaderKey = `${name}-${tenant}-${locale}-${model.modelId}`;\n if (!this.loaders.has(loaderKey)) {\n this.loaders.set(\n loaderKey,\n dataLoaders[name]({\n ...params,\n entity: this.entity\n })\n );\n }\n return this.loaders.get(loaderKey) as DataLoader<any, any>;\n }\n\n private async loadMany(\n loader: Loaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry[]> {\n let results;\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params: Omit<ClearLoaderParams, \"entry\">): void {\n for (const name of loaderNames) {\n const loader = this.getLoader(name, params);\n loader.clearAll();\n }\n }\n}\n"],"mappings":";;;;;;;;;AAAA;AAEA;AAEA;AACA;AAMA;AACA;AACA;AAEA,MAAMA,oBAAoB,GAAIC,MAAoB,IAAK;EACnD,MAAM;IAAEC,MAAM;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAChC,MAAM;IAAEG,MAAM;IAAEC;EAAO,CAAC,GAAGF,KAAK;EAChC,OAAO,IAAIG,mBAAU,CAA4B,MAAOC,GAAsB,IAAK;IAC/E,MAAMC,OAA0C,GAAG,CAAC,CAAC;IACrD,KAAK,MAAMC,EAAE,IAAIF,GAAG,EAAE;MAClB,MAAMG,cAA8B,GAAG;QACnCR,MAAM;QACNS,YAAY,EAAE,IAAAC,wBAAkB,EAAC;UAC7BR,MAAM;UACNC,MAAM;UACNI;QACJ,CAAC,CAAC;QACFI,OAAO,EAAE;UACLC,UAAU,EAAE;QAChB;MACJ,CAAC;MACD,MAAMC,KAAK,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O,CAACE,GAAG,CAAC,KAAK,KAAK,EAAE;YAC9B,IAAIA,GAAG,IAAIA,GAAG,CAACC,OAAO,EAAE;cACpB,MAAM,IAAIZ,cAAW,CAACW,GAAG,CAACC,OAAO,EAAED,GAAG,CAACE,IAAI,8DACpCF,GAAG;gBACNG,IAAI,EAAEC,IAAI,CAACC,SAAS,CAACL,GAAG,CAACG,IAAI,IAAI,CAAC,CAAC;cAAC,GACtC;YACN;YACA,MAAM,IAAId,cAAW,CACjB,uFAAuF,EACvF,2BAA2B,8DAEpBpD,MAAM;cACT2D;YAAM,GAEb;UACL;UACAG,GAAG,CAACO,IAAI,CAAC,GAAGN,GAAG,CAAC;UAChB,OAAOD,GAAG;QACd,CAAC,EAAE,EAAE,CAAC;MACV;IACJ,CAAC,CAAC,OAAOQ,EAAE,EAAE;MACT,MAAM,IAAIlB,cAAW,CACjBkB,EAAE,CAACN,OAAO,IAAI,oBAAoB,EAClCM,EAAE,CAACL,IAAI,IAAI,mBAAmB;QAE1BM,KAAK,EAAED;MAAE,GACNtE,MAAM;QACT2D,MAAM;QACNrD;MAAG,GAEV;IACL;IACA,MAAM,IAAI8C,cAAW,CAChB,2DAA0D,EAC3D,4BAA4B,EAC5B;MACIO,MAAM;MACNrD,GAAG;MACHC;IACJ,CAAC,CACJ;EACL;EAEOiE,QAAQ,CAACxE,MAAwC,EAAQ;IAC5D,KAAK,MAAMmD,IAAI,IAAIN,WAAW,EAAE;MAC5B,MAAMc,MAAM,GAAG,IAAI,CAACT,SAAS,CAACC,IAAI,EAAEnD,MAAM,CAAC;MAC3C2D,MAAM,CAACa,QAAQ,EAAE;IACrB;EACJ;AACJ;AAAC"}
1
+ {"version":3,"file":"operations/entry/dataLoaders.js","sources":["../../../src/operations/entry/dataLoaders.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport type {\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CacheKeyParams } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport { DataLoaderCache } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport type { DataLoaders } from \"~/operations/entry/dataLoader/index.js\";\nimport { getDataLoaderFactory } from \"~/operations/entry/dataLoader/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport type { DataLoadersHandlerInterfaceClearAllParams, IDataLoadersHandler } from \"~/types.js\";\nimport { CmsDdbEntryEntity } from \"~/abstractions/CmsDdbEntryEntity.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\n\ninterface DataLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n ids: readonly string[];\n}\n\ninterface GetLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\nclass DataLoadersHandlerImpl implements IDataLoadersHandler {\n private readonly cache = new DataLoaderCache();\n\n public constructor(private readonly entity: CmsDdbEntryEntity.Interface) {}\n\n public async getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getAllEntryRevisions\", params, ids);\n }\n\n public async getRevisionById<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n return await this.loadMany<T>(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getPublishedRevisionByEntryId\", params, ids);\n }\n\n public async getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getLatestRevisionByEntryId\", params, ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: DataLoaders, params: GetLoaderParams): DataLoader<any, any> {\n const { model } = params;\n const cacheParams: CacheKeyParams = {\n tenant: model.tenant,\n modelId: model.modelId,\n name\n };\n let loader = this.cache.getDataLoader(cacheParams);\n if (loader) {\n return loader;\n }\n const factory = getDataLoaderFactory(name);\n loader = factory({\n entity: this.entity,\n tenant: model.tenant,\n modelId: model.modelId\n });\n this.cache.setDataLoader(cacheParams, loader);\n return loader;\n }\n\n private async loadMany<T extends CmsEntryValues = CmsEntryValues>(\n loader: DataLoaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry<T>[]> {\n let results: any[] = [];\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void {\n this.cache.clearAll(params);\n }\n}\n\nexport const DataLoadersHandler = CmsDdbDataLoaders.createImplementation({\n implementation: DataLoadersHandlerImpl,\n dependencies: [CmsDdbEntryEntity]\n});\n"],"names":["DataLoadersHandlerImpl","entity","DataLoaderCache","params","ids","id","entryId","parseIdentifier","name","model","cacheParams","loader","factory","getDataLoaderFactory","results","Array","acc","res","WebinyError","JSON","ex","DataLoadersHandler","CmsDdbDataLoaders","CmsDdbEntryEntity"],"mappings":";;;;;;AAyBA,MAAMA;IAGF,YAAoCC,MAAmC,CAAE;aAArCA,MAAM,GAANA;aAFnB,KAAK,GAAG,IAAIC;IAE6C;IAE1E,MAAa,qBACTC,MAAwB,EACK;QAC7B,MAAMC,MAAMD,OAAO,GAAG,CAAC,GAAG,CAACE,CAAAA;YACvB,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBF;YACxC,OAAOC;QACX;QACA,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,wBAAwBH,QAAQC;IAClE;IAEA,MAAa,gBACTD,MAAwB,EACK;QAC7B,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,mBAAmBA,QAAQA,OAAO,GAAG;IACvE;IAEA,MAAa,8BACTA,MAAwB,EACK;QAC7B,MAAMC,MAAMD,OAAO,GAAG,CAAC,GAAG,CAACE,CAAAA;YACvB,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBF;YACxC,OAAOC;QACX;QACA,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,iCAAiCH,QAAQC;IAC3E;IAEA,MAAa,2BACTD,MAAwB,EACK;QAC7B,MAAMC,MAAMD,OAAO,GAAG,CAAC,GAAG,CAACE,CAAAA;YACvB,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBF;YACxC,OAAOC;QACX;QACA,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,8BAA8BH,QAAQC;IACxE;IAMQ,UAAUI,IAAiB,EAAEL,MAAuB,EAAwB;QAChF,MAAM,EAAEM,KAAK,EAAE,GAAGN;QAClB,MAAMO,cAA8B;YAChC,QAAQD,MAAM,MAAM;YACpB,SAASA,MAAM,OAAO;YACtB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O,MAAMkB,qBAAqBC,kBAAkB,oBAAoB,CAAC;IACrE,gBAAgBtB;IAChB,cAAc;QAACuB;KAAkB;AACrC"}
@@ -0,0 +1,4 @@
1
+ export declare const DdbEntryStorageOpsFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,55 @@
1
+ import { createFeature } from "@webiny/feature/api/index.js";
2
+ import { DataLoadersHandler } from "./dataLoaders.js";
3
+ import { DdbCreateEntry } from "./DdbCreateEntry.js";
4
+ import { DdbCreateEntryRevisionFrom } from "./DdbCreateEntryRevisionFrom.js";
5
+ import { DdbUpdateEntry } from "./DdbUpdateEntry.js";
6
+ import { DdbMoveEntry } from "./DdbMoveEntry.js";
7
+ import { DdbMoveToBin } from "./DdbMoveToBin.js";
8
+ import { DdbDeleteEntry } from "./DdbDeleteEntry.js";
9
+ import { DdbRestoreFromBin } from "./DdbRestoreFromBin.js";
10
+ import { DdbDeleteEntryRevision } from "./DdbDeleteEntryRevision.js";
11
+ import { DdbDeleteMultipleEntries } from "./DdbDeleteMultipleEntries.js";
12
+ import { DdbGetEntry } from "./DdbGetEntry.js";
13
+ import { DdbListEntries } from "./DdbListEntries.js";
14
+ import { DdbPublishEntry } from "./DdbPublishEntry.js";
15
+ import { DdbUnpublishEntry } from "./DdbUnpublishEntry.js";
16
+ import { DdbGetEntriesByIds } from "./DdbGetEntriesByIds.js";
17
+ import { DdbGetLatestEntriesByIds } from "./DdbGetLatestEntriesByIds.js";
18
+ import { DdbGetPublishedEntriesByIds } from "./DdbGetPublishedEntriesByIds.js";
19
+ import { DdbGetRevisions } from "./DdbGetRevisions.js";
20
+ import { DdbGetRevisionById } from "./DdbGetRevisionById.js";
21
+ import { DdbGetLatestRevisionByEntryId } from "./DdbGetLatestRevisionByEntryId.js";
22
+ import { DdbGetPublishedRevisionByEntryId } from "./DdbGetPublishedRevisionByEntryId.js";
23
+ import { DdbGetPreviousRevision } from "./DdbGetPreviousRevision.js";
24
+ import { DdbGetUniqueFieldValues } from "./DdbGetUniqueFieldValues.js";
25
+ const DdbEntryStorageOpsFeature = createFeature({
26
+ name: "cms.ddb.entryStorageOps",
27
+ register: (container)=>{
28
+ container.register(DataLoadersHandler).inContainerScope();
29
+ container.register(DdbCreateEntry);
30
+ container.register(DdbCreateEntryRevisionFrom);
31
+ container.register(DdbUpdateEntry);
32
+ container.register(DdbMoveEntry);
33
+ container.register(DdbMoveToBin);
34
+ container.register(DdbDeleteEntry);
35
+ container.register(DdbRestoreFromBin);
36
+ container.register(DdbDeleteEntryRevision);
37
+ container.register(DdbDeleteMultipleEntries);
38
+ container.register(DdbGetEntry);
39
+ container.register(DdbListEntries);
40
+ container.register(DdbPublishEntry);
41
+ container.register(DdbUnpublishEntry);
42
+ container.register(DdbGetEntriesByIds);
43
+ container.register(DdbGetLatestEntriesByIds);
44
+ container.register(DdbGetPublishedEntriesByIds);
45
+ container.register(DdbGetRevisions);
46
+ container.register(DdbGetRevisionById);
47
+ container.register(DdbGetLatestRevisionByEntryId);
48
+ container.register(DdbGetPublishedRevisionByEntryId);
49
+ container.register(DdbGetPreviousRevision);
50
+ container.register(DdbGetUniqueFieldValues);
51
+ }
52
+ });
53
+ export { DdbEntryStorageOpsFeature };
54
+
55
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/feature.js","sources":["../../../src/operations/entry/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { DataLoadersHandler } from \"./dataLoaders.js\";\nimport { DdbCreateEntry } from \"./DdbCreateEntry.js\";\nimport { DdbCreateEntryRevisionFrom } from \"./DdbCreateEntryRevisionFrom.js\";\nimport { DdbUpdateEntry } from \"./DdbUpdateEntry.js\";\nimport { DdbMoveEntry } from \"./DdbMoveEntry.js\";\nimport { DdbMoveToBin } from \"./DdbMoveToBin.js\";\nimport { DdbDeleteEntry } from \"./DdbDeleteEntry.js\";\nimport { DdbRestoreFromBin } from \"./DdbRestoreFromBin.js\";\nimport { DdbDeleteEntryRevision } from \"./DdbDeleteEntryRevision.js\";\nimport { DdbDeleteMultipleEntries } from \"./DdbDeleteMultipleEntries.js\";\nimport { DdbGetEntry } from \"./DdbGetEntry.js\";\nimport { DdbListEntries } from \"./DdbListEntries.js\";\nimport { DdbPublishEntry } from \"./DdbPublishEntry.js\";\nimport { DdbUnpublishEntry } from \"./DdbUnpublishEntry.js\";\nimport { DdbGetEntriesByIds } from \"./DdbGetEntriesByIds.js\";\nimport { DdbGetLatestEntriesByIds } from \"./DdbGetLatestEntriesByIds.js\";\nimport { DdbGetPublishedEntriesByIds } from \"./DdbGetPublishedEntriesByIds.js\";\nimport { DdbGetRevisions } from \"./DdbGetRevisions.js\";\nimport { DdbGetRevisionById } from \"./DdbGetRevisionById.js\";\nimport { DdbGetLatestRevisionByEntryId } from \"./DdbGetLatestRevisionByEntryId.js\";\nimport { DdbGetPublishedRevisionByEntryId } from \"./DdbGetPublishedRevisionByEntryId.js\";\nimport { DdbGetPreviousRevision } from \"./DdbGetPreviousRevision.js\";\nimport { DdbGetUniqueFieldValues } from \"./DdbGetUniqueFieldValues.js\";\n\nexport const DdbEntryStorageOpsFeature = createFeature({\n name: \"cms.ddb.entryStorageOps\",\n register: container => {\n // The DataLoader caches reads, so it must live for one request: container scoped, it is built\n // per request (child) container even though the feature is registered once in the root.\n container.register(DataLoadersHandler).inContainerScope();\n container.register(DdbCreateEntry);\n container.register(DdbCreateEntryRevisionFrom);\n container.register(DdbUpdateEntry);\n container.register(DdbMoveEntry);\n container.register(DdbMoveToBin);\n container.register(DdbDeleteEntry);\n container.register(DdbRestoreFromBin);\n container.register(DdbDeleteEntryRevision);\n container.register(DdbDeleteMultipleEntries);\n container.register(DdbGetEntry);\n container.register(DdbListEntries);\n container.register(DdbPublishEntry);\n container.register(DdbUnpublishEntry);\n container.register(DdbGetEntriesByIds);\n container.register(DdbGetLatestEntriesByIds);\n container.register(DdbGetPublishedEntriesByIds);\n container.register(DdbGetRevisions);\n container.register(DdbGetRevisionById);\n container.register(DdbGetLatestRevisionByEntryId);\n container.register(DdbGetPublishedRevisionByEntryId);\n container.register(DdbGetPreviousRevision);\n container.register(DdbGetUniqueFieldValues);\n }\n});\n"],"names":["DdbEntryStorageOpsFeature","createFeature","container","DataLoadersHandler","DdbCreateEntry","DdbCreateEntryRevisionFrom","DdbUpdateEntry","DdbMoveEntry","DdbMoveToBin","DdbDeleteEntry","DdbRestoreFromBin","DdbDeleteEntryRevision","DdbDeleteMultipleEntries","DdbGetEntry","DdbListEntries","DdbPublishEntry","DdbUnpublishEntry","DdbGetEntriesByIds","DdbGetLatestEntriesByIds","DdbGetPublishedEntriesByIds","DdbGetRevisions","DdbGetRevisionById","DdbGetLatestRevisionByEntryId","DdbGetPublishedRevisionByEntryId","DdbGetPreviousRevision","DdbGetUniqueFieldValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAAUC,CAAAA;QAGNA,UAAU,QAAQ,CAACC,oBAAoB,gBAAgB;QACvDD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;QACnBL,UAAU,QAAQ,CAACM;QACnBN,UAAU,QAAQ,CAACO;QACnBP,UAAU,QAAQ,CAACQ;QACnBR,UAAU,QAAQ,CAACS;QACnBT,UAAU,QAAQ,CAACU;QACnBV,UAAU,QAAQ,CAACW;QACnBX,UAAU,QAAQ,CAACY;QACnBZ,UAAU,QAAQ,CAACa;QACnBb,UAAU,QAAQ,CAACc;QACnBd,UAAU,QAAQ,CAACe;QACnBf,UAAU,QAAQ,CAACgB;QACnBhB,UAAU,QAAQ,CAACiB;QACnBjB,UAAU,QAAQ,CAACkB;QACnBlB,UAAU,QAAQ,CAACmB;QACnBnB,UAAU,QAAQ,CAACoB;QACnBpB,UAAU,QAAQ,CAACqB;QACnBrB,UAAU,QAAQ,CAACsB;QACnBtB,UAAU,QAAQ,CAACuB;IACvB;AACJ"}
@@ -1,6 +1,5 @@
1
1
  interface BasePartitionKeyParams {
2
2
  tenant: string;
3
- locale: string;
4
3
  }
5
4
  export interface PartitionKeyParams extends BasePartitionKeyParams {
6
5
  id: string;
@@ -14,7 +13,6 @@ export declare const createLatestSortKey: () => string;
14
13
  export declare const createPublishedSortKey: () => string;
15
14
  export interface GSIPartitionKeyParams {
16
15
  tenant: string;
17
- locale: string;
18
16
  modelId: string;
19
17
  }
20
18
  export declare const createGSIPartitionKey: (params: GSIPartitionKeyParams, type: "A" | "L" | "P") => string;
@@ -22,4 +20,50 @@ export interface GSISortKeyParams {
22
20
  id: string;
23
21
  }
24
22
  export declare const createGSISortKey: (params: GSISortKeyParams) => string;
23
+ export interface ICreateEntryPublishedKeysParams {
24
+ id: string;
25
+ tenant: string;
26
+ modelId: string;
27
+ expiresAt: number | null;
28
+ }
29
+ export declare const createEntryPublishedKeys: (params: ICreateEntryPublishedKeysParams) => {
30
+ PK: string;
31
+ SK: string;
32
+ GSI1_PK: string;
33
+ GSI1_SK: string;
34
+ TYPE: string;
35
+ GSI_TENANT: string;
36
+ expiresAt: number | null;
37
+ };
38
+ export interface ICreateEntryLatestKeysParams {
39
+ id: string;
40
+ tenant: string;
41
+ modelId: string;
42
+ expiresAt: number | null;
43
+ }
44
+ export declare const createEntryLatestKeys: (params: ICreateEntryLatestKeysParams) => {
45
+ PK: string;
46
+ SK: string;
47
+ GSI1_PK: string;
48
+ GSI1_SK: string;
49
+ TYPE: string;
50
+ GSI_TENANT: string;
51
+ expiresAt: number | null;
52
+ };
53
+ export interface ICreateRevisionKeysParams {
54
+ id: string;
55
+ tenant: string;
56
+ version: number;
57
+ modelId: string;
58
+ expiresAt: number | null;
59
+ }
60
+ export declare const createEntryRevisionKeys: (params: ICreateRevisionKeysParams) => {
61
+ PK: string;
62
+ SK: string;
63
+ GSI1_PK: string;
64
+ GSI1_SK: string;
65
+ TYPE: string;
66
+ GSI_TENANT: string;
67
+ expiresAt: number | null;
68
+ };
25
69
  export {};