@webiny/api-headless-cms-ddb 6.4.5-beta.0 → 6.6.0-alpha.0

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 (228) hide show
  1. package/abstractions/CmsDdbDataLoaders.d.ts +5 -0
  2. package/abstractions/CmsDdbDataLoaders.js +5 -0
  3. package/abstractions/CmsDdbDataLoaders.js.map +1 -0
  4. package/abstractions/CmsDdbEntryEntity.d.ts +5 -0
  5. package/abstractions/CmsDdbEntryEntity.js +5 -0
  6. package/abstractions/CmsDdbEntryEntity.js.map +1 -0
  7. package/abstractions/CmsDdbGroupEntity.d.ts +5 -0
  8. package/abstractions/CmsDdbGroupEntity.js +5 -0
  9. package/abstractions/CmsDdbGroupEntity.js.map +1 -0
  10. package/abstractions/CmsDdbModelEntity.d.ts +5 -0
  11. package/abstractions/CmsDdbModelEntity.js +5 -0
  12. package/abstractions/CmsDdbModelEntity.js.map +1 -0
  13. package/abstractions/CmsDdbTable.d.ts +5 -0
  14. package/abstractions/CmsDdbTable.js +5 -0
  15. package/abstractions/CmsDdbTable.js.map +1 -0
  16. package/index.d.ts +13 -2
  17. package/index.js +31 -71
  18. package/index.js.map +1 -1
  19. package/operations/entry/DdbCreateEntry.d.ts +16 -0
  20. package/operations/entry/DdbCreateEntry.js +77 -0
  21. package/operations/entry/DdbCreateEntry.js.map +1 -0
  22. package/operations/entry/DdbCreateEntryRevisionFrom.d.ts +16 -0
  23. package/operations/entry/DdbCreateEntryRevisionFrom.js +85 -0
  24. package/operations/entry/DdbCreateEntryRevisionFrom.js.map +1 -0
  25. package/operations/entry/DdbDeleteEntry.d.ts +16 -0
  26. package/operations/entry/DdbDeleteEntry.js +65 -0
  27. package/operations/entry/DdbDeleteEntry.js.map +1 -0
  28. package/operations/entry/DdbDeleteEntryRevision.d.ts +17 -0
  29. package/operations/entry/DdbDeleteEntryRevision.js +91 -0
  30. package/operations/entry/DdbDeleteEntryRevision.js.map +1 -0
  31. package/operations/entry/DdbDeleteMultipleEntries.d.ts +16 -0
  32. package/operations/entry/DdbDeleteMultipleEntries.js +56 -0
  33. package/operations/entry/DdbDeleteMultipleEntries.js.map +1 -0
  34. package/operations/entry/DdbGetEntriesByIds.d.ts +14 -0
  35. package/operations/entry/DdbGetEntriesByIds.js +31 -0
  36. package/operations/entry/DdbGetEntriesByIds.js.map +1 -0
  37. package/operations/entry/DdbGetEntry.d.ts +14 -0
  38. package/operations/entry/DdbGetEntry.js +27 -0
  39. package/operations/entry/DdbGetEntry.js.map +1 -0
  40. package/operations/entry/DdbGetLatestEntriesByIds.d.ts +14 -0
  41. package/operations/entry/DdbGetLatestEntriesByIds.js +31 -0
  42. package/operations/entry/DdbGetLatestEntriesByIds.js.map +1 -0
  43. package/operations/entry/DdbGetLatestRevisionByEntryId.d.ts +14 -0
  44. package/operations/entry/DdbGetLatestRevisionByEntryId.js +35 -0
  45. package/operations/entry/DdbGetLatestRevisionByEntryId.js.map +1 -0
  46. package/operations/entry/DdbGetPreviousRevision.d.ts +14 -0
  47. package/operations/entry/DdbGetPreviousRevision.js +53 -0
  48. package/operations/entry/DdbGetPreviousRevision.js.map +1 -0
  49. package/operations/entry/DdbGetPublishedEntriesByIds.d.ts +14 -0
  50. package/operations/entry/DdbGetPublishedEntriesByIds.js +31 -0
  51. package/operations/entry/DdbGetPublishedEntriesByIds.js.map +1 -0
  52. package/operations/entry/DdbGetPublishedRevisionByEntryId.d.ts +14 -0
  53. package/operations/entry/DdbGetPublishedRevisionByEntryId.js +35 -0
  54. package/operations/entry/DdbGetPublishedRevisionByEntryId.js.map +1 -0
  55. package/operations/entry/DdbGetRevisionById.d.ts +14 -0
  56. package/operations/entry/DdbGetRevisionById.js +34 -0
  57. package/operations/entry/DdbGetRevisionById.js.map +1 -0
  58. package/operations/entry/DdbGetRevisions.d.ts +14 -0
  59. package/operations/entry/DdbGetRevisions.js +33 -0
  60. package/operations/entry/DdbGetRevisions.js.map +1 -0
  61. package/operations/entry/DdbGetUniqueFieldValues.d.ts +12 -0
  62. package/operations/entry/DdbGetUniqueFieldValues.js +31 -0
  63. package/operations/entry/DdbGetUniqueFieldValues.js.map +1 -0
  64. package/operations/entry/DdbListEntries.d.ts +28 -0
  65. package/operations/entry/DdbListEntries.js +124 -0
  66. package/operations/entry/DdbListEntries.js.map +1 -0
  67. package/operations/entry/DdbMoveEntry.d.ts +14 -0
  68. package/operations/entry/DdbMoveEntry.js +57 -0
  69. package/operations/entry/DdbMoveEntry.js.map +1 -0
  70. package/operations/entry/DdbMoveToBin.d.ts +16 -0
  71. package/operations/entry/DdbMoveToBin.js +77 -0
  72. package/operations/entry/DdbMoveToBin.js.map +1 -0
  73. package/operations/entry/DdbPublishEntry.d.ts +18 -0
  74. package/operations/entry/DdbPublishEntry.js +161 -0
  75. package/operations/entry/DdbPublishEntry.js.map +1 -0
  76. package/operations/entry/DdbRestoreFromBin.d.ts +16 -0
  77. package/operations/entry/DdbRestoreFromBin.js +78 -0
  78. package/operations/entry/DdbRestoreFromBin.js.map +1 -0
  79. package/operations/entry/DdbUnpublishEntry.d.ts +17 -0
  80. package/operations/entry/DdbUnpublishEntry.js +112 -0
  81. package/operations/entry/DdbUnpublishEntry.js.map +1 -0
  82. package/operations/entry/DdbUpdateEntry.d.ts +17 -0
  83. package/operations/entry/DdbUpdateEntry.js +110 -0
  84. package/operations/entry/DdbUpdateEntry.js.map +1 -0
  85. package/operations/entry/dataLoaders.d.ts +7 -6
  86. package/operations/entry/dataLoaders.js +11 -3
  87. package/operations/entry/dataLoaders.js.map +1 -1
  88. package/operations/entry/feature.d.ts +4 -0
  89. package/operations/entry/feature.js +55 -0
  90. package/operations/entry/feature.js.map +1 -0
  91. package/operations/entry/storageEntryUtils.d.ts +8 -0
  92. package/operations/entry/storageEntryUtils.js +25 -0
  93. package/operations/entry/storageEntryUtils.js.map +1 -0
  94. package/operations/group/DdbCreateGroup.d.ts +12 -0
  95. package/operations/group/DdbCreateGroup.js +35 -0
  96. package/operations/group/DdbCreateGroup.js.map +1 -0
  97. package/operations/group/DdbDeleteGroup.d.ts +12 -0
  98. package/operations/group/DdbDeleteGroup.js +31 -0
  99. package/operations/group/DdbDeleteGroup.js.map +1 -0
  100. package/operations/group/DdbGetGroup.d.ts +12 -0
  101. package/operations/group/DdbGetGroup.js +31 -0
  102. package/operations/group/DdbGetGroup.js.map +1 -0
  103. package/operations/group/DdbListGroups.d.ts +14 -0
  104. package/operations/group/DdbListGroups.js +52 -0
  105. package/operations/group/DdbListGroups.js.map +1 -0
  106. package/operations/group/DdbUpdateGroup.d.ts +12 -0
  107. package/operations/group/DdbUpdateGroup.js +35 -0
  108. package/operations/group/DdbUpdateGroup.js.map +1 -0
  109. package/operations/group/feature.d.ts +4 -0
  110. package/operations/group/feature.js +19 -0
  111. package/operations/group/feature.js.map +1 -0
  112. package/operations/group/keys.d.ts +15 -0
  113. package/operations/group/keys.js +17 -0
  114. package/operations/group/keys.js.map +1 -0
  115. package/operations/model/DdbCreateModel.d.ts +12 -0
  116. package/operations/model/DdbCreateModel.js +37 -0
  117. package/operations/model/DdbCreateModel.js.map +1 -0
  118. package/operations/model/DdbDeleteModel.d.ts +12 -0
  119. package/operations/model/DdbDeleteModel.js +31 -0
  120. package/operations/model/DdbDeleteModel.js.map +1 -0
  121. package/operations/model/DdbGetModel.d.ts +12 -0
  122. package/operations/model/DdbGetModel.js +30 -0
  123. package/operations/model/DdbGetModel.js.map +1 -0
  124. package/operations/model/DdbListModels.d.ts +12 -0
  125. package/operations/model/DdbListModels.js +36 -0
  126. package/operations/model/DdbListModels.js.map +1 -0
  127. package/operations/model/DdbUpdateModel.d.ts +12 -0
  128. package/operations/model/DdbUpdateModel.js +36 -0
  129. package/operations/model/DdbUpdateModel.js.map +1 -0
  130. package/operations/model/feature.d.ts +4 -0
  131. package/operations/model/feature.js +19 -0
  132. package/operations/model/feature.js.map +1 -0
  133. package/operations/model/keys.d.ts +15 -0
  134. package/operations/model/keys.js +16 -0
  135. package/operations/model/keys.js.map +1 -0
  136. package/package.json +15 -17
  137. package/types.d.ts +9 -49
  138. package/types.js.map +1 -1
  139. package/dynamoDb/index.d.ts +0 -2
  140. package/dynamoDb/index.js +0 -11
  141. package/dynamoDb/index.js.map +0 -1
  142. package/dynamoDb/path/locationFolderId.d.ts +0 -2
  143. package/dynamoDb/path/locationFolderId.js +0 -21
  144. package/dynamoDb/path/locationFolderId.js.map +0 -1
  145. package/dynamoDb/path/plainObject.d.ts +0 -2
  146. package/dynamoDb/path/plainObject.js +0 -16
  147. package/dynamoDb/path/plainObject.js.map +0 -1
  148. package/dynamoDb/transformValue/datetime.d.ts +0 -5
  149. package/dynamoDb/transformValue/datetime.js +0 -29
  150. package/dynamoDb/transformValue/datetime.js.map +0 -1
  151. package/operations/entry/filtering/createExpressions.d.ts +0 -27
  152. package/operations/entry/filtering/createExpressions.js +0 -124
  153. package/operations/entry/filtering/createExpressions.js.map +0 -1
  154. package/operations/entry/filtering/createFields.d.ts +0 -16
  155. package/operations/entry/filtering/createFields.js +0 -93
  156. package/operations/entry/filtering/createFields.js.map +0 -1
  157. package/operations/entry/filtering/extractSort.d.ts +0 -17
  158. package/operations/entry/filtering/extractSort.js +0 -60
  159. package/operations/entry/filtering/extractSort.js.map +0 -1
  160. package/operations/entry/filtering/filter.d.ts +0 -16
  161. package/operations/entry/filtering/filter.js +0 -85
  162. package/operations/entry/filtering/filter.js.map +0 -1
  163. package/operations/entry/filtering/fullTextSearch.d.ts +0 -14
  164. package/operations/entry/filtering/fullTextSearch.js +0 -25
  165. package/operations/entry/filtering/fullTextSearch.js.map +0 -1
  166. package/operations/entry/filtering/getValue.d.ts +0 -5
  167. package/operations/entry/filtering/getValue.js +0 -37
  168. package/operations/entry/filtering/getValue.js.map +0 -1
  169. package/operations/entry/filtering/index.d.ts +0 -2
  170. package/operations/entry/filtering/index.js +0 -2
  171. package/operations/entry/filtering/mapPlugins.d.ts +0 -8
  172. package/operations/entry/filtering/mapPlugins.js +0 -18
  173. package/operations/entry/filtering/mapPlugins.js.map +0 -1
  174. package/operations/entry/filtering/plugins/defaultFilterCreate.d.ts +0 -2
  175. package/operations/entry/filtering/plugins/defaultFilterCreate.js +0 -33
  176. package/operations/entry/filtering/plugins/defaultFilterCreate.js.map +0 -1
  177. package/operations/entry/filtering/plugins/index.d.ts +0 -1
  178. package/operations/entry/filtering/plugins/index.js +0 -13
  179. package/operations/entry/filtering/plugins/index.js.map +0 -1
  180. package/operations/entry/filtering/plugins/objectFilterCreate.d.ts +0 -2
  181. package/operations/entry/filtering/plugins/objectFilterCreate.js +0 -68
  182. package/operations/entry/filtering/plugins/objectFilterCreate.js.map +0 -1
  183. package/operations/entry/filtering/plugins/refFilterCreate.d.ts +0 -3
  184. package/operations/entry/filtering/plugins/refFilterCreate.js +0 -63
  185. package/operations/entry/filtering/plugins/refFilterCreate.js.map +0 -1
  186. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.d.ts +0 -2
  187. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js +0 -56
  188. package/operations/entry/filtering/plugins/searchableJsonFilterCreate.js.map +0 -1
  189. package/operations/entry/filtering/sort.d.ts +0 -12
  190. package/operations/entry/filtering/sort.js +0 -41
  191. package/operations/entry/filtering/sort.js.map +0 -1
  192. package/operations/entry/filtering/systemFields.d.ts +0 -2
  193. package/operations/entry/filtering/systemFields.js +0 -149
  194. package/operations/entry/filtering/systemFields.js.map +0 -1
  195. package/operations/entry/filtering/transform.d.ts +0 -6
  196. package/operations/entry/filtering/transform.js +0 -7
  197. package/operations/entry/filtering/transform.js.map +0 -1
  198. package/operations/entry/filtering/types.d.ts +0 -40
  199. package/operations/entry/filtering/types.js +0 -0
  200. package/operations/entry/filtering/values.d.ts +0 -2
  201. package/operations/entry/filtering/values.js +0 -15
  202. package/operations/entry/filtering/values.js.map +0 -1
  203. package/operations/entry/filtering/where.d.ts +0 -5
  204. package/operations/entry/filtering/where.js +0 -22
  205. package/operations/entry/filtering/where.js.map +0 -1
  206. package/operations/entry/index.d.ts +0 -9
  207. package/operations/entry/index.js +0 -943
  208. package/operations/entry/index.js.map +0 -1
  209. package/operations/group/index.d.ts +0 -8
  210. package/operations/group/index.js +0 -121
  211. package/operations/group/index.js.map +0 -1
  212. package/operations/model/index.d.ts +0 -7
  213. package/operations/model/index.js +0 -106
  214. package/operations/model/index.js.map +0 -1
  215. package/plugins/CmsEntryFieldFilterPathPlugin.d.ts +0 -23
  216. package/plugins/CmsEntryFieldFilterPathPlugin.js +0 -30
  217. package/plugins/CmsEntryFieldFilterPathPlugin.js.map +0 -1
  218. package/plugins/CmsEntryFieldFilterPlugin.d.ts +0 -43
  219. package/plugins/CmsEntryFieldFilterPlugin.js +0 -20
  220. package/plugins/CmsEntryFieldFilterPlugin.js.map +0 -1
  221. package/plugins/CmsEntryFieldSortingPlugin.d.ts +0 -42
  222. package/plugins/CmsEntryFieldSortingPlugin.js +0 -20
  223. package/plugins/CmsEntryFieldSortingPlugin.js.map +0 -1
  224. package/plugins/CmsFieldFilterValueTransformPlugin.d.ts +0 -11
  225. package/plugins/CmsFieldFilterValueTransformPlugin.js +0 -19
  226. package/plugins/CmsFieldFilterValueTransformPlugin.js.map +0 -1
  227. package/plugins/index.d.ts +0 -4
  228. package/plugins/index.js +0 -4
