@lunora/bindings 1.0.0-alpha.7 → 1.0.0-alpha.9
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/analytics/index.d.mts +70 -70
- package/dist/analytics/index.d.ts +70 -70
- package/dist/images/index.d.mts +147 -147
- package/dist/images/index.d.ts +147 -147
- package/dist/kv/index.d.mts +89 -89
- package/dist/kv/index.d.ts +89 -89
- package/dist/pipelines/index.d.mts +24 -24
- package/dist/pipelines/index.d.ts +24 -24
- package/dist/r2sql/index.d.mts +120 -120
- package/dist/r2sql/index.d.ts +120 -120
- package/dist/vectors/index.d.mts +83 -83
- package/dist/vectors/index.d.ts +83 -83
- package/package.json +2 -2
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { LunoraError } from '@lunora/errors';
|
|
2
2
|
/**
|
|
3
|
-
* Structural types for the Analytics Engine write path.
|
|
4
|
-
*
|
|
5
|
-
* The real binding is workers-types' `AnalyticsEngineDataset`. We mirror it
|
|
6
|
-
* **structurally** (`AnalyticsEngineDatasetLike`) so plain-object test doubles
|
|
7
|
-
* satisfy the contract without pulling workerd into a unit test — the same
|
|
8
|
-
* approach `@lunora/d1` takes with `D1DatabaseLike`
|
|
9
|
-
* (`packages/d1/src/d1-client.ts`).
|
|
10
|
-
*/
|
|
3
|
+
* Structural types for the Analytics Engine write path.
|
|
4
|
+
*
|
|
5
|
+
* The real binding is workers-types' `AnalyticsEngineDataset`. We mirror it
|
|
6
|
+
* **structurally** (`AnalyticsEngineDatasetLike`) so plain-object test doubles
|
|
7
|
+
* satisfy the contract without pulling workerd into a unit test — the same
|
|
8
|
+
* approach `@lunora/d1` takes with `D1DatabaseLike`
|
|
9
|
+
* (`packages/d1/src/d1-client.ts`).
|
|
10
|
+
*/
|
|
11
11
|
/**
|
|
12
|
-
* One Analytics Engine data point, mirroring the positional shape
|
|
13
|
-
* `writeDataPoint` accepts. AE stores up to 20 string `blobs`, up to 20 numeric
|
|
14
|
-
* `doubles`, and exactly **one** `index` (the high-cardinality sampling key) per
|
|
15
|
-
* data point — the SQL API later exposes them as `blob1..blob20`,
|
|
16
|
-
* `double1..double20`, and `index1`.
|
|
17
|
-
*/
|
|
12
|
+
* One Analytics Engine data point, mirroring the positional shape
|
|
13
|
+
* `writeDataPoint` accepts. AE stores up to 20 string `blobs`, up to 20 numeric
|
|
14
|
+
* `doubles`, and exactly **one** `index` (the high-cardinality sampling key) per
|
|
15
|
+
* data point — the SQL API later exposes them as `blob1..blob20`,
|
|
16
|
+
* `double1..double20`, and `index1`.
|
|
17
|
+
*/
|
|
18
18
|
interface AnalyticsEngineDataPoint {
|
|
19
19
|
/** String columns, mapped positionally to `blob1..blob20`. */
|
|
20
20
|
blobs?: (ArrayBuffer | null | string)[];
|
|
@@ -24,19 +24,19 @@ interface AnalyticsEngineDataPoint {
|
|
|
24
24
|
indexes?: (ArrayBuffer | string)[];
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Minimal structural projection of workers-types' `AnalyticsEngineDataset`,
|
|
28
|
-
* kept loose enough for a plain-object fake in unit tests. `writeDataPoint` is
|
|
29
|
-
* fire-and-forget: it returns `void` and never throws on the hot path.
|
|
30
|
-
*/
|
|
27
|
+
* Minimal structural projection of workers-types' `AnalyticsEngineDataset`,
|
|
28
|
+
* kept loose enough for a plain-object fake in unit tests. `writeDataPoint` is
|
|
29
|
+
* fire-and-forget: it returns `void` and never throws on the hot path.
|
|
30
|
+
*/
|
|
31
31
|
interface AnalyticsEngineDatasetLike {
|
|
32
32
|
writeDataPoint: (event: AnalyticsEngineDataPoint) => void;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* Named-field event handed to {@link AnalyticsClient.track}. Each field is
|
|
36
|
-
* mapped to a positional AE column and the mapping recorded in a returned
|
|
37
|
-
* {@link TrackSchema}, so the read side can reconstruct named columns from the
|
|
38
|
-
* SQL API's positional `blobN`/`doubleN`/`index1` output.
|
|
39
|
-
*/
|
|
35
|
+
* Named-field event handed to {@link AnalyticsClient.track}. Each field is
|
|
36
|
+
* mapped to a positional AE column and the mapping recorded in a returned
|
|
37
|
+
* {@link TrackSchema}, so the read side can reconstruct named columns from the
|
|
38
|
+
* SQL API's positional `blobN`/`doubleN`/`index1` output.
|
|
39
|
+
*/
|
|
40
40
|
interface TrackEvent {
|
|
41
41
|
/** String dimensions → `blobs` (`blob1..blob20`), in object key order. */
|
|
42
42
|
dimensions?: Record<string, string>;
|
|
@@ -53,11 +53,11 @@ interface TrackColumn {
|
|
|
53
53
|
field: string;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
|
-
* The field→column mapping {@link AnalyticsClient.track} records for one event
|
|
57
|
-
* shape, so the read side can project the SQL API's positional columns back to
|
|
58
|
-
* named fields. `name` is the logical event name; the column arrays are in the
|
|
59
|
-
* same order the dimensions/metrics were written.
|
|
60
|
-
*/
|
|
56
|
+
* The field→column mapping {@link AnalyticsClient.track} records for one event
|
|
57
|
+
* shape, so the read side can project the SQL API's positional columns back to
|
|
58
|
+
* named fields. `name` is the logical event name; the column arrays are in the
|
|
59
|
+
* same order the dimensions/metrics were written.
|
|
60
|
+
*/
|
|
61
61
|
interface TrackSchema {
|
|
62
62
|
dimensions: TrackColumn[];
|
|
63
63
|
index: TrackColumn | null;
|
|
@@ -65,41 +65,41 @@ interface TrackSchema {
|
|
|
65
65
|
name: string;
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
* The write-side client bound to `ctx.analytics` (the generated context imports
|
|
69
|
-
* this exact type as `import("@lunora/bindings/analytics").AnalyticsClient`). Telemetry
|
|
70
|
-
* is fire-and-forget and sampled — never read a data point back in-handler.
|
|
71
|
-
*/
|
|
68
|
+
* The write-side client bound to `ctx.analytics` (the generated context imports
|
|
69
|
+
* this exact type as `import("@lunora/bindings/analytics").AnalyticsClient`). Telemetry
|
|
70
|
+
* is fire-and-forget and sampled — never read a data point back in-handler.
|
|
71
|
+
*/
|
|
72
72
|
interface AnalyticsClient {
|
|
73
73
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
* Ergonomic named-field write: maps `{ dimensions, metrics, index }` to the
|
|
75
|
+
* positional layout, writes it, and returns the {@link TrackSchema} mapping
|
|
76
|
+
* (the logical `name` is recorded as the first blob, `blob1`).
|
|
77
|
+
*/
|
|
78
78
|
track: (name: string, event?: TrackEvent) => TrackSchema;
|
|
79
79
|
/**
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
* Write a raw positional data point. Enforces AE's per-data-point count
|
|
81
|
+
* caps (≤20 blobs, ≤20 doubles, ≤1 index) and byte budget (combined blobs
|
|
82
|
+
* ≤16 KiB, index ≤96 bytes, measured as UTF-8); overflow throws so a misuse
|
|
83
|
+
* surfaces in dev rather than being silently rejected by the platform.
|
|
84
|
+
*/
|
|
85
85
|
writeDataPoint: (event: AnalyticsEngineDataPoint) => void;
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
|
-
* Wrap an Analytics Engine dataset binding in the write-side
|
|
89
|
-
* {@link AnalyticsClient} bound to `ctx.analytics`.
|
|
90
|
-
*
|
|
91
|
-
* The binding is `env.ANALYTICS` (the self-describing
|
|
92
|
-
* `analytics_engine_datasets` binding the config layer reconciles). Writes are
|
|
93
|
-
* fire-and-forget and sampled — there is no return value to read in-handler.
|
|
94
|
-
*
|
|
95
|
-
* `writeDataPoint` enforces AE's per-data-point caps eagerly — both the count
|
|
96
|
-
* caps (≤20 blobs, ≤20 doubles, ≤1 index) and the byte budget (combined blobs
|
|
97
|
-
* ≤16 KiB, index ≤96 bytes, measured as UTF-8) — so a misuse throws in dev
|
|
98
|
-
* instead of being silently rejected by the platform at the edge. `track` is
|
|
99
|
-
* the ergonomic named-field path: it maps a
|
|
100
|
-
* `{ dimensions, metrics, index }` object to the positional layout and returns
|
|
101
|
-
* the field→column mapping the read side uses to reconstruct named columns.
|
|
102
|
-
*/
|
|
88
|
+
* Wrap an Analytics Engine dataset binding in the write-side
|
|
89
|
+
* {@link AnalyticsClient} bound to `ctx.analytics`.
|
|
90
|
+
*
|
|
91
|
+
* The binding is `env.ANALYTICS` (the self-describing
|
|
92
|
+
* `analytics_engine_datasets` binding the config layer reconciles). Writes are
|
|
93
|
+
* fire-and-forget and sampled — there is no return value to read in-handler.
|
|
94
|
+
*
|
|
95
|
+
* `writeDataPoint` enforces AE's per-data-point caps eagerly — both the count
|
|
96
|
+
* caps (≤20 blobs, ≤20 doubles, ≤1 index) and the byte budget (combined blobs
|
|
97
|
+
* ≤16 KiB, index ≤96 bytes, measured as UTF-8) — so a misuse throws in dev
|
|
98
|
+
* instead of being silently rejected by the platform at the edge. `track` is
|
|
99
|
+
* the ergonomic named-field path: it maps a
|
|
100
|
+
* `{ dimensions, metrics, index }` object to the positional layout and returns
|
|
101
|
+
* the field→column mapping the read side uses to reconstruct named columns.
|
|
102
|
+
*/
|
|
103
103
|
declare const createAnalytics: (binding: AnalyticsEngineDatasetLike) => AnalyticsClient;
|
|
104
104
|
/** Configuration for an {@link AnalyticsSqlClient}. */
|
|
105
105
|
interface AnalyticsSqlConfig {
|
|
@@ -108,24 +108,24 @@ interface AnalyticsSqlConfig {
|
|
|
108
108
|
/** API token with Analytics Engine read scope. A secret — never a binding. */
|
|
109
109
|
apiToken: string;
|
|
110
110
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
* `fetch` implementation. Defaults to the global `fetch`; injected in tests
|
|
112
|
+
* so the SQL path never touches the network.
|
|
113
|
+
*/
|
|
114
114
|
fetch?: typeof globalThis.fetch;
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
|
-
* One column descriptor in a SQL-API response's `meta` array: the column `name`
|
|
118
|
-
* and the AE storage `type` (`String`, `Float64`, `DateTime`, …).
|
|
119
|
-
*/
|
|
117
|
+
* One column descriptor in a SQL-API response's `meta` array: the column `name`
|
|
118
|
+
* and the AE storage `type` (`String`, `Float64`, `DateTime`, …).
|
|
119
|
+
*/
|
|
120
120
|
interface AnalyticsSqlColumnMeta {
|
|
121
121
|
name: string;
|
|
122
122
|
type: string;
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
|
-
* Parsed SQL-API result. AE returns `{ meta, data, rows, rows_before_limit_at_least }`;
|
|
126
|
-
* we surface `columns` (from `meta`), the `rows` array of column→value records,
|
|
127
|
-
* and the total `rowCount`.
|
|
128
|
-
*/
|
|
125
|
+
* Parsed SQL-API result. AE returns `{ meta, data, rows, rows_before_limit_at_least }`;
|
|
126
|
+
* we surface `columns` (from `meta`), the `rows` array of column→value records,
|
|
127
|
+
* and the total `rowCount`.
|
|
128
|
+
*/
|
|
129
129
|
interface AnalyticsSqlResult {
|
|
130
130
|
columns: AnalyticsSqlColumnMeta[];
|
|
131
131
|
rowCount: number;
|
|
@@ -140,9 +140,9 @@ interface AnalyticsSqlClient {
|
|
|
140
140
|
query: (sql: string) => Promise<AnalyticsSqlResult>;
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
|
-
* Build an {@link AnalyticsSqlClient}. Each `query` POSTs the raw SQL text to
|
|
144
|
-
* the account's `analytics_engine/sql` endpoint with the bearer token, then
|
|
145
|
-
* normalises AE's `{ meta, data, rows }` body into {@link AnalyticsSqlResult}.
|
|
146
|
-
*/
|
|
143
|
+
* Build an {@link AnalyticsSqlClient}. Each `query` POSTs the raw SQL text to
|
|
144
|
+
* the account's `analytics_engine/sql` endpoint with the bearer token, then
|
|
145
|
+
* normalises AE's `{ meta, data, rows }` body into {@link AnalyticsSqlResult}.
|
|
146
|
+
*/
|
|
147
147
|
declare const createAnalyticsSqlClient: (config: AnalyticsSqlConfig) => AnalyticsSqlClient;
|
|
148
148
|
export { type AnalyticsClient, type AnalyticsEngineDataPoint, type AnalyticsEngineDatasetLike, type AnalyticsSqlClient, type AnalyticsSqlColumnMeta, type AnalyticsSqlConfig, AnalyticsSqlError, type AnalyticsSqlResult, type TrackColumn, type TrackEvent, type TrackSchema, createAnalytics, createAnalyticsSqlClient };
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { LunoraError } from '@lunora/errors';
|
|
2
2
|
/**
|
|
3
|
-
* Structural types for the Analytics Engine write path.
|
|
4
|
-
*
|
|
5
|
-
* The real binding is workers-types' `AnalyticsEngineDataset`. We mirror it
|
|
6
|
-
* **structurally** (`AnalyticsEngineDatasetLike`) so plain-object test doubles
|
|
7
|
-
* satisfy the contract without pulling workerd into a unit test — the same
|
|
8
|
-
* approach `@lunora/d1` takes with `D1DatabaseLike`
|
|
9
|
-
* (`packages/d1/src/d1-client.ts`).
|
|
10
|
-
*/
|
|
3
|
+
* Structural types for the Analytics Engine write path.
|
|
4
|
+
*
|
|
5
|
+
* The real binding is workers-types' `AnalyticsEngineDataset`. We mirror it
|
|
6
|
+
* **structurally** (`AnalyticsEngineDatasetLike`) so plain-object test doubles
|
|
7
|
+
* satisfy the contract without pulling workerd into a unit test — the same
|
|
8
|
+
* approach `@lunora/d1` takes with `D1DatabaseLike`
|
|
9
|
+
* (`packages/d1/src/d1-client.ts`).
|
|
10
|
+
*/
|
|
11
11
|
/**
|
|
12
|
-
* One Analytics Engine data point, mirroring the positional shape
|
|
13
|
-
* `writeDataPoint` accepts. AE stores up to 20 string `blobs`, up to 20 numeric
|
|
14
|
-
* `doubles`, and exactly **one** `index` (the high-cardinality sampling key) per
|
|
15
|
-
* data point — the SQL API later exposes them as `blob1..blob20`,
|
|
16
|
-
* `double1..double20`, and `index1`.
|
|
17
|
-
*/
|
|
12
|
+
* One Analytics Engine data point, mirroring the positional shape
|
|
13
|
+
* `writeDataPoint` accepts. AE stores up to 20 string `blobs`, up to 20 numeric
|
|
14
|
+
* `doubles`, and exactly **one** `index` (the high-cardinality sampling key) per
|
|
15
|
+
* data point — the SQL API later exposes them as `blob1..blob20`,
|
|
16
|
+
* `double1..double20`, and `index1`.
|
|
17
|
+
*/
|
|
18
18
|
interface AnalyticsEngineDataPoint {
|
|
19
19
|
/** String columns, mapped positionally to `blob1..blob20`. */
|
|
20
20
|
blobs?: (ArrayBuffer | null | string)[];
|
|
@@ -24,19 +24,19 @@ interface AnalyticsEngineDataPoint {
|
|
|
24
24
|
indexes?: (ArrayBuffer | string)[];
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
* Minimal structural projection of workers-types' `AnalyticsEngineDataset`,
|
|
28
|
-
* kept loose enough for a plain-object fake in unit tests. `writeDataPoint` is
|
|
29
|
-
* fire-and-forget: it returns `void` and never throws on the hot path.
|
|
30
|
-
*/
|
|
27
|
+
* Minimal structural projection of workers-types' `AnalyticsEngineDataset`,
|
|
28
|
+
* kept loose enough for a plain-object fake in unit tests. `writeDataPoint` is
|
|
29
|
+
* fire-and-forget: it returns `void` and never throws on the hot path.
|
|
30
|
+
*/
|
|
31
31
|
interface AnalyticsEngineDatasetLike {
|
|
32
32
|
writeDataPoint: (event: AnalyticsEngineDataPoint) => void;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* Named-field event handed to {@link AnalyticsClient.track}. Each field is
|
|
36
|
-
* mapped to a positional AE column and the mapping recorded in a returned
|
|
37
|
-
* {@link TrackSchema}, so the read side can reconstruct named columns from the
|
|
38
|
-
* SQL API's positional `blobN`/`doubleN`/`index1` output.
|
|
39
|
-
*/
|
|
35
|
+
* Named-field event handed to {@link AnalyticsClient.track}. Each field is
|
|
36
|
+
* mapped to a positional AE column and the mapping recorded in a returned
|
|
37
|
+
* {@link TrackSchema}, so the read side can reconstruct named columns from the
|
|
38
|
+
* SQL API's positional `blobN`/`doubleN`/`index1` output.
|
|
39
|
+
*/
|
|
40
40
|
interface TrackEvent {
|
|
41
41
|
/** String dimensions → `blobs` (`blob1..blob20`), in object key order. */
|
|
42
42
|
dimensions?: Record<string, string>;
|
|
@@ -53,11 +53,11 @@ interface TrackColumn {
|
|
|
53
53
|
field: string;
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
56
|
-
* The field→column mapping {@link AnalyticsClient.track} records for one event
|
|
57
|
-
* shape, so the read side can project the SQL API's positional columns back to
|
|
58
|
-
* named fields. `name` is the logical event name; the column arrays are in the
|
|
59
|
-
* same order the dimensions/metrics were written.
|
|
60
|
-
*/
|
|
56
|
+
* The field→column mapping {@link AnalyticsClient.track} records for one event
|
|
57
|
+
* shape, so the read side can project the SQL API's positional columns back to
|
|
58
|
+
* named fields. `name` is the logical event name; the column arrays are in the
|
|
59
|
+
* same order the dimensions/metrics were written.
|
|
60
|
+
*/
|
|
61
61
|
interface TrackSchema {
|
|
62
62
|
dimensions: TrackColumn[];
|
|
63
63
|
index: TrackColumn | null;
|
|
@@ -65,41 +65,41 @@ interface TrackSchema {
|
|
|
65
65
|
name: string;
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
|
-
* The write-side client bound to `ctx.analytics` (the generated context imports
|
|
69
|
-
* this exact type as `import("@lunora/bindings/analytics").AnalyticsClient`). Telemetry
|
|
70
|
-
* is fire-and-forget and sampled — never read a data point back in-handler.
|
|
71
|
-
*/
|
|
68
|
+
* The write-side client bound to `ctx.analytics` (the generated context imports
|
|
69
|
+
* this exact type as `import("@lunora/bindings/analytics").AnalyticsClient`). Telemetry
|
|
70
|
+
* is fire-and-forget and sampled — never read a data point back in-handler.
|
|
71
|
+
*/
|
|
72
72
|
interface AnalyticsClient {
|
|
73
73
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
* Ergonomic named-field write: maps `{ dimensions, metrics, index }` to the
|
|
75
|
+
* positional layout, writes it, and returns the {@link TrackSchema} mapping
|
|
76
|
+
* (the logical `name` is recorded as the first blob, `blob1`).
|
|
77
|
+
*/
|
|
78
78
|
track: (name: string, event?: TrackEvent) => TrackSchema;
|
|
79
79
|
/**
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
* Write a raw positional data point. Enforces AE's per-data-point count
|
|
81
|
+
* caps (≤20 blobs, ≤20 doubles, ≤1 index) and byte budget (combined blobs
|
|
82
|
+
* ≤16 KiB, index ≤96 bytes, measured as UTF-8); overflow throws so a misuse
|
|
83
|
+
* surfaces in dev rather than being silently rejected by the platform.
|
|
84
|
+
*/
|
|
85
85
|
writeDataPoint: (event: AnalyticsEngineDataPoint) => void;
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
|
-
* Wrap an Analytics Engine dataset binding in the write-side
|
|
89
|
-
* {@link AnalyticsClient} bound to `ctx.analytics`.
|
|
90
|
-
*
|
|
91
|
-
* The binding is `env.ANALYTICS` (the self-describing
|
|
92
|
-
* `analytics_engine_datasets` binding the config layer reconciles). Writes are
|
|
93
|
-
* fire-and-forget and sampled — there is no return value to read in-handler.
|
|
94
|
-
*
|
|
95
|
-
* `writeDataPoint` enforces AE's per-data-point caps eagerly — both the count
|
|
96
|
-
* caps (≤20 blobs, ≤20 doubles, ≤1 index) and the byte budget (combined blobs
|
|
97
|
-
* ≤16 KiB, index ≤96 bytes, measured as UTF-8) — so a misuse throws in dev
|
|
98
|
-
* instead of being silently rejected by the platform at the edge. `track` is
|
|
99
|
-
* the ergonomic named-field path: it maps a
|
|
100
|
-
* `{ dimensions, metrics, index }` object to the positional layout and returns
|
|
101
|
-
* the field→column mapping the read side uses to reconstruct named columns.
|
|
102
|
-
*/
|
|
88
|
+
* Wrap an Analytics Engine dataset binding in the write-side
|
|
89
|
+
* {@link AnalyticsClient} bound to `ctx.analytics`.
|
|
90
|
+
*
|
|
91
|
+
* The binding is `env.ANALYTICS` (the self-describing
|
|
92
|
+
* `analytics_engine_datasets` binding the config layer reconciles). Writes are
|
|
93
|
+
* fire-and-forget and sampled — there is no return value to read in-handler.
|
|
94
|
+
*
|
|
95
|
+
* `writeDataPoint` enforces AE's per-data-point caps eagerly — both the count
|
|
96
|
+
* caps (≤20 blobs, ≤20 doubles, ≤1 index) and the byte budget (combined blobs
|
|
97
|
+
* ≤16 KiB, index ≤96 bytes, measured as UTF-8) — so a misuse throws in dev
|
|
98
|
+
* instead of being silently rejected by the platform at the edge. `track` is
|
|
99
|
+
* the ergonomic named-field path: it maps a
|
|
100
|
+
* `{ dimensions, metrics, index }` object to the positional layout and returns
|
|
101
|
+
* the field→column mapping the read side uses to reconstruct named columns.
|
|
102
|
+
*/
|
|
103
103
|
declare const createAnalytics: (binding: AnalyticsEngineDatasetLike) => AnalyticsClient;
|
|
104
104
|
/** Configuration for an {@link AnalyticsSqlClient}. */
|
|
105
105
|
interface AnalyticsSqlConfig {
|
|
@@ -108,24 +108,24 @@ interface AnalyticsSqlConfig {
|
|
|
108
108
|
/** API token with Analytics Engine read scope. A secret — never a binding. */
|
|
109
109
|
apiToken: string;
|
|
110
110
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
* `fetch` implementation. Defaults to the global `fetch`; injected in tests
|
|
112
|
+
* so the SQL path never touches the network.
|
|
113
|
+
*/
|
|
114
114
|
fetch?: typeof globalThis.fetch;
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
|
-
* One column descriptor in a SQL-API response's `meta` array: the column `name`
|
|
118
|
-
* and the AE storage `type` (`String`, `Float64`, `DateTime`, …).
|
|
119
|
-
*/
|
|
117
|
+
* One column descriptor in a SQL-API response's `meta` array: the column `name`
|
|
118
|
+
* and the AE storage `type` (`String`, `Float64`, `DateTime`, …).
|
|
119
|
+
*/
|
|
120
120
|
interface AnalyticsSqlColumnMeta {
|
|
121
121
|
name: string;
|
|
122
122
|
type: string;
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
|
-
* Parsed SQL-API result. AE returns `{ meta, data, rows, rows_before_limit_at_least }`;
|
|
126
|
-
* we surface `columns` (from `meta`), the `rows` array of column→value records,
|
|
127
|
-
* and the total `rowCount`.
|
|
128
|
-
*/
|
|
125
|
+
* Parsed SQL-API result. AE returns `{ meta, data, rows, rows_before_limit_at_least }`;
|
|
126
|
+
* we surface `columns` (from `meta`), the `rows` array of column→value records,
|
|
127
|
+
* and the total `rowCount`.
|
|
128
|
+
*/
|
|
129
129
|
interface AnalyticsSqlResult {
|
|
130
130
|
columns: AnalyticsSqlColumnMeta[];
|
|
131
131
|
rowCount: number;
|
|
@@ -140,9 +140,9 @@ interface AnalyticsSqlClient {
|
|
|
140
140
|
query: (sql: string) => Promise<AnalyticsSqlResult>;
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
|
-
* Build an {@link AnalyticsSqlClient}. Each `query` POSTs the raw SQL text to
|
|
144
|
-
* the account's `analytics_engine/sql` endpoint with the bearer token, then
|
|
145
|
-
* normalises AE's `{ meta, data, rows }` body into {@link AnalyticsSqlResult}.
|
|
146
|
-
*/
|
|
143
|
+
* Build an {@link AnalyticsSqlClient}. Each `query` POSTs the raw SQL text to
|
|
144
|
+
* the account's `analytics_engine/sql` endpoint with the bearer token, then
|
|
145
|
+
* normalises AE's `{ meta, data, rows }` body into {@link AnalyticsSqlResult}.
|
|
146
|
+
*/
|
|
147
147
|
declare const createAnalyticsSqlClient: (config: AnalyticsSqlConfig) => AnalyticsSqlClient;
|
|
148
148
|
export { type AnalyticsClient, type AnalyticsEngineDataPoint, type AnalyticsEngineDatasetLike, type AnalyticsSqlClient, type AnalyticsSqlColumnMeta, type AnalyticsSqlConfig, AnalyticsSqlError, type AnalyticsSqlResult, type TrackColumn, type TrackEvent, type TrackSchema, createAnalytics, createAnalyticsSqlClient };
|