@unchainedshop/platform 4.3.3 → 4.4.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 (218) hide show
  1. package/README.md +149 -2
  2. package/lib/context/index.d.ts +1 -2
  3. package/lib/context/index.js +1 -2
  4. package/lib/context/setAccessToken.d.ts +1 -2
  5. package/lib/context/setAccessToken.js +0 -1
  6. package/lib/migrations/createMigrationRunner.d.ts +0 -1
  7. package/lib/migrations/createMigrationRunner.js +0 -3
  8. package/lib/migrations/migrationRepository.d.ts +1 -2
  9. package/lib/migrations/migrationRepository.js +1 -1
  10. package/lib/migrations/runMigrations.d.ts +2 -3
  11. package/lib/migrations/runMigrations.js +1 -2
  12. package/lib/platform-index.d.ts +4 -5
  13. package/lib/platform-index.js +4 -5
  14. package/lib/setup/setupAccounts.d.ts +1 -2
  15. package/lib/setup/setupAccounts.js +0 -1
  16. package/lib/setup/setupTemplates.d.ts +11 -11
  17. package/lib/setup/setupTemplates.js +16 -19
  18. package/lib/setup/setupUploadHandlers.d.ts +1 -2
  19. package/lib/setup/setupUploadHandlers.js +0 -1
  20. package/lib/setup/setupWorkqueue.d.ts +2 -3
  21. package/lib/setup/setupWorkqueue.js +1 -7
  22. package/lib/startPlatform.d.ts +6 -7
  23. package/lib/startPlatform.js +15 -16
  24. package/lib/templates/index.d.ts +8 -9
  25. package/lib/templates/index.js +8 -9
  26. package/lib/templates/order-parser/getOrderPositionsData.d.ts +2 -3
  27. package/lib/templates/order-parser/getOrderPositionsData.js +0 -1
  28. package/lib/templates/order-parser/getOrderSummaryData.d.ts +2 -3
  29. package/lib/templates/order-parser/getOrderSummaryData.js +0 -1
  30. package/lib/templates/order-parser/index.d.ts +4 -5
  31. package/lib/templates/order-parser/index.js +2 -3
  32. package/lib/templates/resolveAccountActionTemplate.d.ts +1 -2
  33. package/lib/templates/resolveAccountActionTemplate.js +0 -2
  34. package/lib/templates/resolveEnrollmentStatusTemplate.d.ts +1 -2
  35. package/lib/templates/resolveEnrollmentStatusTemplate.js +0 -1
  36. package/lib/templates/resolveErrorReportTemplate.d.ts +1 -2
  37. package/lib/templates/resolveErrorReportTemplate.js +0 -1
  38. package/lib/templates/resolveForwardDeliveryTemplate.d.ts +1 -2
  39. package/lib/templates/resolveForwardDeliveryTemplate.js +1 -2
  40. package/lib/templates/resolveOrderConfirmationTemplate.d.ts +1 -2
  41. package/lib/templates/resolveOrderConfirmationTemplate.js +1 -2
  42. package/lib/templates/resolveOrderRejectionTemplate.d.ts +1 -2
  43. package/lib/templates/resolveOrderRejectionTemplate.js +1 -2
  44. package/lib/templates/resolveQuotationStatusTemplate.d.ts +1 -2
  45. package/lib/templates/resolveQuotationStatusTemplate.js +0 -1
  46. package/package.json +17 -16
  47. package/lib/bulk-importer/createBulkImporter.d.ts +0 -20
  48. package/lib/bulk-importer/createBulkImporter.d.ts.map +0 -1
  49. package/lib/bulk-importer/createBulkImporter.js +0 -97
  50. package/lib/bulk-importer/createBulkImporter.js.map +0 -1
  51. package/lib/bulk-importer/handlers/assortment/create.d.ts +0 -11
  52. package/lib/bulk-importer/handlers/assortment/create.d.ts.map +0 -1
  53. package/lib/bulk-importer/handlers/assortment/create.js +0 -60
  54. package/lib/bulk-importer/handlers/assortment/create.js.map +0 -1
  55. package/lib/bulk-importer/handlers/assortment/index.d.ts +0 -4
  56. package/lib/bulk-importer/handlers/assortment/index.d.ts.map +0 -1
  57. package/lib/bulk-importer/handlers/assortment/index.js +0 -4
  58. package/lib/bulk-importer/handlers/assortment/index.js.map +0 -1
  59. package/lib/bulk-importer/handlers/assortment/remove.d.ts +0 -10
  60. package/lib/bulk-importer/handlers/assortment/remove.d.ts.map +0 -1
  61. package/lib/bulk-importer/handlers/assortment/remove.js +0 -13
  62. package/lib/bulk-importer/handlers/assortment/remove.js.map +0 -1
  63. package/lib/bulk-importer/handlers/assortment/update.d.ts +0 -12
  64. package/lib/bulk-importer/handlers/assortment/update.d.ts.map +0 -1
  65. package/lib/bulk-importer/handlers/assortment/update.js +0 -62
  66. package/lib/bulk-importer/handlers/assortment/update.js.map +0 -1
  67. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts +0 -7
  68. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.d.ts.map +0 -1
  69. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js +0 -37
  70. package/lib/bulk-importer/handlers/assortment/upsertAssortmentChildren.js.map +0 -1
  71. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts +0 -7
  72. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.d.ts.map +0 -1
  73. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js +0 -32
  74. package/lib/bulk-importer/handlers/assortment/upsertAssortmentFilters.js.map +0 -1
  75. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts +0 -7
  76. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.d.ts.map +0 -1
  77. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js +0 -37
  78. package/lib/bulk-importer/handlers/assortment/upsertAssortmentProducts.js.map +0 -1
  79. package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts +0 -7
  80. package/lib/bulk-importer/handlers/assortment/upsertMedia.d.ts.map +0 -1
  81. package/lib/bulk-importer/handlers/assortment/upsertMedia.js +0 -39
  82. package/lib/bulk-importer/handlers/assortment/upsertMedia.js.map +0 -1
  83. package/lib/bulk-importer/handlers/filter/create.d.ts +0 -11
  84. package/lib/bulk-importer/handlers/filter/create.d.ts.map +0 -1
  85. package/lib/bulk-importer/handlers/filter/create.js +0 -54
  86. package/lib/bulk-importer/handlers/filter/create.js.map +0 -1
  87. package/lib/bulk-importer/handlers/filter/index.d.ts +0 -4
  88. package/lib/bulk-importer/handlers/filter/index.d.ts.map +0 -1
  89. package/lib/bulk-importer/handlers/filter/index.js +0 -4
  90. package/lib/bulk-importer/handlers/filter/index.js.map +0 -1
  91. package/lib/bulk-importer/handlers/filter/remove.d.ts +0 -10
  92. package/lib/bulk-importer/handlers/filter/remove.d.ts.map +0 -1
  93. package/lib/bulk-importer/handlers/filter/remove.js +0 -14
  94. package/lib/bulk-importer/handlers/filter/remove.js.map +0 -1
  95. package/lib/bulk-importer/handlers/filter/update.d.ts +0 -11
  96. package/lib/bulk-importer/handlers/filter/update.d.ts.map +0 -1
  97. package/lib/bulk-importer/handlers/filter/update.js +0 -44
  98. package/lib/bulk-importer/handlers/filter/update.js.map +0 -1
  99. package/lib/bulk-importer/handlers/product/create.d.ts +0 -11
  100. package/lib/bulk-importer/handlers/product/create.d.ts.map +0 -1
  101. package/lib/bulk-importer/handlers/product/create.js +0 -51
  102. package/lib/bulk-importer/handlers/product/create.js.map +0 -1
  103. package/lib/bulk-importer/handlers/product/index.d.ts +0 -4
  104. package/lib/bulk-importer/handlers/product/index.d.ts.map +0 -1
  105. package/lib/bulk-importer/handlers/product/index.js +0 -4
  106. package/lib/bulk-importer/handlers/product/index.js.map +0 -1
  107. package/lib/bulk-importer/handlers/product/remove.d.ts +0 -10
  108. package/lib/bulk-importer/handlers/product/remove.d.ts.map +0 -1
  109. package/lib/bulk-importer/handlers/product/remove.js +0 -13
  110. package/lib/bulk-importer/handlers/product/remove.js.map +0 -1
  111. package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts +0 -3
  112. package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.d.ts.map +0 -1
  113. package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js +0 -16
  114. package/lib/bulk-importer/handlers/product/transformSpecificationToProductStructure.js.map +0 -1
  115. package/lib/bulk-importer/handlers/product/update.d.ts +0 -11
  116. package/lib/bulk-importer/handlers/product/update.d.ts.map +0 -1
  117. package/lib/bulk-importer/handlers/product/update.js +0 -48
  118. package/lib/bulk-importer/handlers/product/update.js.map +0 -1
  119. package/lib/bulk-importer/handlers/product/upsertMedia.d.ts +0 -6
  120. package/lib/bulk-importer/handlers/product/upsertMedia.d.ts.map +0 -1
  121. package/lib/bulk-importer/handlers/product/upsertMedia.js +0 -45
  122. package/lib/bulk-importer/handlers/product/upsertMedia.js.map +0 -1
  123. package/lib/bulk-importer/handlers/product/upsertVariations.d.ts +0 -6
  124. package/lib/bulk-importer/handlers/product/upsertVariations.d.ts.map +0 -1
  125. package/lib/bulk-importer/handlers/product/upsertVariations.js +0 -42
  126. package/lib/bulk-importer/handlers/product/upsertVariations.js.map +0 -1
  127. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts +0 -3
  128. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.d.ts.map +0 -1
  129. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js +0 -6
  130. package/lib/bulk-importer/handlers/utils/convertTagsToLowerCase.js.map +0 -1
  131. package/lib/bulk-importer/upsertAsset.d.ts +0 -8
  132. package/lib/bulk-importer/upsertAsset.d.ts.map +0 -1
  133. package/lib/bulk-importer/upsertAsset.js +0 -33
  134. package/lib/bulk-importer/upsertAsset.js.map +0 -1
  135. package/lib/context/index.d.ts.map +0 -1
  136. package/lib/context/index.js.map +0 -1
  137. package/lib/context/setAccessToken.d.ts.map +0 -1
  138. package/lib/context/setAccessToken.js.map +0 -1
  139. package/lib/context/withAccessToken.d.ts +0 -4
  140. package/lib/context/withAccessToken.d.ts.map +0 -1
  141. package/lib/context/withAccessToken.js +0 -42
  142. package/lib/context/withAccessToken.js.map +0 -1
  143. package/lib/migrations/createMigrationRunner.d.ts.map +0 -1
  144. package/lib/migrations/createMigrationRunner.js.map +0 -1
  145. package/lib/migrations/migrationRepository.d.ts.map +0 -1
  146. package/lib/migrations/migrationRepository.js.map +0 -1
  147. package/lib/migrations/runMigrations.d.ts.map +0 -1
  148. package/lib/migrations/runMigrations.js.map +0 -1
  149. package/lib/platform-index.d.ts.map +0 -1
  150. package/lib/platform-index.js.map +0 -1
  151. package/lib/setup/setupAccounts.d.ts.map +0 -1
  152. package/lib/setup/setupAccounts.js.map +0 -1
  153. package/lib/setup/setupCarts.d.ts +0 -8
  154. package/lib/setup/setupCarts.d.ts.map +0 -1
  155. package/lib/setup/setupCarts.js +0 -17
  156. package/lib/setup/setupCarts.js.map +0 -1
  157. package/lib/setup/setupTemplates.d.ts.map +0 -1
  158. package/lib/setup/setupTemplates.js.map +0 -1
  159. package/lib/setup/setupUploadHandlers.d.ts.map +0 -1
  160. package/lib/setup/setupUploadHandlers.js.map +0 -1
  161. package/lib/setup/setupWorkqueue.d.ts.map +0 -1
  162. package/lib/setup/setupWorkqueue.js.map +0 -1
  163. package/lib/startPlatform.d.ts.map +0 -1
  164. package/lib/startPlatform.js.map +0 -1
  165. package/lib/templates/index.d.ts.map +0 -1
  166. package/lib/templates/index.js.map +0 -1
  167. package/lib/templates/order-parser/formatAddress.d.ts +0 -3
  168. package/lib/templates/order-parser/formatAddress.d.ts.map +0 -1
  169. package/lib/templates/order-parser/formatAddress.js +0 -14
  170. package/lib/templates/order-parser/formatAddress.js.map +0 -1
  171. package/lib/templates/order-parser/formatPrice.d.ts +0 -6
  172. package/lib/templates/order-parser/formatPrice.d.ts.map +0 -1
  173. package/lib/templates/order-parser/formatPrice.js +0 -6
  174. package/lib/templates/order-parser/formatPrice.js.map +0 -1
  175. package/lib/templates/order-parser/getOrderPositionsData.d.ts.map +0 -1
  176. package/lib/templates/order-parser/getOrderPositionsData.js.map +0 -1
  177. package/lib/templates/order-parser/getOrderSummaryData.d.ts.map +0 -1
  178. package/lib/templates/order-parser/getOrderSummaryData.js.map +0 -1
  179. package/lib/templates/order-parser/index.d.ts.map +0 -1
  180. package/lib/templates/order-parser/index.js.map +0 -1
  181. package/lib/templates/resolveAccountActionTemplate.d.ts.map +0 -1
  182. package/lib/templates/resolveAccountActionTemplate.js.map +0 -1
  183. package/lib/templates/resolveEnrollmentStatusTemplate.d.ts.map +0 -1
  184. package/lib/templates/resolveEnrollmentStatusTemplate.js.map +0 -1
  185. package/lib/templates/resolveErrorReportTemplate.d.ts.map +0 -1
  186. package/lib/templates/resolveErrorReportTemplate.js.map +0 -1
  187. package/lib/templates/resolveForwardDeliveryTemplate.d.ts.map +0 -1
  188. package/lib/templates/resolveForwardDeliveryTemplate.js.map +0 -1
  189. package/lib/templates/resolveOrderConfirmationTemplate.d.ts.map +0 -1
  190. package/lib/templates/resolveOrderConfirmationTemplate.js.map +0 -1
  191. package/lib/templates/resolveOrderRejectionTemplate.d.ts.map +0 -1
  192. package/lib/templates/resolveOrderRejectionTemplate.js.map +0 -1
  193. package/lib/templates/resolveQuotationStatusTemplate.d.ts.map +0 -1
  194. package/lib/templates/resolveQuotationStatusTemplate.js.map +0 -1
  195. package/src/context/index.ts +0 -1
  196. package/src/context/setAccessToken.ts +0 -22
  197. package/src/migrations/createMigrationRunner.ts +0 -65
  198. package/src/migrations/migrationRepository.ts +0 -22
  199. package/src/migrations/runMigrations.ts +0 -68
  200. package/src/platform-index.ts +0 -19
  201. package/src/setup/setupAccounts.ts +0 -11
  202. package/src/setup/setupTemplates.ts +0 -67
  203. package/src/setup/setupUploadHandlers.ts +0 -22
  204. package/src/setup/setupWorkqueue.ts +0 -104
  205. package/src/startPlatform.ts +0 -128
  206. package/src/templates/index.ts +0 -9
  207. package/src/templates/order-parser/getOrderPositionsData.ts +0 -50
  208. package/src/templates/order-parser/getOrderSummaryData.ts +0 -91
  209. package/src/templates/order-parser/index.ts +0 -65
  210. package/src/templates/resolveAccountActionTemplate.ts +0 -127
  211. package/src/templates/resolveEnrollmentStatusTemplate.ts +0 -34
  212. package/src/templates/resolveErrorReportTemplate.ts +0 -47
  213. package/src/templates/resolveForwardDeliveryTemplate.ts +0 -42
  214. package/src/templates/resolveOrderConfirmationTemplate.ts +0 -40
  215. package/src/templates/resolveOrderRejectionTemplate.ts +0 -41
  216. package/src/templates/resolveQuotationStatusTemplate.ts +0 -45
  217. package/tests/platform-index.test.ts +0 -7
  218. package/tsconfig.json +0 -9
