@arbidocs/sdk 0.5.14 → 0.5.16

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.cjs CHANGED
@@ -3610,8 +3610,8 @@ async function extractErrorMessage(res) {
3610
3610
  return `Request failed: ${res.status} ${res.statusText}`;
3611
3611
  }
3612
3612
  async function authenticatedFetch(options) {
3613
- const { baseUrl, accessToken, path, method, body, headers, signal } = options;
3614
- const res = await fetch(`${baseUrl}${path}`, {
3613
+ const { baseUrl, accessToken, path: path2, method, body, headers, signal } = options;
3614
+ const res = await fetch(`${baseUrl}${path2}`, {
3615
3615
  method: method ?? (body ? "POST" : "GET"),
3616
3616
  headers: {
3617
3617
  Authorization: `Bearer ${accessToken}`,
@@ -4211,7 +4211,6 @@ async function streamSSE(response, callbacks = {}) {
4211
4211
  completed
4212
4212
  };
4213
4213
  }
4214
- var consumeSSEStream = streamSSE;
4215
4214
  var AUTH_TIMEOUT_MS = 1e4;
4216
4215
  var MAX_BACKOFF_MS = 3e4;
4217
4216
  var WebSocketAuthError = class extends Error {
@@ -5063,6 +5062,7 @@ __export(workspaces_exports, {
5063
5062
  addWorkspaceMembers: () => addWorkspaceMembers,
5064
5063
  addWorkspaceMembersBody: () => addWorkspaceMembersBody,
5065
5064
  addWorkspaceUsers: () => addWorkspaceUsers,
5065
+ archiveWorkspace: () => archiveWorkspace,
5066
5066
  cancelWorkspaceTransfer: () => cancelWorkspaceTransfer,
5067
5067
  copyDocuments: () => copyDocuments,
5068
5068
  createWorkspace: () => createWorkspace,
@@ -5070,17 +5070,20 @@ __export(workspaces_exports, {
5070
5070
  exportWorkspaceData: () => exportWorkspaceData,
5071
5071
  getWorkspaceAccessStatus: () => getWorkspaceAccessStatus,
5072
5072
  getWorkspaceActivity: () => getWorkspaceActivity,
5073
+ getWorkspaceArchive: () => getWorkspaceArchive,
5073
5074
  getWorkspaceTransfer: () => getWorkspaceTransfer,
5074
5075
  grantTemporaryWorkspaceAccess: () => grantTemporaryWorkspaceAccess,
5075
5076
  listWorkspaceTransfers: () => listWorkspaceTransfers,
5076
5077
  listWorkspaceUsers: () => listWorkspaceUsers,
5077
5078
  listWorkspaces: () => listWorkspaces,
5079
+ moveWorkspaceToProject: () => moveWorkspaceToProject,
5078
5080
  planWorkspaceTransfer: () => planWorkspaceTransfer,
5079
5081
  primeWorkspaceKey: () => primeWorkspaceKey,
5080
5082
  removeWorkspaceUsers: () => removeWorkspaceUsers,
5081
5083
  resumeWorkspaceTransfer: () => resumeWorkspaceTransfer,
5082
5084
  setUserRole: () => setUserRole,
5083
5085
  startWorkspaceTransfer: () => startWorkspaceTransfer,
5086
+ unarchiveWorkspace: () => unarchiveWorkspace,
5084
5087
  updateWorkspace: () => updateWorkspace
5085
5088
  });
5086
5089
  async function listWorkspaces(arbi) {
@@ -5100,6 +5103,39 @@ async function createWorkspace(arbi, name, encryptedWorkspaceKey, projectExtId,
5100
5103
  "Failed to create workspace"
5101
5104
  );
5102
5105
  }
5106
+ async function moveWorkspaceToProject(arbi, workspaceExtId, projectExtId) {
5107
+ return requireData(
5108
+ await arbi.fetch.PUT("/v1/workspace/{workspace_ext_id}/project", {
5109
+ params: { path: { workspace_ext_id: workspaceExtId } },
5110
+ body: { project_ext_id: projectExtId }
5111
+ }),
5112
+ "Failed to move workspace"
5113
+ );
5114
+ }
5115
+ async function getWorkspaceArchive(arbi, workspaceExtId) {
5116
+ return requireData(
5117
+ await arbi.fetch.GET("/v1/workspace/{workspace_ext_id}/archive", {
5118
+ params: { path: { workspace_ext_id: workspaceExtId } }
5119
+ }),
5120
+ "Could not read the archive state"
5121
+ );
5122
+ }
5123
+ async function archiveWorkspace(arbi, workspaceExtId) {
5124
+ return requireData(
5125
+ await arbi.fetch.POST("/v1/workspace/{workspace_ext_id}/archive", {
5126
+ params: { path: { workspace_ext_id: workspaceExtId } }
5127
+ }),
5128
+ "Could not archive the workspace"
5129
+ );
5130
+ }
5131
+ async function unarchiveWorkspace(arbi, workspaceExtId) {
5132
+ return requireData(
5133
+ await arbi.fetch.POST("/v1/workspace/{workspace_ext_id}/unarchive", {
5134
+ params: { path: { workspace_ext_id: workspaceExtId } }
5135
+ }),
5136
+ "Could not unarchive the workspace"
5137
+ );
5138
+ }
5103
5139
  async function deleteWorkspaces(arbi, workspaceIds) {
5104
5140
  requireOk(
5105
5141
  await arbi.fetch.DELETE("/v1/workspace/", {
@@ -5288,6 +5324,7 @@ __export(conversations_exports, {
5288
5324
  importConversations: () => importConversations,
5289
5325
  listConversations: () => listConversations,
5290
5326
  postConversationMessage: () => postConversationMessage,
5327
+ searchConversations: () => searchConversations,
5291
5328
  updateConversationAssistantMode: () => updateConversationAssistantMode
5292
5329
  });
5293
5330
  async function listConversations(arbi) {
@@ -5320,6 +5357,12 @@ async function deleteConversation(arbi, conversationId) {
5320
5357
  "Failed to delete conversation"
5321
5358
  );
5322
5359
  }
5360
+ async function searchConversations(arbi, body) {
5361
+ return requireData(
5362
+ await arbi.fetch.POST("/v1/conversation/search", { body }),
5363
+ "Failed to search conversations"
5364
+ );
5365
+ }
5323
5366
  async function getMessage(arbi, messageId) {
5324
5367
  return requireData(
5325
5368
  await arbi.fetch.GET("/v1/conversation/message/{message_ext_id}", {
@@ -8586,6 +8629,118 @@ async function remindFact(arbi, factId, options = {}) {
8586
8629
  );
8587
8630
  }
8588
8631
 
8632
+ // src/operations/databases.ts
8633
+ var databases_exports = {};
8634
+ __export(databases_exports, {
8635
+ addDatabaseRows: () => addDatabaseRows,
8636
+ createDatabase: () => createDatabase,
8637
+ deleteDatabase: () => deleteDatabase,
8638
+ deleteDatabaseRows: () => deleteDatabaseRows,
8639
+ exportDatabase: () => exportDatabase,
8640
+ getDatabase: () => getDatabase,
8641
+ importDatabase: () => importDatabase,
8642
+ importDatabaseRows: () => importDatabaseRows,
8643
+ listDatabaseRows: () => listDatabaseRows,
8644
+ listDatabases: () => listDatabases,
8645
+ updateDatabase: () => updateDatabase,
8646
+ updateDatabaseRow: () => updateDatabaseRow
8647
+ });
8648
+ var path = (databaseId) => ({ path: { database_id: databaseId } });
8649
+ function spreadsheet(file) {
8650
+ const form = new FormData();
8651
+ form.append("file", file);
8652
+ return { body: form, bodySerializer: () => form };
8653
+ }
8654
+ async function listDatabases(arbi) {
8655
+ return requireData(await arbi.fetch.GET("/v1/databases"), "Failed to list databases");
8656
+ }
8657
+ async function getDatabase(arbi, databaseId) {
8658
+ return requireData(
8659
+ await arbi.fetch.GET("/v1/databases/{database_id}", { params: path(databaseId) }),
8660
+ "Failed to read the database"
8661
+ );
8662
+ }
8663
+ async function listDatabaseRows(arbi, databaseId, query2 = {}) {
8664
+ return requireData(
8665
+ await arbi.fetch.GET("/v1/databases/{database_id}/rows", {
8666
+ params: { ...path(databaseId), query: query2 }
8667
+ }),
8668
+ "Failed to read the rows"
8669
+ );
8670
+ }
8671
+ async function createDatabase(arbi, body) {
8672
+ return requireData(
8673
+ await arbi.fetch.POST("/v1/databases", { body }),
8674
+ "Failed to create the database"
8675
+ );
8676
+ }
8677
+ async function updateDatabase(arbi, databaseId, body) {
8678
+ return requireData(
8679
+ await arbi.fetch.PATCH("/v1/databases/{database_id}", { params: path(databaseId), body }),
8680
+ "Failed to update the database"
8681
+ );
8682
+ }
8683
+ async function deleteDatabase(arbi, databaseId) {
8684
+ requireOk(
8685
+ await arbi.fetch.DELETE("/v1/databases/{database_id}", { params: path(databaseId) }),
8686
+ "Failed to delete the database"
8687
+ );
8688
+ }
8689
+ async function addDatabaseRows(arbi, databaseId, rows) {
8690
+ return requireData(
8691
+ await arbi.fetch.POST("/v1/databases/{database_id}/rows", {
8692
+ params: path(databaseId),
8693
+ body: { rows }
8694
+ }),
8695
+ "Failed to add rows"
8696
+ );
8697
+ }
8698
+ async function updateDatabaseRow(arbi, databaseId, rowId, values) {
8699
+ return requireData(
8700
+ await arbi.fetch.PATCH("/v1/databases/{database_id}/rows/{row_id}", {
8701
+ params: { path: { database_id: databaseId, row_id: rowId } },
8702
+ body: { values }
8703
+ }),
8704
+ "Failed to update the row"
8705
+ );
8706
+ }
8707
+ async function deleteDatabaseRows(arbi, databaseId, ids) {
8708
+ requireOk(
8709
+ await arbi.fetch.POST("/v1/databases/{database_id}/rows/delete", {
8710
+ params: path(databaseId),
8711
+ body: { ids }
8712
+ }),
8713
+ "Failed to delete rows"
8714
+ );
8715
+ }
8716
+ async function importDatabase(arbi, file, name) {
8717
+ return requireData(
8718
+ await arbi.fetch.POST("/v1/databases/import", {
8719
+ params: { query: { name } },
8720
+ ...spreadsheet(file)
8721
+ }),
8722
+ "Import failed"
8723
+ );
8724
+ }
8725
+ async function importDatabaseRows(arbi, databaseId, file) {
8726
+ return requireData(
8727
+ await arbi.fetch.POST("/v1/databases/{database_id}/import", {
8728
+ params: { ...path(databaseId), query: { add_columns: true } },
8729
+ ...spreadsheet(file)
8730
+ }),
8731
+ "Import failed"
8732
+ );
8733
+ }
8734
+ async function exportDatabase(arbi, databaseId, format) {
8735
+ return requireData(
8736
+ await arbi.fetch.GET("/v1/databases/{database_id}/export", {
8737
+ params: { ...path(databaseId), query: { format } },
8738
+ parseAs: "blob"
8739
+ }),
8740
+ "Export failed"
8741
+ );
8742
+ }
8743
+
8589
8744
  // src/operations/mail.ts
8590
8745
  var mail_exports = {};
8591
8746
  __export(mail_exports, {
@@ -8607,9 +8762,9 @@ __export(mail_exports, {
8607
8762
  });
8608
8763
  var NATIVE_ACCOUNT = "native";
8609
8764
  function createMailFetch(auth) {
8610
- return (path, init = {}) => authenticatedFetch({
8765
+ return (path2, init = {}) => authenticatedFetch({
8611
8766
  ...auth,
8612
- path: `/v1/mail${path}`,
8767
+ path: `/v1/mail${path2}`,
8613
8768
  method: init.method,
8614
8769
  body: init.body,
8615
8770
  headers: {
@@ -8648,8 +8803,8 @@ function getMessage2(mail, messageId, accountId = NATIVE_ACCOUNT) {
8648
8803
  return json(mail(`${accountPath(accountId)}/messages/${encodeURIComponent(messageId)}`));
8649
8804
  }
8650
8805
  async function downloadAttachment(mail, messageId, attachmentId, accountId = NATIVE_ACCOUNT) {
8651
- const path = `${accountPath(accountId)}/messages/${encodeURIComponent(messageId)}/attachments/${encodeURIComponent(attachmentId)}`;
8652
- return new Uint8Array(await (await mail(path)).arrayBuffer());
8806
+ const path2 = `${accountPath(accountId)}/messages/${encodeURIComponent(messageId)}/attachments/${encodeURIComponent(attachmentId)}`;
8807
+ return new Uint8Array(await (await mail(path2)).arrayBuffer());
8653
8808
  }
8654
8809
  async function updateMessage(mail, messageId, update, accountId = NATIVE_ACCOUNT) {
8655
8810
  await mail(`${accountPath(accountId)}/messages/${encodeURIComponent(messageId)}`, {
@@ -8701,11 +8856,11 @@ async function unlockNativeMail(mail, keys) {
8701
8856
  async function claimSecureMail(mail, id, fragmentKey, recipientPublicKey) {
8702
8857
  const key = client.decodeSecureMailKey(fragmentKey);
8703
8858
  try {
8704
- const path = `/secure/${encodeURIComponent(id)}`;
8705
- const { raw } = await client.openSecureMail(await json(mail(path)), key);
8859
+ const path2 = `/secure/${encodeURIComponent(id)}`;
8860
+ const { raw } = await client.openSecureMail(await json(mail(path2)), key);
8706
8861
  raw.fill(0);
8707
8862
  const claim = await client.secureMailClaim(key, recipientPublicKey);
8708
- return await json(mail(`${path}/claim`, { method: "POST", body: JSON.stringify(claim) }));
8863
+ return await json(mail(`${path2}/claim`, { method: "POST", body: JSON.stringify(claim) }));
8709
8864
  } finally {
8710
8865
  key.fill(0);
8711
8866
  }
@@ -10552,6 +10707,14 @@ var Arbi = class {
10552
10707
  this.requireClient().workspaceKeys.forget(workspaceIds);
10553
10708
  },
10554
10709
  update: (body) => updateWorkspace(this.requireClient(), body),
10710
+ /** A workspace's archive state (status, bytes per tier, the unarchive estimate). */
10711
+ archiveState: (workspaceId) => getWorkspaceArchive(this.requireClient(), workspaceId),
10712
+ /** Archive a workspace: closed for everyone until unarchived. */
10713
+ archive: (workspaceId) => archiveWorkspace(this.requireClient(), workspaceId),
10714
+ /** Start unarchiving a workspace (its documents are re-indexed). */
10715
+ unarchive: (workspaceId) => unarchiveWorkspace(this.requireClient(), workspaceId),
10716
+ /** Move a workspace (open or not) to another project. */
10717
+ moveToProject: (workspaceId, projectExtId) => moveWorkspaceToProject(this.requireClient(), workspaceId, projectExtId),
10555
10718
  listUsers: () => listWorkspaceUsers(this.requireClient()),
10556
10719
  /** One page of a workspace's activity feed, newest first (see `getWorkspaceActivity`). */
10557
10720
  activity: (workspaceId, options) => getWorkspaceActivity(this.requireClient(), workspaceId, options),
@@ -10723,6 +10886,8 @@ var Arbi = class {
10723
10886
  list: () => listConversations(this.requireClient()),
10724
10887
  getThreads: (conversationId) => getConversationThreads(this.requireClient(), conversationId),
10725
10888
  delete: (conversationId) => deleteConversation(this.requireClient(), conversationId),
10889
+ /** Search the open workspace's past conversation messages (keyword + semantic), grouped. */
10890
+ search: (body) => searchConversations(this.requireClient(), body),
10726
10891
  /**
10727
10892
  * Patch a conversation: `title`, `shared` (owner only), its bound document
10728
10893
  * (`bound_document_ext_id`, `null` unbinds), and the work fields (`description`, `due_at`,
@@ -10810,11 +10975,11 @@ var Arbi = class {
10810
10975
  };
10811
10976
  /** Authenticated native Word transport, with normal session recovery. */
10812
10977
  editor = {
10813
- request: (path, options = {}) => this.recovering(async () => {
10978
+ request: (path2, options = {}) => this.recovering(async () => {
10814
10979
  const { baseUrl, accessToken } = this.getAuthHeaders();
10815
10980
  const headers = new Headers(options.headers);
10816
10981
  headers.set("Authorization", `Bearer ${accessToken}`);
10817
- const response = await fetch(`${baseUrl}/v1/editor${path}`, { ...options, headers });
10982
+ const response = await fetch(`${baseUrl}/v1/editor${path2}`, { ...options, headers });
10818
10983
  if (!response.ok) {
10819
10984
  const body = await response.json().catch(() => null);
10820
10985
  throw new ArbiApiError(body?.detail || `Document request failed (${response.status})`, {
@@ -10831,13 +10996,13 @@ var Arbi = class {
10831
10996
  */
10832
10997
  mail = {
10833
10998
  /** Fetch a path under `/v1/mail`; rejects a non-2xx response with an `ArbiApiError` (`status`). */
10834
- fetch: (path, init = {}) => this.recovering(async () => {
10999
+ fetch: (path2, init = {}) => this.recovering(async () => {
10835
11000
  const { baseUrl, accessToken } = this.getAuthHeaders();
10836
11001
  const headers = new Headers(init.headers);
10837
11002
  headers.set("Authorization", `Bearer ${accessToken}`);
10838
11003
  if (init.body && !headers.has("Content-Type"))
10839
11004
  headers.set("Content-Type", "application/json");
10840
- const response = await fetch(`${baseUrl}/v1/mail${path}`, { ...init, headers });
11005
+ const response = await fetch(`${baseUrl}/v1/mail${path2}`, { ...init, headers });
10841
11006
  if (!response.ok) {
10842
11007
  const body = await response.json().catch(() => null);
10843
11008
  throw new ArbiApiError(
@@ -11650,6 +11815,22 @@ var Arbi = class {
11650
11815
  /** The documents the open workspace may use as its house template. */
11651
11816
  candidates: () => listHouseTemplateCandidates(this.requireClient())
11652
11817
  };
11818
+ // ── Databases (user-defined tables of the open workspace) ──────────
11819
+ databases = {
11820
+ list: () => listDatabases(this.requireClient()),
11821
+ get: (databaseId) => getDatabase(this.requireClient(), databaseId),
11822
+ /** A search of the rows (any cell), sorted and paged on the server. */
11823
+ rows: (databaseId, query2) => listDatabaseRows(this.requireClient(), databaseId, query2),
11824
+ create: (body) => createDatabase(this.requireClient(), body),
11825
+ update: (databaseId, body) => updateDatabase(this.requireClient(), databaseId, body),
11826
+ delete: (databaseId) => deleteDatabase(this.requireClient(), databaseId),
11827
+ addRows: (databaseId, rows) => addDatabaseRows(this.requireClient(), databaseId, rows),
11828
+ updateRow: (databaseId, rowId, values) => updateDatabaseRow(this.requireClient(), databaseId, rowId, values),
11829
+ deleteRows: (databaseId, ids) => deleteDatabaseRows(this.requireClient(), databaseId, ids),
11830
+ import: (file, name) => importDatabase(this.requireClient(), file, name),
11831
+ importRows: (databaseId, file) => importDatabaseRows(this.requireClient(), databaseId, file),
11832
+ export: (databaseId, format) => exportDatabase(this.requireClient(), databaseId, format)
11833
+ };
11653
11834
  // ── Workspace facts ─────────────────────────────────────────────────
11654
11835
  facts = {
11655
11836
  create: (body) => createFact(this.requireClient(), body),
@@ -12422,13 +12603,13 @@ exports.connectErrorMessage = connectErrorMessage;
12422
12603
  exports.connectWebSocket = connectWebSocket;
12423
12604
  exports.connectWithReconnect = connectWithReconnect;
12424
12605
  exports.connectors = connectors_exports;
12425
- exports.consumeSSEStream = consumeSSEStream;
12426
12606
  exports.contacts = contacts_exports;
12427
12607
  exports.continuityPrompt = continuityPrompt;
12428
12608
  exports.conversations = conversations_exports;
12429
12609
  exports.countCitations = countCitations;
12430
12610
  exports.createAuthenticatedClient = createAuthenticatedClient;
12431
12611
  exports.createIndexAssigner = createIndexAssigner;
12612
+ exports.databases = databases_exports;
12432
12613
  exports.defaultKindForFormat = defaultKindForFormat;
12433
12614
  exports.doctags = doctags_exports;
12434
12615
  exports.documents = documents_exports;