@@ -2,10 +2,12 @@ import error from "@webiny/error";
2
2
  import { DataLoaderCache } from "./dataLoader/DataLoaderCache.js";
3
3
  import { getDataLoaderFactory } from "./dataLoader/index.js";
4
4
  import { parseIdentifier } from "@webiny/utils";
5
- class DataLoadersHandler {
6
- constructor(params){
5
+ import { CmsDdbEntryEntity } from "../../abstractions/CmsDdbEntryEntity.js";
6
+ import { CmsDdbDataLoaders } from "../../abstractions/CmsDdbDataLoaders.js";
7
+ class DataLoadersHandlerImpl {
8
+ constructor(entity){
9
+ this.entity = entity;
7
10
  this.cache = new DataLoaderCache();
8
- this.entity = params.entity;
9
11
  }
10
12
  async getAllEntryRevisions(params) {
11
13
  const ids = params.ids.map((id)=>{
@@ -85,6 +87,12 @@ class DataLoadersHandler {
85
87
  this.cache.clearAll(params);
86
88
  }
87
89
  }
90
+ const DataLoadersHandler = CmsDdbDataLoaders.createImplementation({
91
+ implementation: DataLoadersHandlerImpl,
92
+ dependencies: [
93
+ CmsDdbEntryEntity
94
+ ]
95
+ });
88
96
  export { DataLoadersHandler };
89
97
 
90
98
  //# sourceMappingURL=dataLoaders.js.map
@@ -1 +1 @@
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 {\n DataLoadersHandlerInterfaceClearAllParams,\n IDataLoadersHandler,\n IEntryEntity\n} from \"~/types.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\ninterface IDataLoadersHandlerParams {\n entity: IEntryEntity;\n}\n\nexport class DataLoadersHandler implements IDataLoadersHandler {\n private readonly entity;\n private readonly cache = new DataLoaderCache();\n\n public constructor(params: IDataLoadersHandlerParams) {\n this.entity = params.entity;\n }\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"],"names":["DataLoadersHandler","params","DataLoaderCache","ids","id","entryId","parseIdentifier","name","model","cacheParams","loader","factory","getDataLoaderFactory","results","Array","acc","res","WebinyError","JSON","ex"],"mappings":";;;;AA+BO,MAAMA;IAIT,YAAmBC,MAAiC,CAAE;aAFrC,KAAK,GAAG,IAAIC;QAGzB,IAAI,CAAC,MAAM,GAAGD,OAAO,MAAM;IAC/B;IAEA,MAAa,qBACTA,MAAwB,EACK;QAC7B,MAAME,MAAMF,OAAO,GAAG,CAAC,GAAG,CAACG,CAAAA;YACvB,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBF;YACxC,OAAOC;QACX;QACA,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,wBAAwBJ,QAAQE;IAClE;IAEA,MAAa,gBACTF,MAAwB,EACK;QAC7B,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,mBAAmBA,QAAQA,OAAO,GAAG;IACvE;IAEA,MAAa,8BACTA,MAAwB,EACK;QAC7B,MAAME,MAAMF,OAAO,GAAG,CAAC,GAAG,CAACG,CAAAA;YACvB,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBF;YACxC,OAAOC;QACX;QACA,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,iCAAiCJ,QAAQE;IAC3E;IAEA,MAAa,2BACTF,MAAwB,EACK;QAC7B,MAAME,MAAMF,OAAO,GAAG,CAAC,GAAG,CAACG,CAAAA;YACvB,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBF;YACxC,OAAOC;QACX;QACA,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,8BAA8BJ,QAAQE;IACxE;IAMQ,UAAUI,IAAiB,EAAEN,MAAuB,EAAwB;QAChF,MAAM,EAAEO,KAAK,EAAE,GAAGP;QAClB,MAAMQ,cAA8B;YAChC,QAAQD,MAAM,MAAM;YACpB,SAASA,MAAM,OAAO;YACtBD;QACJ;QACA,IAAIG,SAAS,IAAI,CAAC,KAAK,CAAC,aAAa,CAACD;QACtC,IAAIC,QACA,OAAOA;QAEX,MAAMC,UAAUC,qBAAqBL;QACrCG,SAASC,QAAQ;YACb,QAAQ,IAAI,CAAC,MAAM;YACnB,QAAQH,MAAM,MAAM;YACpB,SAASA,MAAM,OAAO;QAC1B;QACA,IAAI,CAAC,KAAK,CAAC,aAAa,CAACC,aAAaC;QACtC,OAAOA;IACX;IAEA,MAAc,SACVA,MAAmB,EACnBT,MAAuB,EACvBE,GAAsB,EACO;QAC7B,IAAIU,UAAiB,EAAE;QACvB,IAAI;YACAA,UAAU,MAAM,IAAI,CAAC,SAAS,CAACH,QAAQT,QAAQ,QAAQ,CAACE;YACxD,IAAIW,AAA2B,SAA3BA,MAAM,OAAO,CAACD,UACd,OAAOA,QAAQ,MAAM,CAAC,CAACE,KAAKC;gBACxB,IAAIF,AAAuB,UAAvBA,MAAM,OAAO,CAACE,MAAgB;oBAC9B,IAAIA,OAAOA,IAAI,OAAO,EAClB,MAAM,IAAIC,MAAYD,IAAI,OAAO,EAAEA,IAAI,IAAI,EAAE;wBACzC,GAAGA,GAAG;wBACN,MAAME,KAAK,SAAS,CAACF,IAAI,IAAI,IAAI,CAAC;oBACtC;oBAEJ,MAAM,IAAIC,MACN,yFACA,6BACA;wBACI,GAAGhB,MAAM;wBACTS;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,GAAGlB,MAAM;gBACTS;gBACAP;YACJ;QAER;QACA,MAAM,IAAIc,MACN,6DACA,8BACA;YACIP;YACAP;YACAU;QACJ;IAER;IAEO,SAASZ,MAAkD,EAAQ;QACtE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAACA;IACxB;AACJ"}
1
+ {"version":3,"file":"operations/entry/dataLoaders.js","sources":["../../../src/operations/entry/dataLoaders.ts"],"sourcesContent":["import type DataLoader from \"dataloader\";\nimport WebinyError from \"@webiny/error\";\nimport type {\n CmsEntryValues,\n CmsModel,\n CmsStorageEntry\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CacheKeyParams } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport { DataLoaderCache } from \"~/operations/entry/dataLoader/DataLoaderCache.js\";\nimport type { DataLoaders } from \"~/operations/entry/dataLoader/index.js\";\nimport { getDataLoaderFactory } from \"~/operations/entry/dataLoader/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport type { DataLoadersHandlerInterfaceClearAllParams, IDataLoadersHandler } from \"~/types.js\";\nimport { CmsDdbEntryEntity } from \"~/abstractions/CmsDdbEntryEntity.js\";\nimport { CmsDdbDataLoaders } from \"~/abstractions/CmsDdbDataLoaders.js\";\n\ninterface DataLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n ids: readonly string[];\n}\n\ninterface GetLoaderParams {\n model: Pick<CmsModel, \"tenant\" | \"modelId\">;\n}\n\nclass DataLoadersHandlerImpl implements IDataLoadersHandler {\n private readonly cache = new DataLoaderCache();\n\n public constructor(private readonly entity: CmsDdbEntryEntity.Interface) {}\n\n public async getAllEntryRevisions<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getAllEntryRevisions\", params, ids);\n }\n\n public async getRevisionById<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n return await this.loadMany<T>(\"getRevisionById\", params, params.ids);\n }\n\n public async getPublishedRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getPublishedRevisionByEntryId\", params, ids);\n }\n\n public async getLatestRevisionByEntryId<T extends CmsEntryValues = CmsEntryValues>(\n params: DataLoaderParams\n ): Promise<CmsStorageEntry<T>[]> {\n const ids = params.ids.map(id => {\n const { id: entryId } = parseIdentifier(id);\n return entryId;\n });\n return await this.loadMany<T>(\"getLatestRevisionByEntryId\", params, ids);\n }\n\n /**\n * TODO @ts-refactor\n * Maybe pass on the generics to DataLoader definition?\n */\n private getLoader(name: DataLoaders, params: GetLoaderParams): DataLoader<any, any> {\n const { model } = params;\n const cacheParams: CacheKeyParams = {\n tenant: model.tenant,\n modelId: model.modelId,\n name\n };\n let loader = this.cache.getDataLoader(cacheParams);\n if (loader) {\n return loader;\n }\n const factory = getDataLoaderFactory(name);\n loader = factory({\n entity: this.entity,\n tenant: model.tenant,\n modelId: model.modelId\n });\n this.cache.setDataLoader(cacheParams, loader);\n return loader;\n }\n\n private async loadMany<T extends CmsEntryValues = CmsEntryValues>(\n loader: DataLoaders,\n params: GetLoaderParams,\n ids: readonly string[]\n ): Promise<CmsStorageEntry<T>[]> {\n let results: any[] = [];\n try {\n results = await this.getLoader(loader, params).loadMany(ids);\n if (Array.isArray(results) === true) {\n return results.reduce((acc, res) => {\n if (Array.isArray(res) === false) {\n if (res && res.message) {\n throw new WebinyError(res.message, res.code, {\n ...res,\n data: JSON.stringify(res.data || {})\n });\n }\n throw new WebinyError(\n \"Result from the data loader must be an array of arrays which contain requested items.\",\n \"DATA_LOADER_RESULTS_ERROR\",\n {\n ...params,\n loader\n }\n );\n }\n acc.push(...res);\n return acc;\n }, []);\n }\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Data loader error.\",\n ex.code || \"DATA_LOADER_ERROR\",\n {\n error: ex,\n ...params,\n loader,\n ids\n }\n );\n }\n throw new WebinyError(\n `Data loader did not return array of items or empty array.`,\n \"INVALID_DATA_LOADER_RESULT\",\n {\n loader,\n ids,\n results\n }\n );\n }\n\n public clearAll(params?: DataLoadersHandlerInterfaceClearAllParams): void {\n this.cache.clearAll(params);\n }\n}\n\nexport const DataLoadersHandler = CmsDdbDataLoaders.createImplementation({\n implementation: DataLoadersHandlerImpl,\n dependencies: [CmsDdbEntryEntity]\n});\n"],"names":["DataLoadersHandlerImpl","entity","DataLoaderCache","params","ids","id","entryId","parseIdentifier","name","model","cacheParams","loader","factory","getDataLoaderFactory","results","Array","acc","res","WebinyError","JSON","ex","DataLoadersHandler","CmsDdbDataLoaders","CmsDdbEntryEntity"],"mappings":";;;;;;AAyBA,MAAMA;IAGF,YAAoCC,MAAmC,CAAE;aAArCA,MAAM,GAANA;aAFnB,KAAK,GAAG,IAAIC;IAE6C;IAE1E,MAAa,qBACTC,MAAwB,EACK;QAC7B,MAAMC,MAAMD,OAAO,GAAG,CAAC,GAAG,CAACE,CAAAA;YACvB,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBF;YACxC,OAAOC;QACX;QACA,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,wBAAwBH,QAAQC;IAClE;IAEA,MAAa,gBACTD,MAAwB,EACK;QAC7B,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,mBAAmBA,QAAQA,OAAO,GAAG;IACvE;IAEA,MAAa,8BACTA,MAAwB,EACK;QAC7B,MAAMC,MAAMD,OAAO,GAAG,CAAC,GAAG,CAACE,CAAAA;YACvB,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBF;YACxC,OAAOC;QACX;QACA,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,iCAAiCH,QAAQC;IAC3E;IAEA,MAAa,2BACTD,MAAwB,EACK;QAC7B,MAAMC,MAAMD,OAAO,GAAG,CAAC,GAAG,CAACE,CAAAA;YACvB,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBF;YACxC,OAAOC;QACX;QACA,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAI,8BAA8BH,QAAQC;IACxE;IAMQ,UAAUI,IAAiB,EAAEL,MAAuB,EAAwB;QAChF,MAAM,EAAEM,KAAK,EAAE,GAAGN;QAClB,MAAMO,cAA8B;YAChC,QAAQD,MAAM,MAAM;YACpB,SAASA,MAAM,OAAO;YACtBD;QACJ;QACA,IAAIG,SAAS,IAAI,CAAC,KAAK,CAAC,aAAa,CAACD;QACtC,IAAIC,QACA,OAAOA;QAEX,MAAMC,UAAUC,qBAAqBL;QACrCG,SAASC,QAAQ;YACb,QAAQ,IAAI,CAAC,MAAM;YACnB,QAAQH,MAAM,MAAM;YACpB,SAASA,MAAM,OAAO;QAC1B;QACA,IAAI,CAAC,KAAK,CAAC,aAAa,CAACC,aAAaC;QACtC,OAAOA;IACX;IAEA,MAAc,SACVA,MAAmB,EACnBR,MAAuB,EACvBC,GAAsB,EACO;QAC7B,IAAIU,UAAiB,EAAE;QACvB,IAAI;YACAA,UAAU,MAAM,IAAI,CAAC,SAAS,CAACH,QAAQR,QAAQ,QAAQ,CAACC;YACxD,IAAIW,AAA2B,SAA3BA,MAAM,OAAO,CAACD,UACd,OAAOA,QAAQ,MAAM,CAAC,CAACE,KAAKC;gBACxB,IAAIF,AAAuB,UAAvBA,MAAM,OAAO,CAACE,MAAgB;oBAC9B,IAAIA,OAAOA,IAAI,OAAO,EAClB,MAAM,IAAIC,MAAYD,IAAI,OAAO,EAAEA,IAAI,IAAI,EAAE;wBACzC,GAAGA,GAAG;wBACN,MAAME,KAAK,SAAS,CAACF,IAAI,IAAI,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,55 @@
1
+ import { createFeature } from "@webiny/feature/api/index.js";
2
+ import { DataLoadersHandler } from "./dataLoaders.js";
3
+ import { DdbCreateEntry } from "./DdbCreateEntry.js";
4
+ import { DdbCreateEntryRevisionFrom } from "./DdbCreateEntryRevisionFrom.js";
5
+ import { DdbUpdateEntry } from "./DdbUpdateEntry.js";
6
+ import { DdbMoveEntry } from "./DdbMoveEntry.js";
7
+ import { DdbMoveToBin } from "./DdbMoveToBin.js";
8
+ import { DdbDeleteEntry } from "./DdbDeleteEntry.js";
9
+ import { DdbRestoreFromBin } from "./DdbRestoreFromBin.js";
10
+ import { DdbDeleteEntryRevision } from "./DdbDeleteEntryRevision.js";
11
+ import { DdbDeleteMultipleEntries } from "./DdbDeleteMultipleEntries.js";
12
+ import { DdbGetEntry } from "./DdbGetEntry.js";
13
+ import { DdbListEntries } from "./DdbListEntries.js";
14
+ import { DdbPublishEntry } from "./DdbPublishEntry.js";
15
+ import { DdbUnpublishEntry } from "./DdbUnpublishEntry.js";
16
+ import { DdbGetEntriesByIds } from "./DdbGetEntriesByIds.js";
17
+ import { DdbGetLatestEntriesByIds } from "./DdbGetLatestEntriesByIds.js";
18
+ import { DdbGetPublishedEntriesByIds } from "./DdbGetPublishedEntriesByIds.js";
19
+ import { DdbGetRevisions } from "./DdbGetRevisions.js";
20
+ import { DdbGetRevisionById } from "./DdbGetRevisionById.js";
21
+ import { DdbGetLatestRevisionByEntryId } from "./DdbGetLatestRevisionByEntryId.js";
22
+ import { DdbGetPublishedRevisionByEntryId } from "./DdbGetPublishedRevisionByEntryId.js";
23
+ import { DdbGetPreviousRevision } from "./DdbGetPreviousRevision.js";
24
+ import { DdbGetUniqueFieldValues } from "./DdbGetUniqueFieldValues.js";
25
+ const DdbEntryStorageOpsFeature = createFeature({
26
+ name: "cms.ddb.entryStorageOps",
27
+ register: (container)=>{
28
+ container.register(DataLoadersHandler).inSingletonScope();
29
+ container.register(DdbCreateEntry);
30
+ container.register(DdbCreateEntryRevisionFrom);
31
+ container.register(DdbUpdateEntry);
32
+ container.register(DdbMoveEntry);
33
+ container.register(DdbMoveToBin);
34
+ container.register(DdbDeleteEntry);
35
+ container.register(DdbRestoreFromBin);
36
+ container.register(DdbDeleteEntryRevision);
37
+ container.register(DdbDeleteMultipleEntries);
38
+ container.register(DdbGetEntry);
39
+ container.register(DdbListEntries);
40
+ container.register(DdbPublishEntry);
41
+ container.register(DdbUnpublishEntry);
42
+ container.register(DdbGetEntriesByIds);
43
+ container.register(DdbGetLatestEntriesByIds);
44
+ container.register(DdbGetPublishedEntriesByIds);
45
+ container.register(DdbGetRevisions);
46
+ container.register(DdbGetRevisionById);
47
+ container.register(DdbGetLatestRevisionByEntryId);
48
+ container.register(DdbGetPublishedRevisionByEntryId);
49
+ container.register(DdbGetPreviousRevision);
50
+ container.register(DdbGetUniqueFieldValues);
51
+ }
52
+ });
53
+ export { DdbEntryStorageOpsFeature };
54
+
55
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/feature.js","sources":["../../../src/operations/entry/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { DataLoadersHandler } from \"./dataLoaders.js\";\nimport { DdbCreateEntry } from \"./DdbCreateEntry.js\";\nimport { DdbCreateEntryRevisionFrom } from \"./DdbCreateEntryRevisionFrom.js\";\nimport { DdbUpdateEntry } from \"./DdbUpdateEntry.js\";\nimport { DdbMoveEntry } from \"./DdbMoveEntry.js\";\nimport { DdbMoveToBin } from \"./DdbMoveToBin.js\";\nimport { DdbDeleteEntry } from \"./DdbDeleteEntry.js\";\nimport { DdbRestoreFromBin } from \"./DdbRestoreFromBin.js\";\nimport { DdbDeleteEntryRevision } from \"./DdbDeleteEntryRevision.js\";\nimport { DdbDeleteMultipleEntries } from \"./DdbDeleteMultipleEntries.js\";\nimport { DdbGetEntry } from \"./DdbGetEntry.js\";\nimport { DdbListEntries } from \"./DdbListEntries.js\";\nimport { DdbPublishEntry } from \"./DdbPublishEntry.js\";\nimport { DdbUnpublishEntry } from \"./DdbUnpublishEntry.js\";\nimport { DdbGetEntriesByIds } from \"./DdbGetEntriesByIds.js\";\nimport { DdbGetLatestEntriesByIds } from \"./DdbGetLatestEntriesByIds.js\";\nimport { DdbGetPublishedEntriesByIds } from \"./DdbGetPublishedEntriesByIds.js\";\nimport { DdbGetRevisions } from \"./DdbGetRevisions.js\";\nimport { DdbGetRevisionById } from \"./DdbGetRevisionById.js\";\nimport { DdbGetLatestRevisionByEntryId } from \"./DdbGetLatestRevisionByEntryId.js\";\nimport { DdbGetPublishedRevisionByEntryId } from \"./DdbGetPublishedRevisionByEntryId.js\";\nimport { DdbGetPreviousRevision } from \"./DdbGetPreviousRevision.js\";\nimport { DdbGetUniqueFieldValues } from \"./DdbGetUniqueFieldValues.js\";\n\nexport const DdbEntryStorageOpsFeature = createFeature({\n name: \"cms.ddb.entryStorageOps\",\n register: container => {\n container.register(DataLoadersHandler).inSingletonScope();\n container.register(DdbCreateEntry);\n container.register(DdbCreateEntryRevisionFrom);\n container.register(DdbUpdateEntry);\n container.register(DdbMoveEntry);\n container.register(DdbMoveToBin);\n container.register(DdbDeleteEntry);\n container.register(DdbRestoreFromBin);\n container.register(DdbDeleteEntryRevision);\n container.register(DdbDeleteMultipleEntries);\n container.register(DdbGetEntry);\n container.register(DdbListEntries);\n container.register(DdbPublishEntry);\n container.register(DdbUnpublishEntry);\n container.register(DdbGetEntriesByIds);\n container.register(DdbGetLatestEntriesByIds);\n container.register(DdbGetPublishedEntriesByIds);\n container.register(DdbGetRevisions);\n container.register(DdbGetRevisionById);\n container.register(DdbGetLatestRevisionByEntryId);\n container.register(DdbGetPublishedRevisionByEntryId);\n container.register(DdbGetPreviousRevision);\n container.register(DdbGetUniqueFieldValues);\n }\n});\n"],"names":["DdbEntryStorageOpsFeature","createFeature","container","DataLoadersHandler","DdbCreateEntry","DdbCreateEntryRevisionFrom","DdbUpdateEntry","DdbMoveEntry","DdbMoveToBin","DdbDeleteEntry","DdbRestoreFromBin","DdbDeleteEntryRevision","DdbDeleteMultipleEntries","DdbGetEntry","DdbListEntries","DdbPublishEntry","DdbUnpublishEntry","DdbGetEntriesByIds","DdbGetLatestEntriesByIds","DdbGetPublishedEntriesByIds","DdbGetRevisions","DdbGetRevisionById","DdbGetLatestRevisionByEntryId","DdbGetPublishedRevisionByEntryId","DdbGetPreviousRevision","DdbGetUniqueFieldValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAyBO,MAAMA,4BAA4BC,cAAc;IACnD,MAAM;IACN,UAAUC,CAAAA;QACNA,UAAU,QAAQ,CAACC,oBAAoB,gBAAgB;QACvDD,UAAU,QAAQ,CAACE;QACnBF,UAAU,QAAQ,CAACG;QACnBH,UAAU,QAAQ,CAACI;QACnBJ,UAAU,QAAQ,CAACK;QACnBL,UAAU,QAAQ,CAACM;QACnBN,UAAU,QAAQ,CAACO;QACnBP,UAAU,QAAQ,CAACQ;QACnBR,UAAU,QAAQ,CAACS;QACnBT,UAAU,QAAQ,CAACU;QACnBV,UAAU,QAAQ,CAACW;QACnBX,UAAU,QAAQ,CAACY;QACnBZ,UAAU,QAAQ,CAACa;QACnBb,UAAU,QAAQ,CAACc;QACnBd,UAAU,QAAQ,CAACe;QACnBf,UAAU,QAAQ,CAACgB;QACnBhB,UAAU,QAAQ,CAACiB;QACnBjB,UAAU,QAAQ,CAACkB;QACnBlB,UAAU,QAAQ,CAACmB;QACnBnB,UAAU,QAAQ,CAACoB;QACnBpB,UAAU,QAAQ,CAACqB;QACnBrB,UAAU,QAAQ,CAACsB;QACnBtB,UAAU,QAAQ,CAACuB;IACvB;AACJ"}
@@ -0,0 +1,8 @@
1
+ import type { CmsEntryValues, CmsStorageEntry, StorageOperationsCmsModel } from "@webiny/api-headless-cms/types/index.js";
2
+ interface ConvertStorageEntryParams<T extends CmsEntryValues = CmsEntryValues> {
3
+ storageEntry: CmsStorageEntry<T>;
4
+ model: StorageOperationsCmsModel<T>;
5
+ }
6
+ export declare const convertToStorageEntry: (params: ConvertStorageEntryParams) => CmsStorageEntry;
7
+ export declare const convertFromStorageEntry: <T extends CmsEntryValues = CmsEntryValues>(params: ConvertStorageEntryParams<T>) => CmsStorageEntry<T>;
8
+ export {};
@@ -0,0 +1,25 @@
1
+ const convertToStorageEntry = (params)=>{
2
+ const { model, storageEntry } = params;
3
+ const values = model.convertValueKeyToStorage({
4
+ fields: model.fields,
5
+ values: storageEntry.values
6
+ });
7
+ return {
8
+ ...storageEntry,
9
+ values
10
+ };
11
+ };
12
+ const convertFromStorageEntry = (params)=>{
13
+ const { model, storageEntry } = params;
14
+ const values = model.convertValueKeyFromStorage({
15
+ fields: model.fields,
16
+ values: storageEntry.values
17
+ });
18
+ return {
19
+ ...storageEntry,
20
+ values
21
+ };
22
+ };
23
+ export { convertFromStorageEntry, convertToStorageEntry };
24
+
25
+ //# sourceMappingURL=storageEntryUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/entry/storageEntryUtils.js","sources":["../../../src/operations/entry/storageEntryUtils.ts"],"sourcesContent":["import type {\n CmsEntryValues,\n CmsStorageEntry,\n StorageOperationsCmsModel\n} from \"@webiny/api-headless-cms/types/index.js\";\n\ninterface ConvertStorageEntryParams<T extends CmsEntryValues = CmsEntryValues> {\n storageEntry: CmsStorageEntry<T>;\n model: StorageOperationsCmsModel<T>;\n}\n\nexport const convertToStorageEntry = (params: ConvertStorageEntryParams): CmsStorageEntry => {\n const { model, storageEntry } = params;\n\n const values = model.convertValueKeyToStorage({\n fields: model.fields,\n values: storageEntry.values\n });\n return {\n ...storageEntry,\n values\n };\n};\n\nexport const convertFromStorageEntry = <T extends CmsEntryValues = CmsEntryValues>(\n params: ConvertStorageEntryParams<T>\n): CmsStorageEntry<T> => {\n const { model, storageEntry } = params;\n\n const values = model.convertValueKeyFromStorage({\n fields: model.fields,\n values: storageEntry.values\n });\n return {\n ...storageEntry,\n values\n };\n};\n"],"names":["convertToStorageEntry","params","model","storageEntry","values","convertFromStorageEntry"],"mappings":"AAWO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,KAAK,EAAEC,YAAY,EAAE,GAAGF;IAEhC,MAAMG,SAASF,MAAM,wBAAwB,CAAC;QAC1C,QAAQA,MAAM,MAAM;QACpB,QAAQC,aAAa,MAAM;IAC/B;IACA,OAAO;QACH,GAAGA,YAAY;QACfC;IACJ;AACJ;AAEO,MAAMC,0BAA0B,CACnCJ;IAEA,MAAM,EAAEC,KAAK,EAAEC,YAAY,EAAE,GAAGF;IAEhC,MAAMG,SAASF,MAAM,0BAA0B,CAAC;QAC5C,QAAQA,MAAM,MAAM;QACpB,QAAQC,aAAa,MAAM;IAC/B;IACA,OAAO;QACH,GAAGA,YAAY;QACfC;IACJ;AACJ"}
@@ -0,0 +1,12 @@
1
+ import type { CmsGroupStorageOperationsCreateParams } from "@webiny/api-headless-cms/types/index.js";
2
+ import { CreateGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/CreateGroupStorageOperation.js";
3
+ import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
4
+ declare class DdbCreateGroupImpl implements CreateGroupStorageOperation.Interface {
5
+ private entity;
6
+ constructor(entity: CmsDdbGroupEntity.Interface);
7
+ execute(params: CmsGroupStorageOperationsCreateParams): Promise<void>;
8
+ }
9
+ export declare const DdbCreateGroup: typeof DdbCreateGroupImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/group/CreateGroupStorageOperation.js").ICreateGroupStorageOperation>;
11
+ };
12
+ export {};
@@ -0,0 +1,35 @@
1
+ import error from "@webiny/error";
2
+ import { CreateGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/CreateGroupStorageOperation.js";
3
+ import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
4
+ import { createKeys, createType } from "./keys.js";
5
+ class DdbCreateGroupImpl {
6
+ constructor(entity){
7
+ this.entity = entity;
8
+ }
9
+ async execute(params) {
10
+ const { group } = params;
11
+ const keys = createKeys(group);
12
+ try {
13
+ await this.entity.put({
14
+ data: group,
15
+ TYPE: createType(),
16
+ ...keys
17
+ });
18
+ } catch (ex) {
19
+ throw new error(ex.message || "Could not create group.", ex.code || "CREATE_GROUP_ERROR", {
20
+ error: ex,
21
+ group,
22
+ keys
23
+ });
24
+ }
25
+ }
26
+ }
27
+ const DdbCreateGroup = CreateGroupStorageOperation.createImplementation({
28
+ implementation: DdbCreateGroupImpl,
29
+ dependencies: [
30
+ CmsDdbGroupEntity
31
+ ]
32
+ });
33
+ export { DdbCreateGroup };
34
+
35
+ //# sourceMappingURL=DdbCreateGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/group/DdbCreateGroup.js","sources":["../../../src/operations/group/DdbCreateGroup.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsCreateParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { CreateGroupStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/CreateGroupStorageOperation.js\";\nimport { CmsDdbGroupEntity } from \"~/abstractions/CmsDdbGroupEntity.js\";\nimport { createKeys, createType } from \"./keys.js\";\n\nclass DdbCreateGroupImpl implements CreateGroupStorageOperation.Interface {\n constructor(private entity: CmsDdbGroupEntity.Interface) {}\n\n async execute(params: CmsGroupStorageOperationsCreateParams) {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await this.entity.put({\n data: group,\n TYPE: createType(),\n ...keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create group.\",\n ex.code || \"CREATE_GROUP_ERROR\",\n { error: ex, group, keys }\n );\n }\n }\n}\n\nexport const DdbCreateGroup = CreateGroupStorageOperation.createImplementation({\n implementation: DdbCreateGroupImpl,\n dependencies: [CmsDdbGroupEntity]\n});\n"],"names":["DdbCreateGroupImpl","entity","params","group","keys","createKeys","createType","ex","WebinyError","DdbCreateGroup","CreateGroupStorageOperation","CmsDdbGroupEntity"],"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,MAAMG;gBACN,GAAGF,IAAI;YACX;QACJ,EAAE,OAAOG,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,12 @@
1
+ import type { CmsGroupStorageOperationsDeleteParams } from "@webiny/api-headless-cms/types/index.js";
2
+ import { DeleteGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/DeleteGroupStorageOperation.js";
3
+ import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
4
+ declare class DdbDeleteGroupImpl implements DeleteGroupStorageOperation.Interface {
5
+ private entity;
6
+ constructor(entity: CmsDdbGroupEntity.Interface);
7
+ execute(params: CmsGroupStorageOperationsDeleteParams): Promise<void>;
8
+ }
9
+ export declare const DdbDeleteGroup: typeof DdbDeleteGroupImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/group/DeleteGroupStorageOperation.js").IDeleteGroupStorageOperation>;
11
+ };
12
+ export {};
@@ -0,0 +1,31 @@
1
+ import error from "@webiny/error";
2
+ import { DeleteGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/DeleteGroupStorageOperation.js";
3
+ import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
4
+ import { createKeys } from "./keys.js";
5
+ class DdbDeleteGroupImpl {
6
+ constructor(entity){
7
+ this.entity = entity;
8
+ }
9
+ async execute(params) {
10
+ const { group } = params;
11
+ const keys = createKeys(group);
12
+ try {
13
+ await this.entity.delete(keys);
14
+ } catch (ex) {
15
+ throw new error(ex.message || "Could not delete group.", ex.code || "DELETE_GROUP_ERROR", {
16
+ error: ex,
17
+ group,
18
+ keys
19
+ });
20
+ }
21
+ }
22
+ }
23
+ const DdbDeleteGroup = DeleteGroupStorageOperation.createImplementation({
24
+ implementation: DdbDeleteGroupImpl,
25
+ dependencies: [
26
+ CmsDdbGroupEntity
27
+ ]
28
+ });
29
+ export { DdbDeleteGroup };
30
+
31
+ //# sourceMappingURL=DdbDeleteGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/group/DdbDeleteGroup.js","sources":["../../../src/operations/group/DdbDeleteGroup.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsDeleteParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { DeleteGroupStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/DeleteGroupStorageOperation.js\";\nimport { CmsDdbGroupEntity } from \"~/abstractions/CmsDdbGroupEntity.js\";\nimport { createKeys } from \"./keys.js\";\n\nclass DdbDeleteGroupImpl implements DeleteGroupStorageOperation.Interface {\n constructor(private entity: CmsDdbGroupEntity.Interface) {}\n\n async execute(params: CmsGroupStorageOperationsDeleteParams) {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await this.entity.delete(keys);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete group.\",\n ex.code || \"DELETE_GROUP_ERROR\",\n { error: ex, group, keys }\n );\n }\n }\n}\n\nexport const DdbDeleteGroup = DeleteGroupStorageOperation.createImplementation({\n implementation: DdbDeleteGroupImpl,\n dependencies: [CmsDdbGroupEntity]\n});\n"],"names":["DdbDeleteGroupImpl","entity","params","group","keys","createKeys","ex","WebinyError","DdbDeleteGroup","DeleteGroupStorageOperation","CmsDdbGroupEntity"],"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 { CmsGroupStorageOperationsGetParams } from "@webiny/api-headless-cms/types/index.js";
2
+ import { GetGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/GetGroupStorageOperation.js";
3
+ import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
4
+ declare class DdbGetGroupImpl implements GetGroupStorageOperation.Interface {
5
+ private entity;
6
+ constructor(entity: CmsDdbGroupEntity.Interface);
7
+ execute(params: CmsGroupStorageOperationsGetParams): Promise<import("@webiny/api-headless-cms/types/modelGroup.js").CmsGroup | null>;
8
+ }
9
+ export declare const DdbGetGroup: typeof DdbGetGroupImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/group/GetGroupStorageOperation.js").IGetGroupStorageOperation>;
11
+ };
12
+ export {};
@@ -0,0 +1,31 @@
1
+ import error from "@webiny/error";
2
+ import { GetGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/GetGroupStorageOperation.js";
3
+ import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
4
+ import { createKeys } from "./keys.js";
5
+ class DdbGetGroupImpl {
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 group.", ex.code || "GET_GROUP_ERROR", {
16
+ error: ex,
17
+ ...params,
18
+ keys
19
+ });
20
+ }
21
+ }
22
+ }
23
+ const DdbGetGroup = GetGroupStorageOperation.createImplementation({
24
+ implementation: DdbGetGroupImpl,
25
+ dependencies: [
26
+ CmsDdbGroupEntity
27
+ ]
28
+ });
29
+ export { DdbGetGroup };
30
+
31
+ //# sourceMappingURL=DdbGetGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/group/DdbGetGroup.js","sources":["../../../src/operations/group/DdbGetGroup.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsGetParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { GetGroupStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/GetGroupStorageOperation.js\";\nimport { CmsDdbGroupEntity } from \"~/abstractions/CmsDdbGroupEntity.js\";\nimport { createKeys } from \"./keys.js\";\n\nclass DdbGetGroupImpl implements GetGroupStorageOperation.Interface {\n constructor(private entity: CmsDdbGroupEntity.Interface) {}\n\n async execute(params: CmsGroupStorageOperationsGetParams) {\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 group.\",\n ex.code || \"GET_GROUP_ERROR\",\n { error: ex, ...params, keys }\n );\n }\n }\n}\n\nexport const DdbGetGroup = GetGroupStorageOperation.createImplementation({\n implementation: DdbGetGroupImpl,\n dependencies: [CmsDdbGroupEntity]\n});\n"],"names":["DdbGetGroupImpl","entity","params","keys","createKeys","result","ex","WebinyError","DdbGetGroup","GetGroupStorageOperation","CmsDdbGroupEntity"],"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;gBAAI,GAAGJ,MAAM;gBAAEC;YAAK;QAErC;IACJ;AACJ;AAEO,MAAMK,cAAcC,yBAAyB,oBAAoB,CAAC;IACrE,gBAAgBT;IAChB,cAAc;QAACU;KAAkB;AACrC"}
@@ -0,0 +1,14 @@
1
+ import type { CmsGroup, CmsGroupStorageOperationsListParams } from "@webiny/api-headless-cms/types/index.js";
2
+ import { ListGroupsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/ListGroupsStorageOperation.js";
3
+ import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
4
+ import { FilterUtil } from "@webiny/db-dynamodb/feature/FilterUtil/index.js";
5
+ declare class DdbListGroupsImpl implements ListGroupsStorageOperation.Interface {
6
+ private entity;
7
+ private filterUtil;
8
+ constructor(entity: CmsDdbGroupEntity.Interface, filterUtil: FilterUtil.Interface);
9
+ execute(params: CmsGroupStorageOperationsListParams): Promise<CmsGroup[]>;
10
+ }
11
+ export declare const DdbListGroups: typeof DdbListGroupsImpl & {
12
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/group/ListGroupsStorageOperation.js").IListGroupsStorageOperation>;
13
+ };
14
+ export {};
@@ -0,0 +1,52 @@
1
+ import error from "@webiny/error";
2
+ import { sortItems } from "@webiny/db-dynamodb";
3
+ import { ListGroupsStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/ListGroupsStorageOperation.js";
4
+ import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
5
+ import { FilterUtil } from "@webiny/db-dynamodb/feature/FilterUtil/index.js";
6
+ import { createPartitionKey } from "./keys.js";
7
+ class DdbListGroupsImpl {
8
+ constructor(entity, filterUtil){
9
+ this.entity = entity;
10
+ this.filterUtil = filterUtil;
11
+ }
12
+ async execute(params) {
13
+ const { sort, where } = params;
14
+ let records = [];
15
+ try {
16
+ const ddbRecords = await this.entity.queryAll({
17
+ partitionKey: createPartitionKey(where),
18
+ options: {
19
+ gte: " "
20
+ }
21
+ });
22
+ records = ddbRecords.map((item)=>item.data);
23
+ } catch (ex) {
24
+ throw new error(ex.message || "Could not list groups.", ex.code || "LIST_GROUP_ERROR", {
25
+ error: ex,
26
+ ...params,
27
+ sort,
28
+ where
29
+ });
30
+ }
31
+ const filteredItems = this.filterUtil.filter({
32
+ items: records,
33
+ where,
34
+ fields: []
35
+ });
36
+ if (!sort || 0 === sort.length) return filteredItems;
37
+ return sortItems({
38
+ items: filteredItems,
39
+ sort
40
+ });
41
+ }
42
+ }
43
+ const DdbListGroups = ListGroupsStorageOperation.createImplementation({
44
+ implementation: DdbListGroupsImpl,
45
+ dependencies: [
46
+ CmsDdbGroupEntity,
47
+ FilterUtil
48
+ ]
49
+ });
50
+ export { DdbListGroups };
51
+
52
+ //# sourceMappingURL=DdbListGroups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/group/DdbListGroups.js","sources":["../../../src/operations/group/DdbListGroups.ts"],"sourcesContent":["import type {\n CmsGroup,\n CmsGroupStorageOperationsListParams\n} from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { sortItems } from \"@webiny/db-dynamodb\";\nimport { ListGroupsStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/ListGroupsStorageOperation.js\";\nimport { CmsDdbGroupEntity } from \"~/abstractions/CmsDdbGroupEntity.js\";\nimport { FilterUtil } from \"@webiny/db-dynamodb/feature/FilterUtil/index.js\";\nimport { createPartitionKey } from \"./keys.js\";\n\nclass DdbListGroupsImpl implements ListGroupsStorageOperation.Interface {\n constructor(\n private entity: CmsDdbGroupEntity.Interface,\n private filterUtil: FilterUtil.Interface\n ) {}\n\n async execute(params: CmsGroupStorageOperationsListParams) {\n const { sort, where } = params;\n\n let records: CmsGroup[] = [];\n try {\n const ddbRecords = await this.entity.queryAll({\n partitionKey: createPartitionKey(where),\n options: { gte: \" \" }\n });\n records = ddbRecords.map(item => item.data);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list groups.\",\n ex.code || \"LIST_GROUP_ERROR\",\n { error: ex, ...params, sort, where }\n );\n }\n\n const filteredItems = this.filterUtil.filter({\n items: records,\n where,\n fields: []\n });\n if (!sort || sort.length === 0) {\n return filteredItems;\n }\n\n return sortItems({ items: filteredItems, sort });\n }\n}\n\nexport const DdbListGroups = ListGroupsStorageOperation.createImplementation({\n implementation: DdbListGroupsImpl,\n dependencies: [CmsDdbGroupEntity, FilterUtil]\n});\n"],"names":["DdbListGroupsImpl","entity","filterUtil","params","sort","where","records","ddbRecords","createPartitionKey","item","ex","WebinyError","filteredItems","sortItems","DdbListGroups","ListGroupsStorageOperation","CmsDdbGroupEntity","FilterUtil"],"mappings":";;;;;;AAWA,MAAMA;IACF,YACYC,MAAmC,EACnCC,UAAgC,CAC1C;aAFUD,MAAM,GAANA;aACAC,UAAU,GAAVA;IACT;IAEH,MAAM,QAAQC,MAA2C,EAAE;QACvD,MAAM,EAAEC,IAAI,EAAEC,KAAK,EAAE,GAAGF;QAExB,IAAIG,UAAsB,EAAE;QAC5B,IAAI;YACA,MAAMC,aAAa,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;gBAC1C,cAAcC,mBAAmBH;gBACjC,SAAS;oBAAE,KAAK;gBAAI;YACxB;YACAC,UAAUC,WAAW,GAAG,CAACE,CAAAA,OAAQA,KAAK,IAAI;QAC9C,EAAE,OAAOC,IAAI;YACT,MAAM,IAAIC,MACND,GAAG,OAAO,IAAI,0BACdA,GAAG,IAAI,IAAI,oBACX;gBAAE,OAAOA;gBAAI,GAAGP,MAAM;gBAAEC;gBAAMC;YAAM;QAE5C;QAEA,MAAMO,gBAAgB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;YACzC,OAAON;YACPD;YACA,QAAQ,EAAE;QACd;QACA,IAAI,CAACD,QAAQA,AAAgB,MAAhBA,KAAK,MAAM,EACpB,OAAOQ;QAGX,OAAOC,UAAU;YAAE,OAAOD;YAAeR;QAAK;IAClD;AACJ;AAEO,MAAMU,gBAAgBC,2BAA2B,oBAAoB,CAAC;IACzE,gBAAgBf;IAChB,cAAc;QAACgB;QAAmBC;KAAW;AACjD"}
@@ -0,0 +1,12 @@
1
+ import type { CmsGroupStorageOperationsUpdateParams } from "@webiny/api-headless-cms/types/index.js";
2
+ import { UpdateGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/UpdateGroupStorageOperation.js";
3
+ import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
4
+ declare class DdbUpdateGroupImpl implements UpdateGroupStorageOperation.Interface {
5
+ private entity;
6
+ constructor(entity: CmsDdbGroupEntity.Interface);
7
+ execute(params: CmsGroupStorageOperationsUpdateParams): Promise<void>;
8
+ }
9
+ export declare const DdbUpdateGroup: typeof DdbUpdateGroupImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/group/UpdateGroupStorageOperation.js").IUpdateGroupStorageOperation>;
11
+ };
12
+ export {};
@@ -0,0 +1,35 @@
1
+ import error from "@webiny/error";
2
+ import { UpdateGroupStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/group/UpdateGroupStorageOperation.js";
3
+ import { CmsDdbGroupEntity } from "../../abstractions/CmsDdbGroupEntity.js";
4
+ import { createKeys, createType } from "./keys.js";
5
+ class DdbUpdateGroupImpl {
6
+ constructor(entity){
7
+ this.entity = entity;
8
+ }
9
+ async execute(params) {
10
+ const { group } = params;
11
+ const keys = createKeys(group);
12
+ try {
13
+ await this.entity.put({
14
+ data: group,
15
+ TYPE: createType(),
16
+ ...keys
17
+ });
18
+ } catch (ex) {
19
+ throw new error(ex.message || "Could not update group.", ex.code || "UPDATE_GROUP_ERROR", {
20
+ error: ex,
21
+ group,
22
+ keys
23
+ });
24
+ }
25
+ }
26
+ }
27
+ const DdbUpdateGroup = UpdateGroupStorageOperation.createImplementation({
28
+ implementation: DdbUpdateGroupImpl,
29
+ dependencies: [
30
+ CmsDdbGroupEntity
31
+ ]
32
+ });
33
+ export { DdbUpdateGroup };
34
+
35
+ //# sourceMappingURL=DdbUpdateGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/group/DdbUpdateGroup.js","sources":["../../../src/operations/group/DdbUpdateGroup.ts"],"sourcesContent":["import type { CmsGroupStorageOperationsUpdateParams } from \"@webiny/api-headless-cms/types/index.js\";\nimport WebinyError from \"@webiny/error\";\nimport { UpdateGroupStorageOperation } from \"@webiny/api-headless-cms/features/shared/storageOperations/group/UpdateGroupStorageOperation.js\";\nimport { CmsDdbGroupEntity } from \"~/abstractions/CmsDdbGroupEntity.js\";\nimport { createKeys, createType } from \"./keys.js\";\n\nclass DdbUpdateGroupImpl implements UpdateGroupStorageOperation.Interface {\n constructor(private entity: CmsDdbGroupEntity.Interface) {}\n\n async execute(params: CmsGroupStorageOperationsUpdateParams) {\n const { group } = params;\n const keys = createKeys(group);\n try {\n await this.entity.put({\n data: group,\n TYPE: createType(),\n ...keys\n });\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update group.\",\n ex.code || \"UPDATE_GROUP_ERROR\",\n { error: ex, group, keys }\n );\n }\n }\n}\n\nexport const DdbUpdateGroup = UpdateGroupStorageOperation.createImplementation({\n implementation: DdbUpdateGroupImpl,\n dependencies: [CmsDdbGroupEntity]\n});\n"],"names":["DdbUpdateGroupImpl","entity","params","group","keys","createKeys","createType","ex","WebinyError","DdbUpdateGroup","UpdateGroupStorageOperation","CmsDdbGroupEntity"],"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,MAAMG;gBACN,GAAGF,IAAI;YACX;QACJ,EAAE,OAAOG,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 DdbGroupStorageOpsFeature: {
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 { DdbGetGroup } from "./DdbGetGroup.js";
3
+ import { DdbListGroups } from "./DdbListGroups.js";
4
+ import { DdbCreateGroup } from "./DdbCreateGroup.js";
5
+ import { DdbUpdateGroup } from "./DdbUpdateGroup.js";
6
+ import { DdbDeleteGroup } from "./DdbDeleteGroup.js";
7
+ const DdbGroupStorageOpsFeature = createFeature({
8
+ name: "cms.ddb.groupStorageOps",
9
+ register: (container)=>{
10
+ container.register(DdbGetGroup);
11
+ container.register(DdbListGroups);
12
+ container.register(DdbCreateGroup);
13
+ container.register(DdbUpdateGroup);
14
+ container.register(DdbDeleteGroup);
15
+ }
16
+ });
17
+ export { DdbGroupStorageOpsFeature };
18
+
19
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/group/feature.js","sources":["../../../src/operations/group/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { DdbGetGroup } from \"./DdbGetGroup.js\";\nimport { DdbListGroups } from \"./DdbListGroups.js\";\nimport { DdbCreateGroup } from \"./DdbCreateGroup.js\";\nimport { DdbUpdateGroup } from \"./DdbUpdateGroup.js\";\nimport { DdbDeleteGroup } from \"./DdbDeleteGroup.js\";\n\nexport const DdbGroupStorageOpsFeature = createFeature({\n name: \"cms.ddb.groupStorageOps\",\n register: container => {\n container.register(DdbGetGroup);\n container.register(DdbListGroups);\n container.register(DdbCreateGroup);\n container.register(DdbUpdateGroup);\n container.register(DdbDeleteGroup);\n }\n});\n"],"names":["DdbGroupStorageOpsFeature","createFeature","container","DdbGetGroup","DdbListGroups","DdbCreateGroup","DdbUpdateGroup","DdbDeleteGroup"],"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 PartitionKeyParams {
2
+ tenant: string;
3
+ }
4
+ export declare const createPartitionKey: (params: PartitionKeyParams) => string;
5
+ interface SortKeyParams {
6
+ id: string;
7
+ }
8
+ interface Keys {
9
+ PK: string;
10
+ SK: string;
11
+ GSI_TENANT: string;
12
+ }
13
+ export declare const createKeys: (params: PartitionKeyParams & SortKeyParams) => Keys;
14
+ export declare const createType: () => string;
15
+ export {};
@@ -0,0 +1,17 @@
1
+ const createPartitionKey = (params)=>{
2
+ const { tenant } = params;
3
+ return `T#${tenant}#CMS#CMG`;
4
+ };
5
+ const createSortKeys = (params)=>{
6
+ const { id } = params;
7
+ return id;
8
+ };
9
+ const createKeys = (params)=>({
10
+ PK: createPartitionKey(params),
11
+ SK: createSortKeys(params),
12
+ GSI_TENANT: params.tenant
13
+ });
14
+ const createType = ()=>"cms.group";
15
+ export { createKeys, createPartitionKey, createType };
16
+
17
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations/group/keys.js","sources":["../../../src/operations/group/keys.ts"],"sourcesContent":["interface PartitionKeyParams {\n tenant: string;\n}\n\nexport const createPartitionKey = (params: PartitionKeyParams): string => {\n const { tenant } = params;\n return `T#${tenant}#CMS#CMG`;\n};\n\ninterface SortKeyParams {\n id: string;\n}\n\nconst createSortKeys = (params: SortKeyParams): string => {\n const { id } = params;\n return id;\n};\n\ninterface Keys {\n PK: string;\n SK: string;\n GSI_TENANT: string;\n}\n\nexport const createKeys = (params: PartitionKeyParams & SortKeyParams): Keys => {\n return {\n PK: createPartitionKey(params),\n SK: createSortKeys(params),\n GSI_TENANT: params.tenant\n };\n};\n\nexport const createType = (): string => {\n return \"cms.group\";\n};\n"],"names":["createPartitionKey","params","tenant","createSortKeys","id","createKeys","createType"],"mappings":"AAIO,MAAMA,qBAAqB,CAACC;IAC/B,MAAM,EAAEC,MAAM,EAAE,GAAGD;IACnB,OAAO,CAAC,EAAE,EAAEC,OAAO,QAAQ,CAAC;AAChC;AAMA,MAAMC,iBAAiB,CAACF;IACpB,MAAM,EAAEG,EAAE,EAAE,GAAGH;IACf,OAAOG;AACX;AAQO,MAAMC,aAAa,CAACJ,SAChB;QACH,IAAID,mBAAmBC;QACvB,IAAIE,eAAeF;QACnB,YAAYA,OAAO,MAAM;IAC7B;AAGG,MAAMK,aAAa,IACf"}
@@ -0,0 +1,12 @@
1
+ import type { CmsModelStorageOperationsCreateParams } from "@webiny/api-headless-cms/types/index.js";
2
+ import { CreateModelStorageOperation } from "@webiny/api-headless-cms/features/shared/storageOperations/model/CreateModelStorageOperation.js";
3
+ import { CmsDdbModelEntity } from "../../abstractions/CmsDdbModelEntity.js";
4
+ declare class DdbCreateModelImpl implements CreateModelStorageOperation.Interface {
5
+ private entity;
6
+ constructor(entity: CmsDdbModelEntity.Interface);
7
+ execute(params: CmsModelStorageOperationsCreateParams): Promise<import("@webiny/api-headless-cms/types/model.js").StorageCmsModel>;
8
+ }
9
+ export declare const DdbCreateModel: typeof DdbCreateModelImpl & {
10
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-headless-cms/features/shared/storageOperations/model/CreateModelStorageOperation.js").ICreateModelStorageOperation>;
11
+ };
12
+ export {};
@@ -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"}