@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
@@ -0,0 +1,37 @@
1
+ import error from "@webiny/error";
2
+ import { convertException } from "@webiny/utils";
3
+ import { CreateModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/CreateModelStorageOperation.js";
4
+ import { CmsDdbModelEntity } from "../../abstractions/CmsDdbModelEntity.js";
5
+ import { createKeys, createType } from "./keys.js";
6
+ class DdbCreateModelImpl {
7
+ constructor(entity){
8
+ this.entity = entity;
9
+ }
10
+ async execute(params) {
11
+ const { model } = params;
12
+ const keys = createKeys(model);
13
+ try {
14
+ await this.entity.put({
15
+ data: model,
16
+ ...keys,
17
+ TYPE: createType()
18
+ });
19
+ return model;
20
+ } catch (ex) {
21
+ throw new error("Could not create CMS Content Model.", "CREATE_MODEL_ERROR", {
22
+ error: convertException(ex),
23
+ model,
24
+ keys
25
+ });
26
+ }
27
+ }
28
+ }
29
+ const DdbCreateModel = CreateModelStorageOperation.createImplementation({
30
+ implementation: DdbCreateModelImpl,
31
+ dependencies: [
32
+ CmsDdbModelEntity
33
+ ]
34
+ });
35
+ export { DdbCreateModel };
36
+
37
+ //# sourceMappingURL=DdbCreateModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/model/DdbCreateModel.js","sources":["../../../src/operations/model/DdbCreateModel.ts"],"sourcesContent":["import type { CmsModelStorageOperationsCreateParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { convertException } from \"@webiny/utils\";\nimport { CreateModelStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/CreateModelStorageOperation.js\";\nimport { CmsDdbModelEntity } from \"~/abstractions/CmsDdbModelEntity.js\";\nimport { createKeys, createType } from \"./keys.js\";\n\nclass DdbCreateModelImpl implements CreateModelStorageOperation.Interface {\n constructor(private entity: CmsDdbModelEntity.Interface) {}\n\n async execute(params: CmsModelStorageOperationsCreateParams) {\n const { model } = params;\n const keys = createKeys(model);\n try {\n await this.entity.put({\n data: model,\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n throw new WebinyError(`Could not create CMS Content Model.`, \"CREATE_MODEL_ERROR\", {\n error: convertException(ex),\n model,\n keys\n });\n }\n }\n}\n\nexport const DdbCreateModel = CreateModelStorageOperation.createImplementation({\n implementation: DdbCreateModelImpl,\n dependencies: [CmsDdbModelEntity]\n});\n"],"names":["DdbCreateModelImpl","entity","params","model","keys","createKeys","createType","ex","WebinyError","convertException","DdbCreateModel","CreateModelStorageOperation","CmsDdbModelEntity"],"mappings":";;;;;AAOA,MAAMA;IACF,YAAoBC,MAAmC,CAAE;aAArCA,MAAM,GAANA;IAAsC;IAE1D,MAAM,QAAQC,MAA6C,EAAE;QACzD,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAClB,MAAME,OAAOC,WAAWF;QACxB,IAAI;YACA,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;gBAClB,MAAMA;gBACN,GAAGC,IAAI;gBACP,MAAME;YACV;YACA,OAAOH;QACX,EAAE,OAAOI,IAAI;YACT,MAAM,IAAIC,MAAY,uCAAuC,sBAAsB;gBAC/E,OAAOC,iBAAiBF;gBACxBJ;gBACAC;YACJ;QACJ;IACJ;AACJ;AAEO,MAAMM,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBX;IAChB,cAAc;QAACY;KAAkB;AACrC"}
@@ -0,0 +1,12 @@
1
+ import type { CmsModelStorageOperationsDeleteParams } from "@webiny/api-headless-cms/types/index.js";
2
+ import { DeleteModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js";
3
+ import { CmsDdbModelEntity } from "../../abstractions/CmsDdbModelEntity.js";
4
+ declare class DdbDeleteModelImpl implements DeleteModelStorageOperation.Interface {
5
+ private entity;
6
+ constructor(entity: CmsDdbModelEntity.Interface);
7
+ execute(params: CmsModelStorageOperationsDeleteParams): Promise<void>;
8
+ }
9
+ export declare const DdbDeleteModel: typeof DdbDeleteModelImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js").IDeleteModelStorageOperation>;
11
+ };
12
+ export {};
@@ -0,0 +1,31 @@
1
+ import error from "@webiny/error";
2
+ import { DeleteModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js";
3
+ import { CmsDdbModelEntity } from "../../abstractions/CmsDdbModelEntity.js";
4
+ import { createKeys } from "./keys.js";
5
+ class DdbDeleteModelImpl {
6
+ constructor(entity){
7
+ this.entity = entity;
8
+ }
9
+ async execute(params) {
10
+ const { model } = params;
11
+ const keys = createKeys(model);
12
+ try {
13
+ await this.entity.delete(keys);
14
+ } catch (ex) {
15
+ throw new error(ex.message || "Could not delete model.", ex.code || "MODEL_DELETE_ERROR", {
16
+ error: ex,
17
+ model,
18
+ keys
19
+ });
20
+ }
21
+ }
22
+ }
23
+ const DdbDeleteModel = DeleteModelStorageOperation.createImplementation({
24
+ implementation: DdbDeleteModelImpl,
25
+ dependencies: [
26
+ CmsDdbModelEntity
27
+ ]
28
+ });
29
+ export { DdbDeleteModel };
30
+
31
+ //# sourceMappingURL=DdbDeleteModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/model/DdbDeleteModel.js","sources":["../../../src/operations/model/DdbDeleteModel.ts"],"sourcesContent":["import type { CmsModelStorageOperationsDeleteParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { DeleteModelStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/DeleteModelStorageOperation.js\";\nimport { CmsDdbModelEntity } from \"~/abstractions/CmsDdbModelEntity.js\";\nimport { createKeys } from \"./keys.js\";\n\nclass DdbDeleteModelImpl implements DeleteModelStorageOperation.Interface {\n constructor(private entity: CmsDdbModelEntity.Interface) {}\n\n async execute(params: CmsModelStorageOperationsDeleteParams) {\n const { model } = params;\n const keys = createKeys(model);\n try {\n await this.entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete model.\",\n ex.code || \"MODEL_DELETE_ERROR\",\n { error: ex, model, keys }\n );\n }\n }\n}\n\nexport const DdbDeleteModel = DeleteModelStorageOperation.createImplementation({\n implementation: DdbDeleteModelImpl,\n dependencies: [CmsDdbModelEntity]\n});\n"],"names":["DdbDeleteModelImpl","entity","params","model","keys","createKeys","ex","WebinyError","DdbDeleteModel","DeleteModelStorageOperation","CmsDdbModelEntity"],"mappings":";;;;AAMA,MAAMA;IACF,YAAoBC,MAAmC,CAAE;aAArCA,MAAM,GAANA;IAAsC;IAE1D,MAAM,QAAQC,MAA6C,EAAE;QACzD,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAClB,MAAME,OAAOC,WAAWF;QACxB,IAAI;YACA,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAACC;QAC7B,EAAE,OAAOE,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,2BACdA,GAAG,IAAI,IAAI,sBACX;gBAAE,OAAOA;gBAAIH;gBAAOC;YAAK;QAEjC;IACJ;AACJ;AAEO,MAAMI,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBT;IAChB,cAAc;QAACU;KAAkB;AACrC"}
@@ -0,0 +1,12 @@
1
+ import type { CmsModelStorageOperationsGetParams } from "@webiny/api-headless-cms/types/index.js";
2
+ import { GetModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/GetModelStorageOperation.js";
3
+ import { CmsDdbModelEntity } from "../../abstractions/CmsDdbModelEntity.js";
4
+ declare class DdbGetModelImpl implements GetModelStorageOperation.Interface {
5
+ private entity;
6
+ constructor(entity: CmsDdbModelEntity.Interface);
7
+ execute(params: CmsModelStorageOperationsGetParams): Promise<import("@webiny/api-headless-cms/types/model.js").StorageCmsModel | null>;
8
+ }
9
+ export declare const DdbGetModel: typeof DdbGetModelImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/GetModelStorageOperation.js").IGetModelStorageOperation>;
11
+ };
12
+ export {};
@@ -0,0 +1,30 @@
1
+ import error from "@webiny/error";
2
+ import { GetModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/GetModelStorageOperation.js";
3
+ import { CmsDdbModelEntity } from "../../abstractions/CmsDdbModelEntity.js";
4
+ import { createKeys } from "./keys.js";
5
+ class DdbGetModelImpl {
6
+ constructor(entity){
7
+ this.entity = entity;
8
+ }
9
+ async execute(params) {
10
+ const keys = createKeys(params);
11
+ try {
12
+ const result = await this.entity.get(keys);
13
+ return result?.data || null;
14
+ } catch (ex) {
15
+ throw new error(ex.message || "Could not get model.", ex.code || "MODEL_GET_ERROR", {
16
+ error: ex,
17
+ keys
18
+ });
19
+ }
20
+ }
21
+ }
22
+ const DdbGetModel = GetModelStorageOperation.createImplementation({
23
+ implementation: DdbGetModelImpl,
24
+ dependencies: [
25
+ CmsDdbModelEntity
26
+ ]
27
+ });
28
+ export { DdbGetModel };
29
+
30
+ //# sourceMappingURL=DdbGetModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/model/DdbGetModel.js","sources":["../../../src/operations/model/DdbGetModel.ts"],"sourcesContent":["import type { CmsModelStorageOperationsGetParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { GetModelStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/GetModelStorageOperation.js\";\nimport { CmsDdbModelEntity } from \"~/abstractions/CmsDdbModelEntity.js\";\nimport { createKeys } from \"./keys.js\";\n\nclass DdbGetModelImpl implements GetModelStorageOperation.Interface {\n constructor(private entity: CmsDdbModelEntity.Interface) {}\n\n async execute(params: CmsModelStorageOperationsGetParams) {\n const keys = createKeys(params);\n try {\n const result = await this.entity.get(keys);\n return result?.data || null;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not get model.\",\n ex.code || \"MODEL_GET_ERROR\",\n { error: ex, keys }\n );\n }\n }\n}\n\nexport const DdbGetModel = GetModelStorageOperation.createImplementation({\n implementation: DdbGetModelImpl,\n dependencies: [CmsDdbModelEntity]\n});\n"],"names":["DdbGetModelImpl","entity","params","keys","createKeys","result","ex","WebinyError","DdbGetModel","GetModelStorageOperation","CmsDdbModelEntity"],"mappings":";;;;AAMA,MAAMA;IACF,YAAoBC,MAAmC,CAAE;aAArCA,MAAM,GAANA;IAAsC;IAE1D,MAAM,QAAQC,MAA0C,EAAE;QACtD,MAAMC,OAAOC,WAAWF;QACxB,IAAI;YACA,MAAMG,SAAS,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAACF;YACrC,OAAOE,QAAQ,QAAQ;QAC3B,EAAE,OAAOC,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,wBACdA,GAAG,IAAI,IAAI,mBACX;gBAAE,OAAOA;gBAAIH;YAAK;QAE1B;IACJ;AACJ;AAEO,MAAMK,cAAcC,yBAAyB,oBAAoB,CAAC;IACrE,gBAAgBT;IAChB,cAAc;QAACU;KAAkB;AACrC"}
@@ -0,0 +1,12 @@
1
+ import type { CmsModelStorageOperationsListParams } from "@webiny/api-headless-cms/types/index.js";
2
+ import { ListModelsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/ListModelsStorageOperation.js";
3
+ import { CmsDdbModelEntity } from "../../abstractions/CmsDdbModelEntity.js";
4
+ declare class DdbListModelsImpl implements ListModelsStorageOperation.Interface {
5
+ private entity;
6
+ constructor(entity: CmsDdbModelEntity.Interface);
7
+ execute(params: CmsModelStorageOperationsListParams): Promise<import("@webiny/api-headless-cms/types/model.js").StorageCmsModel[]>;
8
+ }
9
+ export declare const DdbListModels: typeof DdbListModelsImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/ListModelsStorageOperation.js").IListModelsStorageOperation>;
11
+ };
12
+ export {};
@@ -0,0 +1,36 @@
1
+ import error from "@webiny/error";
2
+ import { ListModelsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/ListModelsStorageOperation.js";
3
+ import { CmsDdbModelEntity } from "../../abstractions/CmsDdbModelEntity.js";
4
+ import { createPartitionKey } from "./keys.js";
5
+ class DdbListModelsImpl {
6
+ constructor(entity){
7
+ this.entity = entity;
8
+ }
9
+ async execute(params) {
10
+ const { where } = params;
11
+ const partitionKey = createPartitionKey(where);
12
+ try {
13
+ const result = await this.entity.queryAll({
14
+ partitionKey,
15
+ options: {
16
+ gte: " "
17
+ }
18
+ });
19
+ return result.map((item)=>item.data);
20
+ } catch (ex) {
21
+ throw new error(ex.message || "Could not list models.", ex.code || "MODEL_LIST_ERROR", {
22
+ error: ex,
23
+ partitionKey
24
+ });
25
+ }
26
+ }
27
+ }
28
+ const DdbListModels = ListModelsStorageOperation.createImplementation({
29
+ implementation: DdbListModelsImpl,
30
+ dependencies: [
31
+ CmsDdbModelEntity
32
+ ]
33
+ });
34
+ export { DdbListModels };
35
+
36
+ //# sourceMappingURL=DdbListModels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/model/DdbListModels.js","sources":["../../../src/operations/model/DdbListModels.ts"],"sourcesContent":["import type { CmsModelStorageOperationsListParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { ListModelsStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/ListModelsStorageOperation.js\";\nimport { CmsDdbModelEntity } from \"~/abstractions/CmsDdbModelEntity.js\";\nimport { createPartitionKey } from \"./keys.js\";\n\nclass DdbListModelsImpl implements ListModelsStorageOperation.Interface {\n constructor(private entity: CmsDdbModelEntity.Interface) {}\n\n async execute(params: CmsModelStorageOperationsListParams) {\n const { where } = params;\n const partitionKey = createPartitionKey(where);\n try {\n const result = await this.entity.queryAll({\n partitionKey,\n options: { gte: \" \" }\n });\n return result.map(item => item.data);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list models.\",\n ex.code || \"MODEL_LIST_ERROR\",\n { error: ex, partitionKey }\n );\n }\n }\n}\n\nexport const DdbListModels = ListModelsStorageOperation.createImplementation({\n implementation: DdbListModelsImpl,\n dependencies: [CmsDdbModelEntity]\n});\n"],"names":["DdbListModelsImpl","entity","params","where","partitionKey","createPartitionKey","result","item","ex","WebinyError","DdbListModels","ListModelsStorageOperation","CmsDdbModelEntity"],"mappings":";;;;AAMA,MAAMA;IACF,YAAoBC,MAAmC,CAAE;aAArCA,MAAM,GAANA;IAAsC;IAE1D,MAAM,QAAQC,MAA2C,EAAE;QACvD,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAClB,MAAME,eAAeC,mBAAmBF;QACxC,IAAI;YACA,MAAMG,SAAS,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;gBACtCF;gBACA,SAAS;oBAAE,KAAK;gBAAI;YACxB;YACA,OAAOE,OAAO,GAAG,CAACC,CAAAA,OAAQA,KAAK,IAAI;QACvC,EAAE,OAAOC,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,0BACdA,GAAG,IAAI,IAAI,oBACX;gBAAE,OAAOA;gBAAIJ;YAAa;QAElC;IACJ;AACJ;AAEO,MAAMM,gBAAgBC,2BAA2B,oBAAoB,CAAC;IACzE,gBAAgBX;IAChB,cAAc;QAACY;KAAkB;AACrC"}
@@ -0,0 +1,12 @@
1
+ import type { CmsModelStorageOperationsUpdateParams } from "@webiny/api-headless-cms/types/index.js";
2
+ import { UpdateModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/UpdateModelStorageOperation.js";
3
+ import { CmsDdbModelEntity } from "../../abstractions/CmsDdbModelEntity.js";
4
+ declare class DdbUpdateModelImpl implements UpdateModelStorageOperation.Interface {
5
+ private entity;
6
+ constructor(entity: CmsDdbModelEntity.Interface);
7
+ execute(params: CmsModelStorageOperationsUpdateParams): Promise<import("@webiny/api-headless-cms/types/model.js").StorageCmsModel>;
8
+ }
9
+ export declare const DdbUpdateModel: typeof DdbUpdateModelImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/UpdateModelStorageOperation.js").IUpdateModelStorageOperation>;
11
+ };
12
+ export {};
@@ -0,0 +1,36 @@
1
+ import error from "@webiny/error";
2
+ import { UpdateModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/UpdateModelStorageOperation.js";
3
+ import { CmsDdbModelEntity } from "../../abstractions/CmsDdbModelEntity.js";
4
+ import { createKeys, createType } from "./keys.js";
5
+ class DdbUpdateModelImpl {
6
+ constructor(entity){
7
+ this.entity = entity;
8
+ }
9
+ async execute(params) {
10
+ const { model } = params;
11
+ const keys = createKeys(model);
12
+ try {
13
+ await this.entity.put({
14
+ data: model,
15
+ ...keys,
16
+ TYPE: createType()
17
+ });
18
+ return model;
19
+ } catch (ex) {
20
+ throw new error(ex.message || "Could not update model.", ex.code || "MODEL_UPDATE_ERROR", {
21
+ error: ex,
22
+ model,
23
+ keys
24
+ });
25
+ }
26
+ }
27
+ }
28
+ const DdbUpdateModel = UpdateModelStorageOperation.createImplementation({
29
+ implementation: DdbUpdateModelImpl,
30
+ dependencies: [
31
+ CmsDdbModelEntity
32
+ ]
33
+ });
34
+ export { DdbUpdateModel };
35
+
36
+ //# sourceMappingURL=DdbUpdateModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/model/DdbUpdateModel.js","sources":["../../../src/operations/model/DdbUpdateModel.ts"],"sourcesContent":["import type { CmsModelStorageOperationsUpdateParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { UpdateModelStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/model/UpdateModelStorageOperation.js\";\nimport { CmsDdbModelEntity } from \"~/abstractions/CmsDdbModelEntity.js\";\nimport { createKeys, createType } from \"./keys.js\";\n\nclass DdbUpdateModelImpl implements UpdateModelStorageOperation.Interface {\n constructor(private entity: CmsDdbModelEntity.Interface) {}\n\n async execute(params: CmsModelStorageOperationsUpdateParams) {\n const { model } = params;\n const keys = createKeys(model);\n try {\n await this.entity.put({\n data: model,\n ...keys,\n TYPE: createType()\n });\n return model;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update model.\",\n ex.code || \"MODEL_UPDATE_ERROR\",\n { error: ex, model, keys }\n );\n }\n }\n}\n\nexport const DdbUpdateModel = UpdateModelStorageOperation.createImplementation({\n implementation: DdbUpdateModelImpl,\n dependencies: [CmsDdbModelEntity]\n});\n"],"names":["DdbUpdateModelImpl","entity","params","model","keys","createKeys","createType","ex","WebinyError","DdbUpdateModel","UpdateModelStorageOperation","CmsDdbModelEntity"],"mappings":";;;;AAMA,MAAMA;IACF,YAAoBC,MAAmC,CAAE;aAArCA,MAAM,GAANA;IAAsC;IAE1D,MAAM,QAAQC,MAA6C,EAAE;QACzD,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAClB,MAAME,OAAOC,WAAWF;QACxB,IAAI;YACA,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;gBAClB,MAAMA;gBACN,GAAGC,IAAI;gBACP,MAAME;YACV;YACA,OAAOH;QACX,EAAE,OAAOI,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,2BACdA,GAAG,IAAI,IAAI,sBACX;gBAAE,OAAOA;gBAAIJ;gBAAOC;YAAK;QAEjC;IACJ;AACJ;AAEO,MAAMK,iBAAiBC,4BAA4B,oBAAoB,CAAC;IAC3E,gBAAgBV;IAChB,cAAc;QAACW;KAAkB;AACrC"}
@@ -0,0 +1,4 @@
1
+ export declare const DdbModelStorageOpsFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,19 @@
1
+ import { createFeature } from "@webiny/feature/api/index.js";
2
+ import { DdbGetModel } from "./DdbGetModel.js";
3
+ import { DdbListModels } from "./DdbListModels.js";
4
+ import { DdbCreateModel } from "./DdbCreateModel.js";
5
+ import { DdbUpdateModel } from "./DdbUpdateModel.js";
6
+ import { DdbDeleteModel } from "./DdbDeleteModel.js";
7
+ const DdbModelStorageOpsFeature = createFeature({
8
+ name: "cms.ddb.modelStorageOps",
9
+ register: (container)=>{
10
+ container.register(DdbGetModel);
11
+ container.register(DdbListModels);
12
+ container.register(DdbCreateModel);
13
+ container.register(DdbUpdateModel);
14
+ container.register(DdbDeleteModel);
15
+ }
16
+ });
17
+ export { DdbModelStorageOpsFeature };
18
+
19
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/model/feature.js","sources":["../../../src/operations/model/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { DdbGetModel } from \"./DdbGetModel.js\";\nimport { DdbListModels } from \"./DdbListModels.js\";\nimport { DdbCreateModel } from \"./DdbCreateModel.js\";\nimport { DdbUpdateModel } from \"./DdbUpdateModel.js\";\nimport { DdbDeleteModel } from \"./DdbDeleteModel.js\";\n\nexport const DdbModelStorageOpsFeature = createFeature({\n name: \"cms.ddb.modelStorageOps\",\n register: container => {\n container.register(DdbGetModel);\n container.register(DdbListModels);\n container.register(DdbCreateModel);\n container.register(DdbUpdateModel);\n container.register(DdbDeleteModel);\n }\n});\n"],"names":["DdbModelStorageOpsFeature","createFeature","container","DdbGetModel","DdbListModels","DdbCreateModel","DdbUpdateModel","DdbDeleteModel"],"mappings":";;;;;;AAOO,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;IACvB;AACJ"}
@@ -0,0 +1,15 @@
1
+ interface PartitionKeysParams {
2
+ tenant: string;
3
+ }
4
+ export declare const createPartitionKey: (params: PartitionKeysParams) => string;
5
+ interface SortKeyParams {
6
+ modelId: string;
7
+ }
8
+ interface Keys {
9
+ PK: string;
10
+ SK: string;
11
+ GSI_TENANT: string;
12
+ }
13
+ export declare const createKeys: (params: PartitionKeysParams & SortKeyParams) => Keys;
14
+ export declare const createType: () => string;
15
+ export {};
@@ -0,0 +1,16 @@
1
+ import error from "@webiny/error";
2
+ const createPartitionKey = (params)=>{
3
+ const { tenant } = params;
4
+ if (!tenant) throw new error("Missing tenant variable when creating model partitionKey.");
5
+ return `T#${tenant}#CMS#CM`;
6
+ };
7
+ const createSortKey = (params)=>params.modelId;
8
+ const createKeys = (params)=>({
9
+ PK: createPartitionKey(params),
10
+ SK: createSortKey(params),
11
+ GSI_TENANT: params.tenant
12
+ });
13
+ const createType = ()=>"cms.model";
14
+ export { createKeys, createPartitionKey, createType };
15
+
16
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/model/keys.js","sources":["../../../src/operations/model/keys.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\ninterface PartitionKeysParams {\n tenant: string;\n}\n\nexport const createPartitionKey = (params: PartitionKeysParams): string => {\n const { tenant } = params;\n if (!tenant) {\n throw new WebinyError(`Missing tenant variable when creating model partitionKey.`);\n }\n return `T#${tenant}#CMS#CM`;\n};\n\ninterface SortKeyParams {\n modelId: string;\n}\n\nconst createSortKey = (params: SortKeyParams): string => {\n return params.modelId;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n GSI_TENANT: string;\n}\n\nexport const createKeys = (params: PartitionKeysParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKey(params),\n GSI_TENANT: params.tenant\n };\n};\n\nexport const createType = (): string => {\n return \"cms.model\";\n};\n"],"names":["createPartitionKey","params","tenant","WebinyError","createSortKey","createKeys","createType"],"mappings":";AAMO,MAAMA,qBAAqB,CAACC;IAC/B,MAAM,EAAEC,MAAM,EAAE,GAAGD;IACnB,IAAI,CAACC,QACD,MAAM,IAAIC,MAAY;IAE1B,OAAO,CAAC,EAAE,EAAED,OAAO,OAAO,CAAC;AAC/B;AAMA,MAAME,gBAAgB,CAACH,SACZA,OAAO,OAAO;AASlB,MAAMI,aAAa,CAACJ,SAChB;QACH,IAAID,mBAAmBC;QACvB,IAAIG,cAAcH;QAClB,YAAYA,OAAO,MAAM;IAC7B;AAGG,MAAMK,aAAa,IACf"}
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-ddb",
3
- "version": "0.0.0-unstable.eb196ccd2f",
4
- "main": "index.js",
3
+ "version": "0.0.0-unstable.eb81deee7e",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
5
9
  "keywords": [
6
10
  "@webiny/api-headless-cms",
7
11
  "storage-operations",
@@ -22,34 +26,32 @@
22
26
  ],
23
27
  "license": "MIT",
24
28
  "dependencies": {
25
- "@webiny/api": "0.0.0-unstable.eb196ccd2f",
26
- "@webiny/api-headless-cms": "0.0.0-unstable.eb196ccd2f",
27
- "@webiny/aws-sdk": "0.0.0-unstable.eb196ccd2f",
28
- "@webiny/db-dynamodb": "0.0.0-unstable.eb196ccd2f",
29
- "@webiny/error": "0.0.0-unstable.eb196ccd2f",
30
- "@webiny/handler-db": "0.0.0-unstable.eb196ccd2f",
31
- "@webiny/utils": "0.0.0-unstable.eb196ccd2f",
32
- "dataloader": "2.2.3",
33
- "dot-object": "2.1.5",
34
- "dot-prop": "6.0.1",
35
- "lodash": "4.17.21"
29
+ "@webiny/api": "0.0.0-unstable.eb81deee7e",
30
+ "@webiny/api-headless-cms": "0.0.0-unstable.eb81deee7e",
31
+ "@webiny/api-headless-cms-storage": "0.0.0-unstable.eb81deee7e",
32
+ "@webiny/aws-sdk": "0.0.0-unstable.eb81deee7e",
33
+ "@webiny/db-dynamodb": "0.0.0-unstable.eb81deee7e",
34
+ "@webiny/db-utils": "0.0.0-unstable.eb81deee7e",
35
+ "@webiny/error": "0.0.0-unstable.eb81deee7e",
36
+ "@webiny/feature": "0.0.0-unstable.eb81deee7e",
37
+ "@webiny/handler": "0.0.0-unstable.eb81deee7e",
38
+ "@webiny/utils": "0.0.0-unstable.eb81deee7e",
39
+ "dataloader": "2.2.3"
36
40
  },
37
41
  "devDependencies": {
38
- "@types/dot-object": "2.1.6",
39
42
  "@types/jsonpack": "1.1.6",
40
- "@webiny/plugins": "0.0.0-unstable.eb196ccd2f",
41
- "@webiny/project-utils": "0.0.0-unstable.eb196ccd2f",
42
- "jest": "29.7.0",
43
+ "@webiny/api-core": "0.0.0-unstable.eb81deee7e",
44
+ "@webiny/build-tools": "0.0.0-unstable.eb81deee7e",
45
+ "@webiny/di": "1.1.0",
43
46
  "jest-dynalite": "3.6.1",
44
- "typescript": "5.3.3"
47
+ "typescript": "7.0.2",
48
+ "vitest": "4.1.11"
45
49
  },
46
50
  "publishConfig": {
47
- "access": "public",
48
- "directory": "dist"
49
- },
50
- "scripts": {
51
- "build": "node ../cli/bin.js run build",
52
- "watch": "node ../cli/bin.js run watch"
51
+ "access": "public"
53
52
  },
54
- "gitHead": "eb196ccd2f32296e10f7add6dd7220d4e3abece4"
53
+ "gitHead": "b8aec8a1be3f25c3b428b357fe1e352c7cbff9ae",
54
+ "webiny": {
55
+ "publishFrom": "dist"
56
+ }
55
57
  }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Per-request half of the DynamoDB CMS storage: the storage operations and everything they keep state