@@ -72,7 +72,6 @@ const emailConfig = {
72
72
  fr: verifyEmailEnglishConfig,
73
73
  },
74
74
  '': {
75
- // password changed!
76
75
  url: () => null,
77
76
  en: passwordChangedEmailEnglishConfig,
78
77
  de: passwordChangedEmailEnglishConfig,
@@ -103,4 +102,3 @@ export const resolveAccountActionTemplate = async ({ userId, action, recipientEm
103
102
  },
104
103
  ];
105
104
  };
106
- //# sourceMappingURL=resolveAccountActionTemplate.js.map
@@ -1,3 +1,2 @@
1
- import { TemplateResolver } from '@unchainedshop/core';
1
+ import type { TemplateResolver } from '@unchainedshop/core';
2
2
  export declare const resolveEnrollmentStatusTemplate: TemplateResolver;
3
- //# sourceMappingURL=resolveEnrollmentStatusTemplate.d.ts.map
@@ -26,4 +26,3 @@ export const resolveEnrollmentStatusTemplate = async ({ enrollmentId }, context)
26
26
  },
27
27
  ];
28
28
  };
29
- //# sourceMappingURL=resolveEnrollmentStatusTemplate.js.map
@@ -1,5 +1,4 @@
1
- import { TemplateResolver } from '@unchainedshop/core';
1
+ import type { TemplateResolver } from '@unchainedshop/core';
2
2
  declare const resolveErrorReportTemplate: TemplateResolver;
