@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,1594 @@
|
|
1
|
+
declare module "src/middleware" {
|
2
|
+
/**
|
3
|
+
* DataIsland App request middleware.
|
4
|
+
*/
|
5
|
+
export type Middleware = (req: Request, next: (req: Request) => Promise<Response>) => Promise<Response>;
|
6
|
+
}
|
7
|
+
declare module "src/internal/registry" {
|
8
|
+
export type Constructor<T> = new (...args: any[]) => T;
|
9
|
+
abstract class Provider {
|
10
|
+
abstract provide(): any | undefined;
|
11
|
+
}
|
12
|
+
export class RegistryItem<T> {
|
13
|
+
private readonly registry;
|
14
|
+
private readonly type;
|
15
|
+
constructor(registry: Map<Constructor<any>, Provider>, type: Constructor<T>);
|
16
|
+
asValue(value: T): void;
|
17
|
+
asProvider<T>(provider: () => T, oneTime?: boolean): void;
|
18
|
+
asFactory<T>(provider: () => T): void;
|
19
|
+
asSingleton<T>(provider: () => T): void;
|
20
|
+
}
|
21
|
+
export class Registry {
|
22
|
+
private readonly services;
|
23
|
+
constructor();
|
24
|
+
map<T>(type: Constructor<T>): RegistryItem<T>;
|
25
|
+
set<T>(type: Constructor<T>, provider: Provider): void;
|
26
|
+
get<T>(type: Constructor<T>): T | undefined;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
declare module "src/disposable" {
|
30
|
+
/**
|
31
|
+
* Represents an object that can be disposed.
|
32
|
+
*/
|
33
|
+
export interface Disposable {
|
34
|
+
dispose(): void;
|
35
|
+
}
|
36
|
+
/**
|
37
|
+
* Represents a lifetime.
|
38
|
+
*/
|
39
|
+
export class Lifetime {
|
40
|
+
private readonly container;
|
41
|
+
constructor(container: DisposableContainer);
|
42
|
+
/**
|
43
|
+
* Define a new nested disposable to this lifetime.
|
44
|
+
*/
|
45
|
+
defineNested(): DisposableContainer;
|
46
|
+
/**
|
47
|
+
* Shows whether this lifetime is disposed.
|
48
|
+
*/
|
49
|
+
get isDisposed(): boolean;
|
50
|
+
/**
|
51
|
+
* Adds a disposable to this lifetime.
|
52
|
+
*/
|
53
|
+
add(disposable: Disposable): this;
|
54
|
+
/**
|
55
|
+
* Adds a callback to this lifetime.
|
56
|
+
*/
|
57
|
+
addCallback(callback: () => void, target?: unknown): this;
|
58
|
+
}
|
59
|
+
/**
|
60
|
+
* A container for disposables.
|
61
|
+
* Last added, first disposed.
|
62
|
+
* @example
|
63
|
+
* const container = new DisposableContainer();
|
64
|
+
* container.add(someDisposable);
|
65
|
+
* container.addCallback(() => console.log('disposed'));
|
66
|
+
* container.dispose();
|
67
|
+
*/
|
68
|
+
export class DisposableContainer implements Disposable {
|
69
|
+
private _disposables;
|
70
|
+
private _isDisposed;
|
71
|
+
private _lifetime?;
|
72
|
+
/**
|
73
|
+
* Gets whether this container is disposed.
|
74
|
+
*/
|
75
|
+
get isDisposed(): boolean;
|
76
|
+
/**
|
77
|
+
* Define new lifetime.
|
78
|
+
*/
|
79
|
+
get lifetime(): Lifetime;
|
80
|
+
/**
|
81
|
+
* Adds a disposable to this container.
|
82
|
+
* @param disposable The disposable to add.
|
83
|
+
* @returns The disposable container.
|
84
|
+
*/
|
85
|
+
add(disposable: Disposable): Disposable;
|
86
|
+
/**
|
87
|
+
* Adds a callback to be executed when this container is disposed.
|
88
|
+
* @param callback The callback to execute.
|
89
|
+
* @param target The target to bind the callback to.
|
90
|
+
* @returns The disposable container.
|
91
|
+
*/
|
92
|
+
addCallback(callback: () => void, target?: unknown): Disposable;
|
93
|
+
/**
|
94
|
+
* Defines a nested disposable container.
|
95
|
+
*/
|
96
|
+
defineNested(): DisposableContainer;
|
97
|
+
/**
|
98
|
+
* Disposes all disposables in this container. Last added, first disposed.
|
99
|
+
*/
|
100
|
+
dispose(): void;
|
101
|
+
/**
|
102
|
+
* Throws an error if this container is disposed.
|
103
|
+
*/
|
104
|
+
private _throwIfDisposed;
|
105
|
+
}
|
106
|
+
/**
|
107
|
+
* Creates a disposable.
|
108
|
+
* @param action The action to execute when disposed.
|
109
|
+
* @param target The target to bind the action to.
|
110
|
+
* @returns The disposable.
|
111
|
+
*/
|
112
|
+
export function disposable(action: () => void, target: unknown): Disposable;
|
113
|
+
}
|
114
|
+
declare module "src/services/commandService" {
|
115
|
+
import { Service } from "src/services/service";
|
116
|
+
import { Context } from "src/context";
|
117
|
+
import { Constructor } from "src/internal/registry";
|
118
|
+
export abstract class CommandHandler<T> {
|
119
|
+
protected readonly context: Context;
|
120
|
+
constructor(context: Context);
|
121
|
+
resolve<T>(type: Constructor<T>): T | undefined;
|
122
|
+
abstract execute(message: T): Promise<void>;
|
123
|
+
}
|
124
|
+
export abstract class Command {
|
125
|
+
}
|
126
|
+
export class CommandService extends Service {
|
127
|
+
private readonly _registry;
|
128
|
+
private _lastPromise;
|
129
|
+
register<T extends Command>(messageType: Constructor<T>, commandFactory: (context: Context) => CommandHandler<T>): void;
|
130
|
+
execute<T extends Command>(message: T): Promise<void>;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
declare module "src/context" {
|
134
|
+
import { type Constructor, type Registry } from "src/internal/registry";
|
135
|
+
import { type Lifetime } from "src/disposable";
|
136
|
+
import { Command } from "src/services/commandService";
|
137
|
+
/**
|
138
|
+
* DataIsland App context.
|
139
|
+
*/
|
140
|
+
export class Context {
|
141
|
+
private readonly registry;
|
142
|
+
readonly lifetime: Lifetime;
|
143
|
+
readonly appName: string;
|
144
|
+
constructor(registry: Registry, lifetime: Lifetime, appName: string);
|
145
|
+
/**
|
146
|
+
* Resolve a service from the context.
|
147
|
+
* @param type of the service
|
148
|
+
*/
|
149
|
+
resolve<T>(type: Constructor<T>): T | undefined;
|
150
|
+
/**
|
151
|
+
* Execute a command.
|
152
|
+
* @param command to execute
|
153
|
+
*/
|
154
|
+
execute<T extends Command>(command: T): Promise<void>;
|
155
|
+
}
|
156
|
+
}
|
157
|
+
declare module "src/services/service" {
|
158
|
+
import { type Context } from "src/context";
|
159
|
+
import { type Constructor } from "src/internal/registry";
|
160
|
+
import { type DisposableContainer, type Lifetime } from "src/disposable";
|
161
|
+
export class ServiceContext {
|
162
|
+
readonly context: Context;
|
163
|
+
private readonly disposableContainer;
|
164
|
+
constructor(context: Context, disposableContainer: DisposableContainer);
|
165
|
+
get lifetime(): Lifetime;
|
166
|
+
resolve<T>(type: Constructor<T>): T | undefined;
|
167
|
+
onRegister: () => Promise<void>;
|
168
|
+
onStart: () => Promise<void>;
|
169
|
+
onUnregister: () => void;
|
170
|
+
}
|
171
|
+
export abstract class Service {
|
172
|
+
private readonly serviceContext;
|
173
|
+
resolve<T>(type: Constructor<T>): T | undefined;
|
174
|
+
get lifetime(): Lifetime;
|
175
|
+
get context(): Context;
|
176
|
+
constructor(serviceContext: ServiceContext);
|
177
|
+
}
|
178
|
+
}
|
179
|
+
declare module "src/services/middlewareService" {
|
180
|
+
import { Service } from "src/services/service";
|
181
|
+
import { type Middleware } from "src/middleware";
|
182
|
+
import { type Disposable } from "src/disposable";
|
183
|
+
export class MiddlewareService extends Service {
|
184
|
+
private _middlewares;
|
185
|
+
useMiddleware(middleware: Middleware): Disposable;
|
186
|
+
process(req: Request, next: (req: Request) => Promise<Response>): Promise<Response>;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
declare module "src/credentials" {
|
190
|
+
import { type Lifetime } from "src/disposable";
|
191
|
+
import { type Context } from "src/context";
|
192
|
+
/**
|
193
|
+
* DataIsland App credential.
|
194
|
+
*/
|
195
|
+
export abstract class CredentialBase {
|
196
|
+
abstract onRegister(lifetime: Lifetime, context: Context): void;
|
197
|
+
}
|
198
|
+
export class DefaultCredential extends CredentialBase {
|
199
|
+
onRegister(lifetime: Lifetime, context: Context): void;
|
200
|
+
}
|
201
|
+
export class BasicCredential extends CredentialBase {
|
202
|
+
readonly email: string;
|
203
|
+
readonly password: string;
|
204
|
+
constructor(email: string, password: string);
|
205
|
+
onRegister(lifetime: Lifetime, context: Context): void;
|
206
|
+
}
|
207
|
+
export class DebugCredential extends CredentialBase {
|
208
|
+
readonly token: string;
|
209
|
+
constructor(token: string);
|
210
|
+
onRegister(lifetime: Lifetime, context: Context): void;
|
211
|
+
}
|
212
|
+
export class BearerCredential extends CredentialBase {
|
213
|
+
readonly token: string;
|
214
|
+
constructor(token: string);
|
215
|
+
onRegister(lifetime: Lifetime, context: Context): void;
|
216
|
+
}
|
217
|
+
}
|
218
|
+
declare module "src/appBuilder" {
|
219
|
+
import type { Middleware } from "src/middleware";
|
220
|
+
import type { CredentialBase } from "src/credentials";
|
221
|
+
import type { Service, ServiceContext } from "src/services/service";
|
222
|
+
import type { Constructor } from "src/internal/registry";
|
223
|
+
import { CommandHandler, Command } from "src/services/commandService";
|
224
|
+
import { Context } from "src/context";
|
225
|
+
/**
|
226
|
+
* DataIsland App builder.
|
227
|
+
*/
|
228
|
+
export abstract class AppBuilder {
|
229
|
+
/**
|
230
|
+
* Set custom data.
|
231
|
+
*/
|
232
|
+
abstract get env(): Record<string, any>;
|
233
|
+
/**
|
234
|
+
* Add a middleware to the app.
|
235
|
+
*/
|
236
|
+
abstract registerMiddleware(middleware: Middleware): AppBuilder;
|
237
|
+
/**
|
238
|
+
* Host of the app.
|
239
|
+
*/
|
240
|
+
abstract useHost(host: string): AppBuilder;
|
241
|
+
/**
|
242
|
+
* GDPR compliant
|
243
|
+
*/
|
244
|
+
abstract useAutomaticDataCollectionEnabled(value: boolean): AppBuilder;
|
245
|
+
/**
|
246
|
+
* Credential of the app.
|
247
|
+
*/
|
248
|
+
abstract useCredential(credential: CredentialBase): AppBuilder;
|
249
|
+
/**
|
250
|
+
* Register a service to the app.
|
251
|
+
* @param type
|
252
|
+
* @param factory
|
253
|
+
*/
|
254
|
+
abstract registerService<T extends Service>(type: Constructor<T>, factory: (context: ServiceContext) => T): AppBuilder;
|
255
|
+
/**
|
256
|
+
* Register a command to the app.
|
257
|
+
* @param messageType
|
258
|
+
* @param commandFactory
|
259
|
+
*/
|
260
|
+
abstract registerCommand<T extends Command>(messageType: Constructor<T>, commandFactory: ((context: Context) => CommandHandler<T>) | ((context: Context) => (context: Context) => Promise<void>)): AppBuilder;
|
261
|
+
}
|
262
|
+
}
|
263
|
+
declare module "src/events" {
|
264
|
+
import { type Disposable } from "src/disposable";
|
265
|
+
export interface Input<EventType, DataType> {
|
266
|
+
type?: EventType;
|
267
|
+
data: DataType;
|
268
|
+
}
|
269
|
+
export interface Event<EventType, DataType> extends Input<EventType, DataType> {
|
270
|
+
unsubscribe: () => void;
|
271
|
+
}
|
272
|
+
export interface EventSubscriber<EventType, DataType> {
|
273
|
+
subscribe: (callback: (event: Event<EventType, DataType>) => void, type?: EventType) => Disposable;
|
274
|
+
}
|
275
|
+
export class EventDispatcher<EventType, DataType> implements EventSubscriber<EventType, DataType> {
|
276
|
+
private _listeners;
|
277
|
+
dispatch(input: Input<EventType, DataType>): void;
|
278
|
+
subscribe(callback: (event: Event<EventType, DataType>) => void, type?: EventType): Disposable;
|
279
|
+
}
|
280
|
+
}
|
281
|
+
declare module "src/dto/workspacesResponse" {
|
282
|
+
import { WorkspaceId } from "src/storages/workspaces/workspaces";
|
283
|
+
import { FileId } from "src/storages/files/file";
|
284
|
+
export interface WorkspaceProfileDto {
|
285
|
+
name: string;
|
286
|
+
description: string;
|
287
|
+
}
|
288
|
+
export interface WorkspaceDto {
|
289
|
+
id: WorkspaceId;
|
290
|
+
createdAt: number;
|
291
|
+
modifiedAt: number;
|
292
|
+
profile: WorkspaceProfileDto;
|
293
|
+
}
|
294
|
+
export interface WorkspacesResponse {
|
295
|
+
workspaces: WorkspaceDto[];
|
296
|
+
}
|
297
|
+
export interface FileUrlDto {
|
298
|
+
url: string;
|
299
|
+
}
|
300
|
+
export interface FileProgressDto {
|
301
|
+
file_id: FileId;
|
302
|
+
file_parts_count: number;
|
303
|
+
completed_parts_count: number;
|
304
|
+
success: boolean;
|
305
|
+
error?: string;
|
306
|
+
}
|
307
|
+
export interface FileDto {
|
308
|
+
id: string;
|
309
|
+
createdAt: number;
|
310
|
+
modifiedAt: number;
|
311
|
+
name: string;
|
312
|
+
description: string;
|
313
|
+
url: string;
|
314
|
+
hash: string;
|
315
|
+
organizationId: string;
|
316
|
+
workspaceId: string;
|
317
|
+
isProcessedSuccessfully: boolean;
|
318
|
+
}
|
319
|
+
export interface FileListResponse {
|
320
|
+
files: FileDto[];
|
321
|
+
totalFilesCount: number;
|
322
|
+
filesPerPage: number;
|
323
|
+
}
|
324
|
+
}
|
325
|
+
declare module "src/storages/files/file" {
|
326
|
+
import { FileProgressDto } from "src/dto/workspacesResponse";
|
327
|
+
export type FileId = string;
|
328
|
+
/**
|
329
|
+
* File.
|
330
|
+
*/
|
331
|
+
export abstract class File {
|
332
|
+
/**
|
333
|
+
* File id.
|
334
|
+
*/
|
335
|
+
abstract get id(): FileId;
|
336
|
+
/**
|
337
|
+
* File name.
|
338
|
+
*/
|
339
|
+
abstract get name(): string;
|
340
|
+
/**
|
341
|
+
* Get temporary url.
|
342
|
+
*/
|
343
|
+
abstract url(): Promise<string>;
|
344
|
+
/**
|
345
|
+
* Get file status.
|
346
|
+
*/
|
347
|
+
abstract status(): Promise<FileProgressDto>;
|
348
|
+
}
|
349
|
+
}
|
350
|
+
declare module "src/storages/files/filesPage" {
|
351
|
+
import { File } from "src/storages/files/file";
|
352
|
+
/**
|
353
|
+
* Files page.
|
354
|
+
*/
|
355
|
+
export abstract class FilesPage {
|
356
|
+
/**
|
357
|
+
* Get files.
|
358
|
+
*/
|
359
|
+
abstract get files(): File[];
|
360
|
+
/**
|
361
|
+
* Get pages count.
|
362
|
+
*/
|
363
|
+
abstract get pages(): number;
|
364
|
+
/**
|
365
|
+
* Get total count.
|
366
|
+
*/
|
367
|
+
abstract get total(): number;
|
368
|
+
/**
|
369
|
+
* Get current page.
|
370
|
+
*/
|
371
|
+
abstract get page(): number;
|
372
|
+
}
|
373
|
+
}
|
374
|
+
declare module "src/storages/files/files" {
|
375
|
+
import { EventDispatcher } from "src/events";
|
376
|
+
import { File, FileId } from "src/storages/files/file";
|
377
|
+
import { FilesPage } from "src/storages/files/filesPage";
|
378
|
+
/**
|
379
|
+
* Files event.
|
380
|
+
*/
|
381
|
+
export enum FilesEvent {
|
382
|
+
ADDED = "added",
|
383
|
+
REMOVED = "removed"
|
384
|
+
}
|
385
|
+
/**
|
386
|
+
* Upload file.
|
387
|
+
*/
|
388
|
+
export type UploadFile = globalThis.File;
|
389
|
+
/**
|
390
|
+
* Files storage.
|
391
|
+
*/
|
392
|
+
export abstract class Files extends EventDispatcher<FilesEvent, File> {
|
393
|
+
/**
|
394
|
+
* Upload file.
|
395
|
+
*/
|
396
|
+
abstract upload(file: UploadFile): Promise<File>;
|
397
|
+
/**
|
398
|
+
* Delete file.
|
399
|
+
* @param id
|
400
|
+
*/
|
401
|
+
abstract delete(id: FileId): Promise<void>;
|
402
|
+
/**
|
403
|
+
* Query files.
|
404
|
+
*/
|
405
|
+
abstract query(query: string, page: number, limit: number): Promise<FilesPage>;
|
406
|
+
}
|
407
|
+
}
|
408
|
+
declare module "src/storages/workspaces/workspace" {
|
409
|
+
import { EventDispatcher } from "src/events";
|
410
|
+
import { Files } from "src/storages/files/files";
|
411
|
+
import { WorkspaceId } from "src/storages/workspaces/workspaces";
|
412
|
+
import { Organization } from "src/storages/organizations/organization";
|
413
|
+
/**
|
414
|
+
* Workspace event.
|
415
|
+
*/
|
416
|
+
export enum WorkspaceEvent {
|
417
|
+
CHANGED = "changed"
|
418
|
+
}
|
419
|
+
/**
|
420
|
+
* Workspace.
|
421
|
+
*/
|
422
|
+
export abstract class Workspace extends EventDispatcher<WorkspaceEvent, Workspace> {
|
423
|
+
/**
|
424
|
+
* Organization.
|
425
|
+
*/
|
426
|
+
abstract get organization(): Organization;
|
427
|
+
/**
|
428
|
+
* Workspace id.
|
429
|
+
*/
|
430
|
+
abstract get id(): WorkspaceId;
|
431
|
+
/**
|
432
|
+
* Workspace name.
|
433
|
+
*/
|
434
|
+
abstract get name(): string;
|
435
|
+
/**
|
436
|
+
* Workspace description.
|
437
|
+
*/
|
438
|
+
abstract get description(): string;
|
439
|
+
/**
|
440
|
+
* Workspace files.
|
441
|
+
*/
|
442
|
+
abstract get files(): Files;
|
443
|
+
/**
|
444
|
+
* Change workspace name and description.
|
445
|
+
*/
|
446
|
+
abstract change(name: string, description: string): Promise<void>;
|
447
|
+
}
|
448
|
+
}
|
449
|
+
declare module "src/storages/workspaces/workspaces" {
|
450
|
+
import { EventDispatcher } from "src/events";
|
451
|
+
import { Workspace } from "src/storages/workspaces/workspace";
|
452
|
+
export type WorkspaceId = string;
|
453
|
+
/**
|
454
|
+
* Workspaces event.
|
455
|
+
*/
|
456
|
+
export enum WorkspacesEvent {
|
457
|
+
ADDED = "added",
|
458
|
+
REMOVED = "removed"
|
459
|
+
}
|
460
|
+
/**
|
461
|
+
* Organization's workspaces.
|
462
|
+
*/
|
463
|
+
export abstract class Workspaces extends EventDispatcher<WorkspacesEvent, Workspace> {
|
464
|
+
/**
|
465
|
+
* Workspaces.
|
466
|
+
*/
|
467
|
+
abstract get collection(): ReadonlyArray<Workspace>;
|
468
|
+
/**
|
469
|
+
* Get workspace by id.
|
470
|
+
* @param id
|
471
|
+
*/
|
472
|
+
abstract get(id: WorkspaceId): Workspace;
|
473
|
+
/**
|
474
|
+
* Try to get workspace by id.
|
475
|
+
* @param id
|
476
|
+
*/
|
477
|
+
abstract tryGet(id: WorkspaceId): Workspace | undefined;
|
478
|
+
/**
|
479
|
+
* Check if workspace exists.
|
480
|
+
* @param id
|
481
|
+
*/
|
482
|
+
abstract contains(id: WorkspaceId): boolean;
|
483
|
+
/**
|
484
|
+
* Create workspace.
|
485
|
+
*/
|
486
|
+
abstract create(name: string, description: string, regulation?: {
|
487
|
+
isCreateNewGroup: boolean;
|
488
|
+
newGroupName: string;
|
489
|
+
groupIds: string[];
|
490
|
+
}): Promise<Workspace>;
|
491
|
+
/**
|
492
|
+
* Delete workspace.
|
493
|
+
*/
|
494
|
+
abstract delete(id: WorkspaceId): Promise<void>;
|
495
|
+
}
|
496
|
+
}
|
497
|
+
declare module "src/dto/userInfoResponse" {
|
498
|
+
import { WorkspaceDto } from "src/dto/workspacesResponse";
|
499
|
+
export interface UserInfoResponse {
|
500
|
+
adminInOrganization: string[];
|
501
|
+
organizations: OrganizationDto[];
|
502
|
+
user: UserDto;
|
503
|
+
}
|
504
|
+
export interface UserDto {
|
505
|
+
id: string;
|
506
|
+
isDeleted: boolean;
|
507
|
+
created_at: number;
|
508
|
+
modified_at: number;
|
509
|
+
profile: ProfileDto;
|
510
|
+
settings?: UserSettings | null;
|
511
|
+
}
|
512
|
+
export interface ProfileDto {
|
513
|
+
name: string;
|
514
|
+
email: string;
|
515
|
+
}
|
516
|
+
export interface UserSettings {
|
517
|
+
activeOrganizationId: string;
|
518
|
+
activeWorkspaceId: string;
|
519
|
+
}
|
520
|
+
export interface OrganizationProfileDto {
|
521
|
+
name: string;
|
522
|
+
description: string;
|
523
|
+
}
|
524
|
+
export interface OrganizationDto {
|
525
|
+
id: string;
|
526
|
+
createdAt: number;
|
527
|
+
modifiedAt: number;
|
528
|
+
membersCount: number;
|
529
|
+
profile: OrganizationProfileDto;
|
530
|
+
}
|
531
|
+
export interface OrganizationWorkspaces extends OrganizationDto {
|
532
|
+
workspaces: WorkspaceDto[];
|
533
|
+
}
|
534
|
+
export interface MembersResponse {
|
535
|
+
members: UserDto;
|
536
|
+
}
|
537
|
+
}
|
538
|
+
declare module "src/dto/accessGroupResponse" {
|
539
|
+
import { UserDto } from "src/dto/userInfoResponse";
|
540
|
+
export interface PermitsDto {
|
541
|
+
isAdmin: boolean;
|
542
|
+
}
|
543
|
+
export interface RegulationDto {
|
544
|
+
isRegulateOrganization: boolean;
|
545
|
+
regulateWorkspaceIds: string[];
|
546
|
+
}
|
547
|
+
export interface AccessGroupDto {
|
548
|
+
id: string;
|
549
|
+
name: string;
|
550
|
+
type: number;
|
551
|
+
createdAt: number;
|
552
|
+
modifiedAt: number;
|
553
|
+
organizationId: string;
|
554
|
+
permits: PermitsDto;
|
555
|
+
regulation: RegulationDto;
|
556
|
+
membersCount: number;
|
557
|
+
}
|
558
|
+
export interface AccessGroupResponse {
|
559
|
+
group: AccessGroupDto;
|
560
|
+
members: UserDto[];
|
561
|
+
}
|
562
|
+
export interface AccessGroupsResponse {
|
563
|
+
groups: AccessGroupDto[];
|
564
|
+
}
|
565
|
+
}
|
566
|
+
declare module "src/storages/groups/groups" {
|
567
|
+
import { AccessGroupDto } from "src/dto/accessGroupResponse";
|
568
|
+
import { UserDto } from "src/dto/userInfoResponse";
|
569
|
+
import { WorkspaceDto } from "src/dto/workspacesResponse";
|
570
|
+
import { EventDispatcher } from "src/events";
|
571
|
+
import { OrganizationId } from "src/storages/organizations/organizations";
|
572
|
+
import { Organization } from "src/storages/organizations/organization";
|
573
|
+
/**
|
574
|
+
* Group id.
|
575
|
+
*/
|
576
|
+
export type GroupId = string;
|
577
|
+
/**
|
578
|
+
* Group event.
|
579
|
+
*/
|
580
|
+
export enum GroupEvent {
|
581
|
+
ADDED = "added",
|
582
|
+
REMOVED = "removed",
|
583
|
+
UPDATED = "updated"
|
584
|
+
}
|
585
|
+
/**
|
586
|
+
* Group.
|
587
|
+
*/
|
588
|
+
export abstract class Group extends EventDispatcher<GroupEvent, Group> {
|
589
|
+
/**
|
590
|
+
* Group id.
|
591
|
+
*/
|
592
|
+
abstract get id(): GroupId;
|
593
|
+
/**
|
594
|
+
* Group information.
|
595
|
+
*/
|
596
|
+
abstract get group(): AccessGroupDto;
|
597
|
+
/**
|
598
|
+
* Group members.
|
599
|
+
*/
|
600
|
+
abstract get members(): UserDto[];
|
601
|
+
/**
|
602
|
+
* Group workspaces.
|
603
|
+
*/
|
604
|
+
abstract getWorkspaces(): Promise<WorkspaceDto[]>;
|
605
|
+
/**
|
606
|
+
* Set workspaces.
|
607
|
+
*/
|
608
|
+
abstract setWorkspaces(workspaces: string[]): Promise<void>;
|
609
|
+
/**
|
610
|
+
* Set name.
|
611
|
+
*/
|
612
|
+
abstract setName(name: string): Promise<void>;
|
613
|
+
/**
|
614
|
+
* Set permits.
|
615
|
+
*/
|
616
|
+
abstract setPermits(permits: {
|
617
|
+
isAdmin: boolean;
|
618
|
+
}): Promise<void>;
|
619
|
+
/**
|
620
|
+
* Set members.
|
621
|
+
*/
|
622
|
+
abstract setMembersIds(members: string[]): Promise<void>;
|
623
|
+
}
|
624
|
+
/**
|
625
|
+
* Groups storage.
|
626
|
+
*/
|
627
|
+
export abstract class Groups extends EventDispatcher<GroupEvent, Group> {
|
628
|
+
/**
|
629
|
+
* Organization.
|
630
|
+
*/
|
631
|
+
abstract get organization(): Organization;
|
632
|
+
/**
|
633
|
+
* Create new group.
|
634
|
+
* @param name
|
635
|
+
* @param organizationId
|
636
|
+
* @param permits
|
637
|
+
* @param memberIds
|
638
|
+
*/
|
639
|
+
abstract create(name: string, organizationId: OrganizationId, permits: {
|
640
|
+
isAdmin: boolean;
|
641
|
+
}, memberIds: string[]): Promise<Group>;
|
642
|
+
/**
|
643
|
+
* Get group by id.
|
644
|
+
* @param id
|
645
|
+
*/
|
646
|
+
abstract get(id: GroupId): Group | undefined;
|
647
|
+
/**
|
648
|
+
* delete group by id.
|
649
|
+
* @param id
|
650
|
+
*/
|
651
|
+
abstract delete(id: GroupId): Promise<void>;
|
652
|
+
}
|
653
|
+
}
|
654
|
+
declare module "src/dto/chatResponse" {
|
655
|
+
export interface SourceDto {
|
656
|
+
id: string;
|
657
|
+
name: string;
|
658
|
+
url: string;
|
659
|
+
content: string;
|
660
|
+
page: number;
|
661
|
+
}
|
662
|
+
export interface AnswerDto {
|
663
|
+
id: string;
|
664
|
+
chatId: string;
|
665
|
+
question: string;
|
666
|
+
context: string;
|
667
|
+
sources: SourceDto[];
|
668
|
+
timestamp: number;
|
669
|
+
}
|
670
|
+
export interface ChatDto {
|
671
|
+
id: string;
|
672
|
+
name: string;
|
673
|
+
createdAt: number;
|
674
|
+
modifiedAt: number;
|
675
|
+
userId: string;
|
676
|
+
organizationId: string;
|
677
|
+
workspaceId: string;
|
678
|
+
answers: AnswerDto[];
|
679
|
+
}
|
680
|
+
export interface ChatListResponse {
|
681
|
+
chats: ChatDto[];
|
682
|
+
}
|
683
|
+
export enum AnswerStatus {
|
684
|
+
RUNNING = 0,
|
685
|
+
SUCCESS = 1,
|
686
|
+
CANCELED = 2,
|
687
|
+
FAIL = 3
|
688
|
+
}
|
689
|
+
export interface AnswerStepDto {
|
690
|
+
id: string;
|
691
|
+
type: StepType;
|
692
|
+
status: StepStatus;
|
693
|
+
start_at: string;
|
694
|
+
end_at: string;
|
695
|
+
tokens: string[];
|
696
|
+
sources: SourceDto[];
|
697
|
+
}
|
698
|
+
export interface FetchAnswerResponse {
|
699
|
+
id: string;
|
700
|
+
status: AnswerStatus;
|
701
|
+
steps: AnswerStepDto[];
|
702
|
+
}
|
703
|
+
export interface FetchTokensResponse {
|
704
|
+
id: string;
|
705
|
+
step_id: string;
|
706
|
+
step_status: number;
|
707
|
+
step_tokens: string[];
|
708
|
+
}
|
709
|
+
export interface AnswerSourcesResponse {
|
710
|
+
chat_uid: string;
|
711
|
+
uid: string;
|
712
|
+
step_id: string;
|
713
|
+
sources: SourceDto[];
|
714
|
+
}
|
715
|
+
export enum StepStatus {
|
716
|
+
RUNNING = 0,
|
717
|
+
SUCCESS = 1,
|
718
|
+
FAIL = 2,
|
719
|
+
CANCELED = 3
|
720
|
+
}
|
721
|
+
export enum StepType {
|
722
|
+
PREPARE = 0,
|
723
|
+
SOURCES = 1,
|
724
|
+
GENERATE_ANSWER = 6,
|
725
|
+
FINALIZE_RESULT = 9,
|
726
|
+
DONE = 10
|
727
|
+
}
|
728
|
+
export class StepTypeInfo {
|
729
|
+
static hasTokens(type: StepType): boolean;
|
730
|
+
static hasSources(type: StepType): boolean;
|
731
|
+
}
|
732
|
+
}
|
733
|
+
declare module "src/storages/chats/answer" {
|
734
|
+
import { AnswerStatus, FetchTokensResponse, SourceDto, StepType } from "src/dto/chatResponse";
|
735
|
+
export type AnswerId = string;
|
736
|
+
export type StepId = string;
|
737
|
+
export abstract class Answer {
|
738
|
+
/**
|
739
|
+
* Answer id.
|
740
|
+
*/
|
741
|
+
abstract get id(): AnswerId;
|
742
|
+
/**
|
743
|
+
* Answer status.
|
744
|
+
*/
|
745
|
+
abstract get status(): AnswerStatus;
|
746
|
+
/**
|
747
|
+
* Answer sources.
|
748
|
+
*/
|
749
|
+
abstract sources(type: StepType): Promise<SourceDto[]>;
|
750
|
+
/**
|
751
|
+
* Fetch answer.
|
752
|
+
*/
|
753
|
+
abstract fetch(): Promise<void>;
|
754
|
+
/**
|
755
|
+
* Fetch answer.
|
756
|
+
*/
|
757
|
+
abstract fetchTokens(type: StepType, tokenStartAt: number): Promise<FetchTokensResponse>;
|
758
|
+
/**
|
759
|
+
* Cancel answer
|
760
|
+
*/
|
761
|
+
abstract cancel(): Promise<void>;
|
762
|
+
}
|
763
|
+
}
|
764
|
+
declare module "src/storages/chats/chat" {
|
765
|
+
import { Answer } from "src/storages/chats/answer";
|
766
|
+
import { Organization } from "src/storages/organizations/organization";
|
767
|
+
export type ChatId = string;
|
768
|
+
export enum ChatAnswerType {
|
769
|
+
SHORT = "short",
|
770
|
+
LONG = "long"
|
771
|
+
}
|
772
|
+
export abstract class Chat {
|
773
|
+
/**
|
774
|
+
* Organization.
|
775
|
+
*/
|
776
|
+
abstract get organization(): Organization;
|
777
|
+
/**
|
778
|
+
* Chat id.
|
779
|
+
*/
|
780
|
+
abstract get id(): ChatId;
|
781
|
+
/**
|
782
|
+
* Chat name.
|
783
|
+
*/
|
784
|
+
abstract get name(): string;
|
785
|
+
/**
|
786
|
+
* Answers list.
|
787
|
+
*/
|
788
|
+
abstract get collection(): ReadonlyArray<Answer>;
|
789
|
+
/**
|
790
|
+
* Ask new question in chat.
|
791
|
+
*/
|
792
|
+
abstract ask(message: string, answerType: ChatAnswerType): Promise<Answer>;
|
793
|
+
}
|
794
|
+
}
|
795
|
+
declare module "src/storages/chats/chats" {
|
796
|
+
import { EventDispatcher } from "src/events";
|
797
|
+
import { Chat, ChatId } from "src/storages/chats/chat";
|
798
|
+
import { Organization } from "src/storages/organizations/organization";
|
799
|
+
export enum ChatsEvent {
|
800
|
+
ADDED = "added",
|
801
|
+
REMOVED = "removed"
|
802
|
+
}
|
803
|
+
/**
|
804
|
+
* Chats storage.
|
805
|
+
*/
|
806
|
+
export abstract class Chats extends EventDispatcher<ChatsEvent, Chat> {
|
807
|
+
/**
|
808
|
+
* Organization.
|
809
|
+
*/
|
810
|
+
abstract get organization(): Organization;
|
811
|
+
/**
|
812
|
+
* Chats list.
|
813
|
+
*/
|
814
|
+
abstract get collection(): ReadonlyArray<Chat>;
|
815
|
+
/**
|
816
|
+
* Create new chat.
|
817
|
+
*/
|
818
|
+
abstract create(): Promise<Chat>;
|
819
|
+
/**
|
820
|
+
* Get chat by id.
|
821
|
+
* @param id
|
822
|
+
*/
|
823
|
+
abstract get(id: ChatId): Chat;
|
824
|
+
/**
|
825
|
+
* Try to get chat by id.
|
826
|
+
* @param id
|
827
|
+
*/
|
828
|
+
abstract tryGet(id: ChatId): Chat | undefined;
|
829
|
+
/**
|
830
|
+
* Delete chat.
|
831
|
+
* @param id
|
832
|
+
*/
|
833
|
+
abstract delete(id: ChatId): Promise<void>;
|
834
|
+
}
|
835
|
+
}
|
836
|
+
declare module "src/storages/organizations/organization" {
|
837
|
+
import { Workspaces } from "src/storages/workspaces/workspaces";
|
838
|
+
import { OrganizationId } from "src/storages/organizations/organizations";
|
839
|
+
import { GroupId, Groups } from "src/storages/groups/groups";
|
840
|
+
import { Chats } from "src/storages/chats/chats";
|
841
|
+
/**
|
842
|
+
* Organization.
|
843
|
+
*/
|
844
|
+
export abstract class Organization {
|
845
|
+
/**
|
846
|
+
* Organization id.
|
847
|
+
*/
|
848
|
+
abstract get id(): OrganizationId;
|
849
|
+
/**
|
850
|
+
* Organization name.
|
851
|
+
*/
|
852
|
+
abstract get name(): string;
|
853
|
+
/**
|
854
|
+
* Organization description.
|
855
|
+
*/
|
856
|
+
abstract get description(): string;
|
857
|
+
/**
|
858
|
+
* Workspaces.
|
859
|
+
*/
|
860
|
+
abstract get workspaces(): Workspaces;
|
861
|
+
/**
|
862
|
+
* Chats.
|
863
|
+
*/
|
864
|
+
abstract get chats(): Chats;
|
865
|
+
/**
|
866
|
+
* Groups.
|
867
|
+
*/
|
868
|
+
abstract get accessGroups(): Groups;
|
869
|
+
/**
|
870
|
+
* Create invite link
|
871
|
+
*/
|
872
|
+
abstract createInviteLink(emails: string[], accessGroups: GroupId[]): Promise<void>;
|
873
|
+
}
|
874
|
+
}
|
875
|
+
declare module "src/storages/organizations/organizations" {
|
876
|
+
import { EventDispatcher } from "src/events";
|
877
|
+
import { Organization } from "src/storages/organizations/organization";
|
878
|
+
/**
|
879
|
+
* Organization id.
|
880
|
+
*/
|
881
|
+
export type OrganizationId = string;
|
882
|
+
/**
|
883
|
+
* Organization event.
|
884
|
+
*/
|
885
|
+
export enum OrganizationsEvent {
|
886
|
+
ADDED = "added",
|
887
|
+
REMOVED = "removed",
|
888
|
+
CURRENT_CHANGED = "currentChanged"
|
889
|
+
}
|
890
|
+
/**
|
891
|
+
* Organizations storage.
|
892
|
+
*/
|
893
|
+
export abstract class Organizations extends EventDispatcher<OrganizationsEvent, Organization> {
|
894
|
+
/**
|
895
|
+
* User's organizations.
|
896
|
+
*/
|
897
|
+
abstract get collection(): ReadonlyArray<Organization>;
|
898
|
+
/**
|
899
|
+
* Current organization.
|
900
|
+
*/
|
901
|
+
abstract get current(): OrganizationId;
|
902
|
+
abstract set current(value: OrganizationId);
|
903
|
+
/**
|
904
|
+
* Get organization by id.
|
905
|
+
*/
|
906
|
+
abstract get(id: OrganizationId): Organization;
|
907
|
+
/**
|
908
|
+
* Try to get organization by id.
|
909
|
+
* @param id
|
910
|
+
*/
|
911
|
+
abstract tryGet(id: OrganizationId): Organization | undefined;
|
912
|
+
/**
|
913
|
+
* Create new organization.
|
914
|
+
*/
|
915
|
+
abstract create(name: string, description: string): Promise<Organization>;
|
916
|
+
/**
|
917
|
+
* Delete organization.
|
918
|
+
*/
|
919
|
+
abstract delete(id: OrganizationId): Promise<void>;
|
920
|
+
}
|
921
|
+
}
|
922
|
+
declare module "src/storages/user/userProfile" {
|
923
|
+
import { EventDispatcher } from "src/events";
|
924
|
+
export type UserId = string;
|
925
|
+
export enum UserEvent {
|
926
|
+
CHANGED = "changed"
|
927
|
+
}
|
928
|
+
export abstract class UserProfile extends EventDispatcher<UserEvent, UserProfile> {
|
929
|
+
/**
|
930
|
+
* User id.
|
931
|
+
*/
|
932
|
+
abstract get id(): UserId;
|
933
|
+
/**
|
934
|
+
* User name.
|
935
|
+
*/
|
936
|
+
abstract get name(): string;
|
937
|
+
/**
|
938
|
+
* User email.
|
939
|
+
*/
|
940
|
+
abstract get email(): string;
|
941
|
+
/**
|
942
|
+
* Is user deleted.
|
943
|
+
*/
|
944
|
+
abstract get isDeleted(): boolean;
|
945
|
+
/**
|
946
|
+
* Created at.
|
947
|
+
*/
|
948
|
+
abstract get createdAt(): Date;
|
949
|
+
/**
|
950
|
+
* Modified at.
|
951
|
+
*/
|
952
|
+
abstract get modifiedAt(): Date;
|
953
|
+
}
|
954
|
+
}
|
955
|
+
declare module "src/dataIslandApp" {
|
956
|
+
import type { Lifetime } from "src/disposable";
|
957
|
+
import type { CredentialBase } from "src/credentials";
|
958
|
+
import { Context } from "src/context";
|
959
|
+
import type { Constructor } from "src/internal/registry";
|
960
|
+
import { Organizations } from "src/storages/organizations/organizations";
|
961
|
+
import { UserProfile } from "src/storages/user/userProfile";
|
962
|
+
/**
|
963
|
+
* DataIsland App instance.
|
964
|
+
*/
|
965
|
+
export abstract class DataIslandApp {
|
966
|
+
/**
|
967
|
+
* The name of this app.
|
968
|
+
*/
|
969
|
+
abstract get name(): string;
|
970
|
+
/**
|
971
|
+
* The host of this app.
|
972
|
+
*/
|
973
|
+
abstract get host(): string;
|
974
|
+
/**
|
975
|
+
* The automaticDataCollectionEnabled of this app.
|
976
|
+
*/
|
977
|
+
abstract get automaticDataCollectionEnabled(): boolean;
|
978
|
+
/**
|
979
|
+
* The lifetime of this app.
|
980
|
+
*/
|
981
|
+
abstract get lifetime(): Lifetime;
|
982
|
+
/**
|
983
|
+
* The credential of this app.
|
984
|
+
*/
|
985
|
+
abstract get credential(): CredentialBase | undefined;
|
986
|
+
abstract set credential(value: CredentialBase);
|
987
|
+
/**
|
988
|
+
* The context of this app.
|
989
|
+
*/
|
990
|
+
abstract get context(): Context;
|
991
|
+
/**
|
992
|
+
* User's organizations.
|
993
|
+
*/
|
994
|
+
abstract get organizations(): Organizations;
|
995
|
+
/**
|
996
|
+
* User's profile.
|
997
|
+
*/
|
998
|
+
abstract get userProfile(): UserProfile;
|
999
|
+
/**
|
1000
|
+
* Resolve a service from the app.
|
1001
|
+
* @param type
|
1002
|
+
*/
|
1003
|
+
abstract resolve<T>(type: Constructor<T>): T | undefined;
|
1004
|
+
}
|
1005
|
+
}
|
1006
|
+
declare module "src/unitTest" {
|
1007
|
+
export enum UnitTest {
|
1008
|
+
DO_NOTHING = 0,
|
1009
|
+
DO_NOT_START = 1,
|
1010
|
+
DO_NOT_PRINT_INITIALIZED_LOG = 2,
|
1011
|
+
DEFAULT = 3
|
1012
|
+
}
|
1013
|
+
export type UnitTestProfileSyncAction = () => void;
|
1014
|
+
export type UnitTestProfileAsyncAction = () => Promise<void>;
|
1015
|
+
export const appTest: (unitTest: UnitTest | undefined, func: UnitTestProfileSyncAction | UnitTestProfileAsyncAction) => Promise<void>;
|
1016
|
+
export const appTestCurrent: () => UnitTest;
|
1017
|
+
export const isUnitTest: (mask: UnitTest) => boolean;
|
1018
|
+
}
|
1019
|
+
declare module "src/internal/appBuilder.impl" {
|
1020
|
+
import { AppBuilder } from "src/appBuilder";
|
1021
|
+
import { type CredentialBase } from "src/credentials";
|
1022
|
+
import type { Middleware } from "src/middleware";
|
1023
|
+
import { type Service, type ServiceContext } from "src/services/service";
|
1024
|
+
import { type Constructor } from "src/internal/registry";
|
1025
|
+
import { Command, CommandHandler } from "src/services/commandService";
|
1026
|
+
import { Context } from "src/context";
|
1027
|
+
export class AppBuilderImplementation extends AppBuilder {
|
1028
|
+
envData: Record<string, any>;
|
1029
|
+
host: string;
|
1030
|
+
automaticDataCollectionEnabled: boolean;
|
1031
|
+
credential: CredentialBase;
|
1032
|
+
middlewares: Middleware[];
|
1033
|
+
services: Array<[Constructor<any>, (context: ServiceContext) => Service]>;
|
1034
|
+
commands: Array<[
|
1035
|
+
Constructor<any>,
|
1036
|
+
(context: Context) => CommandHandler<any>
|
1037
|
+
]>;
|
1038
|
+
get env(): Record<string, any>;
|
1039
|
+
useHost(host: string): AppBuilder;
|
1040
|
+
useAutomaticDataCollectionEnabled(value: boolean): AppBuilder;
|
1041
|
+
useCredential(credential: CredentialBase): AppBuilder;
|
1042
|
+
registerMiddleware(middleware: Middleware): AppBuilder;
|
1043
|
+
registerService<T extends Service>(type: Constructor<T>, factory: (context: ServiceContext) => T): AppBuilder;
|
1044
|
+
registerCommand<T extends Command>(messageType: Constructor<T>, commandFactory: (context: Context) => CommandHandler<T>): AppBuilder;
|
1045
|
+
}
|
1046
|
+
}
|
1047
|
+
declare module "src/services/credentialService" {
|
1048
|
+
import { type CredentialBase } from "src/credentials";
|
1049
|
+
import { Service } from "src/services/service";
|
1050
|
+
export class CredentialService extends Service {
|
1051
|
+
private _credentialDispose?;
|
1052
|
+
private _credential?;
|
1053
|
+
get credential(): CredentialBase | undefined;
|
1054
|
+
useCredential(credential: CredentialBase): void;
|
1055
|
+
}
|
1056
|
+
}
|
1057
|
+
declare module "src/services/requestBuilder" {
|
1058
|
+
export class RequestBuilder {
|
1059
|
+
private readonly _url;
|
1060
|
+
private readonly _request;
|
1061
|
+
private readonly _headers;
|
1062
|
+
private readonly _searchParams;
|
1063
|
+
constructor(_url: URL, _request: (req: Request) => Promise<Response>);
|
1064
|
+
header(name: string, value: string): RequestBuilder;
|
1065
|
+
headers(headers?: [string, string][] | Record<string, string> | Headers): RequestBuilder;
|
1066
|
+
searchParam(name: string, value: string): RequestBuilder;
|
1067
|
+
searchParams(searchParams?: Map<string, string>): RequestBuilder;
|
1068
|
+
sendPostFormData(body: FormData): Promise<Response>;
|
1069
|
+
sendPostJson(body: object | null | undefined): Promise<Response>;
|
1070
|
+
sendGet(): Promise<Response>;
|
1071
|
+
sendDelete(): Promise<Response>;
|
1072
|
+
sendPutJson(body: object | null | undefined): Promise<Response>;
|
1073
|
+
}
|
1074
|
+
}
|
1075
|
+
declare module "src/services/rpcService" {
|
1076
|
+
import { Service, type ServiceContext } from "src/services/service";
|
1077
|
+
import { RequestBuilder } from "src/services/requestBuilder";
|
1078
|
+
/**
|
1079
|
+
* Options for the RpcService.
|
1080
|
+
*/
|
1081
|
+
export interface RequestOptions {
|
1082
|
+
searchParams?: Map<string, string>;
|
1083
|
+
headers?: [string, string][] | Record<string, string> | Headers;
|
1084
|
+
}
|
1085
|
+
/**
|
1086
|
+
* RPC service.
|
1087
|
+
*/
|
1088
|
+
export class RpcService extends Service {
|
1089
|
+
/**
|
1090
|
+
* Host of the RPC service.
|
1091
|
+
* It is not used if you use the `urlBuilder` option.
|
1092
|
+
*/
|
1093
|
+
readonly host: string;
|
1094
|
+
/**
|
1095
|
+
* Options for the RpcService.
|
1096
|
+
*/
|
1097
|
+
private readonly options?;
|
1098
|
+
constructor(serviceContext: ServiceContext,
|
1099
|
+
/**
|
1100
|
+
* Host of the RPC service.
|
1101
|
+
* It is not used if you use the `urlBuilder` option.
|
1102
|
+
*/
|
1103
|
+
host: string,
|
1104
|
+
/**
|
1105
|
+
* Options for the RpcService.
|
1106
|
+
*/
|
1107
|
+
options?: {
|
1108
|
+
urlBuilder?: ((path: string) => URL) | undefined;
|
1109
|
+
fetchMethod?: ((uri: Request) => Promise<Response>) | undefined;
|
1110
|
+
} | undefined);
|
1111
|
+
/**
|
1112
|
+
* Request method.
|
1113
|
+
*/
|
1114
|
+
request(req: Request): Promise<Response>;
|
1115
|
+
/**
|
1116
|
+
* Build URL.
|
1117
|
+
* @param path
|
1118
|
+
*/
|
1119
|
+
buildUrl(path: string): URL;
|
1120
|
+
/**
|
1121
|
+
* Create a request builder.
|
1122
|
+
* @param path
|
1123
|
+
*/
|
1124
|
+
requestBuilder(path: string): RequestBuilder;
|
1125
|
+
/**
|
1126
|
+
* Send a GET request.
|
1127
|
+
* @param path
|
1128
|
+
* @param options
|
1129
|
+
*/
|
1130
|
+
get(path: string, options?: RequestOptions): Promise<Response>;
|
1131
|
+
/**
|
1132
|
+
* Send a POST request.
|
1133
|
+
* @param path
|
1134
|
+
* @param body JSON object
|
1135
|
+
* @param options
|
1136
|
+
*/
|
1137
|
+
post(path: string, body: object | null | undefined, options?: RequestOptions): Promise<Response>;
|
1138
|
+
/**
|
1139
|
+
* Send a PUT request.
|
1140
|
+
* @param path
|
1141
|
+
* @param body JSON object
|
1142
|
+
* @param options
|
1143
|
+
*/
|
1144
|
+
put(path: string, body: object | null | undefined, options?: RequestOptions): Promise<Response>;
|
1145
|
+
/**
|
1146
|
+
* Send a DELETE request.
|
1147
|
+
* @param path
|
1148
|
+
* @param options
|
1149
|
+
*/
|
1150
|
+
delete(path: string, options?: RequestOptions): Promise<Response>;
|
1151
|
+
}
|
1152
|
+
}
|
1153
|
+
declare module "src/services/responseUtils" {
|
1154
|
+
export class ResponseUtils {
|
1155
|
+
static isOk(response?: Response | null): boolean;
|
1156
|
+
static isFail(response?: Response | null): boolean;
|
1157
|
+
static throwError(message: string, response: Response | undefined | null): Promise<void>;
|
1158
|
+
}
|
1159
|
+
}
|
1160
|
+
declare module "src/storages/files/file.impl" {
|
1161
|
+
import { Context } from "src/context";
|
1162
|
+
import { Disposable } from "src/disposable";
|
1163
|
+
import { FileDto, FileProgressDto } from "src/dto/workspacesResponse";
|
1164
|
+
import { File } from "src/storages/files/file";
|
1165
|
+
export class FileImpl extends File implements Disposable {
|
1166
|
+
private readonly context;
|
1167
|
+
private _isDisposed;
|
1168
|
+
private _content?;
|
1169
|
+
constructor(context: Context);
|
1170
|
+
initFrom(file: FileDto): File;
|
1171
|
+
get isDisposed(): boolean;
|
1172
|
+
dispose(): void;
|
1173
|
+
get id(): string;
|
1174
|
+
get name(): string;
|
1175
|
+
url(): Promise<string>;
|
1176
|
+
status(): Promise<FileProgressDto>;
|
1177
|
+
}
|
1178
|
+
}
|
1179
|
+
declare module "src/storages/files/files.impl" {
|
1180
|
+
import { Context } from "src/context";
|
1181
|
+
import { Disposable } from "src/disposable";
|
1182
|
+
import { Files, UploadFile } from "src/storages/files/files";
|
1183
|
+
import { WorkspaceImpl } from "src/storages/workspaces/workspace.impl";
|
1184
|
+
import { File } from "src/storages/files/file";
|
1185
|
+
import { FilesPage } from "src/storages/files/filesPage";
|
1186
|
+
export class FilesPageImpl extends FilesPage implements Disposable {
|
1187
|
+
private _isDisposed;
|
1188
|
+
files: File[];
|
1189
|
+
total: number;
|
1190
|
+
filesPerPage: number;
|
1191
|
+
page: number;
|
1192
|
+
get pages(): number;
|
1193
|
+
get isDisposed(): boolean;
|
1194
|
+
dispose(): void;
|
1195
|
+
}
|
1196
|
+
export class FilesImpl extends Files {
|
1197
|
+
private readonly workspace;
|
1198
|
+
private readonly context;
|
1199
|
+
constructor(workspace: WorkspaceImpl, context: Context);
|
1200
|
+
filesList?: FilesPage;
|
1201
|
+
upload(file: any): Promise<File>;
|
1202
|
+
delete(id: string): Promise<void>;
|
1203
|
+
query(query: string, page: number, limit: number): Promise<FilesPage>;
|
1204
|
+
/**
|
1205
|
+
* Delete organization.
|
1206
|
+
* @param id
|
1207
|
+
*/
|
1208
|
+
internalDeleteFile(id: string): Promise<void>;
|
1209
|
+
internalQuery(query: string, page: number, limit: number): Promise<FilesPage>;
|
1210
|
+
internalUpload(file: UploadFile): Promise<File>;
|
1211
|
+
}
|
1212
|
+
}
|
1213
|
+
declare module "src/storages/workspaces/workspace.impl" {
|
1214
|
+
import { Context } from "src/context";
|
1215
|
+
import { Files } from "src/storages/files/files";
|
1216
|
+
import { Workspace } from "src/storages/workspaces/workspace";
|
1217
|
+
import { OrganizationImpl } from "src/storages/organizations/organization.impl";
|
1218
|
+
import { WorkspaceDto } from "src/dto/workspacesResponse";
|
1219
|
+
export class WorkspaceImpl extends Workspace {
|
1220
|
+
readonly organization: OrganizationImpl;
|
1221
|
+
readonly context: Context;
|
1222
|
+
private _isMarkAsDeleted;
|
1223
|
+
private _workspace?;
|
1224
|
+
private readonly _files;
|
1225
|
+
constructor(organization: OrganizationImpl, context: Context);
|
1226
|
+
get id(): string;
|
1227
|
+
get name(): string;
|
1228
|
+
get description(): string;
|
1229
|
+
get files(): Files;
|
1230
|
+
change(name: string, description: string): Promise<void>;
|
1231
|
+
initFrom(workspace: WorkspaceDto): Promise<void>;
|
1232
|
+
get isMarkAsDeleted(): boolean;
|
1233
|
+
markToDelete(): void;
|
1234
|
+
}
|
1235
|
+
}
|
1236
|
+
declare module "src/storages/workspaces/workspaces.impl" {
|
1237
|
+
import { WorkspaceId, Workspaces } from "src/storages/workspaces/workspaces";
|
1238
|
+
import { OrganizationImpl } from "src/storages/organizations/organization.impl";
|
1239
|
+
import { Context } from "src/context";
|
1240
|
+
import { Workspace } from "src/storages/workspaces/workspace";
|
1241
|
+
import { OrganizationId } from "src/storages/organizations/organizations";
|
1242
|
+
export class WorkspacesImpl extends Workspaces {
|
1243
|
+
private readonly organization;
|
1244
|
+
private readonly context;
|
1245
|
+
private readonly _workspaces;
|
1246
|
+
constructor(organization: OrganizationImpl, context: Context);
|
1247
|
+
get collection(): readonly Workspace[];
|
1248
|
+
get(id: string): Workspace;
|
1249
|
+
tryGet(id: string): Workspace | undefined;
|
1250
|
+
contains(id: string): boolean;
|
1251
|
+
/**
|
1252
|
+
* Create workspace.
|
1253
|
+
* @param name
|
1254
|
+
* @param description
|
1255
|
+
* @param regulation
|
1256
|
+
*/
|
1257
|
+
create(name: string, description: string, regulation?: {
|
1258
|
+
isCreateNewGroup: boolean;
|
1259
|
+
newGroupName: string;
|
1260
|
+
groupIds: string[];
|
1261
|
+
}): Promise<Workspace>;
|
1262
|
+
/**
|
1263
|
+
* Delete workspace.
|
1264
|
+
* @param id
|
1265
|
+
*/
|
1266
|
+
delete(id: WorkspaceId): Promise<void>;
|
1267
|
+
initFrom(organizationId: OrganizationId): Promise<void>;
|
1268
|
+
}
|
1269
|
+
}
|
1270
|
+
declare module "src/storages/groups/groups.impl" {
|
1271
|
+
import { Context } from "src/context";
|
1272
|
+
import { Disposable } from "src/disposable";
|
1273
|
+
import { AccessGroupDto } from "src/dto/accessGroupResponse";
|
1274
|
+
import { UserDto } from "src/dto/userInfoResponse";
|
1275
|
+
import { WorkspaceDto } from "src/dto/workspacesResponse";
|
1276
|
+
import { Group, GroupId, Groups } from "src/storages/groups/groups";
|
1277
|
+
import { OrganizationImpl } from "src/storages/organizations/organization.impl";
|
1278
|
+
import { OrganizationId } from "src/storages/organizations/organizations";
|
1279
|
+
import { Organization } from "src/storages/organizations/organization";
|
1280
|
+
export class GroupImpl extends Group implements Disposable {
|
1281
|
+
private readonly context;
|
1282
|
+
readonly organization: Organization;
|
1283
|
+
private _isDisposed;
|
1284
|
+
private _content?;
|
1285
|
+
private _members?;
|
1286
|
+
constructor(context: Context, organization: Organization);
|
1287
|
+
initFrom(id: GroupId): Promise<Group>;
|
1288
|
+
get id(): GroupId;
|
1289
|
+
get group(): AccessGroupDto;
|
1290
|
+
getWorkspaces(): Promise<WorkspaceDto[]>;
|
1291
|
+
get members(): UserDto[];
|
1292
|
+
setName(name: string): Promise<void>;
|
1293
|
+
setPermits(permits: {
|
1294
|
+
isAdmin: boolean;
|
1295
|
+
}): Promise<void>;
|
1296
|
+
setWorkspaces(workspaces: string[]): Promise<void>;
|
1297
|
+
setMembersIds(members: string[]): Promise<void>;
|
1298
|
+
get isDisposed(): boolean;
|
1299
|
+
dispose(): void;
|
1300
|
+
}
|
1301
|
+
export class GroupsImpl extends Groups {
|
1302
|
+
readonly organization: OrganizationImpl;
|
1303
|
+
private readonly context;
|
1304
|
+
private _groups;
|
1305
|
+
constructor(organization: OrganizationImpl, context: Context);
|
1306
|
+
initialize(): Promise<void>;
|
1307
|
+
create(name: string, organizationId: OrganizationId, permits: {
|
1308
|
+
isAdmin: boolean;
|
1309
|
+
}, memberIds: string[]): Promise<Group>;
|
1310
|
+
get(id: GroupId): Group | undefined;
|
1311
|
+
delete(id: GroupId): Promise<void>;
|
1312
|
+
/**
|
1313
|
+
* Init access groups.
|
1314
|
+
*/
|
1315
|
+
internalInit(): Promise<void>;
|
1316
|
+
internalCreate(name: string, organizationId: OrganizationId, permits: {
|
1317
|
+
isAdmin: boolean;
|
1318
|
+
}, memberIds: string[]): Promise<Group>;
|
1319
|
+
/**
|
1320
|
+
* Delete group.
|
1321
|
+
* @param id
|
1322
|
+
*/
|
1323
|
+
internalDeleteGroup(id: GroupId): Promise<void>;
|
1324
|
+
}
|
1325
|
+
}
|
1326
|
+
declare module "src/storages/chats/answer.impl" {
|
1327
|
+
import { Context } from "src/context";
|
1328
|
+
import { AnswerDto, AnswerStatus, FetchTokensResponse, SourceDto, StepType } from "src/dto/chatResponse";
|
1329
|
+
import { Answer, AnswerId } from "src/storages/chats/answer";
|
1330
|
+
import { Chat } from "src/storages/chats/chat";
|
1331
|
+
export class AnswerImpl extends Answer {
|
1332
|
+
private readonly chat;
|
1333
|
+
private readonly context;
|
1334
|
+
private _content?;
|
1335
|
+
private _steps?;
|
1336
|
+
private _status?;
|
1337
|
+
private _id?;
|
1338
|
+
constructor(chat: Chat, context: Context);
|
1339
|
+
initFromData(answer: AnswerDto): Promise<AnswerImpl>;
|
1340
|
+
initFromId(id: AnswerId): Promise<AnswerImpl>;
|
1341
|
+
get id(): string;
|
1342
|
+
get status(): AnswerStatus;
|
1343
|
+
private getStep;
|
1344
|
+
sources(type: StepType): Promise<SourceDto[]>;
|
1345
|
+
fetch(): Promise<void>;
|
1346
|
+
fetchTokens(type: StepType, token_start_at: number): Promise<FetchTokensResponse>;
|
1347
|
+
cancel(): Promise<void>;
|
1348
|
+
}
|
1349
|
+
}
|
1350
|
+
declare module "src/storages/chats/chat.impl" {
|
1351
|
+
import { Chat, ChatAnswerType } from "src/storages/chats/chat";
|
1352
|
+
import { Disposable } from "src/disposable";
|
1353
|
+
import { Answer } from "src/storages/chats/answer";
|
1354
|
+
import { ChatDto } from "src/dto/chatResponse";
|
1355
|
+
import { Context } from "src/context";
|
1356
|
+
import { Organization } from "src/storages/organizations/organization";
|
1357
|
+
export class ChatImpl extends Chat implements Disposable {
|
1358
|
+
private readonly context;
|
1359
|
+
readonly organization: Organization;
|
1360
|
+
private _isDisposed;
|
1361
|
+
private readonly _answers;
|
1362
|
+
private _content?;
|
1363
|
+
constructor(context: Context, organization: Organization);
|
1364
|
+
initFrom(chat: ChatDto): Promise<ChatImpl>;
|
1365
|
+
get id(): string;
|
1366
|
+
get name(): string;
|
1367
|
+
get collection(): readonly Answer[];
|
1368
|
+
get isDisposed(): boolean;
|
1369
|
+
ask(message: string, answerType: ChatAnswerType): Promise<Answer>;
|
1370
|
+
dispose(): void;
|
1371
|
+
}
|
1372
|
+
}
|
1373
|
+
declare module "src/storages/chats/chats.impl" {
|
1374
|
+
import { Context } from "src/context";
|
1375
|
+
import { OrganizationImpl } from "src/storages/organizations/organization.impl";
|
1376
|
+
import { OrganizationId } from "src/storages/organizations/organizations";
|
1377
|
+
import { Chat } from "src/storages/chats/chat";
|
1378
|
+
import { Chats } from "src/storages/chats/chats";
|
1379
|
+
export class ChatsImpl extends Chats {
|
1380
|
+
readonly organization: OrganizationImpl;
|
1381
|
+
private readonly context;
|
1382
|
+
private readonly _chats;
|
1383
|
+
constructor(organization: OrganizationImpl, context: Context);
|
1384
|
+
initFrom(organizationId: OrganizationId): Promise<void>;
|
1385
|
+
get collection(): readonly Chat[];
|
1386
|
+
get(id: string): Chat;
|
1387
|
+
tryGet(id: string): Chat | undefined;
|
1388
|
+
create(): Promise<Chat>;
|
1389
|
+
delete(id: string): Promise<void>;
|
1390
|
+
}
|
1391
|
+
}
|
1392
|
+
declare module "src/storages/organizations/organization.impl" {
|
1393
|
+
import { OrganizationId } from "src/storages/organizations/organizations";
|
1394
|
+
import { Disposable } from "src/disposable";
|
1395
|
+
import { OrganizationDto } from "src/dto/userInfoResponse";
|
1396
|
+
import { Workspaces } from "src/storages/workspaces/workspaces";
|
1397
|
+
import { Context } from "src/context";
|
1398
|
+
import { Organization } from "src/storages/organizations/organization";
|
1399
|
+
import { Groups } from "src/storages/groups/groups";
|
1400
|
+
import { Chats } from "src/storages/chats/chats";
|
1401
|
+
export class OrganizationImpl extends Organization implements Disposable {
|
1402
|
+
private readonly context;
|
1403
|
+
private _isDisposed;
|
1404
|
+
private _isAdmin;
|
1405
|
+
private _content?;
|
1406
|
+
private readonly _workspaces;
|
1407
|
+
private readonly _accessGroups;
|
1408
|
+
private readonly _chats;
|
1409
|
+
constructor(context: Context);
|
1410
|
+
initFrom(content: OrganizationDto, isAdmin: boolean): Promise<OrganizationImpl>;
|
1411
|
+
get isAdmin(): boolean;
|
1412
|
+
get isDisposed(): boolean;
|
1413
|
+
dispose(): void;
|
1414
|
+
get id(): OrganizationId;
|
1415
|
+
get name(): string;
|
1416
|
+
get description(): string;
|
1417
|
+
get workspaces(): Workspaces;
|
1418
|
+
get accessGroups(): Groups;
|
1419
|
+
get chats(): Chats;
|
1420
|
+
createInviteLink(emails: string[], accessGroups: string[]): Promise<void>;
|
1421
|
+
}
|
1422
|
+
}
|
1423
|
+
declare module "src/storages/organizations/organizations.impl" {
|
1424
|
+
import { OrganizationId, Organizations } from "src/storages/organizations/organizations";
|
1425
|
+
import { OrganizationImpl } from "src/storages/organizations/organization.impl";
|
1426
|
+
import { OrganizationDto, UserSettings } from "src/dto/userInfoResponse";
|
1427
|
+
import { Context } from "src/context";
|
1428
|
+
import { Organization } from "src/storages/organizations/organization";
|
1429
|
+
export class OrganizationsImpl extends Organizations {
|
1430
|
+
readonly context: Context;
|
1431
|
+
constructor(context: Context);
|
1432
|
+
organizations: OrganizationImpl[];
|
1433
|
+
currentOrganizationId?: OrganizationId;
|
1434
|
+
get collection(): readonly Organization[];
|
1435
|
+
get current(): OrganizationId;
|
1436
|
+
set current(value: OrganizationId);
|
1437
|
+
get(id: OrganizationId): Organization;
|
1438
|
+
tryGet(id: OrganizationId): Organization | undefined;
|
1439
|
+
contains(id: OrganizationId): boolean;
|
1440
|
+
create(name: string, description: string): Promise<Organization>;
|
1441
|
+
delete(id: string): Promise<void>;
|
1442
|
+
/**
|
1443
|
+
* Delete organization.
|
1444
|
+
* @param id
|
1445
|
+
*/
|
1446
|
+
internalDeleteOrganization(id: OrganizationId): Promise<void>;
|
1447
|
+
/**
|
1448
|
+
* Create organization.
|
1449
|
+
* @param name
|
1450
|
+
* @param description
|
1451
|
+
*/
|
1452
|
+
internalCreateOrganization(name: string, description: string): Promise<OrganizationImpl>;
|
1453
|
+
/**
|
1454
|
+
* Init organizations from user profile.
|
1455
|
+
* @param adminInOrganization
|
1456
|
+
* @param organizations
|
1457
|
+
* @param settings
|
1458
|
+
*/
|
1459
|
+
internalInitFrom(adminInOrganization: string[], organizations: OrganizationDto[], settings: UserSettings | null | undefined): Promise<void>;
|
1460
|
+
}
|
1461
|
+
}
|
1462
|
+
declare module "src/services/organizationService" {
|
1463
|
+
import { Service } from "src/services/service";
|
1464
|
+
import { Organizations } from "src/storages/organizations/organizations";
|
1465
|
+
import { OrganizationDto, UserSettings } from "src/dto/userInfoResponse";
|
1466
|
+
export class OrganizationService extends Service {
|
1467
|
+
private _impl?;
|
1468
|
+
private get impl();
|
1469
|
+
get organizations(): Organizations;
|
1470
|
+
initFrom(adminInOrganization: string[], organizations: OrganizationDto[], settings?: UserSettings | null): Promise<void>;
|
1471
|
+
}
|
1472
|
+
}
|
1473
|
+
declare module "src/storages/user/userProfile.impl" {
|
1474
|
+
import { UserProfile } from "src/storages/user/userProfile";
|
1475
|
+
import { UserInfoResponse } from "src/dto/userInfoResponse";
|
1476
|
+
export class UserProfileImpl extends UserProfile {
|
1477
|
+
private content?;
|
1478
|
+
get id(): string;
|
1479
|
+
get name(): string;
|
1480
|
+
get email(): string;
|
1481
|
+
get isDeleted(): boolean;
|
1482
|
+
get createdAt(): Date;
|
1483
|
+
get modifiedAt(): Date;
|
1484
|
+
initFrom(content: UserInfoResponse): void;
|
1485
|
+
}
|
1486
|
+
}
|
1487
|
+
declare module "src/services/userProfileService" {
|
1488
|
+
import { Service } from "src/services/service";
|
1489
|
+
import { UserProfile } from "src/storages/user/userProfile";
|
1490
|
+
export class UserProfileService extends Service {
|
1491
|
+
private readonly impl;
|
1492
|
+
get userProfile(): UserProfile;
|
1493
|
+
fetch(): Promise<void>;
|
1494
|
+
}
|
1495
|
+
}
|
1496
|
+
declare module "src/commands/startCommandHandler" {
|
1497
|
+
import { CommandHandler, Command } from "src/services/commandService";
|
1498
|
+
export class StartCommand extends Command {
|
1499
|
+
}
|
1500
|
+
export class StartCommandHandler extends CommandHandler<StartCommand> {
|
1501
|
+
execute(message: StartCommand): Promise<void>;
|
1502
|
+
}
|
1503
|
+
}
|
1504
|
+
declare module "src/internal/app.impl" {
|
1505
|
+
import { type AppBuilder } from "src/appBuilder";
|
1506
|
+
import { type Constructor } from "src/internal/registry";
|
1507
|
+
import { Context } from "src/context";
|
1508
|
+
import { type Lifetime } from "src/disposable";
|
1509
|
+
import { type CredentialBase } from "src/credentials";
|
1510
|
+
import { DataIslandApp } from "src/dataIslandApp";
|
1511
|
+
import { Organizations } from "src/storages/organizations/organizations";
|
1512
|
+
import { UserProfile } from "src/storages/user/userProfile";
|
1513
|
+
export class DataIslandAppImpl extends DataIslandApp {
|
1514
|
+
readonly name: string;
|
1515
|
+
private _host;
|
1516
|
+
private _automaticDataCollectionEnabled;
|
1517
|
+
private readonly _registry;
|
1518
|
+
private readonly _context;
|
1519
|
+
private readonly _disposable;
|
1520
|
+
constructor(name: string);
|
1521
|
+
get context(): Context;
|
1522
|
+
get credential(): CredentialBase | undefined;
|
1523
|
+
set credential(value: CredentialBase);
|
1524
|
+
get lifetime(): Lifetime;
|
1525
|
+
resolve: <T>(type: Constructor<T>) => T | undefined;
|
1526
|
+
get automaticDataCollectionEnabled(): boolean;
|
1527
|
+
get host(): string;
|
1528
|
+
get organizations(): Organizations;
|
1529
|
+
get userProfile(): UserProfile;
|
1530
|
+
initialize(setup: ((builder: AppBuilder) => Promise<void>) | undefined): Promise<void>;
|
1531
|
+
}
|
1532
|
+
}
|
1533
|
+
declare module "src/internal/createApp.impl" {
|
1534
|
+
import { type AppBuilder } from "src/appBuilder";
|
1535
|
+
import { DataIslandApp } from "src/dataIslandApp";
|
1536
|
+
export function _createApp(name: string, setup?: (builder: AppBuilder) => Promise<void>): Promise<DataIslandApp>;
|
1537
|
+
}
|
1538
|
+
declare module "src/index" {
|
1539
|
+
import { type AppBuilder } from "src/appBuilder";
|
1540
|
+
import { type DataIslandApp } from "src/dataIslandApp";
|
1541
|
+
export * from "src/events";
|
1542
|
+
export * from "src/disposable";
|
1543
|
+
export * from "src/credentials";
|
1544
|
+
export * from "src/dataIslandApp";
|
1545
|
+
export * from "src/appBuilder";
|
1546
|
+
export * from "src/context";
|
1547
|
+
export * from "src/middleware";
|
1548
|
+
export * from "src/storages/organizations/organizations";
|
1549
|
+
export * from "src/storages/organizations/organization";
|
1550
|
+
export * from "src/storages/workspaces/workspaces";
|
1551
|
+
export * from "src/storages/workspaces/workspace";
|
1552
|
+
export * from "src/storages/groups/groups";
|
1553
|
+
export * from "src/storages/user/userProfile";
|
1554
|
+
export * from "src/storages/files/files";
|
1555
|
+
export * from "src/storages/files/file";
|
1556
|
+
export * from "src/storages/files/filesPage";
|
1557
|
+
export * from "src/storages/chats/chats";
|
1558
|
+
export * from "src/storages/chats/chat";
|
1559
|
+
/**
|
1560
|
+
* Current SDK version.
|
1561
|
+
*/
|
1562
|
+
export const SDK_VERSION: string;
|
1563
|
+
/**
|
1564
|
+
* Default DataIsland App name.
|
1565
|
+
*/
|
1566
|
+
export const DEFAULT_NAME = "[DEFAULT]";
|
1567
|
+
/**
|
1568
|
+
* Default DataIsland App host.
|
1569
|
+
*/
|
1570
|
+
export const DEFAULT_HOST = "https://api.dataisland.com.ua";
|
1571
|
+
/**
|
1572
|
+
* Returns a list of DataIsland App instances.
|
1573
|
+
*/
|
1574
|
+
export function dataIslandInstances(): DataIslandApp[];
|
1575
|
+
/**
|
1576
|
+
* Returns a DataIsland App instance.
|
1577
|
+
* @param name Optional The name of the app.
|
1578
|
+
* @param setup Optional setup function.
|
1579
|
+
* @returns A DataIsland App instance.
|
1580
|
+
* @example
|
1581
|
+
* ```js
|
1582
|
+
* import { dataIslandApp, DEFAULT_NAME } from '@neuralinnovations/dataisland-sdk'
|
1583
|
+
*
|
1584
|
+
* const app = await dataIslandApp(DEFAULT_NAME, builder => {
|
1585
|
+
* builder.useHost("https://dataisland.com.ua")
|
1586
|
+
* builder.useAutomaticDataCollectionEnabled(true)
|
1587
|
+
* builder.useCredential(new BasicCredential("email", "password"))
|
1588
|
+
* })
|
1589
|
+
* ```
|
1590
|
+
*/
|
1591
|
+
export function dataIslandApp(name?: string, setup?: (builder: AppBuilder) => Promise<void>): Promise<DataIslandApp>;
|
1592
|
+
export { File } from "src/storages/files/file";
|
1593
|
+
export { FilesPage } from "src/storages/files/filesPage";
|
1594
|
+
}
|