3
+ * in. Register it in the request (child) container, after `HeadlessCmsDdbFeature` is in the root.
4
+ *
5
+ * - @webiny/di applies a decorator only if it sits in the same container as the registration it
6
+ * decorates, or in one of that container's parents. Extensions register their decorators in the
7
+ * request container, so with the storage operations in the root, an extension decorator on one of
8
+ * them (e.g. `ListModelsStorageOperation`) would be skipped without an error. Registering them
9
+ * here puts the decorator and its target in the same container.
10
+ * - The DataLoader cache must live for one request. A root singleton outlives the request and keeps
11
+ * serving the entries it read first.
12
+ * - The filter registries are mutable; a root instance would collect every request's registrations.
13
+ */
14
+ export declare const HeadlessCmsDdbRequestFeature: {
15
+ name: string;
16
+ register(container: import("@webiny/di").Container): void;
17
+ };
@@ -0,0 +1,19 @@
1
+ import { createFeature } from "@webiny/feature/api/index.js";
2
+ import { FilterRegistriesFeature } from "@webiny/api-headless-cms-storage";
3
+ import { DdbGroupStorageOpsFeature } from "./operations/group/feature.js";
4
+ import { DdbModelStorageOpsFeature } from "./operations/model/feature.js";
5
+ import { DdbEntryStorageOpsFeature } from "./operations/entry/feature.js";
6
+ import { DataLoadersHandler } from "./operations/entry/dataLoaders.js";
7
+ const HeadlessCmsDdbRequestFeature = createFeature({
8
+ name: "cms.storageOperations.ddb.request",
9
+ register: (container)=>{
10
+ FilterRegistriesFeature.register(container);
11
+ DdbGroupStorageOpsFeature.register(container);
12
+ DdbModelStorageOpsFeature.register(container);
13
+ DdbEntryStorageOpsFeature.register(container);
14
+ container.register(DataLoadersHandler).inSingletonScope();
15
+ }
16
+ });
17
+ export { HeadlessCmsDdbRequestFeature };
18
+
19
+ //# sourceMappingURL=requestFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestFeature.js","sources":["../src/requestFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { FilterRegistriesFeature } from \"@webiny/api-headless-cms-storage\";\nimport { DdbGroupStorageOpsFeature } from \"~/operations/group/feature.js\";\nimport { DdbModelStorageOpsFeature } from \"~/operations/model/feature.js\";\nimport { DdbEntryStorageOpsFeature } from \"~/operations/entry/feature.js\";\nimport { DataLoadersHandler } from \"~/operations/entry/dataLoaders.js\";\n\n/**\n * Per-request half of the DynamoDB CMS storage: the storage operations and everything they keep state\n * in. Register it in the request (child) container, after `HeadlessCmsDdbFeature` is in the root.\n *\n * - @webiny/di applies a decorator only if it sits in the same container as the registration it\n * decorates, or in one of that container's parents. Extensions register their decorators in the\n * request container, so with the storage operations in the root, an extension decorator on one of\n * them (e.g. `ListModelsStorageOperation`) would be skipped without an error. Registering them\n * here puts the decorator and its target in the same container.\n * - The DataLoader cache must live for one request. A root singleton outlives the request and keeps\n * serving the entries it read first.\n * - The filter registries are mutable; a root instance would collect every request's registrations.\n */\nexport const HeadlessCmsDdbRequestFeature = createFeature({\n name: \"cms.storageOperations.ddb.request\",\n register: container => {\n FilterRegistriesFeature.register(container);\n\n DdbGroupStorageOpsFeature.register(container);\n DdbModelStorageOpsFeature.register(container);\n DdbEntryStorageOpsFeature.register(container);\n\n container.register(DataLoadersHandler).inSingletonScope();\n }\n});\n"],"names":["HeadlessCmsDdbRequestFeature","createFeature","container","FilterRegistriesFeature","DdbGroupStorageOpsFeature","DdbModelStorageOpsFeature","DdbEntryStorageOpsFeature","DataLoadersHandler"],"mappings":";;;;;;AAoBO,MAAMA,+BAA+BC,cAAc;IACtD,MAAM;IACN,UAAUC,CAAAA;QACNC,wBAAwB,QAAQ,CAACD;QAEjCE,0BAA0B,QAAQ,CAACF;QACnCG,0BAA0B,QAAQ,CAACH;QACnCI,0BAA0B,QAAQ,CAACJ;QAEnCA,UAAU,QAAQ,CAACK,oBAAoB,gBAAgB;IAC3D;AACJ"}
package/types.d.ts CHANGED
@@ -1,60 +1,20 @@
1
- import type { Plugin } from "@webiny/plugins/types";
2
- import type { CmsEntryStorageOperations as BaseCmsEntryStorageOperations, CmsModel, CmsModelField, HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations } from "@webiny/api-headless-cms/types";
3
- import type { TableConstructor } from "@webiny/db-dynamodb/toolbox";
4
- import type { AttributeDefinition } from "@webiny/db-dynamodb/toolbox";
5
- import type { DynamoDBDocument } from "@webiny/aws-sdk/client-dynamodb";
6
- import type { Entity, Table } from "@webiny/db-dynamodb/toolbox";
7
- interface CmsFieldFilterValueTransformParams {
8
- /**
9
- * A field which value we are transforming.
10
- */
11
- field: Partial<CmsModelField> & Pick<CmsModelField, "id" | "storageId" | "fieldId" | "settings">;
12
- value: any;
13
- }
14
- export interface CmsFieldFilterValueTransformPlugin extends Plugin {
15
- /**
16
- * A plugin type.
17
- */
18
- type: "cms-field-filter-value-transform";
19
- /**
20
- * A field type this plugin is for.
21
- */
22
- fieldType: string;
23
- /**
24
- * Transform method which expect field definition and value to transform.
25
- */
26
- transform: (params: CmsFieldFilterValueTransformParams) => any;
27
- }
28
- export type Attributes = Record<string, AttributeDefinition>;
1
+ import type { CmsEntryValues, CmsModel, CmsStorageEntry } from "@webiny/api-headless-cms/types/index.js";
29
2
  export declare enum ENTITIES {
30
- SYSTEM = "CmsSystem",
31
3
  GROUPS = "CmsGroups",
32
4
  MODELS = "CmsModels",
33
5
  ENTRIES = "CmsEntries"
34
6
  }
