@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.
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +46 -46
- package/server/controllers/bizplace-initializer/codes.ts +0 -32
- package/server/controllers/bizplace-initializer/dataset/codes.ts +0 -398
- package/server/controllers/bizplace-initializer/dataset/groups.ts +0 -21
- package/server/controllers/bizplace-initializer/dataset/index.ts +0 -5
- package/server/controllers/bizplace-initializer/dataset/menus.ts +0 -500
- package/server/controllers/bizplace-initializer/dataset/roles-privileges.ts +0 -402
- package/server/controllers/bizplace-initializer/dataset/settings.ts +0 -91
- package/server/controllers/bizplace-initializer/generate-bizplace-domain-roles.ts +0 -29
- package/server/controllers/bizplace-initializer/generate-bizplace-domain.ts +0 -56
- package/server/controllers/bizplace-initializer/groups.ts +0 -19
- package/server/controllers/bizplace-initializer/index.ts +0 -5
- package/server/controllers/bizplace-initializer/menus.ts +0 -42
- package/server/controllers/bizplace-initializer/settings.ts +0 -20
- package/server/controllers/company-initializer/business-register.ts +0 -59
- package/server/controllers/company-initializer/codes.ts +0 -147
- package/server/controllers/company-initializer/generate-company-roles.ts +0 -119
- package/server/controllers/company-initializer/index.ts +0 -6
- package/server/controllers/company-initializer/menus.ts +0 -359
- package/server/controllers/company-initializer/settings.ts +0 -33
- package/server/controllers/company-initializer/transporter.ts +0 -20
- package/server/controllers/index.ts +0 -0
- package/server/controllers/invitation.ts +0 -132
- package/server/controllers/utils/make-invitation-token.ts +0 -5
- package/server/controllers/utils/save-invitation-token.ts +0 -9
- package/server/entities/index.ts +0 -0
- package/server/errors/index.ts +0 -1
- package/server/errors/validation-error.ts +0 -17
- package/server/graphql/index.ts +0 -7
- package/server/graphql/resolvers/generators/generate-bizplace.ts +0 -40
- package/server/graphql/resolvers/generators/generate-company.ts +0 -76
- package/server/graphql/resolvers/generators/index.ts +0 -9
- package/server/graphql/resolvers/generators/update-domain-extType.ts +0 -55
- package/server/graphql/resolvers/index.ts +0 -8
- package/server/graphql/resolvers/invitations/index.ts +0 -5
- package/server/graphql/resolvers/invitations/partner-invitation.ts +0 -62
- package/server/graphql/resolvers/oauth2/company-roles-by-scope.ts +0 -38
- package/server/graphql/resolvers/oauth2/index.ts +0 -5
- package/server/graphql/resolvers/synchronization/auto-update-all-marketplace-product-variation-quantity.ts +0 -180
- package/server/graphql/resolvers/synchronization/create-dat-shipments.ts +0 -64
- package/server/graphql/resolvers/synchronization/fetch-sync-invoices.ts +0 -52
- package/server/graphql/resolvers/synchronization/fetch-sync-products.ts +0 -99
- package/server/graphql/resolvers/synchronization/fetch-sync-purchase-orders.ts +0 -75
- package/server/graphql/resolvers/synchronization/index.ts +0 -26
- package/server/graphql/resolvers/synchronization/sellercraft-pack-marketplace-order.ts +0 -91
- package/server/graphql/resolvers/synchronization/sync-all-products-to-sellercraft.ts +0 -39
- package/server/graphql/resolvers/synchronization/sync-products-from-account.ts +0 -40
- package/server/graphql/resolvers/synchronization/sync-products-to-account.ts +0 -64
- package/server/graphql/resolvers/synchronization/sync-products-to-sellercraft.ts +0 -176
- package/server/graphql/types/generators/generate-bizplace-input.ts +0 -11
- package/server/graphql/types/generators/generate-company-input.ts +0 -11
- package/server/graphql/types/generators/index.ts +0 -11
- package/server/graphql/types/generators/update-domain-type-input.ts +0 -8
- package/server/graphql/types/index.ts +0 -10
- package/server/graphql/types/invitations/index.ts +0 -5
- package/server/graphql/types/oauth2/company-role.ts +0 -8
- package/server/graphql/types/oauth2/index.ts +0 -7
- package/server/graphql/types/synchronization/index.ts +0 -33
- package/server/graphql/types/synchronization/sync-invoice-list.ts +0 -8
- package/server/graphql/types/synchronization/sync-invoice-set.ts +0 -38
- package/server/graphql/types/synchronization/sync-product-list.ts +0 -8
- package/server/graphql/types/synchronization/sync-product-set.ts +0 -8
- package/server/graphql/types/synchronization/sync-purchase-order-list.ts +0 -8
- package/server/graphql/types/synchronization/sync-purchase-order-set.ts +0 -28
- package/server/index.ts +0 -37
- package/server/middlewares/business-middleware.ts +0 -32
- package/server/middlewares/index.ts +0 -20
- package/server/middlewares/store-middleware.ts +0 -36
- package/server/middlewares/warehouse-middleware.ts +0 -36
- package/server/migrations/1597668478399-SeedBusinessDomain.ts +0 -34
- package/server/migrations/1597668478401-SeedBusinessRoles.ts +0 -377
- package/server/migrations/1608009991065-SeedUser.ts +0 -64
- package/server/migrations/index.ts +0 -9
- package/server/routers/api/index.ts +0 -3
- package/server/routers/api/restful-apis/unstable/add-contact-point.ts +0 -89
- package/server/routers/api/restful-apis/unstable/add-draft-release-order.ts +0 -198
- package/server/routers/api/restful-apis/unstable/add-inbound-order.ts +0 -246
- package/server/routers/api/restful-apis/unstable/add-marketplace-order.ts +0 -171
- package/server/routers/api/restful-apis/unstable/add-products.ts +0 -112
- package/server/routers/api/restful-apis/unstable/add-release-order.ts +0 -1061
- package/server/routers/api/restful-apis/unstable/add-sales-invoice.ts +0 -144
- package/server/routers/api/restful-apis/unstable/bizplace.ts +0 -45
- package/server/routers/api/restful-apis/unstable/cancel-marketplace-order.ts +0 -81
- package/server/routers/api/restful-apis/unstable/cancel-release-order.ts +0 -91
- package/server/routers/api/restful-apis/unstable/get-contact-point-list.ts +0 -110
- package/server/routers/api/restful-apis/unstable/get-delivery-order-detail.ts +0 -46
- package/server/routers/api/restful-apis/unstable/get-delivery-order-list.ts +0 -121
- package/server/routers/api/restful-apis/unstable/get-delivery-orders.ts +0 -178
- package/server/routers/api/restful-apis/unstable/get-goods-received-notes.ts +0 -134
- package/server/routers/api/restful-apis/unstable/get-inbound-order-detail.ts +0 -128
- package/server/routers/api/restful-apis/unstable/get-inbound-order-list.ts +0 -126
- package/server/routers/api/restful-apis/unstable/get-inventory-overall-product-group.ts +0 -99
- package/server/routers/api/restful-apis/unstable/get-inventory-product-group.ts +0 -107
- package/server/routers/api/restful-apis/unstable/get-marketplace-order-shipping-list.ts +0 -156
- package/server/routers/api/restful-apis/unstable/get-marketplace-store-list.ts +0 -81
- package/server/routers/api/restful-apis/unstable/get-onhand-inventories.ts +0 -125
- package/server/routers/api/restful-apis/unstable/get-partners.ts +0 -26
- package/server/routers/api/restful-apis/unstable/get-products.ts +0 -216
- package/server/routers/api/restful-apis/unstable/get-release-order-detail.ts +0 -138
- package/server/routers/api/restful-apis/unstable/get-release-order-list.ts +0 -199
- package/server/routers/api/restful-apis/unstable/get-warehouses.ts +0 -19
- package/server/routers/api/restful-apis/unstable/index.ts +0 -32
- package/server/routers/api/restful-apis/unstable/reject-inbound-order.ts +0 -46
- package/server/routers/api/restful-apis/unstable/set-marketplace-order-delivered.ts +0 -60
- package/server/routers/api/restful-apis/unstable/set-marketplace-order-failed-delivery.ts +0 -60
- package/server/routers/api/restful-apis/unstable/update-marketplace-order.ts +0 -111
- package/server/routers/api/restful-apis/unstable/update-marketplace-shipping-order.ts +0 -107
- package/server/routers/api/restful-apis/unstable/update-release-order-details.ts +0 -94
- package/server/routers/api/restful-apis/v1/add-contact-point.ts +0 -77
- package/server/routers/api/restful-apis/v1/add-draft-release-order.ts +0 -196
- package/server/routers/api/restful-apis/v1/add-inbound-order.ts +0 -243
- package/server/routers/api/restful-apis/v1/add-marketplace-order.ts +0 -172
- package/server/routers/api/restful-apis/v1/add-products.ts +0 -112
- package/server/routers/api/restful-apis/v1/add-release-order.ts +0 -967
- package/server/routers/api/restful-apis/v1/bizplace.ts +0 -45
- package/server/routers/api/restful-apis/v1/cancel-marketplace-order.ts +0 -81
- package/server/routers/api/restful-apis/v1/cancel-release-order.ts +0 -91
- package/server/routers/api/restful-apis/v1/get-contact-point-list.ts +0 -110
- package/server/routers/api/restful-apis/v1/get-delivery-order-detail.ts +0 -46
- package/server/routers/api/restful-apis/v1/get-delivery-order-list.ts +0 -121
- package/server/routers/api/restful-apis/v1/get-delivery-orders.ts +0 -178
- package/server/routers/api/restful-apis/v1/get-goods-received-notes.ts +0 -134
- package/server/routers/api/restful-apis/v1/get-inbound-order-detail.ts +0 -128
- package/server/routers/api/restful-apis/v1/get-inbound-order-list.ts +0 -126
- package/server/routers/api/restful-apis/v1/get-inventory-overall-product-group.ts +0 -99
- package/server/routers/api/restful-apis/v1/get-inventory-product-group.ts +0 -112
- package/server/routers/api/restful-apis/v1/get-marketplace-order-shipping-list.ts +0 -156
- package/server/routers/api/restful-apis/v1/get-marketplace-store-list.ts +0 -81
- package/server/routers/api/restful-apis/v1/get-onhand-inventories.ts +0 -125
- package/server/routers/api/restful-apis/v1/get-partners.ts +0 -26
- package/server/routers/api/restful-apis/v1/get-products.ts +0 -216
- package/server/routers/api/restful-apis/v1/get-release-order-detail.ts +0 -134
- package/server/routers/api/restful-apis/v1/get-release-order-list.ts +0 -198
- package/server/routers/api/restful-apis/v1/get-warehouses.ts +0 -19
- package/server/routers/api/restful-apis/v1/index.ts +0 -31
- package/server/routers/api/restful-apis/v1/reject-inbound-order.ts +0 -46
- package/server/routers/api/restful-apis/v1/set-marketplace-order-delivered.ts +0 -60
- package/server/routers/api/restful-apis/v1/set-marketplace-order-failed-delivery.ts +0 -60
- package/server/routers/api/restful-apis/v1/update-marketplace-order.ts +0 -111
- package/server/routers/api/restful-apis/v1/update-marketplace-shipping-order.ts +0 -104
- package/server/routers/api/restful-apis/v1/update-release-order-details.ts +0 -94
- package/server/routers/api/restful-apis/v2/add-contact-point.ts +0 -77
- package/server/routers/api/restful-apis/v2/add-draft-release-order.ts +0 -196
- package/server/routers/api/restful-apis/v2/add-inbound-order.ts +0 -243
- package/server/routers/api/restful-apis/v2/add-marketplace-order.ts +0 -172
- package/server/routers/api/restful-apis/v2/add-products.ts +0 -112
- package/server/routers/api/restful-apis/v2/add-release-order.ts +0 -967
- package/server/routers/api/restful-apis/v2/bizplace.ts +0 -45
- package/server/routers/api/restful-apis/v2/cancel-marketplace-order.ts +0 -81
- package/server/routers/api/restful-apis/v2/cancel-release-order.ts +0 -91
- package/server/routers/api/restful-apis/v2/get-contact-point-list.ts +0 -110
- package/server/routers/api/restful-apis/v2/get-delivery-order-detail.ts +0 -46
- package/server/routers/api/restful-apis/v2/get-delivery-order-list.ts +0 -121
- package/server/routers/api/restful-apis/v2/get-delivery-orders.ts +0 -178
- package/server/routers/api/restful-apis/v2/get-goods-received-notes.ts +0 -134
- package/server/routers/api/restful-apis/v2/get-inbound-order-detail.ts +0 -128
- package/server/routers/api/restful-apis/v2/get-inbound-order-list.ts +0 -126
- package/server/routers/api/restful-apis/v2/get-inventory-overall-product-group.ts +0 -99
- package/server/routers/api/restful-apis/v2/get-inventory-product-group.ts +0 -112
- package/server/routers/api/restful-apis/v2/get-marketplace-order-shipping-list.ts +0 -156
- package/server/routers/api/restful-apis/v2/get-marketplace-store-list.ts +0 -81
- package/server/routers/api/restful-apis/v2/get-onhand-inventories.ts +0 -125
- package/server/routers/api/restful-apis/v2/get-partners.ts +0 -26
- package/server/routers/api/restful-apis/v2/get-products.ts +0 -216
- package/server/routers/api/restful-apis/v2/get-release-order-detail.ts +0 -134
- package/server/routers/api/restful-apis/v2/get-release-order-list.ts +0 -198
- package/server/routers/api/restful-apis/v2/get-warehouses.ts +0 -19
- package/server/routers/api/restful-apis/v2/index.ts +0 -31
- package/server/routers/api/restful-apis/v2/reject-inbound-order.ts +0 -46
- package/server/routers/api/restful-apis/v2/set-marketplace-order-delivered.ts +0 -60
- package/server/routers/api/restful-apis/v2/set-marketplace-order-failed-delivery.ts +0 -60
- package/server/routers/api/restful-apis/v2/update-marketplace-order.ts +0 -111
- package/server/routers/api/restful-apis/v2/update-marketplace-shipping-order.ts +0 -104
- package/server/routers/api/restful-apis/v2/update-release-order-details.ts +0 -94
- package/server/routers/auth-invitation-router.ts +0 -25
- package/server/routers/business/bizplace-register-router.ts +0 -31
- package/server/routers/business/business-register-router.ts +0 -32
- package/server/routers/business/index.ts +0 -3
- package/server/routers/business/path-base-business-router.ts +0 -15
- package/server/routes.ts +0 -28
- package/server/templates/account-unlock-email.ts +0 -64
- package/server/templates/invitation-email.ts +0 -65
- package/server/templates/reset-password-email.ts +0 -64
- package/server/templates/verification-email.ts +0 -65
- package/server/utils/build-map.ts +0 -18
- package/server/utils/get-warehouses.ts +0 -115
- package/server/utils/index.ts +0 -3
- package/server/utils/order-no-generator.ts +0 -8
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
/** Customer list to inform when there are changes */
|
|
2
|
-
/** 1. SeeBuu */
|
|
3
|
-
|
|
4
|
-
import gql from 'graphql-tag'
|
|
5
|
-
|
|
6
|
-
import { restfulApiRouter as router } from '@things-factory/api'
|
|
7
|
-
|
|
8
|
-
import { businessMiddleware } from '../../../../middlewares/business-middleware'
|
|
9
|
-
import { storeMiddleware } from '../../../../middlewares/store-middleware'
|
|
10
|
-
|
|
11
|
-
router.get(
|
|
12
|
-
'/v1/warehouse/:storeId/get-marketplace-order-shipping-list',
|
|
13
|
-
businessMiddleware,
|
|
14
|
-
storeMiddleware,
|
|
15
|
-
async (context, next) => {
|
|
16
|
-
const { client, marketplaceStore, domain } = context.state
|
|
17
|
-
const { t } = context
|
|
18
|
-
const { shippingNo, orderNo, status, fromDate, toDate, paginationEntriesPerPage, paginationOffset } = context.query
|
|
19
|
-
|
|
20
|
-
let filters: any = [
|
|
21
|
-
{ name: 'marketplace_store_id', operator: 'eq', value: marketplaceStore?.id, relation: true },
|
|
22
|
-
{ name: 'domain', operator: 'eq', value: domain.id, relation: true }
|
|
23
|
-
]
|
|
24
|
-
let pagination: any = { page: 1, limit: 20 }
|
|
25
|
-
|
|
26
|
-
filters = await validateFilters(context, filters, shippingNo, orderNo, status, fromDate, toDate)
|
|
27
|
-
pagination = await validatePagination(context, pagination, paginationEntriesPerPage, paginationOffset)
|
|
28
|
-
|
|
29
|
-
context.body = {
|
|
30
|
-
result: (
|
|
31
|
-
await client.query({
|
|
32
|
-
query: gql`
|
|
33
|
-
query marketplaceOrderShippings($filters: [Filter], $pagination: Pagination, $sortings: [Sorting]) {
|
|
34
|
-
marketplaceOrderShippings(filters: $filters, pagination: $pagination, sortings: $sortings) {
|
|
35
|
-
items {
|
|
36
|
-
id
|
|
37
|
-
name
|
|
38
|
-
orderNoRef
|
|
39
|
-
subOrderNoRef
|
|
40
|
-
attentionTo
|
|
41
|
-
address1
|
|
42
|
-
address2
|
|
43
|
-
address3
|
|
44
|
-
address4
|
|
45
|
-
address5
|
|
46
|
-
state
|
|
47
|
-
city
|
|
48
|
-
postCode
|
|
49
|
-
country
|
|
50
|
-
phone1
|
|
51
|
-
phone2
|
|
52
|
-
email
|
|
53
|
-
orderType
|
|
54
|
-
trackingNo
|
|
55
|
-
ownTrackingNo
|
|
56
|
-
airwayBill
|
|
57
|
-
deliveryMethod
|
|
58
|
-
weightUnit
|
|
59
|
-
totalWeight
|
|
60
|
-
volumeUnit
|
|
61
|
-
totalVolume
|
|
62
|
-
transporter
|
|
63
|
-
ownTransporter
|
|
64
|
-
marketplaceStore {
|
|
65
|
-
id
|
|
66
|
-
name
|
|
67
|
-
storeId
|
|
68
|
-
}
|
|
69
|
-
marketplaceOrderShippingItems {
|
|
70
|
-
marketplaceOrderItem {
|
|
71
|
-
id
|
|
72
|
-
qty
|
|
73
|
-
status
|
|
74
|
-
marketplaceProductVariation {
|
|
75
|
-
id
|
|
76
|
-
variationId
|
|
77
|
-
name
|
|
78
|
-
sku
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
total
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
`,
|
|
87
|
-
variables: {
|
|
88
|
-
filters,
|
|
89
|
-
pagination,
|
|
90
|
-
sortings: [{ name: 'createdAt', desc: true }]
|
|
91
|
-
},
|
|
92
|
-
context: {
|
|
93
|
-
...context,
|
|
94
|
-
state: {
|
|
95
|
-
...context.state,
|
|
96
|
-
marketplaceStore,
|
|
97
|
-
domain
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
} as any)
|
|
101
|
-
).data
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
export async function validateFilters(context, filters, shippingNo, orderNo, status, fromDate, toDate) {
|
|
107
|
-
if (shippingNo && shippingNo !== '') filters = [...filters, { name: 'name', operator: 'eq', value: shippingNo }]
|
|
108
|
-
|
|
109
|
-
if (orderNo && orderNo !== '') filters = [...filters, { name: 'orderNoRef', operator: 'eq', value: orderNo }]
|
|
110
|
-
|
|
111
|
-
if (status && status !== '') filters = [...filters, { name: 'status', operator: 'eq', value: status }]
|
|
112
|
-
|
|
113
|
-
// if (fromDate && fromDate !== '') {
|
|
114
|
-
// fromDate = new Date(`${fromDate.split(' ').join('')} 00:00:00`)
|
|
115
|
-
// // if (fromDate instanceof Date && !isNaN(fromDate.getTime())) fromDate = fromDate.toLocaleString()
|
|
116
|
-
// // else context.throw(400, context.t('fromDate is invalid'))
|
|
117
|
-
// } else fromDate = ''
|
|
118
|
-
|
|
119
|
-
// if (toDate && toDate !== '') {
|
|
120
|
-
// toDate = new Date(`${toDate.split(' ').join('')} 23:59:59`)
|
|
121
|
-
// // if (toDate instanceof Date && !isNaN(toDate.getTime())) toDate = toDate.toLocaleString()
|
|
122
|
-
// // else context.throw(400, context.t('toDate is invalid'))
|
|
123
|
-
// } else toDate = ''
|
|
124
|
-
|
|
125
|
-
if (fromDate !== '' && toDate !== '')
|
|
126
|
-
filters = [...filters, { name: 'createdAt', operator: 'between', value: [fromDate, toDate] }]
|
|
127
|
-
else if (fromDate !== '' && toDate === '')
|
|
128
|
-
filters = [...filters, { name: 'createdAt', operator: 'gte', value: fromDate }]
|
|
129
|
-
else if (fromDate === '' && toDate !== '')
|
|
130
|
-
filters = [...filters, { name: 'createdAt', operator: 'lte', value: toDate }]
|
|
131
|
-
|
|
132
|
-
return filters
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export async function validatePagination(context, pagination, entries, offset) {
|
|
136
|
-
if (!entries) entries = ''
|
|
137
|
-
if (!offset) offset = ''
|
|
138
|
-
|
|
139
|
-
if (entries !== '' && offset !== '' && !isNaN(parseInt(entries)) && !isNaN(parseInt(offset))) {
|
|
140
|
-
entries = parseInt(entries)
|
|
141
|
-
offset = parseInt(offset)
|
|
142
|
-
|
|
143
|
-
if (offset < 1) context.throw(400, context.t('paginationOffset cannot be less than 1'))
|
|
144
|
-
else if (entries < 1) context.throw(400, context.t('paginationEntriesPerPage cannot be less than 1'))
|
|
145
|
-
else if (entries > 100) context.throw(400, context.t('paginationEntriesPerPage cannot be more than 100'))
|
|
146
|
-
else pagination = { ...pagination, page: offset, limit: entries }
|
|
147
|
-
} else if (entries !== '' && offset === '' && !isNaN(parseInt(entries))) {
|
|
148
|
-
entries = parseInt(entries)
|
|
149
|
-
|
|
150
|
-
if (entries < 1) context.throw(400, context.t('paginationEntriesPerPage cannot be less than 1'))
|
|
151
|
-
else if (entries > 100) context.throw(400, context.t('paginationEntriesPerPage cannot be more than 100'))
|
|
152
|
-
else pagination = { ...pagination, limit: entries }
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return pagination
|
|
156
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/** Customer list to inform when there are changes */
|
|
2
|
-
/** 1. SeeBuu */
|
|
3
|
-
|
|
4
|
-
import gql from 'graphql-tag'
|
|
5
|
-
|
|
6
|
-
import { restfulApiRouter as router } from '@things-factory/api'
|
|
7
|
-
|
|
8
|
-
import { businessMiddleware } from '../../../../middlewares/business-middleware'
|
|
9
|
-
|
|
10
|
-
router.get('/v1/warehouse/get-marketplace-store-list', businessMiddleware, async (context, next) => {
|
|
11
|
-
const { client, domain } = context.state
|
|
12
|
-
const { t } = context
|
|
13
|
-
const { paginationEntriesPerPage, paginationOffset } = context.query
|
|
14
|
-
|
|
15
|
-
let filters: any = []
|
|
16
|
-
let pagination: any = { page: 1, limit: 20 }
|
|
17
|
-
|
|
18
|
-
pagination = await validatePagination(context, pagination, paginationEntriesPerPage, paginationOffset)
|
|
19
|
-
|
|
20
|
-
context.body = {
|
|
21
|
-
result: (
|
|
22
|
-
await client.query({
|
|
23
|
-
query: gql`
|
|
24
|
-
query marketplaceStores($filters: [Filter], $pagination: Pagination, $sortings: [Sorting]) {
|
|
25
|
-
marketplaceStores(filters: $filters, pagination: $pagination, sortings: $sortings) {
|
|
26
|
-
items {
|
|
27
|
-
id
|
|
28
|
-
name
|
|
29
|
-
platform
|
|
30
|
-
eTrax
|
|
31
|
-
storeName
|
|
32
|
-
isAutoUpdateStockQty
|
|
33
|
-
isAutoUpdateShipment
|
|
34
|
-
storeId
|
|
35
|
-
countryCode
|
|
36
|
-
status
|
|
37
|
-
updatedAt
|
|
38
|
-
}
|
|
39
|
-
total
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
`,
|
|
43
|
-
variables: {
|
|
44
|
-
filters,
|
|
45
|
-
pagination,
|
|
46
|
-
sortings: [{ name: 'createdAt', desc: true }]
|
|
47
|
-
},
|
|
48
|
-
context: {
|
|
49
|
-
...context,
|
|
50
|
-
state: {
|
|
51
|
-
...context.state,
|
|
52
|
-
domain
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
} as any)
|
|
56
|
-
).data
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
export async function validatePagination(context, pagination, entries, offset) {
|
|
61
|
-
if (!entries) entries = ''
|
|
62
|
-
if (!offset) offset = ''
|
|
63
|
-
|
|
64
|
-
if (entries !== '' && offset !== '' && !isNaN(parseInt(entries)) && !isNaN(parseInt(offset))) {
|
|
65
|
-
entries = parseInt(entries)
|
|
66
|
-
offset = parseInt(offset)
|
|
67
|
-
|
|
68
|
-
if (offset < 1) context.throw(400, context.t('paginationOffset cannot be less than 1'))
|
|
69
|
-
else if (entries < 1) context.throw(400, context.t('paginationEntriesPerPage cannot be less than 1'))
|
|
70
|
-
else if (entries > 100) context.throw(400, context.t('paginationEntriesPerPage cannot be more than 100'))
|
|
71
|
-
else pagination = { ...pagination, page: offset, limit: entries }
|
|
72
|
-
} else if (entries !== '' && offset === '' && !isNaN(parseInt(entries))) {
|
|
73
|
-
entries = parseInt(entries)
|
|
74
|
-
|
|
75
|
-
if (entries < 1) context.throw(400, context.t('paginationEntriesPerPage cannot be less than 1'))
|
|
76
|
-
else if (entries > 100) context.throw(400, context.t('paginationEntriesPerPage cannot be more than 100'))
|
|
77
|
-
else pagination = { ...pagination, limit: entries }
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return pagination
|
|
81
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import gql from 'graphql-tag'
|
|
2
|
-
|
|
3
|
-
import { restfulApiRouter as router } from '@things-factory/api'
|
|
4
|
-
import { Product } from '@things-factory/product-base'
|
|
5
|
-
import { getRepository } from '@things-factory/shell'
|
|
6
|
-
|
|
7
|
-
import { businessMiddleware } from '../../../../middlewares/business-middleware'
|
|
8
|
-
import { warehouseMiddleware } from '../../../../middlewares/warehouse-middleware'
|
|
9
|
-
|
|
10
|
-
const debug = require('debug')('things-factory:operato-hub:restful-api:v1:onhand-inventories')
|
|
11
|
-
|
|
12
|
-
router.get(
|
|
13
|
-
'/v1/warehouse/:warehouseId/onhand-inventories',
|
|
14
|
-
businessMiddleware,
|
|
15
|
-
warehouseMiddleware,
|
|
16
|
-
async (context, next) => {
|
|
17
|
-
const { client, warehouse: bizplace, domain } = context.state
|
|
18
|
-
const { skuId, batchId } = context.query
|
|
19
|
-
const { t } = context
|
|
20
|
-
const { warehouseId } = context.params
|
|
21
|
-
|
|
22
|
-
if (!warehouseId) context.throw(404, t('error.warehouse id not found'))
|
|
23
|
-
if (!skuId) context.throw(400, context.t('error.required param x not found', { x: 'skuId' }))
|
|
24
|
-
if (!batchId) context.throw(400, context.t('error.required param x not found', { x: 'batchId' }))
|
|
25
|
-
debug('query-params', context.query)
|
|
26
|
-
|
|
27
|
-
let filters = await checkValidity(bizplace, skuId, batchId)
|
|
28
|
-
|
|
29
|
-
context.body = {
|
|
30
|
-
result: (
|
|
31
|
-
await client.query({
|
|
32
|
-
query: gql`
|
|
33
|
-
query inventories($filters: [Filter!]) {
|
|
34
|
-
inventories(filters: $filters) {
|
|
35
|
-
items {
|
|
36
|
-
id
|
|
37
|
-
palletId
|
|
38
|
-
batchId
|
|
39
|
-
packingType
|
|
40
|
-
weight
|
|
41
|
-
bizplace {
|
|
42
|
-
id
|
|
43
|
-
name
|
|
44
|
-
description
|
|
45
|
-
}
|
|
46
|
-
product {
|
|
47
|
-
id
|
|
48
|
-
name
|
|
49
|
-
description
|
|
50
|
-
sku
|
|
51
|
-
}
|
|
52
|
-
qty
|
|
53
|
-
remainQty
|
|
54
|
-
warehouse {
|
|
55
|
-
id
|
|
56
|
-
name
|
|
57
|
-
description
|
|
58
|
-
}
|
|
59
|
-
zone
|
|
60
|
-
location {
|
|
61
|
-
id
|
|
62
|
-
name
|
|
63
|
-
description
|
|
64
|
-
}
|
|
65
|
-
updatedAt
|
|
66
|
-
updater {
|
|
67
|
-
name
|
|
68
|
-
description
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
total
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
`,
|
|
75
|
-
variables: {
|
|
76
|
-
filters
|
|
77
|
-
},
|
|
78
|
-
context: {
|
|
79
|
-
...context,
|
|
80
|
-
state: {
|
|
81
|
-
...context.state,
|
|
82
|
-
bizplace,
|
|
83
|
-
domain
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
} as any)
|
|
87
|
-
).data
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
)
|
|
91
|
-
|
|
92
|
-
export async function checkValidity(bizplace, skuId, batchId) {
|
|
93
|
-
let product: Product = []
|
|
94
|
-
|
|
95
|
-
let filters: any = [
|
|
96
|
-
{ name: 'status', operator: 'notin', value: ['INTRANSIT', 'TERMINATED', 'DELETED'] },
|
|
97
|
-
{ name: 'remainOnly', operator: 'eq', value: true },
|
|
98
|
-
{ name: 'unlockOnly', operator: 'eq', value: true }
|
|
99
|
-
]
|
|
100
|
-
|
|
101
|
-
if (bizplace.id != '') {
|
|
102
|
-
filters = [...filters, { name: 'bizplace', operator: 'in', value: [bizplace.id], relation: true }]
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (skuId) {
|
|
106
|
-
product = await getRepository(Product).findOne({
|
|
107
|
-
where: {
|
|
108
|
-
sku: skuId
|
|
109
|
-
},
|
|
110
|
-
relations: ['domain']
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
if (product) {
|
|
114
|
-
filters = [...filters, { name: 'product', operator: 'in', value: [product.id], relation: true }]
|
|
115
|
-
} else {
|
|
116
|
-
filters = [...filters, { name: 'product', operator: 'in', value: [skuId], relation: true }]
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (batchId) {
|
|
121
|
-
filters = [...filters, { name: 'batchId', operator: 'eq', value: batchId }]
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return filters
|
|
125
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { In } from 'typeorm'
|
|
2
|
-
|
|
3
|
-
import { restfulApiRouter as router } from '@things-factory/api'
|
|
4
|
-
import { Bizplace, Partner } from '@things-factory/biz-base'
|
|
5
|
-
import { getRepository } from '@things-factory/shell'
|
|
6
|
-
|
|
7
|
-
const debug = require('debug')('things-factory:operato-hub:restful-api:v1:get-partners')
|
|
8
|
-
|
|
9
|
-
router.get('/v1/partners/:bizplaceId', async (context, next) => {
|
|
10
|
-
const { bizplaceId } = context.params
|
|
11
|
-
const bizplace: Bizplace = await getRepository(Bizplace).findOneBy({ id: bizplaceId })
|
|
12
|
-
const partners: Partner[] = await getRepository(Partner).find({
|
|
13
|
-
where: { partnerBizplace: { id: bizplace.id } },
|
|
14
|
-
relations: ['domainBizplace']
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
const domainBizplacesId: string[] = partners.map((p: Partner) => p.domainBizplace.id)
|
|
18
|
-
const domainBizplaces: Bizplace = await getRepository(Bizplace).find({
|
|
19
|
-
where: { id: In(domainBizplacesId) },
|
|
20
|
-
relations: ['domain']
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
context.body = {
|
|
24
|
-
result: domainBizplaces.map((b: Bizplace) => b.domain)
|
|
25
|
-
}
|
|
26
|
-
})
|
|
@@ -1,216 +0,0 @@
|
|
|
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
|
-
router.get(
|
|
9
|
-
'/v1/warehouse/:warehouseId/get-products',
|
|
10
|
-
businessMiddleware,
|
|
11
|
-
warehouseMiddleware,
|
|
12
|
-
async (context, next) => {
|
|
13
|
-
const { client, warehouse: bizplace, domain } = context.state
|
|
14
|
-
const { warehouseId } = context.params
|
|
15
|
-
const { t } = context
|
|
16
|
-
const { skuId, name, paginationEntriesPerPage, paginationOffset } = context.query
|
|
17
|
-
|
|
18
|
-
if (!warehouseId) context.throw(404, t('error.warehouse id not found'))
|
|
19
|
-
|
|
20
|
-
let filters: any = [{ name: 'bizplace_id', operator: 'eq', value: warehouseId }]
|
|
21
|
-
let pagination: any = { page: 1, limit: 20 }
|
|
22
|
-
|
|
23
|
-
filters = await validateFilters(filters, skuId, name)
|
|
24
|
-
pagination = await validatePagination(context, pagination, paginationEntriesPerPage, paginationOffset)
|
|
25
|
-
|
|
26
|
-
context.body = {
|
|
27
|
-
result: (
|
|
28
|
-
await client.query({
|
|
29
|
-
query: gql`
|
|
30
|
-
query products($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
|
|
31
|
-
products(filters: $filters, pagination: $pagination, sortings: $sortings) {
|
|
32
|
-
items {
|
|
33
|
-
id
|
|
34
|
-
sku
|
|
35
|
-
name
|
|
36
|
-
description
|
|
37
|
-
type
|
|
38
|
-
brand
|
|
39
|
-
subBrand
|
|
40
|
-
brandSku
|
|
41
|
-
isRequiredCheckExpiry
|
|
42
|
-
expirationPeriod
|
|
43
|
-
pickingStrategy
|
|
44
|
-
auxUnit1
|
|
45
|
-
auxValue1
|
|
46
|
-
auxUnit2
|
|
47
|
-
auxValue2
|
|
48
|
-
auxUnit3
|
|
49
|
-
auxValue3
|
|
50
|
-
updatedAt
|
|
51
|
-
###############################################
|
|
52
|
-
## TEMPORARY REMOVE DUE TO TYPEGRAPHQL ISSUE ##
|
|
53
|
-
# updater {
|
|
54
|
-
# id
|
|
55
|
-
# name
|
|
56
|
-
# }
|
|
57
|
-
# creator {
|
|
58
|
-
# id
|
|
59
|
-
# name
|
|
60
|
-
# }
|
|
61
|
-
###############################################
|
|
62
|
-
productDetails {
|
|
63
|
-
id
|
|
64
|
-
gtin
|
|
65
|
-
sku
|
|
66
|
-
description
|
|
67
|
-
type
|
|
68
|
-
refCode
|
|
69
|
-
isDefault
|
|
70
|
-
packingType
|
|
71
|
-
packingSize
|
|
72
|
-
movement
|
|
73
|
-
uom
|
|
74
|
-
uomValue
|
|
75
|
-
childProductDetail {
|
|
76
|
-
id
|
|
77
|
-
gtin
|
|
78
|
-
sku
|
|
79
|
-
description
|
|
80
|
-
type
|
|
81
|
-
refCode
|
|
82
|
-
product {
|
|
83
|
-
id
|
|
84
|
-
}
|
|
85
|
-
isDefault
|
|
86
|
-
packingType
|
|
87
|
-
packingSize
|
|
88
|
-
movement
|
|
89
|
-
uom
|
|
90
|
-
uomValue
|
|
91
|
-
bundleQty
|
|
92
|
-
weightUnit
|
|
93
|
-
nettWeight
|
|
94
|
-
grossWeight
|
|
95
|
-
lengthUnit
|
|
96
|
-
width
|
|
97
|
-
depth
|
|
98
|
-
height
|
|
99
|
-
volume
|
|
100
|
-
bufferQty
|
|
101
|
-
minQty
|
|
102
|
-
maxQty
|
|
103
|
-
auxUnit1
|
|
104
|
-
auxValue1
|
|
105
|
-
auxUnit2
|
|
106
|
-
auxValue2
|
|
107
|
-
auxUnit3
|
|
108
|
-
auxValue3
|
|
109
|
-
auxUnit4
|
|
110
|
-
auxValue4
|
|
111
|
-
auxUnit5
|
|
112
|
-
auxValue5
|
|
113
|
-
costPrice
|
|
114
|
-
sellPrice
|
|
115
|
-
afterTaxCostPrice
|
|
116
|
-
afterTaxSalesPrice
|
|
117
|
-
updatedAt
|
|
118
|
-
createdAt
|
|
119
|
-
deletedAt
|
|
120
|
-
}
|
|
121
|
-
childQty
|
|
122
|
-
bundleQty
|
|
123
|
-
weightUnit
|
|
124
|
-
nettWeight
|
|
125
|
-
grossWeight
|
|
126
|
-
lengthUnit
|
|
127
|
-
width
|
|
128
|
-
depth
|
|
129
|
-
height
|
|
130
|
-
volume
|
|
131
|
-
bufferQty
|
|
132
|
-
minQty
|
|
133
|
-
maxQty
|
|
134
|
-
auxUnit1
|
|
135
|
-
auxValue1
|
|
136
|
-
auxUnit2
|
|
137
|
-
auxValue2
|
|
138
|
-
auxUnit3
|
|
139
|
-
auxValue3
|
|
140
|
-
auxUnit4
|
|
141
|
-
auxValue4
|
|
142
|
-
auxUnit5
|
|
143
|
-
auxValue5
|
|
144
|
-
costPrice
|
|
145
|
-
sellPrice
|
|
146
|
-
afterTaxCostPrice
|
|
147
|
-
afterTaxSalesPrice
|
|
148
|
-
###############################################
|
|
149
|
-
## TEMPORARY REMOVE DUE TO TYPEGRAPHQL ISSUE ##
|
|
150
|
-
# updater {
|
|
151
|
-
# id
|
|
152
|
-
# name
|
|
153
|
-
# }
|
|
154
|
-
# creator {
|
|
155
|
-
# id
|
|
156
|
-
# name
|
|
157
|
-
# }
|
|
158
|
-
###############################################
|
|
159
|
-
updatedAt
|
|
160
|
-
createdAt
|
|
161
|
-
deletedAt
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
total
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
`,
|
|
168
|
-
variables: {
|
|
169
|
-
filters,
|
|
170
|
-
pagination,
|
|
171
|
-
sortings: []
|
|
172
|
-
},
|
|
173
|
-
context: {
|
|
174
|
-
...context,
|
|
175
|
-
state: {
|
|
176
|
-
...context.state,
|
|
177
|
-
bizplace,
|
|
178
|
-
domain
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
} as any)
|
|
182
|
-
).data
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
)
|
|
186
|
-
|
|
187
|
-
export async function validateFilters(filters, skuId, name) {
|
|
188
|
-
if (skuId && skuId !== '') filters = [...filters, { name: 'sku', operator: 'i_like', value: skuId }]
|
|
189
|
-
|
|
190
|
-
if (name && name !== '') filters = [...filters, { name: 'name', operator: 'i_like', value: name }]
|
|
191
|
-
|
|
192
|
-
return filters
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export async function validatePagination(context, pagination, entries, offset) {
|
|
196
|
-
if (!entries) entries = ''
|
|
197
|
-
if (!offset) offset = ''
|
|
198
|
-
|
|
199
|
-
if (entries !== '' && offset !== '' && !isNaN(parseInt(entries)) && !isNaN(parseInt(offset))) {
|
|
200
|
-
entries = parseInt(entries)
|
|
201
|
-
offset = parseInt(offset)
|
|
202
|
-
|
|
203
|
-
if (offset < 1) context.throw(400, context.t('paginationOffset cannot be less than 1'))
|
|
204
|
-
else if (entries < 1) context.throw(400, context.t('paginationEntriesPerPage cannot be less than 1'))
|
|
205
|
-
else if (entries > 100) context.throw(400, context.t('paginationEntriesPerPage cannot be more than 100'))
|
|
206
|
-
else pagination = { ...pagination, page: offset, limit: entries }
|
|
207
|
-
} else if (entries !== '' && offset === '' && !isNaN(parseInt(entries))) {
|
|
208
|
-
entries = parseInt(entries)
|
|
209
|
-
|
|
210
|
-
if (entries < 1) context.throw(400, context.t('paginationEntriesPerPage cannot be less than 1'))
|
|
211
|
-
else if (entries > 100) context.throw(400, context.t('paginationEntriesPerPage cannot be more than 100'))
|
|
212
|
-
else pagination = { ...pagination, limit: entries }
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return pagination
|
|
216
|
-
}
|