3
3
  export { resolveErrorReportTemplate };
4
4
  export default resolveErrorReportTemplate;
5
- //# sourceMappingURL=resolveErrorReportTemplate.d.ts.map
@@ -32,4 +32,3 @@ ${content}
32
32
  };
33
33
  export { resolveErrorReportTemplate };
34
34
  export default resolveErrorReportTemplate;
35
- //# sourceMappingURL=resolveErrorReportTemplate.js.map
@@ -1,3 +1,2 @@
1
- import { TemplateResolver } from '@unchainedshop/core';
1
+ import type { TemplateResolver } from '@unchainedshop/core';
2
2
  export declare const resolveForwardDeliveryTemplate: TemplateResolver;
3
- //# sourceMappingURL=resolveForwardDeliveryTemplate.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { systemLocale } from '@unchainedshop/utils';
2
- import { transformOrderToText } from './order-parser/index.js';
2
+ import { transformOrderToText } from "./order-parser/index.js";
3
3
  const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
4
4
  export const resolveForwardDeliveryTemplate = async ({ config, orderId }, context) => {
5
5
  const { modules } = context;
@@ -32,4 +32,3 @@ ${EMAIL_WEBSITE_NAME}: ${EMAIL_WEBSITE_URL}
32
32
  },
33
33
  ];
