@reopt-ai/data-contract 0.6.3 → 0.7.0
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/client.cjs +228 -321
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +57 -71
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.ts +57 -71
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +228 -322
- package/dist/client.js.map +1 -1
- package/dist/control.cjs +158 -54
- package/dist/control.cjs.map +1 -1
- package/dist/control.d.cts +121 -137
- package/dist/control.d.cts.map +1 -0
- package/dist/control.d.ts +121 -137
- package/dist/control.d.ts.map +1 -0
- package/dist/control.js +134 -54
- package/dist/control.js.map +1 -1
- package/dist/events-BUIeU60t.d.cts +142 -0
- package/dist/events-BUIeU60t.d.cts.map +1 -0
- package/dist/events-BUIeU60t.d.ts +142 -0
- package/dist/events-BUIeU60t.d.ts.map +1 -0
- package/dist/events.cjs +110 -15
- package/dist/events.cjs.map +1 -1
- package/dist/events.d.cts +2 -59
- package/dist/events.d.ts +2 -59
- package/dist/events.js +101 -15
- package/dist/events.js.map +1 -1
- package/dist/identity.cjs +150 -55
- package/dist/identity.cjs.map +1 -1
- package/dist/identity.d.cts +21 -20
- package/dist/identity.d.cts.map +1 -0
- package/dist/identity.d.ts +21 -20
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +126 -56
- package/dist/identity.js.map +1 -1
- package/dist/index.cjs +46 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -54
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +37 -54
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -25
- package/dist/index.js.map +1 -1
- package/dist/ingest.cjs +152 -57
- package/dist/ingest.cjs.map +1 -1
- package/dist/ingest.d.cts +182 -193
- package/dist/ingest.d.cts.map +1 -0
- package/dist/ingest.d.ts +182 -193
- package/dist/ingest.d.ts.map +1 -0
- package/dist/ingest.js +126 -57
- package/dist/ingest.js.map +1 -1
- package/dist/query.cjs +284 -84
- package/dist/query.cjs.map +1 -1
- package/dist/query.d.cts +456 -469
- package/dist/query.d.cts.map +1 -0
- package/dist/query.d.ts +456 -469
- package/dist/query.d.ts.map +1 -0
- package/dist/query.js +245 -84
- package/dist/query.js.map +1 -1
- package/dist/report.cjs +104 -74
- package/dist/report.cjs.map +1 -1
- package/dist/report.d.cts +182 -136
- package/dist/report.d.cts.map +1 -0
- package/dist/report.d.ts +182 -136
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +93 -74
- package/dist/report.js.map +1 -1
- package/dist/version-B_0qb1_K.cjs +53 -0
- package/dist/version-B_0qb1_K.cjs.map +1 -0
- package/dist/version-C09Cyf4R.js +12 -0
- package/dist/version-C09Cyf4R.js.map +1 -0
- package/dist/{version-DJ2Grb_N.d.ts → version-CGujUGWd.d.cts} +5 -3
- package/dist/version-CGujUGWd.d.cts.map +1 -0
- package/dist/{version-DJ2Grb_N.d.cts → version-CGujUGWd.d.ts} +5 -3
- package/dist/version-CGujUGWd.d.ts.map +1 -0
- package/package.json +69 -28
- package/dist/chunk-3EEANNYN.cjs +0 -62
- package/dist/chunk-3EEANNYN.cjs.map +0 -1
- package/dist/chunk-7W33YGRO.js +0 -160
- package/dist/chunk-7W33YGRO.js.map +0 -1
- package/dist/chunk-F2RNXJGO.cjs +0 -19
- package/dist/chunk-F2RNXJGO.cjs.map +0 -1
- package/dist/chunk-FP2X3PRK.js +0 -62
- package/dist/chunk-FP2X3PRK.js.map +0 -1
- package/dist/chunk-JCEWUSUM.js +0 -53
- package/dist/chunk-JCEWUSUM.js.map +0 -1
- package/dist/chunk-L3JPDRVG.cjs +0 -160
- package/dist/chunk-L3JPDRVG.cjs.map +0 -1
- package/dist/chunk-L4KBQAOO.js +0 -204
- package/dist/chunk-L4KBQAOO.js.map +0 -1
- package/dist/chunk-NJ4JKNBX.js +0 -361
- package/dist/chunk-NJ4JKNBX.js.map +0 -1
- package/dist/chunk-ORNTN6AK.cjs +0 -53
- package/dist/chunk-ORNTN6AK.cjs.map +0 -1
- package/dist/chunk-PSUINLW7.js +0 -19
- package/dist/chunk-PSUINLW7.js.map +0 -1
- package/dist/chunk-RU26QFM2.js +0 -179
- package/dist/chunk-RU26QFM2.js.map +0 -1
- package/dist/chunk-XDH5QQYF.cjs +0 -361
- package/dist/chunk-XDH5QQYF.cjs.map +0 -1
- package/dist/chunk-YCTGHWTP.cjs +0 -204
- package/dist/chunk-YCTGHWTP.cjs.map +0 -1
- package/dist/chunk-ZI6A3WQP.cjs +0 -179
- package/dist/chunk-ZI6A3WQP.cjs.map +0 -1
package/dist/chunk-NJ4JKNBX.js
DELETED
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
zDate,
|
|
3
|
-
zInstant
|
|
4
|
-
} from "./chunk-JCEWUSUM.js";
|
|
5
|
-
|
|
6
|
-
// src/query.ts
|
|
7
|
-
import { z } from "zod";
|
|
8
|
-
var zGranularity = z.enum(["hour", "day", "week", "month"]);
|
|
9
|
-
var zTimezone = z.string().min(1).max(64).refine(isValidTimeZone, { message: "unknown IANA time zone" });
|
|
10
|
-
function isValidTimeZone(value) {
|
|
11
|
-
try {
|
|
12
|
-
new Intl.DateTimeFormat("en-US", { timeZone: value });
|
|
13
|
-
return true;
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
var zChannelFilter = z.object({
|
|
19
|
-
referrerTypes: z.array(z.string()).optional(),
|
|
20
|
-
channelTypes: z.array(z.string()).optional(),
|
|
21
|
-
utmSources: z.array(z.string()).optional(),
|
|
22
|
-
utmMediums: z.array(z.string()).optional(),
|
|
23
|
-
utmCampaigns: z.array(z.string()).optional()
|
|
24
|
-
}).optional();
|
|
25
|
-
var zQuerySource = z.enum(["rollup", "raw", "mixed"]);
|
|
26
|
-
var zQueryMeta = z.object({
|
|
27
|
-
projectId: z.string(),
|
|
28
|
-
/** When the underlying computation actually ran. On a cache hit, when the cached value was computed. */
|
|
29
|
-
computedAt: zInstant,
|
|
30
|
-
/** Age of the returned computation, in seconds. `0` on a cache miss. */
|
|
31
|
-
cacheAgeSeconds: z.number().int().nonnegative(),
|
|
32
|
-
/**
|
|
33
|
-
* How far behind live materialization was when the computation ran, in
|
|
34
|
-
* seconds. `0` means no live event is pending; `null` means measurement
|
|
35
|
-
* failed and must never be interpreted as fresh.
|
|
36
|
-
*
|
|
37
|
-
* Deliberately not `now - max(events.created_at)` — that conflates "the
|
|
38
|
-
* pipeline is behind" with "this project is quiet", and grows without bound
|
|
39
|
-
* on an idle project.
|
|
40
|
-
*/
|
|
41
|
-
ingestLagSeconds: z.number().int().nonnegative().nullable(),
|
|
42
|
-
/** Whether the freshness measurement itself succeeded. */
|
|
43
|
-
ingestLagStatus: z.enum(["known", "unknown"]),
|
|
44
|
-
/**
|
|
45
|
-
* Pending events older than the live replay window. Kept separate so an old
|
|
46
|
-
* permanently failing event neither pegs live lag nor disappears behind 0.
|
|
47
|
-
* `null` means the measurement failed.
|
|
48
|
-
*/
|
|
49
|
-
ingestDeadLetterCount: z.number().int().nonnegative().nullable(),
|
|
50
|
-
cached: z.boolean(),
|
|
51
|
-
/**
|
|
52
|
-
* The time zone actually used to place bucket and window boundaries — the
|
|
53
|
-
* resolved value, not the requested one. Read it rather than assuming the
|
|
54
|
-
* request was honoured: when no zone is given anywhere it is `"UTC"`, and
|
|
55
|
-
* that is exactly the case a consumer needs to notice.
|
|
56
|
-
*/
|
|
57
|
-
timezone: z.string(),
|
|
58
|
-
/**
|
|
59
|
-
* Where the numbers came from. `rollup`: pre-aggregated hourly tables;
|
|
60
|
-
* `raw`: a scan of the event/session tables; `mixed`: finished hours from
|
|
61
|
-
* the rollup, the hour still in progress from raw. Diagnostic — the values
|
|
62
|
-
* agree either way — but a consumer that expected `rollup` and sees `raw`
|
|
63
|
-
* has asked for a combination the rollups cannot serve.
|
|
64
|
-
*/
|
|
65
|
-
source: zQuerySource,
|
|
66
|
-
requestId: z.string()
|
|
67
|
-
});
|
|
68
|
-
function zQueryEnvelope(data) {
|
|
69
|
-
return z.object({ data, meta: zQueryMeta });
|
|
70
|
-
}
|
|
71
|
-
var zTimeseriesBreakdown = z.object({
|
|
72
|
-
kind: z.literal("property"),
|
|
73
|
-
key: z.string().min(1).max(200),
|
|
74
|
-
topN: z.number().int().min(1).max(100).default(5)
|
|
75
|
-
});
|
|
76
|
-
var zEventPropertyFilter = z.object({
|
|
77
|
-
key: z.string().min(1).max(200),
|
|
78
|
-
operator: z.literal("eq").default("eq"),
|
|
79
|
-
value: z.string().min(1).max(500)
|
|
80
|
-
});
|
|
81
|
-
var zEventsTimeseriesInput = z.object({
|
|
82
|
-
projectId: z.string().min(1),
|
|
83
|
-
startDate: zDate,
|
|
84
|
-
endDate: zDate,
|
|
85
|
-
granularity: zGranularity.default("day"),
|
|
86
|
-
/** Omit to count every event in the window. */
|
|
87
|
-
eventName: z.string().min(1).max(200).optional(),
|
|
88
|
-
/** Exact matches against top-level `properties` keys. Every item must match. */
|
|
89
|
-
propertyFilters: z.array(zEventPropertyFilter).max(10).optional(),
|
|
90
|
-
breakdown: zTimeseriesBreakdown.optional(),
|
|
91
|
-
/**
|
|
92
|
-
* Cannot be combined with `breakdown` — the backend's breakdown time series
|
|
93
|
-
* takes no segment. Sending both is refused with `unsupported_combination`
|
|
94
|
-
* rather than silently ignoring one of them.
|
|
95
|
-
*/
|
|
96
|
-
segmentId: z.string().min(1).optional(),
|
|
97
|
-
/** Omit to fall back to the project's configured zone, then to UTC. */
|
|
98
|
-
timezone: zTimezone.optional(),
|
|
99
|
-
/**
|
|
100
|
-
* Events whose catalogue status is `internal` (operational probes) are
|
|
101
|
-
* left out by default. A probe that needs to find its own event sets this.
|
|
102
|
-
*/
|
|
103
|
-
includeInternal: z.boolean().default(false)
|
|
104
|
-
}).refine((input) => input.startDate <= input.endDate, {
|
|
105
|
-
message: "endDate must be on or after startDate",
|
|
106
|
-
path: ["endDate"]
|
|
107
|
-
});
|
|
108
|
-
var zBucketStart = z.string().regex(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/, "expected 'YYYY-MM-DD HH:MM:SS'");
|
|
109
|
-
var zTimeseriesPoint = z.object({
|
|
110
|
-
date: zBucketStart,
|
|
111
|
-
count: z.number().int().nonnegative()
|
|
112
|
-
});
|
|
113
|
-
var zEventsTimeseriesData = z.object({
|
|
114
|
-
granularity: zGranularity,
|
|
115
|
-
/** Zone the buckets were cut in. Mirrors `meta.timezone`. */
|
|
116
|
-
timezone: z.string(),
|
|
117
|
-
/** Total per bucket. Always present, with or without a breakdown. */
|
|
118
|
-
series: z.array(zTimeseriesPoint),
|
|
119
|
-
/** Present only when `breakdown` was requested: the top-N values, each with its own series. */
|
|
120
|
-
breakdown: z.array(
|
|
121
|
-
z.object({
|
|
122
|
-
value: z.string(),
|
|
123
|
-
points: z.array(zTimeseriesPoint)
|
|
124
|
-
})
|
|
125
|
-
).optional()
|
|
126
|
-
});
|
|
127
|
-
var zEventsTimeseriesResponse = zQueryEnvelope(zEventsTimeseriesData);
|
|
128
|
-
var zFunnelInput = z.object({
|
|
129
|
-
projectId: z.string().min(1),
|
|
130
|
-
/** Ordered event names. A user counts at step k if they reached at least step k. */
|
|
131
|
-
steps: z.array(z.string().min(1).max(200)).min(2).max(10),
|
|
132
|
-
startDate: zDate,
|
|
133
|
-
endDate: zDate,
|
|
134
|
-
/** Max seconds between the first and last step for a conversion to count. Default 24h. */
|
|
135
|
-
windowSeconds: z.number().int().min(60).max(2592e3).default(86400),
|
|
136
|
-
segmentId: z.string().min(1).optional(),
|
|
137
|
-
channelFilter: zChannelFilter,
|
|
138
|
-
/**
|
|
139
|
-
* Decides where `startDate` / `endDate` fall. A funnel has no buckets, so
|
|
140
|
-
* this only moves the window — but a nine-hour window shift changes who is
|
|
141
|
-
* in the funnel.
|
|
142
|
-
*/
|
|
143
|
-
timezone: zTimezone.optional(),
|
|
144
|
-
/** Accepted for symmetry with events.timeseries; funnel steps are named explicitly, so nothing is filtered. */
|
|
145
|
-
includeInternal: z.boolean().default(false)
|
|
146
|
-
}).refine((input) => input.startDate <= input.endDate, {
|
|
147
|
-
message: "endDate must be on or after startDate",
|
|
148
|
-
path: ["endDate"]
|
|
149
|
-
});
|
|
150
|
-
var zFunnelStep = z.object({
|
|
151
|
-
step: z.number().int().min(1),
|
|
152
|
-
name: z.string(),
|
|
153
|
-
users: z.number().int().nonnegative(),
|
|
154
|
-
/** Percent of the previous step that reached this one. `100` for step 1. */
|
|
155
|
-
conversionRate: z.number(),
|
|
156
|
-
/** Percent of the previous step that did not. `0` for step 1. */
|
|
157
|
-
dropoffRate: z.number(),
|
|
158
|
-
dropoffUsers: z.number().int().nonnegative()
|
|
159
|
-
});
|
|
160
|
-
var zFunnelData = z.object({
|
|
161
|
-
steps: z.array(zFunnelStep),
|
|
162
|
-
totalUsers: z.number().int().nonnegative(),
|
|
163
|
-
/** Percent of step-1 users that reached the last step. */
|
|
164
|
-
overallConversionRate: z.number()
|
|
165
|
-
});
|
|
166
|
-
var zFunnelResponse = zQueryEnvelope(zFunnelData);
|
|
167
|
-
var zRetentionInterval = z.enum(["day", "week", "month"]);
|
|
168
|
-
var zRetentionInput = z.object({
|
|
169
|
-
projectId: z.string().min(1),
|
|
170
|
-
startDate: zDate,
|
|
171
|
-
endDate: zDate,
|
|
172
|
-
interval: zRetentionInterval.default("day"),
|
|
173
|
-
periods: z.number().int().min(1).max(30).default(7),
|
|
174
|
-
startEvent: z.string().min(1).max(200).optional(),
|
|
175
|
-
returnEvent: z.string().min(1).max(200).optional(),
|
|
176
|
-
/** `bounded`: returned in exactly period N. `unbounded`: returned in period N or later. */
|
|
177
|
-
retentionType: z.enum(["bounded", "unbounded"]).default("bounded"),
|
|
178
|
-
/**
|
|
179
|
-
* `first-ever` (default): the cohort is everyone whose true first activity
|
|
180
|
-
* landed in the window, read from the first-seen aggregate. `startEvent`,
|
|
181
|
-
* `segmentId` and `channelFilter` then constrain only the *returning* side.
|
|
182
|
-
* `first-in-window`: the cohort is selected by scanning events in the window
|
|
183
|
-
* with all filters applied. Slower, but filters apply to cohort selection.
|
|
184
|
-
*/
|
|
185
|
-
cohortMode: z.enum(["first-ever", "first-in-window"]).default("first-ever"),
|
|
186
|
-
segmentId: z.string().min(1).optional(),
|
|
187
|
-
channelFilter: zChannelFilter,
|
|
188
|
-
/**
|
|
189
|
-
* Decides where a cohort day starts, and so which period a return falls in.
|
|
190
|
-
*
|
|
191
|
-
* Honoured under both cohort modes. Note that a non-UTC zone makes
|
|
192
|
-
* `first-ever` read raw events instead of its daily rollup — the rollup is
|
|
193
|
-
* cut on UTC days and cannot be re-cut after the fact — so expect a slower
|
|
194
|
-
* query in exchange for cohorts that match the reader's calendar.
|
|
195
|
-
*/
|
|
196
|
-
timezone: zTimezone.optional(),
|
|
197
|
-
/** Accepted for symmetry with events.timeseries; retention reads named or all-event activity and does not yet apply the internal filter. */
|
|
198
|
-
includeInternal: z.boolean().default(false)
|
|
199
|
-
}).refine((input) => input.startDate <= input.endDate, {
|
|
200
|
-
message: "endDate must be on or after startDate",
|
|
201
|
-
path: ["endDate"]
|
|
202
|
-
});
|
|
203
|
-
var zRetentionCell = z.object({
|
|
204
|
-
/** `0` is the cohort's own period. */
|
|
205
|
-
period: z.number().int().nonnegative(),
|
|
206
|
-
users: z.number().int().nonnegative(),
|
|
207
|
-
/** Percent of `cohortSize`. */
|
|
208
|
-
rate: z.number()
|
|
209
|
-
});
|
|
210
|
-
var zRetentionData = z.object({
|
|
211
|
-
matrix: z.array(
|
|
212
|
-
z.object({
|
|
213
|
-
/** Cohort bucket start, same shape and zone as {@link zBucketStart}. */
|
|
214
|
-
cohortDate: zBucketStart,
|
|
215
|
-
cohortSize: z.number().int().nonnegative(),
|
|
216
|
-
/** Length is `periods + 1`, index-aligned to `period`. */
|
|
217
|
-
retention: z.array(zRetentionCell)
|
|
218
|
-
})
|
|
219
|
-
),
|
|
220
|
-
/** Unweighted mean rate per period across cohorts. */
|
|
221
|
-
averageRetention: z.array(z.object({ period: z.number().int().nonnegative(), rate: z.number() })),
|
|
222
|
-
interval: zRetentionInterval,
|
|
223
|
-
periods: z.number().int(),
|
|
224
|
-
retentionType: z.enum(["bounded", "unbounded"]),
|
|
225
|
-
/** Zone the cohort days were cut in. Mirrors `meta.timezone`. */
|
|
226
|
-
timezone: z.string()
|
|
227
|
-
});
|
|
228
|
-
var zRetentionResponse = zQueryEnvelope(zRetentionData);
|
|
229
|
-
var zTrafficOverviewInput = z.object({
|
|
230
|
-
projectId: z.string().min(1),
|
|
231
|
-
startDate: zDate,
|
|
232
|
-
endDate: zDate,
|
|
233
|
-
granularity: zGranularity.default("day"),
|
|
234
|
-
timezone: zTimezone.optional()
|
|
235
|
-
}).refine((input) => input.startDate <= input.endDate, {
|
|
236
|
-
message: "endDate must be on or after startDate",
|
|
237
|
-
path: ["endDate"]
|
|
238
|
-
});
|
|
239
|
-
var zTrafficTotals = z.object({
|
|
240
|
-
sessions: z.number().int().nonnegative(),
|
|
241
|
-
pageviews: z.number().int().nonnegative(),
|
|
242
|
-
newVisitors: z.number().int().nonnegative(),
|
|
243
|
-
returningVisitors: z.number().int().nonnegative(),
|
|
244
|
-
/** Percent of sessions that bounced, two decimals. */
|
|
245
|
-
bounceRate: z.number()
|
|
246
|
-
});
|
|
247
|
-
var zTrafficSeriesPoint = zTrafficTotals.extend({ date: zBucketStart });
|
|
248
|
-
var zTrafficOverviewData = z.object({
|
|
249
|
-
granularity: zGranularity,
|
|
250
|
-
timezone: z.string(),
|
|
251
|
-
totals: zTrafficTotals,
|
|
252
|
-
series: z.array(zTrafficSeriesPoint)
|
|
253
|
-
});
|
|
254
|
-
var zTrafficOverviewResponse = zQueryEnvelope(zTrafficOverviewData);
|
|
255
|
-
var zTrafficDimension = z.enum(["channel", "referrer", "utm"]);
|
|
256
|
-
var zTrafficSourcesInput = z.object({
|
|
257
|
-
projectId: z.string().min(1),
|
|
258
|
-
startDate: zDate,
|
|
259
|
-
endDate: zDate,
|
|
260
|
-
/** `channel`: channel_type · `referrer`: referrer name+type · `utm`: source/medium/campaign. */
|
|
261
|
-
dimension: zTrafficDimension,
|
|
262
|
-
limit: z.number().int().min(1).max(100).default(10),
|
|
263
|
-
timezone: zTimezone.optional()
|
|
264
|
-
}).refine((input) => input.startDate <= input.endDate, {
|
|
265
|
-
message: "endDate must be on or after startDate",
|
|
266
|
-
path: ["endDate"]
|
|
267
|
-
});
|
|
268
|
-
var zTrafficSourceRow = zTrafficTotals.extend({
|
|
269
|
-
/** Display key for the row: the channel, the referrer name, or `source / medium / campaign`. */
|
|
270
|
-
key: z.string(),
|
|
271
|
-
channelType: z.string().optional(),
|
|
272
|
-
referrerName: z.string().optional(),
|
|
273
|
-
referrerType: z.string().optional(),
|
|
274
|
-
utmSource: z.string().optional(),
|
|
275
|
-
utmMedium: z.string().optional(),
|
|
276
|
-
utmCampaign: z.string().optional()
|
|
277
|
-
});
|
|
278
|
-
var zTrafficSourcesData = z.object({
|
|
279
|
-
dimension: zTrafficDimension,
|
|
280
|
-
timezone: z.string(),
|
|
281
|
-
/** Ordered by sessions, descending. */
|
|
282
|
-
rows: z.array(zTrafficSourceRow)
|
|
283
|
-
});
|
|
284
|
-
var zTrafficSourcesResponse = zQueryEnvelope(zTrafficSourcesData);
|
|
285
|
-
var QUERY_ERROR_CODES = [
|
|
286
|
-
/** 401 — unknown or mismatched credentials. */
|
|
287
|
-
"unauthorized",
|
|
288
|
-
/** 403 — the credential's project is not the project asked about. */
|
|
289
|
-
"project_scope_mismatch",
|
|
290
|
-
/** 403 — the credential lacks the `query` scope. Provision a query-scoped client. */
|
|
291
|
-
"query_scope_missing",
|
|
292
|
-
/** 400 — input failed the schema. `errors` carries the zod issues. */
|
|
293
|
-
"validation_failed",
|
|
294
|
-
/** 400 — inputs are individually valid but cannot be served together (e.g. breakdown + segmentId). */
|
|
295
|
-
"unsupported_combination",
|
|
296
|
-
/** 410 — the project is being deleted. Permanent; stop asking. */
|
|
297
|
-
"project_purging",
|
|
298
|
-
/** 429 — per-credential query rate limit. `Retry-After` set. */
|
|
299
|
-
"rate_limited",
|
|
300
|
-
/** 504 — the analytics backend exceeded its statement timeout. Narrow the window. */
|
|
301
|
-
"query_timeout",
|
|
302
|
-
/** 500 — unexpected server failure. */
|
|
303
|
-
"internal_error"
|
|
304
|
-
];
|
|
305
|
-
var zQueryErrorCode = z.enum(QUERY_ERROR_CODES);
|
|
306
|
-
var zQueryError = z.object({
|
|
307
|
-
status: z.number().int(),
|
|
308
|
-
code: zQueryErrorCode,
|
|
309
|
-
error: z.string(),
|
|
310
|
-
message: z.string().optional(),
|
|
311
|
-
errors: z.unknown().optional(),
|
|
312
|
-
requestId: z.string().optional()
|
|
313
|
-
});
|
|
314
|
-
var QUERY_API_PATHS = {
|
|
315
|
-
eventsTimeseries: "/api/v1/query/events/timeseries",
|
|
316
|
-
funnel: "/api/v1/query/funnel",
|
|
317
|
-
retention: "/api/v1/query/retention",
|
|
318
|
-
trafficOverview: "/api/v1/query/traffic/overview",
|
|
319
|
-
trafficSources: "/api/v1/query/traffic/sources"
|
|
320
|
-
};
|
|
321
|
-
|
|
322
|
-
export {
|
|
323
|
-
zGranularity,
|
|
324
|
-
zTimezone,
|
|
325
|
-
isValidTimeZone,
|
|
326
|
-
zChannelFilter,
|
|
327
|
-
zQuerySource,
|
|
328
|
-
zQueryMeta,
|
|
329
|
-
zQueryEnvelope,
|
|
330
|
-
zTimeseriesBreakdown,
|
|
331
|
-
zEventPropertyFilter,
|
|
332
|
-
zEventsTimeseriesInput,
|
|
333
|
-
zBucketStart,
|
|
334
|
-
zTimeseriesPoint,
|
|
335
|
-
zEventsTimeseriesData,
|
|
336
|
-
zEventsTimeseriesResponse,
|
|
337
|
-
zFunnelInput,
|
|
338
|
-
zFunnelStep,
|
|
339
|
-
zFunnelData,
|
|
340
|
-
zFunnelResponse,
|
|
341
|
-
zRetentionInterval,
|
|
342
|
-
zRetentionInput,
|
|
343
|
-
zRetentionCell,
|
|
344
|
-
zRetentionData,
|
|
345
|
-
zRetentionResponse,
|
|
346
|
-
zTrafficOverviewInput,
|
|
347
|
-
zTrafficTotals,
|
|
348
|
-
zTrafficSeriesPoint,
|
|
349
|
-
zTrafficOverviewData,
|
|
350
|
-
zTrafficOverviewResponse,
|
|
351
|
-
zTrafficDimension,
|
|
352
|
-
zTrafficSourcesInput,
|
|
353
|
-
zTrafficSourceRow,
|
|
354
|
-
zTrafficSourcesData,
|
|
355
|
-
zTrafficSourcesResponse,
|
|
356
|
-
QUERY_ERROR_CODES,
|
|
357
|
-
zQueryErrorCode,
|
|
358
|
-
zQueryError,
|
|
359
|
-
QUERY_API_PATHS
|
|
360
|
-
};
|
|
361
|
-
//# sourceMappingURL=chunk-NJ4JKNBX.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/query.ts"],"sourcesContent":["/**\n * `POST /api/v1/query/*` — the read contract.\n *\n * Server credentials, project-scoped: the authenticated client's projectId must\n * equal the `projectId` in the body, or the request is refused. Reads are POSTs\n * because the inputs nest (funnel steps, channel filters) and would not survive\n * a query string; consumers cache on their own side, so HTTP cache semantics\n * buy nothing here.\n *\n * Response shapes mirror the existing dashboard computations exactly — this\n * plane re-exposes them, it does not add new math.\n */\nimport { z } from \"zod\";\nimport { zDate, zInstant } from \"./index.js\";\n\nexport { zDate, zInstant };\n\n/** Bucket width for a time series. */\nexport const zGranularity = z.enum([\"hour\", \"day\", \"week\", \"month\"]);\nexport type Granularity = z.infer<typeof zGranularity>;\n\n/**\n * IANA time zone name, e.g. `Asia/Seoul`. Decides two things at once: where a\n * calendar day starts, and therefore which bucket an event falls in.\n *\n * A Korean brand reading \"23 Aug: 120 visits\" means 23 Aug in Seoul. Computed\n * in UTC, that headline silently covers 23 Aug 09:00 through 24 Aug 09:00 —\n * wrong by nine hours in a way nothing on the page reveals.\n *\n * Validated against the runtime's own zone database rather than a regex, so an\n * unknown name fails here with a clear message instead of deep inside a query.\n */\nexport const zTimezone = z.string().min(1).max(64).refine(isValidTimeZone, { message: \"unknown IANA time zone\" });\n\nexport function isValidTimeZone(value: string): boolean {\n try {\n new Intl.DateTimeFormat(\"en-US\", { timeZone: value });\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Acquisition-channel filter. Every field is a set — an event matches when its\n * value is in the set; omitted fields do not constrain. Mirrors the dashboard's\n * `channelFilterSchema` field-for-field.\n */\nexport const zChannelFilter = z\n .object({\n referrerTypes: z.array(z.string()).optional(),\n channelTypes: z.array(z.string()).optional(),\n utmSources: z.array(z.string()).optional(),\n utmMediums: z.array(z.string()).optional(),\n utmCampaigns: z.array(z.string()).optional(),\n })\n .optional();\nexport type ChannelFilter = z.infer<typeof zChannelFilter>;\n\n// ─── Envelope ───────────────────────────────────────────────────────────────\n\n/**\n * Staleness is reported as two independent numbers, never as one sum, because\n * the two have different remedies: a stale cache resolves itself at the next\n * TTL, while ingest lag means the read model is genuinely behind and the right\n * response is an \"aggregating\" badge, not a refresh.\n */\nexport const zQuerySource = z.enum([\"rollup\", \"raw\", \"mixed\"]);\nexport type QuerySource = z.infer<typeof zQuerySource>;\n\nexport const zQueryMeta = z.object({\n projectId: z.string(),\n /** When the underlying computation actually ran. On a cache hit, when the cached value was computed. */\n computedAt: zInstant,\n /** Age of the returned computation, in seconds. `0` on a cache miss. */\n cacheAgeSeconds: z.number().int().nonnegative(),\n /**\n * How far behind live materialization was when the computation ran, in\n * seconds. `0` means no live event is pending; `null` means measurement\n * failed and must never be interpreted as fresh.\n *\n * Deliberately not `now - max(events.created_at)` — that conflates \"the\n * pipeline is behind\" with \"this project is quiet\", and grows without bound\n * on an idle project.\n */\n ingestLagSeconds: z.number().int().nonnegative().nullable(),\n /** Whether the freshness measurement itself succeeded. */\n ingestLagStatus: z.enum([\"known\", \"unknown\"]),\n /**\n * Pending events older than the live replay window. Kept separate so an old\n * permanently failing event neither pegs live lag nor disappears behind 0.\n * `null` means the measurement failed.\n */\n ingestDeadLetterCount: z.number().int().nonnegative().nullable(),\n cached: z.boolean(),\n /**\n * The time zone actually used to place bucket and window boundaries — the\n * resolved value, not the requested one. Read it rather than assuming the\n * request was honoured: when no zone is given anywhere it is `\"UTC\"`, and\n * that is exactly the case a consumer needs to notice.\n */\n timezone: z.string(),\n /**\n * Where the numbers came from. `rollup`: pre-aggregated hourly tables;\n * `raw`: a scan of the event/session tables; `mixed`: finished hours from\n * the rollup, the hour still in progress from raw. Diagnostic — the values\n * agree either way — but a consumer that expected `rollup` and sees `raw`\n * has asked for a combination the rollups cannot serve.\n */\n source: zQuerySource,\n requestId: z.string(),\n});\nexport type QueryMeta = z.infer<typeof zQueryMeta>;\n\n/** Every query response is `{ data, meta }`. */\nexport function zQueryEnvelope<T extends z.ZodTypeAny>(data: T) {\n return z.object({ data, meta: zQueryMeta });\n}\n\n// ─── events.timeseries ──────────────────────────────────────────────────────\n\n/**\n * v1 breaks down by `properties` JSON keys only. Built-in columns\n * (country / os / browser / utm_*) have a totals breakdown in the backend but\n * no *time series* variant, and this plane does not add new computations.\n */\nexport const zTimeseriesBreakdown = z.object({\n kind: z.literal(\"property\"),\n key: z.string().min(1).max(200),\n topN: z.number().int().min(1).max(100).default(5),\n});\nexport type TimeseriesBreakdown = z.infer<typeof zTimeseriesBreakdown>;\n\n/** Exact-match filter for a top-level event `properties` key. Multiple filters are ANDed. */\nexport const zEventPropertyFilter = z.object({\n key: z.string().min(1).max(200),\n operator: z.literal(\"eq\").default(\"eq\"),\n value: z.string().min(1).max(500),\n});\nexport type EventPropertyFilter = z.infer<typeof zEventPropertyFilter>;\n\nexport const zEventsTimeseriesInput = z\n .object({\n projectId: z.string().min(1),\n startDate: zDate,\n endDate: zDate,\n granularity: zGranularity.default(\"day\"),\n /** Omit to count every event in the window. */\n eventName: z.string().min(1).max(200).optional(),\n /** Exact matches against top-level `properties` keys. Every item must match. */\n propertyFilters: z.array(zEventPropertyFilter).max(10).optional(),\n breakdown: zTimeseriesBreakdown.optional(),\n /**\n * Cannot be combined with `breakdown` — the backend's breakdown time series\n * takes no segment. Sending both is refused with `unsupported_combination`\n * rather than silently ignoring one of them.\n */\n segmentId: z.string().min(1).optional(),\n /** Omit to fall back to the project's configured zone, then to UTC. */\n timezone: zTimezone.optional(),\n /**\n * Events whose catalogue status is `internal` (operational probes) are\n * left out by default. A probe that needs to find its own event sets this.\n */\n includeInternal: z.boolean().default(false),\n })\n .refine((input) => input.startDate <= input.endDate, {\n message: \"endDate must be on or after startDate\",\n path: [\"endDate\"],\n });\nexport type EventsTimeseriesInput = z.input<typeof zEventsTimeseriesInput>;\n\n/**\n * Bucket start as wall-clock time in `meta.timezone`, `YYYY-MM-DD HH:MM:SS`.\n *\n * Pinned rather than left to the backend, because a consumer keys its chart on\n * this string: an unspecified format is one where two backends, or two\n * granularities, can quietly disagree and produce two different keys for the\n * same bucket.\n *\n * It is wall time, not an instant — for `Asia/Seoul` a day bucket reads\n * `2026-08-24 00:00:00`, which is `2026-08-23T15:00:00Z`. Day, week and month\n * buckets always carry `00:00:00`, so slicing the first ten characters is a\n * safe way to get a date key.\n */\nexport const zBucketStart = z.string().regex(/^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}$/, \"expected 'YYYY-MM-DD HH:MM:SS'\");\n\nexport const zTimeseriesPoint = z.object({\n date: zBucketStart,\n count: z.number().int().nonnegative(),\n});\nexport type TimeseriesPoint = z.infer<typeof zTimeseriesPoint>;\n\nexport const zEventsTimeseriesData = z.object({\n granularity: zGranularity,\n /** Zone the buckets were cut in. Mirrors `meta.timezone`. */\n timezone: z.string(),\n /** Total per bucket. Always present, with or without a breakdown. */\n series: z.array(zTimeseriesPoint),\n /** Present only when `breakdown` was requested: the top-N values, each with its own series. */\n breakdown: z\n .array(\n z.object({\n value: z.string(),\n points: z.array(zTimeseriesPoint),\n })\n )\n .optional(),\n});\nexport type EventsTimeseriesData = z.infer<typeof zEventsTimeseriesData>;\n\nexport const zEventsTimeseriesResponse = zQueryEnvelope(zEventsTimeseriesData);\nexport type EventsTimeseriesResponse = z.infer<typeof zEventsTimeseriesResponse>;\n\n// ─── funnel ─────────────────────────────────────────────────────────────────\n\nexport const zFunnelInput = z\n .object({\n projectId: z.string().min(1),\n /** Ordered event names. A user counts at step k if they reached at least step k. */\n steps: z.array(z.string().min(1).max(200)).min(2).max(10),\n startDate: zDate,\n endDate: zDate,\n /** Max seconds between the first and last step for a conversion to count. Default 24h. */\n windowSeconds: z.number().int().min(60).max(2_592_000).default(86_400),\n segmentId: z.string().min(1).optional(),\n channelFilter: zChannelFilter,\n /**\n * Decides where `startDate` / `endDate` fall. A funnel has no buckets, so\n * this only moves the window — but a nine-hour window shift changes who is\n * in the funnel.\n */\n timezone: zTimezone.optional(),\n /** Accepted for symmetry with events.timeseries; funnel steps are named explicitly, so nothing is filtered. */\n includeInternal: z.boolean().default(false),\n })\n .refine((input) => input.startDate <= input.endDate, {\n message: \"endDate must be on or after startDate\",\n path: [\"endDate\"],\n });\nexport type FunnelInput = z.input<typeof zFunnelInput>;\n\nexport const zFunnelStep = z.object({\n step: z.number().int().min(1),\n name: z.string(),\n users: z.number().int().nonnegative(),\n /** Percent of the previous step that reached this one. `100` for step 1. */\n conversionRate: z.number(),\n /** Percent of the previous step that did not. `0` for step 1. */\n dropoffRate: z.number(),\n dropoffUsers: z.number().int().nonnegative(),\n});\n\nexport const zFunnelData = z.object({\n steps: z.array(zFunnelStep),\n totalUsers: z.number().int().nonnegative(),\n /** Percent of step-1 users that reached the last step. */\n overallConversionRate: z.number(),\n});\nexport type FunnelData = z.infer<typeof zFunnelData>;\n\nexport const zFunnelResponse = zQueryEnvelope(zFunnelData);\nexport type FunnelResponse = z.infer<typeof zFunnelResponse>;\n\n// ─── retention ──────────────────────────────────────────────────────────────\n\nexport const zRetentionInterval = z.enum([\"day\", \"week\", \"month\"]);\n\nexport const zRetentionInput = z\n .object({\n projectId: z.string().min(1),\n startDate: zDate,\n endDate: zDate,\n interval: zRetentionInterval.default(\"day\"),\n periods: z.number().int().min(1).max(30).default(7),\n startEvent: z.string().min(1).max(200).optional(),\n returnEvent: z.string().min(1).max(200).optional(),\n /** `bounded`: returned in exactly period N. `unbounded`: returned in period N or later. */\n retentionType: z.enum([\"bounded\", \"unbounded\"]).default(\"bounded\"),\n /**\n * `first-ever` (default): the cohort is everyone whose true first activity\n * landed in the window, read from the first-seen aggregate. `startEvent`,\n * `segmentId` and `channelFilter` then constrain only the *returning* side.\n * `first-in-window`: the cohort is selected by scanning events in the window\n * with all filters applied. Slower, but filters apply to cohort selection.\n */\n cohortMode: z.enum([\"first-ever\", \"first-in-window\"]).default(\"first-ever\"),\n segmentId: z.string().min(1).optional(),\n channelFilter: zChannelFilter,\n /**\n * Decides where a cohort day starts, and so which period a return falls in.\n *\n * Honoured under both cohort modes. Note that a non-UTC zone makes\n * `first-ever` read raw events instead of its daily rollup — the rollup is\n * cut on UTC days and cannot be re-cut after the fact — so expect a slower\n * query in exchange for cohorts that match the reader's calendar.\n */\n timezone: zTimezone.optional(),\n /** Accepted for symmetry with events.timeseries; retention reads named or all-event activity and does not yet apply the internal filter. */\n includeInternal: z.boolean().default(false),\n })\n .refine((input) => input.startDate <= input.endDate, {\n message: \"endDate must be on or after startDate\",\n path: [\"endDate\"],\n });\nexport type RetentionInput = z.input<typeof zRetentionInput>;\n\nexport const zRetentionCell = z.object({\n /** `0` is the cohort's own period. */\n period: z.number().int().nonnegative(),\n users: z.number().int().nonnegative(),\n /** Percent of `cohortSize`. */\n rate: z.number(),\n});\n\nexport const zRetentionData = z.object({\n matrix: z.array(\n z.object({\n /** Cohort bucket start, same shape and zone as {@link zBucketStart}. */\n cohortDate: zBucketStart,\n cohortSize: z.number().int().nonnegative(),\n /** Length is `periods + 1`, index-aligned to `period`. */\n retention: z.array(zRetentionCell),\n })\n ),\n /** Unweighted mean rate per period across cohorts. */\n averageRetention: z.array(z.object({ period: z.number().int().nonnegative(), rate: z.number() })),\n interval: zRetentionInterval,\n periods: z.number().int(),\n retentionType: z.enum([\"bounded\", \"unbounded\"]),\n /** Zone the cohort days were cut in. Mirrors `meta.timezone`. */\n timezone: z.string(),\n});\nexport type RetentionData = z.infer<typeof zRetentionData>;\n\nexport const zRetentionResponse = zQueryEnvelope(zRetentionData);\nexport type RetentionResponse = z.infer<typeof zRetentionResponse>;\n\n// ─── traffic ────────────────────────────────────────────────────────────────\n\n/**\n * Session-level traffic for a brand site, served from the hourly rollups.\n * `newVisitors` counts sessions whose device was first seen inside them;\n * `returningVisitors` is the rest. Both are session counts, not people —\n * \"visitor\" is the vocabulary the dashboards already use.\n */\nexport const zTrafficOverviewInput = z\n .object({\n projectId: z.string().min(1),\n startDate: zDate,\n endDate: zDate,\n granularity: zGranularity.default(\"day\"),\n timezone: zTimezone.optional(),\n })\n .refine((input) => input.startDate <= input.endDate, {\n message: \"endDate must be on or after startDate\",\n path: [\"endDate\"],\n });\nexport type TrafficOverviewInput = z.input<typeof zTrafficOverviewInput>;\n\nexport const zTrafficTotals = z.object({\n sessions: z.number().int().nonnegative(),\n pageviews: z.number().int().nonnegative(),\n newVisitors: z.number().int().nonnegative(),\n returningVisitors: z.number().int().nonnegative(),\n /** Percent of sessions that bounced, two decimals. */\n bounceRate: z.number(),\n});\nexport type TrafficTotals = z.infer<typeof zTrafficTotals>;\n\nexport const zTrafficSeriesPoint = zTrafficTotals.extend({ date: zBucketStart });\n\nexport const zTrafficOverviewData = z.object({\n granularity: zGranularity,\n timezone: z.string(),\n totals: zTrafficTotals,\n series: z.array(zTrafficSeriesPoint),\n});\nexport type TrafficOverviewData = z.infer<typeof zTrafficOverviewData>;\nexport const zTrafficOverviewResponse = zQueryEnvelope(zTrafficOverviewData);\nexport type TrafficOverviewResponse = z.infer<typeof zTrafficOverviewResponse>;\n\nexport const zTrafficDimension = z.enum([\"channel\", \"referrer\", \"utm\"]);\nexport type TrafficDimension = z.infer<typeof zTrafficDimension>;\n\nexport const zTrafficSourcesInput = z\n .object({\n projectId: z.string().min(1),\n startDate: zDate,\n endDate: zDate,\n /** `channel`: channel_type · `referrer`: referrer name+type · `utm`: source/medium/campaign. */\n dimension: zTrafficDimension,\n limit: z.number().int().min(1).max(100).default(10),\n timezone: zTimezone.optional(),\n })\n .refine((input) => input.startDate <= input.endDate, {\n message: \"endDate must be on or after startDate\",\n path: [\"endDate\"],\n });\nexport type TrafficSourcesInput = z.input<typeof zTrafficSourcesInput>;\n\nexport const zTrafficSourceRow = zTrafficTotals.extend({\n /** Display key for the row: the channel, the referrer name, or `source / medium / campaign`. */\n key: z.string(),\n channelType: z.string().optional(),\n referrerName: z.string().optional(),\n referrerType: z.string().optional(),\n utmSource: z.string().optional(),\n utmMedium: z.string().optional(),\n utmCampaign: z.string().optional(),\n});\nexport type TrafficSourceRow = z.infer<typeof zTrafficSourceRow>;\n\nexport const zTrafficSourcesData = z.object({\n dimension: zTrafficDimension,\n timezone: z.string(),\n /** Ordered by sessions, descending. */\n rows: z.array(zTrafficSourceRow),\n});\nexport type TrafficSourcesData = z.infer<typeof zTrafficSourcesData>;\nexport const zTrafficSourcesResponse = zQueryEnvelope(zTrafficSourcesData);\nexport type TrafficSourcesResponse = z.infer<typeof zTrafficSourcesResponse>;\n\n// ─── Errors ─────────────────────────────────────────────────────────────────\n\nexport const QUERY_ERROR_CODES = [\n /** 401 — unknown or mismatched credentials. */\n \"unauthorized\",\n /** 403 — the credential's project is not the project asked about. */\n \"project_scope_mismatch\",\n /** 403 — the credential lacks the `query` scope. Provision a query-scoped client. */\n \"query_scope_missing\",\n /** 400 — input failed the schema. `errors` carries the zod issues. */\n \"validation_failed\",\n /** 400 — inputs are individually valid but cannot be served together (e.g. breakdown + segmentId). */\n \"unsupported_combination\",\n /** 410 — the project is being deleted. Permanent; stop asking. */\n \"project_purging\",\n /** 429 — per-credential query rate limit. `Retry-After` set. */\n \"rate_limited\",\n /** 504 — the analytics backend exceeded its statement timeout. Narrow the window. */\n \"query_timeout\",\n /** 500 — unexpected server failure. */\n \"internal_error\",\n] as const;\nexport const zQueryErrorCode = z.enum(QUERY_ERROR_CODES);\nexport type QueryErrorCode = z.infer<typeof zQueryErrorCode>;\n\nexport const zQueryError = z.object({\n status: z.number().int(),\n code: zQueryErrorCode,\n error: z.string(),\n message: z.string().optional(),\n errors: z.unknown().optional(),\n requestId: z.string().optional(),\n});\nexport type QueryError = z.infer<typeof zQueryError>;\n\n/** Paths, so the client and the route handlers cannot drift apart. */\nexport const QUERY_API_PATHS = {\n eventsTimeseries: \"/api/v1/query/events/timeseries\",\n funnel: \"/api/v1/query/funnel\",\n retention: \"/api/v1/query/retention\",\n trafficOverview: \"/api/v1/query/traffic/overview\",\n trafficSources: \"/api/v1/query/traffic/sources\",\n} as const;\n"],"mappings":";;;;;;AAYA,SAAS,SAAS;AAMX,IAAM,eAAe,EAAE,KAAK,CAAC,QAAQ,OAAO,QAAQ,OAAO,CAAC;AAc5D,IAAM,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,OAAO,iBAAiB,EAAE,SAAS,yBAAyB,CAAC;AAEzG,SAAS,gBAAgB,OAAwB;AACtD,MAAI;AACF,QAAI,KAAK,eAAe,SAAS,EAAE,UAAU,MAAM,CAAC;AACpD,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAOO,IAAM,iBAAiB,EAC3B,OAAO;AAAA,EACN,eAAe,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EAC5C,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EAC3C,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EACzC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EACzC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAC7C,CAAC,EACA,SAAS;AAWL,IAAM,eAAe,EAAE,KAAK,CAAC,UAAU,OAAO,OAAO,CAAC;AAGtD,IAAM,aAAa,E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,cAAc,EAAE,OAAO;AAAA,EAClC,QAAQ,EAAE,OAAO,EAAE,IAAI;AAAA,EACvB,MAAM;AAAA,EACN,OAAO,EAAE,OAAO;AAAA,EAChB,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,QAAQ,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC7B,WAAW,EAAE,OAAO,EAAE,SAAS;AACjC,CAAC;AAIM,IAAM,kBAAkB;AAAA,EAC7B,kBAAkB;AAAA,EAClB,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,gBAAgB;AAClB;","names":[]}
|
package/dist/chunk-ORNTN6AK.cjs
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); var _class;// src/index.ts
|
|
2
|
-
var _zod = require('zod');
|
|
3
|
-
var zDate = _zod.z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "expected YYYY-MM-DD").refine(isRealCalendarDate, "date does not exist");
|
|
4
|
-
function isRealCalendarDate(value) {
|
|
5
|
-
if (!/^\d{4}-\d{2}-\d{2}$/.test(value)) return false;
|
|
6
|
-
const [year, month, day] = value.split("-").map(Number);
|
|
7
|
-
const instant = new Date(Date.UTC(year, month - 1, day));
|
|
8
|
-
return instant.getUTCFullYear() === year && instant.getUTCMonth() === month - 1 && instant.getUTCDate() === day;
|
|
9
|
-
}
|
|
10
|
-
var zInstant = _zod.z.string().min(20);
|
|
11
|
-
var DataApiError = (_class = class _DataApiError extends Error {
|
|
12
|
-
/**
|
|
13
|
-
* Brand for {@link DataApiError.is}. A bundler that inlines this module into
|
|
14
|
-
* more than one entry point produces two distinct classes, and `instanceof`
|
|
15
|
-
* silently stops matching — the brand survives that, and realm boundaries.
|
|
16
|
-
*/
|
|
17
|
-
__init() {this.isDataApiError = true}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/** Parsed from `Retry-After`, in milliseconds. Only set on 429. */
|
|
22
|
-
|
|
23
|
-
/** zod issues for `validation_failed`, or the raw body when unparseable. */
|
|
24
|
-
|
|
25
|
-
constructor(init) {
|
|
26
|
-
super(init.message);_class.prototype.__init.call(this);;
|
|
27
|
-
this.name = "DataApiError";
|
|
28
|
-
this.status = init.status;
|
|
29
|
-
this.code = init.code;
|
|
30
|
-
this.requestId = init.requestId;
|
|
31
|
-
this.retryAfterMs = init.retryAfterMs;
|
|
32
|
-
this.details = init.details;
|
|
33
|
-
}
|
|
34
|
-
/** 429 and 5xx are worth retrying; 4xx are the caller's fault and are not. */
|
|
35
|
-
get retryable() {
|
|
36
|
-
return this.status === 429 || this.status >= 500;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Prefer this over `instanceof` in a `catch`. It holds even when the class
|
|
40
|
-
* has been duplicated — across CJS entry points, across bundler chunks, or
|
|
41
|
-
* across realms — where `instanceof` quietly returns false.
|
|
42
|
-
*/
|
|
43
|
-
static is(value) {
|
|
44
|
-
return value instanceof _DataApiError || typeof value === "object" && value !== null && value.isDataApiError === true;
|
|
45
|
-
}
|
|
46
|
-
}, _class);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
exports.zDate = zDate; exports.zInstant = zInstant; exports.DataApiError = DataApiError;
|
|
53
|
-
//# sourceMappingURL=chunk-ORNTN6AK.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/eric/reopt-ai/reopt-data/packages/data-contract/dist/chunk-ORNTN6AK.cjs","../src/index.ts"],"names":[],"mappings":"AAAA;ACiBA,0BAAkB;AAgBX,IAAM,MAAA,EAAQ,MAAA,CAClB,MAAA,CAAO,CAAA,CACP,KAAA,CAAM,qBAAA,EAAuB,qBAAqB,CAAA,CAClD,MAAA,CAAO,kBAAA,EAAoB,qBAAqB,CAAA;AAEnD,SAAS,kBAAA,CAAmB,KAAA,EAAwB;AAClD,EAAA,GAAA,CAAI,CAA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A,OAAO,IAAA,CAAK,OAAA,IAAW,IAAA,GAAO,IAAA,CAAK,OAAA,GAAU,GAAA;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,EAAA,CAAG,KAAA,EAAuC;AAC/C,IAAA,OACE,MAAA,WAAiB,cAAA,GAChB,OAAO,MAAA,IAAU,SAAA,GAAY,MAAA,IAAU,KAAA,GAAS,KAAA,CAAuC,eAAA,IAAmB,IAAA;AAAA,EAE/G;AACF,UAAA;AD7EA;AACA;AACE;AACA;AACA;AACF,wFAAC","file":"/Users/eric/reopt-ai/reopt-data/packages/data-contract/dist/chunk-ORNTN6AK.cjs","sourcesContent":[null,"/**\n * `@reopt-ai/data-contract` — the wire contract between reopt-data and its\n * server-credential consumers (RFC-0023).\n *\n * Subpaths:\n * `@reopt-ai/data-contract` this module — version, shared primitives, errors\n * `@reopt-ai/data-contract/ingest` POST /api/track request + response schemas\n * `@reopt-ai/data-contract/query` POST /api/v1/query/* request + response schemas\n * `@reopt-ai/data-contract/control` provisioning request + response schemas\n * `@reopt-ai/data-contract/client` createDataClient() — typed fetch over all\n * `@reopt-ai/data-contract/events` event names + property keys (no zod)\n * `@reopt-ai/data-contract/identity` cookie/header names and encodings shared by\n * the SDKs, the Next.js proxy and ingest\n *\n * Only `/client` touches `fetch`; everything else is pure zod. The single\n * runtime dependency is zod, deliberately — consumers bundle this.\n */\nimport { z } from \"zod\";\n\nexport {\n CONTRACT_VERSION,\n CONTRACT_VERSION_HEADER,\n CLIENT_ID_HEADER,\n CLIENT_SECRET_HEADER,\n WRITE_KEY_HEADER,\n DEVICE_ID_HEADER,\n REQUEST_ID_HEADER,\n} from \"./version.js\";\n\n/**\n * A real calendar date. The query's resolved IANA zone decides which instants\n * its inclusive day covers.\n */\nexport const zDate = z\n .string()\n .regex(/^\\d{4}-\\d{2}-\\d{2}$/, \"expected YYYY-MM-DD\")\n .refine(isRealCalendarDate, \"date does not exist\");\n\nfunction isRealCalendarDate(value: string): boolean {\n if (!/^\\d{4}-\\d{2}-\\d{2}$/.test(value)) return false;\n const [year, month, day] = value.split(\"-\").map(Number);\n const instant = new Date(Date.UTC(year!, month! - 1, day!));\n return instant.getUTCFullYear() === year && instant.getUTCMonth() === month! - 1 && instant.getUTCDate() === day;\n}\n\n/** ISO-8601 instant, as produced by `Date#toISOString()`. */\nexport const zInstant = z.string().min(20);\n\n/**\n * Client credentials. The same pair authenticates both planes; what a given\n * client may reach is decided server-side by `Client.scopes`\n * (`\"ingest\"` / `\"query\"` / `\"provision\"`).\n */\nexport interface ClientCredentials {\n clientId: string;\n clientSecret: string;\n}\n\n/**\n * Credentials are optional on the client itself because the provisioning\n * surface does not use them — it authenticates per call with a platform or\n * organization key. A caller that only provisions should not have to invent an\n * empty client id to satisfy a constructor.\n *\n * Reaching ingest or query without them fails with `credentials_missing`\n * rather than sending an unauthenticated request and reporting the 401 as a\n * server problem.\n */\nexport type OptionalClientCredentials = Partial<ClientCredentials>;\n\n/**\n * Every non-2xx response from either plane, plus the two failures the client\n * itself raises (`contract_mismatch`, `network_error`).\n */\nexport class DataApiError extends Error {\n /**\n * Brand for {@link DataApiError.is}. A bundler that inlines this module into\n * more than one entry point produces two distinct classes, and `instanceof`\n * silently stops matching — the brand survives that, and realm boundaries.\n */\n readonly isDataApiError = true as const;\n\n readonly status: number;\n readonly code: string;\n readonly requestId?: string | undefined;\n /** Parsed from `Retry-After`, in milliseconds. Only set on 429. */\n readonly retryAfterMs?: number | undefined;\n /** zod issues for `validation_failed`, or the raw body when unparseable. */\n readonly details?: unknown | undefined;\n\n constructor(init: {\n message: string;\n status: number;\n code: string;\n requestId?: string | undefined;\n retryAfterMs?: number | undefined;\n details?: unknown | undefined;\n }) {\n super(init.message);\n this.name = \"DataApiError\";\n this.status = init.status;\n this.code = init.code;\n this.requestId = init.requestId;\n this.retryAfterMs = init.retryAfterMs;\n this.details = init.details;\n }\n\n /** 429 and 5xx are worth retrying; 4xx are the caller's fault and are not. */\n get retryable(): boolean {\n return this.status === 429 || this.status >= 500;\n }\n\n /**\n * Prefer this over `instanceof` in a `catch`. It holds even when the class\n * has been duplicated — across CJS entry points, across bundler chunks, or\n * across realms — where `instanceof` quietly returns false.\n */\n static is(value: unknown): value is DataApiError {\n return (\n value instanceof DataApiError ||\n (typeof value === \"object\" && value !== null && (value as { isDataApiError?: unknown }).isDataApiError === true)\n );\n }\n}\n"]}
|
package/dist/chunk-PSUINLW7.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// src/version.ts
|
|
2
|
-
var CONTRACT_VERSION = "0.6.3";
|
|
3
|
-
var CONTRACT_VERSION_HEADER = "x-reopt-contract-version";
|
|
4
|
-
var CLIENT_ID_HEADER = "reopt-client-id";
|
|
5
|
-
var CLIENT_SECRET_HEADER = "reopt-client-secret";
|
|
6
|
-
var WRITE_KEY_HEADER = "reopt-write-key";
|
|
7
|
-
var DEVICE_ID_HEADER = "reopt-device-id";
|
|
8
|
-
var REQUEST_ID_HEADER = "x-request-id";
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
CONTRACT_VERSION,
|
|
12
|
-
CONTRACT_VERSION_HEADER,
|
|
13
|
-
CLIENT_ID_HEADER,
|
|
14
|
-
CLIENT_SECRET_HEADER,
|
|
15
|
-
WRITE_KEY_HEADER,
|
|
16
|
-
DEVICE_ID_HEADER,
|
|
17
|
-
REQUEST_ID_HEADER
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=chunk-PSUINLW7.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/version.ts"],"sourcesContent":["/**\n * Wire version and header names — the part of the contract every party\n * needs and none of them should pay zod for. Both `.` and `./identity`\n * re-export these; browser bundles import them through `./identity` so the\n * schema modules stay out of the client graph.\n */\n\n/**\n * Contract version. Bumped on any breaking change to a schema in this package.\n * The server echoes the version it was built against in `x-reopt-contract-version`;\n * `createDataClient` surfaces a mismatch rather than guessing.\n *\n * Must equal the package version (`package-identity.test.ts` enforces it), so\n * every publish is a wire bump: consumers that check for exact equality —\n * every SDK — must upgrade in lockstep with the server.\n */\nexport const CONTRACT_VERSION = \"0.6.3\";\n\n/** Response header carrying the server's contract version. */\nexport const CONTRACT_VERSION_HEADER = \"x-reopt-contract-version\";\n\n/** Request header names shared by the ingest and query planes. */\nexport const CLIENT_ID_HEADER = \"reopt-client-id\";\nexport const CLIENT_SECRET_HEADER = \"reopt-client-secret\";\nexport const WRITE_KEY_HEADER = \"reopt-write-key\";\nexport const DEVICE_ID_HEADER = \"reopt-device-id\";\nexport const REQUEST_ID_HEADER = \"x-request-id\";\n"],"mappings":";AAgBO,IAAM,mBAAmB;AAGzB,IAAM,0BAA0B;AAGhC,IAAM,mBAAmB;AACzB,IAAM,uBAAuB;AAC7B,IAAM,mBAAmB;AACzB,IAAM,mBAAmB;AACzB,IAAM,oBAAoB;","names":[]}
|