@api-client/core 0.19.17 → 0.19.19

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 (205) hide show
  1. package/build/src/browser.d.ts +12 -12
  2. package/build/src/browser.d.ts.map +1 -1
  3. package/build/src/browser.js +3 -3
  4. package/build/src/browser.js.map +1 -1
  5. package/build/src/index.d.ts +12 -12
  6. package/build/src/index.d.ts.map +1 -1
  7. package/build/src/index.js +3 -3
  8. package/build/src/index.js.map +1 -1
  9. package/build/src/mocking/ProjectMock.d.ts +1 -1
  10. package/build/src/mocking/ProjectMock.d.ts.map +1 -1
  11. package/build/src/mocking/ProjectMock.js.map +1 -1
  12. package/build/src/mocking/lib/File.d.ts +5 -5
  13. package/build/src/mocking/lib/File.d.ts.map +1 -1
  14. package/build/src/mocking/lib/File.js.map +1 -1
  15. package/build/src/mocking/lib/Organization.d.ts +7 -3
  16. package/build/src/mocking/lib/Organization.d.ts.map +1 -1
  17. package/build/src/mocking/lib/Organization.js +19 -1
  18. package/build/src/mocking/lib/Organization.js.map +1 -1
  19. package/build/src/mocking/lib/Permission.d.ts +6 -6
  20. package/build/src/mocking/lib/Permission.d.ts.map +1 -1
  21. package/build/src/mocking/lib/Permission.js.map +1 -1
  22. package/build/src/mocking/lib/User.d.ts +8 -4
  23. package/build/src/mocking/lib/User.d.ts.map +1 -1
  24. package/build/src/mocking/lib/User.js.map +1 -1
  25. package/build/src/modeling/ApiFile.d.ts +8 -4
  26. package/build/src/modeling/ApiFile.d.ts.map +1 -1
  27. package/build/src/modeling/ApiFile.js.map +1 -1
  28. package/build/src/modeling/ApiModel.d.ts +2 -2
  29. package/build/src/modeling/ApiModel.d.ts.map +1 -1
  30. package/build/src/modeling/ApiModel.js.map +1 -1
  31. package/build/src/modeling/DataDomain.d.ts +2 -2
  32. package/build/src/modeling/DataDomain.d.ts.map +1 -1
  33. package/build/src/modeling/DataDomain.js.map +1 -1
  34. package/build/src/modeling/DomainAssociation.d.ts +2 -2
  35. package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
  36. package/build/src/modeling/DomainAssociation.js.map +1 -1
  37. package/build/src/modeling/DomainEntity.d.ts +2 -2
  38. package/build/src/modeling/DomainEntity.d.ts.map +1 -1
  39. package/build/src/modeling/DomainEntity.js.map +1 -1
  40. package/build/src/modeling/DomainFile.d.ts +8 -4
  41. package/build/src/modeling/DomainFile.d.ts.map +1 -1
  42. package/build/src/modeling/DomainFile.js.map +1 -1
  43. package/build/src/modeling/DomainModel.d.ts +2 -2
  44. package/build/src/modeling/DomainModel.d.ts.map +1 -1
  45. package/build/src/modeling/DomainModel.js.map +1 -1
  46. package/build/src/modeling/DomainNamespace.d.ts +2 -2
  47. package/build/src/modeling/DomainNamespace.d.ts.map +1 -1
  48. package/build/src/modeling/DomainNamespace.js.map +1 -1
  49. package/build/src/modeling/DomainProperty.d.ts +2 -2
  50. package/build/src/modeling/DomainProperty.d.ts.map +1 -1
  51. package/build/src/modeling/DomainProperty.js.map +1 -1
  52. package/build/src/modeling/helpers/Intelisense.d.ts +38 -38
  53. package/build/src/modeling/helpers/Intelisense.d.ts.map +1 -1
  54. package/build/src/modeling/helpers/Intelisense.js.map +1 -1
  55. package/build/src/models/AiMessage.d.ts +3 -3
  56. package/build/src/models/AiMessage.d.ts.map +1 -1
  57. package/build/src/models/AiMessage.js.map +1 -1
  58. package/build/src/models/AiSession.d.ts +3 -3
  59. package/build/src/models/AiSession.d.ts.map +1 -1
  60. package/build/src/models/AiSession.js.map +1 -1
  61. package/build/src/models/CertificateFile.d.ts +2 -2
  62. package/build/src/models/CertificateFile.d.ts.map +1 -1
  63. package/build/src/models/CertificateFile.js.map +1 -1
  64. package/build/src/models/Environment.d.ts +2 -2
  65. package/build/src/models/Environment.d.ts.map +1 -1
  66. package/build/src/models/Environment.js.map +1 -1
  67. package/build/src/models/Folder.d.ts +9 -5
  68. package/build/src/models/Folder.d.ts.map +1 -1
  69. package/build/src/models/Folder.js.map +1 -1
  70. package/build/src/models/HttpProject.d.ts +2 -2
  71. package/build/src/models/HttpProject.d.ts.map +1 -1
  72. package/build/src/models/HttpProject.js.map +1 -1
  73. package/build/src/models/ProjectFolder.d.ts +2 -2
  74. package/build/src/models/ProjectFolder.d.ts.map +1 -1
  75. package/build/src/models/ProjectFolder.js.map +1 -1
  76. package/build/src/models/Request.d.ts +3 -3
  77. package/build/src/models/Request.d.ts.map +1 -1
  78. package/build/src/models/Request.js.map +1 -1
  79. package/build/src/models/Thing.d.ts +9 -5
  80. package/build/src/models/Thing.d.ts.map +1 -1
  81. package/build/src/models/Thing.js.map +1 -1
  82. package/build/src/models/TrashEntry.d.ts +2 -2
  83. package/build/src/models/TrashEntry.d.ts.map +1 -1
  84. package/build/src/models/TrashEntry.js.map +1 -1
  85. package/build/src/models/store/Capabilities.d.ts +5 -1
  86. package/build/src/models/store/Capabilities.d.ts.map +1 -1
  87. package/build/src/models/store/Capabilities.js.map +1 -1
  88. package/build/src/models/store/Deletion.d.ts +5 -1
  89. package/build/src/models/store/Deletion.d.ts.map +1 -1
  90. package/build/src/models/store/Deletion.js.map +1 -1
  91. package/build/src/models/store/File.d.ts +45 -37
  92. package/build/src/models/store/File.d.ts.map +1 -1
  93. package/build/src/models/store/File.js +1 -1
  94. package/build/src/models/store/File.js.map +1 -1
  95. package/build/src/models/store/Group.d.ts +3 -3
  96. package/build/src/models/store/Group.d.ts.map +1 -1
  97. package/build/src/models/store/Group.js.map +1 -1
  98. package/build/src/models/store/Invitation.d.ts +3 -3
  99. package/build/src/models/store/Invitation.d.ts.map +1 -1
  100. package/build/src/models/store/Invitation.js.map +1 -1
  101. package/build/src/models/store/Modification.d.ts +5 -1
  102. package/build/src/models/store/Modification.d.ts.map +1 -1
  103. package/build/src/models/store/Modification.js.map +1 -1
  104. package/build/src/models/store/Organization.d.ts +31 -13
  105. package/build/src/models/store/Organization.d.ts.map +1 -1
  106. package/build/src/models/store/Organization.js +29 -47
  107. package/build/src/models/store/Organization.js.map +1 -1
  108. package/build/src/models/store/Permission.d.ts +9 -5
  109. package/build/src/models/store/Permission.d.ts.map +1 -1
  110. package/build/src/models/store/Permission.js.map +1 -1
  111. package/build/src/models/store/User.d.ts +18 -6
  112. package/build/src/models/store/User.d.ts.map +1 -1
  113. package/build/src/models/store/User.js.map +1 -1
  114. package/build/src/models/store/UserIdentity.d.ts +9 -5
  115. package/build/src/models/store/UserIdentity.d.ts.map +1 -1
  116. package/build/src/models/store/UserIdentity.js.map +1 -1
  117. package/build/src/sdk/FilesSdk.d.ts +15 -15
  118. package/build/src/sdk/FilesSdk.d.ts.map +1 -1
  119. package/build/src/sdk/FilesSdk.js +1 -1
  120. package/build/src/sdk/FilesSdk.js.map +1 -1
  121. package/build/src/sdk/OrganizationsSdk.d.ts +25 -9
  122. package/build/src/sdk/OrganizationsSdk.d.ts.map +1 -1
  123. package/build/src/sdk/OrganizationsSdk.js +76 -0
  124. package/build/src/sdk/OrganizationsSdk.js.map +1 -1
  125. package/build/src/sdk/RouteBuilder.d.ts +2 -0
  126. package/build/src/sdk/RouteBuilder.d.ts.map +1 -1
  127. package/build/src/sdk/RouteBuilder.js +6 -0
  128. package/build/src/sdk/RouteBuilder.js.map +1 -1
  129. package/build/src/sdk/SdkMock.d.ts +12 -0
  130. package/build/src/sdk/SdkMock.d.ts.map +1 -1
  131. package/build/src/sdk/SdkMock.js +38 -6
  132. package/build/src/sdk/SdkMock.js.map +1 -1
  133. package/build/src/sdk/SharedSdk.d.ts +2 -2
  134. package/build/src/sdk/SharedSdk.d.ts.map +1 -1
  135. package/build/src/sdk/SharedSdk.js.map +1 -1
  136. package/build/src/sdk/StoreSdkNode.d.ts +1 -1
  137. package/build/src/sdk/StoreSdkNode.d.ts.map +1 -1
  138. package/build/src/sdk/StoreSdkNode.js.map +1 -1
  139. package/build/src/sdk/StoreSdkWeb.d.ts +1 -1
  140. package/build/src/sdk/StoreSdkWeb.d.ts.map +1 -1
  141. package/build/src/sdk/StoreSdkWeb.js.map +1 -1
  142. package/build/src/sdk/UsersSdk.d.ts +5 -5
  143. package/build/src/sdk/UsersSdk.d.ts.map +1 -1
  144. package/build/src/sdk/UsersSdk.js.map +1 -1
  145. package/build/tsconfig.tsbuildinfo +1 -1
  146. package/package.json +1 -1
  147. package/src/mocking/ProjectMock.ts +1 -1
  148. package/src/mocking/lib/File.ts +5 -5
  149. package/src/mocking/lib/Organization.ts +26 -3
  150. package/src/mocking/lib/Permission.ts +8 -8
  151. package/src/mocking/lib/User.ts +11 -6
  152. package/src/modeling/ApiFile.ts +11 -6
  153. package/src/modeling/ApiModel.ts +2 -2
  154. package/src/modeling/DataDomain.ts +2 -2
  155. package/src/modeling/DomainAssociation.ts +2 -2
  156. package/src/modeling/DomainEntity.ts +2 -2
  157. package/src/modeling/DomainFile.ts +11 -6
  158. package/src/modeling/DomainModel.ts +2 -2
  159. package/src/modeling/DomainNamespace.ts +2 -2
  160. package/src/modeling/DomainProperty.ts +2 -2
  161. package/src/modeling/helpers/Intelisense.ts +41 -38
  162. package/src/models/AiMessage.ts +3 -3
  163. package/src/models/AiSession.ts +3 -3
  164. package/src/models/CertificateFile.ts +2 -2
  165. package/src/models/Environment.ts +2 -2
  166. package/src/models/Folder.ts +13 -8
  167. package/src/models/HttpProject.ts +2 -2
  168. package/src/models/ProjectFolder.ts +2 -2
  169. package/src/models/Request.ts +3 -3
  170. package/src/models/Thing.ts +14 -9
  171. package/src/models/TrashEntry.ts +2 -2
  172. package/src/models/store/Capabilities.ts +6 -1
  173. package/src/models/store/Deletion.ts +6 -1
  174. package/src/models/store/File.ts +53 -43
  175. package/src/models/store/Group.ts +3 -3
  176. package/src/models/store/Invitation.ts +3 -3
  177. package/src/models/store/Modification.ts +6 -1
  178. package/src/models/store/Organization.ts +59 -60
  179. package/src/models/store/Permission.ts +17 -12
  180. package/src/models/store/User.ts +21 -6
  181. package/src/models/store/UserIdentity.ts +13 -8
  182. package/src/sdk/FilesSdk.ts +29 -25
  183. package/src/sdk/OrganizationsSdk.ts +100 -16
  184. package/src/sdk/RouteBuilder.ts +8 -0
  185. package/src/sdk/SdkMock.ts +66 -16
  186. package/src/sdk/SharedSdk.ts +3 -3
  187. package/src/sdk/StoreSdkNode.ts +3 -3
  188. package/src/sdk/StoreSdkWeb.ts +3 -3
  189. package/src/sdk/UsersSdk.ts +6 -6
  190. package/tests/unit/mocking/current/File.spec.ts +5 -5
  191. package/tests/unit/mocking/current/Organization.spec.ts +4 -3
  192. package/tests/unit/mocking/current/Permission.spec.ts +2 -2
  193. package/tests/unit/mocking/current/User.spec.ts +2 -2
  194. package/tests/unit/modeling/domain_file.spec.ts +3 -3
  195. package/tests/unit/models/File/createFileCapabilities.spec.ts +3 -3
  196. package/tests/unit/models/File/new.spec.ts +2 -2
  197. package/tests/unit/models/File/setDeleted.spec.ts +3 -3
  198. package/tests/unit/models/File/setLastModified.spec.ts +3 -3
  199. package/tests/unit/models/File/toJSON.spec.ts +2 -2
  200. package/tests/unit/models/Folder/create.spec.ts +3 -3
  201. package/tests/unit/models/Permission/all.spec.ts +3 -3
  202. package/tests/unit/models/store/Invitation.spec.ts +2 -2
  203. package/tests/unit/models/store/Organization.spec.ts +100 -0
  204. package/tests/unit/models/store/Permission.spec.ts +16 -6
  205. package/tests/unit/models/thing.spec.ts +3 -3
