@things-factory/operato-hub 4.1.7 → 4.1.13

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 (41) hide show
  1. package/config.development.js +67 -0
  2. package/dist-server/graphql/resolvers/synchronization/sync-products-to-sellercraft.js +4 -11
  3. package/dist-server/graphql/resolvers/synchronization/sync-products-to-sellercraft.js.map +1 -1
  4. package/dist-server/routers/api/restful-apis/unstable/add-products.js +1 -1
  5. package/dist-server/routers/api/restful-apis/unstable/add-products.js.map +1 -1
  6. package/dist-server/routers/api/restful-apis/unstable/get-inventory-overall-product-group.js +84 -0
  7. package/dist-server/routers/api/restful-apis/unstable/get-inventory-overall-product-group.js.map +1 -0
  8. package/dist-server/routers/api/restful-apis/unstable/get-marketplace-order-shipping-list.js +10 -8
  9. package/dist-server/routers/api/restful-apis/unstable/get-marketplace-order-shipping-list.js.map +1 -1
  10. package/dist-server/routers/api/restful-apis/unstable/index.js +1 -0
  11. package/dist-server/routers/api/restful-apis/unstable/index.js.map +1 -1
  12. package/dist-server/routers/api/restful-apis/v1/add-products.js +1 -1
  13. package/dist-server/routers/api/restful-apis/v1/add-products.js.map +1 -1
  14. package/dist-server/routers/api/restful-apis/v1/get-inventory-overall-product-group.js +84 -0
  15. package/dist-server/routers/api/restful-apis/v1/get-inventory-overall-product-group.js.map +1 -0
  16. package/dist-server/routers/api/restful-apis/v1/get-marketplace-order-shipping-list.js +10 -8
  17. package/dist-server/routers/api/restful-apis/v1/get-marketplace-order-shipping-list.js.map +1 -1
  18. package/dist-server/routers/api/restful-apis/v1/index.js +1 -0
  19. package/dist-server/routers/api/restful-apis/v1/index.js.map +1 -1
  20. package/dist-server/routers/api/restful-apis/v2/add-products.js +1 -1
  21. package/dist-server/routers/api/restful-apis/v2/add-products.js.map +1 -1
  22. package/dist-server/routers/api/restful-apis/v2/get-inventory-overall-product-group.js +84 -0
  23. package/dist-server/routers/api/restful-apis/v2/get-inventory-overall-product-group.js.map +1 -0
  24. package/dist-server/routers/api/restful-apis/v2/get-marketplace-order-shipping-list.js +10 -8
  25. package/dist-server/routers/api/restful-apis/v2/get-marketplace-order-shipping-list.js.map +1 -1
  26. package/dist-server/routers/api/restful-apis/v2/index.js +1 -0
  27. package/dist-server/routers/api/restful-apis/v2/index.js.map +1 -1
  28. package/package.json +69 -69
  29. package/server/graphql/resolvers/synchronization/sync-products-to-sellercraft.ts +4 -12
  30. package/server/routers/api/restful-apis/unstable/add-products.ts +1 -1
  31. package/server/routers/api/restful-apis/unstable/get-inventory-overall-product-group.ts +95 -0
  32. package/server/routers/api/restful-apis/unstable/get-marketplace-order-shipping-list.ts +10 -8
  33. package/server/routers/api/restful-apis/unstable/index.ts +1 -0
  34. package/server/routers/api/restful-apis/v1/add-products.ts +1 -1
  35. package/server/routers/api/restful-apis/v1/get-inventory-overall-product-group.ts +95 -0
  36. package/server/routers/api/restful-apis/v1/get-marketplace-order-shipping-list.ts +10 -8
  37. package/server/routers/api/restful-apis/v1/index.ts +1 -0
  38. package/server/routers/api/restful-apis/v2/add-products.ts +1 -1
  39. package/server/routers/api/restful-apis/v2/get-inventory-overall-product-group.ts +95 -0
  40. package/server/routers/api/restful-apis/v2/get-marketplace-order-shipping-list.ts +10 -8
  41. package/server/routers/api/restful-apis/v2/index.ts +1 -0
