@things-factory/operato-mms 6.1.82 → 6.1.84

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,28 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const NewStockReplenishment = gql`
4
- input NewStockReplenishment {
5
- name: String
6
- description: String
7
- containerNo: String
8
- container: Boolean
9
- ownTransport: Boolean!
10
- crossDocking: Boolean
11
- importCargo: Boolean
12
- jobSheetNo: String
13
- looseItem: Boolean
14
- ata: String
15
- eta: String
16
- etaDate: String
17
- truckNo: String
18
- refNo: String
19
- status: String
20
- remark: String
21
- orderProducts: [Object]!
22
- orderVass: [Object]
23
- deliveryOrderNo: String
24
- containerSize: String
25
- warehouseId: String #outletID
26
- supplier: String
27
- }
28
- `
@@ -1,44 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const ReplenishmentOrderProduct = gql`
4
- type ReplenishmentOrderProduct {
5
- id: String
6
- domain: Domain
7
- bizplace: Bizplace
8
- sku: String
9
- name: String
10
- description: String
11
- type: String
12
- stockReplenishment: StockReplenishment
13
- # collectionOrder: CollectionOrder
14
- # deliveryOrder: DeliveryOrder
15
- # releaseGood: ReleaseGood
16
- # shippingOrder: ShippingOrder
17
- # retailReplenishmentOrder: RetailReplenishmentOrder
18
- # fromInventory: Inventory
19
- # currentInventory: Inventory
20
- # toInventory: Inventory
21
- product: MarketplaceProduct
22
- batchId: String
23
- batchExp: String
24
- adjustedBatchId: String
25
- adjustedPalletQty: Int
26
- packingType: String
27
- uom: String
28
- uomValue: Float
29
- packQty: Int
30
- actualPackQty: Int
31
- palletQty: Int
32
- actualPalletQty: Int
33
- totalUomValue: String
34
- releaseQty: Int
35
- releaseUomValue: Float
36
- remark: String
37
- issue: String
38
- status: String
39
- createdAt: String
40
- updatedAt: String
41
- creator: User
42
- updater: User
43
- }
44
- `
@@ -1,10 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const StockReplenishmentList = gql`
4
- type StockReplenishmentList {
5
- items: [StockReplenishment]
6
- total: Int
7
- errorcode: String
8
- message: String
9
- }
10
- `
@@ -1,41 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const StockReplenishment = gql`
4
- type StockReplenishment {
5
- id: String
6
- name: String
7
- domain: Domain
8
- bizplace: Bizplace
9
- description: String
10
- errorcode: Int
11
- message: String
12
- containerNo: String
13
- containerSize: String
14
- container: Boolean
15
- ownTransport: Boolean
16
- crossDocking: Boolean
17
- # releaseGood: ReleaseGood
18
- importCargo: Boolean
19
- jobSheetNo: String
20
- looseItem: Boolean
21
- ata: String
22
- eta: String
23
- etaDate: String
24
- truckNo: String
25
- refNo: String
26
- status: String
27
- remark: String
28
- # jobSheet: JobSheet
29
- orderProducts: [ReplenishmentOrderProduct]
30
- # orderVass: [OrderVas]
31
- # collectionOrders: [CollectionOrder]
32
- # attachment: [Attachment]
33
- deliveryOrderNo: String
34
- creator: User
35
- updater: User
36
- acceptedBy: User
37
- createdAt: String
38
- updatedAt: String
39
- # supplier: ContactPoint
40
- }
41
- `
@@ -1,11 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const WarehouseInventory = gql`
4
- type WarehouseInventory {
5
- product: Product
6
- qty: Int
7
- lockedQty: Int
8
- remainQty: Int
9
- bizplace: Bizplace
10
- }
11
- `
@@ -1,8 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const WarehouseMarketplaceProductList = gql`
4
- type WarehouseMarketplaceProductList {
5
- items: [WarehouseMarketplaceProduct]
6
- total: Int
7
- }
8
- `
@@ -1,14 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const WarehouseMarketplaceProduct = gql`
4
- type WarehouseMarketplaceProduct {
5
- seq: Int
6
- id: String
7
- domain: Domain
8
- sku: String
9
- name: String
10
- description: String
11
- marketplaceProduct: [MarketplaceProduct]
12
- warehouseInventory: [WarehouseInventory]
13
- }
14
- `
@@ -1,8 +0,0 @@
1
- import { ShippingProviderList } from './shipping-provider-list'
2
- import { ShippingProvider } from './shipping-provider'
3
-
4
- export const Query = `
5
- shippingProviders(storeId: String!, statuses: [String]): ShippingProviderList @transaction
6
- `
7
-
8
- export const Types = [ShippingProviderList, ShippingProvider]
@@ -1,7 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const ShippingProviderList = gql`
4
- type ShippingProviderList {
5
- items: [ShippingProvider]
6
- }
7
- `
@@ -1,7 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const ShippingProvider = gql`
4
- type ShippingProvider {
5
- shippingProvider: String
6
- }
7
- `
@@ -1,9 +0,0 @@
1
- import { WarehouseProduct } from './warehouse-product'
2
-
3
- export const Mutation = /* GraphQL */ `
4
- autoLinkWarehouseMarketplaceProductVariations(
5
- marketplaceStoreIds: [String]!
6
- isCheckedSku: Boolean!
7
- ): Boolean @transaction `
8
-
9
- export const Types = [WarehouseProduct]
@@ -1,9 +0,0 @@
1
- import gql from 'graphql-tag'
2
-
3
- export const WarehouseProduct = gql`
4
- input WarehouseProduct {
5
- id: String
6
- sku: String
7
- name: String
8
- }
9
- `
package/server/index.ts DELETED
@@ -1,20 +0,0 @@
1
- export * from './entities'
2
- export * from './graphql'
3
- export * from './migrations'
4
-
5
- import './routes'
6
- import { ConnectionManager, ScenarioEngine } from '@things-factory/integration-base'
7
-
8
- const debug = require('debug')('things-factory:operato-mms:bootstrap')
9
-
10
- process.on('bootstrap-module-start' as any, async ({ app, config, client }: any) => {
11
- try {
12
- await ConnectionManager.ready()
13
- await ScenarioEngine.loadAll()
14
-
15
- console.log('[operato-mms:bootstrap] Scenario Engine has just started.')
16
- } catch (ex) {
17
- ConnectionManager.logger.error(ex)
18
- console.log('[operato-mms:bootstrap] Just has failed to start Scenario Engine.')
19
- }
20
- })
@@ -1,3 +0,0 @@
1
- // export function initMiddlewares(app) {
2
- // /* can add middlewares into app */
3
- // }
@@ -1,64 +0,0 @@
1
- import { MigrationInterface, QueryRunner } from 'typeorm'
2
-
3
- import { CommonCode, CommonCodeDetail } from '@things-factory/code-base'
4
- import { Domain, getRepository } from '@things-factory/shell'
5
-
6
- const codes = [
7
- {
8
- name: 'COUNTRY_CODES',
9
- description: 'country code',
10
- details: [
11
- { name: 'my', description: 'Malaysia' },
12
- { name: 'sg', description: 'Singapore' },
13
- { name: 'th', description: 'Thailand' },
14
- { name: 'vn', description: 'Vietnam' },
15
- { name: 'id', description: 'Indonesia' },
16
- { name: 'ph', description: 'Philippines' }
17
- ]
18
- },
19
- {
20
- name: 'ECOMMERCE_PLATFORM',
21
- description: 'ecommerce platform',
22
- details: [
23
- { name: 'lazada', description: 'Lazada' },
24
- { name: 'shopee', description: 'Shopee' },
25
- { name: 'shopify', description: 'Shopify' },
26
- { name: 'zalora', description: 'Zalora' }
27
- ]
28
- }
29
- ]
30
-
31
- export class SeedCommonCode1599732967233 implements MigrationInterface {
32
- public async up(queryRunner: QueryRunner): Promise<any> {
33
- const codeRepo = getRepository(CommonCode)
34
- const codeDetailRepo = getRepository(CommonCodeDetail)
35
- const domain = await getRepository(Domain).findOneBy({
36
- subdomain: 'maybank'
37
- })
38
-
39
- return await Promise.all(
40
- codes.map(async code => {
41
- const commonCode = await codeRepo.save({
42
- ...code,
43
- domain
44
- })
45
-
46
- await codeDetailRepo.save(
47
- commonCode.details.map((detail, idx) => {
48
- return {
49
- ...detail,
50
- commonCode,
51
- domain,
52
- rank: (idx + 1) * 10
53
- }
54
- })
55
- )
56
- })
57
- )
58
- }
59
-
60
- public async down(queryRunner: QueryRunner): Promise<any> {
61
- const codeRepo = getRepository(CommonCode)
62
- const codeDetailRepo = getRepository(CommonCodeDetail)
63
- }
64
- }
@@ -1,60 +0,0 @@
1
- import { MigrationInterface, QueryRunner, Repository } from 'typeorm'
2
-
3
- import { User, UserStatus } from '@things-factory/auth-base'
4
- import { Company } from '@things-factory/biz-base'
5
- import { Domain, getRepository } from '@things-factory/shell'
6
-
7
- const ADMIN_USER = {
8
- name: 'Admin',
9
- email: 'admin@hatiolab.com',
10
- password: 'admin',
11
- userType: 'user',
12
- status: UserStatus.ACTIVATED
13
- }
14
- export class SeedUser1608009991075 implements MigrationInterface {
15
- public async up(queryRunner: QueryRunner): Promise<any> {
16
- const userRepository: Repository<User> = getRepository(User)
17
- const domainRepository: Repository<Domain> = getRepository(Domain)
18
-
19
- let adminUser: User = await userRepository.findOne({ where: { name: ADMIN_USER.name }, relations: ['domains'] })
20
- let systemDomain: Domain = await domainRepository.findOne({ where: { systemFlag: true } })
21
-
22
- if (!adminUser) {
23
- const salt = User.generateSalt()
24
-
25
- adminUser = await userRepository.save({
26
- ...ADMIN_USER,
27
- salt,
28
- password: User.encode(ADMIN_USER.password, salt)
29
- })
30
- } else {
31
- adminUser.userType = 'user'
32
- await userRepository.save(adminUser)
33
- }
34
-
35
- if (systemDomain) {
36
- systemDomain.extType = 'company'
37
- await domainRepository.save(systemDomain)
38
- }
39
-
40
- const companyInput: Company = {
41
- name: systemDomain.name,
42
- description: systemDomain.description || null,
43
- address: '',
44
- postalCode: '',
45
- countryCode: '',
46
- brn: ''
47
- } as any
48
- }
49
-
50
- public async down(queryRunner: QueryRunner): Promise<any> {
51
- const userRepository = getRepository(User)
52
- const domainRepository = getRepository(Domain)
53
-
54
- const user = await userRepository.findOne({ where: { name: ADMIN_USER.name } })
55
- await userRepository.delete({ id: user.id })
56
-
57
- const systemDomain = await domainRepository.findOne({ where: { systemFlag: true } })
58
- await domainRepository.delete(systemDomain)
59
- }
60
- }
@@ -1,9 +0,0 @@
1
- const glob = require('glob')
2
- const path = require('path')
3
-
4
- export var migrations = []
5
-
6
- glob.sync(path.resolve(__dirname, '.', '**', '*.js')).forEach(function (file) {
7
- if (file.indexOf('index.js') !== -1) return
8
- migrations = migrations.concat(Object.values(require(path.resolve(file))) || [])
9
- })
@@ -1,190 +0,0 @@
1
- import Router from 'koa-router'
2
-
3
- import { Bizplace, getCustomerBizplaces } from '@things-factory/biz-base'
4
- import { FulfillmentAPI, FulfillmentCenter } from '@things-factory/integration-fulfillment'
5
- import { Etrax, LastMileDelivery } from '@things-factory/integration-lmd'
6
- import { MarketplaceStore, MarketplaceTransporter, StoreAPI } from '@things-factory/integration-marketplace'
7
- import {
8
- MarketplaceOrder,
9
- MarketplaceOrderItem,
10
- MarketplaceOrderShipping,
11
- MarketplaceOrderShippingItem
12
- } from '@things-factory/marketplace-base'
13
- import { Domain, getRepository } from '@things-factory/shell'
14
-
15
- const debug = require('debug')('things-factory:jest.config')
16
- export const etraxRouter = new Router()
17
-
18
- etraxRouter.post(`/lmd/etrax/status_update`, async (context, next) => {
19
- const repo = getRepository(LastMileDelivery)
20
- const requestBody = context.request.body
21
- debug('etrax_status_update/context: ', context)
22
-
23
- const bodyToken = requestBody.Token
24
- const bodyTimestamp = requestBody.TimeStamp
25
- const bodySourceID = requestBody.SourceID
26
- const extOrderNo = requestBody.ExtOrderNo
27
- const trackingNo = requestBody.TrackingNo
28
- const status = requestBody.Status
29
- const awbUrl = requestBody.AWBurl
30
-
31
- const customerCode = bodySourceID
32
- const lmd: LastMileDelivery = await repo.findOne({
33
- where: { clientName: customerCode, platform: 'eTrax' }
34
- })
35
- debug(lmd)
36
-
37
- const secretKey = lmd.secretKey
38
-
39
- if (customerCode === '' || secretKey === '') {
40
- //Cant find the correct record
41
- return
42
- }
43
-
44
- const etrax = new Etrax(customerCode)
45
- debug('RequestBody: ', requestBody)
46
- //Validate Token
47
- const validate = await etrax.validateToken(bodyToken, 'UPDATE_STATUS', bodyTimestamp)
48
- debug('IsAuthenticated: ', validate)
49
-
50
- if (!validate) {
51
- //Return unauthorized
52
- const resp = {
53
- Status: 'ERROR',
54
- Code: 302,
55
- Message: 'Validate failed',
56
- OrderNo: extOrderNo,
57
- ExtOrderNo: extOrderNo,
58
- TrackingNo: trackingNo
59
- }
60
- context.type = 'application/json'
61
- context.body = JSON.stringify(resp)
62
- return
63
- }
64
-
65
- //TAS - Transporter Assignment Success
66
- if (status === 'TAS') {
67
- //Update DB if Validate Success
68
- const orderRepo = getRepository(MarketplaceOrder)
69
- const orderShippingRepo = getRepository(MarketplaceOrderShipping)
70
-
71
- let order: MarketplaceOrder = await orderRepo.findOne({
72
- where: { orderNo: extOrderNo },
73
- relations: [
74
- 'domain',
75
- 'marketplaceStore',
76
- 'marketplaceOrderItems',
77
- 'marketplaceOrderItems.marketplaceOrderShippingItems',
78
- 'marketplaceOrderItems.marketplaceOrderShippingItems.marketplaceOrderShipping',
79
- 'marketplaceOrderItems.marketplaceOrderShippingItems.marketplaceOrderShipping.fulfillmentCenter',
80
- 'marketplaceOrderItems.marketplaceProductVariation'
81
- ]
82
- })
83
- let orderItems: MarketplaceOrderItem[] = order.marketplaceOrderItems
84
-
85
- const marketplaceStore: MarketplaceStore = order.marketplaceStore
86
-
87
- const marketplaceTransporter: MarketplaceTransporter = await getRepository(MarketplaceTransporter).findOne({
88
- where: { marketplaceStore: { id: marketplaceStore.id } },
89
- relations: ['pickupTransporter']
90
- })
91
-
92
- for (const orderItem of orderItems) {
93
- if (orderItem.marketplaceOrderShippingItems[0].marketplaceOrderShipping !== null) {
94
- const orderShippingItems: MarketplaceOrderShippingItem[] = orderItem.marketplaceOrderShippingItems
95
- const orderShipping: MarketplaceOrderShipping = orderShippingItems[0].marketplaceOrderShipping
96
- const fulfillmentCenter: FulfillmentCenter = orderShipping?.fulfillmentCenter
97
-
98
- const centerId: string = fulfillmentCenter.centerId
99
- const warehouseDomain: Domain = await getRepository(Domain).findOne({ where: { subdomain: centerId } })
100
- const customerBizplaces: Bizplace[] = await getCustomerBizplaces(warehouseDomain)
101
- const customerBizplaceId: string = customerBizplaces.find(
102
- customerBizplace => customerBizplace.company.domain.id == order?.domain.id
103
- ).id
104
-
105
- let patch = {
106
- id: orderShipping.releaseOrderId,
107
- trackingNo: trackingNo,
108
- transporter: marketplaceTransporter?.pickupTransporter.name
109
- }
110
-
111
- FulfillmentAPI.updateReleaseGoodDetails(fulfillmentCenter, {
112
- customerBizplaceId,
113
- releaseOrder: { ...patch },
114
- shippingOrder: null
115
- })
116
-
117
- await orderShippingRepo.update({ id: orderShipping.id }, {
118
- trackingNo: trackingNo,
119
- airwayBill: awbUrl,
120
- updatedAt: new Date(),
121
- transporter: marketplaceTransporter?.pickupTransporter.name || orderShipping.transporter
122
- } as any)
123
- }
124
- }
125
-
126
- // to-do update tracking no to every marketplaces
127
- if (marketplaceStore.platform === 'woocommerce' || marketplaceStore.platform === 'shopify') {
128
- const note = 'http://ets.sntglobal.com/?mod=tracking&action=index&orders=' + trackingNo
129
- let orderInfo: MarketplaceOrder = await getRepository(MarketplaceOrder).findOne({
130
- where: {
131
- name: order.name
132
- },
133
- relations: ['marketplaceOrderItems', 'marketplaceOrderItems.marketplaceProductVariation']
134
- })
135
- const result = await StoreAPI.setStoreOrderStatusReadyToShip(marketplaceStore, {
136
- orderId: order.name,
137
- trackingUrl: note,
138
- trackingNo,
139
- order: orderInfo,
140
- note,
141
- transporter: marketplaceTransporter?.pickupTransporter.name
142
- })
143
-
144
- if (marketplaceStore.platform === 'woocommerce') {
145
- await StoreAPI.updateOrderStatus(marketplaceStore, {
146
- orderId: order.name,
147
- status: 'DELIVERED'
148
- })
149
- }
150
- }
151
-
152
- try {
153
- const updatedOrder = await StoreAPI.getStoreOrder(marketplaceStore, { orderId: order.name })
154
-
155
- order.status = updatedOrder.status
156
- order.orderUpdatedAt = updatedOrder.orderUpdatedAt
157
- order.trackingNo = updatedOrder.trackingNo
158
- order.shippingProvider = updatedOrder.shippingProvider
159
- await getRepository(MarketplaceOrder).save(order)
160
-
161
- for (let idx = 0; idx < order.marketplaceOrderItems.length; idx++) {
162
- let matchItem = updatedOrder.orderItems.find(
163
- i => i.variationId == order.marketplaceOrderItems[idx].marketplaceProductVariation.variationId
164
- )
165
-
166
- if (matchItem) {
167
- let targetMarketplaceOrderItem = {
168
- ...order.marketplaceOrderItems[idx],
169
- shippingProvider: matchItem.shippingProvider,
170
- trackingCode: matchItem.trackingNo,
171
- status: matchItem.status
172
- }
173
-
174
- await getRepository(MarketplaceOrderItem).save(targetMarketplaceOrderItem)
175
- }
176
- }
177
- } catch (e) {}
178
-
179
- const resp = {
180
- Status: 'SUCCESS',
181
- Code: 200,
182
- Message: 'Updated',
183
- OrderNo: order.orderNo,
184
- ExtOrderNo: extOrderNo,
185
- TrackingNo: trackingNo
186
- }
187
- context.type = 'application/json'
188
- context.body = JSON.stringify(resp)
189
- }
190
- })