@things-factory/operato-mms 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 (40) hide show
  1. package/dist-server/tsconfig.tsbuildinfo +1 -1
  2. package/package.json +36 -36
  3. package/server/controllers/index.ts +0 -0
  4. package/server/entities/index.ts +0 -3
  5. package/server/graphql/index.ts +0 -7
  6. package/server/graphql/resolvers/index.ts +0 -7
  7. package/server/graphql/resolvers/interface-with-hub/add-release-order.ts +0 -206
  8. package/server/graphql/resolvers/interface-with-hub/auto-add-release-order.ts +0 -209
  9. package/server/graphql/resolvers/interface-with-hub/auto-update-all-marketplace-product-variation-quantity.ts +0 -184
  10. package/server/graphql/resolvers/interface-with-hub/generate-replenishment-order.ts +0 -32
  11. package/server/graphql/resolvers/interface-with-hub/index.ts +0 -18
  12. package/server/graphql/resolvers/interface-with-hub/warehouse-marketplace-products.ts +0 -247
  13. package/server/graphql/resolvers/shipping-provider/index.ts +0 -5
  14. package/server/graphql/resolvers/shipping-provider/shipping-providers.ts +0 -39
  15. package/server/graphql/resolvers/warehouse-product/auto-link-warehouse-marketplace-product-variations.ts +0 -87
  16. package/server/graphql/resolvers/warehouse-product/index.ts +0 -5
  17. package/server/graphql/types/index.ts +0 -9
  18. package/server/graphql/types/interface-with-hub/index.ts +0 -28
  19. package/server/graphql/types/interface-with-hub/new-stock-replenishment.ts +0 -28
  20. package/server/graphql/types/interface-with-hub/replenishment-order-product.ts +0 -44
  21. package/server/graphql/types/interface-with-hub/stock-replenishment-list.ts +0 -10
  22. package/server/graphql/types/interface-with-hub/stock-replenishment.ts +0 -41
  23. package/server/graphql/types/interface-with-hub/warehouse-inventory.ts +0 -11
  24. package/server/graphql/types/interface-with-hub/warehouse-marketplace-product-list.ts +0 -8
  25. package/server/graphql/types/interface-with-hub/warehouse-marketplace-product.ts +0 -14
  26. package/server/graphql/types/shipping-provider/index.ts +0 -8
  27. package/server/graphql/types/shipping-provider/shipping-provider-list.ts +0 -7
  28. package/server/graphql/types/shipping-provider/shipping-provider.ts +0 -7
  29. package/server/graphql/types/warehouse-product/index.ts +0 -9
  30. package/server/graphql/types/warehouse-product/warehouse-product.ts +0 -9
  31. package/server/index.ts +0 -20
  32. package/server/middlewares/index.ts +0 -3
  33. package/server/migrations/1599732967233-SeedCommonCode.ts +0 -64
  34. package/server/migrations/1608009991075-SeedUser.ts +0 -60
  35. package/server/migrations/index.ts +0 -9
  36. package/server/routers/etrax-router.ts +0 -190
  37. package/server/routers/shopify-pos-public-router.ts +0 -151
  38. package/server/routes.ts +0 -9
  39. package/server/util/interface-helper.ts +0 -58
  40. package/server/util/no-generator.ts +0 -11
