@webiny/api-headless-cms-ddb 0.0.0-unstable.eb196ccd2f → 0.0.0-unstable.eb81deee7e

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 (290) 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 -6
  18. package/definitions/entry.js +8 -185
  19. package/definitions/entry.js.map +1 -1
  20. package/definitions/group.d.ts +4 -6
  21. package/definitions/group.js +8 -63
  22. package/definitions/group.js.map +1 -1
  23. package/definitions/model.d.ts +4 -6
  24. package/definitions/model.js +8 -107
  25. package/definitions/model.js.map +1 -1
  26. package/definitions/table.d.ts +3 -5
  27. package/definitions/table.js +6 -29
  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 +17 -3
  32. package/index.js +36 -123
  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 +1 -2
  101. package/operations/entry/dataLoader/DataLoaderCache.js +21 -35
  102. package/operations/entry/dataLoader/DataLoaderCache.js.map +1 -1
  103. package/operations/entry/dataLoader/constants.js +2 -7
  104. package/operations/entry/dataLoader/constants.js.map +1 -1
  105. package/operations/entry/dataLoader/createBatchScheduleFn.js +7 -22
  106. package/operations/entry/dataLoader/createBatchScheduleFn.js.map +1 -1
  107. package/operations/entry/dataLoader/getAllEntryRevisions.d.ts +3 -3
  108. package/operations/entry/dataLoader/getAllEntryRevisions.js +20 -41
  109. package/operations/entry/dataLoader/getAllEntryRevisions.js.map +1 -1
  110. package/operations/entry/dataLoader/getLatestRevisionByEntryId.d.ts +3 -3
  111. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js +36 -52
  112. package/operations/entry/dataLoader/getLatestRevisionByEntryId.js.map +1 -1
  113. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.d.ts +3 -3
  114. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js +36 -52
  115. package/operations/entry/dataLoader/getPublishedRevisionByEntryId.js.map +1 -1
  116. package/operations/entry/dataLoader/getRevisionById.d.ts +3 -3
  117. package/operations/entry/dataLoader/getRevisionById.js +38 -58
  118. package/operations/entry/dataLoader/getRevisionById.js.map +1 -1
  119. package/operations/entry/dataLoader/index.d.ts +3 -3
  120. package/operations/entry/dataLoader/index.js +13 -35
  121. package/operations/entry/dataLoader/index.js.map +1 -1
  122. package/operations/entry/dataLoader/types.d.ts +4 -4
  123. package/operations/entry/dataLoader/types.js +0 -7
  124. package/operations/entry/dataLoaders.d.ts +13 -13
  125. package/operations/entry/dataLoaders.js +92 -110
  126. package/operations/entry/dataLoaders.js.map +1 -1
  127. package/operations/entry/feature.d.ts +4 -0
  128. package/operations/entry/feature.js +53 -0
  129. package/operations/entry/feature.js.map +1 -0
  130. package/operations/entry/keys.d.ts +46 -2
  131. package/operations/entry/keys.js +52 -49
  132. package/operations/entry/keys.js.map +1 -1
  133. package/operations/entry/storageEntryUtils.d.ts +8 -0
  134. package/operations/entry/storageEntryUtils.js +25 -0
  135. package/operations/entry/storageEntryUtils.js.map +1 -0
  136. package/operations/group/DdbCreateGroup.d.ts +12 -0
  137. package/operations/group/DdbCreateGroup.js +35 -0
  138. package/operations/group/DdbCreateGroup.js.map +1 -0
  139. package/operations/group/DdbDeleteGroup.d.ts +12 -0
  140. package/operations/group/DdbDeleteGroup.js +31 -0
  141. package/operations/group/DdbDeleteGroup.js.map +1 -0
  142. package/operations/group/DdbGetGroup.d.ts +12 -0
  143. package/operations/group/DdbGetGroup.js +31 -0
  144. package/operations/group/DdbGetGroup.js.map +1 -0
  145. package/operations/group/DdbListGroups.d.ts +14 -0
  146. package/operations/group/DdbListGroups.js +52 -0
  147. package/operations/group/DdbListGroups.js.map +1 -0
  148. package/operations/group/DdbUpdateGroup.d.ts +12 -0
  149. package/operations/group/DdbUpdateGroup.js +35 -0
  150. package/operations/group/DdbUpdateGroup.js.map +1 -0
  151. package/operations/group/feature.d.ts +4 -0
  152. package/operations/group/feature.js +19 -0
  153. package/operations/group/feature.js.map +1 -0
  154. package/operations/group/keys.d.ts +15 -0
  155. package/operations/group/keys.js +17 -0
  156. package/operations/group/keys.js.map +1 -0
  157. package/operations/model/DdbCreateModel.d.ts +12 -0
  158. package/operations/model/DdbCreateModel.js +37 -0
  159. package/operations/model/DdbCreateModel.js.map +1 -0
  160. package/operations/model/DdbDeleteModel.d.ts +12 -0
  161. package/operations/model/DdbDeleteModel.js +31 -0
  162. package/operations/model/DdbDeleteModel.js.map +1 -0
  163. package/operations/model/DdbGetModel.d.ts +12 -0
  164. package/operations/model/DdbGetModel.js +30 -0
  165. package/operations/model/DdbGetModel.js.map +1 -0
  166. package/operations/model/DdbListModels.d.ts +12 -0
  167. package/operations/model/DdbListModels.js +36 -0
  168. package/operations/model/DdbListModels.js.map +1 -0
  169. package/operations/model/DdbUpdateModel.d.ts +12 -0
  170. package/operations/model/DdbUpdateModel.js +36 -0
  171. package/operations/model/DdbUpdateModel.js.map +1 -0
  172. package/operations/model/feature.d.ts +4 -0
  173. package/operations/model/feature.js +19 -0
  174. package/operations/model/feature.js.map +1 -0
  175. package/operations/model/keys.d.ts +15 -0
  176. package/operations/model/keys.js +16 -0
  177. package/operations/model/keys.js.map +1 -0
  178. package/package.json +27 -25
  179. package/requestFeature.d.ts +17 -0
  180. package/requestFeature.js +19 -0
  181. package/requestFeature.js.map +1 -0
  182. package/types.d.ts +11 -51
  183. package/types.js +6 -12
  184. package/types.js.map +1 -1
  185. package/definitions/system.d.ts +0 -10
  186. package/definitions/system.js +0 -42
  187. package/definitions/system.js.map +0 -1
  188. package/dynamoDb/index.d.ts +0 -2
  189. package/dynamoDb/index.js +0 -15
  190. package/dynamoDb/index.js.map +0 -1
  191. package/dynamoDb/path/locationFolderId.d.ts +0 -2
  192. package/dynamoDb/path/locationFolderId.js +0 -43
  193. package/dynamoDb/path/locationFolderId.js.map +0 -1
  194. package/dynamoDb/path/plainObject.d.ts +0 -2
  195. package/dynamoDb/path/plainObject.js +0 -35
  196. package/dynamoDb/path/plainObject.js.map +0 -1
  197. package/dynamoDb/storage/longText.d.ts +0 -10
  198. package/dynamoDb/storage/longText.js +0 -94
  199. package/dynamoDb/storage/longText.js.map +0 -1
  200. package/dynamoDb/storage/richText.d.ts +0 -2
  201. package/dynamoDb/storage/richText.js +0 -61
  202. package/dynamoDb/storage/richText.js.map +0 -1
  203. package/dynamoDb/transformValue/datetime.d.ts +0 -5
  204. package/dynamoDb/transformValue/datetime.js +0 -47
  205. package/dynamoDb/transformValue/datetime.js.map +0 -1
  206. package/operations/entry/dataLoader/types.js.map +0 -1
  207. package/operations/entry/filtering/createExpressions.d.ts +0 -26
  208. package/operations/entry/filtering/createExpressions.js +0 -178
  209. package/operations/entry/filtering/createExpressions.js.map +0 -1
  210. package/operations/entry/filtering/createFields.d.ts +0 -16
  211. package/operations/entry/filtering/createFields.js +0 -108
  212. package/operations/entry/filtering/createFields.js.map +0 -1
  213. package/operations/entry/filtering/extractSort.d.ts +0 -17
  214. package/operations/entry/filtering/extractSort.js +0 -69
  215. package/operations/entry/filtering/extractSort.js.map +0 -1
  216. package/operations/entry/filtering/filter.d.ts +0 -15
  217. package/operations/entry/filtering/filter.js +0 -158
  218. package/operations/entry/filtering/filter.js.map +0 -1
  219. package/operations/entry/filtering/fullTextSearch.d.ts +0 -14
  220. package/operations/entry/filtering/fullTextSearch.js +0 -50
  221. package/operations/entry/filtering/fullTextSearch.js.map +0 -1
  222. package/operations/entry/filtering/getValue.d.ts +0 -5
  223. package/operations/entry/filtering/getValue.js +0 -66
  224. package/operations/entry/filtering/getValue.js.map +0 -1
  225. package/operations/entry/filtering/index.d.ts +0 -2
  226. package/operations/entry/filtering/index.js +0 -21
  227. package/operations/entry/filtering/index.js.map +0 -1
  228. package/operations/entry/filtering/mapPlugins.d.ts +0 -8
  229. package/operations/entry/filtering/mapPlugins.js +0 -33
  230. package/operations/entry/filtering/mapPlugins.js.map +0 -1
  231. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +0 -2
  232. package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -45
  233. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +0 -1
  234. package/operations/entry/filtering/plugins/index.d.ts +0 -1
  235. package/operations/entry/filtering/plugins/index.js +0 -16
  236. package/operations/entry/filtering/plugins/index.js.map +0 -1
  237. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +0 -2
  238. package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -90
  239. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +0 -1
  240. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +0 -3
  241. package/operations/entry/filtering/plugins/refFilterCreate.js +0 -80
  242. package/operations/entry/filtering/plugins/refFilterCreate.js.map +0 -1
  243. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +0 -2
  244. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +0 -65
  245. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +0 -1
  246. package/operations/entry/filtering/sort.d.ts +0 -12
  247. package/operations/entry/filtering/sort.js +0 -71
  248. package/operations/entry/filtering/sort.js.map +0 -1
  249. package/operations/entry/filtering/systemFields.d.ts +0 -4
  250. package/operations/entry/filtering/systemFields.js +0 -90
  251. package/operations/entry/filtering/systemFields.js.map +0 -1
  252. package/operations/entry/filtering/transform.d.ts +0 -6
  253. package/operations/entry/filtering/transform.js +0 -18
  254. package/operations/entry/filtering/transform.js.map +0 -1
  255. package/operations/entry/filtering/types.d.ts +0 -40
  256. package/operations/entry/filtering/types.js +0 -7
  257. package/operations/entry/filtering/types.js.map +0 -1
  258. package/operations/entry/filtering/values.d.ts +0 -2
  259. package/operations/entry/filtering/values.js +0 -24
  260. package/operations/entry/filtering/values.js.map +0 -1
  261. package/operations/entry/filtering/where.d.ts +0 -5
  262. package/operations/entry/filtering/where.js +0 -35
  263. package/operations/entry/filtering/where.js.map +0 -1
  264. package/operations/entry/index.d.ts +0 -8
  265. package/operations/entry/index.js +0 -1306
  266. package/operations/entry/index.js.map +0 -1
  267. package/operations/group/index.d.ts +0 -9
  268. package/operations/group/index.js +0 -174
  269. package/operations/group/index.js.map +0 -1
  270. package/operations/model/index.d.ts +0 -7
  271. package/operations/model/index.js +0 -150
  272. package/operations/model/index.js.map +0 -1
  273. package/operations/system/index.d.ts +0 -7
  274. package/operations/system/index.js +0 -94
  275. package/operations/system/index.js.map +0 -1
  276. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +0 -23
  277. package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -48
  278. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +0 -1
  279. package/plugins/CmsEntryFieldFilterPlugin.d.ts +0 -43
  280. package/plugins/CmsEntryFieldFilterPlugin.js +0 -27
  281. package/plugins/CmsEntryFieldFilterPlugin.js.map +0 -1
  282. package/plugins/CmsEntryFieldSortingPlugin.d.ts +0 -42
  283. package/plugins/CmsEntryFieldSortingPlugin.js +0 -27
  284. package/plugins/CmsEntryFieldSortingPlugin.js.map +0 -1
  285. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +0 -11
  286. package/plugins/CmsFieldFilterValueTransformPlugin.js +0 -23
  287. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +0 -1
  288. package/plugins/index.d.ts +0 -4
  289. package/plugins/index.js +0 -51
  290. package/plugins/index.js.map +0 -1