34
34
  };
35
- //# sourceMappingURL=resolveForwardDeliveryTemplate.js.map
@@ -1,6 +1,5 @@
1
- import { TemplateResolver } from '@unchainedshop/core';
1
+ import type { TemplateResolver } from '@unchainedshop/core';
2
2
  export declare const resolveOrderConfirmationTemplate: TemplateResolver<{
3
3
  orderId: string;
4
4
  locale: string;
5
5
  }>;
6
- //# sourceMappingURL=resolveOrderConfirmationTemplate.d.ts.map
@@ -1,4 +1,4 @@
1
- import { transformOrderToText } from './order-parser/index.js';
1
+ import { transformOrderToText } from "./order-parser/index.js";
2
2
  const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
3
3
  export const resolveOrderConfirmationTemplate = async ({ orderId, locale }, context) => {
4
4
  const { modules } = context;
@@ -27,4 +27,3 @@ ${EMAIL_WEBSITE_NAME}: ${EMAIL_WEBSITE_URL}
27
27
  },
28
28
  ];
29
29
  };
30
- //# sourceMappingURL=resolveOrderConfirmationTemplate.js.map
@@ -1,3 +1,2 @@
1
- import { TemplateResolver } from '@unchainedshop/core';
1
+ import type { TemplateResolver } from '@unchainedshop/core';
2
2
  export declare const resolveOrderRejectionTemplate: TemplateResolver;
3
- //# sourceMappingURL=resolveOrderRejectionTemplate.d.ts.map
@@ -1,4 +1,4 @@
1
- import { transformOrderToText } from './order-parser/index.js';
1
+ import { transformOrderToText } from "./order-parser/index.js";
2
2
  const { EMAIL_FROM, EMAIL_WEBSITE_NAME, EMAIL_WEBSITE_URL } = process.env;
3
3
  export const resolveOrderRejectionTemplate = async ({ orderId, locale }, context) => {
4
4
  const { modules } = context;
@@ -31,4 +31,3 @@ ${EMAIL_WEBSITE_NAME}: ${EMAIL_WEBSITE_URL}
31
31
  },
32
32
  ];
33
33
  };
34
- //# sourceMappingURL=resolveOrderRejectionTemplate.js.map
@@ -1,3 +1,2 @@
1
- import { TemplateResolver } from '@unchainedshop/core';
1
+ import type { TemplateResolver } from '@unchainedshop/core';
2
2
  export declare const resolveQuotationStatusTemplate: TemplateResolver;
3
- //# sourceMappingURL=resolveQuotationStatusTemplate.d.ts.map
@@ -32,4 +32,3 @@ export const resolveQuotationStatusTemplate = async ({ quotationId }, { modules
32
32
  },
33
33
  ];
34
34
  };
35
- //# sourceMappingURL=resolveQuotationStatusTemplate.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unchainedshop/platform",
3
- "version": "4.3.3",
3
+ "version": "4.4.0",
4
4
  "main": "lib/platform-index.js",
5
5
  "types": "lib/platform-index.d.ts",
6
6
  "type": "module",
@@ -9,8 +9,8 @@
9
9
  "build": "tsc -b",
10
10
  "prepublishOnly": "npm run clean && npm run build",
11
11
  "watch": "tsc -w",
12
- "test": "tsx --test",
13
- "test:watch": "tsx --test --watch"
12
+ "test": "node --test",
13
+ "test:watch": "node --test --watch"
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
@@ -22,8 +22,10 @@
22
22
  "core"
23
23
  ],
24
24
  "authors": [
25
- "Joël Meiller",
26
- "Pascal Kaufmann"
25
+ "Pascal Kaufmann",
26
+ "Mikael Araya",
27
+ "Vedran Rudelj",
28
+ "Joël Meiller"
27
29
  ],
28
30
  "license": "EUPL-1.2",
29
31
  "bugs": {
@@ -35,20 +37,19 @@
35
37
  "npm": ">=10.0.0"
36
38
  },
37
39
  "dependencies": {
38
- "@unchainedshop/api": "^4.3.0",
39
- "@unchainedshop/core": "^4.3.0",
40
- "@unchainedshop/events": "^4.3.0",
41
- "@unchainedshop/file-upload": "^4.3.0",
42
- "@unchainedshop/logger": "^4.3.0",
43
- "@unchainedshop/mongodb": "^4.3.0",
44
- "@unchainedshop/plugins": "^4.3.0",
45
- "@unchainedshop/roles": "^4.3.0",
46
- "@unchainedshop/utils": "^4.3.0",
40
+ "@unchainedshop/api": "^4.4.0",
41
+ "@unchainedshop/core": "^4.4.0",
42
+ "@unchainedshop/events": "^4.4.0",
43
+ "@unchainedshop/file-upload": "^4.4.0",
44
+ "@unchainedshop/logger": "^4.4.0",
45
+ "@unchainedshop/mongodb": "^4.4.0",
46
+ "@unchainedshop/plugins": "^4.4.0",
47
+ "@unchainedshop/roles": "^4.4.0",
48
+ "@unchainedshop/utils": "^4.4.0",
47
49
  "safe-stable-stringify": "^2.5.0"
48
50
  },
