@api-client/core 0.13.2 → 0.13.4

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.
@@ -41728,15 +41728,15 @@
41728
41728
  "@id": "#194"
41729
41729
  },
41730
41730
  {
41731
- "@id": "#203"
41732
- },
41733
- {
41734
41731
  "@id": "#197"
41735
41732
  },
41736
41733
  {
41737
41734
  "@id": "#200"
41738
41735
  },
41739
41736
  {
41737
+ "@id": "#203"
41738
+ },
41739
+ {
41740
41740
  "@id": "#206"
41741
41741
  },
41742
41742
  {
@@ -43138,7 +43138,7 @@
43138
43138
  "doc:ExternalDomainElement",
43139
43139
  "doc:DomainElement"
43140
43140
  ],
43141
- "doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
43141
+ "doc:raw": "code: '5'\ndescription: 'Limited company'\n",
43142
43142
  "core:mediaType": "application/yaml",
43143
43143
  "sourcemaps:sources": [
43144
43144
  {
@@ -43159,7 +43159,7 @@
43159
43159
  "doc:ExternalDomainElement",
43160
43160
  "doc:DomainElement"
43161
43161
  ],
43162
- "doc:raw": "code: 'J'\ndescription: 'Information and communication'\n",
43162
+ "doc:raw": "class: '3'\ndescription: '150 - 300'\nnumberOfFte: 5500\nnumberOfEmployees: 5232\n",
43163
43163
  "core:mediaType": "application/yaml",
43164
43164
  "sourcemaps:sources": [
43165
43165
  {
@@ -43180,7 +43180,7 @@
43180
43180
  "doc:ExternalDomainElement",
43181
43181
  "doc:DomainElement"
43182
43182
  ],
43183
- "doc:raw": "code: '5'\ndescription: 'Limited company'\n",
43183
+ "doc:raw": "code: 'J'\ndescription: 'Information and communication'\n",
43184
43184
  "core:mediaType": "application/yaml",
43185
43185
  "sourcemaps:sources": [
43186
43186
  {
@@ -44426,12 +44426,12 @@
44426
44426
  {
44427
44427
  "@id": "#199/source-map/lexical/element_0",
44428
44428
  "sourcemaps:element": "amf://id#199",
44429
- "sourcemaps:value": "[(1,0)-(5,0)]"
44429
+ "sourcemaps:value": "[(1,0)-(3,0)]"
44430
44430
  },
44431
44431
  {
44432
44432
  "@id": "#202/source-map/lexical/element_0",
44433
44433
  "sourcemaps:element": "amf://id#202",
44434
- "sourcemaps:value": "[(1,0)-(3,0)]"
44434
+ "sourcemaps:value": "[(1,0)-(5,0)]"
44435
44435
  },
44436
44436
  {
44437
44437
  "@id": "#205/source-map/lexical/element_0",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@api-client/core",
3
3
  "description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
4
- "version": "0.13.2",
4
+ "version": "0.13.4",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  "./browser.js": {
@@ -7,16 +7,11 @@ import {
7
7
  SdkOptions,
8
8
  } from './SdkBase.js'
9
9
  import { RouteBuilder } from './RouteBuilder.js'
10
- import { IUser } from '../models/store/User.js'
11
- import { FileBreadcrumb, IFile } from '../models/store/File.js'
10
+ import type { IUser } from '../models/store/User.js'
11
+ import type { FileBreadcrumb, IFile } from '../models/store/File.js'
12
12
  import { FolderKind, CertificateFileKind, ProjectKind, DomainFileKind } from '../models/kinds.js'
13
- import {
14
- ContextListResult,
15
- ContextChangeRecord,
16
- IBulkOperationResult,
17
- ContextListOptions,
18
- } from '../events/BaseEvents.js'
19
- import { IAccessAddOperation, IAccessRemoveOperation, PermissionRole } from '../models/store/Permission.js'
13
+ import type { ContextListResult, IBulkOperationResult, ContextListOptions } from '../events/BaseEvents.js'
14
+ import type { IAccessAddOperation, IAccessRemoveOperation, PermissionRole } from '../models/store/Permission.js'
20
15
  import { nanoid } from 'nanoid'
21
16
  import { Folder, type IFolder } from '../models/Folder.js'
22
17
  import type { AccessPatchInfo, MediaPatchInfo, MediaPatchRevision, PatchInfo } from '../patch/types.js'
@@ -104,7 +99,7 @@ export class FilesSdk extends SdkBase {
104
99
  organization: string,
105
100
  opts: IFileCreateOptions = {},
106
101
  request: SdkOptions = {}
107
- ): Promise<ContextChangeRecord<IFile>> {
102
+ ): Promise<IFile> {
108
103
  const result = await this.createMeta(meta, organization, opts, request)
109
104
  await this.createMedia(contents, organization, result.key, opts, request)
110
105
  return result
@@ -123,7 +118,7 @@ export class FilesSdk extends SdkBase {
123
118
  organization: string,
124
119
  opts: IMetaCreateOptions = {},
125
120
  request: SdkOptions = {}
126
- ): Promise<ContextChangeRecord<IFile>> {
121
+ ): Promise<IFile> {
127
122
  const { token } = request
128
123
  const url = this.sdk.getUrl(RouteBuilder.files(organization))
129
124
  if (opts.parent) {
@@ -147,7 +142,7 @@ export class FilesSdk extends SdkBase {
147
142
  if (!result.body) {
148
143
  throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
149
144
  }
150
- let data: ContextChangeRecord<IFile>
145
+ let data: IFile
151
146
  try {
152
147
  data = JSON.parse(result.body)
153
148
  } catch {
@@ -450,17 +445,30 @@ export class FilesSdk extends SdkBase {
450
445
  * @param info The patch operation on the file's ACL
451
446
  * @param request Optional request options.
452
447
  */
453
- async patchUsers(oid: string, fid: string, info: AccessPatchInfo, request: SdkOptions = {}): Promise<void> {
448
+ async patchUsers(oid: string, fid: string, info: AccessPatchInfo, request: SdkOptions = {}): Promise<IFile> {
454
449
  const { token } = request
455
- const url = this.sdk.getUrl(RouteBuilder.fileUsers(oid, fid))
450
+ const url = this.sdk.getUrl(RouteBuilder.filesAccess(oid, fid))
456
451
  const body = JSON.stringify(info)
457
452
  const result = await this.sdk.http.patch(url.toString(), { token, body })
458
453
  this.inspectCommonStatusCodes(result)
459
454
  const E_PREFIX = 'Unable to patch the file. '
460
- if (result.status !== 204) {
455
+ if (result.status !== 200) {
461
456
  this.logInvalidResponse(result)
462
457
  throw this.createApiError(`${E_PREFIX}${E_RESPONSE_STATUS}${result.status}`, result.body)
463
458
  }
459
+ if (!result.body) {
460
+ throw new Exception(`${E_PREFIX}${E_RESPONSE_NO_VALUE}`, { code: 'E_RESPONSE_NO_VALUE', status: result.status })
461
+ }
462
+ let data: IFile
463
+ try {
464
+ data = JSON.parse(result.body)
465
+ } catch {
466
+ throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status })
467
+ }
468
+ if (!data.key) {
469
+ throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status })
470
+ }
471
+ return data
464
472
  }
465
473
 
466
474
  /**
@@ -479,7 +487,7 @@ export class FilesSdk extends SdkBase {
479
487
  role: PermissionRole,
480
488
  expires?: number,
481
489
  request?: SdkOptions
482
- ): Promise<void> {
490
+ ): Promise<IFile> {
483
491
  const op: IAccessAddOperation = {
484
492
  op: 'add',
485
493
  type: 'user',
@@ -503,7 +511,7 @@ export class FilesSdk extends SdkBase {
503
511
  * @param key The file key
504
512
  * @param otherUserKey The key of the user that gets access to the organization
505
513
  */
506
- async removeUser(organization: string, key: string, otherUserKey: string, request?: SdkOptions): Promise<void> {
514
+ async removeUser(organization: string, key: string, otherUserKey: string, request?: SdkOptions): Promise<IFile> {
507
515
  const op: IAccessRemoveOperation = {
508
516
  op: 'remove',
509
517
  type: 'user',
@@ -19,11 +19,10 @@ export class RouteBuilder {
19
19
  }
20
20
 
21
21
  /**
22
- * Used for SSE or WS to inform clients about a file being shared with the user.
23
- * @returns The path to the /files/access route.
22
+ * Used to patch file access.
24
23
  */
25
- static filesAccess(oid: string): string {
26
- return `${RouteBuilder.files(oid)}/access`
24
+ static filesAccess(oid: string, fid: string): string {
25
+ return `${RouteBuilder.file(oid, fid)}/access`
27
26
  }
28
27
 
29
28
  /**
@@ -167,7 +166,7 @@ export class RouteBuilder {
167
166
  }
168
167
 
169
168
  static organizationUserBatch(oid: string): string {
170
- return `${this.organization(oid)}/batch/read`
169
+ return `${this.organization(oid)}/users/batch/read`
171
170
  }
172
171
 
173
172
  static organizationUser(oid: string, key: string): string {