@things-factory/operato-hub 6.1.83 → 6.1.85

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 (189) hide show
  1. package/dist-server/tsconfig.tsbuildinfo +1 -1
  2. package/package.json +46 -46
  3. package/server/controllers/bizplace-initializer/codes.ts +0 -32
  4. package/server/controllers/bizplace-initializer/dataset/codes.ts +0 -398
  5. package/server/controllers/bizplace-initializer/dataset/groups.ts +0 -21
  6. package/server/controllers/bizplace-initializer/dataset/index.ts +0 -5
  7. package/server/controllers/bizplace-initializer/dataset/menus.ts +0 -500
  8. package/server/controllers/bizplace-initializer/dataset/roles-privileges.ts +0 -402
  9. package/server/controllers/bizplace-initializer/dataset/settings.ts +0 -91
  10. package/server/controllers/bizplace-initializer/generate-bizplace-domain-roles.ts +0 -29
  11. package/server/controllers/bizplace-initializer/generate-bizplace-domain.ts +0 -56
  12. package/server/controllers/bizplace-initializer/groups.ts +0 -19
  13. package/server/controllers/bizplace-initializer/index.ts +0 -5
  14. package/server/controllers/bizplace-initializer/menus.ts +0 -42
  15. package/server/controllers/bizplace-initializer/settings.ts +0 -20
  16. package/server/controllers/company-initializer/business-register.ts +0 -59
  17. package/server/controllers/company-initializer/codes.ts +0 -147
  18. package/server/controllers/company-initializer/generate-company-roles.ts +0 -119
  19. package/server/controllers/company-initializer/index.ts +0 -6
  20. package/server/controllers/company-initializer/menus.ts +0 -359
  21. package/server/controllers/company-initializer/settings.ts +0 -33
  22. package/server/controllers/company-initializer/transporter.ts +0 -20
  23. package/server/controllers/index.ts +0 -0
  24. package/server/controllers/invitation.ts +0 -132
  25. package/server/controllers/utils/make-invitation-token.ts +0 -5
  26. package/server/controllers/utils/save-invitation-token.ts +0 -9
  27. package/server/entities/index.ts +0 -0
  28. package/server/errors/index.ts +0 -1
  29. package/server/errors/validation-error.ts +0 -17
  30. package/server/graphql/index.ts +0 -7
  31. package/server/graphql/resolvers/generators/generate-bizplace.ts +0 -40
  32. package/server/graphql/resolvers/generators/generate-company.ts +0 -76
  33. package/server/graphql/resolvers/generators/index.ts +0 -9
  34. package/server/graphql/resolvers/generators/update-domain-extType.ts +0 -55
  35. package/server/graphql/resolvers/index.ts +0 -8
  36. package/server/graphql/resolvers/invitations/index.ts +0 -5
  37. package/server/graphql/resolvers/invitations/partner-invitation.ts +0 -62
  38. package/server/graphql/resolvers/oauth2/company-roles-by-scope.ts +0 -38
  39. package/server/graphql/resolvers/oauth2/index.ts +0 -5
  40. package/server/graphql/resolvers/synchronization/auto-update-all-marketplace-product-variation-quantity.ts +0 -180
  41. package/server/graphql/resolvers/synchronization/create-dat-shipments.ts +0 -64
  42. package/server/graphql/resolvers/synchronization/fetch-sync-invoices.ts +0 -52
  43. package/server/graphql/resolvers/synchronization/fetch-sync-products.ts +0 -99
  44. package/server/graphql/resolvers/synchronization/fetch-sync-purchase-orders.ts +0 -75
  45. package/server/graphql/resolvers/synchronization/index.ts +0 -26
  46. package/server/graphql/resolvers/synchronization/sellercraft-pack-marketplace-order.ts +0 -91
  47. package/server/graphql/resolvers/synchronization/sync-all-products-to-sellercraft.ts +0 -39
  48. package/server/graphql/resolvers/synchronization/sync-products-from-account.ts +0 -40
  49. package/server/graphql/resolvers/synchronization/sync-products-to-account.ts +0 -64
  50. package/server/graphql/resolvers/synchronization/sync-products-to-sellercraft.ts +0 -176
  51. package/server/graphql/types/generators/generate-bizplace-input.ts +0 -11
  52. package/server/graphql/types/generators/generate-company-input.ts +0 -11
  53. package/server/graphql/types/generators/index.ts +0 -11
  54. package/server/graphql/types/generators/update-domain-type-input.ts +0 -8
  55. package/server/graphql/types/index.ts +0 -10
  56. package/server/graphql/types/invitations/index.ts +0 -5
  57. package/server/graphql/types/oauth2/company-role.ts +0 -8
  58. package/server/graphql/types/oauth2/index.ts +0 -7
  59. package/server/graphql/types/synchronization/index.ts +0 -33
  60. package/server/graphql/types/synchronization/sync-invoice-list.ts +0 -8
  61. package/server/graphql/types/synchronization/sync-invoice-set.ts +0 -38
  62. package/server/graphql/types/synchronization/sync-product-list.ts +0 -8
  63. package/server/graphql/types/synchronization/sync-product-set.ts +0 -8
  64. package/server/graphql/types/synchronization/sync-purchase-order-list.ts +0 -8
  65. package/server/graphql/types/synchronization/sync-purchase-order-set.ts +0 -28
  66. package/server/index.ts +0 -37
  67. package/server/middlewares/business-middleware.ts +0 -32
  68. package/server/middlewares/index.ts +0 -20
  69. package/server/middlewares/store-middleware.ts +0 -36
  70. package/server/middlewares/warehouse-middleware.ts +0 -36
  71. package/server/migrations/1597668478399-SeedBusinessDomain.ts +0 -34
  72. package/server/migrations/1597668478401-SeedBusinessRoles.ts +0 -377
  73. package/server/migrations/1608009991065-SeedUser.ts +0 -64
  74. package/server/migrations/index.ts +0 -9
  75. package/server/routers/api/index.ts +0 -3
  76. package/server/routers/api/restful-apis/unstable/add-contact-point.ts +0 -89
  77. package/server/routers/api/restful-apis/unstable/add-draft-release-order.ts +0 -198
  78. package/server/routers/api/restful-apis/unstable/add-inbound-order.ts +0 -246
  79. package/server/routers/api/restful-apis/unstable/add-marketplace-order.ts +0 -171
  80. package/server/routers/api/restful-apis/unstable/add-products.ts +0 -112
  81. package/server/routers/api/restful-apis/unstable/add-release-order.ts +0 -1061
  82. package/server/routers/api/restful-apis/unstable/add-sales-invoice.ts +0 -144
  83. package/server/routers/api/restful-apis/unstable/bizplace.ts +0 -45
  84. package/server/routers/api/restful-apis/unstable/cancel-marketplace-order.ts +0 -81
  85. package/server/routers/api/restful-apis/unstable/cancel-release-order.ts +0 -91
  86. package/server/routers/api/restful-apis/unstable/get-contact-point-list.ts +0 -110
  87. package/server/routers/api/restful-apis/unstable/get-delivery-order-detail.ts +0 -46
  88. package/server/routers/api/restful-apis/unstable/get-delivery-order-list.ts +0 -121
  89. package/server/routers/api/restful-apis/unstable/get-delivery-orders.ts +0 -178
  90. package/server/routers/api/restful-apis/unstable/get-goods-received-notes.ts +0 -134
  91. package/server/routers/api/restful-apis/unstable/get-inbound-order-detail.ts +0 -128
  92. package/server/routers/api/restful-apis/unstable/get-inbound-order-list.ts +0 -126
  93. package/server/routers/api/restful-apis/unstable/get-inventory-overall-product-group.ts +0 -99
  94. package/server/routers/api/restful-apis/unstable/get-inventory-product-group.ts +0 -107
  95. package/server/routers/api/restful-apis/unstable/get-marketplace-order-shipping-list.ts +0 -156
  96. package/server/routers/api/restful-apis/unstable/get-marketplace-store-list.ts +0 -81
  97. package/server/routers/api/restful-apis/unstable/get-onhand-inventories.ts +0 -125
  98. package/server/routers/api/restful-apis/unstable/get-partners.ts +0 -26
  99. package/server/routers/api/restful-apis/unstable/get-products.ts +0 -216
  100. package/server/routers/api/restful-apis/unstable/get-release-order-detail.ts +0 -138
  101. package/server/routers/api/restful-apis/unstable/get-release-order-list.ts +0 -199
  102. package/server/routers/api/restful-apis/unstable/get-warehouses.ts +0 -19
  103. package/server/routers/api/restful-apis/unstable/index.ts +0 -32
  104. package/server/routers/api/restful-apis/unstable/reject-inbound-order.ts +0 -46
  105. package/server/routers/api/restful-apis/unstable/set-marketplace-order-delivered.ts +0 -60
  106. package/server/routers/api/restful-apis/unstable/set-marketplace-order-failed-delivery.ts +0 -60
  107. package/server/routers/api/restful-apis/unstable/update-marketplace-order.ts +0 -111
  108. package/server/routers/api/restful-apis/unstable/update-marketplace-shipping-order.ts +0 -107
  109. package/server/routers/api/restful-apis/unstable/update-release-order-details.ts +0 -94
  110. package/server/routers/api/restful-apis/v1/add-contact-point.ts +0 -77
  111. package/server/routers/api/restful-apis/v1/add-draft-release-order.ts +0 -196
  112. package/server/routers/api/restful-apis/v1/add-inbound-order.ts +0 -243
  113. package/server/routers/api/restful-apis/v1/add-marketplace-order.ts +0 -172
  114. package/server/routers/api/restful-apis/v1/add-products.ts +0 -112
  115. package/server/routers/api/restful-apis/v1/add-release-order.ts +0 -967
  116. package/server/routers/api/restful-apis/v1/bizplace.ts +0 -45
  117. package/server/routers/api/restful-apis/v1/cancel-marketplace-order.ts +0 -81
  118. package/server/routers/api/restful-apis/v1/cancel-release-order.ts +0 -91
  119. package/server/routers/api/restful-apis/v1/get-contact-point-list.ts +0 -110
  120. package/server/routers/api/restful-apis/v1/get-delivery-order-detail.ts +0 -46
  121. package/server/routers/api/restful-apis/v1/get-delivery-order-list.ts +0 -121
  122. package/server/routers/api/restful-apis/v1/get-delivery-orders.ts +0 -178
  123. package/server/routers/api/restful-apis/v1/get-goods-received-notes.ts +0 -134
  124. package/server/routers/api/restful-apis/v1/get-inbound-order-detail.ts +0 -128
  125. package/server/routers/api/restful-apis/v1/get-inbound-order-list.ts +0 -126
  126. package/server/routers/api/restful-apis/v1/get-inventory-overall-product-group.ts +0 -99
  127. package/server/routers/api/restful-apis/v1/get-inventory-product-group.ts +0 -112
  128. package/server/routers/api/restful-apis/v1/get-marketplace-order-shipping-list.ts +0 -156
  129. package/server/routers/api/restful-apis/v1/get-marketplace-store-list.ts +0 -81
  130. package/server/routers/api/restful-apis/v1/get-onhand-inventories.ts +0 -125
  131. package/server/routers/api/restful-apis/v1/get-partners.ts +0 -26
  132. package/server/routers/api/restful-apis/v1/get-products.ts +0 -216
  133. package/server/routers/api/restful-apis/v1/get-release-order-detail.ts +0 -134
  134. package/server/routers/api/restful-apis/v1/get-release-order-list.ts +0 -198
  135. package/server/routers/api/restful-apis/v1/get-warehouses.ts +0 -19
  136. package/server/routers/api/restful-apis/v1/index.ts +0 -31
  137. package/server/routers/api/restful-apis/v1/reject-inbound-order.ts +0 -46
  138. package/server/routers/api/restful-apis/v1/set-marketplace-order-delivered.ts +0 -60
  139. package/server/routers/api/restful-apis/v1/set-marketplace-order-failed-delivery.ts +0 -60
  140. package/server/routers/api/restful-apis/v1/update-marketplace-order.ts +0 -111
  141. package/server/routers/api/restful-apis/v1/update-marketplace-shipping-order.ts +0 -104
  142. package/server/routers/api/restful-apis/v1/update-release-order-details.ts +0 -94
  143. package/server/routers/api/restful-apis/v2/add-contact-point.ts +0 -77
  144. package/server/routers/api/restful-apis/v2/add-draft-release-order.ts +0 -196
  145. package/server/routers/api/restful-apis/v2/add-inbound-order.ts +0 -243
  146. package/server/routers/api/restful-apis/v2/add-marketplace-order.ts +0 -172
  147. package/server/routers/api/restful-apis/v2/add-products.ts +0 -112
  148. package/server/routers/api/restful-apis/v2/add-release-order.ts +0 -967
  149. package/server/routers/api/restful-apis/v2/bizplace.ts +0 -45
  150. package/server/routers/api/restful-apis/v2/cancel-marketplace-order.ts +0 -81
  151. package/server/routers/api/restful-apis/v2/cancel-release-order.ts +0 -91
  152. package/server/routers/api/restful-apis/v2/get-contact-point-list.ts +0 -110
  153. package/server/routers/api/restful-apis/v2/get-delivery-order-detail.ts +0 -46
  154. package/server/routers/api/restful-apis/v2/get-delivery-order-list.ts +0 -121
  155. package/server/routers/api/restful-apis/v2/get-delivery-orders.ts +0 -178
  156. package/server/routers/api/restful-apis/v2/get-goods-received-notes.ts +0 -134
  157. package/server/routers/api/restful-apis/v2/get-inbound-order-detail.ts +0 -128
  158. package/server/routers/api/restful-apis/v2/get-inbound-order-list.ts +0 -126
  159. package/server/routers/api/restful-apis/v2/get-inventory-overall-product-group.ts +0 -99
  160. package/server/routers/api/restful-apis/v2/get-inventory-product-group.ts +0 -112
  161. package/server/routers/api/restful-apis/v2/get-marketplace-order-shipping-list.ts +0 -156
  162. package/server/routers/api/restful-apis/v2/get-marketplace-store-list.ts +0 -81
  163. package/server/routers/api/restful-apis/v2/get-onhand-inventories.ts +0 -125
  164. package/server/routers/api/restful-apis/v2/get-partners.ts +0 -26
  165. package/server/routers/api/restful-apis/v2/get-products.ts +0 -216
  166. package/server/routers/api/restful-apis/v2/get-release-order-detail.ts +0 -134
  167. package/server/routers/api/restful-apis/v2/get-release-order-list.ts +0 -198
  168. package/server/routers/api/restful-apis/v2/get-warehouses.ts +0 -19
  169. package/server/routers/api/restful-apis/v2/index.ts +0 -31
  170. package/server/routers/api/restful-apis/v2/reject-inbound-order.ts +0 -46
  171. package/server/routers/api/restful-apis/v2/set-marketplace-order-delivered.ts +0 -60
  172. package/server/routers/api/restful-apis/v2/set-marketplace-order-failed-delivery.ts +0 -60
  173. package/server/routers/api/restful-apis/v2/update-marketplace-order.ts +0 -111
  174. package/server/routers/api/restful-apis/v2/update-marketplace-shipping-order.ts +0 -104
  175. package/server/routers/api/restful-apis/v2/update-release-order-details.ts +0 -94
  176. package/server/routers/auth-invitation-router.ts +0 -25
  177. package/server/routers/business/bizplace-register-router.ts +0 -31
  178. package/server/routers/business/business-register-router.ts +0 -32
  179. package/server/routers/business/index.ts +0 -3
  180. package/server/routers/business/path-base-business-router.ts +0 -15
  181. package/server/routes.ts +0 -28
  182. package/server/templates/account-unlock-email.ts +0 -64
  183. package/server/templates/invitation-email.ts +0 -65
  184. package/server/templates/reset-password-email.ts +0 -64
  185. package/server/templates/verification-email.ts +0 -65
  186. package/server/utils/build-map.ts +0 -18
  187. package/server/utils/get-warehouses.ts +0 -115
  188. package/server/utils/index.ts +0 -3
  189. package/server/utils/order-no-generator.ts +0 -8
