@lunora/bindings 1.0.0-alpha.2 → 1.0.0-alpha.21

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.
Files changed (57) hide show
  1. package/LICENSE.md +6 -0
  2. package/dist/analytics/index.d.mts +66 -87
  3. package/dist/analytics/index.d.ts +66 -87
  4. package/dist/analytics/index.mjs +1 -2
  5. package/dist/images/index.d.mts +148 -148
  6. package/dist/images/index.d.ts +148 -148
  7. package/dist/images/index.mjs +1 -3
  8. package/dist/kv/index.d.mts +130 -113
  9. package/dist/kv/index.d.ts +130 -113
  10. package/dist/kv/index.mjs +1 -1
  11. package/dist/packem_shared/AnalyticsSqlError-B-JcsUhX.mjs +1 -0
  12. package/dist/packem_shared/R2SqlError-Uaz0RJTR.mjs +1 -0
  13. package/dist/packem_shared/SelectBuilder-WMBQ2b4q.mjs +1 -0
  14. package/dist/packem_shared/SetOperation-BrzMB1Tb.mjs +1 -0
  15. package/dist/packem_shared/Sql-CwhZl1Q5.mjs +1 -0
  16. package/dist/packem_shared/WindowExpression-CxCuEy8V.mjs +1 -0
  17. package/dist/packem_shared/WindowFunction-rzl4CzYE.mjs +1 -0
  18. package/dist/packem_shared/asc-BsbdtIQU.mjs +1 -0
  19. package/dist/packem_shared/buildImageDeliveryUrl-CMUkVJfB.mjs +1 -0
  20. package/dist/packem_shared/buildSignedImageUrl-BzgCHIu6.mjs +4 -0
  21. package/dist/packem_shared/concurrent-DMFQCILU.mjs +1 -0
  22. package/dist/packem_shared/createAnalytics-HRPCzT1M.mjs +1 -0
  23. package/dist/packem_shared/createContextVectors-D-ae1wWO.mjs +6 -0
  24. package/dist/packem_shared/createImages-TW6ircG2.mjs +1 -0
  25. package/dist/packem_shared/createKv-CKeFDFuG.mjs +1 -0
  26. package/dist/packem_shared/createKvIntrospector-Bz0nqUjD.mjs +1 -0
  27. package/dist/packem_shared/createPipelines-n0Bf_p8Y.mjs +1 -0
  28. package/dist/packem_shared/createVectorAdminIntrospector-B9Yt09yj.mjs +1 -0
  29. package/dist/packem_shared/createVectors-jb8fAY6R.mjs +1 -0
  30. package/dist/pipelines/index.d.mts +24 -24
  31. package/dist/pipelines/index.d.ts +24 -24
  32. package/dist/pipelines/index.mjs +1 -1
  33. package/dist/r2sql/index.d.mts +124 -124
  34. package/dist/r2sql/index.d.ts +124 -124
  35. package/dist/r2sql/index.mjs +1 -7
  36. package/dist/vectors/index.d.mts +185 -134
  37. package/dist/vectors/index.d.ts +185 -134
  38. package/dist/vectors/index.mjs +1 -3
  39. package/package.json +5 -1
  40. package/dist/packem_shared/AnalyticsSqlError-CGTdsi4H.mjs +0 -42
  41. package/dist/packem_shared/R2SqlError-DlDd_SrE.mjs +0 -67
  42. package/dist/packem_shared/SelectBuilder-DHaXZwn_.mjs +0 -167
  43. package/dist/packem_shared/SetOperation-RDHcxccj.mjs +0 -80
  44. package/dist/packem_shared/Sql-DceGtcUd.mjs +0 -68
  45. package/dist/packem_shared/WindowExpression-Cg9s2xcr.mjs +0 -44
  46. package/dist/packem_shared/WindowFunction-DA3pGC3N.mjs +0 -82
  47. package/dist/packem_shared/asc-Cur-xO8v.mjs +0 -16
  48. package/dist/packem_shared/buildImageDeliveryUrl-D1sVfIOP.mjs +0 -30
  49. package/dist/packem_shared/buildSignedImageUrl-Otdgc_jO.mjs +0 -113
  50. package/dist/packem_shared/concurrent-Dj5sOibv.mjs +0 -23
  51. package/dist/packem_shared/createAnalytics-CEEI69o9.mjs +0 -57
  52. package/dist/packem_shared/createContextVectors-BSizpmu5.mjs +0 -140
  53. package/dist/packem_shared/createImages-CJrvqX0u.mjs +0 -80
  54. package/dist/packem_shared/createKv-DTiSt216.mjs +0 -141
  55. package/dist/packem_shared/createPipelines-CfyJ6VGu.mjs +0 -10
  56. package/dist/packem_shared/createVectorAdminIntrospector-BJUOM6VW.mjs +0 -51
  57. 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
