@things-factory/product-base 6.2.177 → 6.2.178

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 (119) hide show
  1. package/dist-server/constants/index.d.ts +1 -0
  2. package/dist-server/constants/product.d.ts +21 -0
  3. package/dist-server/controllers/index.d.ts +0 -0
  4. package/dist-server/index.d.ts +2 -0
  5. package/dist-server/middlewares/index.d.ts +0 -0
  6. package/dist-server/migrations/index.d.ts +1 -0
  7. package/dist-server/service/index.d.ts +20 -0
  8. package/dist-server/service/product/index.d.ts +5 -0
  9. package/dist-server/service/product/product-mutation.d.ts +16 -0
  10. package/dist-server/service/product/product-mutation.js +6 -6
  11. package/dist-server/service/product/product-mutation.js.map +1 -1
  12. package/dist-server/service/product/product-query.d.ts +28 -0
  13. package/dist-server/service/product/product-query.js +2 -2
  14. package/dist-server/service/product/product-query.js.map +1 -1
  15. package/dist-server/service/product/product-types.d.ts +151 -0
  16. package/dist-server/service/product/product-types.js +7 -8
  17. package/dist-server/service/product/product-types.js.map +1 -1
  18. package/dist-server/service/product/product.d.ts +112 -0
  19. package/dist-server/service/product/product.js +10 -12
  20. package/dist-server/service/product/product.js.map +1 -1
  21. package/dist-server/service/product/validate-product.d.ts +2 -0
  22. package/dist-server/service/product/validate-product.js +1 -2
  23. package/dist-server/service/product/validate-product.js.map +1 -1
  24. package/dist-server/service/product-bundle/index.d.ts +5 -0
  25. package/dist-server/service/product-bundle/product-bundle-mutation.d.ts +9 -0
  26. package/dist-server/service/product-bundle/product-bundle-mutation.js +2 -2
  27. package/dist-server/service/product-bundle/product-bundle-mutation.js.map +1 -1
  28. package/dist-server/service/product-bundle/product-bundle-query.d.ts +12 -0
  29. package/dist-server/service/product-bundle/product-bundle-query.js +2 -2
  30. package/dist-server/service/product-bundle/product-bundle-query.js.map +1 -1
  31. package/dist-server/service/product-bundle/product-bundle-types.d.ts +20 -0
  32. package/dist-server/service/product-bundle/product-bundle-types.js +6 -6
  33. package/dist-server/service/product-bundle/product-bundle-types.js.map +1 -1
  34. package/dist-server/service/product-bundle/product-bundle.d.ts +25 -0
  35. package/dist-server/service/product-bundle/product-bundle.js +3 -4
  36. package/dist-server/service/product-bundle/product-bundle.js.map +1 -1
  37. package/dist-server/service/product-bundle-setting/index.d.ts +5 -0
  38. package/dist-server/service/product-bundle-setting/product-bundle-setting-mutation.d.ts +10 -0
  39. package/dist-server/service/product-bundle-setting/product-bundle-setting-mutation.js +4 -4
  40. package/dist-server/service/product-bundle-setting/product-bundle-setting-mutation.js.map +1 -1
  41. package/dist-server/service/product-bundle-setting/product-bundle-setting-query.d.ts +6 -0
  42. package/dist-server/service/product-bundle-setting/product-bundle-setting-query.js +2 -2
  43. package/dist-server/service/product-bundle-setting/product-bundle-setting-query.js.map +1 -1
  44. package/dist-server/service/product-bundle-setting/product-bundle-setting-types.d.ts +16 -0
  45. package/dist-server/service/product-bundle-setting/product-bundle-setting-types.js +4 -4
  46. package/dist-server/service/product-bundle-setting/product-bundle-setting-types.js.map +1 -1
  47. package/dist-server/service/product-bundle-setting/product-bundle-setting.d.ts +12 -0
  48. package/dist-server/service/product-bundle-setting/product-bundle-setting.js +2 -2
  49. package/dist-server/service/product-bundle-setting/product-bundle-setting.js.map +1 -1
  50. package/dist-server/service/product-combination/index.d.ts +5 -0
  51. package/dist-server/service/product-combination/product-combination-mutation.d.ts +9 -0
  52. package/dist-server/service/product-combination/product-combination-mutation.js +2 -2
  53. package/dist-server/service/product-combination/product-combination-mutation.js.map +1 -1
  54. package/dist-server/service/product-combination/product-combination-query.d.ts +11 -0
  55. package/dist-server/service/product-combination/product-combination-query.js +2 -2
  56. package/dist-server/service/product-combination/product-combination-query.js.map +1 -1
  57. package/dist-server/service/product-combination/product-combination-type.d.ts +20 -0
  58. package/dist-server/service/product-combination/product-combination-type.js +6 -6
  59. package/dist-server/service/product-combination/product-combination-type.js.map +1 -1
  60. package/dist-server/service/product-combination/product-combination.d.ts +33 -0
  61. package/dist-server/service/product-combination/product-combination.js +3 -3
  62. package/dist-server/service/product-combination/product-combination.js.map +1 -1
  63. package/dist-server/service/product-combination-setting/index.d.ts +5 -0
  64. package/dist-server/service/product-combination-setting/product-combination-setting-mutation.d.ts +11 -0
  65. package/dist-server/service/product-combination-setting/product-combination-setting-mutation.js +4 -4
  66. package/dist-server/service/product-combination-setting/product-combination-setting-mutation.js.map +1 -1
  67. package/dist-server/service/product-combination-setting/product-combination-setting-query.d.ts +14 -0
  68. package/dist-server/service/product-combination-setting/product-combination-setting-query.js +2 -2
  69. package/dist-server/service/product-combination-setting/product-combination-setting-query.js.map +1 -1
  70. package/dist-server/service/product-combination-setting/product-combination-setting-type.d.ts +18 -0
  71. package/dist-server/service/product-combination-setting/product-combination-setting-type.js +6 -6
  72. package/dist-server/service/product-combination-setting/product-combination-setting-type.js.map +1 -1
  73. package/dist-server/service/product-combination-setting/product-combination-setting.d.ts +22 -0
  74. package/dist-server/service/product-combination-setting/product-combination-setting.js +2 -2
  75. package/dist-server/service/product-combination-setting/product-combination-setting.js.map +1 -1
  76. package/dist-server/service/product-detail/index.d.ts +5 -0
  77. package/dist-server/service/product-detail/product-detail-mutation.d.ts +11 -0
  78. package/dist-server/service/product-detail/product-detail-mutation.js +18 -23
  79. package/dist-server/service/product-detail/product-detail-mutation.js.map +1 -1
  80. package/dist-server/service/product-detail/product-detail-query.d.ts +12 -0
  81. package/dist-server/service/product-detail/product-detail-query.js +2 -2
  82. package/dist-server/service/product-detail/product-detail-query.js.map +1 -1
  83. package/dist-server/service/product-detail/product-detail-types.d.ts +98 -0
  84. package/dist-server/service/product-detail/product-detail-types.js +6 -6
  85. package/dist-server/service/product-detail/product-detail-types.js.map +1 -1
  86. package/dist-server/service/product-detail/product-detail.d.ts +121 -0
  87. package/dist-server/service/product-detail/product-detail.js +7 -8
  88. package/dist-server/service/product-detail/product-detail.js.map +1 -1
  89. package/dist-server/service/product-detail-bizplace-setting/index.d.ts +5 -0
  90. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-mutation.d.ts +8 -0
  91. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-mutation.js +2 -2
  92. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-mutation.js.map +1 -1
  93. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-query.d.ts +11 -0
  94. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-query.js +2 -2
  95. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-query.js.map +1 -1
  96. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-types.d.ts +24 -0
  97. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-types.js +6 -6
  98. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting-types.js.map +1 -1
  99. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting.d.ts +34 -0
  100. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting.js +2 -2
  101. package/dist-server/service/product-detail-bizplace-setting/product-detail-bizplace-setting.js.map +1 -1
  102. package/dist-server/service/product-set/index.d.ts +5 -0
  103. package/dist-server/service/product-set/product-set-mutation.d.ts +39 -0
  104. package/dist-server/service/product-set/product-set-mutation.js +5 -5
  105. package/dist-server/service/product-set/product-set-mutation.js.map +1 -1
  106. package/dist-server/service/product-set/product-set-query.d.ts +12 -0
  107. package/dist-server/service/product-set/product-set-query.js +2 -2
  108. package/dist-server/service/product-set/product-set-query.js.map +1 -1
  109. package/dist-server/service/product-set/product-set-types.d.ts +18 -0
  110. package/dist-server/service/product-set/product-set-types.js +6 -6
  111. package/dist-server/service/product-set/product-set-types.js.map +1 -1
  112. package/dist-server/service/product-set/product-set.d.ts +22 -0
  113. package/dist-server/service/product-set/product-set.js +3 -4
  114. package/dist-server/service/product-set/product-set.js.map +1 -1
  115. package/dist-server/tsconfig.tsbuildinfo +1 -1
  116. package/dist-server/utils/index.d.ts +1 -0
  117. package/dist-server/utils/product-util.d.ts +3 -0
  118. package/package.json +4 -4
  119. package/server/service/product/product.ts +1 -1
@@ -7,6 +7,7 @@ const shell_1 = require("@things-factory/shell");
7
7
  const product_combination_setting_1 = require("./product-combination-setting");
8
8
  let NewProductCombinationSetting = class NewProductCombinationSetting {
9
9
  };
