@things-factory/operato-hub 4.3.31 → 4.3.34

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 (31) hide show
  1. package/dist-server/routers/api/restful-apis/unstable/add-products.js +32 -16
  2. package/dist-server/routers/api/restful-apis/unstable/add-products.js.map +1 -1
  3. package/dist-server/routers/api/restful-apis/unstable/add-release-order.js +88 -9
  4. package/dist-server/routers/api/restful-apis/unstable/add-release-order.js.map +1 -1
  5. package/dist-server/routers/api/restful-apis/unstable/cancel-release-order.js +23 -2
  6. package/dist-server/routers/api/restful-apis/unstable/cancel-release-order.js.map +1 -1
  7. package/dist-server/routers/api/restful-apis/unstable/get-products.js +1 -0
  8. package/dist-server/routers/api/restful-apis/unstable/get-products.js.map +1 -1
  9. package/dist-server/routers/api/restful-apis/v1/add-products.js +32 -16
  10. package/dist-server/routers/api/restful-apis/v1/add-products.js.map +1 -1
  11. package/dist-server/routers/api/restful-apis/v1/cancel-release-order.js +23 -2
  12. package/dist-server/routers/api/restful-apis/v1/cancel-release-order.js.map +1 -1
  13. package/dist-server/routers/api/restful-apis/v1/get-products.js +1 -0
  14. package/dist-server/routers/api/restful-apis/v1/get-products.js.map +1 -1
  15. package/dist-server/routers/api/restful-apis/v2/add-products.js +32 -16
  16. package/dist-server/routers/api/restful-apis/v2/add-products.js.map +1 -1
  17. package/dist-server/routers/api/restful-apis/v2/cancel-release-order.js +23 -2
  18. package/dist-server/routers/api/restful-apis/v2/cancel-release-order.js.map +1 -1
  19. package/dist-server/routers/api/restful-apis/v2/get-products.js +1 -0
  20. package/dist-server/routers/api/restful-apis/v2/get-products.js.map +1 -1
  21. package/openapi/unstable/product.yaml +9 -3
  22. package/openapi/v1/product.yaml +9 -3
  23. package/openapi/v2/product.yaml +9 -3
  24. package/package.json +54 -54
  25. package/server/routers/api/restful-apis/unstable/add-products.ts +40 -16
  26. package/server/routers/api/restful-apis/unstable/add-release-order.ts +16 -14
  27. package/server/routers/api/restful-apis/unstable/get-products.ts +1 -0
  28. package/server/routers/api/restful-apis/v1/add-products.ts +40 -16
  29. package/server/routers/api/restful-apis/v1/get-products.ts +1 -0
  30. package/server/routers/api/restful-apis/v2/add-products.ts +40 -16
  31. package/server/routers/api/restful-apis/v2/get-products.ts +1 -0