- * One Analytics Engine data point, mirroring the positional shape
12
- * `writeDataPoint` accepts. AE stores up to 20 string `blobs`, up to 20 numeric
13
- * `doubles`, and exactly **one** `index` (the high-cardinality sampling key) per
14
- * data point — the SQL API later exposes them as `blob1..blob20`,
15
- * `double1..double20`, and `index1`.
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
- * Ergonomic named-field write: maps `{ dimensions, metrics, index }` to the
74
- * positional layout, writes it, and returns the {@link TrackSchema} mapping
75
- * (the logical `name` is recorded as the first blob, `blob1`).
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
- * Write a raw positional data point. Enforces AE's per-data-point count
80
- * caps (≤20 blobs, ≤20 doubles, ≤1 index) and byte budget (combined blobs
81
- * ≤16 KiB, index ≤96 bytes, measured as UTF-8); overflow throws so a misuse
82
- * surfaces in dev rather than being silently rejected by the platform.
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
- * `fetch` implementation. Defaults to the global `fetch`; injected in tests
111
- * so the SQL path never touches the network.
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; carries the status + body for the caller to surface. */
134
- declare class AnalyticsSqlError extends Error {
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 AnalyticsEngineDataPoint, type AnalyticsEngineDatasetLike, type AnalyticsSqlClient, type AnalyticsSqlColumnMeta, type AnalyticsSqlConfig, AnalyticsSqlError, type AnalyticsSqlResult, type TrackColumn, type TrackEvent, type TrackSchema, createAnalytics, createAnalyticsSqlClient };
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
- * One Analytics Engine data point, mirroring the positional shape
12
- * `writeDataPoint` accepts. AE stores up to 20 string `blobs`, up to 20 numeric
13
- * `doubles`, and exactly **one** `index` (the high-cardinality sampling key) per
14
- * data point — the SQL API later exposes them as `blob1..blob20`,
15
- * `double1..double20`, and `index1`.
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
- * Ergonomic named-field write: maps `{ dimensions, metrics, index }` to the
74
- * positional layout, writes it, and returns the {@link TrackSchema} mapping
75
- * (the logical `name` is recorded as the first blob, `blob1`).
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
- * Write a raw positional data point. Enforces AE's per-data-point count
80
- * caps (≤20 blobs, ≤20 doubles, ≤1 index) and byte budget (combined blobs
81
- * ≤16 KiB, index ≤96 bytes, measured as UTF-8); overflow throws so a misuse
82
- * surfaces in dev rather than being silently rejected by the platform.
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
- * `fetch` implementation. Defaults to the global `fetch`; injected in tests
111
- * so the SQL path never touches the network.
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; carries the status + body for the caller to surface. */
134
- declare class AnalyticsSqlError extends Error {
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 AnalyticsEngineDataPoint, type AnalyticsEngineDatasetLike, type AnalyticsSqlClient, type AnalyticsSqlColumnMeta, type AnalyticsSqlConfig, AnalyticsSqlError, type AnalyticsSqlResult, type TrackColumn, type TrackEvent, type TrackSchema, createAnalytics, createAnalyticsSqlClient };
127
+ export { type AnalyticsClient, type AnalyticsSqlClient, type AnalyticsSqlColumnMeta, type AnalyticsSqlConfig, AnalyticsSqlError, type AnalyticsSqlResult, type TrackColumn, type TrackEvent, type TrackSchema, createAnalytics, createAnalyticsSqlClient };
@@ -1,2 +1 @@
1
- export { createAnalytics } from '../packem_shared/createAnalytics-CEEI69o9.mjs';
2
- export { AnalyticsSqlError, createAnalyticsSqlClient } from '../packem_shared/AnalyticsSqlError-CGTdsi4H.mjs';
1
+ import{createAnalytics as e}from"../packem_shared/createAnalytics-HRPCzT1M.mjs";import{AnalyticsSqlError as a,createAnalyticsSqlClient as c}from"../packem_shared/AnalyticsSqlError-B-JcsUhX.mjs";export{a as AnalyticsSqlError,e as createAnalytics,c as createAnalyticsSqlClient};