@@ -1,64 +0,0 @@
1
- import { Bizplace } from '@things-factory/biz-base'
2
- import { AccountingAPI } from '@things-factory/integration-accounting'
3
- import { Product } from '@things-factory/product-base'
4
-
5
- import { buildMap } from '../../../utils/build-map'
6
- import { getAccountingProducts } from './fetch-sync-products'
7
-
8
- export const syncProductsToAccountResolver = {
9
- async syncProductsToAccount(
10
- _: void,
11
- { accountId, bizplaceId }: { accountId: string; bizplaceId: string },
12
- context: ResolverContext
13
- ): Promise<void> {
14
- try {
15
- const { tx } = context.state
16
-
17
- const bizplace: Bizplace = await tx.getRepository(Bizplace).findOneBy({ id: bizplaceId })
18
- const bizplaceProducts: Product[] = await tx
19
- .getRepository(Product)
20
- .find({ where: { bizplace: { id: bizplace.id } } })
21
-
22
- let platformProducts: Product[] = await getAccountingProducts(accountId)
23
- let platformProductsMap: Map<string, Product> = buildMap(platformProducts, 'sku')
24
-
25
- const updateTargetProducts: Product[] = bizplaceProducts.map((bizplaceProduct: Product) => {
26
- let platformProduct: Product = {}
27
- if (platformProductsMap.has(bizplaceProduct.sku)) {
28
- platformProduct = platformProductsMap.get(bizplaceProduct.sku)
29
- }
30
-
31
- Object.keys(bizplaceProduct).forEach((key: string) => {
32
- platformProduct[key] = bizplaceProduct[key]
33
- })
34
-
35
- return platformProduct
36
- })
37
-
38
- const chunkedProducts: Product[][] = splitChunk(updateTargetProducts)
39
- const accounting: AccountingAPI = await AccountingAPI.getAccounting(accountId)
40
-
41
- for (let i: number = 0; i < chunkedProducts.length; i++) {
42
- const products: Product[] = chunkedProducts[i]
43
- const req = context.req
44
- req.products = products
45
- try {
46
- await AccountingAPI.updateItems(accounting, req)
47
- } catch (e) {
48
- throw new Error(e.statusText)
49
- }
50
- }
51
- } catch (e) {
52
- throw e
53
- }
54
- }
55
- }
56
-
57
- function splitChunk<T>(data: T[], unitCnt: number = 100): T[][] {
58
- let splitChunk: T[][] = []
59
- while (data.length > 0) {
60
- splitChunk.push(data.splice(0, unitCnt))
61
- }
62
-
63
- return splitChunk
64
- }
@@ -1,176 +0,0 @@
1
- import { Bizplace } from '@things-factory/biz-base'
2
- import { logger } from '@things-factory/env'
3
- import { FulfillmentAPI, FulfillmentCenter } from '@things-factory/integration-fulfillment'
4
- import { Sellercraft, SellercraftAPI } from '@things-factory/integration-sellercraft'
5
- import { ProductDetail } from '@things-factory/product-base'
6
- import { Domain } from '@things-factory/shell'
7
-
8
- export const syncProductsToSellercraftResolver = {
9
- async syncProductsToSellercraft(
10
- _: void,
11
- {
12
- sellercraftId,
13
- fulfillmentCenterId
14
- }: { sellercraftId: string; fulfillmentCenterId: string; toCreateSku: boolean },
15
- context: any
16
- ): Promise<void> {
17
- try {
18
- const { domain, tx } = context.state
19
-
20
- let page: number = 0
21
- let hasMorePage: boolean = true
22
- const limit: number = 50
23
-
24
- const sellercraft: Sellercraft = await tx
25
- .getRepository(Sellercraft)
26
- .findOne({ where: { id: sellercraftId }, relations: ['domain'] })
27
- const customerDomain: Domain = sellercraft.domain
28
- const fulfilmentCenter: FulfillmentCenter = await FulfillmentAPI.getFulfillmentCenter(fulfillmentCenterId)
29
- const customerBizplace: Bizplace = await tx
30
- .getRepository(Bizplace)
31
- .findOne({ where: { domain: { id: customerDomain.id } } })
32
-
33
- await tx.query(
34
- `
35
- create temp table temp_warehouse_product_inventory ON COMMIT DROP as (
36
- select p.id, p.sku as product_sku, p.name as product_name, p.description as product_description,
37
- pd.gtin, pd.uom, pd.packing_size, coalesce(pd.nett_weight, 0) as nett_weight, pd.width, pd."depth", pd.height,
38
- coalesce(src.qty, 0) as available_qty, coalesce(src.qty - src."remainQty", 0) as reserved_qty, coalesce(src."remainQty",0) as remain_qty
39
- from bizplaces b
40
- inner join companies c on c.id = b.company_id
41
- inner join domains d on d.id = c.domain_id
42
- inner join products p on p.domain_id = b.domain_id or p.domain_id = c.domain_id
43
- inner join product_details pd on pd.product_id = p.id
44
- left join (
45
- select wboi.* from warehouse_bizplace_onhand_inventories wboi
46
- inner join domains d on d.id = wboi."domainId"
47
- inner join fulfillment_centers fc on d.subdomain = fc.center_id
48
- where fc.id= $1
49
- and wboi."bizplaceId" = $2 and "groupType" = 'SINGLE'
50
- ) src on src."productId" = pd."product_id"
51
- and src."packingType" = pd."packing_type"
52
- and src."packingSize" = pd."packing_size"
53
- and src."uom" = pd."uom"
54
- where b.id = $2
55
- )
56
- `,
57
- [fulfilmentCenter.id, customerBizplace.id]
58
- )
59
-
60
- let total = await tx.query(`
61
- select count(*) from temp_warehouse_product_inventory
62
- `)
63
-
64
- while (hasMorePage) {
65
- hasMorePage = false
66
- try {
67
- // const { items, total } = await FulfillmentAPI.getInventoryProductGroupOpenAPI(fulfilmentCenter, {
68
- // warehouseId: customerBizplace.id,
69
- // paginationEntriesPerPage: limit,
70
- // paginationOffset: page
71
- // })
72
-
73
- const items = await tx.query(
74
- `
75
- select * from temp_warehouse_product_inventory limit $1 offset $2
76
- `,
77
- [limit, page * limit]
78
- )
79
-
80
- let sellercraftInv: any[] = []
81
-
82
- items.map(async item => {
83
- let packingSize: number = 1
84
-
85
- sellercraftInv.push({
86
- sku: item.product_sku,
87
- gtin: item.gtin,
88
- stock: {
89
- quantity_total: item.available_qty * packingSize < 0 ? 0 : item.available_qty * packingSize,
90
- quantity_reserved: item.reserved_qty * packingSize < 0 ? 0 : item.reserved_qty * packingSize,
91
- unit_of_measure: 'EA'
92
- },
93
- package_weight_gm: item.nett_weight <= 0 ? 1 : item.nett_weight,
94
- package_dimensions: {
95
- length_mm: item.depth <= 0 ? 1 : item.depth,
96
- width_mm: item.width <= 0 ? 1 : item.width,
97
- height_mm: item.height <= 0 ? 1 : item.height
98
- }
99
- })
100
- })
101
-
102
- const delay = (ms: number) => {
103
- return new Promise(resolve => setTimeout(resolve, ms))
104
- }
105
-
106
- await delay(500)
107
-
108
- await SellercraftAPI.updateProduct(sellercraft, { context, accountId: sellercraft.accountId, sellercraftInv })
109
-
110
- page++
111
- hasMorePage = (total[0]?.count || 0) > page * limit
112
- } catch (e) {
113
- logger.error(
114
- `[syncProductsToSellercraftResolver] sellercraftID:${sellercraftId} fulfillmentCenterId:${fulfillmentCenterId} page:${page} - ${e}`
115
- )
116
- }
117
- }
118
- } catch (e) {
119
- logger.error(`syncProductsToSellercraftResolver: ${e}`)
120
- }
121
- }
122
- }
123
-
124
- /**
125
- * @summary Check for product child qty at any scanned level
126
- * @description It will check every level of product detail by comparing scanned level and GAN registered level.
127
- * By getting the level that has relation, child qty will be retrieved
128
- * 1st level: PALLET -> 2 CARTONS (scan), 2nd level: CARTON -> 6 BAGS, 3rd level: BAG -> 10 UNITS, lowest: UNIT (order registered packing type)
129
- */
130
- export async function getChildPackingSize(
131
- productDetails: ProductDetail[],
132
- defaultProductDetail: ProductDetail,
133
- unmatchingProductDetail: ProductDetail
134
- ): Promise<number> {
135
- let hasChildRelation: boolean = Boolean(unmatchingProductDetail?.childProductDetail)
136
- let hasMatchingChild: boolean
137
- let packingSize: number = 1
138
- let currentChildProductDetail: ProductDetail
139
-
140
- if (hasChildRelation) {
141
- currentChildProductDetail = productDetails.find(
142
- (productDetail: ProductDetail) => productDetail.id === unmatchingProductDetail.childProductDetail.id
143
- )
144
-
145
- if (!currentChildProductDetail) {
146
- throw new Error(`Unable to find matching packing type for GTIN (${unmatchingProductDetail.gtin})`)
147
- }
148
-
149
- hasMatchingChild = Boolean(defaultProductDetail.id === currentChildProductDetail.id)
150
- if (hasMatchingChild) {
151
- packingSize = unmatchingProductDetail.packingSize
152
- } else {
153
- packingSize = unmatchingProductDetail.packingSize * packingSize
154
- }
155
- } else {
156
- throw new Error(`No child product result for GTIN (${unmatchingProductDetail.gtin})`)
157
- }
158
-
159
- while (hasChildRelation && !hasMatchingChild) {
160
- if (hasMatchingChild) {
161
- packingSize = currentChildProductDetail.packingSize * packingSize // 12 x 10
162
- } else if (!hasMatchingChild && hasChildRelation) {
163
- packingSize = currentChildProductDetail.packingSize * packingSize // 12 x 10
164
- currentChildProductDetail = productDetails.find(
165
- (productDetail: ProductDetail) => productDetail.id === currentChildProductDetail.childProductDetail.id
166
- )
167
-
168
- hasChildRelation = Boolean(currentChildProductDetail?.childProductDetail)
169
- hasMatchingChild = Boolean(defaultProductDetail.id === currentChildProductDetail.id)
170
- } else if (!hasChildRelation && !hasMatchingChild) {
171
- throw new Error(`Unable to find matching packing type for GTIN (${unmatchingProductDetail.gtin})`)
172
- }
173
- }
174
-
175
- return packingSize
176
- }
@@ -1,11 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const GenerateBizplaceInput = gql`
4
- input GenerateBizplaceInput {
5
- name: String!
6
- description: String
7
- address: String
8
- postalCode: String
9
- latlng: String
10
- }
11
- `
@@ -1,11 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const GenerateCompanyInput = gql`
4
- input GenerateCompanyInput {
5
- name: String!
6
- description: String
7
- address: String
8
- postalCode: String
9
- latlng: String
10
- }
11
- `
@@ -1,11 +0,0 @@
1
- import { GenerateCompanyInput } from './generate-company-input'
2
- import { GenerateBizplaceInput } from './generate-bizplace-input'
3
- import { UpdateDomainTypeInput } from './update-domain-type-input'
4
-
5
- export const Mutation = `
6
- generateCompany(businessInput: GenerateCompanyInput!): Company @transaction
7
- generateBizplace(bizplaceInput: GenerateBizplaceInput!): Bizplace @transaction
8
- updateDomainType(domainTypeInput: UpdateDomainTypeInput!): Domain @transaction
9
- `
10
-
11
- export const Types = [GenerateCompanyInput, GenerateBizplaceInput, UpdateDomainTypeInput]
@@ -1,8 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const UpdateDomainTypeInput = gql`
4
- input UpdateDomainTypeInput {
5
- id: String!
6
- extType: String!
7
- }
8
- `
@@ -1,10 +0,0 @@
1
- import * as Generators from './generators'
2
- import * as Invitations from './invitations'
3
- import * as Oauth2 from './oauth2'
4
- import * as Synchronization from './synchronization'
5
-
6
- export const queries = [Synchronization.Query, Oauth2.Query]
7
-
8
- export const mutations = [Generators.Mutation, Invitations.Mutation, Synchronization.Mutation]
9
-
10
- export const types = [...Generators.Types, ...Synchronization.Types, ...Oauth2.Types]
@@ -1,5 +0,0 @@
1
- export const Mutation = /* GraphQL */ `
2
- partnerInvitation(
3
- bizplaceName: String!
4
- ): Boolean
5
- `
@@ -1,8 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const CompanyRole = gql`
4
- type CompanyRole {
5
- domain: Domain
6
- roles: [Role]
7
- }
8
- `
@@ -1,7 +0,0 @@
1
- import { CompanyRole } from './company-role'
2
-
3
- export const Query = /* GraphQL */ `
4
- companyRolesByScope(scope: [String]!): [CompanyRole]
5
- `
6
-
7
- export const Types = [CompanyRole]
@@ -1,33 +0,0 @@
1
- import { SyncInvoiceList } from './sync-invoice-list'
2
- import { SyncInvoiceSet, Types as iTypes } from './sync-invoice-set'
3
- import { SyncProductList } from './sync-product-list'
4
- import { SyncProductSet } from './sync-product-set'
5
- import { SyncPurchaseOrderList } from './sync-purchase-order-list'
6
- import { SyncPurchaseOrderSet, Types as pTypes } from './sync-purchase-order-set'
7
-
8
- export const Query = /* GraphQL */ `
9
- fetchSyncProducts(accountId: String!, bizplaceId: String!, pagination: Pagination): SyncProductList
10
- fetchSyncPurchaseOrders(accountId: String!, warehouseId: String!, customerBizplaceId: String, fromDate: String, toDate: String): Boolean
11
- fetchSyncInvoices(accountId: String!, warehouseId: String!, customerBizplaceId: String!): Boolean
12
- `
13
-
14
- export const Mutation = /* GraphQL */ `
15
- syncProductsToSellercraft(sellercraftId: String!, fulfillmentCenterId: String!): Boolean @transaction
16
- syncProductsFromAccount(accountId: String!, bizplaceId: String!): Boolean @transaction
17
- syncProductsToAccount(accountId: String!, bizplaceId: String!): Boolean @transaction
18
- syncAllProductsToSellercraft: Boolean @transaction
19
- sellercraftPackMarketplaceOrder: Boolean @transaction
20
- createDatShipments: Boolean @transaction
21
- autoUpdateAllMarketplaceProductVariationQuantity(companyDomainId: String, warehouseId: String): Boolean @transaction
22
- `
23
-
24
- export const Types = [
25
- SyncProductSet,
26
- SyncProductList,
27
- SyncPurchaseOrderSet,
28
- SyncPurchaseOrderList,
29
- ...pTypes,
30
- SyncInvoiceSet,
31
- SyncInvoiceList,
32
- ...iTypes
33
- ]
@@ -1,8 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const SyncInvoiceList = gql`
4
- type SyncInvoiceList {
5
- items: [SyncInvoiceSet]
6
- total: Int
7
- }
8
- `
@@ -1,38 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const SyncInvoiceSet = gql`
4
- type SyncInvoiceSet {
5
- refNo: String
6
- refNo2: String
7
- releaseDate: String
8
- deliverTo: InvoiceContact
9
- orderInventories: [InvoiceLineItems]
10
- exportOption: Boolean
11
- ownTransport: Boolean
12
- collectionOrderNo: String
13
- }
14
- `
15
- const InvoiceContact = gql`
16
- type InvoiceContact {
17
- accountNo: String
18
- name: String
19
- companyName: String
20
- phone: String
21
- email: String
22
- address: String
23
- billingAddress: String
24
- }
25
- `
26
- const InvoiceLineItems = gql`
27
- type InvoiceLineItems {
28
- product: InvoiceItemCode
29
- batchId: String
30
- releaseQty: Float
31
- }
32
- `
33
- const InvoiceItemCode = gql`
34
- type InvoiceItemCode {
35
- sku: String
36
- }
37
- `
38
- export const Types = [InvoiceContact, InvoiceLineItems, InvoiceItemCode]
@@ -1,8 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const SyncProductList = gql`
4
- type SyncProductList {
5
- items: [SyncProductSet]
6
- total: Int
7
- }
8
- `
@@ -1,8 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const SyncProductSet = gql`
4
- type SyncProductSet {
5
- platformProduct: Product
6
- bizplaceProduct: Product
7
- }
8
- `
@@ -1,8 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const SyncPurchaseOrderList = gql`
4
- type SyncPurchaseOrderList {
5
- items: [SyncPurchaseOrderSet]
6
- total: Int
7
- }
8
- `
@@ -1,28 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const SyncPurchaseOrderSet = gql`
4
- type SyncPurchaseOrderSet {
5
- refNo: String
6
- refNo2: String
7
- etaDate: String
8
- ownTransport: Boolean
9
- importCargo: Boolean
10
- container: Boolean
11
- orderProducts: [PurchaseOrderLineItems]
12
- }
13
- `
14
- const PurchaseOrderLineItems = gql`
15
- type PurchaseOrderLineItems {
16
- product: PurchaseOrderItemCode
17
- batchId: String
18
- packQty: Float
19
- unitPrice: Float
20
- remark: String
21
- }
22
- `
23
- const PurchaseOrderItemCode = gql`
24
- type PurchaseOrderItemCode {
25
- sku: String
26
- }
27
- `
28
- export const Types = [PurchaseOrderLineItems, PurchaseOrderItemCode]
package/server/index.ts DELETED
@@ -1,37 +0,0 @@
1
- import './routers/api'
2
- import './routes'
3
-
4
- import { User } from '@things-factory/auth-base'
5
- import { Bizplace } from '@things-factory/biz-base'
6
- import { Domain, getRepository } from '@things-factory/shell'
7
-
8
- export * from './graphql'
9
- export * from './middlewares'
10
- export * from './migrations'
11
-
12
- declare global {
13
- namespace NodeJS {
14
- interface Process {
15
- superUserGranted: (domain: Domain, user: User) => Promise<boolean>
16
- }
17
- }
18
- }
19
-
20
- process.on('bootstrap-module-start' as any, async ({ app, config, schema }: any) => {
21
- process.superUserGranted = async (domain: Domain, user: User): Promise<boolean> => {
22
- if (!domain || !user) {
23
- return false
24
- }
25
-
26
- if (domain.extType === 'company') {
27
- return domain.owner === user.id
28
- } else {
29
- const { company }: Bizplace = await getRepository(Bizplace).findOne({
30
- where: { domain: { id: domain.id } },
31
- relations: ['company', 'company.domain']
32
- })
33
- const companyDomain: Domain = company.domain
34
- return companyDomain.owner === user.id
35
- }
36
- }
37
- })
@@ -1,32 +0,0 @@
1
- import { Application } from '@things-factory/auth-base'
2
- import { Bizplace, Company } from '@things-factory/biz-base'
3
- import { Domain, getDomainFromURL, getRepository } from '@things-factory/shell'
4
-
5
- const debug = require('debug')('things-factory:operato-hub:business-middleware')
6
-
7
- export async function businessMiddleware(context, next) {
8
- const { user } = context.state
9
-
10
- debug('user', user?.email)
11
-
12
- if (user) {
13
- const domain: Domain = await getDomainFromURL(context)
14
- const application: Application = await getRepository(Application).findOne({ where: { id: user.reference } })
15
-
16
- let company: Company
17
- if (domain.extType === 'company') {
18
- company = await getRepository(Company).findOne({ where: { domain: { id: domain.id } }, relations: ['domain'] })
19
- } else {
20
- const bizplace: Bizplace = await getRepository(Bizplace).findOne({
21
- where: { domain: { id: domain.id } },
22
- relations: ['company', 'domain']
23
- })
24
- company = bizplace.company
25
- }
26
-
27
- context.state.business = company
28
- context.state.application = application
29
- }
30
-
31
- await next()
32
- }
@@ -1,20 +0,0 @@
1
- import { businessMiddleware } from './business-middleware'
2
-
3
- const debug = require('debug')('things-factory:operato-hub:index')
4
-
5
- export function initMiddlewares(app) {
6
- /*
7
- * post:graphql 에 대해서는 businessMiddleware를 적용한다.
8
- * graphql app을 router에 적용하지 못하기 때문임.
9
- */
10
- app.use(async (context, next) => {
11
- const { method, path } = context
12
-
13
- if (method == 'POST' && (path.startsWith('/graphql'))) {
14
- debug(method, path)
15
- return await businessMiddleware(context, next)
16
- }
17
-
18
- await next()
19
- })
20
- }
@@ -1,36 +0,0 @@
1
- import { MarketplaceStore as MarketplaceStoreEntity } from '@things-factory/integration-marketplace'
2
- import { getRepository } from '@things-factory/shell'
3
-
4
- const debug = require('debug')('things-factory:operato-hub:store-middleware')
5
-
6
- export async function storeMiddleware(context, next) {
7
- const { storeId } = context.params
8
- const { business } = context.state
9
- const { t } = context
10
-
11
- let marketplaceStore: MarketplaceStoreEntity
12
-
13
- debug('company and store', business, storeId)
14
-
15
- if (!business) {
16
- context.throw(404, t('error.company not found'))
17
- }
18
-
19
- if (storeId) {
20
- marketplaceStore = await getRepository(MarketplaceStoreEntity).findOne({
21
- where: { domain: { id: business.domain.id }, name: storeId, status: 'ACTIVE' },
22
- relations: ['domain']
23
- })
24
- debug('marketplace-store', storeId, marketplaceStore?.domain?.subdomain)
25
-
26
- if (!marketplaceStore) {
27
- context.throw(404, t('error.operato marketplace store not found'))
28
- }
29
- } else {
30
- context.throw(404, t('error.store id not found'))
31
- }
32
-
33
- context.state.marketplaceStore = marketplaceStore
34
-
35
- await next()
36
- }
@@ -1,36 +0,0 @@
1
- import { Bizplace } from '@things-factory/biz-base'
2
- import { getRepository } from '@things-factory/shell'
3
-
4
- const debug = require('debug')('things-factory:operato-hub:warehouse-middleware')
5
-
6
- export async function warehouseMiddleware(context, next) {
7
- const { warehouseId } = context.params
8
- const { business } = context.state
9
- const { t } = context
10
-
11
- let warehouse: Bizplace
12
-
13
- debug('company and warehouse', business, warehouseId)
14
-
15
- if (!business) {
16
- context.throw(404, t('error.company not found'))
17
- }
18
-
19
- if (warehouseId) {
20
- warehouse = await getRepository(Bizplace).findOne({
21
- where: { id: warehouseId },
22
- relations: ['company', 'domain']
23
- })
24
- debug('warehouse', warehouseId, warehouse?.domain?.subdomain)
25
-
26
- if (!warehouse) {
27
- context.throw(404, t('error.warehouse not found'))
28
- }
29
- } else {
30
- context.throw(404, t('error.warehouse not found'))
31
- }
32
-
33
- context.state.warehouse = warehouse
34
-
35
- await next()
36
- }
@@ -1,34 +0,0 @@
1
- import { MigrationInterface, QueryRunner } from 'typeorm'
2
-
3
- import { Domain, getRepository } from '@things-factory/shell'
4
-
5
- const SEED_BUSINESS_DOMAIN = [
6
- {
7
- subdomain: 'business',
8
- name: 'Business Hub Domain'
9
- }
10
- ]
11
-
12
- export class SeedBusinessDomain1597668478399 implements MigrationInterface {
13
- public async up(queryRunner: QueryRunner): Promise<any> {
14
- const repository = getRepository(Domain)
15
-
16
- return await Promise.all(
17
- SEED_BUSINESS_DOMAIN.map(async domain => {
18
- await repository.save({
19
- ...domain
20
- })
21
- })
22
- )
23
- }
24
-
25
- public async down(queryRunner: QueryRunner): Promise<any> {
26
- const repository = getRepository(Domain)
27
-
28
- return await Promise.all(
29
- SEED_BUSINESS_DOMAIN.reverse().map(async (domain: Domain) => {
30
- await repository.delete({ subdomain: domain.subdomain })
31
- })
32
- )
33
- }
34
- }