@@ -0,0 +1,95 @@
1
+ import gql from 'graphql-tag'
2
+
3
+ import { restfulApiRouter as router } from '@things-factory/api'
4
+
5
+ import { businessMiddleware } from '../../../../middlewares/business-middleware'
6
+ import { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'
7
+
8
+ const debug = require('debug')('things-factory:operato-hub:restful-api:v2:get-inventory-product-group-open-api')
9
+
10
+ router.get(
11
+ '/v2/warehouse/:warehouseId/get-inventory-product-group-open-api',
12
+ businessMiddleware,
13
+ warehouseMiddleware,
14
+ async (context, next) => {
15
+ const { client, warehouse: bizplace, domain } = context.state
16
+ const { warehouseId } = context.params
17
+ const { t } = context
18
+ const { skuId, packingType, batchId, paginationEntriesPerPage, paginationOffset } = context.query
19
+
20
+ if (!warehouseId) context.throw(404, t('error.warehouse id not found'))
21
+
22
+ let filters: any = [{ name: 'bizplace_id', operator: 'in', value: [warehouseId] }]
23
+ let pagination: any = { page: 1, limit: 100 }
24
+
25
+ filters = await validateFilters(context, filters, skuId, batchId, packingType)
26
+ pagination = await validatePagination(context, pagination, paginationEntriesPerPage, paginationOffset)
27
+
28
+ debug('query-params', context.query)
29
+
30
+ context.body = {
31
+ result: (
32
+ await client.query({
33
+ query: gql`
34
+ query inventoryProductGroupOpenAPI($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
35
+ inventoryProductGroupOpenAPI(filters: $filters, pagination: $pagination, sortings: $sortings) {
36
+ items {
37
+ productSKU
38
+ productName
39
+ packingType
40
+ remainQty
41
+ remainUomValue
42
+ uom
43
+ }
44
+ total
45
+ }
46
+ }
47
+ `,
48
+ variables: { filters, pagination, sortings: [] },
49
+ context: {
50
+ ...context,
51
+ state: {
52
+ ...context.state,
53
+ bizplace,
54
+ domain
55
+ }
56
+ }
57
+ } as any)
58
+ ).data
59
+ }
60
+ }
61
+ )
62
+
63
+ export async function validateFilters(context, filters, skuId, batchId, packingType) {
64
+ if (skuId) {
65
+ filters = [
66
+ ...filters,
67
+ {
68
+ name: 'productName',
69
+ operator: 'i_like',
70
+ value: skuId
71
+ }
72
+ ]
73
+ }
74
+
75
+ return filters
76
+ }
77
+
78
+ export async function validatePagination(context, pagination, entries, offset) {
79
+ if (entries !== '' && offset !== '' && !isNaN(parseInt(entries)) && !isNaN(parseInt(offset))) {
80
+ entries = parseInt(entries)
81
+ offset = parseInt(offset)
82
+
83
+ if (entries < 1) context.throw(400, context.t('paginationEntriesPerPage cannot be less than 1'))
84
+ else if (entries > 100) context.throw(400, context.t('paginationEntriesPerPage cannot be more than 100'))
85
+ else pagination = { ...pagination, page: offset, limit: entries }
86
+ } else if (entries !== '' && offset === '' && !isNaN(parseInt(entries))) {
87
+ entries = parseInt(entries)
88
+
89
+ if (entries < 1) context.throw(400, context.t('paginationEntriesPerPage cannot be less than 1'))
90
+ else if (entries > 100) context.throw(400, context.t('paginationEntriesPerPage cannot be more than 100'))
91
+ else pagination = { ...pagination, limit: entries }
92
+ }
93
+
94
+ return pagination
95
+ }
@@ -63,15 +63,17 @@ router.get(
63
63
  name
64
64
  storeId
65
65
  }
66
- marketplaceOrderItems {
67
- id
68
- qty
69
- status
70
- marketplaceProductVariation {
66
+ marketplaceOrderShippingItems {
67
+ marketplaceOrderItem {
71
68
  id
72
- variationId
73
- name
74
- sku
69
+ qty
70
+ status
71
+ marketplaceProductVariation {
72
+ id
73
+ variationId
74
+ name
75
+ sku
76
+ }
75
77
  }
76
78
  }
77
79
  }
@@ -11,6 +11,7 @@ import './get-delivery-order-list'
11
11
  import './get-inbound-order-detail'
12
12
  import './get-inbound-order-list'
13
13
  import './get-inventory-product-group'
14
+ import './get-inventory-overall-product-group'
14
15
  import './get-onhand-inventories'
15
16
  import './get-products'
16
17
  import './get-release-order-detail'