10
+ exports.NewProductCombinationSetting = NewProductCombinationSetting;
10
11
  tslib_1.__decorate([
11
12
  (0, type_graphql_1.Field)(),
12
13
  tslib_1.__metadata("design:type", String)
@@ -15,12 +16,12 @@ tslib_1.__decorate([
15
16
  (0, type_graphql_1.Field)({ nullable: true }),
16
17
  tslib_1.__metadata("design:type", String)
17
18
  ], NewProductCombinationSetting.prototype, "description", void 0);
18
- NewProductCombinationSetting = tslib_1.__decorate([
19
+ exports.NewProductCombinationSetting = NewProductCombinationSetting = tslib_1.__decorate([
19
20
  (0, type_graphql_1.InputType)()
20
21
  ], NewProductCombinationSetting);
21
- exports.NewProductCombinationSetting = NewProductCombinationSetting;
22
22
  let ProductCombinationSettingPatch = class ProductCombinationSettingPatch {
23
23
  };
24
+ exports.ProductCombinationSettingPatch = ProductCombinationSettingPatch;
24
25
  tslib_1.__decorate([
25
26
  (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
26
27
  tslib_1.__metadata("design:type", String)
@@ -45,12 +46,12 @@ tslib_1.__decorate([
45
46
  (0, type_graphql_1.Field)({ nullable: true }),
46
47
  tslib_1.__metadata("design:type", String)
47
48
  ], ProductCombinationSettingPatch.prototype, "cuFlag", void 0);
48
- ProductCombinationSettingPatch = tslib_1.__decorate([
49
+ exports.ProductCombinationSettingPatch = ProductCombinationSettingPatch = tslib_1.__decorate([
49
50
  (0, type_graphql_1.InputType)()
50
51
  ], ProductCombinationSettingPatch);
51
- exports.ProductCombinationSettingPatch = ProductCombinationSettingPatch;
52
52
  let ProductCombinationSettingList = class ProductCombinationSettingList {
53
53
  };
54
+ exports.ProductCombinationSettingList = ProductCombinationSettingList;
54
55
  tslib_1.__decorate([
55
56
  (0, type_graphql_1.Field)(type => [product_combination_setting_1.ProductCombinationSetting]),
56
57
  tslib_1.__metadata("design:type", Array)
@@ -59,8 +60,7 @@ tslib_1.__decorate([
59
60
  (0, type_graphql_1.Field)(type => type_graphql_1.Int),
60
61
  tslib_1.__metadata("design:type", Number)
61
62
  ], ProductCombinationSettingList.prototype, "total", void 0);
62
- ProductCombinationSettingList = tslib_1.__decorate([
63
+ exports.ProductCombinationSettingList = ProductCombinationSettingList = tslib_1.__decorate([
63
64
  (0, type_graphql_1.ObjectType)()
64
65
  ], ProductCombinationSettingList);
65
- exports.ProductCombinationSettingList = ProductCombinationSettingList;
66
66
  //# sourceMappingURL=product-combination-setting-type.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"product-combination-setting-type.js","sourceRoot":"","sources":["../../../server/service/product-combination-setting/product-combination-setting-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,iDAAiD;AAEjD,+EAAyE;AAGlE,IAAM,4BAA4B,GAAlC,MAAM,4BAA4B;CAMxC,CAAA;AALC;IAAC,IAAA,oBAAK,GAAE;;0DACI;AAEZ;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iEACN;AALT,4BAA4B;IADxC,IAAA,wBAAS,GAAE;GACC,4BAA4B,CAMxC;AANY,oEAA4B;AASlC,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;CAkB1C,CAAA;AAjBC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0DAC3B;AAEX;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAChB,iBAAS;+DAAA;AAEnB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACV,iBAAS;qEAAA;AAEzB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACL,iBAAS;0EAAA;AAE9B;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;2DACR;AAEX;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8DACX;AAjBJ,8BAA8B;IAD1C,IAAA,wBAAS,GAAE;GACC,8BAA8B,CAkB1C;AAlBY,wEAA8B;AAqBpC,IAAM,6BAA6B,GAAnC,MAAM,6BAA6B;CAMzC,CAAA;AALC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,uDAAyB,CAAC,CAAC;;4DACT;AAElC;IAAC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;4DACN;AALF,6BAA6B;IADzC,IAAA,yBAAU,GAAE;GACA,6BAA6B,CAMzC;AANY,sEAA6B","sourcesContent":["import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { ObjectRef } from '@things-factory/shell'\n\nimport { ProductCombinationSetting } from './product-combination-setting'\n\n@InputType()\nexport class NewProductCombinationSetting {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n}\n\n@InputType()\nexport class ProductCombinationSettingPatch {\n @Field(type => ID, { nullable: true })\n id?: string\n\n @Field({ nullable: true })\n product?: ObjectRef\n\n @Field({ nullable: true })\n productDetail?: ObjectRef\n\n @Field({ nullable: true })\n productCombination?: ObjectRef\n\n @Field(type => Int)\n qty: number\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class ProductCombinationSettingList {\n @Field(type => [ProductCombinationSetting])\n items: ProductCombinationSetting[]\n\n @Field(type => Int)\n total: number\n}\n"]}
1
+ {"version":3,"file":"product-combination-setting-type.js","sourceRoot":"","sources":["../../../server/service/product-combination-setting/product-combination-setting-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,iDAAiD;AAEjD,+EAAyE;AA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ObjectType } from 'type-graphql'\n\nimport { ObjectRef } from '@things-factory/shell'\n\nimport { ProductCombinationSetting } from './product-combination-setting'\n\n@InputType()\nexport class NewProductCombinationSetting {\n @Field()\n name: string\n\n @Field({ nullable: true })\n description?: string\n}\n\n@InputType()\nexport class ProductCombinationSettingPatch {\n @Field(type => ID, { nullable: true })\n id?: string\n\n @Field({ nullable: true })\n product?: ObjectRef\n\n @Field({ nullable: true })\n productDetail?: ObjectRef\n\n @Field({ nullable: true })\n productCombination?: ObjectRef\n\n @Field(type => Int)\n qty: number\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class ProductCombinationSettingList {\n @Field(type => [ProductCombinationSetting])\n items: ProductCombinationSetting[]\n\n @Field(type => Int)\n total: number\n}\n"]}
@@ -0,0 +1,22 @@
1
+ import { ProductCombination } from '../product-combination/product-combination';
2
+ import { ProductDetail } from '../product-detail/product-detail';
3
+ import { Product } from '../product/product';
4
+ export declare class ProductCombinationSetting {
5
+ readonly id?: string;
6
+ product?: Product;
7
+ productId?: string;
8
+ productDetail?: ProductDetail;
9
+ productDetailId?: string;
10
+ productCombination?: ProductCombination;
11
+ productCombinationId?: string;
12
+ qty: number;
13
+ gtin?: string;
14
+ packingType?: string;
15
+ packingSize?: number;
16
+ remainUomValueWithUom?: string;
17
+ productSku?: string;
18
+ productName?: string;
19
+ productDescription?: string;
20
+ productType?: string;
21
+ combinationId?: string;
22
+ }
@@ -9,6 +9,7 @@ const product_detail_1 = require("../product-detail/product-detail");
9
9
  const product_1 = require("../product/product");
10
10
  let ProductCombinationSetting = class ProductCombinationSetting {
11
11
  };
12
+ exports.ProductCombinationSetting = ProductCombinationSetting;
12
13
  tslib_1.__decorate([
13
14
  (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
14
15
  (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: true }),
@@ -84,7 +85,7 @@ tslib_1.__decorate([
84
85
  (0, type_graphql_1.Field)({ nullable: true }),
85
86
  tslib_1.__metadata("design:type", String)
86
87
  ], ProductCombinationSetting.prototype, "combinationId", void 0);
87
- ProductCombinationSetting = tslib_1.__decorate([
88
+ exports.ProductCombinationSetting = ProductCombinationSetting = tslib_1.__decorate([
88
89
  (0, typeorm_1.Entity)(),
89
90
  (0, typeorm_1.Index)('ix_product_combination_setting_0', (productCombinationSetting) => [
90
91
  productCombinationSetting.product,
@@ -93,5 +94,4 @@ ProductCombinationSetting = tslib_1.__decorate([
93
94
  ], { unique: true }),
94
95
  (0, type_graphql_1.ObjectType)({ description: 'Entity for ProductCombinationSetting' })
95
96
  ], ProductCombinationSetting);
96
- exports.ProductCombinationSetting = ProductCombinationSetting;
97
97
  //# sourceMappingURL=product-combination-setting.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"product-combination-setting.js","sourceRoot":"","sources":["../../../server/service/product-combination-setting/product-combination-setting.ts"],"names":[],"mappings":";;;;AAAA,+CAAyD;AACzD,qCAA8F;AAE9F,oFAA+E;AAC/E,qEAAgE;AAChE,gDAA4C;AAarC,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;CA0DrC,CAAA;AAzDC;IAAC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDAClB;AAEpB;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAO,CAAC;IAC1B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAO,CAAC;sCACb,iBAAO;0DAAA;AAEjB;IAAC,IAAA,oBAAU,EAAC,CAAC,yBAAoD,EAAE,EAAE,CAAC,yBAAyB,CAAC,OAAO,CAAC;IACvG,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4DACR;AAElB;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAa,CAAC;I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AAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8DACN;AAEpB;IAAC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gEACJ;AAzDX,yBAAyB;IAXrC,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EACJ,kCAAkC,EAClC,CAAC,yBAAoD,EAAE,EAAE,CAAC;QACxD,yBAAyB,CAAC,OAAO;QACjC,yBAAyB,CAAC,aAAa;QACvC,yBAAyB,CAAC,kBAAkB;KAC7C,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC;GACvD,yBAAyB,CA0DrC;AA1DY,8DAAyB","sourcesContent":["import { Field, ID, ObjectType, Int } from 'type-graphql'\nimport { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'\n\nimport { ProductCombination } from '../product-combination/product-combination'\nimport { ProductDetail } from '../product-detail/product-detail'\nimport { Product } from '../product/product'\n\n@Entity()\n@Index(\n 'ix_product_combination_setting_0',\n (productCombinationSetting: ProductCombinationSetting) => [\n productCombinationSetting.product,\n productCombinationSetting.productDetail,\n productCombinationSetting.productCombination\n ],\n { unique: true }\n)\n@ObjectType({ description: 'Entity for ProductCombinationSetting' })\nexport class ProductCombinationSetting {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { nullable: true })\n readonly id?: string\n\n @ManyToOne(type => Product)\n @Field(type => Product)\n product?: Product\n\n @RelationId((productCombinationSetting: ProductCombinationSetting) => productCombinationSetting.product)\n @Field({ nullable: true })\n productId?: string\n\n @ManyToOne(type => ProductDetail)\n @Field(type => ProductDetail)\n productDetail?: ProductDetail\n\n @RelationId((productCombinationSetting: ProductCombinationSetting) => productCombinationSetting.productDetail)\n @Field({ nullable: true })\n productDetailId?: string\n\n @ManyToOne(type => ProductCombination)\n @Field(type => ProductCombination)\n productCombination?: ProductCombination\n\n @RelationId((productCombinationSetting: ProductCombinationSetting) => productCombinationSetting.productCombination)\n productCombinationId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n qty: number\n\n @Field({ nullable: true })\n gtin?: string\n\n @Field({ nullable: true })\n packingType?: string\n\n @Field(type => Int, { nullable: true })\n packingSize?: number\n\n @Field({ nullable: true })\n remainUomValueWithUom?: string\n\n @Field({ nullable: true })\n productSku?: string\n\n @Field({ nullable: true })\n productName?: string\n\n @Field({ nullable: true })\n productDescription?: string\n\n @Field({ nullable: true })\n productType?: string\n\n @Field({ nullable: true })\n combinationId?: string\n}\n"]}
1
+ {"version":3,"file":"product-combination-setting.js","sourceRoot":"","sources":["../../../server/service/product-combination-setting/product-combination-setting.ts"],"names":[],"mappings":";;;;AAAA,+CAAyD;AACzD,qCAA8F;AAE9F,oFAA+E;AAC/E,qEAAgE;AAChE,gDAA4C;AAarC,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;CA0DrC,CAAA;AA1DY,8DAAyB;AAG3B;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;qDAClB;AAIpB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAO,CAAC;IAC1B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAO,CAAC;sCACb,iBAAO;0DAAA;AAIjB;IAFC,IAAA,oBAAU,EAAC,CAAC,yBAAoD,EAAE,EAAE,CAAC,yBAAyB,CAAC,OAAO,CAAC;IACvG,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4DACR;AAIlB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAa,CAAC;IAChC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAa,CAAC;s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C,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gEACJ;oCAzDX,yBAAyB;IAXrC,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EACJ,kCAAkC,EAClC,CAAC,yBAAoD,EAAE,EAAE,CAAC;QACxD,yBAAyB,CAAC,OAAO;QACjC,yBAAyB,CAAC,aAAa;QACvC,yBAAyB,CAAC,kBAAkB;KAC7C,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC;GACvD,yBAAyB,CA0DrC","sourcesContent":["import { Field, ID, ObjectType, Int } from 'type-graphql'\nimport { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'\n\nimport { ProductCombination } from '../product-combination/product-combination'\nimport { ProductDetail } from '../product-detail/product-detail'\nimport { Product } from '../product/product'\n\n@Entity()\n@Index(\n 'ix_product_combination_setting_0',\n (productCombinationSetting: ProductCombinationSetting) => [\n productCombinationSetting.product,\n productCombinationSetting.productDetail,\n productCombinationSetting.productCombination\n ],\n { unique: true }\n)\n@ObjectType({ description: 'Entity for ProductCombinationSetting' })\nexport class ProductCombinationSetting {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { nullable: true })\n readonly id?: string\n\n @ManyToOne(type => Product)\n @Field(type => Product)\n product?: Product\n\n @RelationId((productCombinationSetting: ProductCombinationSetting) => productCombinationSetting.product)\n @Field({ nullable: true })\n productId?: string\n\n @ManyToOne(type => ProductDetail)\n @Field(type => ProductDetail)\n productDetail?: ProductDetail\n\n @RelationId((productCombinationSetting: ProductCombinationSetting) => productCombinationSetting.productDetail)\n @Field({ nullable: true })\n productDetailId?: string\n\n @ManyToOne(type => ProductCombination)\n @Field(type => ProductCombination)\n productCombination?: ProductCombination\n\n @RelationId((productCombinationSetting: ProductCombinationSetting) => productCombinationSetting.productCombination)\n productCombinationId?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n qty: number\n\n @Field({ nullable: true })\n gtin?: string\n\n @Field({ nullable: true })\n packingType?: string\n\n @Field(type => Int, { nullable: true })\n packingSize?: number\n\n @Field({ nullable: true })\n remainUomValueWithUom?: string\n\n @Field({ nullable: true })\n productSku?: string\n\n @Field({ nullable: true })\n productName?: string\n\n @Field({ nullable: true })\n productDescription?: string\n\n @Field({ nullable: true })\n productType?: string\n\n @Field({ nullable: true })\n combinationId?: string\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { ProductDetail } from './product-detail';
2
+ import { ProductDetailMutation } from './product-detail-mutation';
3
+ import { ProductDetailQuery } from './product-detail-query';
4
+ export declare const entities: (typeof ProductDetail)[];
5
+ export declare const resolvers: (typeof ProductDetailMutation | typeof ProductDetailQuery)[];
@@ -0,0 +1,11 @@
1
+ import { ProductDetail } from './product-detail';
2
+ import { ProductDetailPatch } from './product-detail-types';
3
+ export declare class ProductDetailMutation {
4
+ updateProductDetail(id: string, patch: ProductDetailPatch, context: ResolverContext): Promise<ProductDetail>;
5
+ updateMultipleProductDetail(productId: string, patches: ProductDetailPatch[], context: ResolverContext): Promise<ProductDetail[]>;
6
+ deleteProductDetail(name: string, context: ResolverContext): Promise<Boolean>;
7
+ deleteProductDetails(names: string[], context: ResolverContext): Promise<Boolean>;
8
+ }
9
+ export declare function createProductDetail(productDetail: any, context: ResolverContext): Promise<any>;
10
+ export declare function updateProductDetail(id: string, patch: any, context: ResolverContext): Promise<any>;
11
+ export declare function updateMultipleProductDetail(productId: any, patches: any, context: ResolverContext): Promise<any[]>;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updateMultipleProductDetail = exports.updateProductDetail = exports.createProductDetail = exports.ProductDetailMutation = void 0;
3
+ exports.ProductDetailMutation = void 0;
4
+ exports.createProductDetail = createProductDetail;
5
+ exports.updateProductDetail = updateProductDetail;
6
+ exports.updateMultipleProductDetail = updateMultipleProductDetail;
4
7
  const tslib_1 = require("tslib");
5
8
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
6
9
  const type_graphql_1 = require("type-graphql");
@@ -35,6 +38,7 @@ let ProductDetailMutation = class ProductDetailMutation {
35
38
  return true;
36
39
  }
37
40
  };
41
+ exports.ProductDetailMutation = ProductDetailMutation;
38
42
  tslib_1.__decorate([
39
43
  (0, type_graphql_1.Directive)('@transaction'),
40
44
  (0, type_graphql_1.Mutation)(returns => product_detail_1.ProductDetail),
@@ -73,15 +77,13 @@ tslib_1.__decorate([
73
77
  tslib_1.__metadata("design:paramtypes", [Array, Object]),
74
78
  tslib_1.__metadata("design:returntype", Promise)
75
79
  ], ProductDetailMutation.prototype, "deleteProductDetails", null);
76
- ProductDetailMutation = tslib_1.__decorate([
80
+ exports.ProductDetailMutation = ProductDetailMutation = tslib_1.__decorate([
77
81
  (0, type_graphql_1.Resolver)(product_detail_1.ProductDetail)
78
82
  ], ProductDetailMutation);
79
- exports.ProductDetailMutation = ProductDetailMutation;
80
83
  async function createProductDetail(productDetail, context) {
81
84
  const { domain, user, tx } = context.state;
82
85
  return await tx.getRepository(product_detail_1.ProductDetail).save(Object.assign(Object.assign({}, productDetail), { domain, creator: user, updater: user }));
83
86
  }
84
- exports.createProductDetail = createProductDetail;
85
87
  async function updateProductDetail(id, patch, context) {
86
88
  const { domain, user, tx } = context.state;
87
89
  const repository = tx.getRepository(product_detail_1.ProductDetail);
@@ -91,7 +93,6 @@ async function updateProductDetail(id, patch, context) {
91
93
  }
92
94
  return await repository.save(Object.assign(Object.assign(Object.assign({}, productDetail), patch), { updater: user }));
93
95
  }
94
- exports.updateProductDetail = updateProductDetail;
95
96
  async function updateMultipleProductDetail(productId, patches, context) {
96
97
  var _a, e_1, _b, _c;
97
98
  try {
@@ -132,25 +133,20 @@ async function updateMultipleProductDetail(productId, patches, context) {
132
133
  }
133
134
  await productDetailRepo.delete({ id: (0, typeorm_1.In)(deleteIds) });
134
135
  try {
135
- for (var _d = true, _e = tslib_1.__asyncValues(patches.filter(x => x.childProductDetail)), _f; _f = await _e.next(), _a = _f.done, !_a;) {
136
+ for (var _d = true, _e = tslib_1.__asyncValues(patches.filter(x => x.childProductDetail)), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) {
136
137
  _c = _f.value;
137
138
  _d = false;
138
- try {
139
- let patch = _c;
140
- let matchedChildProductDetail = results.find(itm => itm.gtin == patch.childProductDetail);
141
- if (matchedChildProductDetail) {
142
- const childProductDetail = await productDetailRepo.findOne({
143
- where: { id: matchedChildProductDetail.id },
144
- relations: ['product']
145
- });
146
- const productDetail = await productDetailRepo.findOne({
147
- where: { gtin: patch.gtin, product: { id: childProductDetail.product.id } }
148
- });
149
- await productDetailRepo.save(Object.assign(Object.assign({}, productDetail), { childQty: patch.childQty, childProductDetail: childProductDetail, updater: user }));
150
- }
151
- }
152
- finally {
153
- _d = true;
139
+ let patch = _c;
140
+ let matchedChildProductDetail = results.find(itm => itm.gtin == patch.childProductDetail);
141
+ if (matchedChildProductDetail) {
142
+ const childProductDetail = await productDetailRepo.findOne({
143
+ where: { id: matchedChildProductDetail.id },
144
+ relations: ['product']
145
+ });
146
+ const productDetail = await productDetailRepo.findOne({
147
+ where: { gtin: patch.gtin, product: { id: childProductDetail.product.id } }
148
+ });
149
+ await productDetailRepo.save(Object.assign(Object.assign({}, productDetail), { childQty: patch.childQty, childProductDetail: childProductDetail, updater: user }));
154
150
  }
155
151
  }
156
152
  }
@@ -188,5 +184,4 @@ async function updateMultipleProductDetail(productId, patches, context) {
188
184
  throw error;
189
185
  }
190
186
  }
191
- exports.updateMultipleProductDetail = updateMultipleProductDetail;
192
187
  //# sourceMappingURL=product-detail-mutation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"product-detail-mutation.js","sourceRoot":"","sources":["../../../server/service/product-detail/product-detail-mutation.ts"],"names":[],"mappings":";;;;AAAA,4DAAsB;AACtB,+CAAsE;AACtE,qCAAiC;AAEjC,iDAAqD;AAErD,gDAA4C;AAC5C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S,CAAC,MAAM,EAC5B,SAAS,EAAE,SAAS,CAAC,KAAK,EAC1B,eAAe,EAAE,SAAS,CAAC,WAAW,EACtC,UAAU,EAAE,SAAS,CAAC,UAAU,EAChC,UAAU,EAAE,SAAS,CAAC,MAAM,GAC7B,CAAA;SACF;QACD,qDAAqD;QAErD,IAAI,oBAAoB,EAAE;YACxB,oBAAoB,mCACf,oBAAoB,KACvB,WAAW,EAAE,oBAAoB,CAAC,WAAW,EAC7C,WAAW,EAAE,oBAAoB,CAAC,GAAG,EACrC,YAAY,EAAE,oBAAoB,CAAC,QAAQ,EAC3C,eAAe,EAAE,oBAAoB,CAAC,eAAe,GACtD,CAAA;SACF;QAED,IAAI,CAAC,gBAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE;YACpC,MAAM,WAAW,CAAC,MAAM,CACtB;gBACE,EAAE,EAAE,OAAO,CAAC,EAAE;aACf,EACD,oBAAoB,CACrB,CAAA;SACF;QAED,OAAO,OAAO,CAAA;KACf;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,KAAK,CAAA;KACZ;AACH,CAAC;AAlJD,kEAkJC","sourcesContent":["import _ from 'lodash'\nimport { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In, Raw } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { Product } from '../product/product'\nimport { ProductDetail } from './product-detail'\nimport { ProductDetailPatch } from './product-detail-types'\n\n@Resolver(ProductDetail)\nexport class ProductDetailMutation {\n @Directive('@transaction')\n @Mutation(returns => ProductDetail)\n async updateProductDetail(\n @Arg('id') id: string,\n @Arg('patch') patch: ProductDetailPatch,\n @Ctx() context: ResolverContext\n ): Promise<ProductDetail> {\n return await updateProductDetail(id, patch, context)\n }\n\n @Directive('@transaction')\n @Mutation(returns => [ProductDetail])\n async updateMultipleProductDetail(\n @Arg('productId') productId: string,\n @Arg('patches', type => [ProductDetailPatch]) patches: ProductDetailPatch[],\n @Ctx() context: ResolverContext\n ): Promise<ProductDetail[]> {\n try {\n return await updateMultipleProductDetail(productId, patches, context)\n } catch (error) {\n throw error\n }\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteProductDetail(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Boolean> {\n const { domain, user } = context.state\n\n await getRepository(ProductDetail).delete({ domain: { id: domain.id }, name })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteProductDetails(\n @Arg('names', type => [String]) names: string[],\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n const { domain, user } = context.state\n\n await getRepository(ProductDetail).delete({\n domain: { id: domain.id },\n name: In(names)\n })\n\n return true\n }\n}\n\nexport async function createProductDetail(productDetail: any, context: ResolverContext) {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(ProductDetail).save({\n ...productDetail,\n domain,\n creator: user,\n updater: user\n })\n}\n\nexport async function updateProductDetail(id: string, patch: any, context: ResolverContext) {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(ProductDetail)\n const productDetail: ProductDetail = await repository.findOne({ where: { id } })\n\n if (patch.gtin == undefined) {\n delete patch.gtin\n }\n\n return await repository.save({\n ...productDetail,\n ...patch,\n updater: user\n })\n}\n\nexport async function updateMultipleProductDetail(productId, patches, context: ResolverContext) {\n try {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => !patch.id)\n const _updateRecords = patches.filter((patch: any) => patch.id)\n // const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n\n const productRepo = tx.getRepository(Product)\n const productDetailRepo = tx.getRepository(ProductDetail)\n\n const product: Product = await productRepo.findOne({ where: { id: productId }, relations: ['productDetails'] })\n\n const defaultProductDetail: ProductDetail = patches.find(x => x.isDefault)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = {\n ..._createRecords[i],\n name: _createRecords[i].gtin,\n product,\n childProductDetail: null,\n childQty: 0,\n domain: domain,\n creator: user,\n updater: user\n }\n\n if (newRecord.gtin == null || newRecord.gtin == undefined) {\n throw new Error('GTIN cannot be empty.')\n }\n\n const result = await productDetailRepo.save(newRecord)\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n let deleteIds = []\n for (let x = 0; x < product.productDetails.length; x++) {\n let updateRecords = _updateRecords.find(ur => ur.id == product.productDetails[x].id)\n\n if (updateRecords) {\n const productDetail: ProductDetail = await productDetailRepo.findOneBy({ id: updateRecords.id })\n\n const updateRecord = {\n ...productDetail,\n ...updateRecords,\n name: updateRecords.gtin,\n product,\n childProductDetail: null,\n childQty: 0,\n updater: user\n }\n\n if (updateRecord.gtin == '' || updateRecord.gtin == null || updateRecord.gtin == undefined) {\n throw new Error('GTIN cannot be empty.')\n }\n\n const result = await productDetailRepo.save({\n ...productDetail,\n ...updateRecord,\n name: updateRecord.gtin,\n product,\n childProductDetail: null,\n childQty: 0,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n } else {\n deleteIds.push(product.productDetails[x].id)\n }\n }\n\n await productDetailRepo.delete({ id: In(deleteIds) })\n\n for await (let patch of patches.filter(x => x.childProductDetail)) {\n let matchedChildProductDetail = results.find(itm => itm.gtin == patch.childProductDetail)\n\n if (matchedChildProductDetail) {\n const childProductDetail: ProductDetail = await productDetailRepo.findOne({\n where: { id: matchedChildProductDetail.id },\n relations: ['product']\n })\n const productDetail: ProductDetail = await productDetailRepo.findOne({\n where: { gtin: patch.gtin, product: { id: childProductDetail.product.id } }\n })\n\n await productDetailRepo.save({\n ...productDetail,\n childQty: patch.childQty,\n childProductDetail: childProductDetail,\n updater: user\n })\n }\n }\n\n let defaultProductUpdate: Product\n\n //// Temporary solution, to fetch the first case packing type of SKU and update Case data in Product Table.\n //// To be removed\n let firstCase: ProductDetail = await productDetailRepo.findOne({\n where: { product: { id: product.id }, packingType: Raw(alias => `lower(${alias}) = 'case'`) },\n order: {\n name: 'ASC'\n }\n })\n if (firstCase) {\n defaultProductUpdate = {\n ...defaultProductUpdate,\n caseGtin: firstCase.gtin,\n caseWidth: firstCase.width,\n caseHeight: firstCase.height,\n caseDepth: firstCase.depth,\n caseGrossWeight: firstCase.grossWeight,\n caseWeight: firstCase.nettWeight,\n caseVolume: firstCase.volume\n }\n }\n /////////////////////////////////////////////////////\n\n if (defaultProductDetail) {\n defaultProductUpdate = {\n ...defaultProductUpdate,\n packingType: defaultProductDetail.packingType,\n primaryUnit: defaultProductDetail.uom,\n primaryValue: defaultProductDetail.uomValue,\n cogsAccountCode: defaultProductDetail.cogsAccountCode\n }\n }\n\n if (!_.isEmpty(defaultProductUpdate)) {\n await productRepo.update(\n {\n id: product.id\n },\n defaultProductUpdate\n )\n }\n\n return results\n } catch (error) {\n throw error\n }\n}\n"]}
1
+ {"version":3,"file":"product-detail-mutation.js","sourceRoot":"","sources":["../../../server/service/product-detail/product-detail-mutation.ts"],"names":[],"mappings":";;;AA+DA,kDASC;AAED,kDAeC;AAED,kEAkJC;;AA7OD,4DAAsB;AACtB,+CAAsE;AACtE,qCAAiC;AAEjC,iDAAqD;AAErD,gDAA4C;AAC5C,qDAAgD;AAChD,iEAA2D;AAGpD,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAG1B,AAAN,KAAK,CAAC,mBAAmB,CACZ,EAAU,EACP,KAAyB,EAChC,OAAwB;QAE/B,OAAO,MAAM,mBAAmB,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;IACtD,CAAC;IAIK,AAAN,KAAK,CAAC,2BAA2B,CACb,SAAiB,EACW,OAA6B,EACpE,OAAwB;QAE/B,IAAI,CAAC;YACH,OAAO,MAAM,2BAA2B,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QACvE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;IAIK,AAAN,KAAK,CAAC,mBAAmB,CAAc,IAAY,EAAS,OAAwB;QAClF,M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oB,CAAC,eAAe,GACtD,CAAA;QACH,CAAC;QAED,IAAI,CAAC,gBAAC,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,CAAC;YACrC,MAAM,WAAW,CAAC,MAAM,CACtB;gBACE,EAAE,EAAE,OAAO,CAAC,EAAE;aACf,EACD,oBAAoB,CACrB,CAAA;QACH,CAAC;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC","sourcesContent":["import _ from 'lodash'\nimport { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { In, Raw } from 'typeorm'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { Product } from '../product/product'\nimport { ProductDetail } from './product-detail'\nimport { ProductDetailPatch } from './product-detail-types'\n\n@Resolver(ProductDetail)\nexport class ProductDetailMutation {\n @Directive('@transaction')\n @Mutation(returns => ProductDetail)\n async updateProductDetail(\n @Arg('id') id: string,\n @Arg('patch') patch: ProductDetailPatch,\n @Ctx() context: ResolverContext\n ): Promise<ProductDetail> {\n return await updateProductDetail(id, patch, context)\n }\n\n @Directive('@transaction')\n @Mutation(returns => [ProductDetail])\n async updateMultipleProductDetail(\n @Arg('productId') productId: string,\n @Arg('patches', type => [ProductDetailPatch]) patches: ProductDetailPatch[],\n @Ctx() context: ResolverContext\n ): Promise<ProductDetail[]> {\n try {\n return await updateMultipleProductDetail(productId, patches, context)\n } catch (error) {\n throw error\n }\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteProductDetail(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<Boolean> {\n const { domain, user } = context.state\n\n await getRepository(ProductDetail).delete({ domain: { id: domain.id }, name })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async deleteProductDetails(\n @Arg('names', type => [String]) names: string[],\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n const { domain, user } = context.state\n\n await getRepository(ProductDetail).delete({\n domain: { id: domain.id },\n name: In(names)\n })\n\n return true\n }\n}\n\nexport async function createProductDetail(productDetail: any, context: ResolverContext) {\n const { domain, user, tx } = context.state\n\n return await tx.getRepository(ProductDetail).save({\n ...productDetail,\n domain,\n creator: user,\n updater: user\n })\n}\n\nexport async function updateProductDetail(id: string, patch: any, context: ResolverContext) {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(ProductDetail)\n const productDetail: ProductDetail = await repository.findOne({ where: { id } })\n\n if (patch.gtin == undefined) {\n delete patch.gtin\n }\n\n return await repository.save({\n ...productDetail,\n ...patch,\n updater: user\n })\n}\n\nexport async function updateMultipleProductDetail(productId, patches, context: ResolverContext) {\n try {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => !patch.id)\n const _updateRecords = patches.filter((patch: any) => patch.id)\n // const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n\n const productRepo = tx.getRepository(Product)\n const productDetailRepo = tx.getRepository(ProductDetail)\n\n const product: Product = await productRepo.findOne({ where: { id: productId }, relations: ['productDetails'] })\n\n const defaultProductDetail: ProductDetail = patches.find(x => x.isDefault)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = {\n ..._createRecords[i],\n name: _createRecords[i].gtin,\n product,\n childProductDetail: null,\n childQty: 0,\n domain: domain,\n creator: user,\n updater: user\n }\n\n if (newRecord.gtin == null || newRecord.gtin == undefined) {\n throw new Error('GTIN cannot be empty.')\n }\n\n const result = await productDetailRepo.save(newRecord)\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n let deleteIds = []\n for (let x = 0; x < product.productDetails.length; x++) {\n let updateRecords = _updateRecords.find(ur => ur.id == product.productDetails[x].id)\n\n if (updateRecords) {\n const productDetail: ProductDetail = await productDetailRepo.findOneBy({ id: updateRecords.id })\n\n const updateRecord = {\n ...productDetail,\n ...updateRecords,\n name: updateRecords.gtin,\n product,\n childProductDetail: null,\n childQty: 0,\n updater: user\n }\n\n if (updateRecord.gtin == '' || updateRecord.gtin == null || updateRecord.gtin == undefined) {\n throw new Error('GTIN cannot be empty.')\n }\n\n const result = await productDetailRepo.save({\n ...productDetail,\n ...updateRecord,\n name: updateRecord.gtin,\n product,\n childProductDetail: null,\n childQty: 0,\n updater: user\n })\n\n results.push({ ...result, cuFlag: 'M' })\n } else {\n deleteIds.push(product.productDetails[x].id)\n }\n }\n\n await productDetailRepo.delete({ id: In(deleteIds) })\n\n for await (let patch of patches.filter(x => x.childProductDetail)) {\n let matchedChildProductDetail = results.find(itm => itm.gtin == patch.childProductDetail)\n\n if (matchedChildProductDetail) {\n const childProductDetail: ProductDetail = await productDetailRepo.findOne({\n where: { id: matchedChildProductDetail.id },\n relations: ['product']\n })\n const productDetail: ProductDetail = await productDetailRepo.findOne({\n where: { gtin: patch.gtin, product: { id: childProductDetail.product.id } }\n })\n\n await productDetailRepo.save({\n ...productDetail,\n childQty: patch.childQty,\n childProductDetail: childProductDetail,\n updater: user\n })\n }\n }\n\n let defaultProductUpdate: Product\n\n //// Temporary solution, to fetch the first case packing type of SKU and update Case data in Product Table.\n //// To be removed\n let firstCase: ProductDetail = await productDetailRepo.findOne({\n where: { product: { id: product.id }, packingType: Raw(alias => `lower(${alias}) = 'case'`) },\n order: {\n name: 'ASC'\n }\n })\n if (firstCase) {\n defaultProductUpdate = {\n ...defaultProductUpdate,\n caseGtin: firstCase.gtin,\n caseWidth: firstCase.width,\n caseHeight: firstCase.height,\n caseDepth: firstCase.depth,\n caseGrossWeight: firstCase.grossWeight,\n caseWeight: firstCase.nettWeight,\n caseVolume: firstCase.volume\n }\n }\n /////////////////////////////////////////////////////\n\n if (defaultProductDetail) {\n defaultProductUpdate = {\n ...defaultProductUpdate,\n packingType: defaultProductDetail.packingType,\n primaryUnit: defaultProductDetail.uom,\n primaryValue: defaultProductDetail.uomValue,\n cogsAccountCode: defaultProductDetail.cogsAccountCode\n }\n }\n\n if (!_.isEmpty(defaultProductUpdate)) {\n await productRepo.update(\n {\n id: product.id\n },\n defaultProductUpdate\n )\n }\n\n return results\n } catch (error) {\n throw error\n }\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { User } from '@things-factory/auth-base';
2
+ import { Domain, Filter, Pagination, Sorting } from '@things-factory/shell';
3
+ import { ProductDetail } from './product-detail';
4
+ import { ProductDetailList } from './product-detail-types';
5
+ export declare class ProductDetailQuery {
6
+ productDetail(gtin: string, productId: string, customerCompanyDomainId: string, context: ResolverContext): Promise<ProductDetail>;
7
+ productDetails(context: ResolverContext, filters?: Filter[], pagination?: Pagination, sortings?: Sorting[]): Promise<ProductDetailList>;
8
+ checkGtin(gtin: string, customerCompanyDomainId: string, context: ResolverContext): Promise<ProductDetailList>;
9
+ domain(productDetail: ProductDetail): Promise<Domain>;
10
+ updater(productDetail: ProductDetail): Promise<User>;
11
+ creator(productDetail: ProductDetail): Promise<User>;
12
+ }
@@ -157,6 +157,7 @@ let ProductDetailQuery = class ProductDetailQuery {
157
157
  return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: productDetail.creator.id });
158
158
  }
159
159
  };
160
+ exports.ProductDetailQuery = ProductDetailQuery;
160
161
  tslib_1.__decorate([
161
162
  (0, type_graphql_1.Directive)('@transaction'),
162
163
  (0, type_graphql_1.Query)(returns => product_detail_1.ProductDetail),
@@ -208,8 +209,7 @@ tslib_1.__decorate([
208
209
  tslib_1.__metadata("design:paramtypes", [product_detail_1.ProductDetail]),
209
210
  tslib_1.__metadata("design:returntype", Promise)
210
211
  ], ProductDetailQuery.prototype, "creator", null);
211
- ProductDetailQuery = tslib_1.__decorate([
212
+ exports.ProductDetailQuery = ProductDetailQuery = tslib_1.__decorate([
212
213
  (0, type_graphql_1.Resolver)(product_detail_1.ProductDetail)
213
214
  ], ProductDetailQuery);
214
- exports.ProductDetailQuery = ProductDetailQuery;
215
215
  //# sourceMappingURL=product-detail-query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"product-detail-query.js","sourceRoot":"","sources":["../../../server/service/product-detail/product-detail-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAwF;AACxF,qCAAsD;AAEtD,yDAAgD;AAChD,uDAAuG;AACvG,iDAAsH;AAEtH,qDAAgD;AAChD,iEAA0D;AAGnD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAGvB,AAAN,KAAK,CAAC,aAAa,CACJ,IAAY,EACP,SAAiB,EACH,uBAA+B,EACxD,OAAwB;QAE/B,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE5B,MAAM,cAAc,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,cAAM,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,uBAAuB,EAAE,CAAC,CAAA;QAChG,IAAI,CAAC,cAAc,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;SACjD;QAED,IAAI,kBAAkB,CAAA;QACtB,IAAI,SAAS,EAAE;YACb,kBAAkB,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,8BAAa,CAAC,CAAC,OAAO,CAAC;gBACjE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE;gBACxE,SAAS,EAAE,CAAC,SAAS,CAAC;aACvB,CAAC,CAAA;SACH;aAAM;YACL,kBAAkB,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,8BAAa,CAAC,CAAC,OAAO,CAAC;gBACjE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE;gBAClD,SAAS,EAAE,CAAC,SAAS,CAAC;aACvB,CAAC,CAAA;SACH;QAED,IAAI,CAAC,kBAAkB;YAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;QAEtE,OA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wCAAiB,CAAC;IAEjC,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IACX,mBAAA,IAAA,kBAAG,EAAC,yBAAyB,CAAC,CAAA;IAC9B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;mDAoBP;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAgB,8BAAa;;gDAEhD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAgB,8BAAa;;iDAEjD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAgB,8BAAa;;iDAEjD;AAxMU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,8BAAa,CAAC;GACX,kBAAkB,CAyM9B;AAzMY,gDAAkB","sourcesContent":["import { Arg, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\nimport { Brackets, SelectQueryBuilder } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Bizplace, getCompaniesBizplaces, getPartnersCompanyBizplaces } from '@things-factory/biz-base'\nimport { buildCondition, buildQuery, Domain, Filter, getRepository, Pagination, Sorting } from '@things-factory/shell'\n\nimport { ProductDetail } from './product-detail'\nimport { ProductDetailList } from './product-detail-types'\n\n@Resolver(ProductDetail)\nexport class ProductDetailQuery {\n @Directive('@transaction')\n @Query(returns => ProductDetail)\n async productDetail(\n @Arg('gtin') gtin: string,\n @Arg('productId') productId: string,\n @Arg('customerCompanyDomainId') customerCompanyDomainId: string,\n @Ctx() context: ResolverContext\n ): Promise<ProductDetail> {\n const { tx } = context.state\n\n const customerDomain = await tx.getRepository(Domain).findOneBy({ id: customerCompanyDomainId })\n if (!customerDomain) {\n throw new Error('Unable to find company domain')\n }\n\n var foundProductDetail\n if (productId) {\n foundProductDetail = await tx.getRepository(ProductDetail).findOne({\n where: { domain: { id: customerDomain.id }, product: { id: productId } },\n relations: ['product']\n })\n } else {\n foundProductDetail = await tx.getRepository(ProductDetail).findOne({\n where: { domain: { id: customerDomain.id }, gtin },\n relations: ['product']\n })\n }\n\n if (!foundProductDetail) throw new Error('No product candidate found')\n\n return foundProductDetail\n }\n\n @Query(returns => ProductDetailList)\n async productDetails(\n @Ctx() context: ResolverContext,\n @Arg('filters', type => [Filter], { nullable: true }) filters?: Filter[],\n @Arg('pagination', type => Pagination, { nullable: true }) pagination?: Pagination,\n @Arg('sortings', type => [Sorting], { nullable: true }) sortings?: Sorting[]\n ): Promise<ProductDetailList> {\n const { domain, user } = context.state\n const { domains } = user\n\n const params = { filters, pagination }\n const productInfoFilters = params.filters.find(x => x.name == 'product_info' || x.name == 'sku' || x.name == 'name' || x.name == 'description' || x.name == 'type')\n\n const bizplaceFilter = params.filters.find(x => x.name == 'bizplace_id')\n const productFilter = params.filters.find(x => x.name == 'product')\n const createArrivalNotice = params.filters.find(x => x.name == 'create_arrival_notice')\n const productInfoFilterColumns = ['sku', 'name', 'description', 'type', 'brand']\n params.filters = params.filters.filter(\n x =>\n x.name != 'product_info' &&\n x.name != 'bizplace_id' &&\n x.name != 'product' &&\n x.name != 'sku' &&\n x.name != 'brand' &&\n x.name != 'name' &&\n x.name != 'description' &&\n x.name != 'type' &&\n x.name != 'create_arrival_notice'\n )\n\n const qb: SelectQueryBuilder<ProductDetail> = getRepository(ProductDetail).createQueryBuilder('ProductDetail')\n qb.innerJoinAndSelect('ProductDetail.product', 'Product', '\"Product\".\"deleted_at\" IS NULL')\n qb.innerJoinAndSelect('Product.bizplace', 'Bizplace')\n qb.leftJoinAndSelect('ProductDetail.childProductDetail', 'ChildProductDetail')\n qb.leftJoinAndSelect('Product.creator', 'Creator')\n qb.leftJoinAndSelect('Product.updater', 'Updater')\n\n buildQuery(qb, params, context, {\n domainRef: false,\n searchables: ['name']\n })\n\n if (bizplaceFilter?.value) {\n const bizplaceId: string = bizplaceFilter.value\n\n const foundBizplace: Bizplace = await getRepository(Bizplace).findOne({\n where: { id: bizplaceId } /* CONFIRMME regarding TYPEORM - did I migrate correctly ? */,\n relations: ['company', 'company.domain']\n })\n\n if (foundBizplace) {\n const companyDomain: Domain = foundBizplace.company?.domain\n const companyBizplace: Bizplace = await getRepository(Bizplace).findOne({\n where: { domain: { id: companyDomain.id } }\n })\n\n const bizplaceIds = [companyBizplace.id, foundBizplace.id]\n qb.andWhere('Bizplace.id IN (:...bizplaceIds)', { bizplaceIds: [...new Set(bizplaceIds)] })\n }\n } else {\n const warehouseDomain: Domain = domain\n let bizplaceIds = []\n if (warehouseDomain?.extType === 'company') {\n const companyBizplace: Bizplace = await getRepository(Bizplace).findOne({\n where: { domain: { id: warehouseDomain.id } }\n })\n bizplaceIds.push(companyBizplace.id)\n } else if (warehouseDomain?.extType === 'factory') {\n const myBizplace: Bizplace = await getRepository(Bizplace).findOne({\n where: { domain: { id: warehouseDomain.id } },\n relations: ['domain']\n })\n const companiesBizplaces: Bizplace[] = await getCompaniesBizplaces(domains, warehouseDomain)\n const partnersCompanyBizplaces: Bizplace[] = await getPartnersCompanyBizplaces(domain, user)\n bizplaceIds = [...bizplaceIds, myBizplace.id, ...companiesBizplaces.map(biz => biz.id), ...partnersCompanyBizplaces.map(biz => biz.id)]\n } else {\n const companiesBizplaces: Bizplace[] = await getCompaniesBizplaces(domains, warehouseDomain)\n const partnersCompanyBizplaces: Bizplace[] = await getPartnersCompanyBizplaces(domain, user)\n bizplaceIds = [...bizplaceIds, ...companiesBizplaces.map(biz => biz.id), ...partnersCompanyBizplaces.map(biz => biz.id)]\n }\n\n qb.andWhere('Product.bizplace_id IN (:...bizplaceIds)', { bizplaceIds: bizplaceIds })\n }\n\n if (productFilter?.value) {\n if (productFilter.operator === 'eq') {\n qb.andWhere('ProductDetail.product_id = :productId', { productId: productFilter.value })\n } else if (productFilter.operator === 'in') {\n qb.andWhere('ProductDetail.product_id in(:...productId)', { productId: productFilter.value })\n }\n }\n\n if (productInfoFilters?.value) {\n let productInfo = productInfoFilters\n qb.andWhere(\n new Brackets(qb2 => {\n productInfoFilterColumns.forEach(filter => {\n const condition = buildCondition('Product', filter, productInfo.operator, productInfo.value, productInfo.relation, Object.keys(qb.getParameters()).length)\n\n qb2.orWhere(condition.clause, condition.parameters)\n })\n })\n )\n }\n\n if (createArrivalNotice?.value) {\n qb.andWhere('(Product.isRequireSerialNumberScanning = false OR (Product.isRequireSerialNumberScanning = true AND ProductDetail.isDefault = true))')\n }\n\n let [items, total] = await qb.getManyAndCount()\n\n items = items.map(item => {\n return {\n ...item,\n productId: item.product.id,\n name: item.product.name,\n description: item.product.description,\n type: item.product.type,\n sku: item.product.sku,\n isRequireSerialNumberScanningInbound: item.product.isRequireSerialNumberScanningInbound,\n isRequireSerialNumberScanningOutbound: item.product.isRequireSerialNumberScanningOutbound\n }\n })\n\n return { items, total }\n }\n\n @Query(returns => ProductDetailList)\n async checkGtin(\n @Arg('gtin') gtin: string,\n @Arg('customerCompanyDomainId') customerCompanyDomainId: string,\n @Ctx() context: ResolverContext\n ): Promise<ProductDetailList> {\n try {\n const { tx } = context.state\n\n const customerDomainId: Domain = await getRepository(Domain).findOneBy({ id: customerCompanyDomainId })\n if (!customerDomainId) throw new Error('Unable to find company domain')\n var foundProductDetails\n\n let [items, total] = await getRepository(ProductDetail).findAndCount({\n where: { domain: { id: customerDomainId.id }, gtin },\n relations: ['product']\n })\n\n if (items?.length <= 0) throw new Error('No product candidate found')\n\n return { items, total }\n } catch (e) {\n throw new Error(e)\n }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() productDetail: ProductDetail): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: productDetail.domain.id })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() productDetail: ProductDetail): Promise<User> {\n return await getRepository(User).findOneBy({ id: productDetail.updater.id })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() productDetail: ProductDetail): Promise<User> {\n return await getRepository(User).findOneBy({ id: productDetail.creator.id })\n }\n}\n"]}
1
+ {"version":3,"file":"product-detail-query.js","sourceRoot":"","sources":["../../../server/service/product-detail/product-detail-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAwF;AACxF,qCAAsD;AAEtD,yDAAgD;AAChD,uDAAuG;AACvG,iDAAsH;AAEtH,qDAAgD;AAChD,iEAA0D;AAGnD,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAGvB,AAAN,KAAK,CAAC,aAAa,CACJ,IAAY,EACP,SAAiB,EACH,uBAA+B,EACxD,OAAwB;QAE/B,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE5B,MAAM,cAAc,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,cAAM,CAAC,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,uBAAuB,EAAE,CAAC,CAAA;QAChG,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;QAClD,CAAC;QAED,IAAI,kBAAkB,CAAA;QACtB,IAAI,SAAS,EAAE,CAAC;YACd,kBAAkB,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,8BAAa,CAAC,CAAC,OAAO,CAAC;gBACjE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE;gBACxE,SAAS,EAAE,CAAC,SAAS,CAAC;aACvB,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,kBAAkB,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,8BAAa,CAAC,CAAC,OAAO,CAAC;gBACjE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,cAAc,CAAC,EAAE,EAAE,EAAE,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ACpD,mBAAA,IAAA,kBAAG,EAAC,YAAY,EAAE,IAAI,CAAC,EAAE,CAAC,kBAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IACzD,mBAAA,IAAA,kBAAG,EAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,eAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;4DADiB,kBAAU;;wDAyHnF;AAGK;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,wCAAiB,CAAC;IAEjC,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IACX,mBAAA,IAAA,kBAAG,EAAC,yBAAyB,CAAC,CAAA;IAC9B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;mDAoBP;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAgB,8BAAa;;gDAEhD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAgB,8BAAa;;iDAEjD;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAgB,8BAAa;;iDAEjD;6BAxMU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,8BAAa,CAAC;GACX,kBAAkB,CAyM9B","sourcesContent":["import { Arg, Ctx, Directive, FieldResolver, Query, Resolver, Root } from 'type-graphql'\nimport { Brackets, SelectQueryBuilder } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { Bizplace, getCompaniesBizplaces, getPartnersCompanyBizplaces } from '@things-factory/biz-base'\nimport { buildCondition, buildQuery, Domain, Filter, getRepository, Pagination, Sorting } from '@things-factory/shell'\n\nimport { ProductDetail } from './product-detail'\nimport { ProductDetailList } from './product-detail-types'\n\n@Resolver(ProductDetail)\nexport class ProductDetailQuery {\n @Directive('@transaction')\n @Query(returns => ProductDetail)\n async productDetail(\n @Arg('gtin') gtin: string,\n @Arg('productId') productId: string,\n @Arg('customerCompanyDomainId') customerCompanyDomainId: string,\n @Ctx() context: ResolverContext\n ): Promise<ProductDetail> {\n const { tx } = context.state\n\n const customerDomain = await tx.getRepository(Domain).findOneBy({ id: customerCompanyDomainId })\n if (!customerDomain) {\n throw new Error('Unable to find company domain')\n }\n\n var foundProductDetail\n if (productId) {\n foundProductDetail = await tx.getRepository(ProductDetail).findOne({\n where: { domain: { id: customerDomain.id }, product: { id: productId } },\n relations: ['product']\n })\n } else {\n foundProductDetail = await tx.getRepository(ProductDetail).findOne({\n where: { domain: { id: customerDomain.id }, gtin },\n relations: ['product']\n })\n }\n\n if (!foundProductDetail) throw new Error('No product candidate found')\n\n return foundProductDetail\n }\n\n @Query(returns => ProductDetailList)\n async productDetails(\n @Ctx() context: ResolverContext,\n @Arg('filters', type => [Filter], { nullable: true }) filters?: Filter[],\n @Arg('pagination', type => Pagination, { nullable: true }) pagination?: Pagination,\n @Arg('sortings', type => [Sorting], { nullable: true }) sortings?: Sorting[]\n ): Promise<ProductDetailList> {\n const { domain, user } = context.state\n const { domains } = user\n\n const params = { filters, pagination }\n const productInfoFilters = params.filters.find(x => x.name == 'product_info' || x.name == 'sku' || x.name == 'name' || x.name == 'description' || x.name == 'type')\n\n const bizplaceFilter = params.filters.find(x => x.name == 'bizplace_id')\n const productFilter = params.filters.find(x => x.name == 'product')\n const createArrivalNotice = params.filters.find(x => x.name == 'create_arrival_notice')\n const productInfoFilterColumns = ['sku', 'name', 'description', 'type', 'brand']\n params.filters = params.filters.filter(\n x =>\n x.name != 'product_info' &&\n x.name != 'bizplace_id' &&\n x.name != 'product' &&\n x.name != 'sku' &&\n x.name != 'brand' &&\n x.name != 'name' &&\n x.name != 'description' &&\n x.name != 'type' &&\n x.name != 'create_arrival_notice'\n )\n\n const qb: SelectQueryBuilder<ProductDetail> = getRepository(ProductDetail).createQueryBuilder('ProductDetail')\n qb.innerJoinAndSelect('ProductDetail.product', 'Product', '\"Product\".\"deleted_at\" IS NULL')\n qb.innerJoinAndSelect('Product.bizplace', 'Bizplace')\n qb.leftJoinAndSelect('ProductDetail.childProductDetail', 'ChildProductDetail')\n qb.leftJoinAndSelect('Product.creator', 'Creator')\n qb.leftJoinAndSelect('Product.updater', 'Updater')\n\n buildQuery(qb, params, context, {\n domainRef: false,\n searchables: ['name']\n })\n\n if (bizplaceFilter?.value) {\n const bizplaceId: string = bizplaceFilter.value\n\n const foundBizplace: Bizplace = await getRepository(Bizplace).findOne({\n where: { id: bizplaceId } /* CONFIRMME regarding TYPEORM - did I migrate correctly ? */,\n relations: ['company', 'company.domain']\n })\n\n if (foundBizplace) {\n const companyDomain: Domain = foundBizplace.company?.domain\n const companyBizplace: Bizplace = await getRepository(Bizplace).findOne({\n where: { domain: { id: companyDomain.id } }\n })\n\n const bizplaceIds = [companyBizplace.id, foundBizplace.id]\n qb.andWhere('Bizplace.id IN (:...bizplaceIds)', { bizplaceIds: [...new Set(bizplaceIds)] })\n }\n } else {\n const warehouseDomain: Domain = domain\n let bizplaceIds = []\n if (warehouseDomain?.extType === 'company') {\n const companyBizplace: Bizplace = await getRepository(Bizplace).findOne({\n where: { domain: { id: warehouseDomain.id } }\n })\n bizplaceIds.push(companyBizplace.id)\n } else if (warehouseDomain?.extType === 'factory') {\n const myBizplace: Bizplace = await getRepository(Bizplace).findOne({\n where: { domain: { id: warehouseDomain.id } },\n relations: ['domain']\n })\n const companiesBizplaces: Bizplace[] = await getCompaniesBizplaces(domains, warehouseDomain)\n const partnersCompanyBizplaces: Bizplace[] = await getPartnersCompanyBizplaces(domain, user)\n bizplaceIds = [...bizplaceIds, myBizplace.id, ...companiesBizplaces.map(biz => biz.id), ...partnersCompanyBizplaces.map(biz => biz.id)]\n } else {\n const companiesBizplaces: Bizplace[] = await getCompaniesBizplaces(domains, warehouseDomain)\n const partnersCompanyBizplaces: Bizplace[] = await getPartnersCompanyBizplaces(domain, user)\n bizplaceIds = [...bizplaceIds, ...companiesBizplaces.map(biz => biz.id), ...partnersCompanyBizplaces.map(biz => biz.id)]\n }\n\n qb.andWhere('Product.bizplace_id IN (:...bizplaceIds)', { bizplaceIds: bizplaceIds })\n }\n\n if (productFilter?.value) {\n if (productFilter.operator === 'eq') {\n qb.andWhere('ProductDetail.product_id = :productId', { productId: productFilter.value })\n } else if (productFilter.operator === 'in') {\n qb.andWhere('ProductDetail.product_id in(:...productId)', { productId: productFilter.value })\n }\n }\n\n if (productInfoFilters?.value) {\n let productInfo = productInfoFilters\n qb.andWhere(\n new Brackets(qb2 => {\n productInfoFilterColumns.forEach(filter => {\n const condition = buildCondition('Product', filter, productInfo.operator, productInfo.value, productInfo.relation, Object.keys(qb.getParameters()).length)\n\n qb2.orWhere(condition.clause, condition.parameters)\n })\n })\n )\n }\n\n if (createArrivalNotice?.value) {\n qb.andWhere('(Product.isRequireSerialNumberScanning = false OR (Product.isRequireSerialNumberScanning = true AND ProductDetail.isDefault = true))')\n }\n\n let [items, total] = await qb.getManyAndCount()\n\n items = items.map(item => {\n return {\n ...item,\n productId: item.product.id,\n name: item.product.name,\n description: item.product.description,\n type: item.product.type,\n sku: item.product.sku,\n isRequireSerialNumberScanningInbound: item.product.isRequireSerialNumberScanningInbound,\n isRequireSerialNumberScanningOutbound: item.product.isRequireSerialNumberScanningOutbound\n }\n })\n\n return { items, total }\n }\n\n @Query(returns => ProductDetailList)\n async checkGtin(\n @Arg('gtin') gtin: string,\n @Arg('customerCompanyDomainId') customerCompanyDomainId: string,\n @Ctx() context: ResolverContext\n ): Promise<ProductDetailList> {\n try {\n const { tx } = context.state\n\n const customerDomainId: Domain = await getRepository(Domain).findOneBy({ id: customerCompanyDomainId })\n if (!customerDomainId) throw new Error('Unable to find company domain')\n var foundProductDetails\n\n let [items, total] = await getRepository(ProductDetail).findAndCount({\n where: { domain: { id: customerDomainId.id }, gtin },\n relations: ['product']\n })\n\n if (items?.length <= 0) throw new Error('No product candidate found')\n\n return { items, total }\n } catch (e) {\n throw new Error(e)\n }\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() productDetail: ProductDetail): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: productDetail.domain.id })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() productDetail: ProductDetail): Promise<User> {\n return await getRepository(User).findOneBy({ id: productDetail.updater.id })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() productDetail: ProductDetail): Promise<User> {\n return await getRepository(User).findOneBy({ id: productDetail.creator.id })\n }\n}\n"]}
@@ -0,0 +1,98 @@
1
+ import { ObjectRef } from '@things-factory/shell';
2
+ import { ProductDetail } from './product-detail';
3
+ export declare class NewProductDetail {
4
+ name: string;
5
+ gtin?: string;
6
+ refCode?: string;
7
+ product?: ObjectRef;
8
+ isDefault: boolean;
9
+ packingType?: string;
10
+ packingSize?: number;
11
+ movement?: string;
12
+ uom?: string;
13
+ uomValue?: number;
14
+ childProductDetail?: ObjectRef;
15
+ parentProductDetails?: ObjectRef[];
16
+ childQty?: number;
17
+ weightUnit?: string;
18
+ nettWeight?: number;
19
+ grossWeight?: number;
20
+ lengthUnit?: string;
21
+ width?: number;
22
+ depth?: number;
23
+ height?: number;
24
+ volume?: number;
25
+ bufferQty?: number;
26
+ minQty?: number;
27
+ maxQty?: number;
28
+ auxUnit1?: string;
29
+ auxValue1?: string;
30
+ auxUnit2?: string;
31
+ auxValue2?: string;
32
+ auxUnit3?: string;
33
+ auxValue3?: string;
34
+ auxUnit4?: string;
35
+ auxValue4?: string;
36
+ auxUnit5?: string;
37
+ auxValue5?: string;
38
+ isTrackedAsInventory?: boolean;
39
+ discountId?: number;
40
+ costPrice?: number;
41
+ mrpPrice?: number;
42
+ sellPrice?: number;
43
+ afterTaxCostPrice?: number;
44
+ afterTaxSalesPrice?: number;
45
+ inventoryAccountCode?: string;
46
+ cogsAccountCode?: string;
47
+ }
48
+ export declare class ProductDetailList {
49
+ items?: ProductDetail[];
50
+ total?: number;
51
+ }
52
+ export declare class ProductDetailPatch {
53
+ id?: string;
54
+ name?: string;
55
+ gtin?: string;
56
+ refCode?: string;
57
+ product: ObjectRef;
58
+ isDefault: boolean;
59
+ packingType?: string;
60
+ packingSize?: number;
61
+ movement?: string;
62
+ uom?: string;
63
+ uomValue?: number;
64
+ childProductDetail?: string;
65
+ childGtin?: string;
66
+ childQty?: number;
67
+ weightUnit?: string;
68
+ nettWeight?: number;
69
+ grossWeight?: number;
70
+ lengthUnit?: string;
71
+ width?: number;
72
+ depth?: number;
73
+ height?: number;
74
+ volume?: number;
75
+ bufferQty?: number;
76
+ minQty?: number;
77
+ maxQty?: number;
78
+ auxUnit1?: string;
79
+ auxValue1?: string;
80
+ auxUnit2?: string;
81
+ auxValue2?: string;
82
+ auxUnit3?: string;
83
+ auxValue3?: string;
84
+ auxUnit4?: string;
85
+ auxValue4?: string;
86
+ auxUnit5?: string;
87
+ auxValue5?: string;
88
+ isTrackedAsInventory: boolean;
89
+ discountId?: number;
90
+ costPrice?: number;
91
+ mrpPrice?: number;
92
+ sellPrice?: number;
93
+ afterTaxCostPrice?: number;
94
+ afterTaxSalesPrice?: number;
95
+ inventoryAccountCode?: string;
96
+ cogsAccountCode?: string;
97
+ cuFlag?: string;
98
+ }
@@ -7,6 +7,7 @@ const shell_1 = require("@things-factory/shell");
7
7
  const product_detail_1 = require("./product-detail");
8
8
  let NewProductDetail = class NewProductDetail {
9
9
  };
10
+ exports.NewProductDetail = NewProductDetail;
10
11
  tslib_1.__decorate([
11
12
  (0, type_graphql_1.Field)(),
12
13
  tslib_1.__metadata("design:type", String)
@@ -171,12 +172,12 @@ tslib_1.__decorate([
171
172
  (0, type_graphql_1.Field)({ nullable: true }),
172
173
  tslib_1.__metadata("design:type", String)
173
174
  ], NewProductDetail.prototype, "cogsAccountCode", void 0);
174
- NewProductDetail = tslib_1.__decorate([
175
+ exports.NewProductDetail = NewProductDetail = tslib_1.__decorate([
175
176
  (0, type_graphql_1.InputType)()
176
177
  ], NewProductDetail);
177
- exports.NewProductDetail = NewProductDetail;
178
178
  let ProductDetailList = class ProductDetailList {
179
179
  };
180
+ exports.ProductDetailList = ProductDetailList;
180
181
  tslib_1.__decorate([
181
182
  (0, type_graphql_1.Field)(type => [product_detail_1.ProductDetail], { nullable: true }),
182
183
  tslib_1.__metadata("design:type", Array)
@@ -185,12 +186,12 @@ tslib_1.__decorate([
185
186
  (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true }),
186
187
  tslib_1.__metadata("design:type", Number)
187
188
  ], ProductDetailList.prototype, "total", void 0);
188
- ProductDetailList = tslib_1.__decorate([
189
+ exports.ProductDetailList = ProductDetailList = tslib_1.__decorate([
189
190
  (0, type_graphql_1.ObjectType)()
190
191
  ], ProductDetailList);
191
- exports.ProductDetailList = ProductDetailList;
192
192
  let ProductDetailPatch = class ProductDetailPatch {
193
193
  };
194
+ exports.ProductDetailPatch = ProductDetailPatch;
194
195
  tslib_1.__decorate([
195
196
  (0, type_graphql_1.Field)({ nullable: true }),
196
197
  tslib_1.__metadata("design:type", String)
@@ -371,8 +372,7 @@ tslib_1.__decorate([
371
372
  (0, type_graphql_1.Field)({ nullable: true }),
372
373
  tslib_1.__metadata("design:type", String)
373
374
  ], ProductDetailPatch.prototype, "cuFlag", void 0);
374
- ProductDetailPatch = tslib_1.__decorate([
375
+ exports.ProductDetailPatch = ProductDetailPatch = tslib_1.__decorate([
375
376
  (0, type_graphql_1.InputType)()
376
377
  ], ProductDetailPatch);
377
- exports.ProductDetailPatch = ProductDetailPatch;
378
378
  //# sourceMappingURL=product-detail-types.js.map