@arbidocs/sdk 0.4.143 → 0.4.145

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/index.cjs CHANGED
@@ -4922,7 +4922,9 @@ __export(documents_exports, {
4922
4922
  mimeFromName: () => mimeFromName,
4923
4923
  presignedPut: () => presignedPut,
4924
4924
  sanitizeFolderPath: () => sanitizeFolderPath,
4925
+ similarDocuments: () => similarDocuments,
4925
4926
  updateDocuments: () => updateDocuments,
4927
+ uploadDocuments: () => uploadDocuments,
4926
4928
  uploadDocumentsDirect: () => uploadDocumentsDirect,
4927
4929
  uploadFile: () => uploadFile,
4928
4930
  uploadFiles: () => uploadFiles,
@@ -5090,16 +5092,54 @@ async function updateDocuments(arbi, documents) {
5090
5092
  "Failed to update documents"
5091
5093
  );
5092
5094
  }
5093
- async function uploadUrl(arbi, urls, shared = false) {
5095
+ async function uploadUrl(arbi, urls, shared = false, configExtId) {
5094
5096
  return requireData(
5095
5097
  await arbi.fetch.POST("/v1/document/upload-url", {
5096
5098
  params: {
5097
- query: { urls, shared }
5099
+ query: { urls, shared, ...configExtId ? { config_ext_id: configExtId } : {} }
5098
5100
  }
5099
5101
  }),
5100
5102
  "Failed to upload from URLs"
5101
5103
  );
5102
5104
  }
5105
+ async function uploadDocuments(arbi, files, options = {}) {
5106
+ const query = {};
5107
+ if (options.shared !== void 0) query.shared = options.shared;
5108
+ if (options.folder) query.folder = sanitizeFolderPath(options.folder);
5109
+ if (options.configExtId) query.config_ext_id = options.configExtId;
5110
+ if (options.wpType) query.wp_type = options.wpType;
5111
+ if (options.versionOf) query.version_of = options.versionOf;
5112
+ if (options.tagExtId) query.tag_ext_id = options.tagExtId;
5113
+ if (options.workspaceExtId) query.workspace_ext_id = options.workspaceExtId;
5114
+ if (options.derivedFrom) {
5115
+ query.derived_from = options.derivedFrom.docId;
5116
+ query.derived_role = options.derivedFrom.role;
5117
+ }
5118
+ const result = await arbi.fetch.POST("/v1/document/upload", {
5119
+ params: { query },
5120
+ // The schema types the files as strings; they go as multipart parts.
5121
+ body: { files },
5122
+ bodySerializer: () => {
5123
+ const form = new FormData();
5124
+ for (const file of files) form.append("files", file);
5125
+ return form;
5126
+ }
5127
+ });
5128
+ return requireData(result, "Failed to upload documents");
5129
+ }
5130
+ async function similarDocuments(arbi, options = {}) {
5131
+ return requireData(
5132
+ await arbi.fetch.GET("/v1/document/similar", {
5133
+ params: {
5134
+ query: {
5135
+ ...options.threshold !== void 0 ? { threshold: options.threshold } : {},
5136
+ ...options.docId ? { doc_ext_id: options.docId } : {}
5137
+ }
5138
+ }
5139
+ }),
5140
+ "Failed to fetch similar documents"
5141
+ );
5142
+ }
5103
5143
  async function getParsedContent(auth, docId, stage, version) {
5104
5144
  const res = await authenticatedFetch({
5105
5145
  ...auth,
@@ -6162,10 +6202,15 @@ __export(doctags_exports, {
6162
6202
  removeDocTags: () => removeDocTags,
6163
6203
  updateDocTag: () => updateDocTag
6164
6204
  });
6165
- async function assignDocTags(arbi, tagId, docIds, note) {
6205
+ async function assignDocTags(arbi, tagId, docIds, note, citations) {
6166
6206
  return requireData(
6167
6207
  await arbi.fetch.POST("/v1/document/doctag", {
6168
- body: { tag_ext_id: tagId, doc_ext_ids: docIds, note: note ?? null }
6208
+ body: {
6209
+ tag_ext_id: tagId,
6210
+ doc_ext_ids: docIds,
6211
+ note: note ?? null,
6212
+ ...citations ? { citations } : {}
6213
+ }
6169
6214
  }),
6170
6215
  "Failed to create doctags"
6171
6216
  );
@@ -9507,12 +9552,26 @@ var Arbi = class {
9507
9552
  get: (externalIds) => getDocuments(this.requireClient(), externalIds),
9508
9553
  /** Every version of a document, oldest first; `is_current` marks the current one. */
9509
9554
  versions: (docId) => listVersions(this.requireClient(), docId),
9555
+ /** Save a translation's current version as a new PDF document linked to its original. */
9556
+ finaliseTranslation: (docId) => finaliseTranslation(this.requireClient(), docId),
9510
9557
  delete: (externalIds) => deleteDocuments(this.requireClient(), externalIds),
9511
9558
  update: (documents) => updateDocuments(this.requireClient(), documents),
9512
- uploadUrl: (urls, shared) => {
9559
+ uploadUrl: (urls, options) => {
9513
9560
  this.requireWorkspace();
9514
- return uploadUrl(this.requireClient(), urls, shared);
9561
+ return uploadUrl(
9562
+ this.requireClient(),
9563
+ urls,
9564
+ options?.shared,
9565
+ options?.configExtId
9566
+ );
9515
9567
  },
9568
+ /**
9569
+ * Upload files in one request (the open workspace, or `options.workspaceExtId`): folder, tag,
9570
+ * sharing, config, a new version of a document.
9571
+ */
9572
+ upload: (files, options) => uploadDocuments(this.requireClient(), files, options),
9573
+ /** Near-duplicate pairs at or above `threshold` (or one document's, `docId`). */
9574
+ similar: (options) => similarDocuments(this.requireClient(), options),
9516
9575
  uploadFile: (fileData, fileName, options) => {
9517
9576
  this.requireWorkspace();
9518
9577
  return this.recovering(
@@ -9763,10 +9822,12 @@ var Arbi = class {
9763
9822
  };
9764
9823
  // ── Document Tags ─────────────────────────────────────────────────────
9765
9824
  doctags = {
9766
- assign: (tagId, docIds, note) => assignDocTags(this.requireClient(), tagId, docIds, note),
9825
+ /** Apply a tag to documents, with a note (a field's value) and the passages it cites. */
9826
+ assign: (tagId, docIds, note, citations) => assignDocTags(this.requireClient(), tagId, docIds, note, citations),
9767
9827
  remove: (tagId, docIds) => removeDocTags(this.requireClient(), tagId, docIds),
9768
9828
  update: (tagId, docId, updates) => updateDocTag(this.requireClient(), tagId, docId, updates),
9769
- generate: (tagIds, docIds) => generateDocTags(this.requireClient(), tagIds, docIds)
9829
+ /** Fill the tags' values on the documents with AI (`overwrite`: also where already set). */
9830
+ generate: (tagIds, docIds, options) => generateDocTags(this.requireClient(), tagIds, docIds, options)
9770
9831
  };
9771
9832
  // ── Contacts ──────────────────────────────────────────────────────────
9772
9833
  // A card is sealed under its address book's key, which the calendar key bridge carries: without