@arbidocs/sdk 0.5.137 → 0.5.138
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.
- package/dist/{browser-Do_-BxvU.d.ts → browser-C8VTBlM8.d.ts} +25 -1
- package/dist/{browser-CrLmQm-o.d.cts → browser-uV09Vdrg.d.cts} +25 -1
- package/dist/browser.cjs +19 -1
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +19 -1
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +48 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +48 -6
- package/dist/index.js.map +1 -1
- package/examples/human-review/package.json +1 -1
- package/examples/react-chat/package.json +2 -2
- package/package.json +2 -2
|
@@ -1141,7 +1141,26 @@ interface UploadOptions {
|
|
|
1141
1141
|
docId: string;
|
|
1142
1142
|
role: 'crop' | 'redline_base' | 'redline_revised';
|
|
1143
1143
|
};
|
|
1144
|
+
/**
|
|
1145
|
+
* The upload action this request is part of ({@link newUploadSet}): every request of one drop or
|
|
1146
|
+
* selection names the same set, and the person gets one `upload_set_complete` notification when
|
|
1147
|
+
* all of it is processed, not one per request. Sent as query parameters, which a server that
|
|
1148
|
+
* predates upload sets ignores.
|
|
1149
|
+
*/
|
|
1150
|
+
uploadSet?: UploadSet;
|
|
1151
|
+
}
|
|
1152
|
+
/** One upload action: an id minted once for it, and how many files it has in all. */
|
|
1153
|
+
interface UploadSet {
|
|
1154
|
+
id: string;
|
|
1155
|
+
size: number;
|
|
1144
1156
|
}
|
|
1157
|
+
/** A new upload set for an action of `size` files (send it on every request of the action). */
|
|
1158
|
+
declare function newUploadSet(size: number): UploadSet;
|
|
1159
|
+
/** The query parameters naming an upload set (none without one). */
|
|
1160
|
+
declare function uploadSetQuery(set: UploadSet | undefined): {
|
|
1161
|
+
upload_set_id?: string;
|
|
1162
|
+
upload_set_size?: number;
|
|
1163
|
+
};
|
|
1145
1164
|
interface SkippedFile {
|
|
1146
1165
|
file_name: string;
|
|
1147
1166
|
reason: string;
|
|
@@ -1614,6 +1633,8 @@ interface UploadDirectOptions {
|
|
|
1614
1633
|
tagExtId?: string;
|
|
1615
1634
|
/** Expiry for presigned PUT URLs, in seconds. Defaults to server default (1h). */
|
|
1616
1635
|
presignExpiresIn?: number;
|
|
1636
|
+
/** The upload action this request is part of (see {@link UploadOptions.uploadSet}). */
|
|
1637
|
+
uploadSet?: UploadSet;
|
|
1617
1638
|
/**
|
|
1618
1639
|
* Fired as each file's ciphertext is uploaded. In the browser this yields
|
|
1619
1640
|
* byte-level progress (XMLHttpRequest upload.progress); in Node this fires
|
|
@@ -1718,6 +1739,7 @@ type documents_UploadDirectResult = UploadDirectResult;
|
|
|
1718
1739
|
type documents_UploadDocumentsOptions = UploadDocumentsOptions;
|
|
1719
1740
|
type documents_UploadOptions = UploadOptions;
|
|
1720
1741
|
type documents_UploadResult = UploadResult;
|
|
1742
|
+
type documents_UploadSet = UploadSet;
|
|
1721
1743
|
type documents_UploadUrlOptions = UploadUrlOptions;
|
|
1722
1744
|
declare const documents_deleteDocuments: typeof deleteDocuments;
|
|
1723
1745
|
declare const documents_downloadDocument: typeof downloadDocument;
|
|
@@ -1730,6 +1752,7 @@ declare const documents_listDocuments: typeof listDocuments;
|
|
|
1730
1752
|
declare const documents_listPaginated: typeof listPaginated;
|
|
1731
1753
|
declare const documents_listVersions: typeof listVersions;
|
|
1732
1754
|
declare const documents_mimeFromName: typeof mimeFromName;
|
|
1755
|
+
declare const documents_newUploadSet: typeof newUploadSet;
|
|
1733
1756
|
declare const documents_presignedPut: typeof presignedPut;
|
|
1734
1757
|
declare const documents_restoreVersion: typeof restoreVersion;
|
|
1735
1758
|
declare const documents_sanitizeFolderPath: typeof sanitizeFolderPath;
|
|
@@ -1738,9 +1761,10 @@ declare const documents_updateDocuments: typeof updateDocuments;
|
|
|
1738
1761
|
declare const documents_uploadDocuments: typeof uploadDocuments;
|
|
1739
1762
|
declare const documents_uploadDocumentsDirect: typeof uploadDocumentsDirect;
|
|
1740
1763
|
declare const documents_uploadFiles: typeof uploadFiles;
|
|
1764
|
+
declare const documents_uploadSetQuery: typeof uploadSetQuery;
|
|
1741
1765
|
declare const documents_uploadUrl: typeof uploadUrl;
|
|
1742
1766
|
declare namespace documents {
|
|
1743
|
-
export { type documents_DirectUploadClient as DirectUploadClient, type documents_DirectUploadFile as DirectUploadFile, type documents_DirectUploadProgress as DirectUploadProgress, type documents_DocumentListFields as DocumentListFields, type documents_DocumentListOrder as DocumentListOrder, type documents_ListAllOptions as ListAllOptions, type documents_ListPaginatedOptions as ListPaginatedOptions, documents_MAX_PAGES as MAX_PAGES, documents_SUPPORTED_EXTENSIONS as SUPPORTED_EXTENSIONS, type documents_SkippedFile as SkippedFile, type documents_UploadBatchResult as UploadBatchResult, type documents_UploadDirectOptions as UploadDirectOptions, type documents_UploadDirectResult as UploadDirectResult, type documents_UploadDocumentsOptions as UploadDocumentsOptions, type documents_UploadOptions as UploadOptions, type documents_UploadResult as UploadResult, type documents_UploadUrlOptions as UploadUrlOptions, documents_deleteDocuments as deleteDocuments, documents_downloadDocument as downloadDocument, documents_finaliseTranslation as finaliseTranslation, documents_getDocuments as getDocuments, documents_getParsedContent as getParsedContent, documents_getThumbnails as getThumbnails, documents_listAll as listAll, documents_listDocuments as listDocuments, documents_listPaginated as listPaginated, documents_listVersions as listVersions, documents_mimeFromName as mimeFromName, documents_presignedPut as presignedPut, documents_restoreVersion as restoreVersion, documents_sanitizeFolderPath as sanitizeFolderPath, documents_similarDocuments as similarDocuments, documents_updateDocuments as updateDocuments, documents_uploadDocuments as uploadDocuments, documents_uploadDocumentsDirect as uploadDocumentsDirect, uploadFile$1 as uploadFile, documents_uploadFiles as uploadFiles, documents_uploadUrl as uploadUrl };
|
|
1767
|
+
export { type documents_DirectUploadClient as DirectUploadClient, type documents_DirectUploadFile as DirectUploadFile, type documents_DirectUploadProgress as DirectUploadProgress, type documents_DocumentListFields as DocumentListFields, type documents_DocumentListOrder as DocumentListOrder, type documents_ListAllOptions as ListAllOptions, type documents_ListPaginatedOptions as ListPaginatedOptions, documents_MAX_PAGES as MAX_PAGES, documents_SUPPORTED_EXTENSIONS as SUPPORTED_EXTENSIONS, type documents_SkippedFile as SkippedFile, type documents_UploadBatchResult as UploadBatchResult, type documents_UploadDirectOptions as UploadDirectOptions, type documents_UploadDirectResult as UploadDirectResult, type documents_UploadDocumentsOptions as UploadDocumentsOptions, type documents_UploadOptions as UploadOptions, type documents_UploadResult as UploadResult, type documents_UploadSet as UploadSet, type documents_UploadUrlOptions as UploadUrlOptions, documents_deleteDocuments as deleteDocuments, documents_downloadDocument as downloadDocument, documents_finaliseTranslation as finaliseTranslation, documents_getDocuments as getDocuments, documents_getParsedContent as getParsedContent, documents_getThumbnails as getThumbnails, documents_listAll as listAll, documents_listDocuments as listDocuments, documents_listPaginated as listPaginated, documents_listVersions as listVersions, documents_mimeFromName as mimeFromName, documents_newUploadSet as newUploadSet, documents_presignedPut as presignedPut, documents_restoreVersion as restoreVersion, documents_sanitizeFolderPath as sanitizeFolderPath, documents_similarDocuments as similarDocuments, documents_updateDocuments as updateDocuments, documents_uploadDocuments as uploadDocuments, documents_uploadDocumentsDirect as uploadDocumentsDirect, uploadFile$1 as uploadFile, documents_uploadFiles as uploadFiles, documents_uploadSetQuery as uploadSetQuery, documents_uploadUrl as uploadUrl };
|
|
1744
1768
|
}
|
|
1745
1769
|
|
|
1746
1770
|
/**
|
|
@@ -1141,7 +1141,26 @@ interface UploadOptions {
|
|
|
1141
1141
|
docId: string;
|
|
1142
1142
|
role: 'crop' | 'redline_base' | 'redline_revised';
|
|
1143
1143
|
};
|
|
1144
|
+
/**
|
|
1145
|
+
* The upload action this request is part of ({@link newUploadSet}): every request of one drop or
|
|
1146
|
+
* selection names the same set, and the person gets one `upload_set_complete` notification when
|
|
1147
|
+
* all of it is processed, not one per request. Sent as query parameters, which a server that
|
|
1148
|
+
* predates upload sets ignores.
|
|
1149
|
+
*/
|
|
1150
|
+
uploadSet?: UploadSet;
|
|
1151
|
+
}
|
|
1152
|
+
/** One upload action: an id minted once for it, and how many files it has in all. */
|
|
1153
|
+
interface UploadSet {
|
|
1154
|
+
id: string;
|
|
1155
|
+
size: number;
|
|
1144
1156
|
}
|
|
1157
|
+
/** A new upload set for an action of `size` files (send it on every request of the action). */
|
|
1158
|
+
declare function newUploadSet(size: number): UploadSet;
|
|
1159
|
+
/** The query parameters naming an upload set (none without one). */
|
|
1160
|
+
declare function uploadSetQuery(set: UploadSet | undefined): {
|
|
1161
|
+
upload_set_id?: string;
|
|
1162
|
+
upload_set_size?: number;
|
|
1163
|
+
};
|
|
1145
1164
|
interface SkippedFile {
|
|
1146
1165
|
file_name: string;
|
|
1147
1166
|
reason: string;
|
|
@@ -1614,6 +1633,8 @@ interface UploadDirectOptions {
|
|
|
1614
1633
|
tagExtId?: string;
|
|
1615
1634
|
/** Expiry for presigned PUT URLs, in seconds. Defaults to server default (1h). */
|
|
1616
1635
|
presignExpiresIn?: number;
|
|
1636
|
+
/** The upload action this request is part of (see {@link UploadOptions.uploadSet}). */
|
|
1637
|
+
uploadSet?: UploadSet;
|
|
1617
1638
|
/**
|
|
1618
1639
|
* Fired as each file's ciphertext is uploaded. In the browser this yields
|
|
1619
1640
|
* byte-level progress (XMLHttpRequest upload.progress); in Node this fires
|
|
@@ -1718,6 +1739,7 @@ type documents_UploadDirectResult = UploadDirectResult;
|
|
|
1718
1739
|
type documents_UploadDocumentsOptions = UploadDocumentsOptions;
|
|
1719
1740
|
type documents_UploadOptions = UploadOptions;
|
|
1720
1741
|
type documents_UploadResult = UploadResult;
|
|
1742
|
+
type documents_UploadSet = UploadSet;
|
|
1721
1743
|
type documents_UploadUrlOptions = UploadUrlOptions;
|
|
1722
1744
|
declare const documents_deleteDocuments: typeof deleteDocuments;
|
|
1723
1745
|
declare const documents_downloadDocument: typeof downloadDocument;
|
|
@@ -1730,6 +1752,7 @@ declare const documents_listDocuments: typeof listDocuments;
|
|
|
1730
1752
|
declare const documents_listPaginated: typeof listPaginated;
|
|
1731
1753
|
declare const documents_listVersions: typeof listVersions;
|
|
1732
1754
|
declare const documents_mimeFromName: typeof mimeFromName;
|
|
1755
|
+
declare const documents_newUploadSet: typeof newUploadSet;
|
|
1733
1756
|
declare const documents_presignedPut: typeof presignedPut;
|
|
1734
1757
|
declare const documents_restoreVersion: typeof restoreVersion;
|
|
1735
1758
|
declare const documents_sanitizeFolderPath: typeof sanitizeFolderPath;
|
|
@@ -1738,9 +1761,10 @@ declare const documents_updateDocuments: typeof updateDocuments;
|
|
|
1738
1761
|
declare const documents_uploadDocuments: typeof uploadDocuments;
|
|
1739
1762
|
declare const documents_uploadDocumentsDirect: typeof uploadDocumentsDirect;
|
|
1740
1763
|
declare const documents_uploadFiles: typeof uploadFiles;
|
|
1764
|
+
declare const documents_uploadSetQuery: typeof uploadSetQuery;
|
|
1741
1765
|
declare const documents_uploadUrl: typeof uploadUrl;
|
|
1742
1766
|
declare namespace documents {
|
|
1743
|
-
export { type documents_DirectUploadClient as DirectUploadClient, type documents_DirectUploadFile as DirectUploadFile, type documents_DirectUploadProgress as DirectUploadProgress, type documents_DocumentListFields as DocumentListFields, type documents_DocumentListOrder as DocumentListOrder, type documents_ListAllOptions as ListAllOptions, type documents_ListPaginatedOptions as ListPaginatedOptions, documents_MAX_PAGES as MAX_PAGES, documents_SUPPORTED_EXTENSIONS as SUPPORTED_EXTENSIONS, type documents_SkippedFile as SkippedFile, type documents_UploadBatchResult as UploadBatchResult, type documents_UploadDirectOptions as UploadDirectOptions, type documents_UploadDirectResult as UploadDirectResult, type documents_UploadDocumentsOptions as UploadDocumentsOptions, type documents_UploadOptions as UploadOptions, type documents_UploadResult as UploadResult, type documents_UploadUrlOptions as UploadUrlOptions, documents_deleteDocuments as deleteDocuments, documents_downloadDocument as downloadDocument, documents_finaliseTranslation as finaliseTranslation, documents_getDocuments as getDocuments, documents_getParsedContent as getParsedContent, documents_getThumbnails as getThumbnails, documents_listAll as listAll, documents_listDocuments as listDocuments, documents_listPaginated as listPaginated, documents_listVersions as listVersions, documents_mimeFromName as mimeFromName, documents_presignedPut as presignedPut, documents_restoreVersion as restoreVersion, documents_sanitizeFolderPath as sanitizeFolderPath, documents_similarDocuments as similarDocuments, documents_updateDocuments as updateDocuments, documents_uploadDocuments as uploadDocuments, documents_uploadDocumentsDirect as uploadDocumentsDirect, uploadFile$1 as uploadFile, documents_uploadFiles as uploadFiles, documents_uploadUrl as uploadUrl };
|
|
1767
|
+
export { type documents_DirectUploadClient as DirectUploadClient, type documents_DirectUploadFile as DirectUploadFile, type documents_DirectUploadProgress as DirectUploadProgress, type documents_DocumentListFields as DocumentListFields, type documents_DocumentListOrder as DocumentListOrder, type documents_ListAllOptions as ListAllOptions, type documents_ListPaginatedOptions as ListPaginatedOptions, documents_MAX_PAGES as MAX_PAGES, documents_SUPPORTED_EXTENSIONS as SUPPORTED_EXTENSIONS, type documents_SkippedFile as SkippedFile, type documents_UploadBatchResult as UploadBatchResult, type documents_UploadDirectOptions as UploadDirectOptions, type documents_UploadDirectResult as UploadDirectResult, type documents_UploadDocumentsOptions as UploadDocumentsOptions, type documents_UploadOptions as UploadOptions, type documents_UploadResult as UploadResult, type documents_UploadSet as UploadSet, type documents_UploadUrlOptions as UploadUrlOptions, documents_deleteDocuments as deleteDocuments, documents_downloadDocument as downloadDocument, documents_finaliseTranslation as finaliseTranslation, documents_getDocuments as getDocuments, documents_getParsedContent as getParsedContent, documents_getThumbnails as getThumbnails, documents_listAll as listAll, documents_listDocuments as listDocuments, documents_listPaginated as listPaginated, documents_listVersions as listVersions, documents_mimeFromName as mimeFromName, documents_newUploadSet as newUploadSet, documents_presignedPut as presignedPut, documents_restoreVersion as restoreVersion, documents_sanitizeFolderPath as sanitizeFolderPath, documents_similarDocuments as similarDocuments, documents_updateDocuments as updateDocuments, documents_uploadDocuments as uploadDocuments, documents_uploadDocumentsDirect as uploadDocumentsDirect, uploadFile$1 as uploadFile, documents_uploadFiles as uploadFiles, documents_uploadSetQuery as uploadSetQuery, documents_uploadUrl as uploadUrl };
|
|
1744
1768
|
}
|
|
1745
1769
|
|
|
1746
1770
|
/**
|
package/dist/browser.cjs
CHANGED
|
@@ -5822,6 +5822,7 @@ __export(documents_exports, {
|
|
|
5822
5822
|
listPaginated: () => listPaginated,
|
|
5823
5823
|
listVersions: () => listVersions,
|
|
5824
5824
|
mimeFromName: () => mimeFromName,
|
|
5825
|
+
newUploadSet: () => newUploadSet,
|
|
5825
5826
|
presignedPut: () => presignedPut,
|
|
5826
5827
|
restoreVersion: () => restoreVersion,
|
|
5827
5828
|
sanitizeFolderPath: () => sanitizeFolderPath,
|
|
@@ -5831,6 +5832,7 @@ __export(documents_exports, {
|
|
|
5831
5832
|
uploadDocumentsDirect: () => uploadDocumentsDirect,
|
|
5832
5833
|
uploadFile: () => uploadFile,
|
|
5833
5834
|
uploadFiles: () => uploadFiles,
|
|
5835
|
+
uploadSetQuery: () => uploadSetQuery,
|
|
5834
5836
|
uploadUrl: () => uploadUrl
|
|
5835
5837
|
});
|
|
5836
5838
|
var MAX_PAGES = 400;
|
|
@@ -5880,6 +5882,17 @@ var SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
5880
5882
|
function sanitizeFolderPath(folderPath) {
|
|
5881
5883
|
return folderPath.replace(/[\x00-\x1f\x7f]/g, "").replace(/\\/g, "/").replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "").trim();
|
|
5882
5884
|
}
|
|
5885
|
+
function newUploadSet(size) {
|
|
5886
|
+
const crypto2 = globalThis.crypto;
|
|
5887
|
+
const id = typeof crypto2?.randomUUID === "function" ? crypto2.randomUUID() : Array.from(
|
|
5888
|
+
crypto2.getRandomValues(new Uint8Array(16)),
|
|
5889
|
+
(b2) => b2.toString(16).padStart(2, "0")
|
|
5890
|
+
).join("");
|
|
5891
|
+
return { id, size: Math.max(1, Math.floor(size)) };
|
|
5892
|
+
}
|
|
5893
|
+
function uploadSetQuery(set) {
|
|
5894
|
+
return set ? { upload_set_id: set.id, upload_set_size: set.size } : {};
|
|
5895
|
+
}
|
|
5883
5896
|
async function listDocuments(arbi, workspaceExtId) {
|
|
5884
5897
|
if (!workspaceExtId) {
|
|
5885
5898
|
return requireData(await arbi.fetch.GET("/v1/document/list"), "Failed to fetch documents");
|
|
@@ -6062,6 +6075,7 @@ async function uploadDocuments(arbi, files, options = {}) {
|
|
|
6062
6075
|
query2.derived_from = options.derivedFrom.docId;
|
|
6063
6076
|
query2.derived_role = options.derivedFrom.role;
|
|
6064
6077
|
}
|
|
6078
|
+
Object.assign(query2, uploadSetQuery(options.uploadSet));
|
|
6065
6079
|
const result = await arbi.fetch.POST("/v1/document/upload", {
|
|
6066
6080
|
params: { query: query2 },
|
|
6067
6081
|
...options.onProgress ? { fetch: progressFetch(options.onProgress, arbi.http) } : {},
|
|
@@ -6122,6 +6136,8 @@ async function uploadFile(auth, fileData, fileName, options) {
|
|
|
6122
6136
|
params.set("derived_from", options.derivedFrom.docId);
|
|
6123
6137
|
params.set("derived_role", options.derivedFrom.role);
|
|
6124
6138
|
}
|
|
6139
|
+
for (const [key, value] of Object.entries(uploadSetQuery(options?.uploadSet)))
|
|
6140
|
+
params.set(key, String(value));
|
|
6125
6141
|
const qs = params.toString();
|
|
6126
6142
|
const res = await authenticatedFetch({
|
|
6127
6143
|
...auth,
|
|
@@ -6144,6 +6160,8 @@ async function uploadFiles(auth, files, options) {
|
|
|
6144
6160
|
params.set("derived_from", options.derivedFrom.docId);
|
|
6145
6161
|
params.set("derived_role", options.derivedFrom.role);
|
|
6146
6162
|
}
|
|
6163
|
+
for (const [key, value] of Object.entries(uploadSetQuery(options?.uploadSet)))
|
|
6164
|
+
params.set(key, String(value));
|
|
6147
6165
|
const qs = params.toString();
|
|
6148
6166
|
const res = await authenticatedFetch({
|
|
6149
6167
|
...auth,
|
|
@@ -6255,7 +6273,7 @@ async function uploadDocumentsDirect(arbi, workspaceKey, files, options) {
|
|
|
6255
6273
|
folder: options.folder ? sanitizeFolderPath(options.folder) : null,
|
|
6256
6274
|
presign_expires_in: options.presignExpiresIn ?? 3600
|
|
6257
6275
|
};
|
|
6258
|
-
const query2 = { workspace_ext_id: options.workspaceExtId };
|
|
6276
|
+
const query2 = { workspace_ext_id: options.workspaceExtId, ...uploadSetQuery(options.uploadSet) };
|
|
6259
6277
|
const initResult = requireUploadData(
|
|
6260
6278
|
await arbi.fetch.POST("/v1/document/upload-init", { params: { query: query2 }, body: initBody }),
|
|
6261
6279
|
"Failed to initialize direct upload"
|