@neuralinnovations/dataisland-sdk 0.0.1-dev11 → 0.0.1-dev13

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 (60) hide show
  1. package/README.md +122 -5
  2. package/dist/package.json +5 -5
  3. package/dist/src/storages/chats/answer.d.ts +7 -1
  4. package/dist/src/storages/chats/answer.d.ts.map +1 -1
  5. package/dist/src/storages/chats/answer.impl.d.ts.map +1 -1
  6. package/dist/src/storages/chats/answer.impl.js +12 -0
  7. package/dist/src/storages/chats/answer.impl.js.map +1 -1
  8. package/dist/src/storages/chats/answer.js +9 -2
  9. package/dist/src/storages/chats/answer.js.map +1 -1
  10. package/dist/src/storages/files/file.d.ts +9 -2
  11. package/dist/src/storages/files/file.d.ts.map +1 -1
  12. package/dist/src/storages/files/file.impl.d.ts +4 -1
  13. package/dist/src/storages/files/file.impl.d.ts.map +1 -1
  14. package/dist/src/storages/files/file.impl.js +15 -3
  15. package/dist/src/storages/files/file.impl.js.map +1 -1
  16. package/dist/src/storages/files/file.js +2 -1
  17. package/dist/src/storages/files/file.js.map +1 -1
  18. package/dist/src/storages/files/files.d.ts +5 -4
  19. package/dist/src/storages/files/files.d.ts.map +1 -1
  20. package/dist/src/storages/files/files.impl.d.ts +3 -3
  21. package/dist/src/storages/files/files.impl.d.ts.map +1 -1
  22. package/dist/src/storages/files/files.impl.js +12 -6
  23. package/dist/src/storages/files/files.impl.js.map +1 -1
  24. package/dist/src/storages/files/files.js +1 -0
  25. package/dist/src/storages/files/files.js.map +1 -1
  26. package/dist/src/storages/groups/groups.d.ts +1 -3
  27. package/dist/src/storages/groups/groups.d.ts.map +1 -1
  28. package/dist/src/storages/groups/groups.impl.d.ts +2 -3
  29. package/dist/src/storages/groups/groups.impl.d.ts.map +1 -1
  30. package/dist/src/storages/groups/groups.impl.js +6 -6
  31. package/dist/src/storages/groups/groups.impl.js.map +1 -1
  32. package/dist/src/storages/groups/groups.js.map +1 -1
  33. package/dist/src/storages/organizations/organization.d.ts +12 -1
  34. package/dist/src/storages/organizations/organization.d.ts.map +1 -1
  35. package/dist/src/storages/organizations/organization.impl.d.ts +1 -0
  36. package/dist/src/storages/organizations/organization.impl.d.ts.map +1 -1
  37. package/dist/src/storages/organizations/organization.impl.js +36 -0
  38. package/dist/src/storages/organizations/organization.impl.js.map +1 -1
  39. package/dist/src/storages/organizations/organization.js +10 -2
  40. package/dist/src/storages/organizations/organization.js.map +1 -1
  41. package/dist/src/storages/workspaces/workspace.d.ts +4 -0
  42. package/dist/src/storages/workspaces/workspace.d.ts.map +1 -1
  43. package/dist/src/storages/workspaces/workspace.impl.d.ts +1 -0
  44. package/dist/src/storages/workspaces/workspace.impl.d.ts.map +1 -1
  45. package/dist/src/storages/workspaces/workspace.impl.js +11 -0
  46. package/dist/src/storages/workspaces/workspace.impl.js.map +1 -1
  47. package/dist/src/storages/workspaces/workspace.js.map +1 -1
  48. package/package.json +5 -5
  49. package/src/storages/chats/answer.impl.ts +16 -1
  50. package/src/storages/chats/answer.ts +8 -1
  51. package/src/storages/files/file.impl.ts +21 -3
  52. package/src/storages/files/file.ts +14 -2
  53. package/src/storages/files/files.impl.ts +12 -7
  54. package/src/storages/files/files.ts +5 -4
  55. package/src/storages/groups/groups.impl.ts +6 -8
  56. package/src/storages/groups/groups.ts +1 -3
  57. package/src/storages/organizations/organization.impl.ts +48 -1
  58. package/src/storages/organizations/organization.ts +18 -1
  59. package/src/storages/workspaces/workspace.impl.ts +20 -0
  60. package/src/storages/workspaces/workspace.ts +5 -0
@@ -2,7 +2,6 @@ import { AccessGroupDto } from "../../dto/accessGroupResponse"
2
2
  import { UserDto } from "../../dto/userInfoResponse"
3
3
  import { WorkspaceDto } from "../../dto/workspacesResponse"
4
4
  import { EventDispatcher } from "../../events"
5
- import { OrganizationId } from "../organizations/organizations"
6
5
  import { Organization } from "../organizations/organization"
7
6
 
8
7
  /**
@@ -78,11 +77,10 @@ export abstract class Groups extends EventDispatcher<GroupEvent, Group> {
78
77
  /**
79
78
  * Create new group.
80
79
  * @param name
81
- * @param organizationId
82
80
  * @param permits
83
81
  * @param memberIds
84
82
  */
