@arbidocs/sdk 0.5.49 → 0.5.50

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.
@@ -25,13 +25,13 @@ declare class ArbiWorkspaceSupersededError extends ArbiError {
25
25
  constructor(workspaceId: string, supersededBy: string);
26
26
  }
27
27
  /**
28
- * A read made for one workspace could have been answered for another: the session's workspace was
29
- * not, or did not stay, the one it was made for (a switch ran meanwhile). Nothing it returned is
30
- * kept; read again in the workspace now open.
28
+ * A request made for one workspace could have gone to another: the session's workspace was not, or
29
+ * did not stay, the one it was made for (a switch ran meanwhile). A read keeps nothing it returned;
30
+ * an upload is not sent. Do it again in the workspace now open.
31
31
  */
32
32
  declare class ArbiWorkspaceChangedError extends ArbiError {
33
33
  readonly workspaceId: string;
34
- constructor(workspaceId: string);
34
+ constructor(workspaceId: string, doing?: string);
35
35
  }
36
36
  declare class ArbiApiError extends ArbiError {
37
37
  readonly status?: number;
@@ -1338,7 +1338,11 @@ declare function getThumbnails(auth: AuthHeaders, docIds: string[]): Promise<Rec
1338
1338
  * Upload a file. Uses raw fetch for multipart upload. The active workspace is
1339
1339
  * resolved server-side from the open session.
1340
1340
  */
1341
- declare function uploadFile$1(auth: AuthHeaders, fileData: Blob, fileName: string, options?: UploadOptions): Promise<UploadResult>;
1341
+ declare function uploadFile$1(auth: AuthHeaders & {
1342
+ signal?: AbortSignal;
1343
+ }, fileData: Blob, fileName: string, options?: UploadOptions & {
1344
+ workspaceExtId?: string;
1345
+ }): Promise<UploadResult>;
1342
1346
  /**
1343
1347
  * Upload multiple files in a single FormData request with an optional folder
1344
1348
  * parameter. Workspace is resolved from the session, same as ``uploadFile``.
@@ -10626,6 +10630,12 @@ declare class Arbi {
10626
10630
  similarity: number;
10627
10631
  }[];
10628
10632
  }>;
10633
+ /**
10634
+ * Upload one file to the workspace open NOW. A re-login or workspace re-open may run before it
10635
+ * is sent (or before its one retry); it still goes only to this workspace on this session: a
10636
+ * sign-out meanwhile aborts it, and a switch to another workspace refuses it
10637
+ * (`ArbiWorkspaceChangedError`) instead of sending it to the new one.
10638
+ */
10629
10639
  uploadFile: (fileData: Blob, fileName: string, options?: UploadOptions) => Promise<UploadResult>;
10630
10640
  /** Download a document's original file — its current version, or `version`. */
10631
10641
  download: (docId: string, version?: number) => Promise<Response>;
@@ -25,13 +25,13 @@ declare class ArbiWorkspaceSupersededError extends ArbiError {
25
25
  constructor(workspaceId: string, supersededBy: string);
26
26
  }
27
27
  /**
28
- * A read made for one workspace could have been answered for another: the session's workspace was
29
- * not, or did not stay, the one it was made for (a switch ran meanwhile). Nothing it returned is
30
- * kept; read again in the workspace now open.
28
+ * A request made for one workspace could have gone to another: the session's workspace was not, or
29
+ * did not stay, the one it was made for (a switch ran meanwhile). A read keeps nothing it returned;
30
+ * an upload is not sent. Do it again in the workspace now open.
31
31
  */
32
32
  declare class ArbiWorkspaceChangedError extends ArbiError {
33
33
  readonly workspaceId: string;
34
- constructor(workspaceId: string);
34
+ constructor(workspaceId: string, doing?: string);
35
35
  }
36
36
  declare class ArbiApiError extends ArbiError {
37
37
  readonly status?: number;
@@ -1338,7 +1338,11 @@ declare function getThumbnails(auth: AuthHeaders, docIds: string[]): Promise<Rec
1338
1338
  * Upload a file. Uses raw fetch for multipart upload. The active workspace is
1339
1339
  * resolved server-side from the open session.
1340
1340
  */
1341
- declare function uploadFile$1(auth: AuthHeaders, fileData: Blob, fileName: string, options?: UploadOptions): Promise<UploadResult>;
1341
+ declare function uploadFile$1(auth: AuthHeaders & {
1342
+ signal?: AbortSignal;
1343
+ }, fileData: Blob, fileName: string, options?: UploadOptions & {
1344
+ workspaceExtId?: string;
1345
+ }): Promise<UploadResult>;
1342
1346
  /**
1343
1347
  * Upload multiple files in a single FormData request with an optional folder
1344
1348
  * parameter. Workspace is resolved from the session, same as ``uploadFile``.
@@ -10626,6 +10630,12 @@ declare class Arbi {
10626
10630
  similarity: number;
10627
10631
  }[];
10628
10632
  }>;
10633
+ /**
10634
+ * Upload one file to the workspace open NOW. A re-login or workspace re-open may run before it
10635
+ * is sent (or before its one retry); it still goes only to this workspace on this session: a
10636
+ * sign-out meanwhile aborts it, and a switch to another workspace refuses it
10637
+ * (`ArbiWorkspaceChangedError`) instead of sending it to the new one.
10638
+ */
10629
10639
  uploadFile: (fileData: Blob, fileName: string, options?: UploadOptions) => Promise<UploadResult>;
10630
10640
  /** Download a document's original file — its current version, or `version`. */
10631
10641
  download: (docId: string, version?: number) => Promise<Response>;
package/dist/browser.cjs CHANGED
@@ -3501,8 +3501,8 @@ var ArbiWorkspaceSupersededError = class extends ArbiError {
3501
3501
  supersededBy;
3502
3502
  };
3503
3503
  var ArbiWorkspaceChangedError = class extends ArbiError {
3504
- constructor(workspaceId) {
3505
- super(`The workspace changed while reading ${workspaceId}`);
3504
+ constructor(workspaceId, doing = "reading") {
3505
+ super(`The workspace changed while ${doing} ${workspaceId}`);
3506
3506
  this.workspaceId = workspaceId;
3507
3507
  this.name = "ArbiWorkspaceChangedError";
3508
3508
  }
@@ -4727,6 +4727,7 @@ async function uploadFile(auth, fileData, fileName, options) {
4727
4727
  if (options?.configExtId) params.set("config_ext_id", options.configExtId);
4728
4728
  if (options?.wpType) params.set("wp_type", options.wpType);
4729
4729
  if (options?.versionOf) params.set("version_of", options.versionOf);
4730
+ if (options?.workspaceExtId) params.set("workspace_ext_id", options.workspaceExtId);
4730
4731
  if (options?.derivedFrom) {
4731
4732
  params.set("derived_from", options.derivedFrom.docId);
4732
4733
  params.set("derived_role", options.derivedFrom.role);
@@ -10914,11 +10915,25 @@ var Arbi = class {
10914
10915
  upload: (files, options) => uploadDocuments(this.requireClient(), files, options),
10915
10916
  /** Near-duplicate pairs at or above `threshold` (or one document's, `docId`). */
10916
10917
  similar: (options) => similarDocuments(this.requireClient(), options),
10918
+ /**
10919
+ * Upload one file to the workspace open NOW. A re-login or workspace re-open may run before it
10920
+ * is sent (or before its one retry); it still goes only to this workspace on this session: a
10921
+ * sign-out meanwhile aborts it, and a switch to another workspace refuses it
10922
+ * (`ArbiWorkspaceChangedError`) instead of sending it to the new one.
10923
+ */
10917
10924
  uploadFile: (fileData, fileName, options) => {
10918
- this.requireWorkspace();
10919
- return this.recovering(
10920
- () => uploadFile(this.getAuthHeaders(), fileData, fileName, options)
10921
- );
10925
+ const workspaceExtId = this.requireWorkspace();
10926
+ const signal = this.requireClient().auth.sessionSignal();
10927
+ return this.recovering(() => {
10928
+ signal.throwIfAborted();
10929
+ if (this.currentWorkspaceId !== workspaceExtId) {
10930
+ throw new ArbiWorkspaceChangedError(workspaceExtId, "uploading to");
10931
+ }
10932
+ return uploadFile({ ...this.getAuthHeaders(), signal }, fileData, fileName, {
10933
+ ...options,
10934
+ workspaceExtId
10935
+ });
10936
+ });
10922
10937
  },
10923
10938
  /** Download a document's original file — its current version, or `version`. */
10924
10939
  download: (docId, version) => this.recovering(() => downloadDocument(this.getAuthHeaders(), docId, version)),