@@ -1,7 +1,7 @@
1
- import type { IDeletion } from './Deletion.js'
1
+ import type { DeletionSchema } from './Deletion.js'
2
2
  import type { UserOrganizationGrantType } from './Organization.js'
3
3
 
4
- export interface IEmail {
4
+ export interface EmailSchema {
5
5
  /**
6
6
  * When available the email of the user.
7
7
  */
@@ -13,7 +13,12 @@ export interface IEmail {
13
13
  verified?: boolean
14
14
  }
15
15
 
16
- export interface IUserPicture {
16
+ /**
17
+ * @deprecated Use {@link EmailSchema} instead.
18
+ */
19
+ export type IEmail = EmailSchema
20
+
21
+ export interface UserPictureSchema {
17
22
  /**
18
23
  * When available, the URL to the user's picture image.
19
24
  */
@@ -24,6 +29,11 @@ export interface IUserPicture {
24
29
  data?: string
25
30
  }
26
31
 
32
+ /**
33
+ * @deprecated Use {@link UserPictureSchema} instead.
34
+ */
35
+ export type IUserPicture = UserPictureSchema
36
+
27
37
  export const Kind = 'Core#User'
28
38
 
29
39
  export type UserStatus = 'active' | 'deleted' | 'suspended' | 'pending'
@@ -36,7 +46,7 @@ export type UserStatus = 'active' | 'deleted' | 'suspended' | 'pending'
36
46
  * Note, the store implementation may have additional fields that support external
37
47
  * identity providers. However, this is not exposed to the user through the API.
38
48
  */
39
- export interface IUser {
49
+ export interface UserSchema {
40
50
  kind: typeof Kind
41
51
  /**
42
52
  * The data store key of the user.
@@ -53,7 +63,7 @@ export interface IUser {
53
63
  /**
54
64
  * The user picture to render.
55
65
  */
56
- picture?: IUserPicture
66
+ picture?: UserPictureSchema
57
67
  /**
58
68
  * A general purpose tags field.
59
69
  */
@@ -109,5 +119,10 @@ export interface IUser {
109
119
  * The information about the delete information.
110
120
  * Always set when the `delete` is true.
111
121
  */
112
- deletedInfo?: IDeletion
122
+ deletedInfo?: DeletionSchema
113
123
  }
124
+
125
+ /**
126
+ * @deprecated Use {@link UserSchema} instead.
127
+ */
128
+ export type IUser = UserSchema
@@ -9,7 +9,7 @@ type Provider = 'google'
9
9
  * This association allows the user to use different identity providers that map to the same user, as long as the
10
10
  * email stays consistent.
11
11
  */
12
- export interface IUserIdentity {
12
+ export interface UserIdentitySchema {
13
13
  kind: typeof Kind
14
14
  /**
15
15
  * The database ID
@@ -39,7 +39,12 @@ export interface IUserIdentity {
39
39
  hostDomain?: string
40
40
  }
41
41
 
42
- export class UserIdentity implements IUserIdentity {
42
+ /**
43
+ * @deprecated Use {@link UserIdentitySchema} instead.
44
+ */
45
+ export type IUserIdentity = UserIdentitySchema
46
+
47
+ export class UserIdentity implements UserIdentitySchema {
43
48
  kind: typeof Kind = Kind
44
49
  key = ''
45
50
  userId = ''
@@ -48,8 +53,8 @@ export class UserIdentity implements IUserIdentity {
48
53
  emailVerified = false
49
54
  hostDomain?: string
50
55
 
51
- constructor(input?: string | IUserIdentity) {
52
- let init: IUserIdentity
56
+ constructor(input?: string | UserIdentitySchema) {
57
+ let init: UserIdentitySchema
53
58
  if (typeof input === 'string') {
54
59
  init = JSON.parse(input)
55
60
  } else if (typeof input === 'object') {
@@ -67,7 +72,7 @@ export class UserIdentity implements IUserIdentity {
67
72
  this.new(init)
68
73
  }
69
74
 
70
- new(init: IUserIdentity): void {
75
+ new(init: UserIdentitySchema): void {
71
76
  if (!UserIdentity.isUserIdentity(init)) {
72
77
  throw new Error(`Not a UserIdentity.`)
73
78
  }
@@ -86,15 +91,15 @@ export class UserIdentity implements IUserIdentity {
86
91
  }
87
92
 
88
93
  static isUserIdentity(input: unknown): boolean {
89
- const typed = input as IUserIdentity
94
+ const typed = input as UserIdentitySchema
90
95
  if (!input || typed.kind !== Kind) {
91
96
  return false
92
97
  }
93
98
  return true
94
99
  }
95
100
 
96
- toJSON(): IUserIdentity {
97
- const result: IUserIdentity = {
101
+ toJSON(): UserIdentitySchema {
102
+ const result: UserIdentitySchema = {
98
103
  kind: Kind,
99
104
  key: this.key,
100
105
  provider: this.provider,
@@ -7,13 +7,13 @@ import {
7
7
  SdkOptions,
8
8
  } from './SdkBase.js'
9
9
  import { RouteBuilder } from './RouteBuilder.js'
10
- import type { IUser } from '../models/store/User.js'
11
- import type { FileBreadcrumb, IFile } from '../models/store/File.js'
10
+ import type { UserSchema } from '../models/store/User.js'
11
+ import type { FileBreadcrumb, FileSchema } from '../models/store/File.js'
12
12
  import { FolderKind, CertificateFileKind, ProjectKind, DomainFileKind } from '../models/kinds.js'
13
13
  import type { ContextListResult, IBulkOperationResult, ContextListOptions } from '../events/BaseEvents.js'
14
14
  import type { IAccessAddOperation, IAccessRemoveOperation, PermissionRole } from '../models/store/Permission.js'
15
15
  import { nanoid } from '../nanoid.js'
16
- import { Folder, type IFolder } from '../models/Folder.js'
16
+ import { Folder, type FolderSchema } from '../models/Folder.js'
17
17
  import type { AccessPatchInfo, MediaPatchInfo, MediaPatchRevision, PatchInfo } from '../patch/types.js'
18
18
  import { Exception } from '../exceptions/exception.js'
19
19
 
@@ -57,7 +57,7 @@ export class FilesSdk extends SdkBase {
57
57
  organization: string,
58
58
  options: ContextListOptions = {},
59
59
  request: SdkOptions = {}
60
- ): Promise<ContextListResult<IFile>> {
60
+ ): Promise<ContextListResult<FileSchema>> {
61
61
  const { token } = request
62
62
  const opts = { ...options }
63
63
  const url = this.sdk.getUrl(RouteBuilder.files(organization))
@@ -72,7 +72,7 @@ export class FilesSdk extends SdkBase {
72
72
  if (!result.body) {
73
73
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
74
74
  }
75
- let data: ContextListResult<IFile>
75
+ let data: ContextListResult<FileSchema>
76
76
  try {
77
77
  data = JSON.parse(result.body)
78
78
  } catch {
@@ -94,12 +94,12 @@ export class FilesSdk extends SdkBase {
94
94
  * @returns The id of the created file meta.
95
95
  */
96
96
  async create(
97
- meta: IFile,
97
+ meta: FileSchema,
98
98
  contents: unknown,
99
99
  organization: string,
100
100
  opts: IFileCreateOptions = {},
101
101
  request: SdkOptions = {}
102
- ): Promise<IFile> {
102
+ ): Promise<FileSchema> {
103
103
  const result = await this.createMeta(meta, organization, opts, request)
104
104
  await this.createMedia(contents, organization, result.key, opts, request)
105
105
  return result
@@ -108,17 +108,17 @@ export class FilesSdk extends SdkBase {
108
108
  /**
109
109
  * Creates a file in the store.
110
110
  *
111
- * @param file The definition of a file that extends the IFile interface.
111
+ * @param file The definition of a file that extends the FileSchema interface.
112
112
  * @param opts Optional options when creating a file
113
113
  * @param request Optional request options.
114
114
  * @returns The key of the creates file.
115
115
  */
116
116
  async createMeta(
117
- file: IFile,
117
+ file: FileSchema,
118
118
  organization: string,
119
119
  opts: IMetaCreateOptions = {},
120
120
  request: SdkOptions = {}
121
- ): Promise<IFile> {
121
+ ): Promise<FileSchema> {
122
122
  const { token } = request
123
123
  const url = this.sdk.getUrl(RouteBuilder.files(organization))
124
124
  if (opts.parent) {
@@ -142,7 +142,7 @@ export class FilesSdk extends SdkBase {
142
142
  if (!result.body) {
143
143
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
144
144
  }
145
- let data: IFile
145
+ let data: FileSchema
146
146
  try {
147
147
  data = JSON.parse(result.body)
148
148
  } catch {
@@ -199,7 +199,7 @@ export class FilesSdk extends SdkBase {
199
199
  organization: string,
200
200
  opts: IMetaCreateOptions = {},
201
201
  request: SdkOptions = {}
202
- ): Promise<IFolder> {
202
+ ): Promise<FolderSchema> {
203
203
  const file = Folder.fromName(name)
204
204
  const { token } = request
205
205
  const url = this.sdk.getUrl(RouteBuilder.files(organization))
@@ -224,7 +224,7 @@ export class FilesSdk extends SdkBase {
224
224
  if (!result.body) {
225
225
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
226
226
  }
227
- let data: IFolder
227
+ let data: FolderSchema
228
228
  try {
229
229
  data = JSON.parse(result.body)
230
230
  } catch {
@@ -243,7 +243,7 @@ export class FilesSdk extends SdkBase {
243
243
  * @param fid The file key
244
244
  * @param request Optional request options.
245
245
  */
246
- async read(oid: string, fid: string, request: SdkOptions = {}): Promise<IFile> {
246
+ async read(oid: string, fid: string, request: SdkOptions = {}): Promise<FileSchema> {
247
247
  const { token } = request
248
248
  const url = this.sdk.getUrl(RouteBuilder.file(oid, fid))
249
249
  const result = await this.sdk.http.get(url.toString(), { token })
@@ -256,7 +256,7 @@ export class FilesSdk extends SdkBase {
256
256
  if (!result.body) {
257
257
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
258
258
  }
259
- let data: IFile
259
+ let data: FileSchema
260
260
  try {
261
261
  data = JSON.parse(result.body)
262
262
  } catch {
@@ -314,7 +314,11 @@ export class FilesSdk extends SdkBase {
314
314
  * in that place. It also inserts `undefined` in place of a file that doesn't exist.
315
315
  * @param request Optional request options.
316
316
  */
317
- async readBulk(organization: string, keys: string[], request: SdkOptions = {}): Promise<IBulkOperationResult<IFile>> {
317
+ async readBulk(
318
+ organization: string,
319
+ keys: string[],
320
+ request: SdkOptions = {}
321
+ ): Promise<IBulkOperationResult<FileSchema>> {
318
322
  const { token } = request
319
323
  const url = this.sdk.getUrl(RouteBuilder.filesBatch(organization))
320
324
  const body = JSON.stringify({ ids: keys })
@@ -328,7 +332,7 @@ export class FilesSdk extends SdkBase {
328
332
  if (!result.body) {
329
333
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
330
334
  }
331
- let data: IBulkOperationResult<IFile>
335
+ let data: IBulkOperationResult<FileSchema>
332
336
  try {
333
337
  data = JSON.parse(result.body)
334
338
  } catch {
@@ -347,7 +351,7 @@ export class FilesSdk extends SdkBase {
347
351
  * @param request Optional request options.
348
352
  * @returns The updated file object after applying the patch
349
353
  */
350
- async patch(oid: string, fid: string, info: PatchInfo, request: SdkOptions = {}): Promise<IFile> {
354
+ async patch(oid: string, fid: string, info: PatchInfo, request: SdkOptions = {}): Promise<FileSchema> {
351
355
  const { token } = request
352
356
  const path = RouteBuilder.file(oid, fid)
353
357
  const url = this.sdk.getUrl(path)
@@ -362,7 +366,7 @@ export class FilesSdk extends SdkBase {
362
366
  if (!result.body) {
363
367
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
364
368
  }
365
- let data: IFile
369
+ let data: FileSchema
366
370
  try {
367
371
  data = JSON.parse(result.body)
368
372
  } catch {
@@ -445,7 +449,7 @@ export class FilesSdk extends SdkBase {
445
449
  * @param info The patch operation on the file's ACL
446
450
  * @param request Optional request options.
447
451
  */
448
- async patchUsers(oid: string, fid: string, info: AccessPatchInfo, request: SdkOptions = {}): Promise<IFile> {
452
+ async patchUsers(oid: string, fid: string, info: AccessPatchInfo, request: SdkOptions = {}): Promise<FileSchema> {
449
453
  const { token } = request
450
454
  const url = this.sdk.getUrl(RouteBuilder.filesAccess(oid, fid))
451
455
  const body = JSON.stringify(info)
@@ -459,7 +463,7 @@ export class FilesSdk extends SdkBase {
459
463
  if (!result.body) {
460
464
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
461
465
  }
462
- let data: IFile
466
+ let data: FileSchema
463
467
  try {
464
468
  data = JSON.parse(result.body)
465
469
  } catch {
@@ -487,7 +491,7 @@ export class FilesSdk extends SdkBase {
487
491
  role: PermissionRole,
488
492
  expires?: number,
489
493
  request?: SdkOptions
490
- ): Promise<IFile> {
494
+ ): Promise<FileSchema> {
491
495
  const op: IAccessAddOperation = {
492
496
  op: 'add',
493
497
  type: 'user',
@@ -511,7 +515,7 @@ export class FilesSdk extends SdkBase {
511
515
  * @param key The file key
512
516
  * @param otherUserKey The key of the user that gets access to the organization
513
517
  */
514
- async removeUser(organization: string, key: string, otherUserKey: string, request?: SdkOptions): Promise<IFile> {
518
+ async removeUser(organization: string, key: string, otherUserKey: string, request?: SdkOptions): Promise<FileSchema> {
515
519
  const op: IAccessRemoveOperation = {
516
520
  op: 'remove',
517
521
  type: 'user',
@@ -530,7 +534,7 @@ export class FilesSdk extends SdkBase {
530
534
  * @param key The file key
531
535
  * @param request Optional request options.
532
536
  */
533
- async listUsers(organization: string, key: string, request: SdkOptions = {}): Promise<ContextListResult<IUser>> {
537
+ async listUsers(organization: string, key: string, request: SdkOptions = {}): Promise<ContextListResult<UserSchema>> {
534
538
  const { token } = request
535
539
  const url = this.sdk.getUrl(RouteBuilder.fileUsers(organization, key))
536
540
  const result = await this.sdk.http.get(url.toString(), { token })
@@ -543,7 +547,7 @@ export class FilesSdk extends SdkBase {
543
547
  if (!result.body) {
544
548
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
545
549
  }
546
- let data: ContextListResult<IUser>
550
+ let data: ContextListResult<UserSchema>
547
551
  try {
548
552
  data = JSON.parse(result.body)
549
553
  } catch {
@@ -8,17 +8,21 @@ import {
8
8
  } from './SdkBase.js'
9
9
  import { RouteBuilder } from './RouteBuilder.js'
10
10
  import type { ContextListOptions, ContextListResult } from '../events/BaseEvents.js'
11
- import type { IOrganization, UserOrganizationGrantType } from '../models/store/Organization.js'
11
+ import type {
12
+ OrganizationSchema,
13
+ UserOrganizationGrantType,
14
+ OrganizationSlugValidateResponse,
15
+ } from '../models/store/Organization.js'
12
16
  import type { InvitationSchema } from '../models/store/Invitation.js'
13
17
  import type { PatchInfo } from '../patch/types.js'
14
- import type { IUser } from '../models/store/User.js'
18
+ import type { UserSchema } from '../models/store/User.js'
15
19
  import { Exception } from '../exceptions/exception.js'
16
20
 
17
21
  export class OrganizationsSdk extends SdkBase {
18
22
  /**
19
23
  * Lists all user organizations.
20
24
  */
21
- async list(request: SdkOptions = {}): Promise<ContextListResult<IOrganization>> {
25
+ async list(request: SdkOptions = {}): Promise<ContextListResult<OrganizationSchema>> {
22
26
  const { token } = request
23
27
  const url = this.sdk.getUrl(RouteBuilder.organizations())
24
28
  const result = await this.sdk.http.get(url.toString(), { token })
@@ -31,7 +35,7 @@ export class OrganizationsSdk extends SdkBase {
31
35
  if (!result.body) {
32
36
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
33
37
  }
34
- let data: ContextListResult<IOrganization>
38
+ let data: ContextListResult<OrganizationSchema>
35
39
  try {
36
40
  data = JSON.parse(result.body)
37
41
  } catch {
@@ -49,7 +53,7 @@ export class OrganizationsSdk extends SdkBase {
49
53
  * @param request The request options.
50
54
  * @returns A promise that resolves to the created organization.
51
55
  */
52
- async create(orgName: string, request: SdkOptions = {}): Promise<IOrganization> {
56
+ async create(orgName: string, request: SdkOptions = {}): Promise<OrganizationSchema> {
53
57
  const { token } = request
54
58
  const url = this.sdk.getUrl(RouteBuilder.organizations())
55
59
  const body = {
@@ -71,7 +75,7 @@ export class OrganizationsSdk extends SdkBase {
71
75
  if (!result.body) {
72
76
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
73
77
  }
74
- let data: IOrganization
78
+ let data: OrganizationSchema
75
79
  try {
76
80
  data = JSON.parse(result.body)
77
81
  } catch {
@@ -345,7 +349,7 @@ export class OrganizationsSdk extends SdkBase {
345
349
  oid: string,
346
350
  options?: ContextListOptions,
347
351
  request: SdkOptions = {}
348
- ): Promise<ContextListResult<IUser>> => {
352
+ ): Promise<ContextListResult<UserSchema>> => {
349
353
  const { token } = request
350
354
  const url = this.sdk.getUrl(RouteBuilder.organizationUsers(oid))
351
355
  this.sdk.appendListOptions(url, options)
@@ -359,7 +363,7 @@ export class OrganizationsSdk extends SdkBase {
359
363
  if (!result.body) {
360
364
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
361
365
  }
362
- let data: ContextListResult<IUser>
366
+ let data: ContextListResult<UserSchema>
363
367
  try {
364
368
  data = JSON.parse(result.body)
365
369
  } catch {
@@ -379,7 +383,7 @@ export class OrganizationsSdk extends SdkBase {
379
383
  * @param request Optional request options.
380
384
  * @returns The user object
381
385
  */
382
- read: async (oid: string, key: string, request: SdkOptions = {}): Promise<IUser> => {
386
+ read: async (oid: string, key: string, request: SdkOptions = {}): Promise<UserSchema> => {
383
387
  const { token } = request
384
388
  const url = this.sdk.getUrl(RouteBuilder.organizationUser(oid, key))
385
389
  const result = await this.sdk.http.get(url.toString(), { token })
@@ -392,7 +396,7 @@ export class OrganizationsSdk extends SdkBase {
392
396
  if (!result.body) {
393
397
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
394
398
  }
395
- let data: IUser
399
+ let data: UserSchema
396
400
  try {
397
401
  data = JSON.parse(result.body)
398
402
  } catch {
@@ -410,7 +414,11 @@ export class OrganizationsSdk extends SdkBase {
410
414
  * @param request Optional request options.
411
415
  * @returns The created user object.
412
416
  */
413
- readBatch: async (oid: string, keys: string[], request: SdkOptions = {}): Promise<ContextListResult<IUser>> => {
417
+ readBatch: async (
418
+ oid: string,
419
+ keys: string[],
420
+ request: SdkOptions = {}
421
+ ): Promise<ContextListResult<UserSchema>> => {
414
422
  const { token } = request
415
423
  const url = this.sdk.getUrl(RouteBuilder.organizationUserBatch(oid))
416
424
  const body = {
@@ -429,7 +437,7 @@ export class OrganizationsSdk extends SdkBase {
429
437
  if (!result.body) {
430
438
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
431
439
  }
432
- let data: ContextListResult<IUser>
440
+ let data: ContextListResult<UserSchema>
433
441
  try {
434
442
  data = JSON.parse(result.body)
435
443
  } catch {
@@ -447,7 +455,7 @@ export class OrganizationsSdk extends SdkBase {
447
455
  * @param oid The key of the organization parent organization.
448
456
  * @param key The user key.
449
457
  */
450
- activate: async (oid: string, key: string, request: SdkOptions = {}): Promise<IUser> => {
458
+ activate: async (oid: string, key: string, request: SdkOptions = {}): Promise<UserSchema> => {
451
459
  const { token } = request
452
460
  const url = this.sdk.getUrl(RouteBuilder.organizationUserActivate(oid, key))
453
461
  const result = await this.sdk.http.post(url.toString(), { token })
@@ -460,7 +468,7 @@ export class OrganizationsSdk extends SdkBase {
460
468
  if (!result.body) {
461
469
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
462
470
  }
463
- let data: IUser
471
+ let data: UserSchema
464
472
  try {
465
473
  data = JSON.parse(result.body)
466
474
  } catch {
@@ -475,7 +483,7 @@ export class OrganizationsSdk extends SdkBase {
475
483
  * @param oid The key of the organization parent organization.
476
484
  * @param key The user key.
477
485
  */
478
- deactivate: async (oid: string, key: string, request: SdkOptions = {}): Promise<IUser> => {
486
+ deactivate: async (oid: string, key: string, request: SdkOptions = {}): Promise<UserSchema> => {
479
487
  const { token } = request
480
488
  const url = this.sdk.getUrl(RouteBuilder.organizationUserDeactivate(oid, key))
481
489
  const result = await this.sdk.http.post(url.toString(), { token })
@@ -488,7 +496,7 @@ export class OrganizationsSdk extends SdkBase {
488
496
  if (!result.body) {
489
497
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
490
498
  }
491
- let data: IUser
499
+ let data: UserSchema
492
500
  try {
493
501
  data = JSON.parse(result.body)
494
502
  } catch {
@@ -516,4 +524,80 @@ export class OrganizationsSdk extends SdkBase {
516
524
  }
517
525
  },
518
526
  }
527
+
528
+ slugs = {
529
+ /**
530
+ * Generates a slug for the organization.
531
+ * @param name The name of the organization.
532
+ * @param request Optional request options.
533
+ * @returns A promise that resolves to the generated slug.
534
+ */
535
+ generate: async (name: string, request: SdkOptions = {}): Promise<string> => {
536
+ const { token } = request
537
+ const url = this.sdk.getUrl(RouteBuilder.orgSlugGenerate()).toString()
538
+ const body = {
539
+ name,
540
+ }
541
+ const result = await this.sdk.http.post(url, {
542
+ body: JSON.stringify(body),
543
+ token,
544
+ })
545
+ this.inspectCommonStatusCodes(result)
546
+ const E_PREFIX = 'Unable to generate the slug. '
547
+ if (result.status !== 200) {
548
+ this.logInvalidResponse(result)
549
+ throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)
550
+ }
551
+ if (!result.body) {
552
+ throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
553
+ }
554
+ let data: { slug: string }
555
+ try {
556
+ data = JSON.parse(result.body)
557
+ } catch {
558
+ throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status })
559
+ }
560
+ if (!data.slug) {
561
+ throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status })
562
+ }
563
+ return data.slug
564
+ },
565
+
566
+ /**
567
+ * Validates a slug for the organization.
568
+ * @param slug The slug to validate.
569
+ * @param request Optional request options.
570
+ * @returns A promise that resolves to the validation result.
571
+ */
572
+ validate: async (slug: string, request: SdkOptions = {}): Promise<OrganizationSlugValidateResponse> => {
573
+ const { token } = request
574
+ const url = this.sdk.getUrl(RouteBuilder.orgSlugValidate()).toString()
575
+ const body = {
576
+ slug,
577
+ }
578
+ const result = await this.sdk.http.post(url, {
579
+ body: JSON.stringify(body),
580
+ token,
581
+ })
582
+ this.inspectCommonStatusCodes(result)
583
+ const E_PREFIX = 'Unable to validate the slug. '
584
+ if (result.status !== 200) {
585
+ this.logInvalidResponse(result)
586
+ throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)
587
+ }
588
+ if (!result.body) {
589
+ throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
590
+ }
591
+ let data: OrganizationSlugValidateResponse
592
+ try {
593
+ data = JSON.parse(result.body)
594
+ } catch {
595
+ throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status })
596
+ }
597
+ if (typeof data.valid !== 'boolean') {
598
+ throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status })
599
+ }
600
+ return data
601
+ },
602
+ }
519
603
  }
@@ -326,4 +326,12 @@ export class RouteBuilder {
326
326
  static aiMessage(oid: string, sid: string, mid: string): string {
327
327
  return `${RouteBuilder.aiMessages(oid, sid)}/${mid}`
328
328
  }
329
+
330
+ static orgSlugGenerate(): string {
331
+ return `/v1/orgs/slugs/generate`
332
+ }
333
+
334
+ static orgSlugValidate(): string {
335
+ return `/v1/orgs/slugs/validate`
336
+ }
329
337
  }