@arbidocs/sdk 0.5.110 → 0.5.111

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.
@@ -7409,6 +7409,20 @@ declare namespace projects {
7409
7409
  export { type projects_ProductResponse as ProductResponse, type projects_ProjectAddonKind as ProjectAddonKind, type projects_ProjectAddonSettingsRequest as ProjectAddonSettingsRequest, type projects_ProjectBudget as ProjectBudget, type projects_ProjectCheckoutRequest as ProjectCheckoutRequest, type projects_ProjectConversationUsageResponse as ProjectConversationUsageResponse, type projects_ProjectCreateOptions as ProjectCreateOptions, type projects_ProjectDetails as ProjectDetails, type projects_ProjectEventKind as ProjectEventKind, type projects_ProjectEventResponse as ProjectEventResponse, type projects_ProjectInvoicesResponse as ProjectInvoicesResponse, type projects_ProjectNextPeriodAddonsRequest as ProjectNextPeriodAddonsRequest, type projects_ProjectPlanChangeRequest as ProjectPlanChangeRequest, type projects_ProjectQuoteRequest as ProjectQuoteRequest, type projects_ProjectResponse as ProjectResponse, type projects_ProjectUpdateRequest as ProjectUpdateRequest, type projects_ProjectUsageResponse as ProjectUsageResponse, type projects_TaxQuoteResponse as TaxQuoteResponse, type projects_UserDailyUsageResponse as UserDailyUsageResponse, projects_addAddonBlock as addAddonBlock, projects_billingPortal as billingPortal, projects_cancelSubscription as cancelSubscription, projects_changePlan as changePlan, projects_createCheckout as createCheckout, projects_createProject as createProject, projects_deleteProject as deleteProject, projects_formatBudget as formatBudget, projects_getProjectConversationUsage as getProjectConversationUsage, projects_getProjectInvoices as getProjectInvoices, projects_getProjectUsage as getProjectUsage, projects_getUserUsageToday as getUserUsageToday, projects_listProducts as listProducts, projects_listProjectEvents as listProjectEvents, projects_listProjects as listProjects, projects_parseBudget as parseBudget, projects_previewPlanChange as previewPlanChange, projects_quoteAddon as quoteAddon, projects_quotePlan as quotePlan, projects_refreshProject as refreshProject, projects_renameProject as renameProject, projects_setNextPeriodAddons as setNextPeriodAddons, projects_updateAddonSettings as updateAddonSettings, projects_updateProject as updateProject };
7410
7410
  }
7411
7411
 
