@things-factory/operato-hub 4.3.234 → 4.3.235
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.
|
@@ -29,8 +29,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.powrupRouter = void 0;
|
|
30
30
|
const koa_router_1 = __importDefault(require("koa-router"));
|
|
31
31
|
const typeorm_1 = require("typeorm");
|
|
32
|
-
const biz_base_1 = require("@things-factory/biz-base");
|
|
33
32
|
const integration_base_1 = require("@things-factory/integration-base");
|
|
33
|
+
const shell_1 = require("@things-factory/shell");
|
|
34
34
|
const API = __importStar(require("./apis"));
|
|
35
35
|
const validation_middleware_1 = require("./middlewares/validation-middleware");
|
|
36
36
|
const error_util_1 = require("./utils/error-util");
|
|
@@ -40,7 +40,7 @@ exports.powrupRouter.post('/internal/account/create-user', validation_middleware
|
|
|
40
40
|
try {
|
|
41
41
|
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
42
42
|
const { body } = context.request;
|
|
43
|
-
await getIntegration(context, tx);
|
|
43
|
+
await getIntegration(context, null, tx);
|
|
44
44
|
let data = await API.createUser(body, context, tx);
|
|
45
45
|
context.body = {
|
|
46
46
|
result: { data }
|
|
@@ -58,7 +58,7 @@ exports.powrupRouter.post('/internal/account/update-user', validation_middleware
|
|
|
58
58
|
try {
|
|
59
59
|
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
60
60
|
const { body } = context.request;
|
|
61
|
-
await getIntegration(context, tx);
|
|
61
|
+
await getIntegration(context, null, tx);
|
|
62
62
|
let data = await API.updateUser(body, context, tx);
|
|
63
63
|
context.body = {
|
|
64
64
|
result: { data }
|
|
@@ -76,7 +76,7 @@ exports.powrupRouter.post('/internal/account/create-company', validation_middlew
|
|
|
76
76
|
try {
|
|
77
77
|
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
78
78
|
const { body } = context.request;
|
|
79
|
-
await getIntegration(context, tx);
|
|
79
|
+
await getIntegration(context, null, tx);
|
|
80
80
|
let data = await API.createCompany(body, context, tx);
|
|
81
81
|
context.body = {
|
|
82
82
|
result: { data }
|
|
@@ -111,7 +111,7 @@ exports.powrupRouter.post('/internal/account/create-bizplace', validation_middle
|
|
|
111
111
|
try {
|
|
112
112
|
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
113
113
|
const { body } = context.request;
|
|
114
|
-
await getIntegration(context, tx);
|
|
114
|
+
await getIntegration(context, null, tx);
|
|
115
115
|
let data = await API.createBizplace(body, context, tx);
|
|
116
116
|
context.body = {
|
|
117
117
|
result: { data }
|
|
@@ -129,7 +129,7 @@ exports.powrupRouter.post('/internal/account/update-bizplace', validation_middle
|
|
|
129
129
|
try {
|
|
130
130
|
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
131
131
|
const { body } = context.request;
|
|
132
|
-
await getIntegration(context, tx);
|
|
132
|
+
await getIntegration(context, null, tx);
|
|
133
133
|
let data = await API.updateBizplace(body, context, tx);
|
|
134
134
|
context.body = {
|
|
135
135
|
result: { data }
|
|
@@ -147,7 +147,7 @@ exports.powrupRouter.post('/internal/account/create-partner', validation_middlew
|
|
|
147
147
|
try {
|
|
148
148
|
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
149
149
|
const { body } = context.request;
|
|
150
|
-
await getIntegration(context, tx);
|
|
150
|
+
await getIntegration(context, null, tx);
|
|
151
151
|
let data = await API.createPartner(body, context, tx);
|
|
152
152
|
context.body = {
|
|
153
153
|
result: { data }
|
|
@@ -165,7 +165,7 @@ exports.powrupRouter.post('/internal/account/terminate-partner', validation_midd
|
|
|
165
165
|
try {
|
|
166
166
|
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
167
167
|
const { body } = context.request;
|
|
168
|
-
await getIntegration(context, tx);
|
|
168
|
+
await getIntegration(context, null, tx);
|
|
169
169
|
let data = await API.terminatePartner(body, context, tx);
|
|
170
170
|
context.body = {
|
|
171
171
|
result: { data }
|
|
@@ -183,7 +183,7 @@ exports.powrupRouter.post('/internal/account/invite-user', validation_middleware
|
|
|
183
183
|
try {
|
|
184
184
|
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
185
185
|
const { body } = context.request;
|
|
186
|
-
await getIntegration(context, tx);
|
|
186
|
+
await getIntegration(context, null, tx);
|
|
187
187
|
let data = await API.inviteUser(body, context, tx);
|
|
188
188
|
context.body = {
|
|
189
189
|
result: { data }
|
|
@@ -201,7 +201,7 @@ exports.powrupRouter.post('/internal/account/terminate-user', validation_middlew
|
|
|
201
201
|
try {
|
|
202
202
|
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
203
203
|
const { body } = context.request;
|
|
204
|
-
await getIntegration(context, tx);
|
|
204
|
+
await getIntegration(context, null, tx);
|
|
205
205
|
let data = await API.terminateUser(body, context, tx);
|
|
206
206
|
context.body = {
|
|
207
207
|
result: { data }
|
|
@@ -215,65 +215,24 @@ exports.powrupRouter.post('/internal/account/terminate-user', validation_middlew
|
|
|
215
215
|
(0, error_util_1.throwInternalServerError)(context, e);
|
|
216
216
|
}
|
|
217
217
|
});
|
|
218
|
-
exports.powrupRouter.
|
|
218
|
+
exports.powrupRouter.get('/warehouse/get', async (context, next) => {
|
|
219
219
|
try {
|
|
220
220
|
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
221
|
-
const {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
.getRepository(biz_base_1.Bizplace)
|
|
225
|
-
.findOne({ where: { id: bizplaceId }, relations: ['domain'] });
|
|
226
|
-
if (!bizplace) {
|
|
227
|
-
throw new error_util_1.ApiError('E04', `${bizplaceId} not found`);
|
|
221
|
+
const { apiKey, subdomain } = context.query;
|
|
222
|
+
if (!apiKey) {
|
|
223
|
+
throw new error_util_1.ApiError('E01', apiKey);
|
|
228
224
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
.
|
|
232
|
-
if (existingIntegration) {
|
|
233
|
-
throw new error_util_1.ApiError('E04', `${name} already exist`);
|
|
225
|
+
await getIntegration(context, apiKey, tx);
|
|
226
|
+
if (!subdomain) {
|
|
227
|
+
throw new error_util_1.ApiError('E01', subdomain);
|
|
234
228
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
platform: 'powrup',
|
|
239
|
-
active: true,
|
|
240
|
-
domain: bizplace.domain
|
|
241
|
-
};
|
|
242
|
-
let createdIntegration = await tx.getRepository(integration_base_1.Integration).create(integration);
|
|
243
|
-
let data = {
|
|
244
|
-
id: createdIntegration.id,
|
|
245
|
-
name: createdIntegration.name
|
|
246
|
-
};
|
|
247
|
-
context.body = {
|
|
248
|
-
result: { data }
|
|
249
|
-
};
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
catch (e) {
|
|
253
|
-
if (e instanceof error_util_1.ApiError)
|
|
254
|
-
(0, error_util_1.ApiErrorHandler)(context, e);
|
|
255
|
-
else
|
|
256
|
-
(0, error_util_1.throwInternalServerError)(context, e);
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
exports.powrupRouter.post('/integration/update', validation_middleware_1.validationMiddleware, async (context, next) => {
|
|
260
|
-
try {
|
|
261
|
-
await (0, typeorm_1.getConnection)().transaction(async (tx) => {
|
|
262
|
-
const { body } = context.request;
|
|
263
|
-
const { id, name, description, active } = body;
|
|
264
|
-
let existingIntegration = await tx.getRepository(integration_base_1.Integration).findOne(id);
|
|
265
|
-
if (!existingIntegration) {
|
|
266
|
-
throw new error_util_1.ApiError('E04', `${id} not found`);
|
|
229
|
+
const domain = await tx.getRepository(shell_1.Domain).findOne({ where: { subdomain } });
|
|
230
|
+
if (!domain) {
|
|
231
|
+
throw new error_util_1.ApiError('E04', `${subdomain} not found`);
|
|
267
232
|
}
|
|
268
|
-
await tx.getRepository(integration_base_1.Integration).update({ id: existingIntegration.id }, {
|
|
269
|
-
name: name || existingIntegration.name,
|
|
270
|
-
description: description || existingIntegration.description,
|
|
271
|
-
active: active || existingIntegration.active
|
|
272
|
-
});
|
|
273
|
-
let updatedIntegration = await tx.getRepository(integration_base_1.Integration).findOne(existingIntegration.id);
|
|
274
233
|
let data = {
|
|
275
|
-
id:
|
|
276
|
-
name:
|
|
234
|
+
id: domain.id,
|
|
235
|
+
name: domain.name
|
|
277
236
|
};
|
|
278
237
|
context.body = {
|
|
279
238
|
result: { data }
|
|
@@ -287,9 +246,9 @@ exports.powrupRouter.post('/integration/update', validation_middleware_1.validat
|
|
|
287
246
|
(0, error_util_1.throwInternalServerError)(context, e);
|
|
288
247
|
}
|
|
289
248
|
});
|
|
290
|
-
async function getIntegration(context, tx) {
|
|
249
|
+
async function getIntegration(context, apiKey, tx) {
|
|
291
250
|
const integration = await tx.getRepository(integration_base_1.Integration).findOne({
|
|
292
|
-
where: { name: context.request.body.apiKey }
|
|
251
|
+
where: { name: apiKey || context.request.body.apiKey }
|
|
293
252
|
});
|
|
294
253
|
if (integration) {
|
|
295
254
|
context.state.integration = integration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"powrup-router.js","sourceRoot":"","sources":["../../../server/routers/internal/powrup-router.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA+B;AAC/B,qCAAsD;AAEtD,
|
|
1
|
+
{"version":3,"file":"powrup-router.js","sourceRoot":"","sources":["../../../server/routers/internal/powrup-router.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA+B;AAC/B,qCAAsD;AAEtD,uEAA8D;AAC9D,iDAA8C;AAE9C,4CAA6B;AAC7B,+EAA0E;AAC1E,mDAAwF;AAExF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,qDAAqD,CAAC,CAAA;AAExE,QAAA,YAAY,GAAG,IAAI,oBAAM,EAAE,CAAA;AAExC,oBAAY,CAAC,IAAI,CAAC,+BAA+B,EAAE,4CAAoB,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,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AAI,qBAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;KACpC;AACH,CAAC"}
|
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.235",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"@things-factory/shell": "^4.3.227",
|
|
108
108
|
"@things-factory/system-ui": "^4.3.227",
|
|
109
109
|
"@things-factory/warehouse-base": "^4.3.234",
|
|
110
|
-
"@things-factory/worksheet-base": "^4.3.
|
|
110
|
+
"@things-factory/worksheet-base": "^4.3.235",
|
|
111
111
|
"cron-parser": "^4.7.0",
|
|
112
112
|
"koa2-swagger-ui": "^5.0.2",
|
|
113
113
|
"swagger-jsdoc": "^5.0.0",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"resolutions": {
|
|
120
120
|
"core-js": "^3.16.0"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "76d957b60aa3ade7db5bb563a723f59d81548c75"
|
|
123
123
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Router from 'koa-router'
|
|
2
2
|
import { EntityManager, getConnection } from 'typeorm'
|
|
3
3
|
|
|
4
|
-
import { Bizplace } from '@things-factory/biz-base'
|
|
5
4
|
import { Integration } from '@things-factory/integration-base'
|
|
5
|
+
import { Domain } from '@things-factory/shell'
|
|
6
6
|
|
|
7
7
|
import * as API from './apis'
|
|
8
8
|
import { validationMiddleware } from './middlewares/validation-middleware'
|
|
@@ -17,7 +17,7 @@ powrupRouter.post('/internal/account/create-user', validationMiddleware, async (
|
|
|
17
17
|
await getConnection().transaction(async (tx: EntityManager) => {
|
|
18
18
|
const { body } = context.request
|
|
19
19
|
|
|
20
|
-
await getIntegration(context, tx)
|
|
20
|
+
await getIntegration(context, null, tx)
|
|
21
21
|
|
|
22
22
|
let data = await API.createUser(body, context, tx)
|
|
23
23
|
|
|
@@ -36,7 +36,7 @@ powrupRouter.post('/internal/account/update-user', validationMiddleware, async (
|
|
|
36
36
|
await getConnection().transaction(async (tx: EntityManager) => {
|
|
37
37
|
const { body } = context.request
|
|
38
38
|
|
|
39
|
-
await getIntegration(context, tx)
|
|
39
|
+
await getIntegration(context, null, tx)
|
|
40
40
|
|
|
41
41
|
let data = await API.updateUser(body, context, tx)
|
|
42
42
|
|
|
@@ -55,7 +55,7 @@ powrupRouter.post('/internal/account/create-company', validationMiddleware, asyn
|
|
|
55
55
|
await getConnection().transaction(async (tx: EntityManager) => {
|
|
56
56
|
const { body } = context.request
|
|
57
57
|
|
|
58
|
-
await getIntegration(context, tx)
|
|
58
|
+
await getIntegration(context, null, tx)
|
|
59
59
|
|
|
60
60
|
let data = await API.createCompany(body, context, tx)
|
|
61
61
|
|
|
@@ -91,7 +91,7 @@ powrupRouter.post('/internal/account/create-bizplace', validationMiddleware, asy
|
|
|
91
91
|
await getConnection().transaction(async (tx: EntityManager) => {
|
|
92
92
|
const { body } = context.request
|
|
93
93
|
|
|
94
|
-
await getIntegration(context, tx)
|
|
94
|
+
await getIntegration(context, null, tx)
|
|
95
95
|
|
|
96
96
|
let data = await API.createBizplace(body, context, tx)
|
|
97
97
|
|
|
@@ -110,7 +110,7 @@ powrupRouter.post('/internal/account/update-bizplace', validationMiddleware, asy
|
|
|
110
110
|
await getConnection().transaction(async (tx: EntityManager) => {
|
|
111
111
|
const { body } = context.request
|
|
112
112
|
|
|
113
|
-
await getIntegration(context, tx)
|
|
113
|
+
await getIntegration(context, null, tx)
|
|
114
114
|
|
|
115
115
|
let data = await API.updateBizplace(body, context, tx)
|
|
116
116
|
|
|
@@ -128,7 +128,7 @@ powrupRouter.post('/internal/account/create-partner', validationMiddleware, asyn
|
|
|
128
128
|
try {
|
|
129
129
|
await getConnection().transaction(async (tx: EntityManager) => {
|
|
130
130
|
const { body } = context.request
|
|
131
|
-
await getIntegration(context, tx)
|
|
131
|
+
await getIntegration(context, null, tx)
|
|
132
132
|
|
|
133
133
|
let data = await API.createPartner(body, context, tx)
|
|
134
134
|
|
|
@@ -146,7 +146,7 @@ powrupRouter.post('/internal/account/terminate-partner', validationMiddleware, a
|
|
|
146
146
|
try {
|
|
147
147
|
await getConnection().transaction(async (tx: EntityManager) => {
|
|
148
148
|
const { body } = context.request
|
|
149
|
-
await getIntegration(context, tx)
|
|
149
|
+
await getIntegration(context, null, tx)
|
|
150
150
|
|
|
151
151
|
let data = await API.terminatePartner(body, context, tx)
|
|
152
152
|
|
|
@@ -164,7 +164,7 @@ powrupRouter.post('/internal/account/invite-user', validationMiddleware, async (
|
|
|
164
164
|
try {
|
|
165
165
|
await getConnection().transaction(async (tx: EntityManager) => {
|
|
166
166
|
const { body } = context.request
|
|
167
|
-
await getIntegration(context, tx)
|
|
167
|
+
await getIntegration(context, null, tx)
|
|
168
168
|
|
|
169
169
|
let data = await API.inviteUser(body, context, tx)
|
|
170
170
|
|
|
@@ -182,7 +182,7 @@ powrupRouter.post('/internal/account/terminate-user', validationMiddleware, asyn
|
|
|
182
182
|
try {
|
|
183
183
|
await getConnection().transaction(async (tx: EntityManager) => {
|
|
184
184
|
const { body } = context.request
|
|
185
|
-
await getIntegration(context, tx)
|
|
185
|
+
await getIntegration(context, null, tx)
|
|
186
186
|
|
|
187
187
|
let data = await API.terminateUser(body, context, tx)
|
|
188
188
|
|
|
@@ -196,81 +196,30 @@ powrupRouter.post('/internal/account/terminate-user', validationMiddleware, asyn
|
|
|
196
196
|
}
|
|
197
197
|
})
|
|
198
198
|
|
|
199
|
-
powrupRouter.
|
|
199
|
+
powrupRouter.get('/warehouse/get', async (context, next) => {
|
|
200
200
|
try {
|
|
201
201
|
await getConnection().transaction(async (tx: EntityManager) => {
|
|
202
|
-
const {
|
|
203
|
-
|
|
204
|
-
const { bizplaceId, name, description } = body
|
|
202
|
+
const { apiKey, subdomain } = context.query
|
|
205
203
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
.findOne({ where: { id: bizplaceId }, relations: ['domain'] })
|
|
209
|
-
|
|
210
|
-
if (!bizplace) {
|
|
211
|
-
throw new ApiError('E04', `${bizplaceId} not found`)
|
|
204
|
+
if (!apiKey) {
|
|
205
|
+
throw new ApiError('E01', apiKey)
|
|
212
206
|
}
|
|
213
207
|
|
|
214
|
-
|
|
215
|
-
.getRepository(Integration)
|
|
216
|
-
.findOne({ where: { name, domain: bizplace.domain } })
|
|
217
|
-
|
|
218
|
-
if (existingIntegration) {
|
|
219
|
-
throw new ApiError('E04', `${name} already exist`)
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
let integration: Integration = {
|
|
223
|
-
name,
|
|
224
|
-
description,
|
|
225
|
-
platform: 'powrup',
|
|
226
|
-
active: true,
|
|
227
|
-
domain: bizplace.domain
|
|
228
|
-
}
|
|
208
|
+
await getIntegration(context, apiKey, tx)
|
|
229
209
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
let data = {
|
|
233
|
-
id: createdIntegration.id,
|
|
234
|
-
name: createdIntegration.name
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
context.body = {
|
|
238
|
-
result: { data }
|
|
210
|
+
if (!subdomain) {
|
|
211
|
+
throw new ApiError('E01', subdomain)
|
|
239
212
|
}
|
|
240
|
-
})
|
|
241
|
-
} catch (e) {
|
|
242
|
-
if (e instanceof ApiError) ApiErrorHandler(context, e)
|
|
243
|
-
else throwInternalServerError(context, e)
|
|
244
|
-
}
|
|
245
|
-
})
|
|
246
213
|
|
|
247
|
-
|
|
248
|
-
try {
|
|
249
|
-
await getConnection().transaction(async (tx: EntityManager) => {
|
|
250
|
-
const { body } = context.request
|
|
251
|
-
|
|
252
|
-
const { id, name, description, active } = body
|
|
214
|
+
const domain: Domain = await tx.getRepository(Domain).findOne({ where: { subdomain } })
|
|
253
215
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (!existingIntegration) {
|
|
257
|
-
throw new ApiError('E04', `${id} not found`)
|
|
216
|
+
if (!domain) {
|
|
217
|
+
throw new ApiError('E04', `${subdomain} not found`)
|
|
258
218
|
}
|
|
259
219
|
|
|
260
|
-
await tx.getRepository(Integration).update(
|
|
261
|
-
{ id: existingIntegration.id },
|
|
262
|
-
{
|
|
263
|
-
name: name || existingIntegration.name,
|
|
264
|
-
description: description || existingIntegration.description,
|
|
265
|
-
active: active || existingIntegration.active
|
|
266
|
-
}
|
|
267
|
-
)
|
|
268
|
-
|
|
269
|
-
let updatedIntegration: Integration = await tx.getRepository(Integration).findOne(existingIntegration.id)
|
|
270
|
-
|
|
271
220
|
let data = {
|
|
272
|
-
id:
|
|
273
|
-
name:
|
|
221
|
+
id: domain.id,
|
|
222
|
+
name: domain.name
|
|
274
223
|
}
|
|
275
224
|
|
|
276
225
|
context.body = {
|
|
@@ -283,9 +232,9 @@ powrupRouter.post('/integration/update', validationMiddleware, async (context, n
|
|
|
283
232
|
}
|
|
284
233
|
})
|
|
285
234
|
|
|
286
|
-
async function getIntegration(context, tx) {
|
|
235
|
+
async function getIntegration(context, apiKey, tx) {
|
|
287
236
|
const integration: Integration = await tx.getRepository(Integration).findOne({
|
|
288
|
-
where: { name: context.request.body.apiKey }
|
|
237
|
+
where: { name: apiKey || context.request.body.apiKey }
|
|
289
238
|
})
|
|
290
239
|
|
|
291
240
|
if (integration) {
|