@lunora/bindings 1.0.0-alpha.3 → 1.0.0-alpha.31
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/LICENSE.md +6 -0
- package/dist/analytics/index.d.mts +66 -87
- package/dist/analytics/index.d.ts +66 -87
- package/dist/analytics/index.mjs +1 -2
- package/dist/images/index.d.mts +148 -148
- package/dist/images/index.d.ts +148 -148
- package/dist/images/index.mjs +1 -3
- package/dist/kv/index.d.mts +74 -151
- package/dist/kv/index.d.ts +74 -151
- package/dist/kv/index.mjs +1 -2
- package/dist/packem_shared/AnalyticsSqlError-cZQ6kiae.mjs +1 -0
- package/dist/packem_shared/R2SqlError-Ba9yHVqU.mjs +1 -0
- package/dist/packem_shared/SelectBuilder-C3dn71re.mjs +1 -0
- package/dist/packem_shared/SetOperation-DwBivS9U.mjs +1 -0
- package/dist/packem_shared/Sql-CJr-IlfQ.mjs +1 -0
- package/dist/packem_shared/WindowExpression-D2wkQ8zz.mjs +1 -0
- package/dist/packem_shared/WindowFunction-BAPoVyhc.mjs +1 -0
- package/dist/packem_shared/asc-DQLvku7R.mjs +1 -0
- package/dist/packem_shared/buildImageDeliveryUrl-Brqs-dcZ.mjs +1 -0
- package/dist/packem_shared/buildSignedImageUrl-fucJNAbd.mjs +4 -0
- package/dist/packem_shared/concurrent-vRmSvRpF.mjs +1 -0
- package/dist/packem_shared/createAnalytics-BXTNc57d.mjs +1 -0
- package/dist/packem_shared/createContextVectors-Bk6ZVCqQ.mjs +6 -0
- package/dist/packem_shared/createImages-CHgMZP4g.mjs +1 -0
- package/dist/packem_shared/createKv-B0RfMMal.mjs +1 -0
- package/dist/packem_shared/createKvIntrospector-DT1k8mCG.mjs +1 -0
- package/dist/packem_shared/createPipelines-CIvqrc7E.mjs +1 -0
- package/dist/packem_shared/createVectorAdminIntrospector-DrsigTJs.mjs +1 -0
- package/dist/packem_shared/createVectors-DirhBYpw.mjs +1 -0
- package/dist/pipelines/index.d.mts +24 -24
- package/dist/pipelines/index.d.ts +24 -24
- package/dist/pipelines/index.mjs +1 -1
- package/dist/r2sql/index.d.mts +140 -125
- package/dist/r2sql/index.d.ts +140 -125
- package/dist/r2sql/index.mjs +1 -7
- package/dist/vectors/index.d.mts +185 -134
- package/dist/vectors/index.d.ts +185 -134
- package/dist/vectors/index.mjs +1 -3
- package/package.json +5 -1
- package/dist/packem_shared/AnalyticsSqlError-CGTdsi4H.mjs +0 -42
- package/dist/packem_shared/R2SqlError-DlDd_SrE.mjs +0 -67
- package/dist/packem_shared/SelectBuilder-DHaXZwn_.mjs +0 -167
- package/dist/packem_shared/SetOperation-RDHcxccj.mjs +0 -80
- package/dist/packem_shared/Sql-DceGtcUd.mjs +0 -68
- package/dist/packem_shared/WindowExpression-Cg9s2xcr.mjs +0 -44
- package/dist/packem_shared/WindowFunction-DA3pGC3N.mjs +0 -82
- package/dist/packem_shared/asc-Cur-xO8v.mjs +0 -16
- package/dist/packem_shared/buildImageDeliveryUrl-D1sVfIOP.mjs +0 -30
- package/dist/packem_shared/buildSignedImageUrl-Otdgc_jO.mjs +0 -113
- package/dist/packem_shared/concurrent-Dj5sOibv.mjs +0 -23
- package/dist/packem_shared/createAnalytics-CEEI69o9.mjs +0 -57
- package/dist/packem_shared/createContextVectors-BSizpmu5.mjs +0 -140
- package/dist/packem_shared/createImages-CJrvqX0u.mjs +0 -80
- package/dist/packem_shared/createKv-DTiSt216.mjs +0 -141
- package/dist/packem_shared/createKvIntrospector-BThrJVhP.mjs +0 -75
- package/dist/packem_shared/createPipelines-CfyJ6VGu.mjs +0 -10
- package/dist/packem_shared/createVectorAdminIntrospector-BJUOM6VW.mjs +0 -51
- package/dist/packem_shared/createVectors-LSpGoKCd.mjs +0 -91
package/LICENSE.md
CHANGED
|
@@ -103,3 +103,9 @@ Unless required by applicable law or agreed to in writing, software distributed
|
|
|
103
103
|
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
104
|
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
105
|
specific language governing permissions and limitations under the License.
|
|
106
|
+
|
|
107
|
+
<!-- DEPENDENCIES -->
|
|
108
|
+
<!-- /DEPENDENCIES -->
|
|
109
|
+
|
|
110
|
+
<!-- TYPE_DEPENDENCIES -->
|
|
111
|
+
<!-- /TYPE_DEPENDENCIES -->
|
|
@@ -1,41 +1,21 @@
|
|
|
1
|
+
import { AnalyticsEngineDataPoint, AnalyticsEngineDatasetLike } from '@lunora/platform';
|
|
2
|
+
export type { AnalyticsEngineDataPoint, AnalyticsEngineDatasetLike } from '@lunora/platform';
|
|
3
|
+
import { LunoraError } from '@lunora/errors';
|
|
1
4
|
/**
|
|
2
|
-
* Structural types for the Analytics Engine write path.
|
|
3
|
-
*
|
|
4
|
-
* The real binding is workers-types' `AnalyticsEngineDataset`. We mirror it
|
|
5
|
-
* **structurally** (`AnalyticsEngineDatasetLike`) so plain-object test doubles
|
|
6
|
-
* satisfy the contract without pulling workerd into a unit test — the same
|
|
7
|
-
* approach `@lunora/d1` takes with `D1DatabaseLike`
|
|
8
|
-
* (`packages/d1/src/d1-client.ts`).
|
|
9
|
-
*/
|
|
5
|
+
* Structural types for the Analytics Engine write path.
|
|
6
|
+
*
|
|
7
|
+
* The real binding is workers-types' `AnalyticsEngineDataset`. We mirror it
|
|
8
|
+
* **structurally** (`AnalyticsEngineDatasetLike`) so plain-object test doubles
|
|
9
|
+
* satisfy the contract without pulling workerd into a unit test — the same
|
|
10
|
+
* approach `@lunora/d1` takes with `D1DatabaseLike`
|
|
11
|
+
* (`packages/d1/src/d1-client.ts`).
|
|
12
|
+
*/
|
|
10
13
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
interface AnalyticsEngineDataPoint {
|
|
18
|
-
/** String columns, mapped positionally to `blob1..blob20`. */
|
|
19
|
-
blobs?: (ArrayBuffer | null | string)[];
|
|
20
|
-
/** Numeric columns, mapped positionally to `double1..double20`. */
|
|
21
|
-
doubles?: number[];
|
|
22
|
-
/** Sampling key, exposed as `index1`. AE accepts at most one. */
|
|
23
|
-
indexes?: (ArrayBuffer | string)[];
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Minimal structural projection of workers-types' `AnalyticsEngineDataset`,
|
|
27
|
-
* kept loose enough for a plain-object fake in unit tests. `writeDataPoint` is
|
|
28
|
-
* fire-and-forget: it returns `void` and never throws on the hot path.
|
|
29
|
-
*/
|
|
30
|
-
interface AnalyticsEngineDatasetLike {
|
|
31
|
-
writeDataPoint: (event: AnalyticsEngineDataPoint) => void;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Named-field event handed to {@link AnalyticsClient.track}. Each field is
|
|
35
|
-
* mapped to a positional AE column and the mapping recorded in a returned
|
|
36
|
-
* {@link TrackSchema}, so the read side can reconstruct named columns from the
|
|
37
|
-
* SQL API's positional `blobN`/`doubleN`/`index1` output.
|
|
38
|
-
*/
|
|
14
|
+
* Named-field event handed to {@link AnalyticsClient.track}. Each field is
|
|
15
|
+
* mapped to a positional AE column and the mapping recorded in a returned
|
|
16
|
+
* {@link TrackSchema}, so the read side can reconstruct named columns from the
|
|
17
|
+
* SQL API's positional `blobN`/`doubleN`/`index1` output.
|
|
18
|
+
*/
|
|
39
19
|
interface TrackEvent {
|
|
40
20
|
/** String dimensions → `blobs` (`blob1..blob20`), in object key order. */
|
|
41
21
|
dimensions?: Record<string, string>;
|
|
@@ -52,11 +32,11 @@ interface TrackColumn {
|
|
|
52
32
|
field: string;
|
|
53
33
|
}
|
|
54
34
|
/**
|
|
55
|
-
* The field→column mapping {@link AnalyticsClient.track} records for one event
|
|
56
|
-
* shape, so the read side can project the SQL API's positional columns back to
|
|
57
|
-
* named fields. `name` is the logical event name; the column arrays are in the
|
|
58
|
-
* same order the dimensions/metrics were written.
|
|
59
|
-
*/
|
|
35
|
+
* The field→column mapping {@link AnalyticsClient.track} records for one event
|
|
36
|
+
* shape, so the read side can project the SQL API's positional columns back to
|
|
37
|
+
* named fields. `name` is the logical event name; the column arrays are in the
|
|
38
|
+
* same order the dimensions/metrics were written.
|
|
39
|
+
*/
|
|
60
40
|
interface TrackSchema {
|
|
61
41
|
dimensions: TrackColumn[];
|
|
62
42
|
index: TrackColumn | null;
|
|
@@ -64,41 +44,41 @@ interface TrackSchema {
|
|
|
64
44
|
name: string;
|
|
65
45
|
}
|
|
66
46
|
/**
|
|
67
|
-
* The write-side client bound to `ctx.analytics` (the generated context imports
|
|
68
|
-
* this exact type as `import("@lunora/bindings/analytics").AnalyticsClient`). Telemetry
|
|
69
|
-
* is fire-and-forget and sampled — never read a data point back in-handler.
|
|
70
|
-
*/
|
|
47
|
+
* The write-side client bound to `ctx.analytics` (the generated context imports
|
|
48
|
+
* this exact type as `import("@lunora/bindings/analytics").AnalyticsClient`). Telemetry
|
|
49
|
+
* is fire-and-forget and sampled — never read a data point back in-handler.
|
|
50
|
+
*/
|
|
71
51
|
interface AnalyticsClient {
|
|
72
52
|
/**
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
53
|
+
* Ergonomic named-field write: maps `{ dimensions, metrics, index }` to the
|
|
54
|
+
* positional layout, writes it, and returns the {@link TrackSchema} mapping
|
|
55
|
+
* (the logical `name` is recorded as the first blob, `blob1`).
|
|
56
|
+
*/
|
|
77
57
|
track: (name: string, event?: TrackEvent) => TrackSchema;
|
|
78
58
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
59
|
+
* Write a raw positional data point. Enforces AE's per-data-point count
|
|
60
|
+
* caps (≤20 blobs, ≤20 doubles, ≤1 index) and byte budget (combined blobs
|
|
61
|
+
* ≤16 KiB, index ≤96 bytes, measured as UTF-8); overflow throws so a misuse
|
|
62
|
+
* surfaces in dev rather than being silently rejected by the platform.
|
|
63
|
+
*/
|
|
84
64
|
writeDataPoint: (event: AnalyticsEngineDataPoint) => void;
|
|
85
65
|
}
|
|
86
66
|
/**
|
|
87
|
-
* Wrap an Analytics Engine dataset binding in the write-side
|
|
88
|
-
* {@link AnalyticsClient} bound to `ctx.analytics`.
|
|
89
|
-
*
|
|
90
|
-
* The binding is `env.ANALYTICS` (the self-describing
|
|
91
|
-
* `analytics_engine_datasets` binding the config layer reconciles). Writes are
|
|
92
|
-
* fire-and-forget and sampled — there is no return value to read in-handler.
|
|
93
|
-
*
|
|
94
|
-
* `writeDataPoint` enforces AE's per-data-point caps eagerly — both the count
|
|
95
|
-
* caps (≤20 blobs, ≤20 doubles, ≤1 index) and the byte budget (combined blobs
|
|
96
|
-
* ≤16 KiB, index ≤96 bytes, measured as UTF-8) — so a misuse throws in dev
|
|
97
|
-
* instead of being silently rejected by the platform at the edge. `track` is
|
|
98
|
-
* the ergonomic named-field path: it maps a
|
|
99
|
-
* `{ dimensions, metrics, index }` object to the positional layout and returns
|
|
100
|
-
* the field→column mapping the read side uses to reconstruct named columns.
|
|
101
|
-
*/
|
|
67
|
+
* Wrap an Analytics Engine dataset binding in the write-side
|
|
68
|
+
* {@link AnalyticsClient} bound to `ctx.analytics`.
|
|
69
|
+
*
|
|
70
|
+
* The binding is `env.ANALYTICS` (the self-describing
|
|
71
|
+
* `analytics_engine_datasets` binding the config layer reconciles). Writes are
|
|
72
|
+
* fire-and-forget and sampled — there is no return value to read in-handler.
|
|
73
|
+
*
|
|
74
|
+
* `writeDataPoint` enforces AE's per-data-point caps eagerly — both the count
|
|
75
|
+
* caps (≤20 blobs, ≤20 doubles, ≤1 index) and the byte budget (combined blobs
|
|
76
|
+
* ≤16 KiB, index ≤96 bytes, measured as UTF-8) — so a misuse throws in dev
|
|
77
|
+
* instead of being silently rejected by the platform at the edge. `track` is
|
|
78
|
+
* the ergonomic named-field path: it maps a
|
|
79
|
+
* `{ dimensions, metrics, index }` object to the positional layout and returns
|
|
80
|
+
* the field→column mapping the read side uses to reconstruct named columns.
|
|
81
|
+
*/
|
|
102
82
|
declare const createAnalytics: (binding: AnalyticsEngineDatasetLike) => AnalyticsClient;
|
|
103
83
|
/** Configuration for an {@link AnalyticsSqlClient}. */
|
|
104
84
|
interface AnalyticsSqlConfig {
|
|
@@ -107,32 +87,31 @@ interface AnalyticsSqlConfig {
|
|
|
107
87
|
/** API token with Analytics Engine read scope. A secret — never a binding. */
|
|
108
88
|
apiToken: string;
|
|
109
89
|
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
90
|
+
* `fetch` implementation. Defaults to the global `fetch`; injected in tests
|
|
91
|
+
* so the SQL path never touches the network.
|
|
92
|
+
*/
|
|
113
93
|
fetch?: typeof globalThis.fetch;
|
|
114
94
|
}
|
|
115
95
|
/**
|
|
116
|
-
* One column descriptor in a SQL-API response's `meta` array: the column `name`
|
|
117
|
-
* and the AE storage `type` (`String`, `Float64`, `DateTime`, …).
|
|
118
|
-
*/
|
|
96
|
+
* One column descriptor in a SQL-API response's `meta` array: the column `name`
|
|
97
|
+
* and the AE storage `type` (`String`, `Float64`, `DateTime`, …).
|
|
98
|
+
*/
|
|
119
99
|
interface AnalyticsSqlColumnMeta {
|
|
120
100
|
name: string;
|
|
121
101
|
type: string;
|
|
122
102
|
}
|
|
123
103
|
/**
|
|
124
|
-
* Parsed SQL-API result. AE returns `{ meta, data, rows, rows_before_limit_at_least }`;
|
|
125
|
-
* we surface `columns` (from `meta`), the `rows` array of column→value records,
|
|
126
|
-
* and the total `rowCount`.
|
|
127
|
-
*/
|
|
104
|
+
* Parsed SQL-API result. AE returns `{ meta, data, rows, rows_before_limit_at_least }`;
|
|
105
|
+
* we surface `columns` (from `meta`), the `rows` array of column→value records,
|
|
106
|
+
* and the total `rowCount`.
|
|
107
|
+
*/
|
|
128
108
|
interface AnalyticsSqlResult {
|
|
129
109
|
columns: AnalyticsSqlColumnMeta[];
|
|
130
110
|
rowCount: number;
|
|
131
111
|
rows: Record<string, unknown>[];
|
|
132
112
|
}
|
|
133
|
-
/** Thrown when the SQL API responds with a non-2xx status;
|
|
134
|
-
declare class AnalyticsSqlError extends
|
|
135
|
-
readonly status: number;
|
|
113
|
+
/** Thrown when the SQL API responds with a non-2xx status; a `LunoraError` subclass carrying the HTTP `status` + body for the caller to surface. */
|
|
114
|
+
declare class AnalyticsSqlError extends LunoraError {
|
|
136
115
|
constructor(status: number, body: string);
|
|
137
116
|
}
|
|
138
117
|
/** The read client: a single `query(sql)` over the AE SQL API. */
|
|
@@ -140,9 +119,9 @@ interface AnalyticsSqlClient {
|
|
|
140
119
|
query: (sql: string) => Promise<AnalyticsSqlResult>;
|
|
141
120
|
}
|
|
142
121
|
/**
|
|
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
|
-
*/
|
|
122
|
+
* Build an {@link AnalyticsSqlClient}. Each `query` POSTs the raw SQL text to
|
|
123
|
+
* the account's `analytics_engine/sql` endpoint with the bearer token, then
|
|
124
|
+
* normalises AE's `{ meta, data, rows }` body into {@link AnalyticsSqlResult}.
|
|
125
|
+
*/
|
|
147
126
|
declare const createAnalyticsSqlClient: (config: AnalyticsSqlConfig) => AnalyticsSqlClient;
|
|
148
|
-
export { type AnalyticsClient, type
|
|
127
|
+
export { type AnalyticsClient, type AnalyticsSqlClient, type AnalyticsSqlColumnMeta, type AnalyticsSqlConfig, AnalyticsSqlError, type AnalyticsSqlResult, type TrackColumn, type TrackEvent, type TrackSchema, createAnalytics, createAnalyticsSqlClient };
|
|
@@ -1,41 +1,21 @@
|
|
|
1
|
+
import { AnalyticsEngineDataPoint, AnalyticsEngineDatasetLike } from '@lunora/platform';
|
|
2
|
+
export type { AnalyticsEngineDataPoint, AnalyticsEngineDatasetLike } from '@lunora/platform';
|
|
3
|
+
import { LunoraError } from '@lunora/errors';
|
|
1
4
|
/**
|
|
2
|
-
* Structural types for the Analytics Engine write path.
|
|
3
|
-
*
|
|
4
|
-
* The real binding is workers-types' `AnalyticsEngineDataset`. We mirror it
|
|
5
|
-
* **structurally** (`AnalyticsEngineDatasetLike`) so plain-object test doubles
|
|
6
|
-
* satisfy the contract without pulling workerd into a unit test — the same
|
|
7
|
-
* approach `@lunora/d1` takes with `D1DatabaseLike`
|
|
8
|
-
* (`packages/d1/src/d1-client.ts`).
|
|
9
|
-
*/
|
|
5
|
+
* Structural types for the Analytics Engine write path.
|
|
6
|
+
*
|
|
7
|
+
* The real binding is workers-types' `AnalyticsEngineDataset`. We mirror it
|
|
8
|
+
* **structurally** (`AnalyticsEngineDatasetLike`) so plain-object test doubles
|
|
9
|
+
* satisfy the contract without pulling workerd into a unit test — the same
|
|
10
|
+
* approach `@lunora/d1` takes with `D1DatabaseLike`
|
|
11
|
+
* (`packages/d1/src/d1-client.ts`).
|
|
12
|
+
*/
|
|
10
13
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
interface AnalyticsEngineDataPoint {
|
|
18
|
-
/** String columns, mapped positionally to `blob1..blob20`. */
|
|
19
|
-
blobs?: (ArrayBuffer | null | string)[];
|
|
20
|
-
/** Numeric columns, mapped positionally to `double1..double20`. */
|
|
21
|
-
doubles?: number[];
|
|
22
|
-
/** Sampling key, exposed as `index1`. AE accepts at most one. */
|
|
23
|
-
indexes?: (ArrayBuffer | string)[];
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Minimal structural projection of workers-types' `AnalyticsEngineDataset`,
|
|
27
|
-
* kept loose enough for a plain-object fake in unit tests. `writeDataPoint` is
|
|
28
|
-
* fire-and-forget: it returns `void` and never throws on the hot path.
|
|
29
|
-
*/
|
|
30
|
-
interface AnalyticsEngineDatasetLike {
|
|
31
|
-
writeDataPoint: (event: AnalyticsEngineDataPoint) => void;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Named-field event handed to {@link AnalyticsClient.track}. Each field is
|
|
35
|
-
* mapped to a positional AE column and the mapping recorded in a returned
|
|
36
|
-
* {@link TrackSchema}, so the read side can reconstruct named columns from the
|
|
37
|
-
* SQL API's positional `blobN`/`doubleN`/`index1` output.
|
|
38
|
-
*/
|
|
14
|
+
* Named-field event handed to {@link AnalyticsClient.track}. Each field is
|
|
15
|
+
* mapped to a positional AE column and the mapping recorded in a returned
|
|
16
|
+
* {@link TrackSchema}, so the read side can reconstruct named columns from the
|
|
17
|
+
* SQL API's positional `blobN`/`doubleN`/`index1` output.
|
|
18
|
+
*/
|
|
39
19
|
interface TrackEvent {
|
|
40
20
|
/** String dimensions → `blobs` (`blob1..blob20`), in object key order. */
|
|
41
21
|
dimensions?: Record<string, string>;
|
|
@@ -52,11 +32,11 @@ interface TrackColumn {
|
|
|
52
32
|
field: string;
|
|
53
33
|
}
|
|
54
34
|
/**
|
|
55
|
-
* The field→column mapping {@link AnalyticsClient.track} records for one event
|
|
56
|
-
* shape, so the read side can project the SQL API's positional columns back to
|
|
57
|
-
* named fields. `name` is the logical event name; the column arrays are in the
|
|
58
|
-
* same order the dimensions/metrics were written.
|
|
59
|
-
*/
|
|
35
|
+
* The field→column mapping {@link AnalyticsClient.track} records for one event
|
|
36
|
+
* shape, so the read side can project the SQL API's positional columns back to
|
|
37
|
+
* named fields. `name` is the logical event name; the column arrays are in the
|
|
38
|
+
* same order the dimensions/metrics were written.
|
|
39
|
+
*/
|
|
60
40
|
interface TrackSchema {
|
|
61
41
|
dimensions: TrackColumn[];
|
|
62
42
|
index: TrackColumn | null;
|
|
@@ -64,41 +44,41 @@ interface TrackSchema {
|
|
|
64
44
|
name: string;
|
|
65
45
|
}
|
|
66
46
|
/**
|
|
67
|
-
* The write-side client bound to `ctx.analytics` (the generated context imports
|
|
68
|
-
* this exact type as `import("@lunora/bindings/analytics").AnalyticsClient`). Telemetry
|
|
69
|
-
* is fire-and-forget and sampled — never read a data point back in-handler.
|
|
70
|
-
*/
|
|
47
|
+
* The write-side client bound to `ctx.analytics` (the generated context imports
|
|
48
|
+
* this exact type as `import("@lunora/bindings/analytics").AnalyticsClient`). Telemetry
|
|
49
|
+
* is fire-and-forget and sampled — never read a data point back in-handler.
|
|
50
|
+
*/
|
|
71
51
|
interface AnalyticsClient {
|
|
72
52
|
/**
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
53
|
+
* Ergonomic named-field write: maps `{ dimensions, metrics, index }` to the
|
|
54
|
+
* positional layout, writes it, and returns the {@link TrackSchema} mapping
|
|
55
|
+
* (the logical `name` is recorded as the first blob, `blob1`).
|
|
56
|
+
*/
|
|
77
57
|
track: (name: string, event?: TrackEvent) => TrackSchema;
|
|
78
58
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
59
|
+
* Write a raw positional data point. Enforces AE's per-data-point count
|
|
60
|
+
* caps (≤20 blobs, ≤20 doubles, ≤1 index) and byte budget (combined blobs
|
|
61
|
+
* ≤16 KiB, index ≤96 bytes, measured as UTF-8); overflow throws so a misuse
|
|
62
|
+
* surfaces in dev rather than being silently rejected by the platform.
|
|
63
|
+
*/
|
|
84
64
|
writeDataPoint: (event: AnalyticsEngineDataPoint) => void;
|
|
85
65
|
}
|
|
86
66
|
/**
|
|
87
|
-
* Wrap an Analytics Engine dataset binding in the write-side
|
|
88
|
-
* {@link AnalyticsClient} bound to `ctx.analytics`.
|
|
89
|
-
*
|
|
90
|
-
* The binding is `env.ANALYTICS` (the self-describing
|
|
91
|
-
* `analytics_engine_datasets` binding the config layer reconciles). Writes are
|
|
92
|
-
* fire-and-forget and sampled — there is no return value to read in-handler.
|
|
93
|
-
*
|
|
94
|
-
* `writeDataPoint` enforces AE's per-data-point caps eagerly — both the count
|
|
95
|
-
* caps (≤20 blobs, ≤20 doubles, ≤1 index) and the byte budget (combined blobs
|
|
96
|
-
* ≤16 KiB, index ≤96 bytes, measured as UTF-8) — so a misuse throws in dev
|
|
97
|
-
* instead of being silently rejected by the platform at the edge. `track` is
|
|
98
|
-
* the ergonomic named-field path: it maps a
|
|
99
|
-
* `{ dimensions, metrics, index }` object to the positional layout and returns
|
|
100
|
-
* the field→column mapping the read side uses to reconstruct named columns.
|
|
101
|
-
*/
|
|
67
|
+
* Wrap an Analytics Engine dataset binding in the write-side
|
|
68
|
+
* {@link AnalyticsClient} bound to `ctx.analytics`.
|
|
69
|
+
*
|
|
70
|
+
* The binding is `env.ANALYTICS` (the self-describing
|
|
71
|
+
* `analytics_engine_datasets` binding the config layer reconciles). Writes are
|
|
72
|
+
* fire-and-forget and sampled — there is no return value to read in-handler.
|
|
73
|
+
*
|
|
74
|
+
* `writeDataPoint` enforces AE's per-data-point caps eagerly — both the count
|
|
75
|
+
* caps (≤20 blobs, ≤20 doubles, ≤1 index) and the byte budget (combined blobs
|
|
76
|
+
* ≤16 KiB, index ≤96 bytes, measured as UTF-8) — so a misuse throws in dev
|
|
77
|
+
* instead of being silently rejected by the platform at the edge. `track` is
|
|
78
|
+
* the ergonomic named-field path: it maps a
|
|
79
|
+
* `{ dimensions, metrics, index }` object to the positional layout and returns
|
|
80
|
+
* the field→column mapping the read side uses to reconstruct named columns.
|
|
81
|
+
*/
|
|
102
82
|
declare const createAnalytics: (binding: AnalyticsEngineDatasetLike) => AnalyticsClient;
|
|
103
83
|
/** Configuration for an {@link AnalyticsSqlClient}. */
|
|
104
84
|
interface AnalyticsSqlConfig {
|
|
@@ -107,32 +87,31 @@ interface AnalyticsSqlConfig {
|
|
|
107
87
|
/** API token with Analytics Engine read scope. A secret — never a binding. */
|
|
108
88
|
apiToken: string;
|
|
109
89
|
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
90
|
+
* `fetch` implementation. Defaults to the global `fetch`; injected in tests
|
|
91
|
+
* so the SQL path never touches the network.
|
|
92
|
+
*/
|
|
113
93
|
fetch?: typeof globalThis.fetch;
|
|
114
94
|
}
|
|
115
95
|
/**
|
|
116
|
-
* One column descriptor in a SQL-API response's `meta` array: the column `name`
|
|
117
|
-
* and the AE storage `type` (`String`, `Float64`, `DateTime`, …).
|
|
118
|
-
*/
|
|
96
|
+
* One column descriptor in a SQL-API response's `meta` array: the column `name`
|
|
97
|
+
* and the AE storage `type` (`String`, `Float64`, `DateTime`, …).
|
|
98
|
+
*/
|
|
119
99
|
interface AnalyticsSqlColumnMeta {
|
|
120
100
|
name: string;
|
|
121
101
|
type: string;
|
|
122
102
|
}
|
|
123
103
|
/**
|
|
124
|
-
* Parsed SQL-API result. AE returns `{ meta, data, rows, rows_before_limit_at_least }`;
|
|
125
|
-
* we surface `columns` (from `meta`), the `rows` array of column→value records,
|
|
126
|
-
* and the total `rowCount`.
|
|
127
|
-
*/
|
|
104
|
+
* Parsed SQL-API result. AE returns `{ meta, data, rows, rows_before_limit_at_least }`;
|
|
105
|
+
* we surface `columns` (from `meta`), the `rows` array of column→value records,
|
|
106
|
+
* and the total `rowCount`.
|
|
107
|
+
*/
|
|
128
108
|
interface AnalyticsSqlResult {
|
|
129
109
|
columns: AnalyticsSqlColumnMeta[];
|
|
130
110
|
rowCount: number;
|
|
131
111
|
rows: Record<string, unknown>[];
|
|
132
112
|
}
|
|
133
|
-
/** Thrown when the SQL API responds with a non-2xx status;
|
|
134
|
-
declare class AnalyticsSqlError extends
|
|
135
|
-
readonly status: number;
|
|
113
|
+
/** Thrown when the SQL API responds with a non-2xx status; a `LunoraError` subclass carrying the HTTP `status` + body for the caller to surface. */
|
|
114
|
+
declare class AnalyticsSqlError extends LunoraError {
|
|
136
115
|
constructor(status: number, body: string);
|
|
137
116
|
}
|
|
138
117
|
/** The read client: a single `query(sql)` over the AE SQL API. */
|
|
@@ -140,9 +119,9 @@ interface AnalyticsSqlClient {
|
|
|
140
119
|
query: (sql: string) => Promise<AnalyticsSqlResult>;
|
|
141
120
|
}
|
|
142
121
|
/**
|
|
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
|
-
*/
|
|
122
|
+
* Build an {@link AnalyticsSqlClient}. Each `query` POSTs the raw SQL text to
|
|
123
|
+
* the account's `analytics_engine/sql` endpoint with the bearer token, then
|
|
124
|
+
* normalises AE's `{ meta, data, rows }` body into {@link AnalyticsSqlResult}.
|
|
125
|
+
*/
|
|
147
126
|
declare const createAnalyticsSqlClient: (config: AnalyticsSqlConfig) => AnalyticsSqlClient;
|
|
148
|
-
export { type AnalyticsClient, type
|
|
127
|
+
export { type AnalyticsClient, type AnalyticsSqlClient, type AnalyticsSqlColumnMeta, type AnalyticsSqlConfig, AnalyticsSqlError, type AnalyticsSqlResult, type TrackColumn, type TrackEvent, type TrackSchema, createAnalytics, createAnalyticsSqlClient };
|
package/dist/analytics/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { AnalyticsSqlError, createAnalyticsSqlClient } from '../packem_shared/AnalyticsSqlError-CGTdsi4H.mjs';
|
|
1
|
+
import{createAnalytics as e}from"../packem_shared/createAnalytics-BXTNc57d.mjs";import{AnalyticsSqlError as a,createAnalyticsSqlClient as c}from"../packem_shared/AnalyticsSqlError-cZQ6kiae.mjs";export{a as AnalyticsSqlError,e as createAnalytics,c as createAnalyticsSqlClient};
|