@webiny/api-page-builder-so-ddb-es 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f

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 (229) hide show
  1. package/configurations.d.ts +18 -0
  2. package/configurations.js +53 -0
  3. package/configurations.js.map +1 -0
  4. package/definitions/blockCategoryEntity.d.ts +10 -0
  5. package/definitions/blockCategoryEntity.js +57 -0
  6. package/definitions/blockCategoryEntity.js.map +1 -0
  7. package/definitions/categoryEntity.d.ts +10 -6
  8. package/definitions/categoryEntity.js +12 -23
  9. package/definitions/categoryEntity.js.map +1 -0
  10. package/definitions/menuEntity.d.ts +10 -6
  11. package/definitions/menuEntity.js +12 -23
  12. package/definitions/menuEntity.js.map +1 -0
  13. package/definitions/pageBlockEntity.d.ts +10 -0
  14. package/definitions/pageBlockEntity.js +74 -0
  15. package/definitions/pageBlockEntity.js.map +1 -0
  16. package/definitions/pageElasticsearchEntity.d.ts +10 -6
  17. package/definitions/pageElasticsearchEntity.js +15 -23
  18. package/definitions/pageElasticsearchEntity.js.map +1 -0
  19. package/definitions/pageElementEntity.d.ts +10 -6
  20. package/definitions/pageElementEntity.js +12 -23
  21. package/definitions/pageElementEntity.js.map +1 -0
  22. package/definitions/pageEntity.d.ts +10 -6
  23. package/definitions/pageEntity.js +20 -32
  24. package/definitions/pageEntity.js.map +1 -0
  25. package/definitions/pageTemplateEntity.d.ts +10 -0
  26. package/definitions/pageTemplateEntity.js +42 -0
  27. package/definitions/pageTemplateEntity.js.map +1 -0
  28. package/definitions/settingsEntity.d.ts +8 -6
  29. package/definitions/settingsEntity.js +11 -54
  30. package/definitions/settingsEntity.js.map +1 -0
  31. package/definitions/systemEntity.d.ts +10 -6
  32. package/definitions/systemEntity.js +15 -23
  33. package/definitions/systemEntity.js.map +1 -0
  34. package/definitions/table.d.ts +8 -5
  35. package/definitions/table.js +22 -21
  36. package/definitions/table.js.map +1 -0
  37. package/definitions/tableElasticsearch.d.ts +9 -5
  38. package/definitions/tableElasticsearch.js +16 -28
  39. package/definitions/tableElasticsearch.js.map +1 -0
  40. package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
  41. package/elasticsearch/createElasticsearchIndex.js +41 -0
  42. package/elasticsearch/createElasticsearchIndex.js.map +1 -0
  43. package/elasticsearch/indices/base.d.ts +2 -0
  44. package/elasticsearch/indices/base.js +14 -0
  45. package/elasticsearch/indices/base.js.map +1 -0
  46. package/elasticsearch/indices/index.d.ts +1 -0
  47. package/elasticsearch/indices/index.js +14 -0
  48. package/elasticsearch/indices/index.js.map +1 -0
  49. package/elasticsearch/indices/japanese.d.ts +2 -0
  50. package/elasticsearch/indices/japanese.js +15 -0
  51. package/elasticsearch/indices/japanese.js.map +1 -0
  52. package/index.d.ts +3 -8
  53. package/index.js +246 -16
  54. package/index.js.map +1 -0
  55. package/operations/blockCategory/dataLoader.d.ts +17 -0
  56. package/operations/blockCategory/dataLoader.js +63 -0
  57. package/operations/blockCategory/dataLoader.js.map +1 -0
  58. package/operations/blockCategory/fields.d.ts +2 -0
  59. package/operations/blockCategory/fields.js +27 -0
  60. package/operations/blockCategory/fields.js.map +1 -0
  61. package/operations/blockCategory/index.d.ts +8 -0
  62. package/operations/blockCategory/index.js +192 -0
  63. package/operations/blockCategory/index.js.map +1 -0
  64. package/operations/blockCategory/keys.d.ts +9 -0
  65. package/operations/blockCategory/keys.js +23 -0
  66. package/operations/blockCategory/keys.js.map +1 -0
  67. package/operations/category/dataLoader.d.ts +17 -0
  68. package/operations/category/{CategoryDataLoader.js → dataLoader.js} +13 -27
  69. package/operations/category/dataLoader.js.map +1 -0
  70. package/operations/category/fields.d.ts +1 -2
  71. package/operations/category/fields.js +4 -5
  72. package/operations/category/fields.js.map +1 -0
  73. package/operations/category/index.d.ts +7 -4
  74. package/operations/category/index.js +185 -21
  75. package/operations/category/index.js.map +1 -0
  76. package/operations/category/keys.d.ts +9 -0
  77. package/operations/category/keys.js +23 -0
  78. package/operations/category/keys.js.map +1 -0
  79. package/operations/menu/fields.d.ts +1 -2
  80. package/operations/menu/fields.js +19 -18
  81. package/operations/menu/fields.js.map +1 -0
  82. package/operations/menu/index.d.ts +7 -4
  83. package/operations/menu/index.js +193 -21
  84. package/operations/menu/index.js.map +1 -0
  85. package/operations/pageBlock/compression.d.ts +18 -0
  86. package/operations/pageBlock/compression.js +42 -0
  87. package/operations/pageBlock/compression.js.map +1 -0
  88. package/operations/pageBlock/dataLoader.d.ts +17 -0
  89. package/operations/pageBlock/dataLoader.js +63 -0
  90. package/operations/pageBlock/dataLoader.js.map +1 -0
  91. package/operations/pageBlock/fields.d.ts +2 -0
  92. package/operations/pageBlock/fields.js +24 -0
  93. package/operations/pageBlock/fields.js.map +1 -0
  94. package/operations/pageBlock/index.d.ts +8 -0
  95. package/operations/pageBlock/index.js +219 -0
  96. package/operations/pageBlock/index.js.map +1 -0
  97. package/operations/pageBlock/keys.d.ts +20 -0
  98. package/operations/pageBlock/keys.js +37 -0
  99. package/operations/pageBlock/keys.js.map +1 -0
  100. package/operations/pageElement/fields.d.ts +1 -2
  101. package/operations/pageElement/fields.js +4 -5
  102. package/operations/pageElement/fields.js.map +1 -0
  103. package/operations/pageElement/index.d.ts +7 -6
  104. package/operations/pageElement/index.js +182 -21
  105. package/operations/pageElement/index.js.map +1 -0
  106. package/operations/pageTemplate/dataLoader.d.ts +17 -0
  107. package/operations/pageTemplate/dataLoader.js +62 -0
  108. package/operations/pageTemplate/dataLoader.js.map +1 -0
  109. package/operations/pageTemplate/fields.d.ts +2 -0
  110. package/operations/pageTemplate/fields.js +24 -0
  111. package/operations/pageTemplate/fields.js.map +1 -0
  112. package/operations/pageTemplate/index.d.ts +8 -0
  113. package/operations/pageTemplate/index.js +204 -0
  114. package/operations/pageTemplate/index.js.map +1 -0
  115. package/operations/pageTemplate/keys.d.ts +5 -0
  116. package/operations/pageTemplate/keys.js +23 -0
  117. package/operations/pageTemplate/keys.js.map +1 -0
  118. package/operations/pages/elasticsearchQueryBody.d.ts +8 -12
  119. package/operations/pages/elasticsearchQueryBody.js +43 -101
  120. package/operations/pages/elasticsearchQueryBody.js.map +1 -0
  121. package/operations/pages/fields.d.ts +3 -2
  122. package/operations/pages/fields.js +18 -5
  123. package/operations/pages/fields.js.map +1 -0
  124. package/operations/pages/helpers.d.ts +10 -18
  125. package/operations/pages/helpers.js +34 -33
  126. package/operations/pages/helpers.js.map +1 -0
  127. package/operations/pages/index.d.ts +10 -4
  128. package/operations/pages/index.js +785 -18
  129. package/operations/pages/index.js.map +1 -0
  130. package/operations/pages/keys.d.ts +24 -0
  131. package/operations/pages/keys.js +59 -0
  132. package/operations/pages/keys.js.map +1 -0
  133. package/operations/pages/logIgnoredEsResponseError.d.ts +7 -0
  134. package/operations/pages/logIgnoredEsResponseError.js +28 -0
  135. package/operations/pages/logIgnoredEsResponseError.js.map +1 -0
  136. package/operations/pages/shouldIgnoreEsResponseError.d.ts +2 -0
  137. package/operations/pages/shouldIgnoreEsResponseError.js +13 -0
  138. package/operations/pages/shouldIgnoreEsResponseError.js.map +1 -0
  139. package/operations/settings/index.d.ts +11 -6
  140. package/operations/settings/index.js +140 -15
  141. package/operations/settings/index.js.map +1 -0
  142. package/operations/system/index.d.ts +5 -4
  143. package/operations/system/index.js +94 -23
  144. package/operations/system/index.js.map +1 -0
  145. package/package.json +44 -36
  146. package/plugins/definitions/BlockCategoryDynamoDbElasticFieldPlugin.d.ts +4 -0
  147. package/plugins/definitions/BlockCategoryDynamoDbElasticFieldPlugin.js +13 -0
  148. package/plugins/definitions/BlockCategoryDynamoDbElasticFieldPlugin.js.map +1 -0
  149. package/plugins/definitions/CategoryDynamoDbElasticFieldPlugin.js +5 -9
  150. package/plugins/definitions/CategoryDynamoDbElasticFieldPlugin.js.map +1 -0
  151. package/plugins/definitions/IndexPageDataPlugin.d.ts +12 -11
  152. package/plugins/definitions/IndexPageDataPlugin.js +3 -12
  153. package/plugins/definitions/IndexPageDataPlugin.js.map +1 -0
  154. package/plugins/definitions/MenuDynamoDbElasticFieldPlugin.js +5 -9
  155. package/plugins/definitions/MenuDynamoDbElasticFieldPlugin.js.map +1 -0
  156. package/plugins/definitions/PageBlockDynamoDbFieldPlugin.d.ts +4 -0
  157. package/plugins/definitions/PageBlockDynamoDbFieldPlugin.js +13 -0
  158. package/plugins/definitions/PageBlockDynamoDbFieldPlugin.js.map +1 -0
  159. package/plugins/definitions/PageDynamoDbElasticsearchFieldPlugin.d.ts +4 -0
  160. package/plugins/definitions/PageDynamoDbElasticsearchFieldPlugin.js +13 -0
  161. package/plugins/definitions/PageDynamoDbElasticsearchFieldPlugin.js.map +1 -0
  162. package/plugins/definitions/PageElasticsearchBodyModifierPlugin.d.ts +6 -2
  163. package/plugins/definitions/PageElasticsearchBodyModifierPlugin.js +6 -10
  164. package/plugins/definitions/PageElasticsearchBodyModifierPlugin.js.map +1 -0
  165. package/plugins/definitions/PageElasticsearchFieldPlugin.d.ts +1 -2
  166. package/plugins/definitions/PageElasticsearchFieldPlugin.js +5 -14
  167. package/plugins/definitions/PageElasticsearchFieldPlugin.js.map +1 -0
  168. package/plugins/definitions/PageElasticsearchIndexPlugin.d.ts +4 -0
  169. package/plugins/definitions/PageElasticsearchIndexPlugin.js +13 -0
  170. package/plugins/definitions/PageElasticsearchIndexPlugin.js.map +1 -0
  171. package/plugins/definitions/PageElasticsearchQueryModifierPlugin.d.ts +8 -2
  172. package/plugins/definitions/PageElasticsearchQueryModifierPlugin.js +6 -10
  173. package/plugins/definitions/PageElasticsearchQueryModifierPlugin.js.map +1 -0
  174. package/plugins/definitions/PageElasticsearchSortModifierPlugin.d.ts +6 -2
  175. package/plugins/definitions/PageElasticsearchSortModifierPlugin.js +6 -10
  176. package/plugins/definitions/PageElasticsearchSortModifierPlugin.js.map +1 -0
  177. package/plugins/definitions/PageElementDynamoDbElasticFieldPlugin.js +5 -9
  178. package/plugins/definitions/PageElementDynamoDbElasticFieldPlugin.js.map +1 -0
  179. package/plugins/definitions/PageTemplateDynamoDbElasticFieldPlugin.d.ts +4 -0
  180. package/plugins/definitions/PageTemplateDynamoDbElasticFieldPlugin.js +13 -0
  181. package/plugins/definitions/PageTemplateDynamoDbElasticFieldPlugin.js.map +1 -0
  182. package/plugins/definitions/SearchLatestPagesPlugin.d.ts +1 -1
  183. package/plugins/definitions/SearchLatestPagesPlugin.js +5 -9
  184. package/plugins/definitions/SearchLatestPagesPlugin.js.map +1 -0
  185. package/plugins/definitions/SearchPagesPlugin.d.ts +4 -4
  186. package/plugins/definitions/SearchPagesPlugin.js +2 -13
  187. package/plugins/definitions/SearchPagesPlugin.js.map +1 -0
  188. package/plugins/definitions/SearchPublishedPagesPlugin.d.ts +1 -1
  189. package/plugins/definitions/SearchPublishedPagesPlugin.js +5 -9
  190. package/plugins/definitions/SearchPublishedPagesPlugin.js.map +1 -0
  191. package/plugins/definitions/index.d.ts +15 -0
  192. package/plugins/definitions/index.js +172 -0
  193. package/plugins/definitions/index.js.map +1 -0
  194. package/plugins/index.d.ts +1 -0
  195. package/plugins/index.js +18 -0
  196. package/plugins/index.js.map +1 -0
  197. package/tasks/createIndexTaskPlugin.d.ts +2 -0
  198. package/tasks/createIndexTaskPlugin.js +36 -0
  199. package/tasks/createIndexTaskPlugin.js.map +1 -0
  200. package/types.d.ts +63 -0
  201. package/types.js +21 -0
  202. package/types.js.map +1 -0
  203. package/operations/category/CategoryDataLoader.d.ts +0 -20
  204. package/operations/category/CategoryStorageOperations.d.ts +0 -29
  205. package/operations/category/CategoryStorageOperations.js +0 -243
  206. package/operations/configurations.d.ts +0 -36
  207. package/operations/configurations.js +0 -71
  208. package/operations/menu/MenuStorageOperations.d.ts +0 -23
  209. package/operations/menu/MenuStorageOperations.js +0 -235
  210. package/operations/pageElement/PageElementStorageOperations.d.ts +0 -23
  211. package/operations/pageElement/PageElementStorageOperations.js +0 -234
  212. package/operations/pages/PageStorageOperations.d.ts +0 -79
  213. package/operations/pages/PageStorageOperations.js +0 -1117
  214. package/operations/settings/SettingsStorageOperations.d.ts +0 -35
  215. package/operations/settings/SettingsStorageOperations.js +0 -191
  216. package/operations/system/InstallationDdbEsPlugin.d.ts +0 -2
  217. package/operations/system/InstallationDdbEsPlugin.js +0 -73
  218. package/operations/system/SystemStorageOperations.d.ts +0 -16
  219. package/operations/system/SystemStorageOperations.js +0 -114
  220. package/upgrades/index.d.ts +0 -2
  221. package/upgrades/index.js +0 -14
  222. package/upgrades/v5.15.0/category.d.ts +0 -2
  223. package/upgrades/v5.15.0/category.js +0 -75
  224. package/upgrades/v5.15.0/index.d.ts +0 -4
  225. package/upgrades/v5.15.0/index.js +0 -52
  226. package/upgrades/v5.15.0/menu.d.ts +0 -2
  227. package/upgrades/v5.15.0/menu.js +0 -75
  228. package/upgrades/v5.15.0/pageElement.d.ts +0 -2
  229. package/upgrades/v5.15.0/pageElement.js +0 -75
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.PageTemplateDataLoader = void 0;
8
+ var _dataloader = _interopRequireDefault(require("dataloader"));
9
+ var _dbDynamodb = require("@webiny/db-dynamodb");
10
+ var _keys = require("./keys");
11
+ class PageTemplateDataLoader {
12
+ _getDataLoader = undefined;
13
+ constructor(params) {
14
+ this.entity = params.entity;
15
+ }
16
+ async getOne(item) {
17
+ return await this.getDataLoader().load(item);
18
+ }
19
+ async getAll(items) {
20
+ return await this.getDataLoader().loadMany(items);
21
+ }
22
+ clear() {
23
+ this.getDataLoader().clearAll();
24
+ }
25
+ getDataLoader() {
26
+ if (!this._getDataLoader) {
27
+ const cacheKeyFn = key => {
28
+ return `T#${key.tenant}#L#${key.locale}#${key.id}`;
29
+ };
30
+ this._getDataLoader = new _dataloader.default(async items => {
31
+ const batched = items.map(item => {
32
+ return this.entity.getBatch({
33
+ PK: (0, _keys.createPrimaryPK)(item),
34
+ SK: "A"
35
+ });
36
+ });
37
+ const records = await (0, _dbDynamodb.batchReadAll)({
38
+ table: this.entity.table,
39
+ items: batched
40
+ });
41
+ const results = records.reduce((collection, result) => {
42
+ if (!result) {
43
+ return collection;
44
+ }
45
+ const key = cacheKeyFn(result.data);
46
+ collection[key] = result.data;
47
+ return collection;
48
+ }, {});
49
+ return items.map(item => {
50
+ const key = cacheKeyFn(item);
51
+ return results[key] || null;
52
+ });
53
+ }, {
54
+ cacheKeyFn
55
+ });
56
+ }
57
+ return this._getDataLoader;
58
+ }
59
+ }
60
+ exports.PageTemplateDataLoader = PageTemplateDataLoader;
61
+
62
+ //# sourceMappingURL=dataLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_dataloader","_interopRequireDefault","require","_dbDynamodb","_keys","PageTemplateDataLoader","_getDataLoader","undefined","constructor","params","entity","getOne","item","getDataLoader","load","getAll","items","loadMany","clear","clearAll","cacheKeyFn","key","tenant","locale","id","DataLoader","batched","map","getBatch","PK","createPrimaryPK","SK","records","batchReadAll","table","results","reduce","collection","result","data","exports"],"sources":["dataLoader.ts"],"sourcesContent":["import DataLoader from \"dataloader\";\nimport { batchReadAll } from \"@webiny/db-dynamodb\";\nimport type { PageTemplate } from \"@webiny/api-page-builder/types\";\nimport type { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport { createPrimaryPK } from \"./keys\";\nimport type { DataContainer, DataLoaderInterface } from \"~/types\";\n\ninterface Params {\n entity: Entity<any>;\n}\n\ntype DataLoaderGetItem = Pick<PageTemplate, \"id\" | \"tenant\" | \"locale\">;\n\nexport class PageTemplateDataLoader implements DataLoaderInterface {\n private _getDataLoader: DataLoader<any, any> | undefined = undefined;\n\n private readonly entity: Entity<any>;\n\n constructor(params: Params) {\n this.entity = params.entity;\n }\n\n public async getOne(item: DataLoaderGetItem): Promise<PageTemplate> {\n return await this.getDataLoader().load(item);\n }\n\n public async getAll(items: DataLoaderGetItem[]): Promise<PageTemplate[]> {\n return await this.getDataLoader().loadMany(items);\n }\n\n public clear(): void {\n this.getDataLoader().clearAll();\n }\n\n private getDataLoader() {\n if (!this._getDataLoader) {\n const cacheKeyFn = (key: DataLoaderGetItem) => {\n return `T#${key.tenant}#L#${key.locale}#${key.id}`;\n };\n this._getDataLoader = new DataLoader(\n async items => {\n const batched = items.map(item => {\n return this.entity.getBatch({\n PK: createPrimaryPK(item),\n SK: \"A\"\n });\n });\n\n const records = await batchReadAll<DataContainer<PageTemplate>>({\n table: this.entity.table,\n items: batched\n });\n\n const results = records.reduce((collection, result) => {\n if (!result) {\n return collection;\n }\n const key = cacheKeyFn(result.data);\n collection[key] = result.data as PageTemplate;\n return collection;\n }, {} as Record<string, PageTemplate>);\n return items.map(item => {\n const key = cacheKeyFn(item);\n return results[key] || null;\n });\n },\n {\n cacheKeyFn\n }\n );\n }\n return this._getDataLoader;\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAGA,IAAAE,KAAA,GAAAF,OAAA;AASO,MAAMG,sBAAsB,CAAgC;EACvDC,cAAc,GAAqCC,SAAS;EAIpEC,WAAWA,CAACC,MAAc,EAAE;IACxB,IAAI,CAACC,MAAM,GAAGD,MAAM,CAACC,MAAM;EAC/B;EAEA,MAAaC,MAAMA,CAACC,IAAuB,EAAyB;IAChE,OAAO,MAAM,IAAI,CAACC,aAAa,CAAC,CAAC,CAACC,IAAI,CAACF,IAAI,CAAC;EAChD;EAEA,MAAaG,MAAMA,CAACC,KAA0B,EAA2B;IACrE,OAAO,MAAM,IAAI,CAACH,aAAa,CAAC,CAAC,CAACI,QAAQ,CAACD,KAAK,CAAC;EACrD;EAEOE,KAAKA,CAAA,EAAS;IACjB,IAAI,CAACL,aAAa,CAAC,CAAC,CAACM,QAAQ,CAAC,CAAC;EACnC;EAEQN,aAAaA,CAAA,EAAG;IACpB,IAAI,CAAC,IAAI,CAACP,cAAc,EAAE;MACtB,MAAMc,UAAU,GAAIC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ieldPlugin } from "../../plugins/definitions/PageTemplateDynamoDbElasticFieldPlugin";
2
+ export declare const createPageTemplateDynamoDbFields: () => PageTemplateDynamoDbElasticFieldPlugin[];
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createPageTemplateDynamoDbFields = void 0;
7
+ var _PageTemplateDynamoDbElasticFieldPlugin = require("../../plugins/definitions/PageTemplateDynamoDbElasticFieldPlugin");
8
+ const createPageTemplateDynamoDbFields = () => {
9
+ return [new _PageTemplateDynamoDbElasticFieldPlugin.PageTemplateDynamoDbElasticFieldPlugin({
10
+ field: "id"
11
+ }), new _PageTemplateDynamoDbElasticFieldPlugin.PageTemplateDynamoDbElasticFieldPlugin({
12
+ field: "createdOn",
13
+ type: "date"
14
+ }), new _PageTemplateDynamoDbElasticFieldPlugin.PageTemplateDynamoDbElasticFieldPlugin({
15
+ field: "savedOn",
16
+ type: "date"
17
+ }), new _PageTemplateDynamoDbElasticFieldPlugin.PageTemplateDynamoDbElasticFieldPlugin({
18
+ field: "createdBy",
19
+ path: "createdBy.id"
20
+ })];
21
+ };
22
+ exports.createPageTemplateDynamoDbFields = createPageTemplateDynamoDbFields;
23
+
24
+ //# sourceMappingURL=fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_PageTemplateDynamoDbElasticFieldPlugin","require","createPageTemplateDynamoDbFields","PageTemplateDynamoDbElasticFieldPlugin","field","type","path","exports"],"sources":["fields.ts"],"sourcesContent":["import { PageTemplateDynamoDbElasticFieldPlugin } from \"~/plugins/definitions/PageTemplateDynamoDbElasticFieldPlugin\";\n\nexport const createPageTemplateDynamoDbFields = (): PageTemplateDynamoDbElasticFieldPlugin[] => {\n return [\n new PageTemplateDynamoDbElasticFieldPlugin({\n field: \"id\"\n }),\n new PageTemplateDynamoDbElasticFieldPlugin({\n field: \"createdOn\",\n type: \"date\"\n }),\n new PageTemplateDynamoDbElasticFieldPlugin({\n field: \"savedOn\",\n type: \"date\"\n }),\n new PageTemplateDynamoDbElasticFieldPlugin({\n field: \"createdBy\",\n path: \"createdBy.id\"\n })\n ];\n};\n"],"mappings":";;;;;;AAAA,IAAAA,uCAAA,GAAAC,OAAA;AAEO,MAAMC,gCAAgC,GAAGA,CAAA,KAAgD;EAC5F,OAAO,CACH,IAAIC,8EAAsC,CAAC;IACvCC,KAAK,EAAE;EACX,CAAC,CAAC,EACF,IAAID,8EAAsC,CAAC;IACvCC,KAAK,EAAE,WAAW;IAClBC,IAAI,EAAE;EACV,CAAC,CAAC,EACF,IAAIF,8EAAsC,CAAC;IACvCC,KAAK,EAAE,SAAS;IAChBC,IAAI,EAAE;EACV,CAAC,CAAC,EACF,IAAIF,8EAAsC,CAAC;IACvCC,KAAK,EAAE,WAAW;IAClBE,IAAI,EAAE;EACV,CAAC,CAAC,CACL;AACL,CAAC;AAACC,OAAA,CAAAL,gCAAA,GAAAA,gCAAA","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import type { Entity } from "@webiny/db-dynamodb/toolbox";
2
+ import type { PluginsContainer } from "@webiny/plugins";
3
+ import type { PageTemplateStorageOperations } from "../../types";
4
+ export interface CreatePageTemplateStorageOperationsParams {
5
+ entity: Entity<any>;
6
+ plugins: PluginsContainer;
7
+ }
8
+ export declare const createPageTemplateStorageOperations: ({ entity, plugins }: CreatePageTemplateStorageOperationsParams) => PageTemplateStorageOperations;
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.createPageTemplateStorageOperations = void 0;
8
+ var _error = _interopRequireDefault(require("@webiny/error"));
9
+ var _query = require("@webiny/db-dynamodb/utils/query");
10
+ var _sort = require("@webiny/db-dynamodb/utils/sort");
11
+ var _filter = require("@webiny/db-dynamodb/utils/filter");
12
+ var _dataLoader = require("./dataLoader");
13
+ var _listResponse = require("@webiny/db-dynamodb/utils/listResponse");
14
+ var _PageTemplateDynamoDbElasticFieldPlugin = require("../../plugins/definitions/PageTemplateDynamoDbElasticFieldPlugin");
15
+ var _keys = require("./keys");
16
+ var _dbDynamodb = require("@webiny/db-dynamodb");
17
+ const createType = () => {
18
+ return "pb.pageTemplate";
19
+ };
20
+ const createPageTemplateStorageOperations = ({
21
+ entity,
22
+ plugins
23
+ }) => {
24
+ const dataLoader = new _dataLoader.PageTemplateDataLoader({
25
+ entity
26
+ });
27
+ const get = async params => {
28
+ const {
29
+ where
30
+ } = params;
31
+ try {
32
+ if (where.id) {
33
+ return await dataLoader.getOne({
34
+ id: where.id,
35
+ tenant: where.tenant,
36
+ locale: where.locale
37
+ });
38
+ }
39
+ const result = await (0, _query.queryOne)({
40
+ entity,
41
+ partitionKey: (0, _keys.createGSI1PK)(where),
42
+ options: {
43
+ index: "GSI1",
44
+ eq: where.slug
45
+ }
46
+ });
47
+ return result?.data || null;
48
+ } catch (ex) {
49
+ throw new _error.default(ex.message || "Could not load page template by given parameters.", ex.code || "PAGE_TEMPLATE_GET_ERROR", {
50
+ where
51
+ });
52
+ }
53
+ };
54
+ const list = async params => {
55
+ const {
56
+ where,
57
+ sort,
58
+ limit
59
+ } = params;
60
+ const {
61
+ tenant,
62
+ locale,
63
+ ...restWhere
64
+ } = where;
65
+ const queryAllParams = {
66
+ entity,
67
+ partitionKey: (0, _keys.createGSI1PK)({
68
+ tenant,
69
+ locale
70
+ }),
71
+ options: {
72
+ index: "GSI1",
73
+ gt: " "
74
+ }
75
+ };
76
+ let items = [];
77
+ try {
78
+ items = await (0, _query.queryAll)(queryAllParams);
79
+ } catch (ex) {
80
+ throw new _error.default(ex.message || "Could not list page templates by given parameters.", ex.code || "PAGE_TEMPLATE_LIST_ERROR", {
81
+ partitionKey: queryAllParams.partitionKey,
82
+ options: queryAllParams.options
83
+ });
84
+ }
85
+ const itemsData = items.map(item => item?.data).filter(Boolean);
86
+ const fields = plugins.byType(_PageTemplateDynamoDbElasticFieldPlugin.PageTemplateDynamoDbElasticFieldPlugin.type);
87
+ const filteredItems = (0, _filter.filterItems)({
88
+ plugins,
89
+ where: restWhere,
90
+ items: itemsData,
91
+ fields
92
+ });
93
+ const sortedItems = (0, _sort.sortItems)({
94
+ items: filteredItems,
95
+ sort,
96
+ fields
97
+ });
98
+ return (0, _listResponse.createListResponse)({
99
+ items: sortedItems,
100
+ limit: limit || 100000,
101
+ totalCount: sortedItems.length,
102
+ after: null
103
+ });
104
+ };
105
+ const create = async params => {
106
+ const {
107
+ pageTemplate
108
+ } = params;
109
+ const keys = {
110
+ PK: (0, _keys.createPrimaryPK)(pageTemplate),
111
+ SK: "A",
112
+ GSI1_PK: (0, _keys.createGSI1PK)(pageTemplate),
113
+ GSI1_SK: pageTemplate.slug
114
+ };
115
+ try {
116
+ await (0, _dbDynamodb.put)({
117
+ entity,
118
+ item: {
119
+ data: pageTemplate,
120
+ TYPE: createType(),
121
+ ...keys
122
+ }
123
+ });
124
+ /**
125
+ * Always clear data loader cache when modifying the records.
126
+ */
127
+ dataLoader.clear();
128
+ return pageTemplate;
129
+ } catch (ex) {
130
+ throw new _error.default(ex.message || "Could not create page template.", ex.code || "PAGE_TEMPLATE_CREATE_ERROR", {
131
+ keys
132
+ });
133
+ }
134
+ };
135
+ const update = async params => {
136
+ const {
137
+ original,
138
+ pageTemplate
139
+ } = params;
140
+ const keys = {
141
+ PK: (0, _keys.createPrimaryPK)(pageTemplate),
142
+ SK: "A",
143
+ GSI1_PK: (0, _keys.createGSI1PK)(pageTemplate),
144
+ GSI1_SK: pageTemplate.slug
145
+ };
146
+ try {
147
+ await (0, _dbDynamodb.put)({
148
+ entity,
149
+ item: {
150
+ data: pageTemplate,
151
+ TYPE: createType(),
152
+ ...keys
153
+ }
154
+ });
155
+ /**
156
+ * Always clear data loader cache when modifying the records.
157
+ */
158
+ dataLoader.clear();
159
+ return pageTemplate;
160
+ } catch (ex) {
161
+ throw new _error.default(ex.message || "Could not update page template.", ex.code || "PAGE_TEMPLATE_UPDATE_ERROR", {
162
+ keys,
163
+ original,
164
+ pageTemplate
165
+ });
166
+ }
167
+ };
168
+ const deletePageTemplate = async params => {
169
+ const {
170
+ pageTemplate
171
+ } = params;
172
+ const keys = {
173
+ PK: (0, _keys.createPrimaryPK)(pageTemplate),
174
+ SK: "A"
175
+ };
176
+ try {
177
+ await (0, _dbDynamodb.deleteItem)({
178
+ entity,
179
+ keys
180
+ });
181
+ /**
182
+ * Always clear data loader cache when modifying the records.
183
+ */
184
+ dataLoader.clear();
185
+ return pageTemplate;
186
+ } catch (ex) {
187
+ throw new _error.default(ex.message || "Could not delete page template.", ex.code || "PAGE_TEMPLATE_DELETE_ERROR", {
188
+ keys,
189
+ pageTemplate
190
+ });
191
+ }
192
+ };
193
+ return {
194
+ dataLoader,
195
+ get,
196
+ list,
197
+ create,
198
+ update,
199
+ delete: deletePageTemplate
200
+ };
201
+ };
202
+ exports.createPageTemplateStorageOperations = createPageTemplateStorageOperations;
203
+
204
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_error","_interopRequireDefault","require","_query","_sort","_filter","_dataLoader","_listResponse","_PageTemplateDynamoDbElasticFieldPlugin","_keys","_dbDynamodb","createType","createPageTemplateStorageOperations","entity","plugins","dataLoader","PageTemplateDataLoader","get","params","where","id","getOne","tenant","locale","result","queryOne","partitionKey","createGSI1PK","options","index","eq","slug","data","ex","WebinyError","message","code","list","sort","limit","restWhere","queryAllParams","gt","items","queryAll","itemsData","map","item","filter","Boolean","fields","byType","PageTemplateDynamoDbElasticFieldPlugin","type","filteredItems","filterItems","sortedItems","sortItems","createListResponse","totalCount","length","after","create","pageTemplate","keys","PK","createPrimaryPK","SK","GSI1_PK","GSI1_SK","put","TYPE","clear","update","original","deletePageTemplate","deleteItem","delete","exports"],"sources":["index.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n PageTemplate,\n PageTemplateStorageOperationsCreateParams,\n PageTemplateStorageOperationsDeleteParams,\n PageTemplateStorageOperationsGetParams,\n PageTemplateStorageOperationsListParams,\n PageTemplateStorageOperationsUpdateParams\n} from \"@webiny/api-page-builder/types\";\nimport type { Entity } from \"@webiny/db-dynamodb/toolbox\";\nimport type { QueryAllParams } from \"@webiny/db-dynamodb/utils/query\";\nimport { queryAll, queryOne } from \"@webiny/db-dynamodb/utils/query\";\nimport { sortItems } from \"@webiny/db-dynamodb/utils/sort\";\nimport { filterItems } from \"@webiny/db-dynamodb/utils/filter\";\nimport { PageTemplateDataLoader } from \"./dataLoader\";\nimport { createListResponse } from \"@webiny/db-dynamodb/utils/listResponse\";\nimport { PageTemplateDynamoDbElasticFieldPlugin } from \"~/plugins/definitions/PageTemplateDynamoDbElasticFieldPlugin\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport { createGSI1PK, createPrimaryPK } from \"./keys\";\nimport type { DataContainer, PageTemplateStorageOperations } from \"~/types\";\nimport { deleteItem, put } from \"@webiny/db-dynamodb\";\n\nconst createType = (): string => {\n return \"pb.pageTemplate\";\n};\n\nexport interface CreatePageTemplateStorageOperationsParams {\n entity: Entity<any>;\n plugins: PluginsContainer;\n}\n\nexport const createPageTemplateStorageOperations = ({\n entity,\n plugins\n}: CreatePageTemplateStorageOperationsParams): PageTemplateStorageOperations => {\n const dataLoader = new PageTemplateDataLoader({\n entity\n });\n\n const get = async (params: PageTemplateStorageOperationsGetParams) => {\n const { where } = params;\n\n try {\n if (where.id) {\n return await dataLoader.getOne({\n id: where.id,\n tenant: where.tenant,\n locale: where.locale\n });\n }\n\n const result = await queryOne<{ data: PageTemplate }>({\n entity,\n partitionKey: createGSI1PK(where),\n options: {\n index: \"GSI1\",\n eq: where.slug\n }\n });\n\n return result?.data || null;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not load page template by given parameters.\",\n ex.code || \"PAGE_TEMPLATE_GET_ERROR\",\n {\n where\n }\n );\n }\n };\n\n const list = async (params: PageTemplateStorageOperationsListParams) => {\n const { where, sort, limit } = params;\n\n const { tenant, locale, ...restWhere } = where;\n const queryAllParams: QueryAllParams = {\n entity,\n partitionKey: createGSI1PK({ tenant, locale }),\n options: {\n index: \"GSI1\",\n gt: \" \"\n }\n };\n\n let items: DataContainer<PageTemplate>[] = [];\n\n try {\n items = await queryAll<DataContainer<PageTemplate>>(queryAllParams);\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not list page templates by given parameters.\",\n ex.code || \"PAGE_TEMPLATE_LIST_ERROR\",\n {\n partitionKey: queryAllParams.partitionKey,\n options: queryAllParams.options\n }\n );\n }\n\n const itemsData = items.map(item => item?.data).filter(Boolean);\n\n const fields = plugins.byType<PageTemplateDynamoDbElasticFieldPlugin>(\n PageTemplateDynamoDbElasticFieldPlugin.type\n );\n\n const filteredItems = filterItems<PageTemplate>({\n plugins,\n where: restWhere,\n items: itemsData,\n fields\n });\n\n const sortedItems = sortItems<PageTemplate>({\n items: filteredItems,\n sort,\n fields\n });\n\n return createListResponse({\n items: sortedItems,\n limit: limit || 100000,\n totalCount: sortedItems.length,\n after: null\n });\n };\n\n const create = async (params: PageTemplateStorageOperationsCreateParams) => {\n const { pageTemplate } = params;\n\n const keys = {\n PK: createPrimaryPK(pageTemplate),\n SK: \"A\",\n GSI1_PK: createGSI1PK(pageTemplate),\n GSI1_SK: pageTemplate.slug\n };\n\n try {\n await put({\n entity,\n item: {\n data: pageTemplate,\n TYPE: createType(),\n ...keys\n }\n });\n /**\n * Always clear data loader cache when modifying the records.\n */\n dataLoader.clear();\n\n return pageTemplate;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not create page template.\",\n ex.code || \"PAGE_TEMPLATE_CREATE_ERROR\",\n {\n keys\n }\n );\n }\n };\n\n const update = async (params: PageTemplateStorageOperationsUpdateParams) => {\n const { original, pageTemplate } = params;\n const keys = {\n PK: createPrimaryPK(pageTemplate),\n SK: \"A\",\n GSI1_PK: createGSI1PK(pageTemplate),\n GSI1_SK: pageTemplate.slug\n };\n\n try {\n await put({\n entity,\n item: {\n data: pageTemplate,\n TYPE: createType(),\n ...keys\n }\n });\n /**\n * Always clear data loader cache when modifying the records.\n */\n dataLoader.clear();\n\n return pageTemplate;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not update page template.\",\n ex.code || \"PAGE_TEMPLATE_UPDATE_ERROR\",\n {\n keys,\n original,\n pageTemplate\n }\n );\n }\n };\n\n const deletePageTemplate = async (params: PageTemplateStorageOperationsDeleteParams) => {\n const { pageTemplate } = params;\n const keys = {\n PK: createPrimaryPK(pageTemplate),\n SK: \"A\"\n };\n\n try {\n await deleteItem({\n entity,\n keys\n });\n /**\n * Always clear data loader cache when modifying the records.\n */\n dataLoader.clear();\n\n return pageTemplate;\n } catch (ex) {\n throw new WebinyError(\n ex.message || \"Could not delete page template.\",\n ex.code || \"PAGE_TEMPLATE_DELETE_ERROR\",\n {\n keys,\n pageTemplate\n }\n );\n }\n };\n\n return {\n dataLoader,\n get,\n list,\n create,\n update,\n delete: deletePageTemplate\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAWA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,uCAAA,GAAAN,OAAA;AAEA,IAAAO,KAAA,GAAAP,OAAA;AAEA,IAAAQ,WAAA,GAAAR,OAAA;AAEA,MAAMS,UAAU,GAAGA,CAAA,KAAc;EAC7B,OAAO,iBAAiB;AAC5B,CAAC;AAOM,MAAMC,mCAAmC,GAAGA,CAAC;EAChDC,MAAM;EACNC;AACuC,CAAC,KAAoC;EAC5E,MAAMC,UAAU,GAAG,IAAIC,kCAAsB,CAAC;IAC1CH;EACJ,CAAC,CAAC;EAEF,MAAMI,GAAG,GAAG,MAAOC,MAA8C,IAAK;IAClE,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AG7C,MAAM;IAC/B,MAAM8C,IAAI,GAAG;MACTC,EAAE,EAAE,IAAAC,qBAAe,EAACH,YAAY,CAAC;MACjCI,EAAE,EAAE;IACR,CAAC;IAED,IAAI;MACA,MAAM,IAAAS,sBAAU,EAAC;QACb/D,MAAM;QACNmD;MACJ,CAAC,CAAC;MACF;AACZ;AACA;MACYjD,UAAU,CAACyD,KAAK,CAAC,CAAC;MAElB,OAAOT,YAAY;IACvB,CAAC,CAAC,OAAO9B,EAAE,EAAE;MACT,MAAM,IAAIC,cAAW,CACjBD,EAAE,CAACE,OAAO,IAAI,iCAAiC,EAC/CF,EAAE,CAACG,IAAI,IAAI,4BAA4B,EACvC;QACI4B,IAAI;QACJD;MACJ,CACJ,CAAC;IACL;EACJ,CAAC;EAED,OAAO;IACHhD,UAAU;IACVE,GAAG;IACHoB,IAAI;IACJyB,MAAM;IACNW,MAAM;IACNI,MAAM,EAAEF;EACZ,CAAC;AACL,CAAC;AAACG,OAAA,CAAAlE,mCAAA,GAAAA,mCAAA","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ import type { PageTemplate } from "@webiny/api-page-builder/types";
2
+ export type PrimaryPKParams = Pick<PageTemplate, "id" | "tenant" | "locale">;
3
+ export type GSI1Params = Pick<PageTemplate, "tenant" | "locale">;
4
+ export declare const createPrimaryPK: ({ id, tenant, locale }: PrimaryPKParams) => string;
5
+ export declare const createGSI1PK: ({ tenant, locale }: GSI1Params) => string;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createPrimaryPK = exports.createGSI1PK = void 0;
7
+ const createPrimaryPK = ({
8
+ id,
9
+ tenant,
10
+ locale
11
+ }) => {
12
+ return `T#${tenant}#L#${locale}#PB#TEMPLATE#${id}`;
13
+ };
14
+ exports.createPrimaryPK = createPrimaryPK;
15
+ const createGSI1PK = ({
16
+ tenant,
17
+ locale
18
+ }) => {
19
+ return `T#${tenant}#L#${locale}#PB#TEMPLATES`;
20
+ };
21
+ exports.createGSI1PK = createGSI1PK;
22
+
23
+ //# sourceMappingURL=keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createPrimaryPK","id","tenant","locale","exports","createGSI1PK"],"sources":["keys.ts"],"sourcesContent":["import type { PageTemplate } from \"@webiny/api-page-builder/types\";\n\nexport type PrimaryPKParams = Pick<PageTemplate, \"id\" | \"tenant\" | \"locale\">;\nexport type GSI1Params = Pick<PageTemplate, \"tenant\" | \"locale\">;\n\nexport const createPrimaryPK = ({ id, tenant, locale }: PrimaryPKParams): string => {\n return `T#${tenant}#L#${locale}#PB#TEMPLATE#${id}`;\n};\n\nexport const createGSI1PK = ({ tenant, locale }: GSI1Params): string => {\n return `T#${tenant}#L#${locale}#PB#TEMPLATES`;\n};\n"],"mappings":";;;;;;AAKO,MAAMA,eAAe,GAAGA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC;AAAwB,CAAC,KAAa;EAChF,OAAO,KAAKD,MAAM,MAAMC,MAAM,gBAAgBF,EAAE,EAAE;AACtD,CAAC;AAACG,OAAA,CAAAJ,eAAA,GAAAA,eAAA;AAEK,MAAMK,YAAY,GAAGA,CAAC;EAAEH,MAAM;EAAEC;AAAmB,CAAC,KAAa;EACpE,OAAO,KAAKD,MAAM,MAAMC,MAAM,eAAe;AACjD,CAAC;AAACC,OAAA,CAAAC,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -1,18 +1,14 @@
1
- import { SearchBody as esSearchBody } from "elastic-ts";
2
- import { PageStorageOperationsListWhere, PbContext } from "@webiny/api-page-builder/types";
1
+ import type { SearchBody as esSearchBody } from "elastic-ts";
2
+ import type { PageStorageOperationsListWhere } from "@webiny/api-page-builder/types";
3
+ import { PageElasticsearchFieldPlugin } from "../../plugins/definitions/PageElasticsearchFieldPlugin";
4
+ import type { PluginsContainer } from "@webiny/plugins";
3
5
  interface CreateElasticsearchBodyParams {
4
- context: PbContext;
6
+ plugins: PluginsContainer;
5
7
  where: PageStorageOperationsListWhere;
6
8
  limit: number;
7
- after?: string;
9
+ after: string | null;
8
10
  sort: string[];
11
+ fieldPlugins: Record<string, PageElasticsearchFieldPlugin>;
9
12
  }
10
- interface CreateElasticsearchBodyParams {
11
- context: PbContext;
12
- where: PageStorageOperationsListWhere;
13
- limit: number;
14
- after?: string;
15
- sort: string[];
16
- }
17
- export declare const createElasticsearchQueryBody: (params: CreateElasticsearchBodyParams) => esSearchBody;
13
+ export declare const createElasticsearchQueryBody: (params: Omit<CreateElasticsearchBodyParams, "fieldPlugins">) => esSearchBody & Pick<Required<esSearchBody>, "sort">;
18
14
  export {};