@neuralinnovations/dataisland-sdk 0.0.1-dev27 → 0.0.1-dev28

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.
Files changed (126) hide show
  1. package/dist/package.json +6 -2
  2. package/dist/src/commands/startCommandHandler.d.ts.map +1 -1
  3. package/dist/src/commands/startCommandHandler.js +12 -2
  4. package/dist/src/commands/startCommandHandler.js.map +1 -1
  5. package/dist/src/context.d.ts +3 -2
  6. package/dist/src/context.d.ts.map +1 -1
  7. package/dist/src/context.js +2 -2
  8. package/dist/src/context.js.map +1 -1
  9. package/dist/src/credentials.d.ts +5 -0
  10. package/dist/src/credentials.d.ts.map +1 -1
  11. package/dist/src/credentials.js +18 -1
  12. package/dist/src/credentials.js.map +1 -1
  13. package/dist/src/dto/accessGroupResponse.d.ts.map +1 -1
  14. package/dist/src/dto/userInfoResponse.d.ts +1 -0
  15. package/dist/src/dto/userInfoResponse.d.ts.map +1 -1
  16. package/dist/src/index.d.ts +1 -0
  17. package/dist/src/index.d.ts.map +1 -1
  18. package/dist/src/index.js +1 -0
  19. package/dist/src/index.js.map +1 -1
  20. package/dist/src/internal/app.impl.d.ts.map +1 -1
  21. package/dist/src/internal/app.impl.js +20 -2
  22. package/dist/src/internal/app.impl.js.map +1 -1
  23. package/dist/src/middleware.d.ts +2 -0
  24. package/dist/src/middleware.d.ts.map +1 -1
  25. package/dist/src/services/anonymousService.d.ts +8 -0
  26. package/dist/src/services/anonymousService.d.ts.map +1 -0
  27. package/dist/src/services/anonymousService.js +41 -0
  28. package/dist/src/services/anonymousService.js.map +1 -0
  29. package/dist/src/services/commandService.d.ts.map +1 -1
  30. package/dist/src/services/commandService.js.map +1 -1
  31. package/dist/src/services/cookieService.d.ts +7 -0
  32. package/dist/src/services/cookieService.d.ts.map +1 -0
  33. package/dist/src/services/cookieService.js +18 -0
  34. package/dist/src/services/cookieService.js.map +1 -0
  35. package/dist/src/services/httpMethod.d.ts +2 -0
  36. package/dist/src/services/httpMethod.d.ts.map +1 -0
  37. package/dist/src/services/httpMethod.js +3 -0
  38. package/dist/src/services/httpMethod.js.map +1 -0
  39. package/dist/src/services/middlewareService.d.ts +2 -0
  40. package/dist/src/services/middlewareService.d.ts.map +1 -1
  41. package/dist/src/services/middlewareService.js.map +1 -1
  42. package/dist/src/services/requestBuilder.d.ts +2 -0
  43. package/dist/src/services/requestBuilder.d.ts.map +1 -1
  44. package/dist/src/services/requestBuilder.js +11 -10
  45. package/dist/src/services/requestBuilder.js.map +1 -1
  46. package/dist/src/services/responseUtils.d.ts +1 -0
  47. package/dist/src/services/responseUtils.d.ts.map +1 -1
  48. package/dist/src/services/responseUtils.js.map +1 -1
  49. package/dist/src/services/rpcService.d.ts +1 -0
  50. package/dist/src/services/rpcService.d.ts.map +1 -1
  51. package/dist/src/services/rpcService.js +4 -2
  52. package/dist/src/services/rpcService.js.map +1 -1
  53. package/dist/src/services/userProfileService.d.ts +1 -0
  54. package/dist/src/services/userProfileService.d.ts.map +1 -1
  55. package/dist/src/services/userProfileService.js +11 -0
  56. package/dist/src/services/userProfileService.js.map +1 -1
  57. package/dist/src/storages/chats/answer.impl.d.ts.map +1 -1
  58. package/dist/src/storages/chats/answer.impl.js.map +1 -1
  59. package/dist/src/storages/chats/chat.impl.js.map +1 -1
  60. package/dist/src/storages/chats/chats.impl.d.ts.map +1 -1
  61. package/dist/src/storages/chats/chats.impl.js.map +1 -1
  62. package/dist/src/storages/files/file.impl.d.ts.map +1 -1
  63. package/dist/src/storages/files/file.impl.js.map +1 -1
  64. package/dist/src/storages/files/files.d.ts +5 -1
  65. package/dist/src/storages/files/files.d.ts.map +1 -1
  66. package/dist/src/storages/files/files.impl.d.ts +1 -1
  67. package/dist/src/storages/files/files.impl.d.ts.map +1 -1
  68. package/dist/src/storages/files/files.impl.js +4 -2
  69. package/dist/src/storages/files/files.impl.js.map +1 -1
  70. package/dist/src/storages/files/files.js.map +1 -1
  71. package/dist/src/storages/organizations/organization.d.ts.map +1 -1
  72. package/dist/src/storages/organizations/organization.impl.d.ts.map +1 -1
  73. package/dist/src/storages/organizations/organization.impl.js.map +1 -1
  74. package/dist/src/storages/organizations/organization.js.map +1 -1
  75. package/dist/src/storages/organizations/organizations.impl.d.ts.map +1 -1
  76. package/dist/src/storages/organizations/organizations.impl.js.map +1 -1
  77. package/dist/src/storages/user/userProfile.d.ts +4 -0
  78. package/dist/src/storages/user/userProfile.d.ts.map +1 -1
  79. package/dist/src/storages/user/userProfile.impl.d.ts +1 -0
  80. package/dist/src/storages/user/userProfile.impl.d.ts.map +1 -1
  81. package/dist/src/storages/user/userProfile.impl.js +6 -0
  82. package/dist/src/storages/user/userProfile.impl.js.map +1 -1
  83. package/dist/src/storages/user/userProfile.js.map +1 -1
  84. package/dist/src/storages/workspaces/workspace.impl.js.map +1 -1
  85. package/dist/src/storages/workspaces/workspaces.d.ts.map +1 -1
  86. package/dist/src/storages/workspaces/workspaces.impl.d.ts.map +1 -1
  87. package/dist/src/storages/workspaces/workspaces.impl.js.map +1 -1
  88. package/dist/src/storages/workspaces/workspaces.js.map +1 -1
  89. package/dist/src/utils/browserUtils.d.ts +4 -0
  90. package/dist/src/utils/browserUtils.d.ts.map +1 -0
  91. package/dist/src/utils/browserUtils.js +68 -0
  92. package/dist/src/utils/browserUtils.js.map +1 -0
  93. package/package.json +6 -2
  94. package/src/commands/startCommandHandler.ts +16 -5
  95. package/src/context.ts +2 -1
  96. package/src/credentials.ts +22 -0
  97. package/src/dto/accessGroupResponse.ts +15 -16
  98. package/src/dto/userInfoResponse.ts +1 -0
  99. package/src/index.ts +2 -0
  100. package/src/internal/app.impl.ts +30 -4
  101. package/src/middleware.ts +3 -0
  102. package/src/services/anonymousService.ts +43 -0
  103. package/src/services/commandService.ts +4 -2
  104. package/src/services/cookieService.ts +16 -0
  105. package/src/services/httpMethod.ts +1 -0
  106. package/src/services/middlewareService.ts +2 -0
  107. package/src/services/requestBuilder.ts +6 -3
  108. package/src/services/responseUtils.ts +2 -0
  109. package/src/services/rpcService.ts +2 -0
  110. package/src/services/userProfileService.ts +14 -0
  111. package/src/storages/chats/answer.impl.ts +4 -5
  112. package/src/storages/chats/chat.impl.ts +1 -1
  113. package/src/storages/chats/chats.impl.ts +3 -1
  114. package/src/storages/files/file.impl.ts +4 -2
  115. package/src/storages/files/files.impl.ts +4 -3
  116. package/src/storages/files/files.ts +5 -1
  117. package/src/storages/groups/group.impl.ts +1 -1
  118. package/src/storages/organizations/organization.impl.ts +4 -2
  119. package/src/storages/organizations/organization.ts +3 -4
  120. package/src/storages/organizations/organizations.impl.ts +3 -1
  121. package/src/storages/user/userProfile.impl.ts +7 -0
  122. package/src/storages/user/userProfile.ts +5 -0
  123. package/src/storages/workspaces/workspace.impl.ts +1 -1
  124. package/src/storages/workspaces/workspaces.impl.ts +3 -1
  125. package/src/storages/workspaces/workspaces.ts +5 -1
  126. package/src/utils/browserUtils.ts +72 -0