85
- abstract create(name: string, organizationId: OrganizationId, permits: {
83
+ abstract create(name: string, permits: {
86
84
  isAdmin: boolean
87
85
  }, memberIds: string[]): Promise<Group>
88
86
 
@@ -4,7 +4,7 @@ import { OrganizationDto } from "../../dto/userInfoResponse"
4
4
  import { Workspaces } from "../workspaces/workspaces"
5
5
  import { WorkspacesImpl } from "../workspaces/workspaces.impl"
6
6
  import { Context } from "../../context"
7
- import { Organization } from "./organization"
7
+ import { Organization, OrganizationEvent } from "./organization"
8
8
  import { GroupsImpl } from "../groups/groups.impl"
9
9
  import { Groups } from "../groups/groups"
10
10
  import { ChatsImpl } from "../chats/chats.impl"
@@ -75,6 +75,53 @@ export class OrganizationImpl extends Organization implements Disposable {
75
75
  get chats(): Chats {
76
76
  return this._chats
77
77
  }
78
+
79
+ async change(name: string, description: string): Promise<void> {
80
+ if (!this._content) {
81
+ throw new Error("Organization is not loaded.")
82
+ }
83
+
84
+ if (name === this.name && description === this.description) {
85
+ return Promise.resolve()
86
+ }
87
+ if (name === undefined || name === null || name.trim() === "") {
88
+ throw new Error("Name is required. Please provide a valid name.")
89
+ }
90
+ if (
91
+ description === undefined ||
92
+ description === null ||
93
+ description.trim() === ""
94
+ ) {
95
+ throw new Error(
96
+ "Description is required. Please provide a valid description."
97
+ )
98
+ }
99
+
100
+ const response = await this.context
101
+ .resolve(RpcService)
102
+ ?.requestBuilder("api/v1/Organizations")
103
+ .sendPutJson({
104
+ organizationId: this.id,
105
+ profile: {
106
+ name,
107
+ description
108
+ }
109
+ })
110
+
111
+ if (ResponseUtils.isFail(response)) {
112
+ await ResponseUtils.throwError("Failed to change organization", response)
113
+ }
114
+
115
+ if (this._content) {
116
+ this._content.profile.name = name
117
+ this._content.profile.description = description
118
+ }
119
+
120
+ this.dispatch({
121
+ type: OrganizationEvent.CHANGED,
122
+ data: this
123
+ })
124
+ }
78
125
 
79
126
  async createInviteLink(emails: string[], accessGroups: string[]): Promise<void> {
80
127
  const response = await this.context
@@ -2,11 +2,23 @@ import { Workspaces } from "../workspaces/workspaces"
2
2
  import { OrganizationId } from "./organizations"
3
3
  import { GroupId, Groups } from "../groups/groups"
4
4
  import { Chats } from "../chats/chats"
5
+ import { EventDispatcher } from "../../events"
6
+
7
+
8
+ /**
9
+ * Organization event.
10
+ */
11
+ export enum OrganizationEvent {
12
+ CHANGED = "changed"
13
+ }
5
14
 
6
15
  /**
7
16
  * Organization.
8
17
  */
9
- export abstract class Organization {
18
+ export abstract class Organization extends EventDispatcher<
19
+ OrganizationEvent,
20
+ Organization
21
+ > {
10
22
  /**
11
23
  * Organization id.
12
24
  */
@@ -37,6 +49,11 @@ export abstract class Organization {
37
49
  */
38
50
  abstract get accessGroups(): Groups
39
51
 
52
+ /**
53
+ * Change organization name and description.
54
+ */
55
+ abstract change(name: string, description: string): Promise<void>
56
+
40
57
  /**
41
58
  * Create invite link
42
59
  */
@@ -46,6 +46,26 @@ export class WorkspaceImpl extends Workspace {
46
46
  return this._files
47
47
  }
48
48
 
49
+ async filesCount(): Promise<number> {
50
+ // send request to the server
51
+ const response = await this.context
52
+ .resolve(RpcService)
53
+ ?.requestBuilder("api/v1/Workspaces/files/count")
54
+ .searchParam("workspaceId", this.id)
55
+ .searchParam("organizationId", this.organization.id)
56
+ .sendGet()
57
+
58
+ // check response status
59
+ if (ResponseUtils.isFail(response)) {
60
+ await ResponseUtils.throwError(
61
+ `Failed during get workspace total files count for ${this.id} of ${this.organization.id}`,
62
+ response
63
+ )
64
+ }
65
+
66
+ return (await response!.json()).count
67
+ }
68
+
49
69
  async change(name: string, description: string): Promise<void> {
50
70
  if (!this._workspace) {
51
71
  throw new Error("Workspace is not loaded.")
@@ -42,6 +42,11 @@ export abstract class Workspace extends EventDispatcher<
42
42
  */
43
43
  abstract get files(): Files
44
44
 
45
+ /**
46
+ * Workspace files count.
47
+ */
48
+ abstract filesCount(): Promise<number>
49
+
45
50
  /**
46
51
  * Change workspace name and description.
47
52
  */