@api-client/core 0.13.3 → 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.
@@ -42473,13 +42473,13 @@
42473
42473
  "@id": "#210"
42474
42474
  },
42475
42475
  {
42476
- "@id": "#219"
42477
- },
42478
- {
42479
42476
  "@id": "#213"
42480
42477
  },
42481
42478
  {
42482
42479
  "@id": "#216"
42480
+ },
42481
+ {
42482
+ "@id": "#219"
42483
42483
  }
42484
42484
  ],
42485
42485
  "doc:root": false,
@@ -43913,7 +43913,7 @@
43913
43913
  "doc:ExternalDomainElement",
43914
43914
  "doc:DomainElement"
43915
43915
  ],
43916
- "doc:raw": "-\n type: 'GENERAL'\n value: 'info@company.be'\n-\n type: 'IT_DEPT'\n value: 'it-service@company.be'\n",
43916
+ "doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '21'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)21 302099'\n",
43917
43917
  "core:mediaType": "application/yaml",
43918
43918
  "sourcemaps:sources": [
43919
43919
  {
@@ -43934,7 +43934,7 @@
43934
43934
  "doc:ExternalDomainElement",
43935
43935
  "doc:DomainElement"
43936
43936
  ],
43937
- "doc:raw": "type: \"GENERAL\"\nvalue: \"www.company.be\"\n",
43937
+ "doc:raw": "-\n type: 'GENERAL'\n value: 'info@company.be'\n-\n type: 'IT_DEPT'\n value: 'it-service@company.be'\n",
43938
43938
  "core:mediaType": "application/yaml",
43939
43939
  "sourcemaps:sources": [
43940
43940
  {
@@ -43955,7 +43955,7 @@
43955
43955
  "doc:ExternalDomainElement",
43956
43956
  "doc:DomainElement"
43957
43957
  ],
43958
- "doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '21'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)21 302099'\n",
43958
+ "doc:raw": "type: \"GENERAL\"\nvalue: \"www.company.be\"\n",
43959
43959
  "core:mediaType": "application/yaml",
43960
43960
  "sourcemaps:sources": [
43961
43961
  {
@@ -44781,17 +44781,17 @@
44781
44781
  {
44782
44782
  "@id": "#215/source-map/lexical/element_0",
44783
44783
  "sourcemaps:element": "amf://id#215",
44784
- "sourcemaps:value": "[(1,0)-(7,0)]"
44784
+ "sourcemaps:value": "[(1,0)-(6,0)]"
44785
44785
  },
44786
44786
  {
44787
44787
  "@id": "#218/source-map/lexical/element_0",
44788
44788
  "sourcemaps:element": "amf://id#218",
44789
- "sourcemaps:value": "[(1,0)-(3,0)]"
44789
+ "sourcemaps:value": "[(1,0)-(7,0)]"
44790
44790
  },
44791
44791
  {
44792
44792
  "@id": "#221/source-map/lexical/element_0",
44793
44793
  "sourcemaps:element": "amf://id#221",
44794
- "sourcemaps:value": "[(1,0)-(6,0)]"
44794
+ "sourcemaps:value": "[(1,0)-(3,0)]"
44795
44795
  },
44796
44796
  {
44797
44797
  "@id": "#338/source-map/synthesized-field/element_1",
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.3",
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
  /**