35
- export interface TableModifier {
36
- (table: TableConstructor<string, string, string>): TableConstructor<string, string, string>;
37
- }
38
- export interface StorageOperationsFactoryParams {
39
- documentClient: DynamoDBDocument;
40
- table?: TableModifier;
41
- attributes?: Record<ENTITIES, Attributes>;
42
- plugins?: Plugin[] | Plugin[][];
43
- }
44
- export interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {
45
- getTable: () => Table<string, string, string>;
46
- getEntities: () => Record<"system" | "groups" | "models" | "entries", Entity<any>>;
47
- }
48
- export interface StorageOperationsFactory {
49
- (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;
50
- }
51
- export interface CmsEntryStorageOperations extends BaseCmsEntryStorageOperations {
52
- dataLoaders: DataLoadersHandlerInterface;
53
- }
54
7
  export interface DataLoadersHandlerInterfaceClearAllParams {
55
- model: Pick<CmsModel, "tenant" | "locale">;
8
+ tenant: string;
9
+ }
10
+ export interface DataLoadersHandlerDataLoaderParams {
11
+ model: Pick<CmsModel, "tenant" | "modelId">;
12
+ ids: readonly string[];
56
13
  }
57
- export interface DataLoadersHandlerInterface {
14
+ export interface IDataLoadersHandler {
15
+ getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(params: DataLoadersHandlerDataLoaderParams): Promise<CmsStorageEntry<T>[]>;
16
+ getRevisionById<T extends CmsEntryValues = CmsEntryValues>(params: DataLoadersHandlerDataLoaderParams): Promise<CmsStorageEntry<T>[]>;
17
+ getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(params: DataLoadersHandlerDataLoaderParams): Promise<CmsStorageEntry<T>[]>;
18
+ getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(params: DataLoadersHandlerDataLoaderParams): Promise<CmsStorageEntry<T>[]>;
58
19
  clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;
59
20
  }
60
- export {};
package/types.js CHANGED
@@ -1,15 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ENTITIES = void 0;
7
- let ENTITIES = exports.ENTITIES = /*#__PURE__*/function (ENTITIES) {
8
- ENTITIES["SYSTEM"] = "CmsSystem";
9
- ENTITIES["GROUPS"] = "CmsGroups";
10
- ENTITIES["MODELS"] = "CmsModels";
11
- ENTITIES["ENTRIES"] = "CmsEntries";
12
- return ENTITIES;
1
+ var types_ENTITIES = /*#__PURE__*/ function(ENTITIES) {
2
+ ENTITIES["GROUPS"] = "CmsGroups";
3
+ ENTITIES["MODELS"] = "CmsModels";
4
+ ENTITIES["ENTRIES"] = "CmsEntries";
5
+ return ENTITIES;
13
6
  }({});
7
+ export { types_ENTITIES as ENTITIES };
14
8
 
15
9
  //# sourceMappingURL=types.js.map
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ENTITIES","exports"],"sources":["types.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types\";\nimport type {\n CmsEntryStorageOperations as BaseCmsEntryStorageOperations,\n CmsModel,\n CmsModelField,\n HeadlessCmsStorageOperations as BaseHeadlessCmsStorageOperations\n} from \"@webiny/api-headless-cms/types\";\nimport type { TableConstructor } from \"@webiny/db-dynamodb/toolbox\";\nimport type { AttributeDefinition } from \"@webiny/db-dynamodb/toolbox\";\nimport type { DynamoDBDocument } from \"@webiny/aws-sdk/client-dynamodb\";\nimport type { Entity, Table } from \"@webiny/db-dynamodb/toolbox\";\n\ninterface CmsFieldFilterValueTransformParams {\n /**\n * A field which value we are transforming.\n */\n field: Partial<CmsModelField> &\n Pick<CmsModelField, \"id\" | \"storageId\" | \"fieldId\" | \"settings\">;\n value: any;\n}\n\nexport interface CmsFieldFilterValueTransformPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-field-filter-value-transform\";\n /**\n * A field type this plugin is for.\n */\n fieldType: string;\n /**\n * Transform method which expect field definition and value to transform.\n */\n transform: (params: CmsFieldFilterValueTransformParams) => any;\n}\n\nexport type Attributes = Record<string, AttributeDefinition>;\n\nexport enum ENTITIES {\n SYSTEM = \"CmsSystem\",\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\"\n}\n\nexport interface TableModifier {\n (table: TableConstructor<string, string, string>): TableConstructor<string, string, string>;\n}\n\nexport interface StorageOperationsFactoryParams {\n documentClient: DynamoDBDocument;\n table?: TableModifier;\n attributes?: Record<ENTITIES, Attributes>;\n plugins?: Plugin[] | Plugin[][];\n}\n\nexport interface HeadlessCmsStorageOperations extends BaseHeadlessCmsStorageOperations {\n getTable: () => Table<string, string, string>;\n getEntities: () => Record<\"system\" | \"groups\" | \"models\" | \"entries\", Entity<any>>;\n}\n\nexport interface StorageOperationsFactory {\n (params: StorageOperationsFactoryParams): HeadlessCmsStorageOperations;\n}\n\nexport interface CmsEntryStorageOperations extends BaseCmsEntryStorageOperations {\n dataLoaders: DataLoadersHandlerInterface;\n}\n\nexport interface DataLoadersHandlerInterfaceClearAllParams {\n model: Pick<CmsModel, \"tenant\" | \"locale\">;\n}\nexport interface DataLoadersHandlerInterface {\n clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;\n}\n"],"mappings":";;;;;;IAsCYA,QAAQ,GAAAC,OAAA,CAAAD,QAAA,0BAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAARA,QAAQ;EAAA,OAARA,QAAQ;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type {\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\n\nexport enum ENTITIES {\n GROUPS = \"CmsGroups\",\n MODELS = \"CmsModels\",\n ENTRIES = \"CmsEntries\"\n}\n\nexport interface DataLoadersHandlerInterfaceClearAllParams {\n tenant: string;\n}\n\nexport interface DataLoadersHandlerDataLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n ids: readonly string[];\n}\n\nexport interface IDataLoadersHandler {\n getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoadersHandlerDataLoaderParams\n ): Promise<CmsStorageEntry<T>[]>;\n getRevisionById<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoadersHandlerDataLoaderParams\n ): Promise<CmsStorageEntry<T>[]>;\n getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoadersHandlerDataLoaderParams\n ): Promise<CmsStorageEntry<T>[]>;\n getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoadersHandlerDataLoaderParams\n ): Promise<CmsStorageEntry<T>[]>;\n clearAll: (params?: DataLoadersHandlerInterfaceClearAllParams) => void;\n}\n"],"names":["ENTITIES"],"mappings":"AAMO,IAAKA,iBAAQA,WAAAA,GAAAA,SAARA,QAAQ;;;;WAARA"}
@@ -1,10 +0,0 @@
1
- import type { Table } from "@webiny/db-dynamodb/toolbox";
2
- import { Entity } from "@webiny/db-dynamodb/toolbox";
3
- import type { Attributes } from "../types";
4
- interface Params {
5
- table: Table<string, string, string>;
6
- entityName: string;
7
- attributes: Attributes;
8
- }
9
- export declare const createSystemEntity: (params: Params) => Entity<any>;
10
- export {};
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createSystemEntity = void 0;
7
- var _toolbox = require("@webiny/db-dynamodb/toolbox");
8
- const createSystemEntity = params => {
9
- const {
10
- entityName,
11
- attributes,
12
- table
13
- } = params;
14
- return new _toolbox.Entity({
15
- name: entityName,
16
- table,
17
- attributes: {
18
- PK: {
19
- partitionKey: true
20
- },
21
- SK: {
22
- sortKey: true
23
- },
24
- version: {
25
- type: "string"
26
- },
27
- locale: {
28
- type: "string"
29
- },
30
- tenant: {
31
- type: "string"
32
- },
33
- readAPIKey: {
34
- type: "string"
35
- },
36
- ...(attributes || {})
37
- }
38
- });
39
- };
40
- exports.createSystemEntity = createSystemEntity;
41
-
42
- //# sourceMappingURL=system.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_toolbox","require","createSystemEntity","params","entityName","attributes","table","Entity","name","PK","partitionKey","SK","sortKey","version","type","locale","tenant","readAPIKey","exports"],"sources":["system.ts"],"sourcesContent":["import type { Table } from \"@webiny/db-dynamodb/toolbox\";\nimport { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport type { Attributes } from \"~/types\";\n\ninterface Params {\n table: Table<string, string, string>;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createSystemEntity = (params: Params): Entity<any> => {\n const { entityName, attributes, table } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n version: {\n type: \"string\"\n },\n locale: {\n type: \"string\"\n },\n tenant: {\n type: \"string\"\n },\n readAPIKey: {\n type: \"string\"\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AASO,MAAMC,kBAAkB,GAAIC,MAAc,IAAkB;EAC/D,MAAM;IAAEC,UAAU;IAAEC,UAAU;IAAEC;EAAM,CAAC,GAAGH,MAAM;EAChD,OAAO,IAAII,eAAM,CAAC;IACdC,IAAI,EAAEJ,UAAU;IAChBE,KAAK;IACLD,UAAU,EAAE;MACRI,EAAE,EAAE;QACAC,YAAY,EAAE;MAClB,CAAC;MACDC,EAAE,EAAE;QACAC,OAAO,EAAE;MACb,CAAC;MACDC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV,CAAC;MACDC,MAAM,EAAE;QACJD,IAAI,EAAE;MACV,CAAC;MACDE,MAAM,EAAE;QACJF,IAAI,EAAE;MACV,CAAC;MACDG,UAAU,EAAE;QACRH,IAAI,EAAE;MACV,CAAC;MACD,IAAIT,UAAU,IAAI,CAAC,CAAC;IACxB;EACJ,CAAC,CAAC;AACN,CAAC;AAACa,OAAA,CAAAhB,kBAAA,GAAAA,kBAAA","ignoreList":[]}