@@ -29,6 +29,8 @@ router.post(
29
29
  await checkMandatoryKey(context, bodyReq)
30
30
  debug('post:/add-product request.body', bodyReq)
31
31
 
32
+ let products = checkProductDetails(bodyReq)
33
+
32
34
  context.body = {
33
35
  result: (
34
36
  await client.mutate({
@@ -39,7 +41,7 @@ router.post(
39
41
  }
40
42
  }
41
43
  `,
42
- variables: { products: bodyReq },
44
+ variables: { products },
43
45
  context: {
44
46
  ...context,
45
47
  state: {
@@ -66,23 +68,45 @@ export async function checkMandatoryKey(context, params) {
66
68
 
67
69
  if (param?.productDetails) {
68
70
  let noSubParams = []
69
- param.productDetails.forEach((subParam, key) => {
70
- if (!subParam.gtin) noSubParams.push('gtin')
71
-
72
- if (!subParam.packingType) noSubParams.push('packingType')
73
-
74
- if (!subParam.packingSize) noSubParams.push('packingSize')
75
-
76
- if (!subParam.uom) noSubParams.push('uom')
77
-
78
- if (!subParam.uomValue) noSubParams.push('uomValue')
79
-
80
- if (noSubParams?.length)
81
- context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }))
82
- })
71
+ if (param.productDetails.length == 0) {
72
+ context.throw(
73
+ 400,
74
+ context.t('error.required param {x} not found in productDetails', {
75
+ x: 'gtin, packingType, packingSize, uom, uomValue'
76
+ })
77
+ )
78
+ } else {
79
+ param.productDetails.forEach((subParam, key) => {
80
+ if (!subParam.gtin) noSubParams.push('gtin')
81
+
82
+ if (!subParam.packingType) noSubParams.push('packingType')
83
+
84
+ if (!subParam.packingSize) noSubParams.push('packingSize')
85
+
86
+ if (!subParam.uom) noSubParams.push('uom')
87
+
88
+ if (!subParam.uomValue) noSubParams.push('uomValue')
89
+
90
+ if (noSubParams?.length)
91
+ context.throw(
92
+ 400,
93
+ context.t('error.required param {x} not found in productDetails', { x: `${noSubParams.join(', ')}` })
94
+ )
95
+ })
96
+ }
83
97
  }
84
98
 
85
99
  if (noparams?.length)
86
- context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }))
100
+ context.throw(400, context.t('error.required param {x} not found', { x: `${noparams.join(', ')}` }))
87
101
  })
88
102
  }
103
+
104
+ function checkProductDetails(params) {
105
+ params.forEach(param => {
106
+ if (!param?.productDetails.some(pd => pd.isDefault)) {
107
+ param.productDetails[0].isDefault = true
108
+ }
109
+ })
110
+
111
+ return params
112
+ }
@@ -40,6 +40,7 @@ router.get(
40
40
  brandSku
41
41
  isRequiredCheckExpiry
42
42
  expirationPeriod
43
+ pickingStrategy
43
44
  auxUnit1
44
45
  auxValue1
45
46
  auxUnit2
@@ -29,6 +29,8 @@ router.post(
29
29
  await checkMandatoryKey(context, bodyReq)
30
30
  debug('post:/add-product request.body', bodyReq)
31
31
 
32
+ let products = checkProductDetails(bodyReq)
33
+
32
34
  context.body = {
33
35
  result: (
34
36
  await client.mutate({
@@ -39,7 +41,7 @@ router.post(
39
41
  }
40
42
  }
41
43
  `,
42
- variables: { products: bodyReq },
44
+ variables: { products },
43
45
  context: {
44
46
  ...context,
45
47
  state: {
@@ -66,23 +68,45 @@ export async function checkMandatoryKey(context, params) {
66
68
 
67
69
  if (param?.productDetails) {
68
70
  let noSubParams = []
69
- param.productDetails.forEach((subParam, key) => {
70
- if (!subParam.gtin) noSubParams.push('gtin')
71
-
72
- if (!subParam.packingType) noSubParams.push('packingType')
73
-
74
- if (!subParam.packingSize) noSubParams.push('packingSize')
75
-
76
- if (!subParam.uom) noSubParams.push('uom')
77
-
78
- if (!subParam.uomValue) noSubParams.push('uomValue')
79
-
80
- if (noSubParams?.length)
81
- context.throw(400, context.t('error.required param x not found', { x: `${noSubParams.join(', ')}` }))
82
- })
71
+ if (param.productDetails.length == 0) {
72
+ context.throw(
73
+ 400,
74
+ context.t('error.required param {x} not found in productDetails', {
75
+ x: 'gtin, packingType, packingSize, uom, uomValue'
76
+ })
77
+ )
78
+ } else {
79
+ param.productDetails.forEach((subParam, key) => {
80
+ if (!subParam.gtin) noSubParams.push('gtin')
81
+
82
+ if (!subParam.packingType) noSubParams.push('packingType')
83
+
84
+ if (!subParam.packingSize) noSubParams.push('packingSize')
85
+
86
+ if (!subParam.uom) noSubParams.push('uom')
87
+
88
+ if (!subParam.uomValue) noSubParams.push('uomValue')
89
+
90
+ if (noSubParams?.length)
91
+ context.throw(
92
+ 400,
93
+ context.t('error.required param {x} not found in productDetails', { x: `${noSubParams.join(', ')}` })
94
+ )
95
+ })
96
+ }
83
97
  }
84
98
 
85
99
  if (noparams?.length)
86
- context.throw(400, context.t('error.required param x not found', { x: `${noparams.join(', ')}` }))
100
+ context.throw(400, context.t('error.required param {x} not found', { x: `${noparams.join(', ')}` }))
87
101
  })
88
102
  }
103
+
104
+ function checkProductDetails(params) {
105
+ params.forEach(param => {
106
+ if (!param?.productDetails.some(pd => pd.isDefault)) {
107
+ param.productDetails[0].isDefault = true
108
+ }
109
+ })
110
+
111
+ return params
112
+ }
@@ -40,6 +40,7 @@ router.get(
40
40
  brandSku
41
41
  isRequiredCheckExpiry
42
42
  expirationPeriod
43
+ pickingStrategy
43
44
  auxUnit1
44
45
  auxValue1
45
46
  auxUnit2