@things-factory/product-base 4.3.638 → 4.3.651

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 (114) hide show
  1. package/package.json +2 -2
  2. package/server/service/product/product-types.ts +14 -8
  3. package/server/service/product/product.ts +13 -8
  4. package/server/service/product-detail/product-detail-mutation.ts +1 -1
  5. package/dist-server/constants/index.js +0 -18
  6. package/dist-server/constants/index.js.map +0 -1
  7. package/dist-server/constants/product.js +0 -25
  8. package/dist-server/constants/product.js.map +0 -1
  9. package/dist-server/controllers/index.js +0 -1
  10. package/dist-server/controllers/index.js.map +0 -1
  11. package/dist-server/index.js +0 -19
  12. package/dist-server/index.js.map +0 -1
  13. package/dist-server/middlewares/index.js +0 -1
  14. package/dist-server/middlewares/index.js.map +0 -1
  15. package/dist-server/migrations/index.js +0 -12
  16. package/dist-server/migrations/index.js.map +0 -1
  17. package/dist-server/service/index.js +0 -74
  18. package/dist-server/service/index.js.map +0 -1
  19. package/dist-server/service/product/index.js +0 -9
  20. package/dist-server/service/product/index.js.map +0 -1
  21. package/dist-server/service/product/product-mutation.js +0 -408
  22. package/dist-server/service/product/product-mutation.js.map +0 -1
  23. package/dist-server/service/product/product-query.js +0 -373
  24. package/dist-server/service/product/product-query.js.map +0 -1
  25. package/dist-server/service/product/product-types.js +0 -610
  26. package/dist-server/service/product/product-types.js.map +0 -1
  27. package/dist-server/service/product/product.js +0 -609
  28. package/dist-server/service/product/product.js.map +0 -1
  29. package/dist-server/service/product/validate-product.js +0 -26
  30. package/dist-server/service/product/validate-product.js.map +0 -1
  31. package/dist-server/service/product-barcode/index.js +0 -9
  32. package/dist-server/service/product-barcode/index.js.map +0 -1
  33. package/dist-server/service/product-barcode/product-barcode-mutation.js +0 -120
  34. package/dist-server/service/product-barcode/product-barcode-mutation.js.map +0 -1
  35. package/dist-server/service/product-barcode/product-barcode-query.js +0 -87
  36. package/dist-server/service/product-barcode/product-barcode-query.js.map +0 -1
  37. package/dist-server/service/product-barcode/product-barcode-type.js +0 -63
  38. package/dist-server/service/product-barcode/product-barcode-type.js.map +0 -1
  39. package/dist-server/service/product-barcode/product-barcode.js +0 -104
  40. package/dist-server/service/product-barcode/product-barcode.js.map +0 -1
  41. package/dist-server/service/product-bundle/index.js +0 -9
  42. package/dist-server/service/product-bundle/index.js.map +0 -1
  43. package/dist-server/service/product-bundle/product-bundle-mutation.js +0 -130
  44. package/dist-server/service/product-bundle/product-bundle-mutation.js.map +0 -1
  45. package/dist-server/service/product-bundle/product-bundle-query.js +0 -128
  46. package/dist-server/service/product-bundle/product-bundle-query.js.map +0 -1
  47. package/dist-server/service/product-bundle/product-bundle-types.js +0 -85
  48. package/dist-server/service/product-bundle/product-bundle-types.js.map +0 -1
  49. package/dist-server/service/product-bundle/product-bundle.js +0 -128
  50. package/dist-server/service/product-bundle/product-bundle.js.map +0 -1
  51. package/dist-server/service/product-bundle-setting/index.js +0 -9
  52. package/dist-server/service/product-bundle-setting/index.js.map +0 -1
  53. package/dist-server/service/product-bundle-setting/product-bundle-setting-mutation.js +0 -165
  54. package/dist-server/service/product-bundle-setting/product-bundle-setting-mutation.js.map +0 -1
  55. package/dist-server/service/product-bundle-setting/product-bundle-setting-query.js +0 -113
  56. package/dist-server/service/product-bundle-setting/product-bundle-setting-query.js.map +0 -1
  57. package/dist-server/service/product-bundle-setting/product-bundle-setting-types.js +0 -69
  58. package/dist-server/service/product-bundle-setting/product-bundle-setting-types.js.map +0 -1
  59. package/dist-server/service/product-bundle-setting/product-bundle-setting.js +0 -63
  60. package/dist-server/service/product-bundle-setting/product-bundle-setting.js.map +0 -1
  61. package/dist-server/service/product-combination/index.js +0 -9
  62. package/dist-server/service/product-combination/index.js.map +0 -1
  63. package/dist-server/service/product-combination/product-combination-mutation.js +0 -137
  64. package/dist-server/service/product-combination/product-combination-mutation.js.map +0 -1
  65. package/dist-server/service/product-combination/product-combination-query.js +0 -86
  66. package/dist-server/service/product-combination/product-combination-query.js.map +0 -1
  67. package/dist-server/service/product-combination/product-combination-type.js +0 -83
  68. package/dist-server/service/product-combination/product-combination-type.js.map +0 -1
  69. package/dist-server/service/product-combination/product-combination.js +0 -133
  70. package/dist-server/service/product-combination/product-combination.js.map +0 -1
  71. package/dist-server/service/product-combination-setting/index.js +0 -9
  72. package/dist-server/service/product-combination-setting/index.js.map +0 -1
  73. package/dist-server/service/product-combination-setting/product-combination-setting-mutation.js +0 -221
  74. package/dist-server/service/product-combination-setting/product-combination-setting-mutation.js.map +0 -1
  75. package/dist-server/service/product-combination-setting/product-combination-setting-query.js +0 -177
  76. package/dist-server/service/product-combination-setting/product-combination-setting-query.js.map +0 -1
  77. package/dist-server/service/product-combination-setting/product-combination-setting-type.js +0 -75
  78. package/dist-server/service/product-combination-setting/product-combination-setting-type.js.map +0 -1
  79. package/dist-server/service/product-combination-setting/product-combination-setting.js +0 -105
  80. package/dist-server/service/product-combination-setting/product-combination-setting.js.map +0 -1
  81. package/dist-server/service/product-detail/index.js +0 -9
  82. package/dist-server/service/product-detail/index.js.map +0 -1
  83. package/dist-server/service/product-detail/product-detail-mutation.js +0 -374
  84. package/dist-server/service/product-detail/product-detail-mutation.js.map +0 -1
  85. package/dist-server/service/product-detail/product-detail-query.js +0 -223
  86. package/dist-server/service/product-detail/product-detail-query.js.map +0 -1
  87. package/dist-server/service/product-detail/product-detail-types.js +0 -392
  88. package/dist-server/service/product-detail/product-detail-types.js.map +0 -1
  89. package/dist-server/service/product-detail/product-detail.js +0 -444
  90. package/dist-server/service/product-detail/product-detail.js.map +0 -1
  91. package/dist-server/service/product-detail-bizplace-setting/index.js +0 -9
  92. package/dist-server/service/product-detail-bizplace-setting/index.js.map +0 -1
  93. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-mutation.js +0 -118
  94. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-mutation.js.map +0 -1
  95. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-query.js +0 -107
  96. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-query.js.map +0 -1
  97. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-types.js +0 -99
  98. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-types.js.map +0 -1
  99. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting.js +0 -120
  100. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting.js.map +0 -1
  101. package/dist-server/service/product-set/index.js +0 -9
  102. package/dist-server/service/product-set/index.js.map +0 -1
  103. package/dist-server/service/product-set/product-set-mutation.js +0 -146
  104. package/dist-server/service/product-set/product-set-mutation.js.map +0 -1
  105. package/dist-server/service/product-set/product-set-query.js +0 -136
  106. package/dist-server/service/product-set/product-set-query.js.map +0 -1
  107. package/dist-server/service/product-set/product-set-types.js +0 -77
  108. package/dist-server/service/product-set/product-set-types.js.map +0 -1
  109. package/dist-server/service/product-set/product-set.js +0 -118
  110. package/dist-server/service/product-set/product-set.js.map +0 -1
  111. package/dist-server/utils/index.js +0 -18
  112. package/dist-server/utils/index.js.map +0 -1
  113. package/dist-server/utils/product-util.js +0 -16
  114. package/dist-server/utils/product-util.js.map +0 -1