7412
+ /**
7413
+ * The person's saved Analytics dashboards (`/v1/user/dashboards`). Each one's spec (JSON) is sealed
7414
+ * here to the user's own X25519 key (a SealedBox to the public half of the keypair their signing key
7415
+ * derives, as a saved signature): the server keeps bytes it can never read, its owner's only.
7416
+ */
7417
+
7418
+ /** A saved dashboard, opened: its spec as the JSON it was saved as; `null` when it does not open
7419
+ * with the user's key (sealed under another key, or damaged). */
7420
+ interface UserDashboard {
7421
+ id: string;
7422
+ json: string | null;
7423
+ updatedAt: string;
7424
+ }
7425
+
7412
7426
  /**
7413
7427
  * Stepped workflows: a run is a work conversation whose plan has named steps (`TaskPlan.steps`).
7414
7428
  * Form, upload and review steps wait for a person (`work.actOnStep`); an agent step is a turn the
@@ -10477,6 +10491,16 @@ declare class Arbi {
10477
10491
  is_billing_manager: boolean;
10478
10492
  }>;
10479
10493
  };
10494
+ readonly dashboards: {
10495
+ /** The user's saved dashboards (each spec's JSON), oldest first. */
10496
+ list: () => Promise<UserDashboard[]>;
10497
+ /** Save a dashboard's spec JSON (new without `id`, else replaced). */
10498
+ save: (dashboard: {
10499
+ id?: string;
10500
+ json: string;
10501
+ }) => Promise<UserDashboard>;
10502
+ remove: (id: string) => Promise<void>;
10503
+ };
10480
10504
  readonly firm: {
10481
10505
  /** The firm's pooled monthly £ of AI usage (`has_pool` false where there is none). */
10482
10506
  pool: () => Promise<{
@@ -7409,6 +7409,20 @@ declare namespace projects {
7409
7409
  export { type projects_ProductResponse as ProductResponse, type projects_ProjectAddonKind as ProjectAddonKind, type projects_ProjectAddonSettingsRequest as ProjectAddonSettingsRequest, type projects_ProjectBudget as ProjectBudget, type projects_ProjectCheckoutRequest as ProjectCheckoutRequest, type projects_ProjectConversationUsageResponse as ProjectConversationUsageResponse, type projects_ProjectCreateOptions as ProjectCreateOptions, type projects_ProjectDetails as ProjectDetails, type projects_ProjectEventKind as ProjectEventKind, type projects_ProjectEventResponse as ProjectEventResponse, type projects_ProjectInvoicesResponse as ProjectInvoicesResponse, type projects_ProjectNextPeriodAddonsRequest as ProjectNextPeriodAddonsRequest, type projects_ProjectPlanChangeRequest as ProjectPlanChangeRequest, type projects_ProjectQuoteRequest as ProjectQuoteRequest, type projects_ProjectResponse as ProjectResponse, type projects_ProjectUpdateRequest as ProjectUpdateRequest, type projects_ProjectUsageResponse as ProjectUsageResponse, type projects_TaxQuoteResponse as TaxQuoteResponse, type projects_UserDailyUsageResponse as UserDailyUsageResponse, projects_addAddonBlock as addAddonBlock, projects_billingPortal as billingPortal, projects_cancelSubscription as cancelSubscription, projects_changePlan as changePlan, projects_createCheckout as createCheckout, projects_createProject as createProject, projects_deleteProject as deleteProject, projects_formatBudget as formatBudget, projects_getProjectConversationUsage as getProjectConversationUsage, projects_getProjectInvoices as getProjectInvoices, projects_getProjectUsage as getProjectUsage, projects_getUserUsageToday as getUserUsageToday, projects_listProducts as listProducts, projects_listProjectEvents as listProjectEvents, projects_listProjects as listProjects, projects_parseBudget as parseBudget, projects_previewPlanChange as previewPlanChange, projects_quoteAddon as quoteAddon, projects_quotePlan as quotePlan, projects_refreshProject as refreshProject, projects_renameProject as renameProject, projects_setNextPeriodAddons as setNextPeriodAddons, projects_updateAddonSettings as updateAddonSettings, projects_updateProject as updateProject };
7410
7410
  }
7411
7411
 
7412
+ /**
7413
+ * The person's saved Analytics dashboards (`/v1/user/dashboards`). Each one's spec (JSON) is sealed
7414
+ * here to the user's own X25519 key (a SealedBox to the public half of the keypair their signing key
7415
+ * derives, as a saved signature): the server keeps bytes it can never read, its owner's only.
7416
+ */
7417
+
7418
+ /** A saved dashboard, opened: its spec as the JSON it was saved as; `null` when it does not open
7419
+ * with the user's key (sealed under another key, or damaged). */
7420
+ interface UserDashboard {
7421
+ id: string;
7422
+ json: string | null;
7423
+ updatedAt: string;
7424
+ }
7425
+
7412
7426
  /**
7413
7427
  * Stepped workflows: a run is a work conversation whose plan has named steps (`TaskPlan.steps`).
7414
7428
  * Form, upload and review steps wait for a person (`work.actOnStep`); an agent step is a turn the
@@ -10477,6 +10491,16 @@ declare class Arbi {
10477
10491
  is_billing_manager: boolean;
10478
10492
  }>;
10479
10493
  };
10494
+ readonly dashboards: {
10495
+ /** The user's saved dashboards (each spec's JSON), oldest first. */
10496
+ list: () => Promise<UserDashboard[]>;
10497
+ /** Save a dashboard's spec JSON (new without `id`, else replaced). */
10498
+ save: (dashboard: {
10499
+ id?: string;
10500
+ json: string;
10501
+ }) => Promise<UserDashboard>;
10502
+ remove: (id: string) => Promise<void>;
10503
+ };
10480
10504
  readonly firm: {
10481
10505
  /** The firm's pooled monthly £ of AI usage (`has_pool` false where there is none). */
10482
10506
  pool: () => Promise<{
package/dist/browser.cjs CHANGED
@@ -4157,7 +4157,7 @@ async function streamSSE(response, callbacks = {}) {
4157
4157
  });
4158
4158
  }
4159
4159
  const reader = response.body.getReader();
4160
- const decoder = new TextDecoder("utf-8");
4160
+ const decoder2 = new TextDecoder("utf-8");
4161
4161
  let sseBuffer = "";
4162
4162
  let text2 = "";
4163
4163
  let assistantMessageExtId = null;
@@ -4384,7 +4384,7 @@ async function streamSSE(response, callbacks = {}) {
4384
4384
  const { done, value } = chunk;
4385
4385
  if (done) break;
4386
4386
  const { events, remaining } = parseSSEEvents(
4387
- decoder.decode(value, { stream: true }),
4387
+ decoder2.decode(value, { stream: true }),
4388
4388
  sseBuffer
4389
4389
  );
4390
4390
  sseBuffer = remaining;
@@ -5748,12 +5748,12 @@ function consumeResponse(response, controller, cancel, options = {}) {
5748
5748
  if (controller.signal.aborted) abort();
5749
5749
  else if (options.id) bind(options.id);
5750
5750
  void (async () => {
5751
- const decoder = new TextDecoder();
5751
+ const decoder2 = new TextDecoder();
5752
5752
  const frames = new ResponseEventDecoder();
5753
5753
  try {
5754
5754
  while (!finished) {
5755
5755
  const { value, done } = await reader.read();
5756
- for (const frame of frames.push(decoder.decode(value, { stream: !done }), done)) {
5756
+ for (const frame of frames.push(decoder2.decode(value, { stream: !done }), done)) {
5757
5757
  process(frame);
5758
5758
  if (options.bufferEvents && bound && !finished && !iteratorClosed && queue.length >= 256)
5759
5759
  await new Promise((resolve) => {
@@ -8988,6 +8988,45 @@ async function cancelSubscription(arbi, projectExtId) {
8988
8988
  "Failed to cancel the subscription"
8989
8989
  );
8990
8990
  }
8991
+ var encoder = new TextEncoder();
8992
+ var decoder = new TextDecoder();
8993
+ var seal = (json2, keypair) => client.sealedBoxEncrypt(Uint8Array.from(encoder.encode(json2)), keypair.publicKey);
8994
+ async function listUserDashboards(arbi, keypair) {
8995
+ const rows = requireData(
8996
+ await arbi.fetch.GET("/v1/user/dashboards"),
8997
+ "Failed to load your dashboards"
8998
+ );
8999
+ return rows.map((row) => {
9000
+ let json2 = null;
9001
+ try {
9002
+ json2 = decoder.decode(client.sealedBoxDecrypt(row.ciphertext, keypair.secretKey));
9003
+ } catch {
9004
+ }
9005
+ return { id: row.external_id, json: json2, updatedAt: row.updated_at };
9006
+ });
9007
+ }
9008
+ async function saveUserDashboard(arbi, keypair, dashboard) {
9009
+ const body = { ciphertext: seal(dashboard.json, keypair) };
9010
+ const row = dashboard.id ? requireData(
9011
+ await arbi.fetch.PUT("/v1/user/dashboards/{dashboard_ext_id}", {
9012
+ params: { path: { dashboard_ext_id: dashboard.id } },
9013
+ body
9014
+ }),
9015
+ "Failed to save the dashboard"
9016
+ ) : requireData(
9017
+ await arbi.fetch.POST("/v1/user/dashboards", { body }),
9018
+ "Failed to save the dashboard"
9019
+ );
9020
+ return { id: row.external_id, json: dashboard.json, updatedAt: row.updated_at };
9021
+ }
9022
+ async function deleteUserDashboard(arbi, id) {
9023
+ requireOk(
9024
+ await arbi.fetch.DELETE("/v1/user/dashboards/{dashboard_ext_id}", {
9025
+ params: { path: { dashboard_ext_id: id } }
9026
+ }),
9027
+ "Failed to delete the dashboard"
9028
+ );
9029
+ }
8991
9030
 
8992
9031
  // src/operations/work.ts
8993
9032
  var work_exports = {};
@@ -12112,6 +12151,21 @@ var Arbi = class {
12112
12151
  */
12113
12152
  me: () => getCurrentUser(this.requireClient())
12114
12153
  };
12154
+ // ── Saved Analytics dashboards (the person's own, sealed to their key) ──
12155
+ dashboards = {
12156
+ /** The user's saved dashboards (each spec's JSON), oldest first. */
12157
+ list: async () => listUserDashboards(
12158
+ this.requireClient(),
12159
+ (await this.requireChatCrypto()).encryptionKeypair
12160
+ ),
12161
+ /** Save a dashboard's spec JSON (new without `id`, else replaced). */
12162
+ save: async (dashboard) => saveUserDashboard(
12163
+ this.requireClient(),
12164
+ (await this.requireChatCrypto()).encryptionKeypair,
12165
+ dashboard
12166
+ ),
12167
+ remove: (id) => deleteUserDashboard(this.requireClient(), id)
12168
+ };
12115
12169
  // ── Firm ──────────────────────────────────────────────────────────────
12116
12170
  firm = {
12117
12171
  /** The firm's pooled monthly £ of AI usage (`has_pool` false where there is none). */