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

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 (128) hide show
  1. package/dist/package.json +4 -1
  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 +1 -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 +1 -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.map +1 -1
  43. package/dist/src/services/requestBuilder.js +8 -7
  44. package/dist/src/services/requestBuilder.js.map +1 -1
  45. package/dist/src/services/responseUtils.d.ts +1 -0
  46. package/dist/src/services/responseUtils.d.ts.map +1 -1
  47. package/dist/src/services/responseUtils.js.map +1 -1
  48. package/dist/src/services/rpcService.d.ts.map +1 -1
  49. package/dist/src/services/rpcService.js.map +1 -1
  50. package/dist/src/services/userProfileService.d.ts +1 -0
  51. package/dist/src/services/userProfileService.d.ts.map +1 -1
  52. package/dist/src/services/userProfileService.js +11 -0
  53. package/dist/src/services/userProfileService.js.map +1 -1
  54. package/dist/src/storages/chats/answer.impl.d.ts.map +1 -1
  55. package/dist/src/storages/chats/answer.impl.js.map +1 -1
  56. package/dist/src/storages/chats/chat.impl.js.map +1 -1
  57. package/dist/src/storages/chats/chats.impl.d.ts.map +1 -1
  58. package/dist/src/storages/chats/chats.impl.js.map +1 -1
  59. package/dist/src/storages/files/file.impl.d.ts.map +1 -1
  60. package/dist/src/storages/files/file.impl.js.map +1 -1
  61. package/dist/src/storages/files/files.d.ts +6 -1
  62. package/dist/src/storages/files/files.d.ts.map +1 -1
  63. package/dist/src/storages/files/files.impl.d.ts +1 -1
  64. package/dist/src/storages/files/files.impl.d.ts.map +1 -1
  65. package/dist/src/storages/files/files.impl.js +9 -1
  66. package/dist/src/storages/files/files.impl.js.map +1 -1
  67. package/dist/src/storages/files/files.js.map +1 -1
  68. package/dist/src/storages/organizations/organization.d.ts.map +1 -1
  69. package/dist/src/storages/organizations/organization.impl.d.ts.map +1 -1
  70. package/dist/src/storages/organizations/organization.impl.js.map +1 -1
  71. package/dist/src/storages/organizations/organization.js.map +1 -1
  72. package/dist/src/storages/organizations/organizations.impl.d.ts.map +1 -1
  73. package/dist/src/storages/organizations/organizations.impl.js.map +1 -1
  74. package/dist/src/storages/user/userProfile.d.ts +4 -0
  75. package/dist/src/storages/user/userProfile.d.ts.map +1 -1
  76. package/dist/src/storages/user/userProfile.impl.d.ts +1 -0
  77. package/dist/src/storages/user/userProfile.impl.d.ts.map +1 -1
  78. package/dist/src/storages/user/userProfile.impl.js +6 -0
  79. package/dist/src/storages/user/userProfile.impl.js.map +1 -1
  80. package/dist/src/storages/user/userProfile.js.map +1 -1
  81. package/dist/src/storages/workspaces/workspace.impl.js.map +1 -1
  82. package/dist/src/storages/workspaces/workspaces.d.ts.map +1 -1
  83. package/dist/src/storages/workspaces/workspaces.impl.d.ts.map +1 -1
  84. package/dist/src/storages/workspaces/workspaces.impl.js.map +1 -1
  85. package/dist/src/storages/workspaces/workspaces.js.map +1 -1
  86. package/dist/src/utils/browserUtils.d.ts +4 -0
  87. package/dist/src/utils/browserUtils.d.ts.map +1 -0
  88. package/dist/src/utils/browserUtils.js +68 -0
  89. package/dist/src/utils/browserUtils.js.map +1 -0
  90. package/dist/src/utils/request.d.ts +6 -0
  91. package/dist/src/utils/request.d.ts.map +1 -0
  92. package/dist/src/utils/request.js +3 -0
  93. package/dist/src/utils/request.js.map +1 -0
  94. package/package.json +4 -1
  95. package/src/commands/startCommandHandler.ts +16 -5
  96. package/src/context.ts +2 -1
  97. package/src/credentials.ts +22 -0
  98. package/src/dto/accessGroupResponse.ts +15 -16
  99. package/src/dto/userInfoResponse.ts +1 -0
  100. package/src/index.ts +2 -0
  101. package/src/internal/app.impl.ts +30 -4
  102. package/src/middleware.ts +2 -0
  103. package/src/services/anonymousService.ts +43 -0
  104. package/src/services/commandService.ts +4 -2
  105. package/src/services/cookieService.ts +16 -0
  106. package/src/services/httpMethod.ts +1 -0
  107. package/src/services/middlewareService.ts +1 -0
  108. package/src/services/requestBuilder.ts +10 -8
  109. package/src/services/responseUtils.ts +2 -0
  110. package/src/services/rpcService.ts +1 -0
  111. package/src/services/userProfileService.ts +14 -0
  112. package/src/storages/chats/answer.impl.ts +4 -5
  113. package/src/storages/chats/chat.impl.ts +1 -1
  114. package/src/storages/chats/chats.impl.ts +3 -1
  115. package/src/storages/files/file.impl.ts +4 -2
  116. package/src/storages/files/files.impl.ts +11 -3
  117. package/src/storages/files/files.ts +5 -1
  118. package/src/storages/groups/group.impl.ts +1 -1
  119. package/src/storages/organizations/organization.impl.ts +4 -2
  120. package/src/storages/organizations/organization.ts +3 -4
  121. package/src/storages/organizations/organizations.impl.ts +3 -1
  122. package/src/storages/user/userProfile.impl.ts +7 -0
  123. package/src/storages/user/userProfile.ts +5 -0
  124. package/src/storages/workspaces/workspace.impl.ts +1 -1
  125. package/src/storages/workspaces/workspaces.impl.ts +3 -1
  126. package/src/storages/workspaces/workspaces.ts +5 -1
  127. package/src/utils/browserUtils.ts +72 -0
  128. package/src/utils/request.ts +6 -0
@@ -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
+ }
@@ -0,0 +1,6 @@
1
+
2
+ export type Request = globalThis.Request
3
+ export type Response = globalThis.Response
4
+ export type Headers = globalThis.Headers
5
+ export type FormData = globalThis.FormData
6
+ export type fetch = typeof globalThis.fetch