@@ -1,62 +1,42 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.createGetRevisionById = void 0;
8
- var _dataloader = _interopRequireDefault(require("dataloader"));
9
- var _dbDynamodb = require("@webiny/db-dynamodb");
10
- var _cleanup = require("@webiny/db-dynamodb/utils/cleanup");
11
- var _keys = require("../keys");
12
- var _utils = require("@webiny/utils");
13
- var _createBatchScheduleFn = require("./createBatchScheduleFn");
14
- const createGetRevisionById = params => {
15
- const {
16
- entity,
17
- locale,
18
- tenant
19
- } = params;
20
- return new _dataloader.default(async ids => {
21
- const queries = ids.reduce((collection, id) => {
22
- const partitionKey = (0, _keys.createPartitionKey)({
23
- tenant,
24
- locale,
25
- id
26
- });
27
- const {
28
- version
29
- } = (0, _utils.parseIdentifier)(id);
30
- if (version === null) {
31
- return collection;
32
- }
33
- const sortKey = (0, _keys.createRevisionSortKey)({
34
- version
35
- });
36
- const keys = `${partitionKey}__${sortKey}`;
37
- if (collection[keys]) {
38
- return collection;
39
- }
40
- collection[keys] = entity.getBatch({
41
- PK: partitionKey,
42
- SK: sortKey
43
- });
44
- return collection;
45
- }, {});
46
- const records = await (0, _dbDynamodb.batchReadAll)({
47
- table: entity.table,
48
- items: Object.values(queries)
49
- });
50
- const items = (0, _cleanup.cleanupItems)(entity, records);
51
- return ids.map(id => {
52
- return items.filter(item => {
53
- return id === item.id;
54
- });
1
+ import dataloader from "dataloader";
2
+ import { cleanupItems } from "@webiny/db-dynamodb/utils/cleanup.js";
3
+ import { createPartitionKey, createRevisionSortKey } from "../keys.js";
4
+ import { parseIdentifier } from "@webiny/utils";
5
+ import { createBatchScheduleFn } from "./createBatchScheduleFn.js";
6
+ const createGetRevisionById = (params)=>{
7
+ const { entity, tenant, modelId } = params;
8
+ return new dataloader(async (ids)=>{
9
+ const reader = entity.createEntityReader();
10
+ const keys = new Set();
11
+ for (const id of ids){
12
+ const partitionKey = createPartitionKey({
13
+ tenant,
14
+ id
15
+ });
16
+ const { version } = parseIdentifier(id);
17
+ if (null === version) continue;
18
+ const sortKey = createRevisionSortKey({
19
+ version
20
+ });
21
+ const key = `${partitionKey}__${sortKey}`;
22
+ if (!keys.has(key)) {
23
+ keys.add(key);
24
+ reader.get({
25
+ PK: partitionKey,
26
+ SK: sortKey
27
+ });
28
+ }
29
+ }
30
+ const records = await reader.execute();
31
+ const items = cleanupItems(entity.entity, records).map((item)=>item.data);
32
+ return ids.map((id)=>items.filter((item)=>{
33
+ if (item.modelId !== modelId) return false;
34
+ return id === item.id;
35
+ }));
36
+ }, {
37
+ batchScheduleFn: createBatchScheduleFn()
55
38
  });
56
- }, {
57
- batchScheduleFn: (0, _createBatchScheduleFn.createBatchScheduleFn)()
58
- });
59
39
  };
60
- exports.createGetRevisionById = createGetRevisionById;
40
+ export { createGetRevisionById };
61
41
 
62
42
  //# sourceMappingURL=getRevisionById.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_dataloader","_interopRequireDefault","require","_dbDynamodb","_cleanup","_keys","_utils","_createBatchScheduleFn","createGetRevisionById","params","entity","locale","tenant","DataLoader","ids","queries","reduce","collection","id","partitionKey","createPartitionKey","version","parseIdentifier","sortKey","createRevisionSortKey","keys","getBatch","PK","SK","records","batchReadAll","table","items","Object","values","cleanupItems","map","filter","item","batchScheduleFn","createBatchScheduleFn","exports"],"sources":["getRevisionById.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { batchReadAll } from \"@webiny/db-dynamodb\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup\";\nimport { createPartitionKey, createRevisionSortKey } from \"~/operations/entry/keys\";\nimport type { DataLoaderParams } from \"./types\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn\";\n\nexport const createGetRevisionById = (params: DataLoaderParams) => {\n const { entity, locale, tenant } = params;\n\n return new DataLoader<string, CmsStorageEntry[]>(\n async (ids: readonly string[]) => {\n const queries = ids.reduce<Record<string, ReturnType<typeof entity.getBatch>>>(\n (collection, id) => {\n const partitionKey = createPartitionKey({\n tenant,\n locale,\n id\n });\n const { version } = parseIdentifier(id);\n if (version === null) {\n return collection;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const keys = `${partitionKey}__${sortKey}`;\n if (collection[keys]) {\n return collection;\n }\n\n collection[keys] = entity.getBatch({\n PK: partitionKey,\n SK: sortKey\n });\n\n return collection;\n },\n {}\n );\n\n const records = await batchReadAll<CmsStorageEntry>({\n table: entity.table,\n items: Object.values(queries)\n });\n const items = cleanupItems(entity, records);\n\n return ids.map(id => {\n return items.filter(item => {\n return id === item.id;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,sBAAA,GAAAL,OAAA;AAEO,MAAMM,qBAAqB,GAAIC,MAAwB,IAAK;EAC/D,MAAM;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAO,CAAC,GAAGH,MAAM;EAEzC,OAAO,IAAII,mBAAU,CACjB,MAAOC,GAAsB,IAAK;IAC9B,MAAMC,O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":[]}
1
+ {"version":3,"file":"operations/entry/dataLoader/getRevisionById.js","sources":["../../../../src/operations/entry/dataLoader/getRevisionById.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport type { CmsStorageEntry } from \"@webiny/api-headless-cms/types/index.js\";\nimport { cleanupItems } from \"@webiny/db-dynamodb/utils/cleanup.js\";\nimport { createPartitionKey, createRevisionSortKey } from \"~/operations/entry/keys.js\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { createBatchScheduleFn } from \"./createBatchScheduleFn.js\";\n\nexport const createGetRevisionById = (params: IDataLoaderParams) => {\n const { entity, tenant, modelId } = params;\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 const { version } = parseIdentifier(id);\n if (version === null) {\n continue;\n }\n const sortKey = createRevisionSortKey({\n version\n });\n const key = `${partitionKey}__${sortKey}`;\n if (keys.has(key)) {\n continue;\n }\n keys.add(key);\n\n reader.get({\n PK: partitionKey,\n SK: sortKey\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 return items.filter(item => {\n if (item.modelId !== modelId) {\n return false;\n }\n return id === item.id;\n });\n });\n },\n {\n batchScheduleFn: createBatchScheduleFn()\n }\n );\n};\n"],"names":["createGetRevisionById","params","entity","tenant","modelId","DataLoader","ids","reader","keys","Set","id","partitionKey","createPartitionKey","version","parseIdentifier","sortKey","createRevisionSortKey","key","records","items","cleanupItems","item","createBatchScheduleFn"],"mappings":";;;;;AAQO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGH;IAEpC,OAAO,IAAII,WACP,OAAMC;QACF,MAAMC,SAASL,OAAO,kBAAkB;QAExC,MAAMM,OAAO,IAAIC;QAEjB,KAAK,MAAMC,MAAMJ,IAAK;YAClB,MAAMK,eAAeC,mBAAmB;gBACpCT;gBACAO;YACJ;YACA,MAAM,EAAEG,OAAO,EAAE,GAAGC,gBAAgBJ;YACpC,IAAIG,AAAY,SAAZA,SACA;YAEJ,MAAME,UAAUC,sBAAsB;gBAClCH;YACJ;YACA,MAAMI,MAAM,GAAGN,aAAa,EAAE,EAAEI,SAAS;YACzC,KAAIP,KAAK,GAAG,CAACS;gBAGbT,KAAK,GAAG,CAACS;gBAETV,OAAO,GAAG,CAAC;oBACP,IAAII;oBACJ,IAAII;gBACR;;QACJ;QAEA,MAAMG,UAAU,MAAMX,OAAO,OAAO;QACpC,MAAMY,QAAQC,aAAalB,OAAO,MAAM,EAAEgB,SAAS,GAAG,CAACG,CAAAA,OAC5CA,KAAK,IAAI;QAGpB,OAAOf,IAAI,GAAG,CAACI,CAAAA,KACJS,MAAM,MAAM,CAACE,CAAAA;gBAChB,IAAIA,KAAK,OAAO,KAAKjB,SACjB,OAAO;gBAEX,OAAOM,OAAOW,KAAK,EAAE;YACzB;IAER,GACA;QACI,iBAAiBC;IACrB;AAER"}
@@ -1,8 +1,8 @@
1
1
  import type DataLoader from "dataloader";
2
- import type { DataLoaderParams } from "./types";
3
- export * from "./DataLoaderCache";
2
+ import type { IDataLoaderParams } from "./types.js";
3
+ export * from "./DataLoaderCache.js";
4
4
  interface Callable {
5
- (params: DataLoaderParams): DataLoader<any, any>;
5
+ (params: IDataLoaderParams): DataLoader<any, any>;
6
6
  }
7
7
  export type DataLoaders = "getAllEntryRevisions" | "getRevisionById" | "getPublishedRevisionByEntryId" | "getLatestRevisionByEntryId";
8
8
  export declare const getDataLoaderFactory: (name: string) => Callable;
@@ -1,40 +1,18 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- getDataLoaderFactory: true
8
- };
9
- exports.getDataLoaderFactory = void 0;
10
- var _getAllEntryRevisions = require("./getAllEntryRevisions");
11
- var _getLatestRevisionByEntryId = require("./getLatestRevisionByEntryId");
12
- var _getPublishedRevisionByEntryId = require("./getPublishedRevisionByEntryId");
13
- var _getRevisionById = require("./getRevisionById");
14
- var _DataLoaderCache = require("./DataLoaderCache");
15
- Object.keys(_DataLoaderCache).forEach(function (key) {
16
- if (key === "default" || key === "__esModule") return;
17
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
18
- if (key in exports && exports[key] === _DataLoaderCache[key]) return;
19
- Object.defineProperty(exports, key, {
20
- enumerable: true,
21
- get: function () {
22
- return _DataLoaderCache[key];
23
- }
24
- });
25
- });
1
+ import { createGetAllEntryRevisions } from "./getAllEntryRevisions.js";
2
+ import { createGetLatestRevisionByEntryId } from "./getLatestRevisionByEntryId.js";
3
+ import { createGetPublishedRevisionByEntryId } from "./getPublishedRevisionByEntryId.js";
4
+ import { createGetRevisionById } from "./getRevisionById.js";
5
+ export * from "./DataLoaderCache.js";
26
6
  const dataLoaders = {
27
- getAllEntryRevisions: _getAllEntryRevisions.createGetAllEntryRevisions,
28
- getLatestRevisionByEntryId: _getLatestRevisionByEntryId.createGetLatestRevisionByEntryId,
29
- getPublishedRevisionByEntryId: _getPublishedRevisionByEntryId.createGetPublishedRevisionByEntryId,
30
- getRevisionById: _getRevisionById.createGetRevisionById
7
+ getAllEntryRevisions: createGetAllEntryRevisions,
8
+ getLatestRevisionByEntryId: createGetLatestRevisionByEntryId,
9
+ getPublishedRevisionByEntryId: createGetPublishedRevisionByEntryId,
10
+ getRevisionById: createGetRevisionById
31
11
  };
32
- const getDataLoaderFactory = name => {
33
- if (!dataLoaders[name]) {
34
- throw new Error(`Missing data loader "${name}".`);
35
- }
36
- return dataLoaders[name];
12
+ const getDataLoaderFactory = (name)=>{
13
+ if (!dataLoaders[name]) throw new Error(`Missing data loader "${name}".`);
14
+ return dataLoaders[name];
37
15
  };
38
- exports.getDataLoaderFactory = getDataLoaderFactory;
16
+ export { getDataLoaderFactory };
39
17
 
40
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_getAllEntryRevisions","require","_getLatestRevisionByEntryId","_getPublishedRevisionByEntryId","_getRevisionById","_DataLoaderCache","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","dataLoaders","getAllEntryRevisions","createGetAllEntryRevisions","getLatestRevisionByEntryId","createGetLatestRevisionByEntryId","getPublishedRevisionByEntryId","createGetPublishedRevisionByEntryId","getRevisionById","createGetRevisionById","getDataLoaderFactory","name","Error"],"sources":["index.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport type { DataLoaderParams } from \"./types\";\nimport { createGetAllEntryRevisions } from \"./getAllEntryRevisions\";\nimport { createGetLatestRevisionByEntryId } from \"./getLatestRevisionByEntryId\";\nimport { createGetPublishedRevisionByEntryId } from \"./getPublishedRevisionByEntryId\";\nimport { createGetRevisionById } from \"./getRevisionById\";\n\nexport * from \"./DataLoaderCache\";\n\ninterface Callable {\n (params: DataLoaderParams): DataLoader<any, any>;\n}\n\nconst dataLoaders: Record<string, Callable> = {\n getAllEntryRevisions: createGetAllEntryRevisions,\n getLatestRevisionByEntryId: createGetLatestRevisionByEntryId,\n getPublishedRevisionByEntryId: createGetPublishedRevisionByEntryId,\n getRevisionById: createGetRevisionById\n};\n\nexport type DataLoaders =\n | \"getAllEntryRevisions\"\n | \"getRevisionById\"\n | \"getPublishedRevisionByEntryId\"\n | \"getLatestRevisionByEntryId\";\n\nexport const getDataLoaderFactory = (name: string) => {\n if (!dataLoaders[name]) {\n throw new Error(`Missing data loader \"${name}\".`);\n }\n return dataLoaders[name];\n};\n"],"mappings":";;;;;;;;;AAEA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,2BAAA,GAAAD,OAAA;AACA,IAAAE,8BAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AAEA,IAAAI,gBAAA,GAAAJ,OAAA;AAAAK,MAAA,CAAAC,IAAA,CAAAF,gBAAA,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,gBAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,gBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAMA,MAAMS,WAAqC,GAAG;EAC1CC,oBAAoB,EAAEC,gDAA0B;EAChDC,0BAA0B,EAAEC,4DAAgC;EAC5DC,6BAA6B,EAAEC,kEAAmC;EAClEC,eAAe,EAAEC;AACrB,CAAC;AAQM,MAAMC,oBAAoB,GAAIC,IAAY,IAAK;EAClD,IAAI,CAACV,WAAW,CAACU,IAAI,CAAC,EAAE;IACpB,MAAM,IAAIC,KAAK,CAAC,wBAAwBD,IAAI,IAAI,CAAC;EACrD;EACA,OAAOV,WAAW,CAACU,IAAI,CAAC;AAC5B,CAAC;AAACd,OAAA,CAAAa,oBAAA,GAAAA,oBAAA","ignoreList":[]}
1
+ {"version":3,"file":"operations/entry/dataLoader/index.js","sources":["../../../../src/operations/entry/dataLoader/index.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport type { IDataLoaderParams } from \"./types.js\";\nimport { createGetAllEntryRevisions } from \"./getAllEntryRevisions.js\";\nimport { createGetLatestRevisionByEntryId } from \"./getLatestRevisionByEntryId.js\";\nimport { createGetPublishedRevisionByEntryId } from \"./getPublishedRevisionByEntryId.js\";\nimport { createGetRevisionById } from \"./getRevisionById.js\";\n\nexport * from \"./DataLoaderCache.js\";\n\ninterface Callable {\n (params: IDataLoaderParams): DataLoader<any, any>;\n}\n\nconst dataLoaders: Record<string, Callable> = {\n getAllEntryRevisions: createGetAllEntryRevisions,\n getLatestRevisionByEntryId: createGetLatestRevisionByEntryId,\n getPublishedRevisionByEntryId: createGetPublishedRevisionByEntryId,\n getRevisionById: createGetRevisionById\n};\n\nexport type DataLoaders =\n | \"getAllEntryRevisions\"\n | \"getRevisionById\"\n | \"getPublishedRevisionByEntryId\"\n | \"getLatestRevisionByEntryId\";\n\nexport const getDataLoaderFactory = (name: string) => {\n if (!dataLoaders[name]) {\n throw new Error(`Missing data loader \"${name}\".`);\n }\n return dataLoaders[name];\n};\n"],"names":["dataLoaders","createGetAllEntryRevisions","createGetLatestRevisionByEntryId","createGetPublishedRevisionByEntryId","createGetRevisionById","getDataLoaderFactory","name","Error"],"mappings":";;;;;AAaA,MAAMA,cAAwC;IAC1C,sBAAsBC;IACtB,4BAA4BC;IAC5B,+BAA+BC;IAC/B,iBAAiBC;AACrB;AAQO,MAAMC,uBAAuB,CAACC;IACjC,IAAI,CAACN,WAAW,CAACM,KAAK,EAClB,MAAM,IAAIC,MAAM,CAAC,qBAAqB,EAAED,KAAK,EAAE,CAAC;IAEpD,OAAON,WAAW,CAACM,KAAK;AAC5B"}
@@ -1,6 +1,6 @@
1
- import type { Entity } from "@webiny/db-dynamodb/toolbox";
2
- export interface DataLoaderParams {
3
- entity: Entity<any>;
1
+ import type { IEntryEntity } from "../../../definitions/types.js";
2
+ export interface IDataLoaderParams {
3
+ entity: IEntryEntity;
4
4
  tenant: string;
5
- locale: string;
5
+ modelId: string;
6
6
  }
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- //# sourceMappingURL=types.js.map
@@ -1,21 +1,18 @@
1
- import type { CmsModel, CmsStorageEntry } from "@webiny/api-headless-cms/types";
2
- import type { Entity } from "@webiny/db-dynamodb/toolbox";
3
- import type { DataLoadersHandlerInterface, DataLoadersHandlerInterfaceClearAllParams } from "../../types";
1
+ import type { CmsEntryValues, CmsModel, CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
2
+ import type { DataLoadersHandlerInterfaceClearAllParams, IDataLoadersHandler } from "../../types.js";
3
+ import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
4
4
  interface DataLoaderParams {
5
- model: Pick<CmsModel, "tenant" | "locale" | "modelId">;
5
+ model: Pick<CmsModel, "tenant" | "modelId">;
6
6
  ids: readonly string[];
7
7
  }
8
- interface DataLoadersHandlerParams {
9
- entity: Entity<any>;
10
- }
11
- export declare class DataLoadersHandler implements DataLoadersHandlerInterface {
8
+ declare class DataLoadersHandlerImpl implements IDataLoadersHandler {
12
9
  private readonly entity;
13
10
  private readonly cache;
14
- constructor(params: DataLoadersHandlerParams);
15
- getAllEntryRevisions(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
16
- getRevisionById(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
17
- getPublishedRevisionByEntryId(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
18
- getLatestRevisionByEntryId(params: DataLoaderParams): Promise<CmsStorageEntry[]>;
11
+ constructor(entity: CmsDdbEntryEntity.Interface);
12
+ getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(params: DataLoaderParams): Promise<CmsStorageEntry<T>[]>;
13
+ getRevisionById<T extends CmsEntryValues = CmsEntryValues>(params: DataLoaderParams): Promise<CmsStorageEntry<T>[]>;
14
+ getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(params: DataLoaderParams): Promise<CmsStorageEntry<T>[]>;
15
+ getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(params: DataLoaderParams): Promise<CmsStorageEntry<T>[]>;
19
16
  /**
20
17
  * TODO @ts-refactor
21
18
  * Maybe pass on the generics to DataLoader definition?
@@ -24,4 +21,7 @@ export declare class DataLoadersHandler implements DataLoadersHandlerInterface {
24
21
  private loadMany;
25
22
  clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void;
26
23
  }
24
+ export declare const DataLoadersHandler: typeof DataLoadersHandlerImpl & {
25
+ __abstraction: import("@webiny/di").Abstraction<IDataLoadersHandler>;
26
+ };
27
27
  export {};
@@ -1,116 +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 _error = _interopRequireDefault(require("@webiny/error"));
9
- var _DataLoaderCache = require("./dataLoader/DataLoaderCache");
10
- var _dataLoader = require("./dataLoader");
11
- var _utils = require("@webiny/utils");
12
- class DataLoadersHandler {
13
- cache = new _DataLoaderCache.DataLoaderCache();
14
- constructor(params) {
15
- this.entity = params.entity;
16
- }
17
- async getAllEntryRevisions(params) {
18
- const ids = params.ids.map(id => {
19
- const {
20
- id: entryId
21
- } = (0, _utils.parseIdentifier)(id);
22
- return entryId;
23
- });
24
- return await this.loadMany("getAllEntryRevisions", params, ids);
25
- }
26
- async getRevisionById(params) {
27
- return await this.loadMany("getRevisionById", params, params.ids);
28
- }
29
- async getPublishedRevisionByEntryId(params) {
30
- const ids = params.ids.map(id => {
31
- const {
32
- id: entryId
33
- } = (0, _utils.parseIdentifier)(id);
34
- return entryId;
35
- });
36
- return await this.loadMany("getPublishedRevisionByEntryId", params, ids);
37
- }
38
- async getLatestRevisionByEntryId(params) {
39
- const ids = params.ids.map(id => {
40
- const {
41
- id: entryId
42
- } = (0, _utils.parseIdentifier)(id);
43
- return entryId;
44
- });
45
- return await this.loadMany("getLatestRevisionByEntryId", params, ids);
46
- }
47
-
48
- /**
49
- * TODO @ts-refactor
50
- * Maybe pass on the generics to DataLoader definition?
51
- */
52
- getLoader(name, params) {
53
- const {
54
- model
55
- } = params;
56
- const cacheParams = {
57
- tenant: model.tenant,
58
- locale: model.locale,
59
- name
60
- };
61
- let loader = this.cache.getDataLoader(cacheParams);
62
- if (loader) {
63
- return loader;
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();
11
+ }
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);
64
21
  }
65
- const factory = (0, _dataLoader.getDataLoaderFactory)(name);
66
- loader = factory({
67
- entity: this.entity,
68
- tenant: model.tenant,
69
- locale: model.locale
70
- });
71
- this.cache.setDataLoader(cacheParams, loader);
72
- return loader;
73
- }
74
- async loadMany(loader, params, ids) {
75
- let results = [];
76
- try {
77
- results = await this.getLoader(loader, params).loadMany(ids);
78
- if (Array.isArray(results) === true) {
79
- return results.reduce((acc, res) => {
80
- if (Array.isArray(res) === false) {
81
- if (res && res.message) {
82
- throw new _error.default(res.message, res.code, {
83
- ...res,
84
- data: JSON.stringify(res.data || {})
85
- });
86
- }
87
- throw new _error.default("Result from the data loader must be an array of arrays which contain requested items.", "DATA_LOADER_RESULTS_ERROR", {
88
- ...params,
89
- loader
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);
28
+ }
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);
35
+ }
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
90
78
  });
91
- }
92
- acc.push(...res);
93
- return acc;
94
- }, []);
95
- }
96
- } catch (ex) {
97
- throw new _error.default(ex.message || "Data loader error.", ex.code || "DATA_LOADER_ERROR", {
98
- error: ex,
99
- ...params,
100
- loader,
101
- ids
102
- });
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);
103
88
  }
104
- throw new _error.default(`Data loader did not return array of items or empty array.`, "INVALID_DATA_LOADER_RESULT", {
105
- loader,
106
- ids,
107
- results
108
- });
109
- }
110
- clearAll(params) {
111
- this.cache.clearAll(params?.model);
112
- }
113
89
  }
