@nemphi/sdk 0.2.4836 → 0.2.4853

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
@@ -1679,6 +1679,15 @@ export interface Document {
1679
1679
  extracted?: unknown;
1680
1680
  error?: string;
1681
1681
  }
1682
+ /**
1683
+ * A document with the whole text its extraction read (documents.read_text):
1684
+ * a .docx as paragraphs, a spreadsheet as tables, a presentation as slides,
1685
+ * a PDF as pages. Empty until the document is processed, or when it has no
1686
+ * text (a picture).
1687
+ */
1688
+ export interface DocumentText extends Document {
1689
+ markdown: string;
1690
+ }
1682
1691
  /** Upload kind hints that route a document to the company-profile parser. */
1683
1692
  export type CompanyDocumentKind = "rut" | "company_registration";
1684
1693
  /**
@@ -4162,36 +4171,84 @@ export interface MetricResult {
4162
4171
  /** The goal the query carried, echoed for the renderer. */
4163
4172
  target?: number;
4164
4173
  }
4165
- /** One read-only DuckDB SQL statement against the analytics lake. */
4166
- export interface AnalyticsQuery {
4167
- sql: string;
4174
+ /** How `analytics.query` folds the matching events into one column. */
4175
+ export interface AnalyticsMeasure {
4176
+ kind: "count" | "sum" | "avg" | "min" | "max" | "uniq";
4177
+ /**
4178
+ * The property measured; required for every kind but `count`, and a
4179
+ * number property for sum, avg, min and max.
4180
+ */
4181
+ property?: string;
4182
+ }
4183
+ /** One condition an event must meet to count. Values are always strings ("12", "true"). */
4184
+ export interface AnalyticsFilter {
4185
+ property: string;
4186
+ op: "eq" | "neq" | "in" | "not_in" | "gt" | "gte" | "lt" | "lte" | "contains" | "is_set" | "not_set";
4187
+ /** The operand of every op but in, not_in, is_set and not_set. */
4188
+ value?: string;
4189
+ /** The operands of in and not_in. */
4190
+ values?: string[];
4191
+ }
4192
+ /** One sort key: a result column (`period`, a dimension, `count` or `<property>_<kind>`). */
4193
+ export interface AnalyticsOrder {
4194
+ by: string;
4195
+ desc?: boolean;
4196
+ }
4197
+ /** The query a saved metric keeps: everything but the window and the row cap. */
4198
+ export interface SavedMetricQuery {
4199
+ /** The event stream, a name from `analytics.catalog`. */
4200
+ stream: string;
4201
+ /** Default one count. */
4202
+ measures?: AnalyticsMeasure[];
4203
+ /** Properties to group by; each becomes a column named without a leading `$`. */
4204
+ dimensions?: string[];
4205
+ /** Adds a first column `period` (YYYY-MM-DD, or YYYY-MM-DD HH:00 by hour). */
4206
+ bucket?: "hour" | "day" | "week" | "month";
4207
+ filters?: AnalyticsFilter[];
4208
+ order?: AnalyticsOrder[];
4209
+ }
4210
+ /**
4211
+ * A structured question over the workspace's own event streams. The
4212
+ * server compiles it to HogQL scoped to the workspace; nobody writes SQL.
4213
+ */
4214
+ export interface AnalyticsQuery extends SavedMetricQuery {
4215
+ /** First day, YYYY-MM-DD (inclusive); the window defaults to the last 30 days. */
4216
+ from?: string;
4217
+ /** Last day, YYYY-MM-DD (inclusive). */
4218
+ to?: string;
4168
4219
  /** Row cap for the result (default 200; max 2000). */
4169
4220
  max_rows?: number;
4170
4221
  }
4171
- export interface AnalyticsColumn {
4222
+ export interface AnalyticsResultColumn {
4172
4223
  name: string;
4173
- /** DuckDB type name (BIGINT, VARCHAR, DATE, TIMESTAMPTZ, ...). */
4224
+ /** The ClickHouse type PostHog reports (String, UInt64, Float64, Nullable(Float64), DateTime, ...). */
4174
4225
  type: string;
4175
4226
  }
4176
4227
  export interface AnalyticsResult {
4177
- columns: AnalyticsColumn[];
4228
+ columns: AnalyticsResultColumn[];
4178
4229
  rows: unknown[][];
4230
+ /** The HogQL that ran, for display only. */
4231
+ sql: string;
4179
4232
  row_count: number;
4180
4233
  truncated?: boolean;
4181
4234
  elapsed_ms: number;
4182
4235
  }
4183
- /** One analytics lake table as returned by `analytics.catalog`. */
4184
- export interface AnalyticsTable {
4236
+ /** One property an event stream carries. */
4237
+ export interface AnalyticsProperty {
4238
+ name: string;
4239
+ type: "string" | "number" | "boolean";
4240
+ doc: string;
4241
+ }
4242
+ /** One event stream as returned by `analytics.catalog`. */
4243
+ export interface AnalyticsStream {
4185
4244
  name: string;
4186
- /** "stream" (~1 min lag) or "snapshot" (daily copy). */
4187
- kind: "stream" | "snapshot";
4188
4245
  doc: string;
4189
- columns: AnalyticsColumn[];
4246
+ properties: AnalyticsProperty[];
4190
4247
  }
4191
4248
  export interface AnalyticsCatalog {
4192
- /** False until the analytics plane (ANALYTICS_URL) is deployed. */
4249
+ /** False until the platform has a PostHog query key. */
4193
4250
  configured: boolean;
4194
- tables: AnalyticsTable[];
4251
+ streams: AnalyticsStream[];
4195
4252
  }
4196
4253
  export interface CanvasStat {
4197
4254
  label: string;
@@ -5569,7 +5626,7 @@ export interface MarketingAdAccounts {
5569
5626
  }
5570
5627
  /** The window every marketing analytics answer echoes back, as YYYY-MM-DD. */
5571
5628
  export interface MarketingWindow {
5572
- /** False until the analytics plane (the lake) is deployed; every list is then empty. */
5629
+ /** Always true: the figures are read from the workspace's own database. */
5573
5630
  configured: boolean;
5574
5631
  since: string;
5575
5632
  until: string;
@@ -7312,7 +7369,7 @@ export interface NemphiClient {
7312
7369
  listMarketingAdAccounts(): Promise<MarketingAdAccounts>;
7313
7370
  /**
7314
7371
  * Every connected marketing account compared over one window, from the
7315
- * analytics lake: each social channel with its audience counter, the
7372
+ * synced provider figures: each social channel with its audience counter, the
7316
7373
  * posts it published and every organic measure the provider reported,
7317
7374
  * and each ad account with its spend and results. Defaults to the last
7318
7375
  * 28 days.
@@ -8260,6 +8317,8 @@ export interface NemphiClient {
8260
8317
  }): Promise<PartyMatches>;
8261
8318
  listDocuments(): Promise<Document[]>;
8262
8319
  getDocument(id: string): Promise<Document>;
8320
+ /** The document with the whole text its extraction read, as Markdown. */
8321
+ readDocumentText(id: string): Promise<DocumentText>;
8263
8322
  listLiveDocuments(filter?: LiveDocumentFilter): Promise<LiveDocument[]>;
8264
8323
  createLiveDocument(title: string, kind?: LiveDocumentKind, place?: LiveDocumentPlace): Promise<LiveDocument>;
8265
8324
  /** Files a document in a folder (empty: the top level) or moves it to another space. */
@@ -9321,9 +9380,9 @@ export interface NemphiClient {
9321
9380
  error?: string;
9322
9381
  }>;
9323
9382
  }>;
9324
- /** Ad-hoc read-only SQL on the analytics lake (tenant-scoped; requires the analytics plane). */
9383
+ /** A structured question over the workspace's own event streams, compiled to tenant-scoped HogQL. */
9325
9384
  queryAnalytics(input: AnalyticsQuery): Promise<AnalyticsResult>;
9326
- /** Lake tables, columns and docs, plus whether the analytics plane is configured. */
9385
+ /** The event streams and their properties, plus whether analytics is configured. */
9327
9386
  analyticsCatalog(): Promise<AnalyticsCatalog>;
9328
9387
  createConnection(input: {
9329
9388
  provider: "wompi" | "mercadopago";