@nemphi/sdk 0.2.4682 → 0.2.4844

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.d.ts CHANGED
@@ -1465,8 +1465,20 @@ export interface ActionPreview {
1465
1465
  user_name: string;
1466
1466
  expires_at: string;
1467
1467
  }
1468
- /** What a live document is: a document, a spreadsheet or a presentation. */
1469
- export type LiveDocumentKind = "doc" | "sheet" | "slides";
1468
+ /**
1469
+ * What a live document is: a document, a spreadsheet, a presentation, or a
1470
+ * `file` on the shelves (an uploaded or synced workspace document).
1471
+ */
1472
+ export type LiveDocumentKind = "doc" | "sheet" | "slides" | "file";
1473
+ /** The workspace document a `file` live document stands for. */
1474
+ export interface LiveDocumentFile {
1475
+ document_id: string;
1476
+ filename: string;
1477
+ content_type: string;
1478
+ size_bytes: number;
1479
+ /** The extraction's status: uploaded, processing, processed or failed. */
1480
+ status: string;
1481
+ }
1470
1482
  /**
1471
1483
  * Where a live document lives: its owner's `personal` space (seen by the
1472
1484
  * members it is shared with too) or the workspace's shared `team` space.
@@ -1504,6 +1516,8 @@ export interface LiveDocument {
1504
1516
  space: LiveDocumentSpace;
1505
1517
  folder_id: string | null;
1506
1518
  created_by: string | null;
1519
+ /** The file a kind `file` document stands for; null on one the team edits. */
1520
+ file: LiveDocumentFile | null;
1507
1521
  /** Whether the caller owns it: a personal document they created. */
1508
1522
  owned: boolean;
1509
1523
  tags: LiveDocumentTag[];
@@ -1522,6 +1536,8 @@ export interface LiveDocumentFilter {
1522
1536
  folder_id?: string;
1523
1537
  top_level?: boolean;
1524
1538
  tag?: string;
1539
+ /** Only the documents this member (a user id) created. */
1540
+ created_by?: string;
1525
1541
  }
1526
1542
  /** A folder of documents; folders nest through `parent_id`. */
1527
1543
  export interface LiveDocumentFolder {
@@ -1543,6 +1559,76 @@ export interface LiveDocumentShares {
1543
1559
  email: string;
1544
1560
  }[];
1545
1561
  }
1562
+ /** How many days a transfer's link works. */
1563
+ export type TransferExpiryDays = 1 | 3 | 7 | 14 | 30;
1564
+ /** What `createTransfer` sends (`transfers.create`). */
1565
+ export interface TransferInput {
1566
+ live_document_ids: string[];
1567
+ /** The first document's title by default. */
1568
+ title?: string;
1569
+ message?: string;
1570
+ /** 7 by default. */
1571
+ expires_in_days?: TransferExpiryDays;
1572
+ /** 6 to 72 characters; none by default. */
1573
+ password?: string;
1574
+ /** Addresses mailed the link. */
1575
+ recipients?: string[];
1576
+ }
1577
+ /** One document a transfer carries. */
1578
+ export interface TransferItem {
1579
+ /** The item's id; absent in the create answer. */
1580
+ id?: string;
1581
+ live_document_id: string;
1582
+ title: string;
1583
+ kind: LiveDocumentKind;
1584
+ }
1585
+ /** A transfer just created: its link exists only in this answer. */
1586
+ export interface CreatedTransfer {
1587
+ id: string;
1588
+ url: string;
1589
+ title: string;
1590
+ expires_at: string;
1591
+ locked: boolean;
1592
+ items: TransferItem[];
1593
+ recipients: string[];
1594
+ }
1595
+ /** One of the caller's transfers (`transfers.list`). The link is not kept. */
1596
+ export interface Transfer {
1597
+ id: string;
1598
+ title: string;
1599
+ message: string;
1600
+ created_by: string;
1601
+ sender_name: string;
1602
+ expires_at: string;
1603
+ expired: boolean;
1604
+ locked: boolean;
1605
+ revoked_at: string | null;
1606
+ download_count: number;
1607
+ created_at: string;
1608
+ items: TransferItem[];
1609
+ }
1610
+ /** One document on a transfer's public page. */
1611
+ export interface PublicTransferItem {
1612
+ id: string;
1613
+ name: string;
1614
+ /** A file's size; null for a document rendered when it downloads. */
1615
+ size_bytes: number | null;
1616
+ content_type: string;
1617
+ }
1618
+ /** A transfer's public page; `items` is absent while it is locked. */
1619
+ export interface PublicTransfer {
1620
+ title: string;
1621
+ message: string;
1622
+ sender_name: string;
1623
+ expires_at: string;
1624
+ locked: boolean;
1625
+ items?: PublicTransferItem[];
1626
+ }
1627
+ /** An unlocked transfer: the key its downloads carry for an hour. */
1628
+ export interface UnlockedTransfer {
1629
+ key: string;
1630
+ items: PublicTransferItem[];
1631
+ }
1546
1632
  /** One of the workspace's document tags and what it means. */