@@ -8,6 +8,7 @@ import { ResponseUtils } from "../../services/responseUtils"
8
8
  import { File } from "./file"
9
9
  import { FilesPage } from "./filesPage"
10
10
  import { FilesPageImpl } from "./filesPage.impl"
11
+ import FormData from "form-data"
11
12
 
12
13
  export class FilesImpl extends Files {
13
14
  constructor(
@@ -20,7 +21,7 @@ export class FilesImpl extends Files {
20
21
  // Object used as files page data, returned by "query"
21
22
  public filesList?: FilesPage
22
23
 
23
- async upload(files: any[]): Promise<File[]> {
24
+ async upload(files: UploadFile[]): Promise<File[]> {
24
25
  const loaded_files = []
25
26
  for (const file of files) {
26
27
  loaded_files.push(await this.internalUpload(file))
@@ -158,7 +159,7 @@ export class FilesImpl extends Files {
158
159
  form.append("organizationId", this.workspace.organization.id)
159
160
  form.append("workspaceId", this.workspace.id)
160
161
  form.append("name", file.name)
161
- form.append("file", file, file.name)
162
+ form.append("file", file.stream, file.name)
162
163
 
163
164
  // send request to the server
164
165
  const response = await this.context
@@ -172,7 +173,7 @@ export class FilesImpl extends Files {
172
173
  }
173
174
 
174
175
  // parse file from the server's response
175
- const result = (await response!.json()).file as FileDto
176
+ const result = (await response!.json() as { file: FileDto }).file as FileDto
176
177
 
177
178
  // create file implementation
178
179
  const fileImpl = new FileImpl(this.context)
@@ -14,7 +14,11 @@ export enum FilesEvent {
14
14
  /**
15
15
  * Upload file.
16
16
  */
17
- export type UploadFile = globalThis.File
17
+ export type UploadFile = {
18
+ name: string
19
+ type: "application/pdf"
20
+ stream: ReadableStream
21
+ }
18
22
 
19
23
  /**
20
24
  * Files storage.
@@ -38,7 +38,7 @@ export class GroupImpl extends Group implements Disposable {
38
38
 
39
39
  // wait for all promises
40
40
  await Promise.all([groupPromise, workspacePromise])
41
-
41
+
42
42
  return this
43
43
  }
44
44
 
@@ -94,7 +94,9 @@ export class OrganizationImpl extends Organization implements Disposable {
94
94
  )
95
95
  }
96
96
 
97
- return (await response!.json()).members as UserDto[]
97
+ return (await response!.json() as {
98
+ members: UserDto[]
99
+ }).members as UserDto[]
98
100
  }
99
101
 
100
102
  async change(name: string, description: string): Promise<void> {
@@ -143,7 +145,7 @@ export class OrganizationImpl extends Organization implements Disposable {
143
145
  data: this
144
146
  })
145
147
  }
146
-
148
+
147
149
  async createInviteLink(emails: string[], accessGroups: string[]): Promise<void> {
148
150
  const response = await this.context
149
151
  .resolve(RpcService)
@@ -6,7 +6,6 @@ import { EventDispatcher } from "../../events"
6
6
  import { UserDto } from "../../dto/userInfoResponse"
7
7
  import { GroupId } from "../groups/group"
8
8
 
9
-
10
9
  /**
11
10
  * Organization event.
12
11
  */
@@ -18,9 +17,9 @@ export enum OrganizationEvent {
18
17
  * Organization.
19
18
  */
20
19
  export abstract class Organization extends EventDispatcher<
21
- OrganizationEvent,
22
- Organization
23
- > {
20
+ OrganizationEvent,
21
+ Organization
22
+ > {
24
23
  /**
25
24
  * Organization id.
26
25
  */
@@ -147,7 +147,9 @@ export class OrganizationsImpl extends Organizations {
147
147
  response
148
148
  )
149
149
  }
150
- const content = (await response!.json()).organization as OrganizationDto
150
+ const content = (await response!.json() as {
151
+ organization: OrganizationDto
152
+ }).organization as OrganizationDto
151
153
 
152
154
  // create organization and init from content
153
155
  const org = await new OrganizationImpl(this.context).initFrom(content, true)
@@ -32,6 +32,13 @@ export class UserProfileImpl extends UserProfile {
32
32
  throw new Error("The profile is not loaded.")
33
33
  }
34
34
 
35
+ get isAnonymous(): boolean {
36
+ if (this.content) {
37
+ return this.content.user.isAnonymousMode
38
+ }
39
+ throw new Error("The profile is not loaded.")
40
+ }
41
+
35
42
  get createdAt(): Date {
36
43
  if (this.content) {
37
44
  return new Date(this.content.user.created_at)
@@ -30,6 +30,11 @@ export abstract class UserProfile extends EventDispatcher<
30
30
  */
31
31
  abstract get isDeleted(): boolean
32
32
 
33
+ /**
34
+ * Is user anonymous
35
+ */
36
+ abstract get isAnonymous(): boolean
37
+
33
38
  /**
34
39
  * Created at.
35
40
  */
@@ -63,7 +63,7 @@ export class WorkspaceImpl extends Workspace {
63
63
  )
64
64
  }
65
65
 
66
- return (await response!.json()).count
66
+ return ((await response!.json()) as { count: number }).count
67
67
  }
68
68
 
69
69
  async change(name: string, description: string): Promise<void> {
@@ -108,7 +108,9 @@ export class WorkspacesImpl extends Workspaces {
108
108
  }
109
109
 
110
110
  // parse workspace from the server's response
111
- const content = (await response!.json()).workspace as WorkspaceDto
111
+ const content = ((await response!.json()) as {
112
+ workspace: WorkspaceDto
113
+ }).workspace as WorkspaceDto
112
114
 
113
115
  // create workspace implementation
114
116
  const workspace = new WorkspaceImpl(this.organization, this.context)
@@ -44,7 +44,11 @@ export abstract class Workspaces extends EventDispatcher<
44
44
  /**
45
45
  * Create workspace.
46
46
  */
47
- abstract create(name: string, description: string, regulation?: { isCreateNewGroup: boolean, newGroupName: string, groupIds: string[]}): Promise<Workspace>
47
+ abstract create(name: string, description: string, regulation?: {
48
+ isCreateNewGroup: boolean,
49
+ newGroupName: string,
50
+ groupIds: string[]
51
+ }): Promise<Workspace>
48
52
 
49
53
  /**
50
54
  * Delete workspace.
@@ -0,0 +1,72 @@
1
+ const getDocument = () => {
2
+ if (!(globalThis as any).document) {
3
+ (globalThis as any).document = {
4
+ cookie: ""
5
+ }
6
+ }
7
+ return document
8
+ }
9
+
10
+ const getNavigator = () => {
11
+ if (!(globalThis as any).navigator) {
12
+ (globalThis as any).navigator = {
13
+ userAgent: "",
14
+ language: "",
15
+ hardwareConcurrency: 0,
16
+ cookieEnabled: false
17
+ }
18
+ }
19
+ return navigator
20
+ }
21
+
22
+ const getWidow = () => {
23
+ if (!(globalThis as any).window) {
24
+ (globalThis as any).window = {
25
+ devicePixelRatio: 16 / 9.0,
26
+ sessionStorage: {},
27
+ localStorage: {}
28
+ }
29
+ }
30
+ return window
31
+ }
32
+
33
+ export const setCookie = (name: string, value: string | undefined): void => {
34
+ const doc = getDocument()
35
+ doc.cookie = `${name}=${value || ""};`
36
+ }
37
+
38
+ export const getCookie = (name: string): string | undefined => {
39
+ const doc = getDocument()
40
+ const nameValidator = `${name}=`
41
+ const cookieItems = doc.cookie.split(";")
42
+
43
+ for (let index = 0; index < cookieItems.length; index++) {
44
+ let cookie = cookieItems[index]
45
+
46
+ while (cookie.charAt(0) === " ") {
47
+ cookie = cookie.substring(1, cookie.length)
48
+ }
49
+
50
+ if (cookie.indexOf(nameValidator) === 0) {
51
+ return cookie.substring(nameValidator.length, cookie.length)
52
+ }
53
+ }
54
+
55
+ return undefined
56
+ }
57
+
58
+ export const createFingerprint = () => {
59
+ const nav = getNavigator()
60
+ const win = getWidow()
61
+ const fingerprint = new Map<string, any>()
62
+
63
+ fingerprint.set("userAgent", nav.userAgent)
64
+ fingerprint.set("language", nav.language)
65
+ fingerprint.set("hardware_concurrency", nav.hardwareConcurrency)
66
+ fingerprint.set("cookie_enabled", nav.cookieEnabled)
67
+ fingerprint.set("pixel_ratio", win.devicePixelRatio)
68
+ fingerprint.set("session_storage", win.sessionStorage)
69
+ fingerprint.set("local_storage", win.localStorage)
70
+
71
+ return fingerprint
72
+ }