@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.
- package/dist-server/routers/api/restful-apis/unstable/add-products.js +32 -16
- package/dist-server/routers/api/restful-apis/unstable/add-products.js.map +1 -1
- package/dist-server/routers/api/restful-apis/unstable/add-release-order.js +88 -9
- package/dist-server/routers/api/restful-apis/unstable/add-release-order.js.map +1 -1
- package/dist-server/routers/api/restful-apis/unstable/cancel-release-order.js +23 -2
- package/dist-server/routers/api/restful-apis/unstable/cancel-release-order.js.map +1 -1
- package/dist-server/routers/api/restful-apis/unstable/get-products.js +1 -0
- package/dist-server/routers/api/restful-apis/unstable/get-products.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v1/add-products.js +32 -16
- package/dist-server/routers/api/restful-apis/v1/add-products.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v1/cancel-release-order.js +23 -2
- package/dist-server/routers/api/restful-apis/v1/cancel-release-order.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v1/get-products.js +1 -0
- package/dist-server/routers/api/restful-apis/v1/get-products.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v2/add-products.js +32 -16
- package/dist-server/routers/api/restful-apis/v2/add-products.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v2/cancel-release-order.js +23 -2
- package/dist-server/routers/api/restful-apis/v2/cancel-release-order.js.map +1 -1
- package/dist-server/routers/api/restful-apis/v2/get-products.js +1 -0
- package/dist-server/routers/api/restful-apis/v2/get-products.js.map +1 -1
- package/openapi/unstable/product.yaml +9 -3
- package/openapi/v1/product.yaml +9 -3
- package/openapi/v2/product.yaml +9 -3
- package/package.json +54 -54
- package/server/routers/api/restful-apis/unstable/add-products.ts +40 -16
- package/server/routers/api/restful-apis/unstable/add-release-order.ts +16 -14
- package/server/routers/api/restful-apis/unstable/get-products.ts +1 -0
- package/server/routers/api/restful-apis/v1/add-products.ts +40 -16
- package/server/routers/api/restful-apis/v1/get-products.ts +1 -0
- package/server/routers/api/restful-apis/v2/add-products.ts +40 -16
- 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
|
|
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.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
+
}
|
|
@@ -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
|
|
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.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
+
}
|