@webiny/api-page-builder-so-ddb-es 0.0.0-ee-vpcs.549378cf03

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 (186) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -0
  3. package/configurations.d.ts +9 -0
  4. package/configurations.js +49 -0
  5. package/configurations.js.map +1 -0
  6. package/definitions/blockCategoryEntity.d.ts +9 -0
  7. package/definitions/blockCategoryEntity.js +61 -0
  8. package/definitions/blockCategoryEntity.js.map +1 -0
  9. package/definitions/categoryEntity.d.ts +9 -0
  10. package/definitions/categoryEntity.js +61 -0
  11. package/definitions/categoryEntity.js.map +1 -0
  12. package/definitions/menuEntity.d.ts +9 -0
  13. package/definitions/menuEntity.js +61 -0
  14. package/definitions/menuEntity.js.map +1 -0
  15. package/definitions/pageBlockEntity.d.ts +9 -0
  16. package/definitions/pageBlockEntity.js +64 -0
  17. package/definitions/pageBlockEntity.js.map +1 -0
  18. package/definitions/pageElasticsearchEntity.d.ts +9 -0
  19. package/definitions/pageElasticsearchEntity.js +40 -0
  20. package/definitions/pageElasticsearchEntity.js.map +1 -0
  21. package/definitions/pageElementEntity.d.ts +9 -0
  22. package/definitions/pageElementEntity.js +67 -0
  23. package/definitions/pageElementEntity.js.map +1 -0
  24. package/definitions/pageEntity.d.ts +9 -0
  25. package/definitions/pageEntity.js +97 -0
  26. package/definitions/pageEntity.js.map +1 -0
  27. package/definitions/settingsEntity.d.ts +9 -0
  28. package/definitions/settingsEntity.js +77 -0
  29. package/definitions/settingsEntity.js.map +1 -0
  30. package/definitions/systemEntity.d.ts +9 -0
  31. package/definitions/systemEntity.js +40 -0
  32. package/definitions/systemEntity.js.map +1 -0
  33. package/definitions/table.d.ts +9 -0
  34. package/definitions/table.js +24 -0
  35. package/definitions/table.js.map +1 -0
  36. package/definitions/tableElasticsearch.d.ts +9 -0
  37. package/definitions/tableElasticsearch.js +24 -0
  38. package/definitions/tableElasticsearch.js.map +1 -0
  39. package/elasticsearch/createElasticsearchIndex.d.ts +9 -0
  40. package/elasticsearch/createElasticsearchIndex.js +60 -0
  41. package/elasticsearch/createElasticsearchIndex.js.map +1 -0
  42. package/elasticsearch/indices/base.d.ts +2 -0
  43. package/elasticsearch/indices/base.js +15 -0
  44. package/elasticsearch/indices/base.js.map +1 -0
  45. package/elasticsearch/indices/index.d.ts +1 -0
  46. package/elasticsearch/indices/index.js +16 -0
  47. package/elasticsearch/indices/index.js.map +1 -0
  48. package/elasticsearch/indices/japanese.d.ts +2 -0
  49. package/elasticsearch/indices/japanese.js +16 -0
  50. package/elasticsearch/indices/japanese.js.map +1 -0
  51. package/index.d.ts +2 -0
  52. package/index.js +233 -0
  53. package/index.js.map +1 -0
  54. package/operations/blockCategory/dataLoader.d.ts +16 -0
  55. package/operations/blockCategory/dataLoader.js +79 -0
  56. package/operations/blockCategory/dataLoader.js.map +1 -0
  57. package/operations/blockCategory/fields.d.ts +2 -0
  58. package/operations/blockCategory/fields.js +28 -0
  59. package/operations/blockCategory/fields.js.map +1 -0
  60. package/operations/blockCategory/index.d.ts +8 -0
  61. package/operations/blockCategory/index.js +208 -0
  62. package/operations/blockCategory/index.js.map +1 -0
  63. package/operations/blockCategory/keys.d.ts +9 -0
  64. package/operations/blockCategory/keys.js +25 -0
  65. package/operations/blockCategory/keys.js.map +1 -0
  66. package/operations/category/dataLoader.d.ts +16 -0
  67. package/operations/category/dataLoader.js +79 -0
  68. package/operations/category/dataLoader.js.map +1 -0
  69. package/operations/category/fields.d.ts +2 -0
  70. package/operations/category/fields.js +28 -0
  71. package/operations/category/fields.js.map +1 -0
  72. package/operations/category/index.d.ts +8 -0
  73. package/operations/category/index.js +208 -0
  74. package/operations/category/index.js.map +1 -0
  75. package/operations/category/keys.d.ts +9 -0
  76. package/operations/category/keys.js +25 -0
  77. package/operations/category/keys.js.map +1 -0
  78. package/operations/menu/fields.d.ts +2 -0
  79. package/operations/menu/fields.js +27 -0
  80. package/operations/menu/fields.js.map +1 -0
  81. package/operations/menu/index.d.ts +8 -0
  82. package/operations/menu/index.js +217 -0
  83. package/operations/menu/index.js.map +1 -0
  84. package/operations/pageBlock/dataLoader.d.ts +16 -0
  85. package/operations/pageBlock/dataLoader.js +79 -0
  86. package/operations/pageBlock/dataLoader.js.map +1 -0
  87. package/operations/pageBlock/fields.d.ts +2 -0
  88. package/operations/pageBlock/fields.js +25 -0
  89. package/operations/pageBlock/fields.js.map +1 -0
  90. package/operations/pageBlock/index.d.ts +8 -0
  91. package/operations/pageBlock/index.js +208 -0
  92. package/operations/pageBlock/index.js.map +1 -0
  93. package/operations/pageBlock/keys.d.ts +9 -0
  94. package/operations/pageBlock/keys.js +25 -0
  95. package/operations/pageBlock/keys.js.map +1 -0
  96. package/operations/pageElement/fields.d.ts +2 -0
  97. package/operations/pageElement/fields.js +19 -0
  98. package/operations/pageElement/fields.js.map +1 -0
  99. package/operations/pageElement/index.d.ts +8 -0
  100. package/operations/pageElement/index.js +207 -0
  101. package/operations/pageElement/index.js.map +1 -0
  102. package/operations/pages/elasticsearchQueryBody.d.ts +12 -0
  103. package/operations/pages/elasticsearchQueryBody.js +237 -0
  104. package/operations/pages/elasticsearchQueryBody.js.map +1 -0
  105. package/operations/pages/fields.d.ts +4 -0
  106. package/operations/pages/fields.js +54 -0
  107. package/operations/pages/fields.js.map +1 -0
  108. package/operations/pages/helpers.d.ts +35 -0
  109. package/operations/pages/helpers.js +83 -0
  110. package/operations/pages/helpers.js.map +1 -0
  111. package/operations/pages/index.d.ts +11 -0
  112. package/operations/pages/index.js +829 -0
  113. package/operations/pages/index.js.map +1 -0
  114. package/operations/pages/keys.d.ts +24 -0
  115. package/operations/pages/keys.js +79 -0
  116. package/operations/pages/keys.js.map +1 -0
  117. package/operations/settings/index.d.ts +6 -0
  118. package/operations/settings/index.js +178 -0
  119. package/operations/settings/index.js.map +1 -0
  120. package/operations/system/index.d.ts +6 -0
  121. package/operations/system/index.js +104 -0
  122. package/operations/system/index.js.map +1 -0
  123. package/package.json +65 -0
  124. package/plugins/definitions/BlockCategoryDynamoDbElasticFieldPlugin.d.ts +4 -0
  125. package/plugins/definitions/BlockCategoryDynamoDbElasticFieldPlugin.js +17 -0
  126. package/plugins/definitions/BlockCategoryDynamoDbElasticFieldPlugin.js.map +1 -0
  127. package/plugins/definitions/CategoryDynamoDbElasticFieldPlugin.d.ts +4 -0
  128. package/plugins/definitions/CategoryDynamoDbElasticFieldPlugin.js +17 -0
  129. package/plugins/definitions/CategoryDynamoDbElasticFieldPlugin.js.map +1 -0
  130. package/plugins/definitions/IndexPageDataPlugin.d.ts +17 -0
  131. package/plugins/definitions/IndexPageDataPlugin.js +32 -0
  132. package/plugins/definitions/IndexPageDataPlugin.js.map +1 -0
  133. package/plugins/definitions/MenuDynamoDbElasticFieldPlugin.d.ts +4 -0
  134. package/plugins/definitions/MenuDynamoDbElasticFieldPlugin.js +17 -0
  135. package/plugins/definitions/MenuDynamoDbElasticFieldPlugin.js.map +1 -0
  136. package/plugins/definitions/PageBlockDynamoDbFieldPlugin.d.ts +4 -0
  137. package/plugins/definitions/PageBlockDynamoDbFieldPlugin.js +17 -0
  138. package/plugins/definitions/PageBlockDynamoDbFieldPlugin.js.map +1 -0
  139. package/plugins/definitions/PageDynamoDbElasticsearchFieldPlugin.d.ts +4 -0
  140. package/plugins/definitions/PageDynamoDbElasticsearchFieldPlugin.js +17 -0
  141. package/plugins/definitions/PageDynamoDbElasticsearchFieldPlugin.js.map +1 -0
  142. package/plugins/definitions/PageElasticsearchBodyModifierPlugin.d.ts +4 -0
  143. package/plugins/definitions/PageElasticsearchBodyModifierPlugin.js +17 -0
  144. package/plugins/definitions/PageElasticsearchBodyModifierPlugin.js.map +1 -0
  145. package/plugins/definitions/PageElasticsearchFieldPlugin.d.ts +4 -0
  146. package/plugins/definitions/PageElasticsearchFieldPlugin.js +17 -0
  147. package/plugins/definitions/PageElasticsearchFieldPlugin.js.map +1 -0
  148. package/plugins/definitions/PageElasticsearchIndexPlugin.d.ts +4 -0
  149. package/plugins/definitions/PageElasticsearchIndexPlugin.js +17 -0
  150. package/plugins/definitions/PageElasticsearchIndexPlugin.js.map +1 -0
  151. package/plugins/definitions/PageElasticsearchQueryModifierPlugin.d.ts +4 -0
  152. package/plugins/definitions/PageElasticsearchQueryModifierPlugin.js +17 -0
  153. package/plugins/definitions/PageElasticsearchQueryModifierPlugin.js.map +1 -0
  154. package/plugins/definitions/PageElasticsearchSortModifierPlugin.d.ts +4 -0
  155. package/plugins/definitions/PageElasticsearchSortModifierPlugin.js +17 -0
  156. package/plugins/definitions/PageElasticsearchSortModifierPlugin.js.map +1 -0
  157. package/plugins/definitions/PageElementDynamoDbElasticFieldPlugin.d.ts +4 -0
  158. package/plugins/definitions/PageElementDynamoDbElasticFieldPlugin.js +17 -0
  159. package/plugins/definitions/PageElementDynamoDbElasticFieldPlugin.js.map +1 -0
  160. package/plugins/definitions/SearchLatestPagesPlugin.d.ts +4 -0
  161. package/plugins/definitions/SearchLatestPagesPlugin.js +17 -0
  162. package/plugins/definitions/SearchLatestPagesPlugin.js.map +1 -0
  163. package/plugins/definitions/SearchPagesPlugin.d.ts +23 -0
  164. package/plugins/definitions/SearchPagesPlugin.js +39 -0
  165. package/plugins/definitions/SearchPagesPlugin.js.map +1 -0
  166. package/plugins/definitions/SearchPublishedPagesPlugin.d.ts +4 -0
  167. package/plugins/definitions/SearchPublishedPagesPlugin.js +17 -0
  168. package/plugins/definitions/SearchPublishedPagesPlugin.js.map +1 -0
  169. package/types.d.ts +39 -0
  170. package/types.js +20 -0
  171. package/types.js.map +1 -0
  172. package/upgrades/index.d.ts +2 -0
  173. package/upgrades/index.js +14 -0
  174. package/upgrades/index.js.map +1 -0
  175. package/upgrades/v5.15.0/category.d.ts +2 -0
  176. package/upgrades/v5.15.0/category.js +73 -0
  177. package/upgrades/v5.15.0/category.js.map +1 -0
  178. package/upgrades/v5.15.0/index.d.ts +4 -0
  179. package/upgrades/v5.15.0/index.js +52 -0
  180. package/upgrades/v5.15.0/index.js.map +1 -0
  181. package/upgrades/v5.15.0/menu.d.ts +2 -0
  182. package/upgrades/v5.15.0/menu.js +73 -0
  183. package/upgrades/v5.15.0/menu.js.map +1 -0
  184. package/upgrades/v5.15.0/pageElement.d.ts +2 -0
  185. package/upgrades/v5.15.0/pageElement.js +73 -0
  186. package/upgrades/v5.15.0/pageElement.js.map +1 -0
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.upgradeCategories = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _CategoryStorageOperations = require("../../operations/category/CategoryStorageOperations");
13
+
14
+ var _query = require("@webiny/db-dynamodb/utils/query");
15
+
16
+ var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
17
+
18
+ var _error = _interopRequireDefault(require("@webiny/error"));
19
+
20
+ // @ts-ignore
21
+ const upgradeCategories = async context => {
22
+ const tenant = context.tenancy.getCurrentTenant().id;
23
+ const localeCodes = await context.i18n.getLocales().map(locale => locale.code); // @ts-ignore
24
+
25
+ const categoryStorageOperations = context.pageBuilder.categories.storageOperations;
26
+
27
+ if (categoryStorageOperations instanceof _CategoryStorageOperations.CategoryStorageOperationsDdbEs === false) {
28
+ throw new _error.default("context.pageBuilder.categories.storageOperations must be instance of CategoryStorageOperationsDdbEs.");
29
+ }
30
+ /**
31
+ * First we need all categories in all existing locales of the tenant.
32
+ */
33
+
34
+
35
+ const records = [];
36
+
37
+ for (const locale of localeCodes) {
38
+ const partitionKey = categoryStorageOperations.createPartitionKey({
39
+ tenant,
40
+ locale
41
+ });
42
+ const result = await (0, _query.queryAll)({
43
+ entity: categoryStorageOperations.entity,
44
+ partitionKey,
45
+ options: {
46
+ gt: " "
47
+ }
48
+ });
49
+ /**
50
+ * Need to update existing categories with tenant and locale information.
51
+ */
52
+
53
+ records.push(...result.map(item => {
54
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {
55
+ PK: partitionKey,
56
+ SK: categoryStorageOperations.createSortKey(item),
57
+ TYPE: categoryStorageOperations.createType(),
58
+ tenant,
59
+ locale
60
+ });
61
+ }));
62
+ }
63
+
64
+ const items = records.map(record => {
65
+ return categoryStorageOperations.entity.putBatch(record);
66
+ });
67
+ await (0, _batchWrite.batchWriteAll)({
68
+ table: categoryStorageOperations.table,
69
+ items
70
+ });
71
+ };
72
+
73
+ exports.upgradeCategories = upgradeCategories;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["upgradeCategories","context","tenant","tenancy","getCurrentTenant","id","localeCodes","i18n","getLocales","map","locale","code","categoryStorageOperations","pageBuilder","categories","storageOperations","CategoryStorageOperationsDdbEs","WebinyError","records","partitionKey","createPartitionKey","result","queryAll","entity","options","gt","push","item","PK","SK","createSortKey","TYPE","createType","items","record","putBatch","batchWriteAll","table"],"sources":["category.ts"],"sourcesContent":["import { PbContext } from \"@webiny/api-page-builder/graphql/types\";\n// @ts-ignore\nimport { CategoryStorageOperationsDdbEs } from \"~/operations/category/CategoryStorageOperations\";\nimport { Category } from \"@webiny/api-page-builder/types\";\nimport { queryAll } from \"@webiny/db-dynamodb/utils/query\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport WebinyError from \"@webiny/error\";\n\ntype DbRecord<T> = T & {\n PK: string;\n SK: string;\n TYPE: string;\n};\n\nexport const upgradeCategories = async (context: PbContext) => {\n const tenant: string = context.tenancy.getCurrentTenant().id;\n const localeCodes: string[] = await context.i18n.getLocales().map(locale => locale.code);\n // @ts-ignore\n const categoryStorageOperations = context.pageBuilder.categories\n .storageOperations as CategoryStorageOperationsDdbEs;\n if (categoryStorageOperations instanceof CategoryStorageOperationsDdbEs === false) {\n throw new WebinyError(\n \"context.pageBuilder.categories.storageOperations must be instance of CategoryStorageOperationsDdbEs.\"\n );\n }\n /**\n * First we need all categories in all existing locales of the tenant.\n */\n const records: DbRecord<Category>[] = [];\n for (const locale of localeCodes) {\n const partitionKey = categoryStorageOperations.createPartitionKey({\n tenant,\n locale\n });\n const result = await queryAll<Category>({\n entity: categoryStorageOperations.entity,\n partitionKey,\n options: {\n gt: \" \"\n }\n });\n /**\n * Need to update existing categories with tenant and locale information.\n */\n records.push(\n ...result.map(item => {\n return {\n ...item,\n PK: partitionKey,\n SK: categoryStorageOperations.createSortKey(item),\n TYPE: categoryStorageOperations.createType(),\n tenant,\n locale\n };\n })\n );\n }\n const items = records.map(record => {\n return categoryStorageOperations.entity.putBatch(record);\n });\n\n await batchWriteAll({\n table: categoryStorageOperations.table,\n items\n });\n};\n"],"mappings":";;;;;;;;;;;AAEA;;AAEA;;AACA;;AACA;;AALA;AAaO,MAAMA,iBAAiB,GAAG,MAAOC,OAAP,IAA8B;EAC3D,MAAMC,MAAc,GAAGD,OAAO,CAACE,OAAR,CAAgBC,gBAAhB,GAAmCC,EAA1D;EACA,MAAMC,WAAqB,GAAG,MAAML,OAAO,CAACM,IAAR,CAAaC,UAAb,GAA0BC,GAA1B,CAA8BC,MAAM,IAAIA,MAAM,CAACC,IAA/C,CAApC,CAF2D,CAG3D;;EACA,MAAMC,yBAAyB,GAAGX,OAAO,CAACY,WAAR,CAAoBC,UAApB,CAC7BC,iBADL;;EAEA,IAAIH,yBAAyB,YAAYI,yDAArC,KAAwE,KAA5E,EAAmF;IAC/E,MAAM,IAAIC,cAAJ,CACF,sGADE,CAAN;EAGH;EACD;AACJ;AACA;;;EACI,MAAMC,OAA6B,GAAG,EAAtC;;EACA,KAAK,MAAMR,MAAX,IAAqBJ,WAArB,EAAkC;IAC9B,MAAMa,YAAY,GAAGP,yBAAyB,CAACQ,kBAA1B,CAA6C;MAC9DlB,MAD8D;MAE9DQ;IAF8D,CAA7C,CAArB;IAIA,MAAMW,MAAM,GAAG,MAAM,IAAAC,eAAA,EAAmB;MACpCC,MAAM,EAAEX,yBAAyB,CAACW,MADE;MAEpCJ,YAFoC;MAGpCK,OAAO,EAAE;QACLC,EAAE,EAAE;MADC;IAH2B,CAAnB,CAArB;IAOA;AACR;AACA;;IACQP,OAAO,CAACQ,IAAR,CACI,GAAGL,MAAM,CAACZ,GAAP,CAAWkB,IAAI,IAAI;MAClB,mEACOA,IADP;QAEIC,EAAE,EAAET,YAFR;QAGIU,EAAE,EAAEjB,yBAAyB,CAACkB,aAA1B,CAAwCH,IAAxC,CAHR;QAIII,IAAI,EAAEnB,yBAAyB,CAACoB,UAA1B,EAJV;QAKI9B,MALJ;QAMIQ;MANJ;IAQH,CATE,CADP;EAYH;;EACD,MAAMuB,KAAK,GAAGf,OAAO,CAACT,GAAR,CAAYyB,MAAM,IAAI;IAChC,OAAOtB,yBAAyB,CAACW,MAA1B,CAAiCY,QAAjC,CAA0CD,MAA1C,CAAP;EACH,CAFa,CAAd;EAIA,MAAM,IAAAE,yBAAA,EAAc;IAChBC,KAAK,EAAEzB,yBAAyB,CAACyB,KADjB;IAEhBJ;EAFgB,CAAd,CAAN;AAIH,CAnDM"}
@@ -0,0 +1,4 @@
1
+ import { UpgradePlugin } from "@webiny/api-upgrade/types";
2
+ import { PbContext } from "@webiny/api-page-builder/graphql/types";
3
+ declare const _default: () => UpgradePlugin<PbContext>;
4
+ export default _default;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _category = require("./category");
9
+
10
+ var _menu = require("./menu");
11
+
12
+ var _pageElement = require("./pageElement");
13
+
14
+ var _default = () => {
15
+ return {
16
+ type: "api-upgrade",
17
+ app: "page-builder",
18
+ version: "5.15.0",
19
+ apply: async context => {
20
+ /**
21
+ * Upgrade categories.
22
+ */
23
+ try {
24
+ await (0, _category.upgradeCategories)(context);
25
+ } catch (ex) {
26
+ console.log(ex.message);
27
+ }
28
+ /**
29
+ * Upgrade menus.
30
+ */
31
+
32
+
33
+ try {
34
+ await (0, _menu.upgradeMenus)(context);
35
+ } catch (ex) {
36
+ console.log(ex.message);
37
+ }
38
+ /**
39
+ * Upgrade page elements.
40
+ */
41
+
42
+
43
+ try {
44
+ await (0, _pageElement.upgradePageElements)(context);
45
+ } catch (ex) {
46
+ console.log(ex.message);
47
+ }
48
+ }
49
+ };
50
+ };
51
+
52
+ exports.default = _default;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["type","app","version","apply","context","upgradeCategories","ex","console","log","message","upgradeMenus","upgradePageElements"],"sources":["index.ts"],"sourcesContent":["import { UpgradePlugin } from \"@webiny/api-upgrade/types\";\nimport { PbContext } from \"@webiny/api-page-builder/graphql/types\";\nimport { upgradeCategories } from \"~/upgrades/v5.15.0/category\";\nimport { upgradeMenus } from \"~/upgrades/v5.15.0/menu\";\nimport { upgradePageElements } from \"~/upgrades/v5.15.0/pageElement\";\n\nexport default (): UpgradePlugin<PbContext> => {\n return {\n type: \"api-upgrade\",\n app: \"page-builder\",\n version: \"5.15.0\",\n apply: async context => {\n /**\n * Upgrade categories.\n */\n try {\n await upgradeCategories(context);\n } catch (ex) {\n console.log(ex.message);\n }\n /**\n * Upgrade menus.\n */\n try {\n await upgradeMenus(context);\n } catch (ex) {\n console.log(ex.message);\n }\n /**\n * Upgrade page elements.\n */\n try {\n await upgradePageElements(context);\n } catch (ex) {\n console.log(ex.message);\n }\n }\n };\n};\n"],"mappings":";;;;;;;AAEA;;AACA;;AACA;;eAEe,MAAgC;EAC3C,OAAO;IACHA,IAAI,EAAE,aADH;IAEHC,GAAG,EAAE,cAFF;IAGHC,OAAO,EAAE,QAHN;IAIHC,KAAK,EAAE,MAAMC,OAAN,IAAiB;MACpB;AACZ;AACA;MACY,IAAI;QACA,MAAM,IAAAC,2BAAA,EAAkBD,OAAlB,CAAN;MACH,CAFD,CAEE,OAAOE,EAAP,EAAW;QACTC,OAAO,CAACC,GAAR,CAAYF,EAAE,CAACG,OAAf;MACH;MACD;AACZ;AACA;;;MACY,IAAI;QACA,MAAM,IAAAC,kBAAA,EAAaN,OAAb,CAAN;MACH,CAFD,CAEE,OAAOE,EAAP,EAAW;QACTC,OAAO,CAACC,GAAR,CAAYF,EAAE,CAACG,OAAf;MACH;MACD;AACZ;AACA;;;MACY,IAAI;QACA,MAAM,IAAAE,gCAAA,EAAoBP,OAApB,CAAN;MACH,CAFD,CAEE,OAAOE,EAAP,EAAW;QACTC,OAAO,CAACC,GAAR,CAAYF,EAAE,CAACG,OAAf;MACH;IACJ;EA7BE,CAAP;AA+BH,C"}
@@ -0,0 +1,2 @@
1
+ import { PbContext } from "@webiny/api-page-builder/graphql/types";
2
+ export declare const upgradeMenus: (context: PbContext) => Promise<void>;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.upgradeMenus = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _MenuStorageOperations = require("../../operations/menu/MenuStorageOperations");
13
+
14
+ var _query = require("@webiny/db-dynamodb/utils/query");
15
+
16
+ var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
17
+
18
+ var _error = _interopRequireDefault(require("@webiny/error"));
19
+
20
+ // @ts-ignore
21
+ const upgradeMenus = async context => {
22
+ const tenant = context.tenancy.getCurrentTenant().id;
23
+ const localeCodes = await context.i18n.getLocales().map(locale => locale.code); // @ts-ignore
24
+
25
+ const menuStorageOperations = context.pageBuilder.menus.storageOperations;
26
+
27
+ if (menuStorageOperations instanceof _MenuStorageOperations.MenuStorageOperationsDdbEs === false) {
28
+ throw new _error.default("context.pageBuilder.menus.storageOperations must be instance of MenuStorageOperationsDdbEs.");
29
+ }
30
+ /**
31
+ * First we need all categories in all existing locales of the tenant.
32
+ */
33
+
34
+
35
+ const records = [];
36
+
37
+ for (const locale of localeCodes) {
38
+ const partitionKey = menuStorageOperations.createPartitionKey({
39
+ tenant,
40
+ locale
41
+ });
42
+ const result = await (0, _query.queryAll)({
43
+ entity: menuStorageOperations.entity,
44
+ partitionKey,
45
+ options: {
46
+ gt: " "
47
+ }
48
+ });
49
+ /**
50
+ * Need to update existing menus with tenant and locale information.
51
+ */
52
+
53
+ records.push(...result.map(item => {
54
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {
55
+ PK: partitionKey,
56
+ SK: menuStorageOperations.createSortKey(item),
57
+ TYPE: menuStorageOperations.createType(),
58
+ tenant,
59
+ locale
60
+ });
61
+ }));
62
+ }
63
+
64
+ const items = records.map(record => {
65
+ return menuStorageOperations.entity.putBatch(record);
66
+ });
67
+ await (0, _batchWrite.batchWriteAll)({
68
+ table: menuStorageOperations.table,
69
+ items
70
+ });
71
+ };
72
+
73
+ exports.upgradeMenus = upgradeMenus;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["upgradeMenus","context","tenant","tenancy","getCurrentTenant","id","localeCodes","i18n","getLocales","map","locale","code","menuStorageOperations","pageBuilder","menus","storageOperations","MenuStorageOperationsDdbEs","WebinyError","records","partitionKey","createPartitionKey","result","queryAll","entity","options","gt","push","item","PK","SK","createSortKey","TYPE","createType","items","record","putBatch","batchWriteAll","table"],"sources":["menu.ts"],"sourcesContent":["import { PbContext } from \"@webiny/api-page-builder/graphql/types\";\n// @ts-ignore\nimport { MenuStorageOperationsDdbEs } from \"~/operations/menu/MenuStorageOperations\";\nimport { Menu } from \"@webiny/api-page-builder/types\";\nimport { queryAll } from \"@webiny/db-dynamodb/utils/query\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport WebinyError from \"@webiny/error\";\n\ntype DbRecord<T> = T & {\n PK: string;\n SK: string;\n TYPE: string;\n};\n\nexport const upgradeMenus = async (context: PbContext) => {\n const tenant: string = context.tenancy.getCurrentTenant().id;\n const localeCodes: string[] = await context.i18n.getLocales().map(locale => locale.code);\n // @ts-ignore\n const menuStorageOperations = context.pageBuilder.menus\n .storageOperations as MenuStorageOperationsDdbEs;\n if (menuStorageOperations instanceof MenuStorageOperationsDdbEs === false) {\n throw new WebinyError(\n \"context.pageBuilder.menus.storageOperations must be instance of MenuStorageOperationsDdbEs.\"\n );\n }\n /**\n * First we need all categories in all existing locales of the tenant.\n */\n const records: DbRecord<Menu>[] = [];\n for (const locale of localeCodes) {\n const partitionKey = menuStorageOperations.createPartitionKey({\n tenant,\n locale\n });\n const result = await queryAll<Menu>({\n entity: menuStorageOperations.entity,\n partitionKey,\n options: {\n gt: \" \"\n }\n });\n /**\n * Need to update existing menus with tenant and locale information.\n */\n records.push(\n ...result.map(item => {\n return {\n ...item,\n PK: partitionKey,\n SK: menuStorageOperations.createSortKey(item),\n TYPE: menuStorageOperations.createType(),\n tenant,\n locale\n };\n })\n );\n }\n const items = records.map(record => {\n return menuStorageOperations.entity.putBatch(record);\n });\n\n await batchWriteAll({\n table: menuStorageOperations.table,\n items\n });\n};\n"],"mappings":";;;;;;;;;;;AAEA;;AAEA;;AACA;;AACA;;AALA;AAaO,MAAMA,YAAY,GAAG,MAAOC,OAAP,IAA8B;EACtD,MAAMC,MAAc,GAAGD,OAAO,CAACE,OAAR,CAAgBC,gBAAhB,GAAmCC,EAA1D;EACA,MAAMC,WAAqB,GAAG,MAAML,OAAO,CAACM,IAAR,CAAaC,UAAb,GAA0BC,GAA1B,CAA8BC,MAAM,IAAIA,MAAM,CAACC,IAA/C,CAApC,CAFsD,CAGtD;;EACA,MAAMC,qBAAqB,GAAGX,OAAO,CAACY,WAAR,CAAoBC,KAApB,CACzBC,iBADL;;EAEA,IAAIH,qBAAqB,YAAYI,iDAAjC,KAAgE,KAApE,EAA2E;IACvE,MAAM,IAAIC,cAAJ,CACF,6FADE,CAAN;EAGH;EACD;AACJ;AACA;;;EACI,MAAMC,OAAyB,GAAG,EAAlC;;EACA,KAAK,MAAMR,MAAX,IAAqBJ,WAArB,EAAkC;IAC9B,MAAMa,YAAY,GAAGP,qBAAqB,CAACQ,kBAAtB,CAAyC;MAC1DlB,MAD0D;MAE1DQ;IAF0D,CAAzC,CAArB;IAIA,MAAMW,MAAM,GAAG,MAAM,IAAAC,eAAA,EAAe;MAChCC,MAAM,EAAEX,qBAAqB,CAACW,MADE;MAEhCJ,YAFgC;MAGhCK,OAAO,EAAE;QACLC,EAAE,EAAE;MADC;IAHuB,CAAf,CAArB;IAOA;AACR;AACA;;IACQP,OAAO,CAACQ,IAAR,CACI,GAAGL,MAAM,CAACZ,GAAP,CAAWkB,IAAI,IAAI;MAClB,mEACOA,IADP;QAEIC,EAAE,EAAET,YAFR;QAGIU,EAAE,EAAEjB,qBAAqB,CAACkB,aAAtB,CAAoCH,IAApC,CAHR;QAIII,IAAI,EAAEnB,qBAAqB,CAACoB,UAAtB,EAJV;QAKI9B,MALJ;QAMIQ;MANJ;IAQH,CATE,CADP;EAYH;;EACD,MAAMuB,KAAK,GAAGf,OAAO,CAACT,GAAR,CAAYyB,MAAM,IAAI;IAChC,OAAOtB,qBAAqB,CAACW,MAAtB,CAA6BY,QAA7B,CAAsCD,MAAtC,CAAP;EACH,CAFa,CAAd;EAIA,MAAM,IAAAE,yBAAA,EAAc;IAChBC,KAAK,EAAEzB,qBAAqB,CAACyB,KADb;IAEhBJ;EAFgB,CAAd,CAAN;AAIH,CAnDM"}
@@ -0,0 +1,2 @@
1
+ import { PbContext } from "@webiny/api-page-builder/graphql/types";
2
+ export declare const upgradePageElements: (context: PbContext) => Promise<void>;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.upgradePageElements = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _PageElementStorageOperations = require("../../operations/pageElement/PageElementStorageOperations");
13
+
14
+ var _query = require("@webiny/db-dynamodb/utils/query");
15
+
16
+ var _batchWrite = require("@webiny/db-dynamodb/utils/batchWrite");
17
+
18
+ var _error = _interopRequireDefault(require("@webiny/error"));
19
+
20
+ // @ts-ignore
21
+ const upgradePageElements = async context => {
22
+ const tenant = context.tenancy.getCurrentTenant().id;
23
+ const localeCodes = await context.i18n.getLocales().map(locale => locale.code); // @ts-ignore
24
+
25
+ const pageElementsStorageOperations = context.pageBuilder.pageElements.storageOperations;
26
+
27
+ if (pageElementsStorageOperations instanceof _PageElementStorageOperations.PageElementStorageOperationsDdbEs === false) {
28
+ throw new _error.default("context.pageBuilder.pageElements.storageOperations must be instance of PageElementStorageOperationsDdbEs.");
29
+ }
30
+ /**
31
+ * First we need all categories in all existing locales of the tenant.
32
+ */
33
+
34
+
35
+ const records = [];
36
+
37
+ for (const locale of localeCodes) {
38
+ const partitionKey = pageElementsStorageOperations.createPartitionKey({
39
+ tenant,
40
+ locale
41
+ });
42
+ const result = await (0, _query.queryAll)({
43
+ entity: pageElementsStorageOperations.entity,
44
+ partitionKey,
45
+ options: {
46
+ gt: " "
47
+ }
48
+ });
49
+ /**
50
+ * Need to update existing menus with tenant and locale information.
51
+ */
52
+
53
+ records.push(...result.map(item => {
54
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {
55
+ PK: partitionKey,
56
+ SK: pageElementsStorageOperations.createSortKey(item),
57
+ TYPE: pageElementsStorageOperations.createType(),
58
+ tenant,
59
+ locale
60
+ });
61
+ }));
62
+ }
63
+
64
+ const items = records.map(record => {
65
+ return pageElementsStorageOperations.entity.putBatch(record);
66
+ });
67
+ await (0, _batchWrite.batchWriteAll)({
68
+ table: pageElementsStorageOperations.table,
69
+ items
70
+ });
71
+ };
72
+
73
+ exports.upgradePageElements = upgradePageElements;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["upgradePageElements","context","tenant","tenancy","getCurrentTenant","id","localeCodes","i18n","getLocales","map","locale","code","pageElementsStorageOperations","pageBuilder","pageElements","storageOperations","PageElementStorageOperationsDdbEs","WebinyError","records","partitionKey","createPartitionKey","result","queryAll","entity","options","gt","push","item","PK","SK","createSortKey","TYPE","createType","items","record","putBatch","batchWriteAll","table"],"sources":["pageElement.ts"],"sourcesContent":["import { PbContext } from \"@webiny/api-page-builder/graphql/types\";\n// @ts-ignore\nimport { PageElementStorageOperationsDdbEs } from \"~/operations/pageElement/PageElementStorageOperations\";\nimport { PageElement } from \"@webiny/api-page-builder/types\";\nimport { queryAll } from \"@webiny/db-dynamodb/utils/query\";\nimport { batchWriteAll } from \"@webiny/db-dynamodb/utils/batchWrite\";\nimport WebinyError from \"@webiny/error\";\n\ntype DbRecord<T> = T & {\n PK: string;\n SK: string;\n TYPE: string;\n};\n\nexport const upgradePageElements = async (context: PbContext) => {\n const tenant: string = context.tenancy.getCurrentTenant().id;\n const localeCodes: string[] = await context.i18n.getLocales().map(locale => locale.code);\n // @ts-ignore\n const pageElementsStorageOperations = context.pageBuilder.pageElements\n .storageOperations as PageElementStorageOperationsDdbEs;\n if (pageElementsStorageOperations instanceof PageElementStorageOperationsDdbEs === false) {\n throw new WebinyError(\n \"context.pageBuilder.pageElements.storageOperations must be instance of PageElementStorageOperationsDdbEs.\"\n );\n }\n /**\n * First we need all categories in all existing locales of the tenant.\n */\n const records: DbRecord<PageElement>[] = [];\n for (const locale of localeCodes) {\n const partitionKey = pageElementsStorageOperations.createPartitionKey({\n tenant,\n locale\n });\n const result = await queryAll<PageElement>({\n entity: pageElementsStorageOperations.entity,\n partitionKey,\n options: {\n gt: \" \"\n }\n });\n /**\n * Need to update existing menus with tenant and locale information.\n */\n records.push(\n ...result.map(item => {\n return {\n ...item,\n PK: partitionKey,\n SK: pageElementsStorageOperations.createSortKey(item),\n TYPE: pageElementsStorageOperations.createType(),\n tenant,\n locale\n };\n })\n );\n }\n const items = records.map(record => {\n return pageElementsStorageOperations.entity.putBatch(record);\n });\n\n await batchWriteAll({\n table: pageElementsStorageOperations.table,\n items\n });\n};\n"],"mappings":";;;;;;;;;;;AAEA;;AAEA;;AACA;;AACA;;AALA;AAaO,MAAMA,mBAAmB,GAAG,MAAOC,OAAP,IAA8B;EAC7D,MAAMC,MAAc,GAAGD,OAAO,CAACE,OAAR,CAAgBC,gBAAhB,GAAmCC,EAA1D;EACA,MAAMC,WAAqB,GAAG,MAAML,OAAO,CAACM,IAAR,CAAaC,UAAb,GAA0BC,GAA1B,CAA8BC,MAAM,IAAIA,MAAM,CAACC,IAA/C,CAApC,CAF6D,CAG7D;;EACA,MAAMC,6BAA6B,GAAGX,OAAO,CAACY,WAAR,CAAoBC,YAApB,CACjCC,iBADL;;EAEA,IAAIH,6BAA6B,YAAYI,+DAAzC,KAA+E,KAAnF,EAA0F;IACtF,MAAM,IAAIC,cAAJ,CACF,2GADE,CAAN;EAGH;EACD;AACJ;AACA;;;EACI,MAAMC,OAAgC,GAAG,EAAzC;;EACA,KAAK,MAAMR,MAAX,IAAqBJ,WAArB,EAAkC;IAC9B,MAAMa,YAAY,GAAGP,6BAA6B,CAACQ,kBAA9B,CAAiD;MAClElB,MADkE;MAElEQ;IAFkE,CAAjD,CAArB;IAIA,MAAMW,MAAM,GAAG,MAAM,IAAAC,eAAA,EAAsB;MACvCC,MAAM,EAAEX,6BAA6B,CAACW,MADC;MAEvCJ,YAFuC;MAGvCK,OAAO,EAAE;QACLC,EAAE,EAAE;MADC;IAH8B,CAAtB,CAArB;IAOA;AACR;AACA;;IACQP,OAAO,CAACQ,IAAR,CACI,GAAGL,MAAM,CAACZ,GAAP,CAAWkB,IAAI,IAAI;MAClB,mEACOA,IADP;QAEIC,EAAE,EAAET,YAFR;QAGIU,EAAE,EAAEjB,6BAA6B,CAACkB,aAA9B,CAA4CH,IAA5C,CAHR;QAIII,IAAI,EAAEnB,6BAA6B,CAACoB,UAA9B,EAJV;QAKI9B,MALJ;QAMIQ;MANJ;IAQH,CATE,CADP;EAYH;;EACD,MAAMuB,KAAK,GAAGf,OAAO,CAACT,GAAR,CAAYyB,MAAM,IAAI;IAChC,OAAOtB,6BAA6B,CAACW,MAA9B,CAAqCY,QAArC,CAA8CD,MAA9C,CAAP;EACH,CAFa,CAAd;EAIA,MAAM,IAAAE,yBAAA,EAAc;IAChBC,KAAK,EAAEzB,6BAA6B,CAACyB,KADrB;IAEhBJ;EAFgB,CAAd,CAAN;AAIH,CAnDM"}