@nemphi/sdk 0.2.4836 → 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
@@ -4162,36 +4162,84 @@ export interface MetricResult {
4162
4162
  /** The goal the query carried, echoed for the renderer. */
4163
4163
  target?: number;
4164
4164
  }
4165
- /** One read-only DuckDB SQL statement against the analytics lake. */
4166
- export interface AnalyticsQuery {
4167
- 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;
4168
4210
  /** Row cap for the result (default 200; max 2000). */
4169
4211
  max_rows?: number;
4170
4212
  }
4171
- export interface AnalyticsColumn {
4213
+ export interface AnalyticsResultColumn {
4172
4214
  name: string;
4173
- /** DuckDB type name (BIGINT, VARCHAR, DATE, TIMESTAMPTZ, ...). */
4215
+ /** The ClickHouse type PostHog reports (String, UInt64, Float64, Nullable(Float64), DateTime, ...). */
4174
4216
  type: string;
4175
4217
  }
4176
4218
  export interface AnalyticsResult {
4177
- columns: AnalyticsColumn[];
4219
+ columns: AnalyticsResultColumn[];
4178
4220
  rows: unknown[][];
4221
+ /** The HogQL that ran, for display only. */
4222
+ sql: string;
4179
4223
  row_count: number;
4180
4224
  truncated?: boolean;
4181
4225
  elapsed_ms: number;
4182
4226
  }
4183
- /** One analytics lake table as returned by `analytics.catalog`. */
4184
- 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 {
4185
4235
  name: string;
4186
- /** "stream" (~1 min lag) or "snapshot" (daily copy). */
4187
- kind: "stream" | "snapshot";
4188
4236
  doc: string;
4189
- columns: AnalyticsColumn[];
4237
+ properties: AnalyticsProperty[];
4190
4238
  }
4191
4239
  export interface AnalyticsCatalog {
4192
- /** False until the analytics plane (ANALYTICS_URL) is deployed. */
4240
+ /** False until the platform has a PostHog query key. */
4193
4241
  configured: boolean;
4194
- tables: AnalyticsTable[];
4242
+ streams: AnalyticsStream[];
4195
4243
  }
4196
4244
  export interface CanvasStat {
4197
4245
  label: string;
@@ -5569,7 +5617,7 @@ export interface MarketingAdAccounts {
5569
5617
  }
5570
5618
  /** The window every marketing analytics answer echoes back, as YYYY-MM-DD. */
5571
5619
  export interface MarketingWindow {
5572
- /** 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. */
5573
5621
  configured: boolean;
5574
5622
  since: string;
5575
5623
  until: string;
@@ -7312,7 +7360,7 @@ export interface NemphiClient {
7312
7360
  listMarketingAdAccounts(): Promise<MarketingAdAccounts>;
7313
7361
  /**
7314
7362
  * Every connected marketing account compared over one window, from the
7315
- * analytics lake: each social channel with its audience counter, the
7363
+ * synced provider figures: each social channel with its audience counter, the
7316
7364
  * posts it published and every organic measure the provider reported,
7317
7365
  * and each ad account with its spend and results. Defaults to the last
7318
7366
  * 28 days.
@@ -9321,9 +9369,9 @@ export interface NemphiClient {
9321
9369
  error?: string;
9322
9370
  }>;
9323
9371
  }>;
9324
- /** 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. */
9325
9373
  queryAnalytics(input: AnalyticsQuery): Promise<AnalyticsResult>;
9326
- /** Lake tables, columns and docs, plus whether the analytics plane is configured. */
9374
+ /** The event streams and their properties, plus whether analytics is configured. */
9327
9375
  analyticsCatalog(): Promise<AnalyticsCatalog>;
9328
9376
  createConnection(input: {
9329
9377
  provider: "wompi" | "mercadopago";