@@ -1,408 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- var __importDefault = (this && this.__importDefault) || function (mod) {
15
- return (mod && mod.__esModule) ? mod : { "default": mod };
16
- };
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.updateProduct = exports.createProducts = exports.createProduct = exports.ProductMutation = void 0;
19
- const promises_all_1 = __importDefault(require("promises-all"));
20
- const type_graphql_1 = require("type-graphql");
21
- const typeorm_1 = require("typeorm");
22
- const attachment_base_1 = require("@things-factory/attachment-base");
23
- const biz_base_1 = require("@things-factory/biz-base");
24
- const env_1 = require("@things-factory/env");
25
- const constants_1 = require("../../constants");
26
- const product_detail_1 = require("../product-detail/product-detail");
27
- const product_detail_mutation_1 = require("../product-detail/product-detail-mutation");
28
- const product_set_1 = require("../product-set/product-set");
29
- const product_1 = require("./product");
30
- const product_types_1 = require("./product-types");
31
- const validate_product_1 = require("./validate-product");
32
- let ProductMutation = class ProductMutation {
33
- async createProduct(product, context) {
34
- return await createProduct(product, context);
35
- }
36
- async createProducts(products, context) {
37
- return await createProducts(products, context);
38
- }
39
- async updateProduct(id, patch, context) {
40
- return await updateProduct(id, patch, context);
41
- }
42
- async importMultipleProduct(patches, context) {
43
- try {
44
- let results = [];
45
- //// 1. Group and massage data based on sku for Product and Product Details.
46
- let massagedPatch = patches.reduce(function (acc, currentObj) {
47
- let existingParent = acc.find(itm => itm.sku == currentObj.sku);
48
- if (existingParent) {
49
- existingParent.productDetails = [
50
- ...existingParent.productDetails,
51
- new product_detail_1.ProductDetail(Object.assign(Object.assign({}, currentObj), { childProductDetail: currentObj.childGtin }))
52
- ];
53
- return acc;
54
- }
55
- else {
56
- let newProduct = Object.assign(Object.assign({}, currentObj), { productDetails: [
57
- new product_detail_1.ProductDetail(Object.assign(Object.assign({}, currentObj), { childProductDetail: currentObj.childGtin, isDefault: true }))
58
- ] });
59
- return [...acc, newProduct];
60
- }
61
- }, []);
62
- //// 2. Update all Grouped Product data and Product Details Data
63
- for (let i = 0; i < massagedPatch.length; i++) {
64
- const patch = massagedPatch[i];
65
- const result = await createProduct(patch, context);
66
- results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
67
- }
68
- return results;
69
- }
70
- catch (error) {
71
- throw error;
72
- }
73
- }
74
- async updateMultipleProduct(patches, context) {
75
- try {
76
- let results = [];
77
- const _createRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === '+');
78
- const _updateRecords = patches.filter((patch) => patch.cuFlag.toUpperCase() === 'M');
79
- if (_createRecords.length > 0) {
80
- for (let i = 0; i < _createRecords.length; i++) {
81
- const patch = _createRecords[i];
82
- const result = await createProduct(patch, context);
83
- if (result.costPrice) {
84
- result.costPrice = result.costPrice.toFixed(2);
85
- }
86
- results.push(Object.assign(Object.assign({}, result), { cuFlag: '+' }));
87
- }
88
- }
89
- if (_updateRecords.length > 0) {
90
- for (let i = 0; i < _updateRecords.length; i++) {
91
- const patch = _updateRecords[i];
92
- const result = await updateProduct(patch.id, patch, context);
93
- if (result.costPrice) {
94
- result.costPrice = +result.costPrice.toFixed(2);
95
- }
96
- results.push(Object.assign(Object.assign({}, result), { cuFlag: 'M' }));
97
- }
98
- }
99
- return results;
100
- }
101
- catch (error) {
102
- throw error;
103
- }
104
- }
105
- async linkProduct(productSetId, patches, context) {
106
- const { tx } = context.state;
107
- let productSet = await tx.getRepository(product_set_1.ProductSet).findOne({
108
- where: { id: productSetId },
109
- relations: ['domain', 'creator', 'updater', 'product']
110
- });
111
- let existingProductLink = productSet.product;
112
- let newProductLink = patches.reduce((acc, curr) => {
113
- if (!existingProductLink.find(itm => itm.id == curr.id)) {
114
- acc.push({ id: curr.id });
115
- }
116
- return acc;
117
- }, []);
118
- let removeProductLink = existingProductLink.reduce((acc, curr) => {
119
- if (!patches.find(itm => itm.id == curr.id)) {
120
- acc.push({ id: curr.id });
121
- }
122
- return acc;
123
- }, []);
124
- if (newProductLink.length > 0) {
125
- for (let i = 0; i < newProductLink.length; i++) {
126
- const patch = Object.assign(Object.assign({}, newProductLink[i]), { productSet });
127
- await updateProduct(newProductLink[i].id, patch, context);
128
- }
129
- }
130
- if (removeProductLink.length > 0) {
131
- for (let i = 0; i < removeProductLink.length; i++) {
132
- const patch = Object.assign(Object.assign({}, removeProductLink[i]), { productSet: null });
133
- await updateProduct(removeProductLink[i].id, patch, context);
134
- }
135
- }
136
- return true;
137
- }
138
- async deleteProduct(id, context) {
139
- const { tx, user, domain } = context.state;
140
- const productSetRepo = tx.getRepository(product_1.Product);
141
- const productSet = await productSetRepo.findOne({ domain, id });
142
- await productSetRepo.save(Object.assign(Object.assign({}, productSet), { status: constants_1.PRODUCT_STATUS.DELETED, updater: user }));
143
- return true;
144
- }
145
- async deleteProducts(ids, context) {
146
- const { tx, user } = context.state;
147
- const productRepo = tx.getRepository(product_1.Product);
148
- await productRepo.update({
149
- id: (0, typeorm_1.In)(ids)
150
- }, {
151
- deletedAt: new Date()
152
- });
153
- return true;
154
- }
155
- async undeleteProducts(ids, context) {
156
- const { tx, user } = context.state;
157
- const productRepo = tx.getRepository(product_1.Product);
158
- await productRepo.update({
159
- id: (0, typeorm_1.In)(ids)
160
- }, {
161
- deletedAt: null
162
- });
163
- return true;
164
- }
165
- };
166
- __decorate([
167
- (0, type_graphql_1.Directive)('@transaction'),
168
- (0, type_graphql_1.Mutation)(returns => product_1.Product),
169
- __param(0, (0, type_graphql_1.Arg)('product')),
170
- __param(1, (0, type_graphql_1.Ctx)()),
171
- __metadata("design:type", Function),
172
- __metadata("design:paramtypes", [product_types_1.NewProduct, Object]),
173
- __metadata("design:returntype", Promise)
174
- ], ProductMutation.prototype, "createProduct", null);
175
- __decorate([
176
- (0, type_graphql_1.Directive)('@transaction'),
177
- (0, type_graphql_1.Mutation)(returns => [product_1.Product]),
178
- __param(0, (0, type_graphql_1.Arg)('products', type => [product_types_1.NewProduct])),
179
- __param(1, (0, type_graphql_1.Ctx)()),
180
- __metadata("design:type", Function),
181
- __metadata("design:paramtypes", [Array, Object]),
182
- __metadata("design:returntype", Promise)
183
- ], ProductMutation.prototype, "createProducts", null);
184
- __decorate([
185
- (0, type_graphql_1.Directive)('@transaction'),
186
- (0, type_graphql_1.Mutation)(returns => product_1.Product),
187
- __param(0, (0, type_graphql_1.Arg)('id')),
188
- __param(1, (0, type_graphql_1.Arg)('patch')),
189
- __param(2, (0, type_graphql_1.Ctx)()),
190
- __metadata("design:type", Function),
191
- __metadata("design:paramtypes", [String, product_types_1.ProductPatch, Object]),
192
- __metadata("design:returntype", Promise)
193
- ], ProductMutation.prototype, "updateProduct", null);
194
- __decorate([
195
- (0, type_graphql_1.Directive)('@transaction'),
196
- (0, type_graphql_1.Mutation)(returns => [product_1.Product]),
197
- __param(0, (0, type_graphql_1.Arg)('patches', type => [product_types_1.ProductPatch])),
198
- __param(1, (0, type_graphql_1.Ctx)()),
199
- __metadata("design:type", Function),
200
- __metadata("design:paramtypes", [Array, Object]),
201
- __metadata("design:returntype", Promise)
202
- ], ProductMutation.prototype, "importMultipleProduct", null);
203
- __decorate([
204
- (0, type_graphql_1.Directive)('@transaction'),
205
- (0, type_graphql_1.Mutation)(returns => [product_1.Product]),
206
- __param(0, (0, type_graphql_1.Arg)('patches', type => [product_types_1.ProductPatch])),
207
- __param(1, (0, type_graphql_1.Ctx)()),
208
- __metadata("design:type", Function),
209
- __metadata("design:paramtypes", [Array, Object]),
210
- __metadata("design:returntype", Promise)
211
- ], ProductMutation.prototype, "updateMultipleProduct", null);
212
- __decorate([
213
- (0, type_graphql_1.Directive)('@privilege(category: "order", privilege: "mutation") '),
214
- (0, type_graphql_1.Directive)('@transaction'),
215
- (0, type_graphql_1.Mutation)(returns => Boolean),
216
- __param(0, (0, type_graphql_1.Arg)('productSetId')),
217
- __param(1, (0, type_graphql_1.Arg)('patches', type => [product_types_1.ProductPatch])),
218
- __param(2, (0, type_graphql_1.Ctx)()),
219
- __metadata("design:type", Function),
220
- __metadata("design:paramtypes", [String, Array, Object]),
221
- __metadata("design:returntype", Promise)
222
- ], ProductMutation.prototype, "linkProduct", null);
223
- __decorate([
224
- (0, type_graphql_1.Directive)('@privilege(category: "order", privilege: "mutation") '),
225
- (0, type_graphql_1.Directive)('@transaction'),
226
- (0, type_graphql_1.Mutation)(returns => Boolean),
227
- __param(0, (0, type_graphql_1.Arg)('id')),
228
- __param(1, (0, type_graphql_1.Ctx)()),
229
- __metadata("design:type", Function),
230
- __metadata("design:paramtypes", [String, Object]),
231
- __metadata("design:returntype", Promise)
232
- ], ProductMutation.prototype, "deleteProduct", null);
233
- __decorate([
234
- (0, type_graphql_1.Directive)('@privilege(category: "order", privilege: "mutation") '),
235
- (0, type_graphql_1.Directive)('@transaction'),
236
- (0, type_graphql_1.Mutation)(returns => Boolean),
237
- __param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
238
- __param(1, (0, type_graphql_1.Ctx)()),
239
- __metadata("design:type", Function),
240
- __metadata("design:paramtypes", [Array, Object]),
241
- __metadata("design:returntype", Promise)
242
- ], ProductMutation.prototype, "deleteProducts", null);
243
- __decorate([
244
- (0, type_graphql_1.Directive)('@privilege(category: "order", privilege: "mutation") '),
245
- (0, type_graphql_1.Directive)('@transaction'),
246
- (0, type_graphql_1.Mutation)(returns => Boolean),
247
- __param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
248
- __param(1, (0, type_graphql_1.Ctx)()),
249
- __metadata("design:type", Function),
250
- __metadata("design:paramtypes", [Array, Object]),
251
- __metadata("design:returntype", Promise)
252
- ], ProductMutation.prototype, "undeleteProducts", null);
253
- ProductMutation = __decorate([
254
- (0, type_graphql_1.Resolver)(product_1.Product)
255
- ], ProductMutation);
256
- exports.ProductMutation = ProductMutation;
257
- async function createProduct(product, context) {
258
- var _a, _b, _c;
259
- try {
260
- const { domain, user, tx } = context.state;
261
- const productRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(product_1.Product)) || (0, typeorm_1.getRepository)(product_1.Product);
262
- const bizplaceRepo = (tx === null || tx === void 0 ? void 0 : tx.getRepository(biz_base_1.Bizplace)) || (0, typeorm_1.getRepository)(biz_base_1.Bizplace);
263
- let bizplace;
264
- if ((_a = product.bizplace) === null || _a === void 0 ? void 0 : _a.id) {
265
- bizplace = await bizplaceRepo.findOne(product.bizplace.id);
266
- }
267
- else if ((_b = context.state) === null || _b === void 0 ? void 0 : _b.bizplace) {
268
- bizplace = context.state.bizplace;
269
- }
270
- else {
271
- bizplace = await bizplaceRepo.findOne({ where: { domain } });
272
- }
273
- if ((_c = product === null || product === void 0 ? void 0 : product.productRef) === null || _c === void 0 ? void 0 : _c.id) {
274
- product.productRef = await productRepo.findOne(product.productRef.id);
275
- }
276
- let foundExistingProduct = await productRepo.findOne({ sku: product.sku, domain });
277
- if (foundExistingProduct) {
278
- throw new Error('Duplicated sku matching with existing products found');
279
- }
280
- if (!(product === null || product === void 0 ? void 0 : product.id))
281
- delete product.id;
282
- await (0, validate_product_1.validateProduct)(Object.assign(Object.assign({}, product), { bizplace,
283
- domain }), context);
284
- if (product.uom) {
285
- product.primaryUnit = product.uom;
286
- }
287
- if (product.uomValue) {
288
- product.primaryValue = product.uomValue;
289
- }
290
- const result = await productRepo.save(Object.assign(Object.assign({}, product), { bizplace,
291
- domain, creator: user, updater: user }));
292
- let productDetails;
293
- if (product.productDetails) {
294
- productDetails = product.productDetails.reduce((acc, currentObj) => {
295
- let existingProductDetail = acc.find(itm => itm.packingType == currentObj.packingType && itm.uom == currentObj.uom && itm.name == currentObj.name);
296
- if (existingProductDetail) {
297
- existingProductDetail.productBarcodes = [...existingProductDetail.productBarcodes, { gtin: currentObj.gtin }];
298
- return acc;
299
- }
300
- else {
301
- let newProductDetail = Object.assign(Object.assign({}, currentObj), { productBarcodes: currentObj.productBarcodes ? [...currentObj.productBarcodes] : [{ gtin: currentObj.gtin }] });
302
- return [...acc, newProductDetail];
303
- }
304
- }, []);
305
- }
306
- else {
307
- productDetails = [new product_detail_1.ProductDetail(Object.assign(Object.assign({}, product), { product: result, isDefault: true }))];
308
- if (!productDetails[0].productBarcodes || productDetails[0].productBarcodes.length < 1) {
309
- productDetails[0].productBarcodes = [{ gtin: product.gtin ? product.gtin : product.sku }];
310
- }
311
- }
312
- productDetails.map((pd, index) => {
313
- const count = index + 1;
314
- pd.refCode = pd.refCode && pd.refCode !== '' ? pd.refCode : product.sku + '-000' + count;
315
- });
316
- await (0, product_detail_mutation_1.updateMultipleProductDetail)(result.id, productDetails, context);
317
- if (product.thumbnail) {
318
- await (0, attachment_base_1.createAttachment)(null, {
319
- attachment: {
320
- file: product.thumbnail,
321
- refBy: result.id
322
- }
323
- }, context);
324
- }
325
- return result;
326
- }
327
- catch (error) {
328
- throw error;
329
- }
330
- }
331
- exports.createProduct = createProduct;
332
- async function createProducts(products, context) {
333
- const { resolve, reject } = await promises_all_1.default.all(products.map(product => createProduct(product, context)));
334
- if (reject.length) {
335
- reject.forEach(({ name, message }) => env_1.logger.error(`${name}: ${message}`));
336
- return reject;
337
- }
338
- return resolve;
339
- }
340
- exports.createProducts = createProducts;
341
- async function updateProduct(id, patch, context) {
342
- var _a;
343
- try {
344
- const { user, tx, domain } = context.state;
345
- const bizplaceRepo = tx.getRepository(biz_base_1.Bizplace);
346
- const productRepo = tx.getRepository(product_1.Product);
347
- const productDetailRepo = tx.getRepository(product_detail_1.ProductDetail);
348
- let product = await productRepo.findOne({ where: { id }, relations: ['domain'] });
349
- let productDetail = await productDetailRepo.findOne({
350
- where: { product: { id }, isDefault: true },
351
- relations: ['domain']
352
- });
353
- let multipleProductDetail;
354
- if (Array.isArray(patch.productDetails)) {
355
- multipleProductDetail = await productDetailRepo.find({
356
- where: { product: { id } },
357
- relations: ['domain']
358
- });
359
- }
360
- if (patch.productRef && patch.productRef.id) {
361
- patch.productRef = await productRepo.findOne(patch.productRef.id);
362
- }
363
- let bizplace;
364
- if ((_a = product.bizplace) === null || _a === void 0 ? void 0 : _a.id) {
365
- bizplace = await bizplaceRepo.findOne(product.bizplace.id);
366
- }
367
- else {
368
- bizplace = await bizplaceRepo.findOne({ where: { name: domain.name } });
369
- }
370
- await (0, validate_product_1.validateProduct)(Object.assign(Object.assign(Object.assign({}, product), patch), { bizplace,
371
- domain }), context);
372
- if (patch.uom) {
373
- product.primaryUnit = patch.uom;
374
- }
375
- if (patch.uomValue) {
376
- product.primaryValue = patch.uomValue;
377
- }
378
- product = await productRepo.save(Object.assign(Object.assign(Object.assign({}, product), patch), { domain, updater: user }));
379
- if (Array.isArray(patch.productDetails)) {
380
- await (0, product_detail_mutation_1.updateMultipleProductDetail)(product.id, patch.productDetails, context, multipleProductDetail);
381
- }
382
- else if (productDetail) {
383
- if (product.gtin) {
384
- delete product.gtin;
385
- }
386
- productDetail = await (0, product_detail_mutation_1.updateProductDetail)(productDetail.id, new product_detail_1.ProductDetail(Object.assign(Object.assign(Object.assign({}, product), patch), { product })), context);
387
- }
388
- else {
389
- productDetail = await (0, product_detail_mutation_1.createProductDetail)(new product_detail_1.ProductDetail(Object.assign(Object.assign(Object.assign({}, product), patch), { product, isDefault: true })), context);
390
- }
391
- const productId = id;
392
- if (patch.thumbnail) {
393
- await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [productId] }, context);
394
- await (0, attachment_base_1.createAttachment)(null, {
395
- attachment: {
396
- file: patch.thumbnail,
397
- refBy: product.id
398
- }
399
- }, context);
400
- }
401
- return product;
402
- }
403
- catch (error) {
404
- throw error;
405
- }
406
- }
407
- exports.updateProduct = updateProduct;
408
- //# sourceMappingURL=product-mutation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"product-mutation.js","sourceRoot":"","sources":["../../../server/service/product/product-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,gEAAsC;AACtC,+CAAsE;AACtE,qCAAsE;AAEtE,qEAA0F;AAE1F,uDAAmD;AACnD,6CAA4C;AAG5C,+CAAgD;AAChD,qEAAgE;AAChE,uFAIkD;AAClD,4DAAuD;AACvD,uCAAmC;AACnC,mDAA0D;AAC1D,yDAAoD;AAG7C,IAAM,eAAe,GAArB,MAAM,eAAe;IAGpB,AAAN,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