@things-factory/operato-hub 4.3.232 → 4.3.233
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/config.development.js +1 -1
- package/dist-server/routers/internal/apis/create-bizplace.js +32 -3
- package/dist-server/routers/internal/apis/create-bizplace.js.map +1 -1
- package/dist-server/routers/internal/apis/create-company.js +5 -2
- package/dist-server/routers/internal/apis/create-company.js.map +1 -1
- package/dist-server/routers/internal/apis/create-partner.js +9 -9
- package/dist-server/routers/internal/apis/create-partner.js.map +1 -1
- package/dist-server/routers/internal/apis/create-user.js +2 -2
- package/dist-server/routers/internal/apis/create-user.js.map +1 -1
- package/dist-server/routers/internal/apis/invite-user.js +7 -7
- package/dist-server/routers/internal/apis/invite-user.js.map +1 -1
- package/dist-server/routers/internal/apis/terminate-partner.js +7 -7
- package/dist-server/routers/internal/apis/terminate-partner.js.map +1 -1
- package/dist-server/routers/internal/apis/terminate-user.js +7 -7
- package/dist-server/routers/internal/apis/terminate-user.js.map +1 -1
- package/dist-server/routers/internal/apis/update-bizplace.js +2 -2
- package/dist-server/routers/internal/apis/update-bizplace.js.map +1 -1
- package/dist-server/routers/internal/apis/update-company.js +19 -22
- package/dist-server/routers/internal/apis/update-company.js.map +1 -1
- package/dist-server/routers/internal/apis/update-user.js +1 -1
- package/dist-server/routers/internal/apis/update-user.js.map +1 -1
- package/dist-server/routers/internal/utils/params.js +45 -30
- package/dist-server/routers/internal/utils/params.js.map +1 -1
- package/package.json +2 -2
- package/server/routers/internal/apis/create-bizplace.ts +49 -5
- package/server/routers/internal/apis/create-company.ts +6 -2
- package/server/routers/internal/apis/create-partner.ts +9 -9
- package/server/routers/internal/apis/create-user.ts +2 -2
- package/server/routers/internal/apis/invite-user.ts +7 -7
- package/server/routers/internal/apis/terminate-partner.ts +7 -7
- package/server/routers/internal/apis/terminate-user.ts +7 -7
- package/server/routers/internal/apis/update-bizplace.ts +2 -2
- package/server/routers/internal/apis/update-company.ts +20 -22
- package/server/routers/internal/apis/update-user.ts +1 -1
- package/server/routers/internal/utils/params.ts +45 -30
|
@@ -3,9 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.reqParams = exports.params = void 0;
|
|
4
4
|
exports.params = {
|
|
5
5
|
'create-user': ['refUserId', 'name', 'description', 'email', 'password', 'salt', 'status'],
|
|
6
|
-
'update-user': ['
|
|
7
|
-
'create-company': [
|
|
8
|
-
|
|
6
|
+
'update-user': ['email', 'name', 'description', 'password', 'salt', 'status'],
|
|
7
|
+
'create-company': [
|
|
8
|
+
'refCompanyId',
|
|
9
|
+
'userEmail',
|
|
10
|
+
'name',
|
|
11
|
+
'description',
|
|
12
|
+
'brn',
|
|
13
|
+
'address',
|
|
14
|
+
'postalCode',
|
|
15
|
+
'type',
|
|
16
|
+
'status'
|
|
17
|
+
],
|
|
18
|
+
'update-company': [
|
|
19
|
+
'userEmail',
|
|
20
|
+
'refCompanyId',
|
|
21
|
+
'name',
|
|
22
|
+
'description',
|
|
23
|
+
'brn',
|
|
24
|
+
'address',
|
|
25
|
+
'postalCode',
|
|
26
|
+
'type',
|
|
27
|
+
'status'
|
|
28
|
+
],
|
|
9
29
|
'create-bizplace': [
|
|
10
30
|
'refBizplaceId',
|
|
11
31
|
'name',
|
|
@@ -14,22 +34,17 @@ exports.params = {
|
|
|
14
34
|
'postalCode',
|
|
15
35
|
'latlng',
|
|
16
36
|
'extType',
|
|
17
|
-
'
|
|
18
|
-
'
|
|
37
|
+
'refCompanyId',
|
|
38
|
+
'userEmail'
|
|
19
39
|
],
|
|
20
|
-
'update-bizplace': ['
|
|
21
|
-
'create-partner': ['
|
|
22
|
-
'terminate-partner': ['
|
|
23
|
-
'invite-user': ['
|
|
24
|
-
'terminate-user': ['
|
|
40
|
+
'update-bizplace': ['refBizplaceId', 'name', 'description', 'address', 'postalCode', 'latlng', 'extType'],
|
|
41
|
+
'create-partner': ['refBizplaceId', 'partnerRefBizplaceId', 'userEmail'],
|
|
42
|
+
'terminate-partner': ['refBizplaceId', 'partnerRefBizplaceId'],
|
|
43
|
+
'invite-user': ['userEmail', 'refBizplaceId'],
|
|
44
|
+
'terminate-user': ['userEmail', 'refBizplaceId']
|
|
25
45
|
};
|
|
26
46
|
exports.reqParams = {
|
|
27
47
|
'create-user': [
|
|
28
|
-
{
|
|
29
|
-
name: 'refUserId',
|
|
30
|
-
required: true,
|
|
31
|
-
type: 'field'
|
|
32
|
-
},
|
|
33
48
|
{
|
|
34
49
|
name: 'name',
|
|
35
50
|
required: true,
|
|
@@ -48,7 +63,7 @@ exports.reqParams = {
|
|
|
48
63
|
],
|
|
49
64
|
'update-user': [
|
|
50
65
|
{
|
|
51
|
-
name: '
|
|
66
|
+
name: 'email',
|
|
52
67
|
required: true,
|
|
53
68
|
type: 'field'
|
|
54
69
|
}
|
|
@@ -65,19 +80,19 @@ exports.reqParams = {
|
|
|
65
80
|
type: 'field'
|
|
66
81
|
},
|
|
67
82
|
{
|
|
68
|
-
name: '
|
|
83
|
+
name: 'userEmail',
|
|
69
84
|
required: true,
|
|
70
85
|
type: 'field'
|
|
71
86
|
}
|
|
72
87
|
],
|
|
73
88
|
'update-company': [
|
|
74
89
|
{
|
|
75
|
-
name: '
|
|
90
|
+
name: 'userEmail',
|
|
76
91
|
required: true,
|
|
77
92
|
type: 'field'
|
|
78
93
|
},
|
|
79
94
|
{
|
|
80
|
-
name: '
|
|
95
|
+
name: 'refCompanyId',
|
|
81
96
|
required: true,
|
|
82
97
|
type: 'field'
|
|
83
98
|
}
|
|
@@ -89,12 +104,12 @@ exports.reqParams = {
|
|
|
89
104
|
type: 'field'
|
|
90
105
|
},
|
|
91
106
|
{
|
|
92
|
-
name: '
|
|
107
|
+
name: 'userEmail',
|
|
93
108
|
required: true,
|
|
94
109
|
type: 'field'
|
|
95
110
|
},
|
|
96
111
|
{
|
|
97
|
-
name: '
|
|
112
|
+
name: 'refCompanyId',
|
|
98
113
|
required: true,
|
|
99
114
|
type: 'field'
|
|
100
115
|
},
|
|
@@ -106,55 +121,55 @@ exports.reqParams = {
|
|
|
106
121
|
],
|
|
107
122
|
'update-bizplace': [
|
|
108
123
|
{
|
|
109
|
-
name: '
|
|
124
|
+
name: 'refBizplaceId',
|
|
110
125
|
required: true,
|
|
111
126
|
type: 'field'
|
|
112
127
|
}
|
|
113
128
|
],
|
|
114
129
|
'create-partner': [
|
|
115
130
|
{
|
|
116
|
-
name: '
|
|
131
|
+
name: 'refBizplaceId',
|
|
117
132
|
required: true,
|
|
118
133
|
type: 'field'
|
|
119
134
|
},
|
|
120
135
|
{
|
|
121
|
-
name: '
|
|
136
|
+
name: 'partnerRefBizplaceId',
|
|
122
137
|
required: true,
|
|
123
138
|
type: 'field'
|
|
124
139
|
}
|
|
125
140
|
],
|
|
126
141
|
'terminate-partner': [
|
|
127
142
|
{
|
|
128
|
-
name: '
|
|
143
|
+
name: 'refBizplaceId',
|
|
129
144
|
required: true,
|
|
130
145
|
type: 'field'
|
|
131
146
|
},
|
|
132
147
|
{
|
|
133
|
-
name: '
|
|
148
|
+
name: 'partnerRefBizplaceId',
|
|
134
149
|
required: true,
|
|
135
150
|
type: 'field'
|
|
136
151
|
}
|
|
137
152
|
],
|
|
138
153
|
'invite-user': [
|
|
139
154
|
{
|
|
140
|
-
name: '
|
|
155
|
+
name: 'userEmail',
|
|
141
156
|
required: true,
|
|
142
157
|
type: 'field'
|
|
143
158
|
},
|
|
144
159
|
{
|
|
145
|
-
name: '
|
|
160
|
+
name: 'refBizplaceId',
|
|
146
161
|
required: true,
|
|
147
162
|
type: 'field'
|
|
148
163
|
}
|
|
149
164
|
],
|
|
150
165
|
'terminate-user': [
|
|
151
166
|
{
|
|
152
|
-
name: '
|
|
167
|
+
name: 'userEmail',
|
|
153
168
|
required: true,
|
|
154
169
|
type: 'field'
|
|
155
170
|
},
|
|
156
171
|
{
|
|
157
|
-
name: '
|
|
172
|
+
name: 'refBizplaceId',
|
|
158
173
|
required: true,
|
|
159
174
|
type: 'field'
|
|
160
175
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.js","sourceRoot":"","sources":["../../../../server/routers/internal/utils/params.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG;IACpB,aAAa,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC;IAC1F,aAAa,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"params.js","sourceRoot":"","sources":["../../../../server/routers/internal/utils/params.ts"],"names":[],"mappings":"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"}
|
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.233",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"resolutions": {
|
|
120
120
|
"core-js": "^3.16.0"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "544826ef621347e85325f8ebc6018598ac64259d"
|
|
123
123
|
}
|
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Repository } from 'typeorm'
|
|
2
|
+
|
|
3
|
+
import { Privilege, Role, User } from '@things-factory/auth-base'
|
|
2
4
|
import { Bizplace, Company } from '@things-factory/biz-base'
|
|
5
|
+
import { Domain } from '@things-factory/shell'
|
|
3
6
|
|
|
4
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
generateBizplaceDomain,
|
|
9
|
+
initCodes,
|
|
10
|
+
initGroups,
|
|
11
|
+
initMenus,
|
|
12
|
+
initSettings
|
|
13
|
+
} from '../../../controllers/bizplace-initializer'
|
|
14
|
+
import { generateBizplaceDomainRoles } from '../../../controllers/bizplace-initializer/generate-bizplace-domain-roles'
|
|
5
15
|
import { ApiError } from '../utils/error-util'
|
|
6
16
|
|
|
7
17
|
export async function createBizplace(request, context, tx) {
|
|
8
18
|
const { data: bizplace } = request
|
|
9
|
-
const company: Company = await tx.getRepository(Company).findOne({ where: {
|
|
19
|
+
const company: Company = await tx.getRepository(Company).findOne({ where: { refCompanyId: bizplace.refCompanyId } })
|
|
20
|
+
|
|
21
|
+
if (!company) {
|
|
22
|
+
throw new ApiError('E04', `${bizplace.refCompanyId} not found`)
|
|
23
|
+
}
|
|
10
24
|
|
|
11
25
|
const oldBizplace = await tx.getRepository(Bizplace).findOne({
|
|
12
26
|
where: {
|
|
@@ -17,7 +31,7 @@ export async function createBizplace(request, context, tx) {
|
|
|
17
31
|
throw new ApiError('E04', `${bizplace.name} is duplicated`)
|
|
18
32
|
}
|
|
19
33
|
|
|
20
|
-
let foundUser: User = await tx.getRepository(User).findOne({ where: {
|
|
34
|
+
let foundUser: User = await tx.getRepository(User).findOne({ where: { email: bizplace.userEmail } })
|
|
21
35
|
|
|
22
36
|
let createdBizplace: Bizplace = await tx.getRepository(Bizplace).save({
|
|
23
37
|
name: bizplace.name,
|
|
@@ -32,7 +46,37 @@ export async function createBizplace(request, context, tx) {
|
|
|
32
46
|
creator: foundUser
|
|
33
47
|
})
|
|
34
48
|
|
|
35
|
-
await generateBizplaceDomain(createdBizplace.id, foundUser, tx)
|
|
49
|
+
let domain: Domain = await generateBizplaceDomain(createdBizplace.id, foundUser, tx)
|
|
50
|
+
if (bizplace?.extType && bizplace?.extType == 'warehouse') {
|
|
51
|
+
domain.extType = bizplace.extType
|
|
52
|
+
await generateBizplaceDomainRoles(domain, tx)
|
|
53
|
+
await initMenus(tx, domain)
|
|
54
|
+
await initCodes(tx, domain)
|
|
55
|
+
await initSettings(tx, domain)
|
|
56
|
+
await initGroups(tx, domain)
|
|
57
|
+
|
|
58
|
+
const userRepo: Repository<User> = tx.getRepository(User)
|
|
59
|
+
const user: User = await userRepo.findOne({ where: { email: bizplace.userEmail }, relations: ['domains', 'roles'] })
|
|
60
|
+
const roleRepo: Repository<Role> = tx.getRepository(Role)
|
|
61
|
+
const role: Role = await roleRepo.findOne({ where: { domain } })
|
|
62
|
+
const privilegeRepo: Repository<Privilege> = tx.getRepository(Privilege)
|
|
63
|
+
const privileges: Privilege = await privilegeRepo.find()
|
|
64
|
+
|
|
65
|
+
const domains: Domain[] = user.domains
|
|
66
|
+
domains.push(domain)
|
|
67
|
+
user.domains = domains
|
|
68
|
+
|
|
69
|
+
const roles: Role[] = await user.roles
|
|
70
|
+
roles.push(role)
|
|
71
|
+
user.roles = roles
|
|
72
|
+
|
|
73
|
+
role.privileges = privileges
|
|
74
|
+
|
|
75
|
+
await userRepo.save(user)
|
|
76
|
+
await roleRepo.save(role)
|
|
77
|
+
|
|
78
|
+
await tx.getRepository(Domain).update({ id: domain.id }, { extType: bizplace.extType })
|
|
79
|
+
}
|
|
36
80
|
|
|
37
81
|
let data = {
|
|
38
82
|
id: createdBizplace.id,
|
|
@@ -7,9 +7,12 @@ import { generateBusinessRoles } from '../../../controllers/company-initializer'
|
|
|
7
7
|
import { ApiError } from '../utils/error-util'
|
|
8
8
|
|
|
9
9
|
export async function createCompany(request, context, tx) {
|
|
10
|
-
const { name, description, brn, address, postalCode, countryCode, type, status,
|
|
10
|
+
const { name, description, brn, address, postalCode, countryCode, type, status, userEmail, refCompanyId } =
|
|
11
|
+
request.data
|
|
11
12
|
|
|
12
|
-
let foundUser: User = await tx
|
|
13
|
+
let foundUser: User = await tx
|
|
14
|
+
.getRepository(User)
|
|
15
|
+
.findOne({ where: { email: userEmail }, relations: ['domains', 'roles'] })
|
|
13
16
|
|
|
14
17
|
const subdomain = slugger(name)
|
|
15
18
|
|
|
@@ -71,6 +74,7 @@ export async function createCompany(request, context, tx) {
|
|
|
71
74
|
address: company.address,
|
|
72
75
|
postalCode: company.postalCode || '',
|
|
73
76
|
latlng: '',
|
|
77
|
+
refBizplaceId: refCompanyId || null,
|
|
74
78
|
domain,
|
|
75
79
|
company
|
|
76
80
|
})
|
|
@@ -4,22 +4,22 @@ import { Bizplace } from '@things-factory/biz-base'
|
|
|
4
4
|
import { ApiError } from '../utils/error-util'
|
|
5
5
|
|
|
6
6
|
export async function createPartner(request, context, tx) {
|
|
7
|
-
const {
|
|
7
|
+
const { refBizplaceId, partnerRefBizplaceId, userEmail } = request.data
|
|
8
8
|
|
|
9
9
|
const bizplace: Bizplace = await tx
|
|
10
10
|
.getRepository(Bizplace)
|
|
11
|
-
.findOne({ where: {
|
|
11
|
+
.findOne({ where: { refBizplaceId }, relations: ['domain'] })
|
|
12
12
|
|
|
13
13
|
if (!bizplace) {
|
|
14
|
-
throw new ApiError('E04', `${
|
|
14
|
+
throw new ApiError('E04', `${refBizplaceId} does not exist`)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const partnerBizplace: Bizplace = await tx
|
|
18
18
|
.getRepository(Bizplace)
|
|
19
|
-
.findOne({ where: {
|
|
19
|
+
.findOne({ where: { refBizplaceId: partnerRefBizplaceId }, relations: ['domain'] })
|
|
20
20
|
|
|
21
21
|
if (!partnerBizplace) {
|
|
22
|
-
throw new ApiError('E04', `${
|
|
22
|
+
throw new ApiError('E04', `${partnerRefBizplaceId} does not exist`)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const isExistingCustomer: boolean = Boolean(
|
|
@@ -29,10 +29,10 @@ export async function createPartner(request, context, tx) {
|
|
|
29
29
|
)
|
|
30
30
|
|
|
31
31
|
if (isExistingCustomer) {
|
|
32
|
-
throw new ApiError('E04', `${
|
|
32
|
+
throw new ApiError('E04', `${partnerRefBizplaceId} already registered as partner`)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
let user: User = await tx.getRepository(User).findOne({ where: {
|
|
35
|
+
let user: User = await tx.getRepository(User).findOne({ where: { email: userEmail } })
|
|
36
36
|
|
|
37
37
|
await tx.getRepository(Partner).save({
|
|
38
38
|
domain: bizplace.domain,
|
|
@@ -42,8 +42,8 @@ export async function createPartner(request, context, tx) {
|
|
|
42
42
|
})
|
|
43
43
|
|
|
44
44
|
let data = {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
refBizplaceId,
|
|
46
|
+
partnerRefBizplaceId
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
return data
|
|
@@ -7,7 +7,7 @@ export async function createUser(request, context, tx) {
|
|
|
7
7
|
const { email } = user
|
|
8
8
|
user.email = email.trim()
|
|
9
9
|
|
|
10
|
-
const oldUser: User = await tx.getRepository(User).findOne({ where: {
|
|
10
|
+
const oldUser: User = await tx.getRepository(User).findOne({ where: { email: user.email } })
|
|
11
11
|
if (oldUser) {
|
|
12
12
|
throw new ApiError('E04', context.t('error.x already exists in y', { x: context.t('field.user'), y: 'operato' }))
|
|
13
13
|
}
|
|
@@ -21,7 +21,7 @@ export async function createUser(request, context, tx) {
|
|
|
21
21
|
status: user?.status || 'inactive',
|
|
22
22
|
salt: user?.salt || salt,
|
|
23
23
|
passwordUpdatedAt: new Date(),
|
|
24
|
-
password: user?.password
|
|
24
|
+
password: user?.password && user?.salt ? user.password : User.encode(user.password, salt)
|
|
25
25
|
})
|
|
26
26
|
|
|
27
27
|
let data = {
|
|
@@ -5,20 +5,20 @@ import { Domain } from '@things-factory/shell'
|
|
|
5
5
|
import { ApiError } from '../utils/error-util'
|
|
6
6
|
|
|
7
7
|
export async function inviteUser(request, context, tx) {
|
|
8
|
-
const {
|
|
8
|
+
const { userEmail, refBizplaceId } = request.data
|
|
9
9
|
|
|
10
|
-
const user: User = await tx.getRepository(User).findOne({ where: {
|
|
10
|
+
const user: User = await tx.getRepository(User).findOne({ where: { email: userEmail }, relations: ['domains'] })
|
|
11
11
|
|
|
12
12
|
if (!user) {
|
|
13
|
-
throw new ApiError('E04', `${
|
|
13
|
+
throw new ApiError('E04', `${userEmail} does not exist`)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const bizplace: Bizplace = await tx
|
|
17
17
|
.getRepository(Bizplace)
|
|
18
|
-
.findOne({ where: {
|
|
18
|
+
.findOne({ where: { refBizplaceId }, relations: ['domain'] })
|
|
19
19
|
|
|
20
20
|
if (!bizplace) {
|
|
21
|
-
throw new ApiError('E04', `${
|
|
21
|
+
throw new ApiError('E04', `${refBizplaceId} does not exist`)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const existingDomains: Domain[] = user.domains
|
|
@@ -30,8 +30,8 @@ export async function inviteUser(request, context, tx) {
|
|
|
30
30
|
await tx.getRepository(User).save(user)
|
|
31
31
|
|
|
32
32
|
let data = {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
refBizplaceId,
|
|
34
|
+
userEmail
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
return data
|
|
@@ -4,22 +4,22 @@ import { Bizplace } from '@things-factory/biz-base'
|
|
|
4
4
|
import { ApiError } from '../utils/error-util'
|
|
5
5
|
|
|
6
6
|
export async function terminatePartner(request, context, tx) {
|
|
7
|
-
const {
|
|
7
|
+
const { refBizplaceId, partnerRefBizplaceId } = request.data
|
|
8
8
|
|
|
9
9
|
const bizplace: Bizplace = await tx
|
|
10
10
|
.getRepository(Bizplace)
|
|
11
|
-
.findOne({ where: {
|
|
11
|
+
.findOne({ where: { refBizplaceId }, relations: ['domain'] })
|
|
12
12
|
|
|
13
13
|
if (!bizplace) {
|
|
14
|
-
throw new ApiError('E04', `${
|
|
14
|
+
throw new ApiError('E04', `${refBizplaceId} does not exist`)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const partnerBizplace: Bizplace = await tx
|
|
18
18
|
.getRepository(Bizplace)
|
|
19
|
-
.findOne({ where: {
|
|
19
|
+
.findOne({ where: { refBizplaceId: partnerRefBizplaceId }, relations: ['domain'] })
|
|
20
20
|
|
|
21
21
|
if (!partnerBizplace) {
|
|
22
|
-
throw new ApiError('E04', `${
|
|
22
|
+
throw new ApiError('E04', `${partnerRefBizplaceId} does not exist`)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const partner: Partner = await tx.getRepository(Partner).findOne({
|
|
@@ -37,8 +37,8 @@ export async function terminatePartner(request, context, tx) {
|
|
|
37
37
|
await terminateGrantedRoles(bizplace.domain, partnerBizplace.domain, tx)
|
|
38
38
|
|
|
39
39
|
let data = {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
refBizplaceId,
|
|
41
|
+
partnerRefBizplaceId
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
return data
|
|
@@ -5,22 +5,22 @@ import { Domain } from '@things-factory/shell'
|
|
|
5
5
|
import { ApiError } from '../utils/error-util'
|
|
6
6
|
|
|
7
7
|
export async function terminateUser(request, context, tx) {
|
|
8
|
-
const {
|
|
8
|
+
const { userEmail, refBizplaceId } = request.data
|
|
9
9
|
|
|
10
10
|
const user: User = await tx
|
|
11
11
|
.getRepository(User)
|
|
12
|
-
.findOne({ where: {
|
|
12
|
+
.findOne({ where: { email: userEmail }, relations: ['domains', 'roles', 'roles.domain'] })
|
|
13
13
|
|
|
14
14
|
if (!user) {
|
|
15
|
-
throw new ApiError('E04', `${
|
|
15
|
+
throw new ApiError('E04', `${userEmail} does not exist`)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
const bizplace: Bizplace = await tx
|
|
19
19
|
.getRepository(Bizplace)
|
|
20
|
-
.findOne({ where: {
|
|
20
|
+
.findOne({ where: { refBizplaceId }, relations: ['domain'] })
|
|
21
21
|
|
|
22
22
|
if (!bizplace) {
|
|
23
|
-
throw new ApiError('E04', `${
|
|
23
|
+
throw new ApiError('E04', `${refBizplaceId} does not exist`)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const targetDomainIdx: number = user.domains.findIndex((userDomain: Domain) => userDomain.id === bizplace.domain.id)
|
|
@@ -37,8 +37,8 @@ export async function terminateUser(request, context, tx) {
|
|
|
37
37
|
await tx.getRepository(User).save(user)
|
|
38
38
|
|
|
39
39
|
let data = {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
refBizplaceId,
|
|
41
|
+
userEmail
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
return data
|
|
@@ -9,12 +9,12 @@ export async function updateBizplace(request, context, tx) {
|
|
|
9
9
|
|
|
10
10
|
const existingBizplace: Bizplace = await tx.getRepository(Bizplace).findOne({
|
|
11
11
|
where: {
|
|
12
|
-
|
|
12
|
+
refBizplaceId: bizplace.refBizplaceId
|
|
13
13
|
},
|
|
14
14
|
relations: ['company', 'domain']
|
|
15
15
|
})
|
|
16
16
|
if (!existingBizplace) {
|
|
17
|
-
throw new ApiError('E04', `${bizplace.
|
|
17
|
+
throw new ApiError('E04', `${bizplace.refBizplaceId} does not exist`)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const company: Company = existingBizplace.company
|
|
@@ -6,39 +6,37 @@ import { slugger } from '@things-factory/utils'
|
|
|
6
6
|
import { ApiError } from '../utils/error-util'
|
|
7
7
|
|
|
8
8
|
export async function updateCompany(request, context, tx) {
|
|
9
|
-
const {
|
|
9
|
+
const { refCompanyId, name, description, brn, address, postalCode, countryCode, type, status, userEmail } =
|
|
10
|
+
request.data
|
|
10
11
|
|
|
11
|
-
let foundUser: User = await tx
|
|
12
|
+
let foundUser: User = await tx
|
|
13
|
+
.getRepository(User)
|
|
14
|
+
.findOne({ where: { email: userEmail }, relations: ['domains', 'roles'] })
|
|
12
15
|
|
|
13
16
|
const subdomain = slugger(name)
|
|
14
17
|
|
|
15
18
|
//check for existing company
|
|
16
19
|
const existingCompany: Company = await tx.getRepository(Company).findOne({
|
|
17
|
-
where: {
|
|
20
|
+
where: { refCompanyId }
|
|
18
21
|
})
|
|
19
22
|
|
|
20
23
|
if (!existingCompany) {
|
|
21
24
|
throw new ApiError('E04', `${name} does not exist`)
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
relations: ['bizplace']
|
|
29
|
-
})
|
|
27
|
+
const existingBizplaces: Bizplace[] = await tx
|
|
28
|
+
.getRepository(Bizplace)
|
|
29
|
+
.find({ where: { company: existingCompany }, relations: ['domain'] })
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
31
|
+
let companyBizplace: Bizplace = existingBizplaces.find(biz => biz.domain.extType == 'company')
|
|
32
|
+
let companyDomain: Domain = companyBizplace.domain
|
|
34
33
|
|
|
35
34
|
// update company
|
|
36
35
|
await tx.getRepository(Domain).update(
|
|
37
|
-
{ id:
|
|
36
|
+
{ id: companyDomain.id },
|
|
38
37
|
{
|
|
39
|
-
subdomain: name ? subdomain :
|
|
40
|
-
name: name ? name :
|
|
41
|
-
updater: foundUser
|
|
38
|
+
subdomain: name ? subdomain : companyDomain.subdomain,
|
|
39
|
+
name: name ? name : companyDomain.name
|
|
42
40
|
}
|
|
43
41
|
)
|
|
44
42
|
|
|
@@ -55,19 +53,19 @@ export async function updateCompany(request, context, tx) {
|
|
|
55
53
|
}
|
|
56
54
|
)
|
|
57
55
|
await tx.getRepository(Bizplace).update(
|
|
58
|
-
{ id:
|
|
56
|
+
{ id: companyBizplace.id },
|
|
59
57
|
{
|
|
60
|
-
name: name ||
|
|
61
|
-
description: description ||
|
|
62
|
-
address: address ||
|
|
63
|
-
postalCode: postalCode ||
|
|
58
|
+
name: name || companyBizplace.name,
|
|
59
|
+
description: description || companyBizplace.description,
|
|
60
|
+
address: address || companyBizplace.address,
|
|
61
|
+
postalCode: postalCode || companyBizplace.postalCode || '',
|
|
64
62
|
latlng: '',
|
|
65
63
|
updater: foundUser
|
|
66
64
|
}
|
|
67
65
|
)
|
|
68
66
|
|
|
69
67
|
const updatedCompany: Company = await tx.getRepository(Company).findOne({
|
|
70
|
-
where: { id }
|
|
68
|
+
where: { id: existingCompany.id }
|
|
71
69
|
})
|
|
72
70
|
|
|
73
71
|
let data = {
|
|
@@ -5,7 +5,7 @@ import { ApiError } from '../utils/error-util'
|
|
|
5
5
|
export async function updateUser(request, context, tx) {
|
|
6
6
|
let user: NewUser = request?.data || {}
|
|
7
7
|
|
|
8
|
-
const existingUser: User = await tx.getRepository(User).findOne({ where: {
|
|
8
|
+
const existingUser: User = await tx.getRepository(User).findOne({ where: { email: user.email } })
|
|
9
9
|
if (!existingUser) {
|
|
10
10
|
throw new ApiError('E04', context.t('error.x does not exists in y', { x: context.t('field.user'), y: 'operato' }))
|
|
11
11
|
}
|