@things-factory/operato-hub 4.3.232 → 4.3.234
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 +105 -76
- 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 +6 -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 +29 -29
- package/server/routers/internal/apis/create-bizplace.ts +49 -5
- package/server/routers/internal/apis/create-company.ts +7 -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
|
@@ -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
|
}
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
export const params = {
|
|
2
2
|
'create-user': ['refUserId', 'name', 'description', 'email', 'password', 'salt', 'status'],
|
|
3
|
-
'update-user': ['
|
|
4
|
-
'create-company': [
|
|
5
|
-
|
|
3
|
+
'update-user': ['email', 'name', 'description', 'password', 'salt', 'status'],
|
|
4
|
+
'create-company': [
|
|
5
|
+
'refCompanyId',
|
|
6
|
+
'userEmail',
|
|
7
|
+
'name',
|
|
8
|
+
'description',
|
|
9
|
+
'brn',
|
|
10
|
+
'address',
|
|
11
|
+
'postalCode',
|
|
12
|
+
'type',
|
|
13
|
+
'status'
|
|
14
|
+
],
|
|
15
|
+
'update-company': [
|
|
16
|
+
'userEmail',
|
|
17
|
+
'refCompanyId',
|
|
18
|
+
'name',
|
|
19
|
+
'description',
|
|
20
|
+
'brn',
|
|
21
|
+
'address',
|
|
22
|
+
'postalCode',
|
|
23
|
+
'type',
|
|
24
|
+
'status'
|
|
25
|
+
],
|
|
6
26
|
'create-bizplace': [
|
|
7
27
|
'refBizplaceId',
|
|
8
28
|
'name',
|
|
@@ -11,23 +31,18 @@ export const params = {
|
|
|
11
31
|
'postalCode',
|
|
12
32
|
'latlng',
|
|
13
33
|
'extType',
|
|
14
|
-
'
|
|
15
|
-
'
|
|
34
|
+
'refCompanyId',
|
|
35
|
+
'userEmail'
|
|
16
36
|
],
|
|
17
|
-
'update-bizplace': ['
|
|
18
|
-
'create-partner': ['
|
|
19
|
-
'terminate-partner': ['
|
|
20
|
-
'invite-user': ['
|
|
21
|
-
'terminate-user': ['
|
|
37
|
+
'update-bizplace': ['refBizplaceId', 'name', 'description', 'address', 'postalCode', 'latlng', 'extType'],
|
|
38
|
+
'create-partner': ['refBizplaceId', 'partnerRefBizplaceId', 'userEmail'],
|
|
39
|
+
'terminate-partner': ['refBizplaceId', 'partnerRefBizplaceId'],
|
|
40
|
+
'invite-user': ['userEmail', 'refBizplaceId'],
|
|
41
|
+
'terminate-user': ['userEmail', 'refBizplaceId']
|
|
22
42
|
}
|
|
23
43
|
|
|
24
44
|
export const reqParams = {
|
|
25
45
|
'create-user': [
|
|
26
|
-
{
|
|
27
|
-
name: 'refUserId',
|
|
28
|
-
required: true,
|
|
29
|
-
type: 'field'
|
|
30
|
-
},
|
|
31
46
|
{
|
|
32
47
|
name: 'name',
|
|
33
48
|
required: true,
|
|
@@ -46,7 +61,7 @@ export const reqParams = {
|
|
|
46
61
|
],
|
|
47
62
|
'update-user': [
|
|
48
63
|
{
|
|
49
|
-
name: '
|
|
64
|
+
name: 'email',
|
|
50
65
|
required: true,
|
|
51
66
|
type: 'field'
|
|
52
67
|
}
|
|
@@ -63,19 +78,19 @@ export const reqParams = {
|
|
|
63
78
|
type: 'field'
|
|
64
79
|
},
|
|
65
80
|
{
|
|
66
|
-
name: '
|
|
81
|
+
name: 'userEmail',
|
|
67
82
|
required: true,
|
|
68
83
|
type: 'field'
|
|
69
84
|
}
|
|
70
85
|
],
|
|
71
86
|
'update-company': [
|
|
72
87
|
{
|
|
73
|
-
name: '
|
|
88
|
+
name: 'userEmail',
|
|
74
89
|
required: true,
|
|
75
90
|
type: 'field'
|
|
76
91
|
},
|
|
77
92
|
{
|
|
78
|
-
name: '
|
|
93
|
+
name: 'refCompanyId',
|
|
79
94
|
required: true,
|
|
80
95
|
type: 'field'
|
|
81
96
|
}
|
|
@@ -87,12 +102,12 @@ export const reqParams = {
|
|
|
87
102
|
type: 'field'
|
|
88
103
|
},
|
|
89
104
|
{
|
|
90
|
-
name: '
|
|
105
|
+
name: 'userEmail',
|
|
91
106
|
required: true,
|
|
92
107
|
type: 'field'
|
|
93
108
|
},
|
|
94
109
|
{
|
|
95
|
-
name: '
|
|
110
|
+
name: 'refCompanyId',
|
|
96
111
|
required: true,
|
|
97
112
|
type: 'field'
|
|
98
113
|
},
|
|
@@ -104,55 +119,55 @@ export const reqParams = {
|
|
|
104
119
|
],
|
|
105
120
|
'update-bizplace': [
|
|
106
121
|
{
|
|
107
|
-
name: '
|
|
122
|
+
name: 'refBizplaceId',
|
|
108
123
|
required: true,
|
|
109
124
|
type: 'field'
|
|
110
125
|
}
|
|
111
126
|
],
|
|
112
127
|
'create-partner': [
|
|
113
128
|
{
|
|
114
|
-
name: '
|
|
129
|
+
name: 'refBizplaceId',
|
|
115
130
|
required: true,
|
|
116
131
|
type: 'field'
|
|
117
132
|
},
|
|
118
133
|
{
|
|
119
|
-
name: '
|
|
134
|
+
name: 'partnerRefBizplaceId',
|
|
120
135
|
required: true,
|
|
121
136
|
type: 'field'
|
|
122
137
|
}
|
|
123
138
|
],
|
|
124
139
|
'terminate-partner': [
|
|
125
140
|
{
|
|
126
|
-
name: '
|
|
141
|
+
name: 'refBizplaceId',
|
|
127
142
|
required: true,
|
|
128
143
|
type: 'field'
|
|
129
144
|
},
|
|
130
145
|
{
|
|
131
|
-
name: '
|
|
146
|
+
name: 'partnerRefBizplaceId',
|
|
132
147
|
required: true,
|
|
133
148
|
type: 'field'
|
|
134
149
|
}
|
|
135
150
|
],
|
|
136
151
|
'invite-user': [
|
|
137
152
|
{
|
|
138
|
-
name: '
|
|
153
|
+
name: 'userEmail',
|
|
139
154
|
required: true,
|
|
140
155
|
type: 'field'
|
|
141
156
|
},
|
|
142
157
|
{
|
|
143
|
-
name: '
|
|
158
|
+
name: 'refBizplaceId',
|
|
144
159
|
required: true,
|
|
145
160
|
type: 'field'
|
|
146
161
|
}
|
|
147
162
|
],
|
|
148
163
|
'terminate-user': [
|
|
149
164
|
{
|
|
150
|
-
name: '
|
|
165
|
+
name: 'userEmail',
|
|
151
166
|
required: true,
|
|
152
167
|
type: 'field'
|
|
153
168
|
},
|
|
154
169
|
{
|
|
155
|
-
name: '
|
|
170
|
+
name: 'refBizplaceId',
|
|
156
171
|
required: true,
|
|
157
172
|
type: 'field'
|
|
158
173
|
}
|