@neuralinnovations/dataisland-sdk 0.0.1-dev1 → 0.0.1-dev10
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/LICENSE +201 -0
- package/README.md +174 -1
- package/dist/dataisland-sdk.d.ts +1594 -0
- package/dist/dataisland-sdk.js +2890 -0
- package/dist/dataisland-sdk.js.map +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +41 -3
- package/src/appBuilder.ts +24 -5
- package/src/commands/startCommandHandler.ts +14 -0
- package/src/context.ts +31 -0
- package/src/credentials.ts +31 -9
- package/src/dataIslandApp.ts +59 -0
- package/src/disposable.ts +4 -5
- package/src/dto/accessGroupResponse.ts +35 -0
- package/src/dto/chatResponse.ts +103 -0
- package/src/dto/userInfoResponse.ts +47 -0
- package/src/dto/workspacesResponse.ts +49 -0
- package/src/events.ts +13 -17
- package/src/index.ts +44 -18
- package/src/internal/app.impl.ts +97 -32
- package/src/internal/appBuilder.impl.ts +39 -12
- package/src/internal/createApp.impl.ts +5 -5
- package/src/middleware.ts +1 -1
- package/src/services/commandService.ts +44 -0
- package/src/services/credentialService.ts +3 -3
- package/src/services/middlewareService.ts +8 -6
- package/src/services/organizationService.ts +28 -0
- package/src/services/requestBuilder.ts +127 -0
- package/src/services/responseUtils.ts +32 -0
- package/src/services/rpcService.ts +129 -52
- package/src/services/service.ts +10 -8
- package/src/services/userProfileService.ts +38 -0
- package/src/storages/chats/answer.impl.ts +163 -0
- package/src/storages/chats/answer.ts +42 -0
- package/src/storages/chats/chat.impl.ts +87 -0
- package/src/storages/chats/chat.ts +38 -0
- package/src/storages/chats/chats.impl.ts +142 -0
- package/src/storages/chats/chats.ts +47 -0
- package/src/storages/files/file.impl.ts +69 -0
- package/src/storages/files/file.ts +28 -0
- package/src/storages/files/files.impl.ts +213 -0
- package/src/storages/files/files.ts +38 -0
- package/src/storages/files/filesPage.ts +27 -0
- package/src/storages/groups/groups.impl.ts +326 -0
- package/src/storages/groups/groups.ts +101 -0
- package/src/storages/organizations/organization.impl.ts +95 -0
- package/src/storages/organizations/organization.ts +44 -0
- package/src/storages/organizations/organizations.impl.ts +197 -0
- package/src/storages/organizations/organizations.ts +56 -0
- package/src/storages/user/userProfile.impl.ts +56 -0
- package/src/storages/user/userProfile.ts +42 -0
- package/src/storages/workspaces/workspace.impl.ts +109 -0
- package/src/storages/workspaces/workspace.ts +49 -0
- package/src/storages/workspaces/workspaces.impl.ts +212 -0
- package/src/storages/workspaces/workspaces.ts +53 -0
- package/src/unitTest.ts +53 -0
- package/.browserslistrc +0 -5
- package/.editorconfig +0 -22
- package/.eslintrc.json +0 -44
- package/.github/workflows/publish-npm.yml +0 -28
- package/.prettierignore +0 -1
- package/.prettierrc +0 -11
- package/.yarnrc +0 -2
- package/babel.config.js +0 -6
- package/jest.config.ts +0 -199
- package/src/appSdk.ts +0 -40
- package/src/internal/context.ts +0 -13
- package/src/types.ts +0 -110
- package/test/disposable.test.ts +0 -39
- package/test/events.test.ts +0 -151
- package/test/index.test.ts +0 -83
- package/test/registry.test.ts +0 -44
- package/tsconfig.json +0 -31
@@ -0,0 +1,326 @@
|
|
1
|
+
import { Context } from "../../context"
|
2
|
+
import { Disposable } from "../../disposable"
|
3
|
+
import {
|
4
|
+
AccessGroupDto,
|
5
|
+
AccessGroupResponse,
|
6
|
+
AccessGroupsResponse
|
7
|
+
} from "../../dto/accessGroupResponse"
|
8
|
+
import { UserDto } from "../../dto/userInfoResponse"
|
9
|
+
import { WorkspaceDto, WorkspacesResponse } from "../../dto/workspacesResponse"
|
10
|
+
import { RpcService } from "../../services/rpcService"
|
11
|
+
import { Group, GroupEvent, GroupId, Groups } from "./groups"
|
12
|
+
import { OrganizationImpl } from "../organizations/organization.impl"
|
13
|
+
import { OrganizationId } from "../organizations/organizations"
|
14
|
+
import { ResponseUtils } from "../../services/responseUtils"
|
15
|
+
import { Organization } from "../organizations/organization"
|
16
|
+
|
17
|
+
export class GroupImpl extends Group implements Disposable {
|
18
|
+
private _isDisposed: boolean = false
|
19
|
+
private _content?: AccessGroupDto
|
20
|
+
private _members?: UserDto[]
|
21
|
+
|
22
|
+
constructor(
|
23
|
+
private readonly context: Context,
|
24
|
+
public readonly organization: Organization
|
25
|
+
) {
|
26
|
+
super()
|
27
|
+
}
|
28
|
+
|
29
|
+
async initFrom(id: GroupId): Promise<Group> {
|
30
|
+
// fetch group
|
31
|
+
const response = await this.context.resolve(RpcService)
|
32
|
+
?.requestBuilder("api/v1/AccessGroups")
|
33
|
+
.searchParam("id", id)
|
34
|
+
.sendGet()
|
35
|
+
|
36
|
+
// check response status
|
37
|
+
if (ResponseUtils.isFail(response)) {
|
38
|
+
await ResponseUtils.throwError(`Failed to get group: ${id}, organization: ${this}`, response)
|
39
|
+
}
|
40
|
+
|
41
|
+
// parse group from the server's response
|
42
|
+
const group = (await response!.json()) as AccessGroupResponse
|
43
|
+
|
44
|
+
// init group
|
45
|
+
this._content = group.group
|
46
|
+
this._members = group.members
|
47
|
+
|
48
|
+
return this
|
49
|
+
}
|
50
|
+
|
51
|
+
get id(): GroupId {
|
52
|
+
if (this._content) {
|
53
|
+
return this._content.id
|
54
|
+
}
|
55
|
+
throw new Error("Access group is not loaded.")
|
56
|
+
}
|
57
|
+
|
58
|
+
get group(): AccessGroupDto {
|
59
|
+
if (this._content) {
|
60
|
+
return this._content
|
61
|
+
}
|
62
|
+
throw new Error("Access group is not loaded.")
|
63
|
+
}
|
64
|
+
|
65
|
+
async getWorkspaces(): Promise<WorkspaceDto[]> {
|
66
|
+
// fetch workspaces
|
67
|
+
const response = await this.context.resolve(RpcService)
|
68
|
+
?.requestBuilder("api/v1/Organizations/workspaces")
|
69
|
+
.searchParam("groupId", this.id)
|
70
|
+
.sendGet()
|
71
|
+
|
72
|
+
if (ResponseUtils.isFail(response)) {
|
73
|
+
await ResponseUtils.throwError(`Failed to get workspaces for group: ${this.id}, organization: ${this.organization.id}`, response)
|
74
|
+
}
|
75
|
+
|
76
|
+
// parse workspaces from the server's response
|
77
|
+
const workspaces = (await response!.json()) as WorkspacesResponse
|
78
|
+
|
79
|
+
return workspaces.workspaces
|
80
|
+
}
|
81
|
+
|
82
|
+
get members(): UserDto[] {
|
83
|
+
if (this._members) {
|
84
|
+
return this._members
|
85
|
+
}
|
86
|
+
throw new Error("Access group is not loaded.")
|
87
|
+
}
|
88
|
+
|
89
|
+
async setName(name: string): Promise<void> {
|
90
|
+
if (name === undefined || name === null) {
|
91
|
+
throw new Error("Groups change, name is undefined or null")
|
92
|
+
}
|
93
|
+
if (name.length === 0 || name.trim().length === 0) {
|
94
|
+
throw new Error("Groups change, name is empty")
|
95
|
+
}
|
96
|
+
// send request to the server
|
97
|
+
const response = await this.context
|
98
|
+
.resolve(RpcService)
|
99
|
+
?.requestBuilder("api/v1/AccessGroups/name")
|
100
|
+
.sendPutJson({
|
101
|
+
groupId: this.id,
|
102
|
+
name: name
|
103
|
+
})
|
104
|
+
|
105
|
+
// check response status
|
106
|
+
if (ResponseUtils.isFail(response)) {
|
107
|
+
await ResponseUtils.throwError(`Failed to change group name, group: ${this.id}, organization: ${this.organization.id}`, response)
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
async setPermits(permits: { isAdmin: boolean }): Promise<void> {
|
112
|
+
// send request to the server
|
113
|
+
const response = await this.context
|
114
|
+
.resolve(RpcService)
|
115
|
+
?.requestBuilder("api/v1/AccessGroups/permits")
|
116
|
+
.sendPutJson({
|
117
|
+
groupId: this.id,
|
118
|
+
permits: permits
|
119
|
+
})
|
120
|
+
|
121
|
+
if (ResponseUtils.isFail(response)) {
|
122
|
+
await ResponseUtils.throwError(`Failed to change group permits, group: ${this.id}, organization: ${this.organization.id}`, response)
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
async setWorkspaces(workspaces: string[]): Promise<void> {
|
127
|
+
if (workspaces === null || workspaces === undefined) {
|
128
|
+
throw new Error("Group add workspaces, workspaces is undefined or null")
|
129
|
+
}
|
130
|
+
|
131
|
+
// send request to the server
|
132
|
+
const response = await this.context
|
133
|
+
.resolve(RpcService)
|
134
|
+
?.requestBuilder("api/v1/AccessGroups/workspaces")
|
135
|
+
.sendPutJson({
|
136
|
+
groupId: this.id,
|
137
|
+
actualWorkspaceIds: workspaces
|
138
|
+
})
|
139
|
+
|
140
|
+
if (ResponseUtils.isFail(response)) {
|
141
|
+
await ResponseUtils.throwError(`Failed to set workspaces for group: ${this.id}, organization: ${this.organization.id}`, response)
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
async setMembersIds(members: string[]) {
|
146
|
+
if (members === null || members === undefined) {
|
147
|
+
throw new Error("Group add members, members is undefined or null")
|
148
|
+
}
|
149
|
+
|
150
|
+
// send request to the server
|
151
|
+
const response = await this.context
|
152
|
+
.resolve(RpcService)
|
153
|
+
?.requestBuilder("api/v1/AccessGroups/members")
|
154
|
+
.sendPutJson({
|
155
|
+
groupId: this.id,
|
156
|
+
memberIds: members
|
157
|
+
})
|
158
|
+
|
159
|
+
if (ResponseUtils.isFail(response)) {
|
160
|
+
await ResponseUtils.throwError(`Failed to set members for group: ${this.id}, organization: ${this.organization.id}`, response)
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
get isDisposed(): boolean {
|
165
|
+
return this._isDisposed
|
166
|
+
}
|
167
|
+
|
168
|
+
dispose(): void {
|
169
|
+
this._isDisposed = true
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
export class GroupsImpl extends Groups {
|
174
|
+
|
175
|
+
private _groups: Group[] = []
|
176
|
+
|
177
|
+
constructor(
|
178
|
+
public readonly organization: OrganizationImpl,
|
179
|
+
private readonly context: Context
|
180
|
+
) {
|
181
|
+
super()
|
182
|
+
}
|
183
|
+
|
184
|
+
async initialize() {
|
185
|
+
await this.internalInit()
|
186
|
+
}
|
187
|
+
|
188
|
+
async create(name: string, organizationId: OrganizationId, permits: {
|
189
|
+
isAdmin: boolean
|
190
|
+
}, memberIds: string[]): Promise<Group> {
|
191
|
+
return await this.internalCreate(name, organizationId, permits, memberIds)
|
192
|
+
}
|
193
|
+
|
194
|
+
get(id: GroupId): Group | undefined {
|
195
|
+
return this._groups.find(group => group.id === id)
|
196
|
+
}
|
197
|
+
|
198
|
+
async delete(id: GroupId): Promise<void> {
|
199
|
+
return await this.internalDeleteGroup(id)
|
200
|
+
}
|
201
|
+
|
202
|
+
//----------------------------------------------------------------------------
|
203
|
+
// INTERNALS
|
204
|
+
//----------------------------------------------------------------------------
|
205
|
+
|
206
|
+
/**
|
207
|
+
* Init access groups.
|
208
|
+
*/
|
209
|
+
async internalInit(): Promise<void> {
|
210
|
+
// fetch groups
|
211
|
+
const response = await this.context.resolve(RpcService)
|
212
|
+
?.requestBuilder("api/v1/Organizations/access_groups")
|
213
|
+
.searchParam("id", this.organization.id)
|
214
|
+
.sendGet()
|
215
|
+
|
216
|
+
// check response status
|
217
|
+
if (ResponseUtils.isFail(response)) {
|
218
|
+
await ResponseUtils.throwError(`Failed to get groups for organization: ${this.organization.id}`, response)
|
219
|
+
}
|
220
|
+
|
221
|
+
// parse groups from the server's response
|
222
|
+
const groups = (await response!.json()) as AccessGroupsResponse
|
223
|
+
|
224
|
+
// init groups
|
225
|
+
for (const gr of groups.groups) {
|
226
|
+
// create group implementation
|
227
|
+
const group = await new GroupImpl(this.context, this.organization).initFrom(gr.id)
|
228
|
+
|
229
|
+
// add group to the collection
|
230
|
+
this._groups.push(group)
|
231
|
+
|
232
|
+
// dispatch event
|
233
|
+
this.dispatch({
|
234
|
+
type: GroupEvent.ADDED,
|
235
|
+
data: group
|
236
|
+
})
|
237
|
+
}
|
238
|
+
}
|
239
|
+
|
240
|
+
async internalCreate(name: string, organizationId: OrganizationId, permits: {
|
241
|
+
isAdmin: boolean
|
242
|
+
}, memberIds: string[]): Promise<Group> {
|
243
|
+
if (name === undefined || name === null) {
|
244
|
+
throw new Error("Group create, name is undefined or null")
|
245
|
+
}
|
246
|
+
if (name.length === 0 || name.trim().length === 0) {
|
247
|
+
throw new Error("Group create, name is empty")
|
248
|
+
}
|
249
|
+
|
250
|
+
// send request to the server
|
251
|
+
const response = await this.context
|
252
|
+
.resolve(RpcService)
|
253
|
+
?.requestBuilder("api/v1/AccessGroups")
|
254
|
+
.sendPostJson({
|
255
|
+
name: name,
|
256
|
+
organizationId: organizationId,
|
257
|
+
permits: permits,
|
258
|
+
memberIds: memberIds
|
259
|
+
})
|
260
|
+
|
261
|
+
// check response status
|
262
|
+
if (ResponseUtils.isFail(response)) {
|
263
|
+
await ResponseUtils.throwError(`Failed to create group, organization: ${this.organization.id}`, response)
|
264
|
+
}
|
265
|
+
// parse group from the server's response
|
266
|
+
const content = (await response!.json()) as AccessGroupResponse
|
267
|
+
|
268
|
+
// create group implementation
|
269
|
+
const group = await new GroupImpl(this.context, this.organization).initFrom(content.group.id)
|
270
|
+
|
271
|
+
// add group to the collection
|
272
|
+
this._groups.push(group)
|
273
|
+
|
274
|
+
// dispatch event
|
275
|
+
this.dispatch({
|
276
|
+
type: GroupEvent.ADDED,
|
277
|
+
data: group
|
278
|
+
})
|
279
|
+
|
280
|
+
return group
|
281
|
+
}
|
282
|
+
|
283
|
+
/**
|
284
|
+
* Delete group.
|
285
|
+
* @param id
|
286
|
+
*/
|
287
|
+
async internalDeleteGroup(id: GroupId): Promise<void> {
|
288
|
+
if (id === undefined || id === null) {
|
289
|
+
throw new Error("Group delete, id is undefined or null")
|
290
|
+
}
|
291
|
+
if (id.length === 0 || id.trim().length === 0) {
|
292
|
+
throw new Error("Group delete, id is empty")
|
293
|
+
}
|
294
|
+
|
295
|
+
// send request to the server
|
296
|
+
const response = await this.context
|
297
|
+
.resolve(RpcService)
|
298
|
+
?.requestBuilder("/api/v1/AccessGroups")
|
299
|
+
.searchParam("groupId", id)
|
300
|
+
.sendDelete()
|
301
|
+
|
302
|
+
// check response status
|
303
|
+
if (ResponseUtils.isFail(response)) {
|
304
|
+
await ResponseUtils.throwError(`Failed to delete group: ${id}, organization: ${this.organization.id}`, response)
|
305
|
+
}
|
306
|
+
|
307
|
+
// delete group from collection
|
308
|
+
const group = <GroupImpl>this._groups.find(f => f.id === id)
|
309
|
+
const index = this._groups.indexOf(group)
|
310
|
+
if (index < 0) {
|
311
|
+
throw new Error("Group delete, index is not found")
|
312
|
+
}
|
313
|
+
|
314
|
+
// remove group from collection
|
315
|
+
this._groups.splice(index, 1)
|
316
|
+
|
317
|
+
// dispatch event, group removed
|
318
|
+
this.dispatch({
|
319
|
+
type: GroupEvent.REMOVED,
|
320
|
+
data: group
|
321
|
+
})
|
322
|
+
|
323
|
+
// dispose group
|
324
|
+
group.dispose()
|
325
|
+
}
|
326
|
+
}
|
@@ -0,0 +1,101 @@
|
|
1
|
+
import { AccessGroupDto } from "../../dto/accessGroupResponse"
|
2
|
+
import { UserDto } from "../../dto/userInfoResponse"
|
3
|
+
import { WorkspaceDto } from "../../dto/workspacesResponse"
|
4
|
+
import { EventDispatcher } from "../../events"
|
5
|
+
import { OrganizationId } from "../organizations/organizations"
|
6
|
+
import { Organization } from "../organizations/organization"
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Group id.
|
10
|
+
*/
|
11
|
+
export type GroupId = string
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Group event.
|
15
|
+
*/
|
16
|
+
export enum GroupEvent {
|
17
|
+
ADDED = "added",
|
18
|
+
REMOVED = "removed",
|
19
|
+
UPDATED = "updated"
|
20
|
+
}
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Group.
|
24
|
+
*/
|
25
|
+
export abstract class Group extends EventDispatcher<GroupEvent, Group> {
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Group id.
|
29
|
+
*/
|
30
|
+
abstract get id(): GroupId
|
31
|
+
|
32
|
+
/**
|
33
|
+
* Group information.
|
34
|
+
*/
|
35
|
+
abstract get group(): AccessGroupDto
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Group members.
|
39
|
+
*/
|
40
|
+
abstract get members(): UserDto[]
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Group workspaces.
|
44
|
+
*/
|
45
|
+
abstract getWorkspaces(): Promise<WorkspaceDto[]>
|
46
|
+
|
47
|
+
/**
|
48
|
+
* Set workspaces.
|
49
|
+
*/
|
50
|
+
abstract setWorkspaces(workspaces: string[]): Promise<void>
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Set name.
|
54
|
+
*/
|
55
|
+
abstract setName(name: string): Promise<void>
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Set permits.
|
59
|
+
*/
|
60
|
+
abstract setPermits(permits: { isAdmin: boolean }): Promise<void>
|
61
|
+
|
62
|
+
/**
|
63
|
+
* Set members.
|
64
|
+
*/
|
65
|
+
abstract setMembersIds(members: string[]): Promise<void>
|
66
|
+
}
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Groups storage.
|
70
|
+
*/
|
71
|
+
export abstract class Groups extends EventDispatcher<GroupEvent, Group> {
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Organization.
|
75
|
+
*/
|
76
|
+
abstract get organization(): Organization
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Create new group.
|
80
|
+
* @param name
|
81
|
+
* @param organizationId
|
82
|
+
* @param permits
|
83
|
+
* @param memberIds
|
84
|
+
*/
|
85
|
+
abstract create(name: string, organizationId: OrganizationId, permits: {
|
86
|
+
isAdmin: boolean
|
87
|
+
}, memberIds: string[]): Promise<Group>
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Get group by id.
|
91
|
+
* @param id
|
92
|
+
*/
|
93
|
+
abstract get(id: GroupId): Group | undefined
|
94
|
+
|
95
|
+
/**
|
96
|
+
* delete group by id.
|
97
|
+
* @param id
|
98
|
+
*/
|
99
|
+
abstract delete(id: GroupId): Promise<void>
|
100
|
+
|
101
|
+
}
|
@@ -0,0 +1,95 @@
|
|
1
|
+
import { OrganizationId } from "./organizations"
|
2
|
+
import { Disposable } from "../../disposable"
|
3
|
+
import { OrganizationDto } from "../../dto/userInfoResponse"
|
4
|
+
import { Workspaces } from "../workspaces/workspaces"
|
5
|
+
import { WorkspacesImpl } from "../workspaces/workspaces.impl"
|
6
|
+
import { Context } from "../../context"
|
7
|
+
import { Organization } from "./organization"
|
8
|
+
import { GroupsImpl } from "../groups/groups.impl"
|
9
|
+
import { Groups } from "../groups/groups"
|
10
|
+
import { ChatsImpl } from "../chats/chats.impl"
|
11
|
+
import { Chats } from "../chats/chats"
|
12
|
+
import { RpcService } from "../../services/rpcService"
|
13
|
+
import { ResponseUtils } from "../../services/responseUtils"
|
14
|
+
|
15
|
+
export class OrganizationImpl extends Organization implements Disposable {
|
16
|
+
private _isDisposed: boolean = false
|
17
|
+
private _isAdmin: boolean = false
|
18
|
+
private _content?: OrganizationDto
|
19
|
+
private readonly _workspaces: WorkspacesImpl
|
20
|
+
private readonly _accessGroups: GroupsImpl
|
21
|
+
private readonly _chats: ChatsImpl
|
22
|
+
|
23
|
+
constructor(private readonly context: Context) {
|
24
|
+
super()
|
25
|
+
this._workspaces = new WorkspacesImpl(this, this.context)
|
26
|
+
this._accessGroups = new GroupsImpl(this, this.context)
|
27
|
+
this._chats = new ChatsImpl(this, this.context)
|
28
|
+
}
|
29
|
+
|
30
|
+
public async initFrom(
|
31
|
+
content: OrganizationDto,
|
32
|
+
isAdmin: boolean
|
33
|
+
): Promise<OrganizationImpl> {
|
34
|
+
this._content = content
|
35
|
+
this._isAdmin = isAdmin
|
36
|
+
|
37
|
+
// init workspaces by organization id
|
38
|
+
await this._workspaces.initFrom(content.id)
|
39
|
+
|
40
|
+
return this
|
41
|
+
}
|
42
|
+
|
43
|
+
get isAdmin(): boolean {
|
44
|
+
return this._isAdmin
|
45
|
+
}
|
46
|
+
|
47
|
+
get isDisposed(): boolean {
|
48
|
+
return this._isDisposed
|
49
|
+
}
|
50
|
+
|
51
|
+
dispose(): void {
|
52
|
+
this._isDisposed = true
|
53
|
+
}
|
54
|
+
|
55
|
+
get id(): OrganizationId {
|
56
|
+
return <OrganizationId>this._content?.id
|
57
|
+
}
|
58
|
+
|
59
|
+
get name(): string {
|
60
|
+
return <OrganizationId>this._content?.profile.name
|
61
|
+
}
|
62
|
+
|
63
|
+
get description(): string {
|
64
|
+
return <OrganizationId>this._content?.profile.description
|
65
|
+
}
|
66
|
+
|
67
|
+
get workspaces(): Workspaces {
|
68
|
+
return this._workspaces
|
69
|
+
}
|
70
|
+
|
71
|
+
get accessGroups(): Groups {
|
72
|
+
return this._accessGroups
|
73
|
+
}
|
74
|
+
|
75
|
+
get chats(): Chats {
|
76
|
+
return this._chats
|
77
|
+
}
|
78
|
+
|
79
|
+
async createInviteLink(emails: string[], accessGroups: string[]): Promise<void> {
|
80
|
+
const response = await this.context
|
81
|
+
.resolve(RpcService)
|
82
|
+
?.requestBuilder("api/v1/Invites")
|
83
|
+
.sendPostJson({
|
84
|
+
organizationId: this.id,
|
85
|
+
emails: emails,
|
86
|
+
accessGroupIds: accessGroups
|
87
|
+
})
|
88
|
+
if (ResponseUtils.isFail(response)) {
|
89
|
+
await ResponseUtils.throwError(
|
90
|
+
`Invite link creation failed for organization ${this.id}`,
|
91
|
+
response
|
92
|
+
)
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { Workspaces } from "../workspaces/workspaces"
|
2
|
+
import { OrganizationId } from "./organizations"
|
3
|
+
import { GroupId, Groups } from "../groups/groups"
|
4
|
+
import { Chats } from "../chats/chats"
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Organization.
|
8
|
+
*/
|
9
|
+
export abstract class Organization {
|
10
|
+
/**
|
11
|
+
* Organization id.
|
12
|
+
*/
|
13
|
+
abstract get id(): OrganizationId
|
14
|
+
|
15
|
+
/**
|
16
|
+
* Organization name.
|
17
|
+
*/
|
18
|
+
abstract get name(): string
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Organization description.
|
22
|
+
*/
|
23
|
+
abstract get description(): string
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Workspaces.
|
27
|
+
*/
|
28
|
+
abstract get workspaces(): Workspaces
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Chats.
|
32
|
+
*/
|
33
|
+
abstract get chats(): Chats
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Groups.
|
37
|
+
*/
|
38
|
+
abstract get accessGroups(): Groups
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Create invite link
|
42
|
+
*/
|
43
|
+
abstract createInviteLink(emails: string[], accessGroups: GroupId[]): Promise<void>
|
44
|
+
}
|