@things-factory/product-base 4.3.654 → 4.3.671

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 (112) hide show
  1. package/package.json +4 -4
  2. package/server/service/product-detail/product-detail-query.ts +1 -0
  3. package/dist-server/constants/index.js +0 -18
  4. package/dist-server/constants/index.js.map +0 -1
  5. package/dist-server/constants/product.js +0 -25
  6. package/dist-server/constants/product.js.map +0 -1
  7. package/dist-server/controllers/index.js +0 -1
  8. package/dist-server/controllers/index.js.map +0 -1
  9. package/dist-server/index.js +0 -19
  10. package/dist-server/index.js.map +0 -1
  11. package/dist-server/middlewares/index.js +0 -1
  12. package/dist-server/middlewares/index.js.map +0 -1
  13. package/dist-server/migrations/index.js +0 -12
  14. package/dist-server/migrations/index.js.map +0 -1
  15. package/dist-server/service/index.js +0 -74
  16. package/dist-server/service/index.js.map +0 -1
  17. package/dist-server/service/product/index.js +0 -10
  18. package/dist-server/service/product/index.js.map +0 -1
  19. package/dist-server/service/product/product-mutation.js +0 -408
  20. package/dist-server/service/product/product-mutation.js.map +0 -1
  21. package/dist-server/service/product/product-query.js +0 -373
  22. package/dist-server/service/product/product-query.js.map +0 -1
  23. package/dist-server/service/product/product-types.js +0 -618
  24. package/dist-server/service/product/product-types.js.map +0 -1
  25. package/dist-server/service/product/product.js +0 -615
  26. package/dist-server/service/product/product.js.map +0 -1
  27. package/dist-server/service/product/validate-product.js +0 -26
  28. package/dist-server/service/product/validate-product.js.map +0 -1
  29. package/dist-server/service/product-barcode/index.js +0 -9
  30. package/dist-server/service/product-barcode/index.js.map +0 -1
  31. package/dist-server/service/product-barcode/product-barcode-mutation.js +0 -120
  32. package/dist-server/service/product-barcode/product-barcode-mutation.js.map +0 -1
  33. package/dist-server/service/product-barcode/product-barcode-query.js +0 -87
  34. package/dist-server/service/product-barcode/product-barcode-query.js.map +0 -1
  35. package/dist-server/service/product-barcode/product-barcode-type.js +0 -63
  36. package/dist-server/service/product-barcode/product-barcode-type.js.map +0 -1
  37. package/dist-server/service/product-barcode/product-barcode.js +0 -104
  38. package/dist-server/service/product-barcode/product-barcode.js.map +0 -1
  39. package/dist-server/service/product-bundle/index.js +0 -9
  40. package/dist-server/service/product-bundle/index.js.map +0 -1
  41. package/dist-server/service/product-bundle/product-bundle-mutation.js +0 -130
  42. package/dist-server/service/product-bundle/product-bundle-mutation.js.map +0 -1
  43. package/dist-server/service/product-bundle/product-bundle-query.js +0 -128
  44. package/dist-server/service/product-bundle/product-bundle-query.js.map +0 -1
  45. package/dist-server/service/product-bundle/product-bundle-types.js +0 -85
  46. package/dist-server/service/product-bundle/product-bundle-types.js.map +0 -1
  47. package/dist-server/service/product-bundle/product-bundle.js +0 -128
  48. package/dist-server/service/product-bundle/product-bundle.js.map +0 -1
  49. package/dist-server/service/product-bundle-setting/index.js +0 -9
  50. package/dist-server/service/product-bundle-setting/index.js.map +0 -1
  51. package/dist-server/service/product-bundle-setting/product-bundle-setting-mutation.js +0 -165
  52. package/dist-server/service/product-bundle-setting/product-bundle-setting-mutation.js.map +0 -1
  53. package/dist-server/service/product-bundle-setting/product-bundle-setting-query.js +0 -113
  54. package/dist-server/service/product-bundle-setting/product-bundle-setting-query.js.map +0 -1
  55. package/dist-server/service/product-bundle-setting/product-bundle-setting-types.js +0 -69
  56. package/dist-server/service/product-bundle-setting/product-bundle-setting-types.js.map +0 -1
  57. package/dist-server/service/product-bundle-setting/product-bundle-setting.js +0 -63
  58. package/dist-server/service/product-bundle-setting/product-bundle-setting.js.map +0 -1
  59. package/dist-server/service/product-combination/index.js +0 -9
  60. package/dist-server/service/product-combination/index.js.map +0 -1
  61. package/dist-server/service/product-combination/product-combination-mutation.js +0 -137
  62. package/dist-server/service/product-combination/product-combination-mutation.js.map +0 -1
  63. package/dist-server/service/product-combination/product-combination-query.js +0 -86
  64. package/dist-server/service/product-combination/product-combination-query.js.map +0 -1
  65. package/dist-server/service/product-combination/product-combination-type.js +0 -83
  66. package/dist-server/service/product-combination/product-combination-type.js.map +0 -1
  67. package/dist-server/service/product-combination/product-combination.js +0 -133
  68. package/dist-server/service/product-combination/product-combination.js.map +0 -1
  69. package/dist-server/service/product-combination-setting/index.js +0 -9
  70. package/dist-server/service/product-combination-setting/index.js.map +0 -1
  71. package/dist-server/service/product-combination-setting/product-combination-setting-mutation.js +0 -221
  72. package/dist-server/service/product-combination-setting/product-combination-setting-mutation.js.map +0 -1
  73. package/dist-server/service/product-combination-setting/product-combination-setting-query.js +0 -177
  74. package/dist-server/service/product-combination-setting/product-combination-setting-query.js.map +0 -1
  75. package/dist-server/service/product-combination-setting/product-combination-setting-type.js +0 -75
  76. package/dist-server/service/product-combination-setting/product-combination-setting-type.js.map +0 -1
  77. package/dist-server/service/product-combination-setting/product-combination-setting.js +0 -105
  78. package/dist-server/service/product-combination-setting/product-combination-setting.js.map +0 -1
  79. package/dist-server/service/product-detail/index.js +0 -9
  80. package/dist-server/service/product-detail/index.js.map +0 -1
  81. package/dist-server/service/product-detail/product-detail-mutation.js +0 -374
  82. package/dist-server/service/product-detail/product-detail-mutation.js.map +0 -1
  83. package/dist-server/service/product-detail/product-detail-query.js +0 -223
  84. package/dist-server/service/product-detail/product-detail-query.js.map +0 -1
  85. package/dist-server/service/product-detail/product-detail-types.js +0 -392
  86. package/dist-server/service/product-detail/product-detail-types.js.map +0 -1
  87. package/dist-server/service/product-detail/product-detail.js +0 -444
  88. package/dist-server/service/product-detail/product-detail.js.map +0 -1
  89. package/dist-server/service/product-detail-bizplace-setting/index.js +0 -9
  90. package/dist-server/service/product-detail-bizplace-setting/index.js.map +0 -1
  91. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-mutation.js +0 -118
  92. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-mutation.js.map +0 -1
  93. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-query.js +0 -107
  94. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-query.js.map +0 -1
  95. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-types.js +0 -99
  96. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-types.js.map +0 -1
  97. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting.js +0 -120
  98. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting.js.map +0 -1
  99. package/dist-server/service/product-set/index.js +0 -9
  100. package/dist-server/service/product-set/index.js.map +0 -1
  101. package/dist-server/service/product-set/product-set-mutation.js +0 -146
  102. package/dist-server/service/product-set/product-set-mutation.js.map +0 -1
  103. package/dist-server/service/product-set/product-set-query.js +0 -136
  104. package/dist-server/service/product-set/product-set-query.js.map +0 -1
  105. package/dist-server/service/product-set/product-set-types.js +0 -77
  106. package/dist-server/service/product-set/product-set-types.js.map +0 -1
  107. package/dist-server/service/product-set/product-set.js +0 -118
  108. package/dist-server/service/product-set/product-set.js.map +0 -1
  109. package/dist-server/utils/index.js +0 -18
  110. package/dist-server/utils/index.js.map +0 -1
  111. package/dist-server/utils/product-util.js +0 -16
  112. package/dist-server/utils/product-util.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/product-base",