49
51
  "devDependencies": {
50
- "@types/node": "^24.0.13",
51
- "tsx": "^4.20.3",
52
+ "@types/node": "^25.0.0",
52
53
  "typescript": "^5.8.3"
53
54
  }
54
55
  }
@@ -1,20 +0,0 @@
1
- import { mongodb } from '@unchainedshop/mongodb';
2
- import { BulkImporter, UnchainedCore } from '@unchainedshop/types/core.js';
3
- export type BulkImportOperationResult = {
4
- entity: string;
5
- operation: string;
6
- success: boolean;
7
- };
8
- export type BulkImportOperation = (payload: any, options: {
9
- bulk: (collection: string) => typeof mongodb.BulkOperationBase;
10
- createShouldUpsertIfIDExists?: boolean;
11
- updateShouldUpsertIfIDNotExists?: boolean;
12
- skipCacheInvalidation?: boolean;
13
- logger?: any;
14
- }, unchainedAPI: UnchainedCore) => Promise<BulkImportOperationResult>;
15
- export type BulkImportHandler = {
16
- [x: string]: BulkImportOperation;
17
- };
18
- export declare const getOperation: (entity: string, operation: string) => BulkImportOperation;
19
- export declare const createBulkImporterFactory: (db: any, bulkImporterOptions: any) => BulkImporter;
20
- //# sourceMappingURL=createBulkImporter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createBulkImporter.d.ts","sourceRoot":"","sources":["../../src/bulk-importer/createBulkImporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAK3E,MAAM,MAAM,yBAAyB,GAAG;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,CAChC,OAAO,EAAE,GAAG,EACZ,OAAO,EAAE;IACP,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,OAAO,CAAC,iBAAiB,CAAC;IAC/D,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,+BAA+B,CAAC,EAAE,OAAO,CAAC;IAC1C,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,MAAM,CAAC,EAAE,GAAG,CAAC;CACd,EACD,YAAY,EAAE,aAAa,KACxB,OAAO,CAAC,yBAAyB,CAAC,CAAC;AAExC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,CAAC,CAAC,EAAE,MAAM,GAAG,mBAAmB,CAAC;CAClC,CAAC;AAIF,eAAO,MAAM,YAAY,WAAY,MAAM,aAAa,MAAM,KAAG,mBAahE,CAAC;AAEF,eAAO,MAAM,yBAAyB,iCAA6B,GAAG,KAAG,YAgGxE,CAAC"}
@@ -1,97 +0,0 @@
1
- import * as AssortmentHandlers from './handlers/assortment/index.js';
2
- import * as FilterHandlers from './handlers/filter/index.js';
3
- import * as ProductHandlers from './handlers/product/index.js';
4
- let bulkOperationHandlers = {};
5
- export const getOperation = (entity, operation) => {
6
- const handlers = bulkOperationHandlers[entity];
7
- if (!handlers) {
8
- throw new Error(`Entity ${entity} unknown`);
9
- }
10
- const entityOperation = handlers[operation];
11
- if (!entityOperation || typeof entityOperation !== 'function') {
12
- throw new Error(`Operation ${operation} for entity ${entity} invalid`);
13
- }
14
- return entityOperation;
15
- };
16
- export const createBulkImporterFactory = (db, bulkImporterOptions) => {
17
- bulkOperationHandlers = {
18
- ASSORTMENT: AssortmentHandlers,
19
- PRODUCT: ProductHandlers,
20
- FILTER: FilterHandlers,
21
- ...(bulkImporterOptions?.handlers || {}),
22
- };
23
- const createBulkImporter = (options) => {
24
- const bulkOperations = {};
25
- const preparationIssues = [];
26
- const processedOperations = {};
27
- const { logger, createShouldUpsertIfIDExists, skipCacheInvalidation, updateShouldUpsertIfIDNotExists, } = options;
28
- const bulk = (collectionName) => {
29
- const Collection = db.collection(collectionName);
30
- if (!bulkOperations[collectionName])
31
- bulkOperations[collectionName] = Collection.initializeOrderedBulkOp();
32
- return bulkOperations[collectionName];
33
- };
34
- logger.info(`Configure event import with options: createShouldUpsertIfIDExists=${createShouldUpsertIfIDExists} updateShouldUpsertIfIDNotExists=${updateShouldUpsertIfIDNotExists} skipCacheInvalidation=${skipCacheInvalidation}`);
35
- return {
36
- prepare: async (event, unchainedAPI) => {
37
- const entity = event.entity.toUpperCase();
38
- const operation = event.operation.toLowerCase();
39
- const handler = getOperation(entity, operation);
40
- const payloadId = event.payload?._id || 'global';
41
- logger.verbose(`${operation} ${entity} ${payloadId} [PREPARE]`);
42
- logger.profile(`${operation} ${entity} ${payloadId} [DONE]`, {
43
- level: 'verbose',
44
- });
45
- try {
46
- await handler(event.payload, { bulk, ...options }, unchainedAPI);
47
- if (!processedOperations[entity])
48
- processedOperations[entity] = {};
49
- if (!processedOperations[entity][operation])
50
- processedOperations[entity][operation] = [];
51
- processedOperations[entity][operation].push(payloadId);
52
- logger.verbose(`${operation} ${entity} ${payloadId} [SUCCESS]`);
53
- }
54
- catch (e) {
55
- logger.verbose(`${operation} ${entity} ${payloadId} [FAILED]: ${e.message}`);
56
- preparationIssues.push({
57
- operation,
58
- entity,
59
- payloadId,
60
- errorCode: e.name,
61
- errorMessage: e.message,
62
- });
63
- }
64
- finally {
65
- logger.profile(`${operation} ${entity} ${payloadId} [DONE]`, {
66
- level: 'verbose',
67
- });
68
- }
69
- },
70
- execute: async () => {
71
- logger.info(`Execute bulk operations for: ${Object.keys(bulkOperations).join(', ')}`);
72
- const processedBulkOperations = await Promise.allSettled(Object.values(bulkOperations).map(async (o) => o.execute()));
73
- const operationResults = {
74
- processedOperations,
75
- processedBulkOperations,
76
- };
77
- if (preparationIssues?.length) {
78
- logger.error(`${preparationIssues.length} issues occured while preparing events, import finished with errors`);
79
- const errors = { preparationIssues };
80
- return [operationResults, errors];
81
- }
82
- logger.info(`Import finished without errors`);
83
- return [operationResults, null];
84
- },
85
- invalidateCaches: async (unchainedAPI) => {
86
- if (skipCacheInvalidation)
87
- return;
88
- await unchainedAPI.modules.assortments.invalidateCache({}, { skipUpstreamTraversal: true });
89
- await unchainedAPI.modules.filters.invalidateCache({}, unchainedAPI);
90
- },
91
- };
92
- };
93
- return {
94
- createBulkImporter,
95
- };
96
- };
97
- //# sourceMappingURL=createBulkImporter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createBulkImporter.js","sourceRoot":"","sources":["../../src/bulk-importer/createBulkImporter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,kBAAkB,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,eAAe,MAAM,6BAA6B,CAAC;AAuB/D,IAAI,qBAAqB,GAAsC,EAAE,CAAC;AAElE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,SAAiB,EAAuB,EAAE;IACrF,MAAM,QAAQ,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,UAAU,MAAM,UAAU,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,eAAe,GAAG,QAAQ,CAAC,SAAS,CAAwB,CAAC;IAEnE,IAAI,CAAC,eAAe,IAAI,OAAO,eAAe,KAAK,UAAU,EAAE,CAAC;QAC9D,MAAM,IAAI,KAAK,CAAC,aAAa,SAAS,eAAe,MAAM,UAAU,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,EAAE,EAAE,mBAA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AAC,IAAI,CAAC,gCAAgC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAEtF,MAAM,uBAAuB,GAAG,MAAM,OAAO,CAAC,UAAU,CACtD,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CACjE,CAAC;gBACF,MAAM,gBAAgB,GAAG;oBACvB,mBAAmB;oBACnB,uBAAuB;iBACxB,CAAC;gBACF,IAAI,iBAAiB,EAAE,MAAM,EAAE,CAAC;oBAC9B,MAAM,CAAC,KAAK,CACV,GAAG,iBAAiB,CAAC,MAAM,qEAAqE,CACjG,CAAC;oBACF,MAAM,MAAM,GAAG,EAAE,iBAAiB,EAAE,CAAC;oBACrC,OAAO,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;gBACpC,CAAC;gBACD,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;gBAC9C,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;YAClC,CAAC;YACD,gBAAgB,EAAE,KAAK,EAAE,YAA2B,EAAE,EAAE;gBACtD,IAAI,qBAAqB;oBAAE,OAAO;gBAClC,MAAM,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC5F,MAAM,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;YACvE,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO;QACL,kBAAkB;KACnB,CAAC;AACJ,CAAC,CAAC"}
@@ -1,11 +0,0 @@
1
- import { UnchainedCore } from '@unchainedshop/types/core.js';
2
- export default function createAssortment(payload: any, { logger, createShouldUpsertIfIDExists }: {
3
- logger: any;
4
- createShouldUpsertIfIDExists: any;
5
- }, unchainedAPI: UnchainedCore): Promise<{
6
- entity: string;
7
- operation: string;
8
- _id: any;
9
- success: boolean;
10
- }>;
11
- //# sourceMappingURL=create.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAO7D,wBAA8B,gBAAgB,CAC5C,OAAO,EAAE,GAAG,EACZ,EAAE,MAAM,EAAE,4BAA4B,EAAE;;;CAAA,EACxC,YAAY,EAAE,aAAa;;;;;GAyE5B"}
@@ -1,60 +0,0 @@
1
- import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
2
- import upsertAssortmentChildren from './upsertAssortmentChildren.js';
3
- import upsertAssortmentFilters from './upsertAssortmentFilters.js';
4
- import upsertAssortmentProducts from './upsertAssortmentProducts.js';
5
- import upsertMedia from './upsertMedia.js';
6
- export default async function createAssortment(payload, { logger, createShouldUpsertIfIDExists }, unchainedAPI) {
7
- const { modules } = unchainedAPI;
8
- const { media, specification, products, children, filters, _id } = payload;
9
- if (!specification)
10
- throw new Error(`Specification is required when creating new assortment ${_id}`);
11
- if (!specification.content)
12
- throw new Error(`Assortment content is required when creating new assortment${_id}`);
13
- specification.tags = convertTagsToLowerCase(specification?.tags);
14
- logger.debug('create assortment object', specification);
15
- try {
16
- await modules.assortments.create({ ...specification, _id });
17
- }
18
- catch (e) {
19
- if (!createShouldUpsertIfIDExists)
20
- throw e;
21
- logger.debug('entity already exists, falling back to update', specification);
22
- await modules.assortments.update(_id, {
23
- ...specification,
24
- });
25
- }
26
- if (!(await modules.assortments.assortmentExists({ assortmentId: _id }))) {
27
- throw new Error(`Can't create assortment ${_id}, fields missing?`);
28
- }
29
- logger.debug('create localized content for assortment', specification.content);
30
- await modules.assortments.texts.updateTexts(_id, Object.entries(specification.content).map(([locale, localizedData]) => {
31
- return {
32
- locale,
33
- ...localizedData,
34
- };
35
- }));
36
- logger.debug('create assortment products', products);
37
- await upsertAssortmentProducts({
38
- products: products || [],
39
- assortmentId: _id,
40
- }, unchainedAPI);
41
- logger.debug('create assortment children', children);
42
- await upsertAssortmentChildren({
43
- children: children || [],
44
- assortmentId: _id,
45
- }, unchainedAPI);
46
- logger.debug('create assortment filters', filters);
47
- await upsertAssortmentFilters({
48
- filters: filters || [],
49
- assortmentId: _id,
50
- }, unchainedAPI);
51
- logger.debug('create assortment media', media);
52
- await upsertMedia({ media: media || [], assortmentId: _id }, unchainedAPI);
53
- return {
54
- entity: 'ASSORTMENT',
55
- operation: 'create',
56
- _id,
57
- success: true,
58
- };
59
- }
60
- //# sourceMappingURL=create.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/create.ts"],"names":[],"mappings":"AACA,OAAO,sBAAsB,MAAM,oCAAoC,CAAC;AACxE,OAAO,wBAAwB,MAAM,+BAA+B,CAAC;AACrE,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AACnE,OAAO,wBAAwB,MAAM,+BAA+B,CAAC;AACrE,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAE3C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,gBAAgB,CAC5C,OAAY,EACZ,EAAE,MAAM,EAAE,4BAA4B,EAAE,EACxC,YAA2B;IAE3B,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;IACjC,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IAC3E,IAAI,CAAC,aAAa;QAAE,MAAM,IAAI,KAAK,CAAC,0DAA0D,GAAG,EAAE,CAAC,CAAC;IAErG,IAAI,CAAC,aAAa,CAAC,OAAO;QACxB,MAAM,IAAI,KAAK,CAAC,8DAA8D,GAAG,EAAE,CAAC,CA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ACb,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,QAAQ,CAAC,CAAC;IACrD,MAAM,wBAAwB,CAC5B;QACE,QAAQ,EAAE,QAAQ,IAAI,EAAE;QACxB,YAAY,EAAE,GAAG;KAClB,EACD,YAAY,CACb,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,OAAO,CAAC,CAAC;IACnD,MAAM,uBAAuB,CAC3B;QACE,OAAO,EAAE,OAAO,IAAI,EAAE;QACtB,YAAY,EAAE,GAAG;KAClB,EACD,YAAY,CACb,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;IAC/C,MAAM,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,YAAY,CAAC,CAAC;IAE3E,OAAO;QACL,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,QAAQ;QACnB,GAAG;QACH,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
@@ -1,4 +0,0 @@
1
- export { default as create } from './create.js';
2
- export { default as update } from './update.js';
3
- export { default as remove } from './remove.js';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}
@@ -1,4 +0,0 @@
1
- export { default as create } from './create.js';
2
- export { default as update } from './update.js';
3
- export { default as remove } from './remove.js';
4
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}
@@ -1,10 +0,0 @@
1
- import { UnchainedCore } from '@unchainedshop/types/core.js';
2
- export default function removeAssortment(payload: any, { logger }: {
3
- logger: any;
4
- }, unchainedAPI: UnchainedCore): Promise<{
5
- entity: string;
6
- operation: string;
7
- _id: any;
8
- success: boolean;
9
- }>;
10
- //# sourceMappingURL=remove.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/remove.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,wBAA8B,gBAAgB,CAAC,OAAO,KAAA,EAAE,EAAE,MAAM,EAAE;;CAAA,EAAE,YAAY,EAAE,aAAa;;;;;GAY9F"}
@@ -1,13 +0,0 @@
1
- export default async function removeAssortment(payload, { logger }, unchainedAPI) {
2
- const { modules } = unchainedAPI;
3
- const { _id } = payload;
4
- logger.debug('remove assortment');
5
- await modules.assortments.delete(_id, { skipInvalidation: true });
6
- return {
7
- entity: 'ASSORTMENT',
8
- operation: 'remove',
9
- _id,
10
- success: true,
11
- };
12
- }
13
- //# sourceMappingURL=remove.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remove.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/remove.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,YAA2B;IAC7F,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC;IACjC,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACxB,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IAClC,MAAM,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;IAElE,OAAO;QACL,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,QAAQ;QACnB,GAAG;QACH,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
@@ -1,12 +0,0 @@
1
- import { UnchainedCore } from '@unchainedshop/types/core.js';
2
- export default function updateAssortment(payload: any, { logger, createShouldUpsertIfIDExists, updateShouldUpsertIfIDNotExists }: {
3
- logger: any;
4
- createShouldUpsertIfIDExists: any;
5
- updateShouldUpsertIfIDNotExists: any;
6
- }, unchainedAPI: UnchainedCore): Promise<{
7
- entity: string;
8
- operation: string;
9
- _id: any;
10
- success: boolean;
11
- }>;
12
- //# sourceMappingURL=update.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAQ7D,wBAA8B,gBAAgB,CAC5C,OAAO,EAAE,GAAG,EACZ,EAAE,MAAM,EAAE,4BAA4B,EAAE,+BAA+B,EAAE;;;;CAAA,EACzE,YAAY,EAAE,aAAa;;;;;GA2E5B"}
@@ -1,62 +0,0 @@
1
- import upsertAssortmentProducts from './upsertAssortmentProducts.js';
2
- import upsertAssortmentChildren from './upsertAssortmentChildren.js';
3
- import upsertAssortmentFilters from './upsertAssortmentFilters.js';
4
- import upsertMedia from './upsertMedia.js';
5
- import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
6
- import createAssortment from './create.js';
7
- export default async function updateAssortment(payload, { logger, createShouldUpsertIfIDExists, updateShouldUpsertIfIDNotExists }, unchainedAPI) {
8
- const { modules } = unchainedAPI;
9
- const { media, specification, products, children, filters, _id } = payload;
10
- if (!(await modules.assortments.assortmentExists({ assortmentId: _id }))) {
11
- if (updateShouldUpsertIfIDNotExists) {
12
- return createAssortment(payload, { logger, createShouldUpsertIfIDExists }, unchainedAPI);
13
- }
14
- throw new Error(`Can't update non-existing assortment ${_id}`);
15
- }
16
- if (specification) {
17
- logger.debug('update assortment object', specification);
18
- specification.tags = convertTagsToLowerCase(specification?.tags);
19
- await unchainedAPI.modules.assortments.update(_id, { ...specification });
20
- if (specification.content) {
21
- logger.debug('replace localized content for assortment', specification.content);
22
- await modules.assortments.texts.updateTexts(_id, Object.entries(specification.content).map(([locale, localizedData]) => {
23
- return {
24
- locale,
25
- ...localizedData,
26
- };
27
- }));
28
- }
29
- }
30
- if (products) {
31
- logger.debug('update product products', products);
32
- await upsertAssortmentProducts({
33
- products: products || [],
34
- assortmentId: _id,
35
- }, unchainedAPI);
36
- }
37
- if (children) {
38
- logger.debug('update assortment children', children);
39
- await upsertAssortmentChildren({
40
- children: children || [],
41
- assortmentId: _id,
42
- }, unchainedAPI);
43
- }
44
- if (filters) {
45
- logger.debug('update assortment filters', filters);
46
- await upsertAssortmentFilters({
47
- filters: filters || [],
48
- assortmentId: _id,
49
- }, unchainedAPI);
50
- }
51
- if (media) {
52
- logger.debug('update assortment media', media);
53
- await upsertMedia({ media: media || [], assortmentId: _id }, unchainedAPI);
54
- }
55
- return {
56
- entity: 'ASSORTMENT',
57
- operation: 'update',
58
- _id,
59
- success: true,
60
- };
61
- }
62
- //# sourceMappingURL=update.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/update.ts"],"names":[],"mappings":"AACA,OAAO,wBAAwB,MAAM,+BAA+B,CAAC;AACrE,OAAO,wBAAwB,MAAM,+BAA+B,CAAC;AACrE,OAAO,uBAAuB,MAAM,8BAA8B,CAAC;AACnE,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,sBAAsB,MAAM,oCAAoC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Aa,CAAgB,EAAE,EAAE;gBACnF,OAAO;oBACL,MAAM;oBACN,GAAG,aAAa;iBACjB,CAAC;YACJ,CAAC,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;QAClD,MAAM,wBAAwB,CAC5B;YACE,QAAQ,EAAE,QAAQ,IAAI,EAAE;YACxB,YAAY,EAAE,GAAG;SAClB,EACD,YAAY,CACb,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,QAAQ,CAAC,CAAC;QACrD,MAAM,wBAAwB,CAC5B;YACE,QAAQ,EAAE,QAAQ,IAAI,EAAE;YACxB,YAAY,EAAE,GAAG;SAClB,EACD,YAAY,CACb,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,OAAO,CAAC,CAAC;QACnD,MAAM,uBAAuB,CAC3B;YACE,OAAO,EAAE,OAAO,IAAI,EAAE;YACtB,YAAY,EAAE,GAAG;SAClB,EACD,YAAY,CACb,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;QAC/C,MAAM,WAAW,CAAC,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,EAAE,YAAY,EAAE,GAAG,EAAE,EAAE,YAAY,CAAC,CAAC;IAC7E,CAAC;IAED,OAAO;QACL,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,QAAQ;QACnB,GAAG;QACH,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC"}
@@ -1,7 +0,0 @@
1
- import { UnchainedCore } from '@unchainedshop/types/core.js';
2
- declare const _default: ({ children, assortmentId: parentAssortmentId }: {
3
- children: any;
4
- assortmentId: any;
5
- }, unchainedAPI: UnchainedCore) => Promise<void>;
6
- export default _default;
7
- //# sourceMappingURL=upsertAssortmentChildren.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upsertAssortmentChildren.d.ts","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;;;;iBAuBuB,aAAa;AAAjG,wBAwBE"}
@@ -1,37 +0,0 @@
1
- import convertTagsToLowerCase from '../utils/convertTagsToLowerCase.js';
2
- const upsert = async (assortmentLink, { modules }) => {
3
- if (!(await modules.assortments.assortmentExists({
4
- assortmentId: assortmentLink.childAssortmentId,
5
- }))) {
6
- throw new Error(`Can't link non-existing assortment ${assortmentLink.childAssortmentId}`);
7
- }
8
- try {
9
- const newAssortmentLink = await modules.assortments.links.create(assortmentLink, {
10
- skipInvalidation: true,
11
- });
12
- return newAssortmentLink;
13
- }
14
- catch {
15
- return modules.assortments.links.update(assortmentLink._id, assortmentLink, {
16
- skipInvalidation: true,
17
- });
18
- }
19
- };
20
- export default async ({ children, assortmentId: parentAssortmentId }, unchainedAPI) => {
21
- const { modules } = unchainedAPI;
22
- const assortmentLinkIds = await Promise.all(children.map(async ({ assortmentId: childAssortmentId, ...childrenRest }) => {
23
- const tags = convertTagsToLowerCase(childrenRest?.tags);
24
- const assortmentLink = await upsert({
25
- ...childrenRest,
26
- tags,
27
- parentAssortmentId,
28
- childAssortmentId,
29
- }, unchainedAPI);
30
- return assortmentLink._id;
31
- }));
32
- await modules.assortments.links.deleteMany({
33
- _id: { $nin: assortmentLinkIds },
34
- parentAssortmentId,
35
- }, { skipInvalidation: true });
36
- };
37
- //# sourceMappingURL=upsertAssortmentChildren.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upsertAssortmentChildren.js","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertAssortmentChildren.ts"],"names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;QACF,OAAO,cAAc,CAAC,GAAG,CAAC;IAC5B,CAAC,CAAC,CACH,CAAC;IACF,MAAM,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,UAAU,CACxC;QACE,GAAG,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;QAChC,kBAAkB;KACnB,EACD,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAC3B,CAAC;AACJ,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- import { UnchainedCore } from '@unchainedshop/types/core.js';
2
- declare const _default: ({ filters, assortmentId }: {
3
- filters: any;
4
- assortmentId: any;
5
- }, unchainedAPI: UnchainedCore) => Promise<void>;
6
- export default _default;
7
- //# sourceMappingURL=upsertAssortmentFilters.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upsertAssortmentFilters.d.ts","sourceRoot":"","sources":["../../../../src/bulk-importer/handlers/assortment/upsertAssortmentFilters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;;;;iBAmBE,aAAa;AAA5E,wBAqBE"}