114
- exports.DataLoadersHandler = DataLoadersHandler;
90
+ const DataLoadersHandler = CmsDdbDataLoaders.createImplementation({
91
+ implementation: DataLoadersHandlerImpl,
92
+ dependencies: [
93
+ CmsDdbEntryEntity
94
+ ]
95
+ });
96
+ export { DataLoadersHandler };
115
97
 
116
98
  //# sourceMappingURL=dataLoaders.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_error","_interopRequireDefault","require","_DataLoaderCache","_dataLoader","_utils","DataLoadersHandler","cache","DataLoaderCache","constructor","params","entity","getAllEntryRevisions","ids","map","id","entryId","parseIdentifier","loadMany","getRevisionById","getPublishedRevisionByEntryId","getLatestRevisionByEntryId","getLoader","name","model","cacheParams","tenant","locale","loader","getDataLoader","factory","getDataLoaderFactory","setDataLoader","results","Array","isArray","reduce","acc","res","message","WebinyError","code","data","JSON","stringify","push","ex","error","clearAll","exports"],"sources":["dataLoaders.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport type { CmsModel, CmsStorageEntry } from \"@webiny/api-headless-cms/types\";\nimport type { CacheKeyParams } from \"~/operations/entry/dataLoader/DataLoaderCache\";\nimport { DataLoaderCache } from \"~/operations/entry/dataLoader/DataLoaderCache\";\nimport type { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport type { DataLoaders } from \"~/operations/entry/dataLoader\";\nimport { getDataLoaderFactory } from \"~/operations/entry/dataLoader\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport type {\n DataLoadersHandlerInterface,\n DataLoadersHandlerInterfaceClearAllParams\n} from \"~/types\";\n\ninterface DataLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\" | \"modelId\">;\n ids: readonly string[];\n}\n\ninterface GetLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\" | \"modelId\">;\n}\n\ninterface DataLoadersHandlerParams {\n entity: Entity<any>;\n}\n\nexport class DataLoadersHandler implements DataLoadersHandlerInterface {\n private readonly entity: Entity<any>;\n private readonly cache: DataLoaderCache = new DataLoaderCache();\n\n public constructor(params: DataLoadersHandlerParams) {\n this.entity = params.entity;\n }\n\n public async getAllEntryRevisions(params: DataLoaderParams): Promise<CmsStorageEntry[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany(\"getAllEntryRevisions\", params, ids);\n }\n\n public async getRevisionById(params: DataLoaderParams): Promise<CmsStorageEntry[]> {\n return await this.loadMany(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany(\"getPublishedRevisionByEntryId\", params, ids);\n }\n\n public async getLatestRevisionByEntryId(params: DataLoaderParams): Promise<CmsStorageEntry[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany(\"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 locale: model.locale,\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 locale: model.locale\n });\n this.cache.setDataLoader(cacheParams, loader);\n return loader;\n }\n\n private async loadMany(\n loader: DataLoaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry[]> {\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?.model);\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,gBAAA,GAAAD,OAAA;AAGA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAmBO,MAAMI,kBAAkB,CAAwC;EAElDC,KAAK,GAAoB,IAAIC,gCAAe,CAAC,CAAC;EAExDC,WAAWA,CAACC,MAAgC,EAAE;IACjD,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;EAC/B;EAEA,MAAaC,oBAAoBA,CAACF,MAAwB,EAA8B;IACpF,MAAMG,GAAG,GAAGH,MAAM,CAACG,GAAG,CAACC,GAAG,CAACC,EAAE,IAAI;MAC7B,MAAM;QAAEA,EAAE,EAAEC;MAAQ,CAAC,GAAG,IAAAC,sBAAe,EAACF,EAAE,CAAC;MAC3C,OAAOC,OAAO;IAClB,CAAC,CAAC;IACF,OAAO,MAAM,IAAI,CAACE,QAAQ,CAAC,sBAAsB,EAAER,MAAM,EAAEG,GAAG,CAAC;EACnE;EAEA,MAAaM,eAAeA,CAACT,MAAwB,EAA8B;IAC/E,OAAO,MAAM,IAAI,CAACQ,QAAQ,CAAC,iBAAiB,EAAER,MAAM,EAAEA,MAAM,CAACG,GAAG,CAAC;EACrE;EAEA,MAAaO,6BAA6BA,CACt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W,CACjB,2DAA2D,EAC3D,4BAA4B,EAC5B;MACIZ,MAAM;MACNf,GAAG;MACHoB;IACJ,CACJ,CAAC;EACL;EAEOe,QAAQA,CAACtC,MAAkD,EAAQ;IACtE,IAAI,CAACH,KAAK,CAACyC,QAAQ,CAACtC,MAAM,EAAEc,KAAK,CAAC;EACtC;AACJ;AAACyB,OAAA,CAAA3C,kBAAA,GAAAA,kBAAA","ignoreList":[]}
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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AAI,IAAI,CAAC;oBACtC;oBAEJ,MAAM,IAAIC,MACN,yFACA,6BACA;wBACI,GAAGf,MAAM;wBACTQ;oBACJ;gBAER;gBACAK,IAAI,IAAI,IAAIC;gBACZ,OAAOD;YACX,GAAG,EAAE;QAEb,EAAE,OAAOI,IAAI;YACT,MAAM,IAAIF,MACNE,GAAG,OAAO,IAAI,sBACdA,GAAG,IAAI,IAAI,qBACX;gBACI,OAAOA;gBACP,GAAGjB,MAAM;gBACTQ;gBACAP;YACJ;QAER;QACA,MAAM,IAAIc,MACN,6DACA,8BACA;YACIP;YACAP;YACAU;QACJ;IAER;IAEO,SAASX,MAAkD,EAAQ;QACtE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAACA;IACxB;AACJ;AAEO,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,53 @@
1
+ import { createFeature } from "@webiny/feature/api/index.js";
2
+ import { DdbCreateEntry } from "./DdbCreateEntry.js";
3
+ import { DdbCreateEntryRevisionFrom } from "./DdbCreateEntryRevisionFrom.js";
4
+ import { DdbUpdateEntry } from "./DdbUpdateEntry.js";
5
+ import { DdbMoveEntry } from "./DdbMoveEntry.js";
6
+ import { DdbMoveToBin } from "./DdbMoveToBin.js";
7
+ import { DdbDeleteEntry } from "./DdbDeleteEntry.js";
8
+ import { DdbRestoreFromBin } from "./DdbRestoreFromBin.js";
9
+ import { DdbDeleteEntryRevision } from "./DdbDeleteEntryRevision.js";
10
+ import { DdbDeleteMultipleEntries } from "./DdbDeleteMultipleEntries.js";
11
+ import { DdbGetEntry } from "./DdbGetEntry.js";
12
+ import { DdbListEntries } from "./DdbListEntries.js";
13
+ import { DdbPublishEntry } from "./DdbPublishEntry.js";
14
+ import { DdbUnpublishEntry } from "./DdbUnpublishEntry.js";
15
+ import { DdbGetEntriesByIds } from "./DdbGetEntriesByIds.js";
16
+ import { DdbGetLatestEntriesByIds } from "./DdbGetLatestEntriesByIds.js";
17
+ import { DdbGetPublishedEntriesByIds } from "./DdbGetPublishedEntriesByIds.js";
18
+ import { DdbGetRevisions } from "./DdbGetRevisions.js";
19
+ import { DdbGetRevisionById } from "./DdbGetRevisionById.js";
20
+ import { DdbGetLatestRevisionByEntryId } from "./DdbGetLatestRevisionByEntryId.js";
21
+ import { DdbGetPublishedRevisionByEntryId } from "./DdbGetPublishedRevisionByEntryId.js";
22
+ import { DdbGetPreviousRevision } from "./DdbGetPreviousRevision.js";
23
+ import { DdbGetUniqueFieldValues } from "./DdbGetUniqueFieldValues.js";
24
+ const DdbEntryStorageOpsFeature = createFeature({
25
+ name: "cms.ddb.entryStorageOps",
26
+ register: (container)=>{
27
+ container.register(DdbCreateEntry);
28
+ container.register(DdbCreateEntryRevisionFrom);
29
+ container.register(DdbUpdateEntry);
30
+ container.register(DdbMoveEntry);
31
+ container.register(DdbMoveToBin);
32
+ container.register(DdbDeleteEntry);
33
+ container.register(DdbRestoreFromBin);
34
+ container.register(DdbDeleteEntryRevision);
35
+ container.register(DdbDeleteMultipleEntries);
36
+ container.register(DdbGetEntry);
37
+ container.register(DdbListEntries);
38
+ container.register(DdbPublishEntry);
39
+ container.register(DdbUnpublishEntry);
40
+ container.register(DdbGetEntriesByIds);
41
+ container.register(DdbGetLatestEntriesByIds);
42
+ container.register(DdbGetPublishedEntriesByIds);
43
+ container.register(DdbGetRevisions);
44
+ container.register(DdbGetRevisionById);
45
+ container.register(DdbGetLatestRevisionByEntryId);
46
+ container.register(DdbGetPublishedRevisionByEntryId);
47
+ container.register(DdbGetPreviousRevision);
48
+ container.register(DdbGetUniqueFieldValues);
49
+ }
50
+ });
51
+ export { DdbEntryStorageOpsFeature };
52
+
53
+ //# 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 { 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 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","DdbCreateEntry","DdbCreateEntryRevisionFrom","DdbUpdateEntry","DdbMoveEntry","DdbMoveToBin","DdbDeleteEntry","DdbRestoreFromBin","DdbDeleteEntryRevision","DdbDeleteMultipleEntries","DdbGetEntry","DdbListEntries","DdbPublishEntry","DdbUnpublishEntry","DdbGetEntriesByIds","DdbGetLatestEntriesByIds","DdbGetPublishedEntriesByIds","DdbGetRevisions","DdbGetRevisionById","DdbGetLatestRevisionByEntryId","DdbGetPublishedRevisionByEntryId","DdbGetPreviousRevision","DdbGetUniqueFieldValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwBO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAAUC,CAAAA;QACNA,UAAU,QAAQ,CAACC;QACnBD,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;IACvB;AACJ"}