1547
1633
  export interface LiveDocumentWorkspaceTag {
1548
1634
  id: string;
@@ -1557,6 +1643,8 @@ export interface LiveDocumentState {
1557
1643
  id: string;
1558
1644
  title: string;
1559
1645
  kind: LiveDocumentKind;
1646
+ /** The file a kind `file` document stands for; null on one the team edits. */
1647
+ file: LiveDocumentFile | null;
1560
1648
  state: string;
1561
1649
  seq: number;
1562
1650
  /** Set while the document is in the trash, where it opens read-only. */
@@ -1586,6 +1674,8 @@ export interface Document {
1586
1674
  /** Upload only: true when the bytes were already filed for this tenant
1587
1675
  * and the returned document is the existing one, not a new row. */
1588
1676
  duplicate?: boolean;
1677
+ /** Upload only: the Docs shelf entry made when the upload named a place. */
1678
+ live_document_id?: string;
1589
1679
  extracted?: unknown;
1590
1680
  error?: string;
1591
1681
  }
@@ -1598,6 +1688,30 @@ export type CompanyDocumentKind = "rut" | "company_registration";
1598
1688
  * `knowledge.search` either way.
1599
1689
  */
1600
1690
  export type UploadDocumentKind = CompanyDocumentKind | "context";
1691
+ /** What `beginUpload` takes: the file's name, type and exact size, and
1692
+ * optionally a kind hint and a Docs shelf place (filed on completion). */
1693
+ export interface BeginUploadInput {
1694
+ filename: string;
1695
+ content_type?: string;
1696
+ size_bytes: number;
1697
+ kind?: UploadDocumentKind;
1698
+ space?: LiveDocumentSpace;
1699
+ folder_id?: string;
1700
+ title?: string;
1701
+ }
1702
+ /** An open upload session: send `parts` parts of `part_size` bytes each
1703
+ * (the last one shorter), in order from 1, before `expires_at`. */
1704
+ export interface UploadSession {
1705
+ id: string;
1706
+ part_size: number;
1707
+ parts: number;
1708
+ expires_at: string;
1709
+ }
1710
+ /** One part recorded, and the bytes the session holds so far. */
1711
+ export interface UploadPartResult {
1712
+ number: number;
1713
+ bytes_received: number;
1714
+ }
1601
1715
  /**
1602
1716
  * The tenant's own legal/fiscal identity, filled by parsing its
1603
1717
  * registration document (Colombia: the RUT) or via `company.set_profile`.
@@ -4048,36 +4162,84 @@ export interface MetricResult {
4048
4162
  /** The goal the query carried, echoed for the renderer. */
4049
4163
  target?: number;
4050
4164
  }
4051
- /** One read-only DuckDB SQL statement against the analytics lake. */
4052
- export interface AnalyticsQuery {
4053
- sql: string;
4165
+ /** How `analytics.query` folds the matching events into one column. */
4166
+ export interface AnalyticsMeasure {
4167
+ kind: "count" | "sum" | "avg" | "min" | "max" | "uniq";
4168
+ /**
4169
+ * The property measured; required for every kind but `count`, and a
4170
+ * number property for sum, avg, min and max.
4171
+ */
4172
+ property?: string;
4173
+ }
4174
+ /** One condition an event must meet to count. Values are always strings ("12", "true"). */
4175
+ export interface AnalyticsFilter {
4176
+ property: string;
4177
+ op: "eq" | "neq" | "in" | "not_in" | "gt" | "gte" | "lt" | "lte" | "contains" | "is_set" | "not_set";
4178
+ /** The operand of every op but in, not_in, is_set and not_set. */
4179
+ value?: string;
4180
+ /** The operands of in and not_in. */
4181
+ values?: string[];
4182
+ }
4183
+ /** One sort key: a result column (`period`, a dimension, `count` or `<property>_<kind>`). */
4184
+ export interface AnalyticsOrder {
4185
+ by: string;
4186
+ desc?: boolean;
4187
+ }
4188
+ /** The query a saved metric keeps: everything but the window and the row cap. */
4189
+ export interface SavedMetricQuery {
4190
+ /** The event stream, a name from `analytics.catalog`. */
4191
+ stream: string;
4192
+ /** Default one count. */
4193
+ measures?: AnalyticsMeasure[];
4194
+ /** Properties to group by; each becomes a column named without a leading `$`. */
4195
+ dimensions?: string[];
4196
+ /** Adds a first column `period` (YYYY-MM-DD, or YYYY-MM-DD HH:00 by hour). */
4197
+ bucket?: "hour" | "day" | "week" | "month";
4198
+ filters?: AnalyticsFilter[];
4199
+ order?: AnalyticsOrder[];
4200
+ }
4201
+ /**
4202
+ * A structured question over the workspace's own event streams. The
4203
+ * server compiles it to HogQL scoped to the workspace; nobody writes SQL.
4204
+ */
4205
+ export interface AnalyticsQuery extends SavedMetricQuery {
4206
+ /** First day, YYYY-MM-DD (inclusive); the window defaults to the last 30 days. */
4207
+ from?: string;
4208
+ /** Last day, YYYY-MM-DD (inclusive). */
4209
+ to?: string;
4054
4210
  /** Row cap for the result (default 200; max 2000). */
4055
4211
  max_rows?: number;
4056
4212
  }
4057
- export interface AnalyticsColumn {
4213
+ export interface AnalyticsResultColumn {
4058
4214
  name: string;
4059
- /** DuckDB type name (BIGINT, VARCHAR, DATE, TIMESTAMPTZ, ...). */
4215
+ /** The ClickHouse type PostHog reports (String, UInt64, Float64, Nullable(Float64), DateTime, ...). */
4060
4216
  type: string;
4061
4217
  }
4062
4218
  export interface AnalyticsResult {
4063
- columns: AnalyticsColumn[];
4219
+ columns: AnalyticsResultColumn[];
4064
4220
  rows: unknown[][];
4221
+ /** The HogQL that ran, for display only. */
4222
+ sql: string;
4065
4223
  row_count: number;
4066
4224
  truncated?: boolean;
4067
4225
  elapsed_ms: number;
4068
4226
  }
4069
- /** One analytics lake table as returned by `analytics.catalog`. */
4070
- export interface AnalyticsTable {
4227
+ /** One property an event stream carries. */
4228
+ export interface AnalyticsProperty {
4229
+ name: string;
4230
+ type: "string" | "number" | "boolean";
4231
+ doc: string;
4232
+ }
4233
+ /** One event stream as returned by `analytics.catalog`. */
4234
+ export interface AnalyticsStream {
4071
4235
  name: string;
4072
- /** "stream" (~1 min lag) or "snapshot" (daily copy). */
4073
- kind: "stream" | "snapshot";
4074
4236
  doc: string;
4075
- columns: AnalyticsColumn[];
4237
+ properties: AnalyticsProperty[];
4076
4238
  }
4077
4239
  export interface AnalyticsCatalog {
4078
- /** False until the analytics plane (ANALYTICS_URL) is deployed. */
4240
+ /** False until the platform has a PostHog query key. */
4079
4241
  configured: boolean;
4080
- tables: AnalyticsTable[];
4242
+ streams: AnalyticsStream[];
4081
4243
  }
4082
4244
  export interface CanvasStat {
4083
4245
  label: string;
@@ -4104,7 +4266,7 @@ export interface CanvasStat {
4104
4266
  }
4105
4267
  /** Selects one live record source with optional filters (records blocks). */
4106
4268
  export interface RecordsQuery {
4107
- source: "invoices" | "bills" | "parties" | "items" | "quotes" | "sales_orders" | "rentals" | "purchase_orders" | "employees" | "assets" | "bank_transactions" | "warehouses" | "stock_levels" | "stock_movements" | "inventory_counts" | "payroll_runs" | "payslips" | "payroll_novelties" | "payroll_parameters" | "payment_runs" | "journal_entries" | "accounts" | "agent_runs" | "crm_deals" | "members" | "roles" | "policies" | "connections" | "email_accounts" | "email_templates" | "email_campaigns" | "categorization_rules" | "documents" | "calendar_events" | "connected_calendar_events" | "calendar_accounts" | "connected_calendars" | "projects" | "project_tasks" | "project_columns" | "live_documents" | "agents" | "tags" | "tag_dimensions" | "crm_pipelines" | "crm_stages" | "crm_fields" | "payments" | "banks" | "payment_formats" | "apps" | "booking_types" | "bookings" | "ai_models";
4269
+ source: "invoices" | "bills" | "parties" | "items" | "quotes" | "sales_orders" | "rentals" | "purchase_orders" | "employees" | "assets" | "bank_transactions" | "warehouses" | "stock_levels" | "stock_movements" | "inventory_counts" | "payroll_runs" | "payslips" | "payroll_novelties" | "payroll_parameters" | "payment_runs" | "journal_entries" | "accounts" | "agent_runs" | "crm_deals" | "members" | "roles" | "policies" | "connections" | "email_accounts" | "email_templates" | "email_campaigns" | "categorization_rules" | "documents" | "calendar_events" | "connected_calendar_events" | "calendar_accounts" | "drive_accounts" | "connected_calendars" | "projects" | "project_tasks" | "project_columns" | "live_documents" | "agents" | "tags" | "tag_dimensions" | "crm_pipelines" | "crm_stages" | "crm_fields" | "payments" | "banks" | "payment_formats" | "apps" | "booking_types" | "bookings" | "ai_models";
4108
4270
  /** Status filter in the source's own vocabulary (e.g. draft | posted; unmatched). */
4109
4271
  status?: string;
4110
4272
  /** Kind filter where the source has one (parties: customer | vendor | both). */
@@ -5455,7 +5617,7 @@ export interface MarketingAdAccounts {
5455
5617
  }
5456
5618
  /** The window every marketing analytics answer echoes back, as YYYY-MM-DD. */
5457
5619
  export interface MarketingWindow {
5458
- /** False until the analytics plane (the lake) is deployed; every list is then empty. */
5620
+ /** Always true: the figures are read from the workspace's own database. */
5459
5621
  configured: boolean;
5460
5622
  since: string;
5461
5623
  until: string;
@@ -5719,6 +5881,25 @@ export interface CalendarConnection {
5719
5881
  last_error: string | null;
5720
5882
  calendars: ConnectedCalendar[];
5721
5883
  }
5884
+ /** A drive a member connects, mirrored into their personal Docs. */
5885
+ export type DriveProvider = "google" | "onedrive";
5886
+ /** One of the member's connected drives (`drives.list`). Never carries credentials. */
5887
+ export interface DriveAccount {
5888
+ id: string;
5889
+ provider: DriveProvider;
5890
+ address: string;
5891
+ /** `error`: the provider refused the connection and it waits to be connected again. */
5892
+ status: "active" | "error" | "disconnected";
5893
+ last_synced_at: string | null;
5894
+ last_error: string | null;
5895
+ /** The Docs folder the drive mirrors into, once the first sync made it. */
5896
+ root_folder_id: string | null;
5897
+ files: number;
5898
+ folders: number;
5899
+ /** Items left out (too large, edited here since, refused by the provider). */
5900
+ skipped: number;
5901
+ created_at: string;
5902
+ }
5722
5903
  export interface ConnectedCalendarEvent {
5723
5904
  id: string;
5724
5905
  calendar_id: string;
@@ -7179,7 +7360,7 @@ export interface NemphiClient {
7179
7360
  listMarketingAdAccounts(): Promise<MarketingAdAccounts>;
7180
7361
  /**
7181
7362
  * Every connected marketing account compared over one window, from the
7182
- * analytics lake: each social channel with its audience counter, the
7363
+ * synced provider figures: each social channel with its audience counter, the
7183
7364
  * posts it published and every organic measure the provider reported,
7184
7365
  * and each ad account with its spend and results. Defaults to the last
7185
7366
  * 28 days.
@@ -8079,7 +8260,22 @@ export interface NemphiClient {
8079
8260
  filename?: string;
8080
8261
  kind?: UploadDocumentKind;
8081
8262
  partyId?: string;
8263
+ /** Shelve the upload under Docs: a space, a folder of it, a title. */
8264
+ place?: LiveDocumentPlace & {
8265
+ title?: string;
8266
+ };
8082
8267
  }): Promise<Document>;
8268
+ /** Start a large upload (up to 5 GiB) sent in parts. */
8269
+ beginUpload(input: BeginUploadInput): Promise<UploadSession>;
8270
+ /** Send part `number` (from 1, in order): exactly `part_size` bytes, the
8271
+ * last part the rest. Sending the last recorded part again is answered
8272
+ * as the session stands. */
8273
+ uploadPart(id: string, number: number, body: Blob | Uint8Array): Promise<UploadPartResult>;
8274
+ /** Assemble the parts and file the document, the same answer as
8275
+ * `uploadDocument` (with `duplicate` for bytes already filed). */
8276
+ completeUpload(id: string): Promise<Document>;
8277
+ /** Abandon an upload and discard its parts. */
8278
+ abortUpload(id: string): Promise<void>;
8083
8279
  /**
8084
8280
  * Upload a workspace company logo (PNG/JPEG/WebP/GIF, max 2 MiB).
8085
8281
  * Owners and admins only. Sets `company_profiles.logo_url` to
@@ -8137,6 +8333,8 @@ export interface NemphiClient {
8137
8333
  id: string;
8138
8334
  deleted: boolean;
8139
8335
  }>;
8336
+ /** Puts a folder inside another folder of its space (empty: the top level). */
8337
+ moveLiveDocumentFolder(id: string, parentId: string): Promise<LiveDocumentFolder>;
8140
8338
  listLiveDocumentTags(): Promise<LiveDocumentWorkspaceTag[]>;
8141
8339
  /** Puts a tag on a document by name; a new name adds the tag to the workspace. */
8142
8340
  tagLiveDocument(id: string, tag: string): Promise<LiveDocument>;
@@ -8182,6 +8380,40 @@ export interface NemphiClient {
8182
8380
  * content type — for showing what was shared, not only its name.
8183
8381
  */
8184
8382
  downloadDocument(id: string): Promise<Response>;
8383
+ /** Sends documents through a public link, mailed to any recipients. */
8384
+ createTransfer(input: TransferInput): Promise<CreatedTransfer>;
8385
+ /** The caller's transfers (an owner or admin: the workspace's), newest first. */
8386
+ listTransfers(): Promise<Transfer[]>;
8387
+ /** Stops a transfer's link working, for everyone. */
8388
+ revokeTransfer(id: string): Promise<{
8389
+ id: string;
8390
+ revoked: boolean;
8391
+ }>;
8392
+ /** A transfer's public page, by its link's token; no session needed. */
8393
+ getPublicTransfer(token: string): Promise<PublicTransfer>;
8394
+ /** Unlocks a password-locked transfer; a wrong password fails with code `locked`. */
8395
+ unlockPublicTransfer(token: string, password: string): Promise<UnlockedTransfer>;
8396
+ /** One document of a transfer, as a streamable attachment `Response`. */
8397
+ downloadPublicTransferItem(token: string, item: string, key?: string): Promise<Response>;
8398
+ /** Every document of a transfer as one zip, streamed. */
8399
+ downloadPublicTransferZip(token: string, key?: string): Promise<Response>;
8400
+ /** The member's connected Google Drive and OneDrive accounts. */
8401
+ listDriveAccounts(): Promise<DriveAccount[]>;
8402
+ /** Starts connecting a drive: open `auth_url`; the provider returns to `returnTo`. */
8403
+ connectDriveAccount(input: {
8404
+ provider: DriveProvider;
8405
+ returnTo?: string;
8406
+ }): Promise<{
8407
+ auth_url: string;
8408
+ }>;
8409
+ /** Queues a sync of one of the member's drives now. */
8410
+ syncDriveAccount(id: string): Promise<{
8411
+ queued: boolean;
8412
+ }>;
8413
+ /** Forgets a drive's credentials and stops syncing; the copied documents stay. */
8414
+ disconnectDriveAccount(id: string): Promise<{
8415
+ disconnected: boolean;
8416
+ }>;
8185
8417
  /**
8186
8418
  * The action ledger, cursor-paged by id. `after` walks forward from a
8187
8419
  * cursor (oldest first); `before` walks backward from the newest
@@ -9137,9 +9369,9 @@ export interface NemphiClient {
9137
9369
  error?: string;
9138
9370
  }>;
9139
9371
  }>;
9140
- /** Ad-hoc read-only SQL on the analytics lake (tenant-scoped; requires the analytics plane). */
9372
+ /** A structured question over the workspace's own event streams, compiled to tenant-scoped HogQL. */
9141
9373
  queryAnalytics(input: AnalyticsQuery): Promise<AnalyticsResult>;
9142
- /** Lake tables, columns and docs, plus whether the analytics plane is configured. */
9374
+ /** The event streams and their properties, plus whether analytics is configured. */
9143
9375
  analyticsCatalog(): Promise<AnalyticsCatalog>;
9144
9376
  createConnection(input: {
9145
9377
  provider: "wompi" | "mercadopago";