3
- "version": "4.3.654",
3
+ "version": "4.3.671",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -23,8 +23,8 @@
23
23
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
24
24
  },
25
25
  "dependencies": {
26
- "@things-factory/biz-base": "^4.3.595",
27
- "@things-factory/routing-base": "^4.3.591"
26
+ "@things-factory/biz-base": "^4.3.671",
27
+ "@things-factory/routing-base": "^4.3.671"
28
28
  },
29
- "gitHead": "c5d37a4840c0af0a8ff131858cef69732ed284f5"
29
+ "gitHead": "ef524cb207378186ec71917d9a8546363d4300b2"
30
30
  }
@@ -171,6 +171,7 @@ export class ProductDetailQuery {
171
171
  sku: item.product.sku,
172
172
  brand: item.product.brand,
173
173
  brandSku: item.product.brandSku,
174
+ isRequiredCheckExpiry: item.product.isRequiredCheckExpiry,
174
175
  isRequireSerialNumberScanningInbound: item.product.isRequireSerialNumberScanningInbound,
175
176
  isRequireSerialNumberScanningOutbound: item.product.isRequireSerialNumberScanningOutbound,
176
177
  costPrice: item?.costPrice || item?.costPrice == 0 ? parseFloat(item.costPrice.toFixed(2)) : null
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./product"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB"}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PRODUCT_COMBINATION_STATUS = exports.PRODUCT_BUNDLE_STATUS = exports.PRODUCT_SET_STATUS = exports.PRODUCT_STATUS = void 0;
4
- exports.PRODUCT_STATUS = {
5
- ACTIVE: 'ACTIVE',
6
- DELETED: 'DELETED',
7
- INACTIVE: 'INACTIVE'
8
- };
9
- exports.PRODUCT_SET_STATUS = {
10
- ACTIVE: 'ACTIVE',
11
- DELETED: 'DELETED',
12
- INACTIVE: 'INACTIVE'
13
- };
14
- exports.PRODUCT_BUNDLE_STATUS = {
15
- ACTIVE: 'ACTIVE',
16
- DELETED: 'DELETED',
17
- INACTIVE: 'INACTIVE'
18
- };
19
- exports.PRODUCT_COMBINATION_STATUS = {
20
- ACTIVE: 'ACTIVE',
21
- ACTIVATED: 'ACTIVATED',
22
- DELETED: 'DELETED',
23
- INACTIVE: 'INACTIVE'
24
- };
25
- //# sourceMappingURL=product.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"product.js","sourceRoot":"","sources":["../../server/constants/product.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG;IAC5B,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;CACrB,CAAA;AAEY,QAAA,kBAAkB,GAAG;IAChC,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;CACrB,CAAA;AAEY,QAAA,qBAAqB,GAAG;IACnC,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;CACrB,CAAA;AAEY,QAAA,0BAA0B,GAAG;IACxC,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;IACtB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;CACrB,CAAA"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/controllers/index.ts"],"names":[],"mappings":""}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./service"), exports);
18
- __exportStar(require("./migrations"), exports);
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,+CAA4B"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/middlewares/index.ts"],"names":[],"mappings":""}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.migrations = void 0;
4
- const glob = require('glob');
5
- const path = require('path');
6
- exports.migrations = [];
7
- glob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function (file) {
8
- if (file.indexOf('index.js') !== -1)
9
- return;
10
- exports.migrations = exports.migrations.concat(Object.values(require(path.resolve(file))) || []);
11
- });
12
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/migrations/index.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEjB,QAAA,UAAU,GAAG,EAAE,CAAA;AAE1B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAS,IAAI;IACzE,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAAE,OAAM;IAC3C,kBAAU,GAAG,kBAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;AAClF,CAAC,CAAC,CAAA"}
@@ -1,74 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.updateProduct = exports.createProduct = exports.schema = exports.entities = void 0;
18
- const product_1 = require("./product");
19
- const product_bundle_1 = require("./product-bundle");
20
- const product_bundle_setting_1 = require("./product-bundle-setting");
21
- const product_detail_1 = require("./product-detail");
22
- const product_detail_bizplace_setting_1 = require("./product-detail-bizplace-setting");
23
- const product_set_1 = require("./product-set");
24
- const product_combination_1 = require("./product-combination");
25
- const product_combination_setting_1 = require("./product-combination-setting");
26
- const product_barcode_1 = require("./product-barcode");
27
- /* EXPORT ENTITY TYPES */
28
- __exportStar(require("./product-barcode/product-barcode"), exports);
29
- __exportStar(require("./product-combination-setting/product-combination-setting"), exports);
30
- __exportStar(require("./product-combination/product-combination"), exports);
31
- __exportStar(require("./product/product"), exports);
32
- __exportStar(require("./product-detail/product-detail"), exports);
33
- __exportStar(require("./product-bundle/product-bundle"), exports);
34
- __exportStar(require("./product-bundle-setting/product-bundle-setting"), exports);
35
- __exportStar(require("./product-detail-bizplace-setting/product-detail-bizplace-setting"), exports);
36
- __exportStar(require("./product-set/product-set"), exports);
37
- /* EXPORT TYPES */
38
- __exportStar(require("./product-barcode/product-barcode-type"), exports);
39
- __exportStar(require("./product-combination/product-combination-type"), exports);
40
- __exportStar(require("./product-combination-setting/product-combination-setting-type"), exports);
41
- __exportStar(require("./product/product-types"), exports);
42
- __exportStar(require("./product-detail/product-detail-types"), exports);
43
- __exportStar(require("./product-bundle/product-bundle-types"), exports);
44
- __exportStar(require("./product-bundle-setting/product-bundle-setting-types"), exports);
45
- __exportStar(require("./product-detail-bizplace-setting/product-detail-bizplace-setting-types"), exports);
46
- __exportStar(require("./product-set/product-set-types"), exports);
47
- exports.entities = [
48
- ...product_1.entities,
49
- ...product_detail_1.entities,
50
- ...product_bundle_1.entities,
51
- ...product_bundle_setting_1.entities,
52
- ...product_detail_bizplace_setting_1.entities,
53
- ...product_set_1.entities,
54
- ...product_combination_1.entities,
55
- ...product_combination_setting_1.entities,
56
- ...product_barcode_1.entities
57
- ];
58
- exports.schema = {
59
- resolverClasses: [
60
- ...product_1.resolvers,
61
- ...product_detail_1.resolvers,
62
- ...product_bundle_1.resolvers,
63
- ...product_bundle_setting_1.resolvers,
64
- ...product_detail_bizplace_setting_1.resolvers,
65
- ...product_set_1.resolvers,
66
- ...product_combination_1.resolvers,
67
- ...product_combination_setting_1.resolvers,
68
- ...product_barcode_1.resolvers
69
- ]
70
- };
71
- var product_mutation_1 = require("./product/product-mutation");
72
- Object.defineProperty(exports, "createProduct", { enumerable: true, get: function () { return product_mutation_1.createProduct; } });
73
- Object.defineProperty(exports, "updateProduct", { enumerable: true, get: function () { return product_mutation_1.updateProduct; } });
74
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAsF;AACtF,qDAAyG;AACzG,qEAGiC;AACjC,qDAAyG;AACzG,uFAG0C;AAC1C,+CAAgG;AAChG,+DAAwH;AACxH,+EAGsC;AACtC,uDAA4G;AAG5G,yBAAyB;AACzB,oEAAiD;AACjD,4FAAyE;AACzE,4EAAyD;AACzD,oDAAiC;AACjC,kEAA+C;AAC/C,kEAA+C;AAC/C,kFAA+D;AAC/D,oGAAiF;AACjF,4DAAyC;AAEzC,kBAAkB;AAClB,yEAAsD;AACtD,iFAA8D;AAC9D,iGAA8E;AAC9E,0DAAuC;AACvC,wEAAqD;AACrD,wEAAqD;AACrD,wFAAqE;AACrE,0GAAuF;AACvF,kEAA+C;AAElC,QAAA,QAAQ,GAAG;IACtB,GAAG,kBAAe;IAClB,GAAG,yBAAqB;IACxB,GAAG,yBAAqB;IACxB,GAAG,iCAA4B;IAC/B,GAAG,0CAAoC;IACvC,GAAG,sBAAkB;IACrB,GAAG,8BAA0B;IAC7B,GAAG,sCAAiC;IACpC,GAAG,0BAAsB;CAC1B,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,GAAG,mBAAgB;QACnB,GAAG,0BAAsB;QACzB,GAAG,0BAAsB;QACzB,GAAG,kCAA6B;QAChC,GAAG,2CAAoC;QACvC,GAAG,uBAAmB;QACtB,GAAG,+BAA2B;QAC9B,GAAG,uCAAkC;QACrC,GAAG,2BAAuB;KAC3B;CACF,CAAA;AAED,+DAAyE;AAAhE,iHAAA,aAAa,OAAA;AAAE,iHAAA,aAAa,OAAA"}
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolvers = exports.entities = void 0;
4
- const product_1 = require("./product");
5
- const product_mutation_1 = require("./product-mutation");
6
- const product_query_1 = require("./product-query");
7
- exports.entities = [product_1.Product];
8
- exports.resolvers = [product_query_1.ProductQuery, product_mutation_1.ProductMutation];
9
- //product entity
10
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/service/product/index.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AACnC,yDAAoD;AACpD,mDAA8C;AAEjC,QAAA,QAAQ,GAAG,CAAC,iBAAO,CAAC,CAAA;AACpB,QAAA,SAAS,GAAG,CAAC,4BAAY,EAAE,kCAAe,CAAC,CAAA;AAExD,gBAAgB"}
@@ -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