@things-factory/operato-hub 4.3.334 → 4.3.335
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/routers/internal/index.js +1 -0
- package/dist-server/routers/internal/index.js.map +1 -1
- package/dist-server/routers/internal/sellercraft-router.js +53 -0
- package/dist-server/routers/internal/sellercraft-router.js.map +1 -0
- package/dist-server/routes.js +2 -1
- package/dist-server/routes.js.map +1 -1
- package/package.json +10 -10
- package/server/routers/internal/index.ts +1 -0
- package/server/routers/internal/sellercraft-router.ts +75 -0
- package/server/routes.ts +8 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/routers/internal/index.ts"],"names":[],"mappings":";;AAAA,2BAAwB;AACxB,yBAAsB;AACtB,mBAAgB;AAChB,kBAAe"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/routers/internal/index.ts"],"names":[],"mappings":";;AAAA,gCAA6B;AAC7B,2BAAwB;AACxB,yBAAsB;AACtB,mBAAgB;AAChB,kBAAe"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.sellercraftRouter = void 0;
|
|
7
|
+
const koa_router_1 = __importDefault(require("koa-router"));
|
|
8
|
+
const typeorm_1 = require("typeorm");
|
|
9
|
+
const biz_base_1 = require("@things-factory/biz-base");
|
|
10
|
+
const integration_fulfillment_1 = require("@things-factory/integration-fulfillment");
|
|
11
|
+
const integration_sellercraft_1 = require("@things-factory/integration-sellercraft");
|
|
12
|
+
const sync_products_to_sellercraft_1 = require("../../graphql/resolvers/synchronization/sync-products-to-sellercraft");
|
|
13
|
+
const error_util_1 = require("./utils/error-util");
|
|
14
|
+
const debug = require('debug')('things-factory:operato-hub:sellercraft-router');
|
|
15
|
+
exports.sellercraftRouter = new koa_router_1.default();
|
|
16
|
+
exports.sellercraftRouter.post('/internal/sync-products-to-sellercraft', async (context, next) => {
|
|
17
|
+
try {
|
|
18
|
+
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
19
|
+
const { body } = context.request;
|
|
20
|
+
await getSellercraftAndFulfillmentCenter(context, tx);
|
|
21
|
+
sync_products_to_sellercraft_1.syncProductsToSellercraftResolver.syncProductsToSellercraft(null, { sellercraftId: body.sellercraftId, fulfillmentCenterId: body.fulfillmentCenterId, toCreateSku: null }, Object.assign(Object.assign({}, context), { state: Object.assign(Object.assign({}, context.state), { tx: tx }) }));
|
|
22
|
+
context.body = {
|
|
23
|
+
result: { status: 'success' }
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
if (e instanceof error_util_1.ApiError)
|
|
29
|
+
(0, error_util_1.ApiErrorHandler)(context, e);
|
|
30
|
+
else
|
|
31
|
+
(0, error_util_1.throwInternalServerError)(context, e);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
async function getSellercraftAndFulfillmentCenter(context, tx) {
|
|
35
|
+
const { body } = context.request;
|
|
36
|
+
const sellercraft = await tx.getRepository(integration_sellercraft_1.Sellercraft).findOne({
|
|
37
|
+
where: { id: body.sellercraftId, status: 'ACTIVE' }
|
|
38
|
+
});
|
|
39
|
+
if (!sellercraft) {
|
|
40
|
+
throw new error_util_1.ApiError('E04', 'sellercraftId');
|
|
41
|
+
}
|
|
42
|
+
const bizplace = await tx.getRepository(biz_base_1.Bizplace).findOne({
|
|
43
|
+
where: { domain: sellercraft.domainId }
|
|
44
|
+
});
|
|
45
|
+
const companyBizplace = await (0, biz_base_1.getCompanyBizplace)(null, null, bizplace.id);
|
|
46
|
+
const fulfillmentCenter = await tx.getRepository(integration_fulfillment_1.FulfillmentCenter).findOne({
|
|
47
|
+
where: { id: body.fulfillmentCenterId, domain: companyBizplace.domain.id }
|
|
48
|
+
});
|
|
49
|
+
if (!fulfillmentCenter) {
|
|
50
|
+
throw new error_util_1.ApiError('E04', 'fulfillmentCenterId');
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=sellercraft-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sellercraft-router.js","sourceRoot":"","sources":["../../../server/routers/internal/sellercraft-router.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AAC/B,qCAGgB;AAEhB,uDAGiC;AACjC,qFAA2E;AAC3E,qFAAqE;AAErE,uHAAwH;AACxH,mDAI2B;AAE3B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,+CAA+C,CAAC,CAAA;AAElE,QAAA,iBAAiB,GAAG,IAAI,oBAAM,EAAE,CAAA;AAE7C,yBAAiB,CAAC,IAAI,CAAC,wCAAwC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACvF,IAAI;QACF,MAAM,IAAA,uBAAa,GAAE,CAAC,WAAW,CAAC,KAAK,EAAE,EAAiB,EAAE,EAAE;YAC5D,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,CAAA;YAEhC,MAAM,kCAAkC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;YAErD,gEAAiC,CAAC,yBAAyB,CACzD,IAAI,EACJ,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,EAAE,WAAW,EAAE,IAAI,EAAE,kCAElG,OAAO,KACV,KAAK,kCAAO,OAAO,CAAC,KAAK,KAAE,EAAE,EAAE,EAAE,OAEpC,CAAA;YAED,OAAO,CAAC,IAAI,GAAG;gBACb,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE;aAC9B,CAAA;QACH,CAAC,CAAC,CAAA;KACH;IAAC,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|
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const business_middleware_1 = require("./middlewares/business-middleware");
|
|
4
4
|
const business_1 = require("./routers/business");
|
|
5
5
|
const powrup_router_1 = require("./routers/internal/powrup-router");
|
|
6
|
+
const sellercraft_router_1 = require("./routers/internal/sellercraft-router");
|
|
6
7
|
const xilnex_router_1 = require("./routers/xilnex-router");
|
|
7
8
|
const debug = require('debug')('things-factory:operato-hub:routes');
|
|
8
9
|
process.on('bootstrap-module-global-public-route', (app, globalPublicRouter) => {
|
|
9
|
-
globalPublicRouter.use(xilnex_router_1.xilnexRouter.routes(), xilnex_router_1.xilnexRouter.allowedMethods(), powrup_router_1.powrupRouter.routes(), powrup_router_1.powrupRouter.allowedMethods());
|
|
10
|
+
globalPublicRouter.use(xilnex_router_1.xilnexRouter.routes(), xilnex_router_1.xilnexRouter.allowedMethods(), powrup_router_1.powrupRouter.routes(), powrup_router_1.powrupRouter.allowedMethods(), sellercraft_router_1.sellercraftRouter.routes(), sellercraft_router_1.sellercraftRouter.allowedMethods());
|
|
10
11
|
});
|
|
11
12
|
process.on('bootstrap-module-global-private-route', (app, globalPrivateRouter) => {
|
|
12
13
|
globalPrivateRouter.use('/business-register', business_1.businessRegisterRouter.routes(), business_1.businessRegisterRouter.allowedMethods());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,2EAAsE;AACtE,
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../server/routes.ts"],"names":[],"mappings":";;AAAA,2EAAsE;AACtE,iDAG2B;AAC3B,oEAA+D;AAC/D,8EAAyE;AACzE,2DAAsD;AAEtD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,mCAAmC,CAAC,CAAA;AAEnE,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF,kBAAkB,CAAC,GAAG,CACpB,4BAAY,CAAC,MAAM,EAAE,EACrB,4BAAY,CAAC,cAAc,EAAE,EAC7B,4BAAY,CAAC,MAAM,EAAE,EACrB,4BAAY,CAAC,cAAc,EAAE,EAC7B,sCAAiB,CAAC,MAAM,EAAE,EAC1B,sCAAiB,CAAC,cAAc,EAAE,CACnC,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF,mBAAmB,CAAC,GAAG,CACrB,oBAAoB,EACpB,iCAAsB,CAAC,MAAM,EAAE,EAC/B,iCAAsB,CAAC,cAAc,EAAE,CACxC,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,sCAA6C,EAAE,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE;IACpF,mGAAmG;IACnG,kBAAkB,CAAC,GAAG,CAAC,wCAAkB,CAAC,CAAA;AAC5C,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,EAAE,CAAC,uCAA8C,EAAE,CAAC,GAAG,EAAE,mBAAmB,EAAE,EAAE;IACtF,mBAAmB,CAAC,GAAG,CAAC,wCAAkB,CAAC,CAAA;IAE3C,8CAA8C;IAC9C,mBAAmB,CAAC,GAAG,CACrB,oBAAoB,EACpB,iCAAsB,CAAC,MAAM,EAAE,EAC/B,iCAAsB,CAAC,cAAc,EAAE,CACxC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/operato-hub",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.335",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -79,20 +79,20 @@
|
|
|
79
79
|
"@things-factory/import-ui-excel": "^4.3.281",
|
|
80
80
|
"@things-factory/integration-accounting": "^4.3.332",
|
|
81
81
|
"@things-factory/integration-fulfillment": "^4.3.332",
|
|
82
|
-
"@things-factory/integration-lmd": "^4.3.
|
|
83
|
-
"@things-factory/integration-marketplace": "^4.3.
|
|
82
|
+
"@things-factory/integration-lmd": "^4.3.335",
|
|
83
|
+
"@things-factory/integration-marketplace": "^4.3.335",
|
|
84
84
|
"@things-factory/integration-pos": "^4.3.332",
|
|
85
|
-
"@things-factory/integration-powrup": "^4.3.
|
|
86
|
-
"@things-factory/integration-sellercraft": "^4.3.
|
|
85
|
+
"@things-factory/integration-powrup": "^4.3.335",
|
|
86
|
+
"@things-factory/integration-sellercraft": "^4.3.335",
|
|
87
87
|
"@things-factory/integration-sftp": "^4.3.332",
|
|
88
88
|
"@things-factory/lite-menu": "^4.3.281",
|
|
89
|
-
"@things-factory/marketplace-base": "^4.3.
|
|
89
|
+
"@things-factory/marketplace-base": "^4.3.335",
|
|
90
90
|
"@things-factory/more-ui": "^4.3.281",
|
|
91
91
|
"@things-factory/notification": "^4.3.281",
|
|
92
92
|
"@things-factory/pdf": "^4.3.281",
|
|
93
93
|
"@things-factory/product-ui": "^4.3.326",
|
|
94
94
|
"@things-factory/resource-ui": "^4.3.281",
|
|
95
|
-
"@things-factory/sales-base": "^4.3.
|
|
95
|
+
"@things-factory/sales-base": "^4.3.335",
|
|
96
96
|
"@things-factory/scene-data-transform": "^4.3.281",
|
|
97
97
|
"@things-factory/scene-excel": "^4.3.281",
|
|
98
98
|
"@things-factory/scene-firebase": "^4.3.281",
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
"@things-factory/setting-ui": "^4.3.281",
|
|
108
108
|
"@things-factory/shell": "^4.3.281",
|
|
109
109
|
"@things-factory/system-ui": "^4.3.281",
|
|
110
|
-
"@things-factory/warehouse-base": "^4.3.
|
|
111
|
-
"@things-factory/worksheet-base": "^4.3.
|
|
110
|
+
"@things-factory/warehouse-base": "^4.3.335",
|
|
111
|
+
"@things-factory/worksheet-base": "^4.3.335",
|
|
112
112
|
"cron-parser": "^4.7.0",
|
|
113
113
|
"koa2-swagger-ui": "^5.0.2",
|
|
114
114
|
"swagger-jsdoc": "^5.0.0",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"resolutions": {
|
|
121
121
|
"core-js": "^3.16.0"
|
|
122
122
|
},
|
|
123
|
-
"gitHead": "
|
|
123
|
+
"gitHead": "b475ac676bc9286c19f679300a012c1d0528761b"
|
|
124
124
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import Router from 'koa-router'
|
|
2
|
+
import {
|
|
3
|
+
EntityManager,
|
|
4
|
+
getConnection
|
|
5
|
+
} from 'typeorm'
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
Bizplace,
|
|
9
|
+
getCompanyBizplace
|
|
10
|
+
} from '@things-factory/biz-base'
|
|
11
|
+
import { FulfillmentCenter } from '@things-factory/integration-fulfillment'
|
|
12
|
+
import { Sellercraft } from '@things-factory/integration-sellercraft'
|
|
13
|
+
|
|
14
|
+
import { syncProductsToSellercraftResolver } from '../../graphql/resolvers/synchronization/sync-products-to-sellercraft'
|
|
15
|
+
import {
|
|
16
|
+
ApiError,
|
|
17
|
+
ApiErrorHandler,
|
|
18
|
+
throwInternalServerError
|
|
19
|
+
} from './utils/error-util'
|
|
20
|
+
|
|
21
|
+
const debug = require('debug')('things-factory:operato-hub:sellercraft-router')
|
|
22
|
+
|
|
23
|
+
export const sellercraftRouter = new Router()
|
|
24
|
+
|
|
25
|
+
sellercraftRouter.post('/internal/sync-products-to-sellercraft', async (context, next) => {
|
|
26
|
+
try {
|
|
27
|
+
await getConnection().transaction(async (tx: EntityManager) => {
|
|
28
|
+
const { body } = context.request
|
|
29
|
+
|
|
30
|
+
await getSellercraftAndFulfillmentCenter(context, tx)
|
|
31
|
+
|
|
32
|
+
syncProductsToSellercraftResolver.syncProductsToSellercraft(
|
|
33
|
+
null,
|
|
34
|
+
{ sellercraftId: body.sellercraftId, fulfillmentCenterId: body.fulfillmentCenterId, toCreateSku: null },
|
|
35
|
+
{
|
|
36
|
+
...context,
|
|
37
|
+
state: { ...context.state, tx: tx }
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
context.body = {
|
|
42
|
+
result: { status: 'success' }
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
} catch (e) {
|
|
46
|
+
if (e instanceof ApiError) ApiErrorHandler(context, e)
|
|
47
|
+
else throwInternalServerError(context, e)
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
async function getSellercraftAndFulfillmentCenter(context, tx) {
|
|
52
|
+
const { body } = context.request
|
|
53
|
+
|
|
54
|
+
const sellercraft: Sellercraft = await tx.getRepository(Sellercraft).findOne({
|
|
55
|
+
where: { id: body.sellercraftId, status: 'ACTIVE' }
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
if (!sellercraft) {
|
|
59
|
+
throw new ApiError('E04', 'sellercraftId')
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const bizplace: Bizplace = await tx.getRepository(Bizplace).findOne({
|
|
63
|
+
where: { domain: sellercraft.domainId }
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const companyBizplace: Bizplace = await getCompanyBizplace(null, null, bizplace.id)
|
|
67
|
+
|
|
68
|
+
const fulfillmentCenter: FulfillmentCenter = await tx.getRepository(FulfillmentCenter).findOne({
|
|
69
|
+
where: { id: body.fulfillmentCenterId, domain: companyBizplace.domain.id }
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
if (!fulfillmentCenter) {
|
|
73
|
+
throw new ApiError('E04', 'fulfillmentCenterId')
|
|
74
|
+
}
|
|
75
|
+
}
|
package/server/routes.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { businessMiddleware } from './middlewares/business-middleware'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
bizplaceRegisterRouter,
|
|
4
|
+
businessRegisterRouter
|
|
5
|
+
} from './routers/business'
|
|
3
6
|
import { powrupRouter } from './routers/internal/powrup-router'
|
|
7
|
+
import { sellercraftRouter } from './routers/internal/sellercraft-router'
|
|
4
8
|
import { xilnexRouter } from './routers/xilnex-router'
|
|
5
9
|
|
|
6
10
|
const debug = require('debug')('things-factory:operato-hub:routes')
|
|
@@ -10,7 +14,9 @@ process.on('bootstrap-module-global-public-route' as any, (app, globalPublicRout
|
|
|
10
14
|
xilnexRouter.routes(),
|
|
11
15
|
xilnexRouter.allowedMethods(),
|
|
12
16
|
powrupRouter.routes(),
|
|
13
|
-
powrupRouter.allowedMethods()
|
|
17
|
+
powrupRouter.allowedMethods(),
|
|
18
|
+
sellercraftRouter.routes(),
|
|
19
|
+
sellercraftRouter.allowedMethods()
|
|
14
20
|
)
|
|
15
21
|
})
|
|
16
22
|
|