@things-factory/product-base 4.0.21 → 4.0.22

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 (245) hide show
  1. package/dist-server/entities/index.js +30 -0
  2. package/dist-server/entities/index.js.map +1 -0
  3. package/dist-server/entities/product-bundle-setting.js +47 -0
  4. package/dist-server/entities/product-bundle-setting.js.map +1 -0
  5. package/dist-server/entities/product-bundle.js +98 -0
  6. package/dist-server/entities/product-bundle.js.map +1 -0
  7. package/dist-server/entities/product-combination-setting.js +48 -0
  8. package/dist-server/entities/product-combination-setting.js.map +1 -0
  9. package/dist-server/entities/product-combination.js +91 -0
  10. package/dist-server/entities/product-combination.js.map +1 -0
  11. package/dist-server/entities/product-detail-bizplace-setting.js +91 -0
  12. package/dist-server/entities/product-detail-bizplace-setting.js.map +1 -0
  13. package/dist-server/entities/product-detail.js +338 -0
  14. package/dist-server/entities/product-detail.js.map +1 -0
  15. package/dist-server/entities/product-set.js +90 -0
  16. package/dist-server/entities/product-set.js.map +1 -0
  17. package/dist-server/entities/product.js +293 -0
  18. package/dist-server/entities/product.js.map +1 -0
  19. package/dist-server/graphql/index.js +30 -0
  20. package/dist-server/graphql/index.js.map +1 -0
  21. package/dist-server/graphql/resolvers/index.js +21 -0
  22. package/dist-server/graphql/resolvers/index.js.map +1 -0
  23. package/dist-server/graphql/resolvers/product/create-product.js +60 -0
  24. package/dist-server/graphql/resolvers/product/create-product.js.map +1 -0
  25. package/dist-server/graphql/resolvers/product/create-products.js +24 -0
  26. package/dist-server/graphql/resolvers/product/create-products.js.map +1 -0
  27. package/dist-server/graphql/resolvers/product/delete-product.js +14 -0
  28. package/dist-server/graphql/resolvers/product/delete-product.js.map +1 -0
  29. package/dist-server/graphql/resolvers/product/delete-products.js +17 -0
  30. package/dist-server/graphql/resolvers/product/delete-products.js.map +1 -0
  31. package/dist-server/graphql/resolvers/product/import-multiple-product.js +35 -0
  32. package/dist-server/graphql/resolvers/product/import-multiple-product.js.map +1 -0
  33. package/dist-server/graphql/resolvers/product/index.js +20 -0
  34. package/dist-server/graphql/resolvers/product/index.js.map +1 -0
  35. package/dist-server/graphql/resolvers/product/link-product.js +41 -0
  36. package/dist-server/graphql/resolvers/product/link-product.js.map +1 -0
  37. package/dist-server/graphql/resolvers/product/my-bizplace-products.js +47 -0
  38. package/dist-server/graphql/resolvers/product/my-bizplace-products.js.map +1 -0
  39. package/dist-server/graphql/resolvers/product/product-query.js +94 -0
  40. package/dist-server/graphql/resolvers/product/product-query.js.map +1 -0
  41. package/dist-server/graphql/resolvers/product/product.js +33 -0
  42. package/dist-server/graphql/resolvers/product/product.js.map +1 -0
  43. package/dist-server/graphql/resolvers/product/products-by-bizplace.js +60 -0
  44. package/dist-server/graphql/resolvers/product/products-by-bizplace.js.map +1 -0
  45. package/dist-server/graphql/resolvers/product/products.js +68 -0
  46. package/dist-server/graphql/resolvers/product/products.js.map +1 -0
  47. package/dist-server/graphql/resolvers/product/undelete-products.js +17 -0
  48. package/dist-server/graphql/resolvers/product/undelete-products.js.map +1 -0
  49. package/dist-server/graphql/resolvers/product/update-multiple-product.js +33 -0
  50. package/dist-server/graphql/resolvers/product/update-multiple-product.js.map +1 -0
  51. package/dist-server/graphql/resolvers/product/update-product.js +58 -0
  52. package/dist-server/graphql/resolvers/product/update-product.js.map +1 -0
  53. package/dist-server/graphql/resolvers/product/validate-product.js +38 -0
  54. package/dist-server/graphql/resolvers/product/validate-product.js.map +1 -0
  55. package/dist-server/graphql/resolvers/product-bundle/create-product-bundle.js +12 -0
  56. package/dist-server/graphql/resolvers/product-bundle/create-product-bundle.js.map +1 -0
  57. package/dist-server/graphql/resolvers/product-bundle/delete-product-bundle.js +13 -0
  58. package/dist-server/graphql/resolvers/product-bundle/delete-product-bundle.js.map +1 -0
  59. package/dist-server/graphql/resolvers/product-bundle/delete-product-bundles.js +19 -0
  60. package/dist-server/graphql/resolvers/product-bundle/delete-product-bundles.js.map +1 -0
  61. package/dist-server/graphql/resolvers/product-bundle/index.js +15 -0
  62. package/dist-server/graphql/resolvers/product-bundle/index.js.map +1 -0
  63. package/dist-server/graphql/resolvers/product-bundle/my-bizplace-product-bundles.js +43 -0
  64. package/dist-server/graphql/resolvers/product-bundle/my-bizplace-product-bundles.js.map +1 -0
  65. package/dist-server/graphql/resolvers/product-bundle/product-bundle-query.js +21 -0
  66. package/dist-server/graphql/resolvers/product-bundle/product-bundle-query.js.map +1 -0
  67. package/dist-server/graphql/resolvers/product-bundle/update-multiple-product-bundle.js +50 -0
  68. package/dist-server/graphql/resolvers/product-bundle/update-multiple-product-bundle.js.map +1 -0
  69. package/dist-server/graphql/resolvers/product-bundle/update-product-bundle.js +16 -0
  70. package/dist-server/graphql/resolvers/product-bundle/update-product-bundle.js.map +1 -0
  71. package/dist-server/graphql/resolvers/product-bundle-setting/create-product-bundle-setting.js +12 -0
  72. package/dist-server/graphql/resolvers/product-bundle-setting/create-product-bundle-setting.js.map +1 -0
  73. package/dist-server/graphql/resolvers/product-bundle-setting/delete-product-bundle-setting.js +12 -0
  74. package/dist-server/graphql/resolvers/product-bundle-setting/delete-product-bundle-setting.js.map +1 -0
  75. package/dist-server/graphql/resolvers/product-bundle-setting/delete-product-bundle-settings.js +14 -0
  76. package/dist-server/graphql/resolvers/product-bundle-setting/delete-product-bundle-settings.js.map +1 -0
  77. package/dist-server/graphql/resolvers/product-bundle-setting/index.js +15 -0
  78. package/dist-server/graphql/resolvers/product-bundle-setting/index.js.map +1 -0
  79. package/dist-server/graphql/resolvers/product-bundle-setting/link-product-bundle.js +77 -0
  80. package/dist-server/graphql/resolvers/product-bundle-setting/link-product-bundle.js.map +1 -0
  81. package/dist-server/graphql/resolvers/product-bundle-setting/product-bundle-sets.js +75 -0
  82. package/dist-server/graphql/resolvers/product-bundle-setting/product-bundle-sets.js.map +1 -0
  83. package/dist-server/graphql/resolvers/product-bundle-setting/product-bundle-setting-query.js +14 -0
  84. package/dist-server/graphql/resolvers/product-bundle-setting/product-bundle-setting-query.js.map +1 -0
  85. package/dist-server/graphql/resolvers/product-bundle-setting/update-multiple-product-bundle-setting.js +33 -0
  86. package/dist-server/graphql/resolvers/product-bundle-setting/update-multiple-product-bundle-setting.js.map +1 -0
  87. package/dist-server/graphql/resolvers/product-combination/create-product-combination.js +12 -0
  88. package/dist-server/graphql/resolvers/product-combination/create-product-combination.js.map +1 -0
  89. package/dist-server/graphql/resolvers/product-combination/delete-product-combination.js +13 -0
  90. package/dist-server/graphql/resolvers/product-combination/delete-product-combination.js.map +1 -0
  91. package/dist-server/graphql/resolvers/product-combination/delete-product-combinations.js +19 -0
  92. package/dist-server/graphql/resolvers/product-combination/delete-product-combinations.js.map +1 -0
  93. package/dist-server/graphql/resolvers/product-combination/index.js +14 -0
  94. package/dist-server/graphql/resolvers/product-combination/index.js.map +1 -0
  95. package/dist-server/graphql/resolvers/product-combination/product-combination-query.js +21 -0
  96. package/dist-server/graphql/resolvers/product-combination/product-combination-query.js.map +1 -0
  97. package/dist-server/graphql/resolvers/product-combination/update-multiple-product-combination.js +44 -0
  98. package/dist-server/graphql/resolvers/product-combination/update-multiple-product-combination.js.map +1 -0
  99. package/dist-server/graphql/resolvers/product-combination/update-product-combination.js +16 -0
  100. package/dist-server/graphql/resolvers/product-combination/update-product-combination.js.map +1 -0
  101. package/dist-server/graphql/resolvers/product-combination-setting/create-product-combination-setting.js +12 -0
  102. package/dist-server/graphql/resolvers/product-combination-setting/create-product-combination-setting.js.map +1 -0
  103. package/dist-server/graphql/resolvers/product-combination-setting/delete-product-combination-setting.js +12 -0
  104. package/dist-server/graphql/resolvers/product-combination-setting/delete-product-combination-setting.js.map +1 -0
  105. package/dist-server/graphql/resolvers/product-combination-setting/delete-product-combination-settings.js +14 -0
  106. package/dist-server/graphql/resolvers/product-combination-setting/delete-product-combination-settings.js.map +1 -0
  107. package/dist-server/graphql/resolvers/product-combination-setting/index.js +15 -0
  108. package/dist-server/graphql/resolvers/product-combination-setting/index.js.map +1 -0
  109. package/dist-server/graphql/resolvers/product-combination-setting/link-product-combination.js +73 -0
  110. package/dist-server/graphql/resolvers/product-combination-setting/link-product-combination.js.map +1 -0
  111. package/dist-server/graphql/resolvers/product-combination-setting/product-combination-sets.js +87 -0
  112. package/dist-server/graphql/resolvers/product-combination-setting/product-combination-sets.js.map +1 -0
  113. package/dist-server/graphql/resolvers/product-combination-setting/product-combination-setting-query.js +16 -0
  114. package/dist-server/graphql/resolvers/product-combination-setting/product-combination-setting-query.js.map +1 -0
  115. package/dist-server/graphql/resolvers/product-combination-setting/update-multiple-product-combination-setting.js +33 -0
  116. package/dist-server/graphql/resolvers/product-combination-setting/update-multiple-product-combination-setting.js.map +1 -0
  117. package/dist-server/graphql/resolvers/product-detail/create-product-detail.js +17 -0
  118. package/dist-server/graphql/resolvers/product-detail/create-product-detail.js.map +1 -0
  119. package/dist-server/graphql/resolvers/product-detail/delete-product-detail.js +13 -0
  120. package/dist-server/graphql/resolvers/product-detail/delete-product-detail.js.map +1 -0
  121. package/dist-server/graphql/resolvers/product-detail/delete-product-details.js +16 -0
  122. package/dist-server/graphql/resolvers/product-detail/delete-product-details.js.map +1 -0
  123. package/dist-server/graphql/resolvers/product-detail/index.js +15 -0
  124. package/dist-server/graphql/resolvers/product-detail/index.js.map +1 -0
  125. package/dist-server/graphql/resolvers/product-detail/product-detail-query.js +114 -0
  126. package/dist-server/graphql/resolvers/product-detail/product-detail-query.js.map +1 -0
  127. package/dist-server/graphql/resolvers/product-detail/update-multiple-product-detail.js +112 -0
  128. package/dist-server/graphql/resolvers/product-detail/update-multiple-product-detail.js.map +1 -0
  129. package/dist-server/graphql/resolvers/product-detail/update-product-detail.js +20 -0
  130. package/dist-server/graphql/resolvers/product-detail/update-product-detail.js.map +1 -0
  131. package/dist-server/graphql/resolvers/product-detail-bizplace-setting/create-product-detail-bizplace-setting.js +12 -0
  132. package/dist-server/graphql/resolvers/product-detail-bizplace-setting/create-product-detail-bizplace-setting.js.map +1 -0
  133. package/dist-server/graphql/resolvers/product-detail-bizplace-setting/delete-product-detail-bizplace-setting.js +13 -0
  134. package/dist-server/graphql/resolvers/product-detail-bizplace-setting/delete-product-detail-bizplace-setting.js.map +1 -0
  135. package/dist-server/graphql/resolvers/product-detail-bizplace-setting/delete-product-detail-bizplace-settings.js +16 -0
  136. package/dist-server/graphql/resolvers/product-detail-bizplace-setting/delete-product-detail-bizplace-settings.js.map +1 -0
  137. package/dist-server/graphql/resolvers/product-detail-bizplace-setting/index.js +15 -0
  138. package/dist-server/graphql/resolvers/product-detail-bizplace-setting/index.js.map +1 -0
  139. package/dist-server/graphql/resolvers/product-detail-bizplace-setting/product-detail-bizplace-setting-query.js +56 -0
  140. package/dist-server/graphql/resolvers/product-detail-bizplace-setting/product-detail-bizplace-setting-query.js.map +1 -0
  141. package/dist-server/graphql/resolvers/product-detail-bizplace-setting/update-multiple-product-detail-bizplace-setting.js +35 -0
  142. package/dist-server/graphql/resolvers/product-detail-bizplace-setting/update-multiple-product-detail-bizplace-setting.js.map +1 -0
  143. package/dist-server/graphql/resolvers/product-detail-bizplace-setting/update-product-detail-bizplace-setting.js +16 -0
  144. package/dist-server/graphql/resolvers/product-detail-bizplace-setting/update-product-detail-bizplace-setting.js.map +1 -0
  145. package/dist-server/graphql/resolvers/product-set/create-product-set.js +27 -0
  146. package/dist-server/graphql/resolvers/product-set/create-product-set.js.map +1 -0
  147. package/dist-server/graphql/resolvers/product-set/delete-product-set.js +14 -0
  148. package/dist-server/graphql/resolvers/product-set/delete-product-set.js.map +1 -0
  149. package/dist-server/graphql/resolvers/product-set/delete-product-sets.js +20 -0
  150. package/dist-server/graphql/resolvers/product-set/delete-product-sets.js.map +1 -0
  151. package/dist-server/graphql/resolvers/product-set/index.js +15 -0
  152. package/dist-server/graphql/resolvers/product-set/index.js.map +1 -0
  153. package/dist-server/graphql/resolvers/product-set/my-bizplace-product-sets.js +39 -0
  154. package/dist-server/graphql/resolvers/product-set/my-bizplace-product-sets.js.map +1 -0
  155. package/dist-server/graphql/resolvers/product-set/product-set-query.js +30 -0
  156. package/dist-server/graphql/resolvers/product-set/product-set-query.js.map +1 -0
  157. package/dist-server/graphql/resolvers/product-set/product-set.js +16 -0
  158. package/dist-server/graphql/resolvers/product-set/product-set.js.map +1 -0
  159. package/dist-server/graphql/resolvers/product-set/product-sets.js +22 -0
  160. package/dist-server/graphql/resolvers/product-set/product-sets.js.map +1 -0
  161. package/dist-server/graphql/resolvers/product-set/update-multiple-product-set.js +28 -0
  162. package/dist-server/graphql/resolvers/product-set/update-multiple-product-set.js.map +1 -0
  163. package/dist-server/graphql/resolvers/product-set/update-product-set.js +23 -0
  164. package/dist-server/graphql/resolvers/product-set/update-product-set.js.map +1 -0
  165. package/dist-server/graphql/types/index.js +21 -0
  166. package/dist-server/graphql/types/index.js.map +1 -0
  167. package/dist-server/graphql/types/product/index.js +61 -0
  168. package/dist-server/graphql/types/product/index.js.map +1 -0
  169. package/dist-server/graphql/types/product/new-product.js +66 -0
  170. package/dist-server/graphql/types/product/new-product.js.map +1 -0
  171. package/dist-server/graphql/types/product/product-list.js +14 -0
  172. package/dist-server/graphql/types/product/product-list.js.map +1 -0
  173. package/dist-server/graphql/types/product/product-patch.js +70 -0
  174. package/dist-server/graphql/types/product/product-patch.js.map +1 -0
  175. package/dist-server/graphql/types/product/product.js +73 -0
  176. package/dist-server/graphql/types/product/product.js.map +1 -0
  177. package/dist-server/graphql/types/product-bundle/index.js +37 -0
  178. package/dist-server/graphql/types/product-bundle/index.js.map +1 -0
  179. package/dist-server/graphql/types/product-bundle/new-product-bundle.js +14 -0
  180. package/dist-server/graphql/types/product-bundle/new-product-bundle.js.map +1 -0
  181. package/dist-server/graphql/types/product-bundle/product-bundle-list.js +14 -0
  182. package/dist-server/graphql/types/product-bundle/product-bundle-list.js.map +1 -0
  183. package/dist-server/graphql/types/product-bundle/product-bundle-patch.js +21 -0
  184. package/dist-server/graphql/types/product-bundle/product-bundle-patch.js.map +1 -0
  185. package/dist-server/graphql/types/product-bundle/product-bundle.js +26 -0
  186. package/dist-server/graphql/types/product-bundle/product-bundle.js.map +1 -0
  187. package/dist-server/graphql/types/product-bundle-setting/index.js +38 -0
  188. package/dist-server/graphql/types/product-bundle-setting/index.js.map +1 -0
  189. package/dist-server/graphql/types/product-bundle-setting/new-product-bundle-setting.js +14 -0
  190. package/dist-server/graphql/types/product-bundle-setting/new-product-bundle-setting.js.map +1 -0
  191. package/dist-server/graphql/types/product-bundle-setting/product-bundle-setting-list.js +14 -0
  192. package/dist-server/graphql/types/product-bundle-setting/product-bundle-setting-list.js.map +1 -0
  193. package/dist-server/graphql/types/product-bundle-setting/product-bundle-setting-patch.js +21 -0
  194. package/dist-server/graphql/types/product-bundle-setting/product-bundle-setting-patch.js.map +1 -0
  195. package/dist-server/graphql/types/product-bundle-setting/product-bundle-setting.js +36 -0
  196. package/dist-server/graphql/types/product-bundle-setting/product-bundle-setting.js.map +1 -0
  197. package/dist-server/graphql/types/product-combination/index.js +39 -0
  198. package/dist-server/graphql/types/product-combination/index.js.map +1 -0
  199. package/dist-server/graphql/types/product-combination/new-product-combination.js +15 -0
  200. package/dist-server/graphql/types/product-combination/new-product-combination.js.map +1 -0
  201. package/dist-server/graphql/types/product-combination/product-combination-list.js +14 -0
  202. package/dist-server/graphql/types/product-combination/product-combination-list.js.map +1 -0
  203. package/dist-server/graphql/types/product-combination/product-combination-patch.js +19 -0
  204. package/dist-server/graphql/types/product-combination/product-combination-patch.js.map +1 -0
  205. package/dist-server/graphql/types/product-combination/product-combination.js +26 -0
  206. package/dist-server/graphql/types/product-combination/product-combination.js.map +1 -0
  207. package/dist-server/graphql/types/product-combination-setting/index.js +44 -0
  208. package/dist-server/graphql/types/product-combination-setting/index.js.map +1 -0
  209. package/dist-server/graphql/types/product-combination-setting/new-product-combination-setting.js +14 -0
  210. package/dist-server/graphql/types/product-combination-setting/new-product-combination-setting.js.map +1 -0
  211. package/dist-server/graphql/types/product-combination-setting/product-combination-setting-list.js +14 -0
  212. package/dist-server/graphql/types/product-combination-setting/product-combination-setting-list.js.map +1 -0
  213. package/dist-server/graphql/types/product-combination-setting/product-combination-setting-patch.js +18 -0
  214. package/dist-server/graphql/types/product-combination-setting/product-combination-setting-patch.js.map +1 -0
  215. package/dist-server/graphql/types/product-combination-setting/product-combination-setting.js +33 -0
  216. package/dist-server/graphql/types/product-combination-setting/product-combination-setting.js.map +1 -0
  217. package/dist-server/graphql/types/product-detail/index.js +36 -0
  218. package/dist-server/graphql/types/product-detail/index.js.map +1 -0
  219. package/dist-server/graphql/types/product-detail/new-product-detail.js +55 -0
  220. package/dist-server/graphql/types/product-detail/new-product-detail.js.map +1 -0
  221. package/dist-server/graphql/types/product-detail/product-detail-list.js +14 -0
  222. package/dist-server/graphql/types/product-detail/product-detail-list.js.map +1 -0
  223. package/dist-server/graphql/types/product-detail/product-detail-patch.js +57 -0
  224. package/dist-server/graphql/types/product-detail/product-detail-patch.js.map +1 -0
  225. package/dist-server/graphql/types/product-detail-bizplace-setting/index.js +36 -0
  226. package/dist-server/graphql/types/product-detail-bizplace-setting/index.js.map +1 -0
  227. package/dist-server/graphql/types/product-detail-bizplace-setting/new-product-detail-bizplace-setting.js +18 -0
  228. package/dist-server/graphql/types/product-detail-bizplace-setting/new-product-detail-bizplace-setting.js.map +1 -0
  229. package/dist-server/graphql/types/product-detail-bizplace-setting/product-detail-bizplace-setting-list.js +14 -0
  230. package/dist-server/graphql/types/product-detail-bizplace-setting/product-detail-bizplace-setting-list.js.map +1 -0
  231. package/dist-server/graphql/types/product-detail-bizplace-setting/product-detail-bizplace-setting-patch.js +20 -0
  232. package/dist-server/graphql/types/product-detail-bizplace-setting/product-detail-bizplace-setting-patch.js.map +1 -0
  233. package/dist-server/graphql/types/product-detail-bizplace-setting/product-detail-bizplace-setting.js +30 -0
  234. package/dist-server/graphql/types/product-detail-bizplace-setting/product-detail-bizplace-setting.js.map +1 -0
  235. package/dist-server/graphql/types/product-set/index.js +52 -0
  236. package/dist-server/graphql/types/product-set/index.js.map +1 -0
  237. package/dist-server/graphql/types/product-set/new-product-set.js +16 -0
  238. package/dist-server/graphql/types/product-set/new-product-set.js.map +1 -0
  239. package/dist-server/graphql/types/product-set/product-set-list.js +14 -0
  240. package/dist-server/graphql/types/product-set/product-set-list.js.map +1 -0
  241. package/dist-server/graphql/types/product-set/product-set-patch.js +17 -0
  242. package/dist-server/graphql/types/product-set/product-set-patch.js.map +1 -0
  243. package/dist-server/graphql/types/product-set/product-set.js +24 -0
  244. package/dist-server/graphql/types/product-set/product-set.js.map +1 -0
  245. package/package.json +4 -3
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateMultipleProductCombination = void 0;
4
+ const constants_1 = require("../../../constants");
5
+ const entities_1 = require("../../../entities");
6
+ exports.updateMultipleProductCombination = {
7
+ async updateMultipleProductCombination(_, { productDetailId, patches }, context) {
8
+ const { domain, user, tx } = context.state;
9
+ let results = [];
10
+ const _createRecords = patches.filter((patch) => !patch.id);
11
+ const _updateRecords = patches.filter((patch) => patch.id);
12
+ const productDetailRepo = tx.getRepository(entities_1.ProductDetail);
13
+ const productCombinationRepo = tx.getRepository(entities_1.ProductCombination);
14
+ if (_createRecords.length > 0) {
15
+ for (let i = 0; i < _createRecords.length; i++) {
16
+ let newRecord = _createRecords[i];
17
+ const productDetail = await productDetailRepo.findOne({
18
+ where: { id: productDetailId },
19
+ relations: ['product']
20
+ });
21
+ delete newRecord.id;
22
+ if (!newRecord.status || newRecord.status === '') {
23
+ newRecord.status = constants_1.PRODUCT_COMBINATION_STATUS.INACTIVE;
24
+ }
25
+ const result = await productCombinationRepo.save(Object.assign(Object.assign({}, newRecord), { domain,
26
+ productDetail, product: productDetail.product, status: newRecord.status.toUpperCase(), creator: user, updater: user }));
27
+ results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
28
+ }
29
+ }
30
+ if (_updateRecords.length > 0) {
31
+ for (let i = 0; i < _updateRecords.length; i++) {
32
+ const newRecord = _updateRecords[i];
33
+ const productCombination = await productCombinationRepo.findOne({ domain, id: newRecord.id });
34
+ if (newRecord.status) {
35
+ newRecord.status = newRecord.status.toUpperCase();
36
+ }
37
+ const result = await productCombinationRepo.save(Object.assign(Object.assign(Object.assign({}, productCombination), newRecord), { updater: user }));
38
+ results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
39
+ }
40
+ }
41
+ return results;
42
+ }
43
+ };
44
+ //# sourceMappingURL=update-multiple-product-combination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-multiple-product-combination.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/product-combination/update-multiple-product-combination.ts"],"names":[],"mappings":";;;AAAA,kDAA+D;AAC/D,gDAAqE;AAExD,QAAA,gCAAgC,GAAG;IAC9C,KAAK,CAAC,gCAAgC,CAAC,CAAM,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,EAAE,OAAY;QACvF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,IAAI,OAAO,GAAG,EAAE,CAAA;QAChB,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAChE,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;QAC/D,MAAM,iBAAiB,GAAG,EAAE,CAAC,aAAa,CAAC,wBAAa,CAAC,CAAA;QACzD,MAAM,sBAAsB,GAAG,EAAE,CAAC,aAAa,CAAC,6BAAkB,CAAC,CAAA;QAEnE,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;YAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC9C,IAAI,SAAS,GAAG,cAAc,CAAC,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E,IAAI,IACb,CAAA;gBAEF,OAAO,CAAC,IAAI,iCAAM,MAAM,KAAE,MAAM,EAAE,GAAG,IAAG,CAAA;aACzC;SACF;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CACF,CAAA"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateProductCombination = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const entities_1 = require("../../../entities");
6
+ exports.updateProductCombination = {
7
+ async updateProductCombination(_, { id, patch }, context) {
8
+ const { domain, user } = context.state;
9
+ const repository = (0, typeorm_1.getRepository)(entities_1.ProductCombination);
10
+ const productCombination = await repository.findOne({
11
+ where: { domain, id }
12
+ });
13
+ return await repository.save(Object.assign(Object.assign(Object.assign({}, productCombination), patch), { updater: user }));
14
+ }
15
+ };
16
+ //# sourceMappingURL=update-product-combination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-product-combination.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/product-combination/update-product-combination.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAEvC,gDAAsD;AAEzC,QAAA,wBAAwB,GAAG;IACtC,KAAK,CAAC,wBAAwB,CAAC,CAAM,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,OAAY;QAChE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEtC,MAAM,UAAU,GAAG,IAAA,uBAAa,EAAC,6BAAkB,CAAC,CAAA;QACpD,MAAM,kBAAkB,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC;YAClD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;SACtB,CAAC,CAAA;QAEF,OAAO,MAAM,UAAU,CAAC,IAAI,+CACvB,kBAAkB,GAClB,KAAK,KACR,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;CACF,CAAA"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createProductCombinationSetting = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const entities_1 = require("../../../entities");
6
+ exports.createProductCombinationSetting = {
7
+ async createProductCombinationSetting(_, { productCombinationSetting }, context) {
8
+ const { user } = context.state;
9
+ return await (0, typeorm_1.getRepository)(entities_1.ProductCombinationSetting).save(Object.assign(Object.assign({}, productCombinationSetting), { creator: user, updater: user }));
10
+ }
11
+ };
12
+ //# sourceMappingURL=create-product-combination-setting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-product-combination-setting.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/product-combination-setting/create-product-combination-setting.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAEvC,gDAA6D;AAEhD,QAAA,+BAA+B,GAAG;IAC7C,KAAK,CAAC,+BAA+B,CAAC,CAAM,EAAE,EAAE,yBAAyB,EAAE,EAAE,OAAY;QACvF,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE9B,OAAO,MAAM,IAAA,uBAAa,EAAC,oCAAyB,CAAC,CAAC,IAAI,iCACrD,yBAAyB,KAC5B,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;CACF,CAAA"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteProductCombinationSetting = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const entities_1 = require("../../../entities");
6
+ exports.deleteProductCombinationSetting = {
7
+ async deleteProductCombinationSetting(_, { id }, context) {
8
+ await (0, typeorm_1.getRepository)(entities_1.ProductCombinationSetting).delete({ id });
9
+ return true;
10
+ }
11
+ };
12
+ //# sourceMappingURL=delete-product-combination-setting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-product-combination-setting.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/product-combination-setting/delete-product-combination-setting.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAEvC,gDAA6D;AAEhD,QAAA,+BAA+B,GAAG;IAC7C,KAAK,CAAC,+BAA+B,CAAC,CAAM,EAAE,EAAE,EAAE,EAAE,EAAE,OAAY;QAChE,MAAM,IAAA,uBAAa,EAAC,oCAAyB,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;QAE7D,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteProductCombinationSettings = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const entities_1 = require("../../../entities");
6
+ exports.deleteProductCombinationSettings = {
7
+ async deleteProductCombinationSettings(_, { ids }, context) {
8
+ await (0, typeorm_1.getRepository)(entities_1.ProductCombinationSetting).delete({
9
+ product: (0, typeorm_1.In)(ids)
10
+ });
11
+ return true;
12
+ }
13
+ };
14
+ //# sourceMappingURL=delete-product-combination-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-product-combination-settings.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/product-combination-setting/delete-product-combination-settings.ts"],"names":[],"mappings":";;;AAAA,qCAA2C;AAE3C,gDAA6D;AAEhD,QAAA,gCAAgC,GAAG;IAC9C,KAAK,CAAC,gCAAgC,CAAC,CAAM,EAAE,EAAE,GAAG,EAAE,EAAE,OAAY;QAClE,MAAM,IAAA,uBAAa,EAAC,oCAAyB,CAAC,CAAC,MAAM,CAAC;YACpD,OAAO,EAAE,IAAA,YAAE,EAAC,GAAG,CAAC;SACjB,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProductCombinationSettingResolver = void 0;
4
+ const create_product_combination_setting_1 = require("./create-product-combination-setting");
5
+ const delete_product_combination_setting_1 = require("./delete-product-combination-setting");
6
+ const delete_product_combination_settings_1 = require("./delete-product-combination-settings");
7
+ const link_product_combination_1 = require("./link-product-combination");
8
+ const product_combination_sets_1 = require("./product-combination-sets");
9
+ const product_combination_setting_query_1 = require("./product-combination-setting-query");
10
+ const update_multiple_product_combination_setting_1 = require("./update-multiple-product-combination-setting");
11
+ exports.ProductCombinationSettingResolver = {
12
+ Query: Object.assign(Object.assign({}, product_combination_setting_query_1.Query), product_combination_sets_1.productCombinationSets),
13
+ Mutation: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, update_multiple_product_combination_setting_1.updateMultipleProductCombinationSetting), create_product_combination_setting_1.createProductCombinationSetting), delete_product_combination_setting_1.deleteProductCombinationSetting), delete_product_combination_settings_1.deleteProductCombinationSettings), link_product_combination_1.linkProductCombination)
14
+ };
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/product-combination-setting/index.ts"],"names":[],"mappings":";;;AAAA,6FAAsF;AACtF,6FAAsF;AACtF,+FAAwF;AACxF,yEAAmE;AACnE,yEAAmE;AACnE,2FAA2D;AAC3D,+GAAuG;AAE1F,QAAA,iCAAiC,GAAG;IAC/C,KAAK,kCACA,yCAAK,GACL,iDAAsB,CAC1B;IACD,QAAQ,4EACH,qFAAuC,GACvC,oEAA+B,GAC/B,oEAA+B,GAC/B,sEAAgC,GAChC,iDAAsB,CAC1B;CACF,CAAA"}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.linkProductCombination = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const entities_1 = require("../../../entities");
6
+ const update_multiple_product_combination_setting_1 = require("./update-multiple-product-combination-setting");
7
+ const debug = require('debug')('things-factory:product-base:productCombinationSetting');
8
+ exports.linkProductCombination = {
9
+ async linkProductCombination(_, { productCombinationId, patches }, context) {
10
+ try {
11
+ const { domain, tx } = context.state;
12
+ const qb = tx
13
+ .getRepository(entities_1.ProductCombinationSetting)
14
+ .createQueryBuilder('pbs')
15
+ .innerJoinAndSelect('pbs.product', 'prd')
16
+ .innerJoinAndSelect('pbs.productDetail', 'pd')
17
+ .innerJoinAndSelect('pbs.productCombination', 'pc')
18
+ .where('pc.id = :productCombinationId', { productCombinationId })
19
+ .andWhere('pc.domain_id = :domainId', { domainId: domain.id });
20
+ const existingCombinationLink = await qb.getMany();
21
+ let newCombinationLink = patches.reduce((acc, curr) => {
22
+ if (!existingCombinationLink.find(item => item.product.id === curr.product.id && item.productDetail.id === curr.productDetail.id)) {
23
+ acc.push({
24
+ productCombination: { id: productCombinationId },
25
+ product: { id: curr.product.id },
26
+ productDetail: { id: curr.productDetail.id },
27
+ qty: curr.qty,
28
+ cuFlag: '+'
29
+ });
30
+ }
31
+ // check if there is existing bundle link but changes in bundle qty
32
+ else if (existingCombinationLink.find(item => item.product.id === curr.product.id &&
33
+ item.productDetail.id === curr.productDetail.id &&
34
+ item.qty !== curr.qty)) {
35
+ acc.push({
36
+ id: curr.id,
37
+ productCombination: { id: productCombinationId },
38
+ product: { id: curr.product.id },
39
+ productDetail: { id: curr.productDetail.id },
40
+ qty: curr.qty,
41
+ cuFlag: 'M'
42
+ });
43
+ }
44
+ return acc;
45
+ }, []);
46
+ let removeCombinationLink = existingCombinationLink.reduce((acc, curr) => {
47
+ if (!patches.find(item => item.id == curr.id)) {
48
+ acc.push({
49
+ id: curr.id,
50
+ productCombination: { id: productCombinationId },
51
+ product: { id: curr.product.id },
52
+ productDetail: { id: curr.productDetail.id },
53
+ qty: curr.qty
54
+ });
55
+ }
56
+ return acc;
57
+ }, []);
58
+ if (newCombinationLink.length > 0) {
59
+ await (0, update_multiple_product_combination_setting_1.updateMultipleProductCombinationSetting)(newCombinationLink, tx);
60
+ }
61
+ if (removeCombinationLink.length > 0) {
62
+ await tx.getRepository(entities_1.ProductCombinationSetting).delete({
63
+ id: (0, typeorm_1.In)(removeCombinationLink.map(combinationLink => combinationLink.id))
64
+ });
65
+ }
66
+ }
67
+ catch (error) {
68
+ debug('link-product-combination', error);
69
+ throw error;
70
+ }
71
+ }
72
+ };
73
+ //# sourceMappingURL=link-product-combination.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"link-product-combination.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/product-combination-setting/link-product-combination.ts"],"names":[],"mappings":";;;AAAA,qCAA+D;AAI/D,gDAA6D;AAC7D,+GAAuG;AAEvG,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,uDAAuD,CAAC,CAAA;AAE1E,QAAA,sBAAsB,GAAG;IACpC,KAAK,CAAC,sBAAsB,CAAC,CAAM,EAAE,EAAE,oBAAoB,EAAE,OAAO,EAAE,EAAE,OAAY;QAClF,IAAI;YACF,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAA0C,OAAO,CAAC,KAAK,CAAA;YAE3E,MAAM,EAAE,GAAkD,EAAE;iBACzD,aAAa,CAAC,oCAAyB,CAAC;iBACxC,kBAAkB,CAAC,KAAK,CAAC;iBACzB,kBAAkB,CAAC,aAAa,EAAE,KAAK,CAAC;iBACxC,kBAAkB,CAAC,mBAAmB,EAAE,IAAI,CAAC;iBAC7C,kBAAkB,CAAC,wBAAwB,EAAE,IAAI,CAAC;iBAClD,KAAK,CAAC,+BAA+B,EAAE,EAAE,oBAAoB,EAAE,CAAC;iBAChE,QAAQ,CAAC,0BAA0B,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAA;YAEhE,MAAM,uBAAuB,GAAG,MAAM,EAAE,CAAC,OAAO,EAAE,CAAA;YAElD,IAAI,kBAAkB,GAAgC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;gBACjF,IACE,CAAC,uBAAuB,CAAC,IAAI,CAC3B,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,C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gBACpG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC,EAAE;oBAC7C,GAAG,CAAC,IAAI,CAAC;wBACP,EAAE,EAAE,IAAI,CAAC,EAAE;wBACX,kBAAkB,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE;wBAChD,OAAO,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE;wBAChC,aAAa,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE;wBAC5C,GAAG,EAAE,IAAI,CAAC,GAAG;qBACd,CAAC,CAAA;iBACH;gBACD,OAAO,GAAG,CAAA;YACZ,CAAC,EAAE,EAAE,CAAC,CAAA;YAEN,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,EAAE;gBACjC,MAAM,IAAA,qFAAuC,EAAC,kBAAkB,EAAE,EAAE,CAAC,CAAA;aACtE;YAED,IAAI,qBAAqB,CAAC,MAAM,GAAG,CAAC,EAAE;gBACpC,MAAM,EAAE,CAAC,aAAa,CAAC,oCAAyB,CAAC,CAAC,MAAM,CAAC;oBACvD,EAAE,EAAE,IAAA,YAAE,EAAC,qBAAqB,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;iBACzE,CAAC,CAAA;aACH;SACF;QAAC,OAAO,KAAK,EAAE;YACd,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAA;YACxC,MAAM,KAAK,CAAA;SACZ;IACH,CAAC;CACF,CAAA"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.productCombinationSets = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const biz_base_1 = require("@things-factory/biz-base");
6
+ const shell_1 = require("@things-factory/shell");
7
+ const entities_1 = require("../../../entities");
8
+ exports.productCombinationSets = {
9
+ async productCombinationSets(_, params, context) {
10
+ var _a;
11
+ const { domain } = context.state;
12
+ const page = params.pagination.page;
13
+ const limit = params.pagination.limit;
14
+ const filters = params.filters.filter(x => x.name !== 'product_info' && x.name !== 'productCombinationId' && x.name !== 'bizplace_id');
15
+ const bizplaceFilter = params.filters.find(x => x.name == 'bizplace_id');
16
+ const productCombinationId = params.filters.find(x => x.name === 'productCombinationId');
17
+ const productInfoFilter = params.filters.find(x => x.name === 'product_info');
18
+ const productInfoColumns = ['sku', 'name', 'description'];
19
+ params.filters = [...filters];
20
+ params.sortings = [
21
+ { name: 'prd.sku' },
22
+ { name: 'prdDet.gtin' },
23
+ ...params.sortings.map(sorting => {
24
+ const name = sorting.name.replace('product', '').toLowerCase();
25
+ return Object.assign(Object.assign({}, sorting), { name });
26
+ })
27
+ ];
28
+ if (bizplaceFilter === null || bizplaceFilter === void 0 ? void 0 : bizplaceFilter.value) {
29
+ const bizplaceId = bizplaceFilter.value;
30
+ const foundBizplace = await (0, typeorm_1.getRepository)(biz_base_1.Bizplace).findOne({
31
+ where: { id: bizplaceId },
32
+ relations: ['company', 'company.domain']
33
+ });
34
+ if (foundBizplace) {
35
+ const companyDomain = (_a = foundBizplace.company) === null || _a === void 0 ? void 0 : _a.domain;
36
+ const companyBizplace = await (0, typeorm_1.getRepository)(biz_base_1.Bizplace).findOne({ where: { domain: companyDomain } });
37
+ const bizplaceIds = [companyBizplace.id, foundBizplace.id];
38
+ params.filters = [...filters, { name: 'bizplace_id', operator: 'in', value: [...new Set(bizplaceIds)] }];
39
+ }
40
+ }
41
+ else {
42
+ let bizplace = await (0, typeorm_1.getRepository)(biz_base_1.Bizplace).findOne({ where: { domain } });
43
+ params.filters = [...filters, { name: 'bizplace_id', operator: 'in', value: [bizplace.id] }];
44
+ }
45
+ const qb = (0, typeorm_1.getRepository)(entities_1.Product).createQueryBuilder('prd');
46
+ (0, shell_1.buildQuery)(qb, params, context, false);
47
+ qb.innerJoinAndSelect('product_details', 'prdDet', 'prdDet.product_id = prd.id');
48
+ qb.leftJoinAndSelect('product_combination_settings', 'pcs', `pcs.product_id = prd.id and pcs.product_detail_id = prdDet.id ${productCombinationId && productCombinationId.operator === 'noteq' ? 'and pcs.product_detail_id = null' : ''}`);
49
+ qb.leftJoinAndSelect('pcs.productCombination', 'pc');
50
+ if (productInfoFilter) {
51
+ qb.andWhere(new typeorm_1.Brackets(qb2 => {
52
+ productInfoColumns.forEach(filter => {
53
+ const condition = (0, shell_1.buildCondition)(qb.alias, filter, productInfoFilter.operator, productInfoFilter.value, productInfoFilter.relation, Object.keys(qb.getParameters()).length);
54
+ qb2.orWhere(condition.clause, condition.parameters);
55
+ });
56
+ }));
57
+ }
58
+ if (productCombinationId && productCombinationId.operator === 'eq') {
59
+ qb.andWhere('pc.id = :combinationId::uuid', {
60
+ combinationId: productCombinationId.value
61
+ });
62
+ }
63
+ let productCombinationSets = await qb
64
+ .offset((page - 1) * limit)
65
+ .limit(limit)
66
+ .getRawMany();
67
+ const items = productCombinationSets.map(item => {
68
+ return {
69
+ id: item.pcs_id,
70
+ productDetailId: item.prdDet_id,
71
+ gtin: item.prdDet_gtin,
72
+ packingType: item.prdDet_packing_type,
73
+ packingSize: item.prdDet_packing_size,
74
+ productId: item.prd_id,
75
+ productSku: item.prd_sku,
76
+ productName: item.prd_name,
77
+ productDescription: item.prd_description,
78
+ productType: item.prd_type,
79
+ combinationId: item.pc_id,
80
+ qty: item.pcs_qty
81
+ };
82
+ });
83
+ const total = await qb.getCount();
84
+ return { items, total };
85
+ }
86
+ };
87
+ //# sourceMappingURL=product-combination-sets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-combination-sets.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/product-combination-setting/product-combination-sets.ts"],"names":[],"mappings":";;;AAAA,qCAAqE;AAErE,uDAAmD;AACnD,iDAAqF;AAErF,gDAA2C;AAE9B,QAAA,sBAAsB,GAAG;IACpC,KAAK,CAAC,sB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,EAAE;aAClC,MAAM,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;aAC1B,KAAK,CAAC,KAAK,CAAC;aACZ,UAAU,EAAE,CAAA;QAEf,MAAM,KAAK,GAAG,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC9C,OAAO;gBACL,EAAE,EAAE,IAAI,CAAC,MAAM;gBACf,eAAe,EAAE,IAAI,CAAC,SAAS;gBAC/B,IAAI,EAAE,IAAI,CAAC,WAAW;gBACtB,WAAW,EAAE,IAAI,CAAC,mBAAmB;gBACrC,WAAW,EAAE,IAAI,CAAC,mBAAmB;gBACrC,SAAS,EAAE,IAAI,CAAC,MAAM;gBACtB,UAAU,EAAE,IAAI,CAAC,OAAO;gBACxB,WAAW,EAAE,IAAI,CAAC,QAAQ;gBAC1B,kBAAkB,EAAE,IAAI,CAAC,eAAe;gBACxC,WAAW,EAAE,IAAI,CAAC,QAAQ;gBAC1B,aAAa,EAAE,IAAI,CAAC,KAAK;gBACzB,GAAG,EAAE,IAAI,CAAC,OAAO;aAClB,CAAA;QACH,CAAC,CAAC,CAAA;QAEF,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAA;QAEjC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;CACF,CAAA"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Query = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const entities_1 = require("../../../entities");
6
+ exports.Query = {
7
+ async productCombinationSettings(_, { productCombinationId }, context) {
8
+ const productCombination = await (0, typeorm_1.getRepository)(entities_1.ProductCombination).findOne({
9
+ where: { id: productCombinationId },
10
+ relations: ['productCombinationSetting']
11
+ });
12
+ const productCombinationSettings = productCombination.productCombinationSettings;
13
+ return productCombinationSettings;
14
+ }
15
+ };
16
+ //# sourceMappingURL=product-combination-setting-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-combination-setting-query.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/product-combination-setting/product-combination-setting-query.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAEvC,gDAAiF;AAEpE,QAAA,KAAK,GAAG;IACnB,KAAK,CAAC,0BAA0B,CAAC,CAAM,EAAE,EAAE,oBAAoB,EAAE,EAAE,OAAY;QAC7E,MAAM,kBAAkB,GAAuB,MAAM,IAAA,uBAAa,EAAC,6BAAkB,CAAC,CAAC,OAAO,CAAC;YAC7F,KAAK,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE;YACnC,SAAS,EAAE,CAAC,2BAA2B,CAAC;SACzC,CAAC,CAAA;QAEF,MAAM,0BAA0B,GAAgC,kBAAkB,CAAC,0BAA0B,CAAA;QAE7G,OAAO,0BAA0B,CAAA;IACnC,CAAC;CACF,CAAA"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateMultipleProductCombinationSetting = exports.updateMultipleProductCombinationSettingResolver = void 0;
4
+ const entities_1 = require("../../../entities");
5
+ exports.updateMultipleProductCombinationSettingResolver = {
6
+ async updateMultipleProductCombinationSetting(_, { patches }, context) {
7
+ await updateMultipleProductCombinationSetting(patches);
8
+ }
9
+ };
10
+ async function updateMultipleProductCombinationSetting(patches, tx) {
11
+ let results = [];
12
+ const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
13
+ const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
14
+ const productCombinationSettingRepo = tx.getRepository(entities_1.ProductCombinationSetting);
15
+ if (_createRecords.length > 0) {
16
+ for (let i = 0; i < _createRecords.length; i++) {
17
+ const newRecord = _createRecords[i];
18
+ const result = await productCombinationSettingRepo.save(Object.assign({}, newRecord));
19
+ results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
20
+ }
21
+ }
22
+ if (_updateRecords.length > 0) {
23
+ for (let i = 0; i < _updateRecords.length; i++) {
24
+ const newRecord = _updateRecords[i];
25
+ const productCombinationSetting = await productCombinationSettingRepo.findOne({ id: newRecord.id });
26
+ const result = await productCombinationSettingRepo.save(Object.assign(Object.assign({}, productCombinationSetting), newRecord));
27
+ results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
28
+ }
29
+ }
30
+ return results;
31
+ }
32
+ exports.updateMultipleProductCombinationSetting = updateMultipleProductCombinationSetting;
33
+ //# sourceMappingURL=update-multiple-product-combination-setting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-multiple-product-combination-setting.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/product-combination-setting/update-multiple-product-combination-setting.ts"],"names":[],"mappings":";;;AAEA,gDAA6D;AAEhD,QAAA,+CAA+C,GAAG;IAC7D,KAAK,CAAC,uCAAuC,CAAC,CAAM,EAAE,EAAE,OAAO,EAAE,EAAE,OAAY;QAC7E,MAAM,uCAAuC,CAAC,OAAO,CAAC,CAAA;IACxD,CAAC;CACF,CAAA;AAEM,KAAK,UAAU,uCAAuC,CAC3D,OAAoC,EACpC,EAAkB;IAElB,IAAI,OAAO,GAAG,EAAE,CAAA;IAChB,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,CAAA;IACzF,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,CAAA;IACzF,MAAM,6BAA6B,GAAG,EAAE,CAAC,aAAa,CAAC,oCAAyB,CAAC,CAAA;IAEjF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC9C,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,CAAC,CAAA;YAEnC,MAAM,MAAM,GAAG,MAAM,6BAA6B,CAAC,IAAI,mBAClD,SAAS,EACZ,CAAA;YAEF,OAAO,CAAC,IAAI,iCAAM,MAAM,KAAE,MAAM,EAAE,GAAG,IAAG,CAAA;SACzC;KACF;IAED,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;QAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC9C,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,CAAC,CAAA;YACnC,MAAM,yBAAyB,GAAG,MAAM,6BAA6B,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAA;YAEnG,MAAM,MAAM,GAAG,MAAM,6BAA6B,CAAC,IAAI,iCAClD,yBAAyB,GACzB,SAAS,EACZ,CAAA;YAEF,OAAO,CAAC,IAAI,iCAAM,MAAM,KAAE,MAAM,EAAE,GAAG,IAAG,CAAA;SACzC;KACF;IAED,OAAO,OAAO,CAAA;AAChB,CAAC;AApCD,0FAoCC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createProductDetail = exports.createProductDetailResolver = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const entities_1 = require("../../../entities");
6
+ exports.createProductDetailResolver = {
7
+ async createProductDetail(_, { productDetail }, context) {
8
+ const { domain, user } = context.state;
9
+ return await (0, typeorm_1.getRepository)(entities_1.ProductDetail).save(Object.assign(Object.assign({}, productDetail), { domain, creator: user, updater: user }));
10
+ }
11
+ };
12
+ async function createProductDetail(productDetail, context) {
13
+ const { domain, user, tx } = context.state;
14
+ return await tx.getRepository(entities_1.ProductDetail).save(Object.assign(Object.assign({}, productDetail), { domain, creator: user, updater: user }));
15
+ }
16
+ exports.createProductDetail = createProductDetail;
17
+ //# sourceMappingURL=create-product-detail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-product-detail.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/product-detail/create-product-detail.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,gDAAiD;AAEpC,QAAA,2BAA2B,GAAG;IACzC,KAAK,CAAC,mBAAmB,CAAC,CAAM,EAAE,EAAE,aAAa,EAAE,EAAE,OAAY;QAC/D,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEtC,OAAO,MAAM,IAAA,uBAAa,EAAC,wBAAa,CAAC,CAAC,IAAI,iCACzC,aAAa,KAChB,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;IACJ,CAAC;CACF,CAAA;AAEM,KAAK,UAAU,mBAAmB,CAAC,aAAkB,EAAE,OAAY;IACxE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAE1C,OAAO,MAAM,EAAE,CAAC,aAAa,CAAC,wBAAa,CAAC,CAAC,IAAI,iCAC5C,aAAa,KAChB,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;AACJ,CAAC;AATD,kDASC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteProductDetailResolver = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const entities_1 = require("../../../entities");
6
+ exports.deleteProductDetailResolver = {
7
+ async deleteProductDetail(_, { name }, context) {
8
+ const { domain, user } = context.state;
9
+ await (0, typeorm_1.getRepository)(entities_1.ProductDetail).delete({ domain, name });
10
+ return true;
11
+ }
12
+ };
13
+ //# sourceMappingURL=delete-product-detail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-product-detail.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/product-detail/delete-product-detail.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AACvC,gDAAiD;AAEpC,QAAA,2BAA2B,GAAG;IACzC,KAAK,CAAC,mBAAmB,CAAC,CAAM,EAAE,EAAE,IAAI,EAAE,EAAE,OAAY;QACtD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEtC,MAAM,IAAA,uBAAa,EAAC,wBAAa,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;QAE3D,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deleteProductDetailsResolver = void 0;
4
+ const typeorm_1 = require("typeorm");
5
+ const entities_1 = require("../../../entities");
6
+ exports.deleteProductDetailsResolver = {
7
+ async deleteProductDetails(_, { names }, context) {
8
+ const { domain, user } = context.state;
9
+ await (0, typeorm_1.getRepository)(entities_1.ProductDetail).delete({
10
+ domain,
11
+ name: (0, typeorm_1.In)(names)
12
+ });
13
+ return true;
14
+ }
15
+ };
16
+ //# sourceMappingURL=delete-product-details.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-product-details.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/product-detail/delete-product-details.ts"],"names":[],"mappings":";;;AAAA,qCAA2C;AAC3C,gDAAiD;AAEpC,QAAA,4BAA4B,GAAG;IAC1C,KAAK,CAAC,oBAAoB,CAAC,CAAM,EAAE,EAAE,KAAK,EAAE,EAAE,OAAY;QACxD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEtC,MAAM,IAAA,uBAAa,EAAC,wBAAa,CAAC,CAAC,MAAM,CAAC;YACtC,MAAM;YACN,IAAI,EAAE,IAAA,YAAE,EAAC,KAAK,CAAC;SAClB,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProductDetailResolver = void 0;
4
+ const product_detail_query_1 = require("./product-detail-query");
5
+ const update_product_detail_1 = require("./update-product-detail");
6
+ const update_multiple_product_detail_1 = require("./update-multiple-product-detail");
7
+ const create_product_detail_1 = require("./create-product-detail");
8
+ const delete_product_detail_1 = require("./delete-product-detail");
9
+ const delete_product_details_1 = require("./delete-product-details");
10
+ exports.ProductDetailResolver = {
11
+ ProductDetail: product_detail_query_1.ProductDetail,
12
+ Query: product_detail_query_1.Query,
13
+ Mutation: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, update_product_detail_1.updateProductDetailResolver), update_multiple_product_detail_1.updateMultipleProductDetailResolver), create_product_detail_1.createProductDetailResolver), delete_product_detail_1.deleteProductDetailResolver), delete_product_details_1.deleteProductDetailsResolver)
14
+ };
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/product-detail/index.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAE7D,mEAA0F;AAC1F,qFAAmH;AACnH,mEAA0F;AAC1F,mEAAqE;AACrE,qEAAuE;AAE1D,QAAA,qBAAqB,GAAG;IACnC,aAAa,EAAb,oCAAa;IACb,KAAK,EAAL,4BAAK;IACL,QAAQ,4EACH,mDAA2B,GAC3B,oEAAmC,GACnC,mDAA2B,GAC3B,mDAA2B,GAC3B,qDAA4B,CAChC;CACF,CAAA"}
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProductDetail = exports.Query = void 0;
4
+ const biz_base_1 = require("@things-factory/biz-base");
5
+ const shell_1 = require("@things-factory/shell");
6
+ const typeorm_1 = require("typeorm");
7
+ const entities_1 = require("../../../entities");
8
+ exports.Query = {
9
+ async productDetail(_, { gtin, customerCompanyDomainId }, context) {
10
+ const { tx } = context.state;
11
+ const repository = tx.getRepository(entities_1.ProductDetail);
12
+ const customerDomainId = await tx.getRepository(shell_1.Domain).findOne(customerCompanyDomainId);
13
+ if (!customerDomainId)
14
+ throw new Error('Unable to find company domain');
15
+ const foundProductDetail = await repository.findOne({ where: { domain: customerDomainId, gtin }, relations: ['product'] });
16
+ if (!foundProductDetail)
17
+ throw new Error('No product candidate found');
18
+ return foundProductDetail;
19
+ },
20
+ async productDetails(_, params, context) {
21
+ var _a;
22
+ const { domain, user } = context.state;
23
+ const { domains } = user;
24
+ const productInfoFilters = params.filters.find(x => x.name == 'product_info' || x.name == 'sku' || x.name == 'name' || x.name == 'description' || x.name == 'type');
25
+ const bizplaceFilter = params.filters.find(x => x.name == 'bizplace_id');
26
+ const productFilter = params.filters.find(x => x.name == 'product');
27
+ const productInfoFilterColumns = ['sku', 'name', 'description', 'type'];
28
+ params.filters = params.filters.filter(x => x.name != 'product_info' &&
29
+ x.name != 'bizplace_id' &&
30
+ x.name != 'product' &&
31
+ x.name != 'sku' &&
32
+ x.name != 'name' &&
33
+ x.name != 'description' &&
34
+ x.name != 'type');
35
+ const qb = (0, typeorm_1.getRepository)(entities_1.ProductDetail).createQueryBuilder('ProductDetail');
36
+ qb.innerJoinAndSelect('ProductDetail.product', 'Product', '"Product"."deleted_at" IS NULL');
37
+ qb.innerJoinAndSelect('Product.bizplace', 'Bizplace');
38
+ qb.leftJoinAndSelect('ProductDetail.childProductDetail', 'ChildProductDetail');
39
+ qb.leftJoinAndSelect('Product.creator', 'Creator');
40
+ qb.leftJoinAndSelect('Product.updater', 'Updater');
41
+ (0, shell_1.buildQuery)(qb, params, context, false);
42
+ if (bizplaceFilter === null || bizplaceFilter === void 0 ? void 0 : bizplaceFilter.value) {
43
+ const bizplaceId = bizplaceFilter.value;
44
+ const foundBizplace = await (0, typeorm_1.getRepository)(biz_base_1.Bizplace).findOne({
45
+ where: { id: bizplaceId },
46
+ relations: ['company', 'company.domain']
47
+ });
48
+ if (foundBizplace) {
49
+ const companyDomain = (_a = foundBizplace.company) === null || _a === void 0 ? void 0 : _a.domain;
50
+ const companyBizplace = await (0, typeorm_1.getRepository)(biz_base_1.Bizplace).findOne({ where: { domain: companyDomain } });
51
+ const bizplaceIds = [companyBizplace.id, foundBizplace.id];
52
+ qb.andWhere('Bizplace.id IN (:...bizplaceIds)', { bizplaceIds: [...new Set(bizplaceIds)] });
53
+ }
54
+ }
55
+ else {
56
+ const warehouseDomain = domain;
57
+ let bizplaceIds = [];
58
+ if ((warehouseDomain === null || warehouseDomain === void 0 ? void 0 : warehouseDomain.extType) === 'company') {
59
+ const companyBizplace = await (0, typeorm_1.getRepository)(biz_base_1.Bizplace).findOne({
60
+ where: { domain: warehouseDomain }
61
+ });
62
+ bizplaceIds.push(companyBizplace.id);
63
+ }
64
+ else {
65
+ const companiesBizplaces = await (0, biz_base_1.getCompaniesBizplaces)(domains, warehouseDomain);
66
+ const partnersCompanyBizplaces = await (0, biz_base_1.getPartnersCompanyBizplaces)(domain, user);
67
+ bizplaceIds = [
68
+ ...bizplaceIds,
69
+ ...companiesBizplaces.map(biz => biz.id),
70
+ ...partnersCompanyBizplaces.map(biz => biz.id)
71
+ ];
72
+ }
73
+ qb.andWhere('Product.bizplace_id IN (:...bizplaceIds)', { bizplaceIds: bizplaceIds });
74
+ }
75
+ if (productFilter === null || productFilter === void 0 ? void 0 : productFilter.value) {
76
+ qb.andWhere('ProductDetail.product_id = :productId', { productId: productFilter.value });
77
+ }
78
+ if (productInfoFilters === null || productInfoFilters === void 0 ? void 0 : productInfoFilters.value) {
79
+ let productInfo = productInfoFilters;
80
+ qb.andWhere(new typeorm_1.Brackets(qb2 => {
81
+ productInfoFilterColumns.forEach(filter => {
82
+ const condition = (0, shell_1.buildCondition)('Product', filter, productInfo.operator, productInfo.value, productInfo.relation, Object.keys(qb.getParameters()).length);
83
+ qb2.orWhere(condition.clause, condition.parameters);
84
+ });
85
+ }));
86
+ }
87
+ let [items, total] = await qb.getManyAndCount();
88
+ items = items.map(item => {
89
+ return Object.assign(Object.assign({}, item), { productId: item.product.id, name: item.product.name, description: item.product.description, type: item.product.type, sku: item.product.sku, auxUnit1: item.product.auxUnit1, auxValue1: item.product.auxValue1 });
90
+ });
91
+ return { items, total };
92
+ }
93
+ };
94
+ exports.ProductDetail = {
95
+ async domain(productDetail) {
96
+ var _a;
97
+ return (_a = (await (0, typeorm_1.getRepository)(entities_1.ProductDetail).findOne(productDetail.id, {
98
+ relations: ['domain']
99
+ }))) === null || _a === void 0 ? void 0 : _a.domain;
100
+ },
101
+ async creator(productDetail) {
102
+ var _a;
103
+ return (_a = (await (0, typeorm_1.getRepository)(entities_1.ProductDetail).findOne(productDetail.id, {
104
+ relations: ['creator']
105
+ }))) === null || _a === void 0 ? void 0 : _a.creator;
106
+ },
107
+ async updater(productDetail) {
108
+ var _a;
109
+ return (_a = (await (0, typeorm_1.getRepository)(entities_1.ProductDetail).findOne(productDetail.id, {
110
+ relations: ['updater']
111
+ }))) === null || _a === void 0 ? void 0 : _a.updater;
112
+ }
113
+ };
114
+ //# sourceMappingURL=product-detail-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-detail-query.js","sourceRoot":"","sources":["../../../../server/graphql/resolvers/product-detail/product-detail-query.ts"],"names":[],"mappings":";;;AAAA,uDAAuG;AACvG,iDAAqF;AACrF,qCAAqE;AACrE,gDAAwE;AAE3D,QAAA,KAAK,GAAG;IACnB,KAAK,CAAC,aAAa,CAAC,CAAM,EAAE,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,OAAY;QACzE,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC5B,MAAM,UAAU,GAAG,EAAE,CAAC,aAAa,CAAC,wBAAmB,CAAC,CAAA;QAExD,MAAM,gBAAgB,GAAW,MAAM,EAAE,CAAC,aAAa,CAAC,cAAM,CAAC,CAAC,OAAO,CAAC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