@@ -1,151 +0,0 @@
1
- import Router from 'koa-router'
2
-
3
- import { Bizplace, Company } from '@things-factory/biz-base'
4
- import { config } from '@things-factory/env'
5
- import { MarketplaceStore, Shopify } from '@things-factory/integration-marketplace'
6
- import { MarketplaceProductVariation } from '@things-factory/marketplace-base'
7
- import { Product } from '@things-factory/product-base'
8
- import { Domain, getRepository } from '@things-factory/shell'
9
- import {
10
- generateInventoryHistory,
11
- Inventory,
12
- INVENTORY_STATUS,
13
- INVENTORY_TRANSACTION_TYPE
14
- } from '@things-factory/warehouse-base'
15
-
16
- const shopifyConfig = config.get('marketplaceIntegrationShopify', {})
17
- const { apiKey, apiSecret } = shopifyConfig
18
-
19
- export const shopifyPosPublicRouter = new Router()
20
-
21
- shopifyPosPublicRouter.post('/webhook-shopify/orders/create', async (context, next) => {
22
- const { request, t } = context
23
-
24
- const hmac = request.get('x-shopify-hmac-sha256')
25
- const shopDomain = request.get('x-shopify-shop-domain')
26
- const shop = shopDomain.replace('.myshopify.com', '')
27
- const shopify = new Shopify({ apiKey, apiSecret, shop })
28
-
29
- const marketplaceStore: MarketplaceStore = await getRepository(MarketplaceStore).findOne({
30
- where: { storeId: shop, status: 'ACTIVE' },
31
- relations: ['domain']
32
- })
33
- if (!marketplaceStore) {
34
- context.status = 404
35
- context.body = t('error.unable to find store account')
36
- return
37
- }
38
-
39
- const webhookKey: string = marketplaceStore.webhookKey
40
-
41
- const verifyMerchant: boolean = shopify.verifyWebhook(request, hmac, webhookKey)
42
- if (!verifyMerchant) {
43
- context.status = 404
44
- context.body = t('error.unable to verify webhook origin')
45
- return
46
- }
47
-
48
- const data = request.body
49
- if (data.source_name === 'pos') {
50
- const domainCompany: Company = await getRepository(Company).findOne({
51
- where: { domain: { id: marketplaceStore.domain.id } }
52
- })
53
-
54
- const bizplaces: Bizplace[] = await getRepository(Bizplace).find({
55
- where: { company: { id: domainCompany.id } },
56
- relations: ['domain']
57
- })
58
-
59
- const warehouseDomains: Domain[] = bizplaces.map((bizplace: Bizplace) => bizplace.domain)
60
-
61
- const selectedWarehouseDomain: Domain[] = warehouseDomains.filter(
62
- domain => domain.description === 'default' && domain.extType === 'warehouse'
63
- )
64
-
65
- const refOrder: any = { id: data.id, name: data.order_number }
66
-
67
- const lineItems = data.line_items
68
- for (var i = 0; i < lineItems.length; i++) {
69
- const variationId: string = lineItems[i].variant_id
70
- var itemQty: number = lineItems[i].quantity
71
- var itemUomValue: number = 0
72
-
73
- const marketplaceProductVariation: MarketplaceProductVariation = await getRepository(
74
- MarketplaceProductVariation
75
- ).findOne({
76
- where: {
77
- variationId,
78
- domain: { id: marketplaceStore.domain.id }
79
- }
80
- })
81
-
82
- const warehouseProduct: Product = await getRepository(Product).findOne({
83
- where: {
84
- sku: marketplaceProductVariation.sku
85
- },
86
- relations: ['bizplace']
87
- })
88
-
89
- const inventories: Inventory[] = await getRepository(Inventory).find({
90
- where: {
91
- product: { id: warehouseProduct.id },
92
- domain: selectedWarehouseDomain[0],
93
- status: 'STORED'
94
- },
95
- relations: ['domain', 'bizplace', 'product', 'warehouse', 'location']
96
- })
97
-
98
- for (var j = 0; j < inventories.length; j++) {
99
- var inventory: Inventory = inventories[j]
100
-
101
- if (inventory.qty >= itemQty) {
102
- itemUomValue = (inventory.uomValue / inventory.qty) * itemQty
103
- inventory.qty -= itemQty
104
- inventory.uomValue -= itemUomValue
105
-
106
- await generateInventoryHistory(
107
- inventory,
108
- refOrder,
109
- INVENTORY_TRANSACTION_TYPE.SALES_ADJUSTMENT,
110
- -itemQty,
111
- -itemUomValue,
112
- null
113
- )
114
-
115
- if (inventory.qty === 0) {
116
- inventory.status = INVENTORY_STATUS.TERMINATED
117
-
118
- await generateInventoryHistory(inventory, refOrder, INVENTORY_STATUS.TERMINATED, 0, 0, null)
119
- }
120
- itemQty = 0
121
- } else {
122
- itemQty -= inventory.qty
123
- itemUomValue = (inventory.uomValue / inventory.qty) * itemQty
124
- inventory.qty -= itemQty
125
- inventory.uomValue -= itemUomValue
126
-
127
- await generateInventoryHistory(
128
- inventory,
129
- refOrder,
130
- INVENTORY_TRANSACTION_TYPE.SALES_ADJUSTMENT,
131
- -itemQty,
132
- -itemUomValue,
133
- null
134
- )
135
-
136
- if (inventory.qty === 0) {
137
- inventory.status = INVENTORY_STATUS.TERMINATED
138
-
139
- await generateInventoryHistory(inventory, refOrder, INVENTORY_STATUS.TERMINATED, 0, 0, null)
140
- }
141
- }
142
-
143
- if (itemQty == 0) {
144
- break
145
- }
146
- }
147
- }
148
- }
149
-
150
- context.status = 200
151
- })
package/server/routes.ts DELETED
@@ -1,9 +0,0 @@
1
- import { etraxRouter } from './routers/etrax-router'
2
- import { shopifyPosPublicRouter } from './routers/shopify-pos-public-router'
3
-
4
- process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRouter) => {
5
- globalPublicRouter.use(shopifyPosPublicRouter.routes(), shopifyPosPublicRouter.allowedMethods())
6
- globalPublicRouter.use(etraxRouter.routes(), etraxRouter.allowedMethods())
7
- })
8
-
9
- process.on('bootstrap-module-domain-private-route' as any, (app, domainPrivateRouter) => {})
@@ -1,58 +0,0 @@
1
- import fetch, { RequestInit } from 'node-fetch'
2
- import { URL } from 'url'
3
-
4
- import { config } from '@things-factory/env'
5
- import { Oauth2Client } from '@things-factory/oauth2-client'
6
- import { Domain, getRepository } from '@things-factory/shell'
7
-
8
- export type PlatformType = 'Operato Hub'
9
-
10
- const platforms: { name: string; apiURL: string }[] = config.get('oauth2')?.platforms || []
11
- const API_URL_MAP: Map<string, string> = new Map(platforms.map(platform => [platform.name, platform.apiURL]))
12
-
13
- export const interfaceHelper = {
14
- async fetch<T>(
15
- platform: PlatformType,
16
- endPoint: string,
17
- method: string,
18
- context: any,
19
- body?: Record<string, any>
20
- ): Promise<any> {
21
- const { domain } = context.state
22
- const url: URL = new URL(API_URL_MAP.get(platform))
23
- url.host = domain.subdomain + '.' + url.host
24
- url.pathname += '/' + endPoint
25
- url.pathname.replace(/\/+/g, '/')
26
- endPoint = decodeURIComponent(url.href)
27
- const accessToken: string = await this.getAccessToken(domain)
28
-
29
- const requestInit: RequestInit = {
30
- method,
31
- headers: {
32
- Accept: 'application/json',
33
- 'Content-Type': 'application/json',
34
- Authorization: `Bearer ${accessToken}`
35
- }
36
- }
37
- if (body) requestInit.body = JSON.stringify(body)
38
- const res = await fetch(endPoint, requestInit)
39
-
40
- if (res.ok) {
41
- const { result } = await res.json()
42
- return result
43
- } else {
44
- const errorcode = res.status
45
- const message = await res.text()
46
- return { errorcode, message }
47
- }
48
- },
49
-
50
- async getAccessToken(domain: Domain): Promise<string> {
51
- const { accessToken }: Oauth2Client = await getRepository(Oauth2Client).findOneBy({
52
- domain,
53
- name: 'Operato Hub'
54
- })
55
-
56
- return accessToken
57
- }
58
- }
@@ -1,11 +0,0 @@
1
- import { v4 as uuidv4 } from 'uuid'
2
-
3
- export class NoGenerator {
4
- static id() {
5
- return `${uuidv4()}`
6
- }
7
-
8
- static sku() {
9
- return `SKU-${uuidv4()}`
10
- }
11
- }