@tracelog/event-contract 2.0.0 → 2.1.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/CHANGELOG.md CHANGED
@@ -18,6 +18,20 @@ carry it forward.
18
18
  This package, `@tracelog/capture-core` and `@tracelog/capture-web` carry one
19
19
  number between them.
20
20
 
21
+ ## [2.1.0](https://github.com/nacorga/tracelog-sdk/compare/event-contract@2.0.1...event-contract@2.1.0) (2026-10-06)
22
+
23
+
24
+ ### Added
25
+
26
+ * **event-contract:** items, the day a booking is for and the recurrence ([a1ef6d1](https://github.com/nacorga/tracelog-sdk/commit/a1ef6d144b265192f089baf67c367b35b6d030fd))
27
+
28
+ ## [2.0.1](https://github.com/nacorga/tracelog-sdk/compare/event-contract@2.0.0...event-contract@2.0.1) (2026-10-02)
29
+
30
+
31
+ ### Fixed
32
+
33
+ * a bundle that imports only the contract's limits carries no zod ([518d50e](https://github.com/nacorga/tracelog-sdk/commit/518d50ef2e1dcae1b6c8bd9e871503f3d45f5bf9))
34
+
21
35
  ## [2.0.0](https://github.com/nacorga/tracelog-sdk/compare/event-contract@1.3.1...event-contract@2.0.0) (2026-10-01)
22
36
 
23
37
 
package/README.md CHANGED
@@ -19,7 +19,7 @@ schemas rather than a copy of them. Sites installing TraceLog do not need it:
19
19
  <!-- x-release-please-start-version -->
20
20
 
21
21
  ```bash
22
- npm install --save-exact @tracelog/event-contract@2.0.0
22
+ npm install --save-exact @tracelog/event-contract@2.1.0
23
23
  ```
24
24
 
25
25
  <!-- x-release-please-end -->
@@ -42,6 +42,9 @@ npm install --save-exact @tracelog/event-contract@2.0.0
42
42
  and could not read — and the patterns its ids and events are held
43
43
  to, as strings the runtime inlines. The envelope does not validate it; the
44
44
  platform reads it, and a value that fails it is no report.
45
+ - **The items** — `itemSchema` and `itemsSchema`, `scheduledForSchema` and
46
+ their limits. Where its event takes it, a malformed one is read as absent
47
+ and the event stands.
45
48
 
46
49
  ## Licence
47
50
 
package/dist/index.d.ts CHANGED
@@ -1,294 +1,3 @@
1
- import { z } from "zod";
2
- export declare const EVENT_ENVELOPE_VERSION: 1;
3
- export declare const MAX_BATCH_EVENTS = 50;
4
- export declare const MAX_BATCH_BYTES: number;
5
- export declare const MAX_CONTEXT_BYTES: number;
6
- export declare const MAX_ERROR_MESSAGE_BYTES = 1024;
7
- export declare const FUTURE_TOLERANCE_MS: number;
8
- export declare const LATE_AFTER_MS: number;
9
- export declare const eventIdSchema: z.ZodUUID;
10
- export declare const sessionIdSchema: z.ZodUUID;
11
- export declare const eventNameSchema: z.ZodString;
12
- export declare const occurredAtSchema: z.ZodISODateTime;
13
- export declare const eventModeSchema: z.ZodLiteral<"verification">;
14
- export declare const contextSchema: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
15
- export declare const utmSchema: z.ZodObject<{
16
- source: z.ZodOptional<z.ZodString>;
17
- medium: z.ZodOptional<z.ZodString>;
18
- campaign: z.ZodOptional<z.ZodString>;
19
- term: z.ZodOptional<z.ZodString>;
20
- content: z.ZodOptional<z.ZodString>;
21
- }, z.core.$strict>;
22
- export declare const deviceSchema: z.ZodEnum<{
23
- desktop: "desktop";
24
- mobile: "mobile";
25
- tablet: "tablet";
26
- }>;
27
- export declare const sessionStartEventSchema: z.ZodObject<{
28
- kind: z.ZodLiteral<"session_start">;
29
- referrer: z.ZodOptional<z.ZodString>;
30
- utm: z.ZodObject<{
31
- source: z.ZodOptional<z.ZodString>;
32
- medium: z.ZodOptional<z.ZodString>;
33
- campaign: z.ZodOptional<z.ZodString>;
34
- term: z.ZodOptional<z.ZodString>;
35
- content: z.ZodOptional<z.ZodString>;
36
- }, z.core.$strict>;
37
- landingPage: z.ZodString;
38
- device: z.ZodEnum<{
39
- desktop: "desktop";
40
- mobile: "mobile";
41
- tablet: "tablet";
42
- }>;
43
- eventId: z.ZodUUID;
44
- sessionId: z.ZodUUID;
45
- name: z.ZodString;
46
- occurredAt: z.ZodISODateTime;
47
- mode: z.ZodOptional<z.ZodLiteral<"verification">>;
48
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
49
- }, z.core.$strict>;
50
- export declare const stepEventSchema: z.ZodObject<{
51
- kind: z.ZodLiteral<"step">;
52
- eventId: z.ZodUUID;
53
- sessionId: z.ZodUUID;
54
- name: z.ZodString;
55
- occurredAt: z.ZodISODateTime;
56
- mode: z.ZodOptional<z.ZodLiteral<"verification">>;
57
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
58
- }, z.core.$strict>;
59
- export declare const currencySchema: z.ZodString;
60
- export declare const conversionEventSchema: z.ZodObject<{
61
- kind: z.ZodLiteral<"conversion">;
62
- identifier: z.ZodString;
63
- value: z.ZodOptional<z.ZodNumber>;
64
- currency: z.ZodOptional<z.ZodString>;
65
- eventId: z.ZodUUID;
66
- sessionId: z.ZodUUID;
67
- name: z.ZodString;
68
- occurredAt: z.ZodISODateTime;
69
- mode: z.ZodOptional<z.ZodLiteral<"verification">>;
70
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
71
- }, z.core.$strict>;
72
- export declare const errorMessageSchema: z.ZodString;
73
- export declare const errorEventSchema: z.ZodObject<{
74
- kind: z.ZodLiteral<"error">;
75
- message: z.ZodString;
76
- stepName: z.ZodString;
77
- eventId: z.ZodUUID;
78
- sessionId: z.ZodUUID;
79
- name: z.ZodString;
80
- occurredAt: z.ZodISODateTime;
81
- mode: z.ZodOptional<z.ZodLiteral<"verification">>;
82
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
83
- }, z.core.$strict>;
84
- export declare const eventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
85
- kind: z.ZodLiteral<"session_start">;
86
- referrer: z.ZodOptional<z.ZodString>;
87
- utm: z.ZodObject<{
88
- source: z.ZodOptional<z.ZodString>;
89
- medium: z.ZodOptional<z.ZodString>;
90
- campaign: z.ZodOptional<z.ZodString>;
91
- term: z.ZodOptional<z.ZodString>;
92
- content: z.ZodOptional<z.ZodString>;
93
- }, z.core.$strict>;
94
- landingPage: z.ZodString;
95
- device: z.ZodEnum<{
96
- desktop: "desktop";
97
- mobile: "mobile";
98
- tablet: "tablet";
99
- }>;
100
- eventId: z.ZodUUID;
101
- sessionId: z.ZodUUID;
102
- name: z.ZodString;
103
- occurredAt: z.ZodISODateTime;
104
- mode: z.ZodOptional<z.ZodLiteral<"verification">>;
105
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
106
- }, z.core.$strict>, z.ZodObject<{
107
- kind: z.ZodLiteral<"step">;
108
- eventId: z.ZodUUID;
109
- sessionId: z.ZodUUID;
110
- name: z.ZodString;
111
- occurredAt: z.ZodISODateTime;
112
- mode: z.ZodOptional<z.ZodLiteral<"verification">>;
113
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
114
- }, z.core.$strict>, z.ZodObject<{
115
- kind: z.ZodLiteral<"conversion">;
116
- identifier: z.ZodString;
117
- value: z.ZodOptional<z.ZodNumber>;
118
- currency: z.ZodOptional<z.ZodString>;
119
- eventId: z.ZodUUID;
120
- sessionId: z.ZodUUID;
121
- name: z.ZodString;
122
- occurredAt: z.ZodISODateTime;
123
- mode: z.ZodOptional<z.ZodLiteral<"verification">>;
124
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
125
- }, z.core.$strict>, z.ZodObject<{
126
- kind: z.ZodLiteral<"error">;
127
- message: z.ZodString;
128
- stepName: z.ZodString;
129
- eventId: z.ZodUUID;
130
- sessionId: z.ZodUUID;
131
- name: z.ZodString;
132
- occurredAt: z.ZodISODateTime;
133
- mode: z.ZodOptional<z.ZodLiteral<"verification">>;
134
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
135
- }, z.core.$strict>], "kind">;
136
- export declare const eventBatchSchema: z.ZodObject<{
137
- v: z.ZodLiteral<1>;
138
- events: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
139
- kind: z.ZodLiteral<"session_start">;
140
- referrer: z.ZodOptional<z.ZodString>;
141
- utm: z.ZodObject<{
142
- source: z.ZodOptional<z.ZodString>;
143
- medium: z.ZodOptional<z.ZodString>;
144
- campaign: z.ZodOptional<z.ZodString>;
145
- term: z.ZodOptional<z.ZodString>;
146
- content: z.ZodOptional<z.ZodString>;
147
- }, z.core.$strict>;
148
- landingPage: z.ZodString;
149
- device: z.ZodEnum<{
150
- desktop: "desktop";
151
- mobile: "mobile";
152
- tablet: "tablet";
153
- }>;
154
- eventId: z.ZodUUID;
155
- sessionId: z.ZodUUID;
156
- name: z.ZodString;
157
- occurredAt: z.ZodISODateTime;
158
- mode: z.ZodOptional<z.ZodLiteral<"verification">>;
159
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
160
- }, z.core.$strict>, z.ZodObject<{
161
- kind: z.ZodLiteral<"step">;
162
- eventId: z.ZodUUID;
163
- sessionId: z.ZodUUID;
164
- name: z.ZodString;
165
- occurredAt: z.ZodISODateTime;
166
- mode: z.ZodOptional<z.ZodLiteral<"verification">>;
167
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
168
- }, z.core.$strict>, z.ZodObject<{
169
- kind: z.ZodLiteral<"conversion">;
170
- identifier: z.ZodString;
171
- value: z.ZodOptional<z.ZodNumber>;
172
- currency: z.ZodOptional<z.ZodString>;
173
- eventId: z.ZodUUID;
174
- sessionId: z.ZodUUID;
175
- name: z.ZodString;
176
- occurredAt: z.ZodISODateTime;
177
- mode: z.ZodOptional<z.ZodLiteral<"verification">>;
178
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
179
- }, z.core.$strict>, z.ZodObject<{
180
- kind: z.ZodLiteral<"error">;
181
- message: z.ZodString;
182
- stepName: z.ZodString;
183
- eventId: z.ZodUUID;
184
- sessionId: z.ZodUUID;
185
- name: z.ZodString;
186
- occurredAt: z.ZodISODateTime;
187
- mode: z.ZodOptional<z.ZodLiteral<"verification">>;
188
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
189
- }, z.core.$strict>], "kind">>;
190
- }, z.core.$strict>;
191
- export declare const validationClassSchema: z.ZodEnum<{
192
- unknown_version: "unknown_version";
193
- invalid_schema: "invalid_schema";
194
- too_large: "too_large";
195
- future_time: "future_time";
196
- late: "late";
197
- }>;
198
- /**
199
- * `expired` is ingestion's, never `validateEventBatch`'s: an event whose day
200
- * has left the platform's raw hot window is refused alone, the rest of its
201
- * batch stored, because its evidence would not outlive the hour
202
- * ([spec/data.md] § Validation). The window is the platform's to set, so the
203
- * contract names the class and holds no age.
204
- */
205
- export declare const rejectionClassSchema: z.ZodEnum<{
206
- unknown_version: "unknown_version";
207
- invalid_schema: "invalid_schema";
208
- too_large: "too_large";
209
- future_time: "future_time";
210
- expired: "expired";
211
- }>;
212
- /**
213
- * The tag sighting: which GA4, Meta and Google Ads tags the page requested
214
- * around a conversion, carried in that conversion's `context` under
215
- * `TAG_SIGHTINGS_CONTEXT_KEY` ([spec/capture.md] § Tag sightings). The
216
- * envelope does not validate it — `context` stays the free-form bag it is —
217
- * so a platform pinned at any 1.x accepts a conversion carrying it; the
218
- * platform parses it with `tagSightingReportSchema`, and a value that fails
219
- * is no report.
220
- */
221
- export declare const TAG_SIGHTINGS_CONTEXT_KEY = "__tl.tags";
222
- export declare const MAX_TAG_SIGHTINGS = 16;
223
- export declare const tagSightingKinds: readonly ["ga4", "meta", "google_ads"];
224
- export type TagSightingKind = (typeof tagSightingKinds)[number];
225
- /** Source strings, so the bundle can inline them and both sides build one pattern. */
226
- export declare const TAG_ID_PATTERNS: Readonly<Record<TagSightingKind, string>>;
227
- export declare const TAG_EVENT_PATTERN = "^[A-Za-z0-9_]{1,64}$";
228
- export declare const tagSightingSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
229
- kind: z.ZodLiteral<"ga4">;
230
- id: z.ZodString;
231
- event: z.ZodNull;
232
- }, z.core.$strict>, z.ZodObject<{
233
- kind: z.ZodLiteral<"meta">;
234
- id: z.ZodString;
235
- event: z.ZodNullable<z.ZodString>;
236
- }, z.core.$strict>, z.ZodObject<{
237
- kind: z.ZodLiteral<"google_ads">;
238
- id: z.ZodString;
239
- event: z.ZodNull;
240
- }, z.core.$strict>], "kind">;
241
- export declare const tagSightingReportSchema: z.ZodObject<{
242
- complete: z.ZodBoolean;
243
- sightings: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
244
- kind: z.ZodLiteral<"ga4">;
245
- id: z.ZodString;
246
- event: z.ZodNull;
247
- }, z.core.$strict>, z.ZodObject<{
248
- kind: z.ZodLiteral<"meta">;
249
- id: z.ZodString;
250
- event: z.ZodNullable<z.ZodString>;
251
- }, z.core.$strict>, z.ZodObject<{
252
- kind: z.ZodLiteral<"google_ads">;
253
- id: z.ZodString;
254
- event: z.ZodNull;
255
- }, z.core.$strict>], "kind">>;
256
- unread: z.ZodOptional<z.ZodArray<z.ZodEnum<{
257
- ga4: "ga4";
258
- meta: "meta";
259
- google_ads: "google_ads";
260
- }>>>;
261
- }, z.core.$strict>;
262
- export type TagSighting = z.infer<typeof tagSightingSchema>;
263
- export type TagSightingReport = z.infer<typeof tagSightingReportSchema>;
264
- export type EventId = z.infer<typeof eventIdSchema>;
265
- export type SessionId = z.infer<typeof sessionIdSchema>;
266
- export type EventName = z.infer<typeof eventNameSchema>;
267
- export type EventMode = z.infer<typeof eventModeSchema>;
268
- export type EventContext = z.infer<typeof contextSchema>;
269
- export type Utm = z.infer<typeof utmSchema>;
270
- export type Device = z.infer<typeof deviceSchema>;
271
- export type SessionStartEvent = z.infer<typeof sessionStartEventSchema>;
272
- export type StepEvent = z.infer<typeof stepEventSchema>;
273
- export type ConversionEvent = z.infer<typeof conversionEventSchema>;
274
- export type ErrorEvent = z.infer<typeof errorEventSchema>;
275
- export type Event = z.infer<typeof eventSchema>;
276
- export type EventBatch = z.infer<typeof eventBatchSchema>;
277
- export type ValidationClass = z.infer<typeof validationClassSchema>;
278
- export type RejectionClass = z.infer<typeof rejectionClassSchema>;
279
- export interface LateEventFlag {
280
- classification: "late";
281
- eventId: EventId;
282
- }
283
- export type EventBatchValidationResult = {
284
- accepted: true;
285
- batch: EventBatch;
286
- flags: readonly LateEventFlag[];
287
- } | {
288
- accepted: false;
289
- classification: RejectionClass;
290
- };
291
- export declare function validateEventBatch(input: unknown, clock: {
292
- now(): Date;
293
- }): EventBatchValidationResult;
1
+ export * from "./limits.js";
2
+ export * from "./schema.js";
294
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,sBAAsB,EAAG,CAAU,CAAC;AACjD,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,eAAe,QAAa,CAAC;AAC1C,eAAO,MAAM,iBAAiB,QAAW,CAAC;AAC1C,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,eAAO,MAAM,mBAAmB,QAAgB,CAAC;AACjD,eAAO,MAAM,aAAa,QAA0B,CAAC;AAiBrD,eAAO,MAAM,aAAa,WAAa,CAAC;AACxC,eAAO,MAAM,eAAe,WAAa,CAAC;AAC1C,eAAO,MAAM,eAAe,aAA6C,CAAC;AAC1E,eAAO,MAAM,gBAAgB,kBAAmC,CAAC;AACjE,eAAO,MAAM,eAAe,8BAA4B,CAAC;AACzD,eAAO,MAAM,aAAa,2CAOvB,CAAC;AAWJ,eAAO,MAAM,SAAS;;;;;;kBAMpB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;EAA0C,CAAC;AAEpE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;kBAOlC,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;;kBAG1B,CAAC;AAEH,eAAO,MA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AI,CAAC;IACf,KAAK,EAAE,UAAU,CAAC;IAClB,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;CACjC,GACD;IACE,QAAQ,EAAE,KAAK,CAAC;IAChB,cAAc,EAAE,cAAc,CAAC;CAChC,CAAC;AAYN,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,EACd,KAAK,EAAE;IAAE,GAAG,IAAI,IAAI,CAAA;CAAE,GACrB,0BAA0B,CA8B5B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,191 +1,3 @@
1
- import { z } from "zod";
2
- export const EVENT_ENVELOPE_VERSION = 1;
3
- export const MAX_BATCH_EVENTS = 50;
4
- export const MAX_BATCH_BYTES = 256 * 1024;
5
- export const MAX_CONTEXT_BYTES = 8 * 1024;
6
- export const MAX_ERROR_MESSAGE_BYTES = 1024;
7
- export const FUTURE_TOLERANCE_MS = 5 * 60 * 1000;
8
- export const LATE_AFTER_MS = 7 * 24 * 60 * 60 * 1000;
9
- const textEncoder = new TextEncoder();
10
- function utf8ByteLength(value) {
11
- return textEncoder.encode(value).byteLength;
12
- }
13
- function serializedByteLength(value) {
14
- try {
15
- const serialized = JSON.stringify(value);
16
- return serialized === undefined ? undefined : utf8ByteLength(serialized);
17
- }
18
- catch {
19
- return undefined;
20
- }
21
- }
22
- export const eventIdSchema = z.uuidv7();
23
- export const sessionIdSchema = z.uuidv7();
24
- export const eventNameSchema = z.string().regex(/^[a-z][a-z0-9_]{0,63}$/);
25
- export const occurredAtSchema = z.iso.datetime({ precision: 3 });
26
- export const eventModeSchema = z.literal("verification");
27
- export const contextSchema = z
28
- .record(z.string(), z.json())
29
- .refine((context) => (serializedByteLength(context) ?? Number.POSITIVE_INFINITY) <=
30
- MAX_CONTEXT_BYTES, { message: `context must serialize to at most ${MAX_CONTEXT_BYTES} bytes` });
31
- const commonEventFields = {
32
- eventId: eventIdSchema,
33
- sessionId: sessionIdSchema,
34
- name: eventNameSchema,
35
- occurredAt: occurredAtSchema,
36
- mode: eventModeSchema.optional(),
37
- context: contextSchema.optional(),
38
- };
39
- export const utmSchema = z.strictObject({
40
- source: z.string().optional(),
41
- medium: z.string().optional(),
42
- campaign: z.string().optional(),
43
- term: z.string().optional(),
44
- content: z.string().optional(),
45
- });
46
- export const deviceSchema = z.enum(["desktop", "mobile", "tablet"]);
47
- export const sessionStartEventSchema = z.strictObject({
48
- ...commonEventFields,
49
- kind: z.literal("session_start"),
50
- referrer: z.string().optional(),
51
- utm: utmSchema,
52
- landingPage: z.string(),
53
- device: deviceSchema,
54
- });
55
- export const stepEventSchema = z.strictObject({
56
- ...commonEventFields,
57
- kind: z.literal("step"),
58
- });
59
- export const currencySchema = z.string().regex(/^[A-Z]{3}$/);
60
- export const conversionEventSchema = z.strictObject({
61
- ...commonEventFields,
62
- kind: z.literal("conversion"),
63
- identifier: z.string().min(1).max(256),
64
- value: z.number().nonnegative().optional(),
65
- currency: currencySchema.optional(),
66
- });
67
- export const errorMessageSchema = z
68
- .string()
69
- .refine((message) => utf8ByteLength(message) <= MAX_ERROR_MESSAGE_BYTES, {
70
- message: `message must be at most ${MAX_ERROR_MESSAGE_BYTES} bytes`,
71
- });
72
- export const errorEventSchema = z.strictObject({
73
- ...commonEventFields,
74
- kind: z.literal("error"),
75
- message: errorMessageSchema,
76
- stepName: eventNameSchema,
77
- });
78
- export const eventSchema = z.discriminatedUnion("kind", [
79
- sessionStartEventSchema,
80
- stepEventSchema,
81
- conversionEventSchema,
82
- errorEventSchema,
83
- ]);
84
- export const eventBatchSchema = z.strictObject({
85
- v: z.literal(EVENT_ENVELOPE_VERSION),
86
- events: z.array(eventSchema).max(MAX_BATCH_EVENTS),
87
- });
88
- export const validationClassSchema = z.enum([
89
- "unknown_version",
90
- "invalid_schema",
91
- "too_large",
92
- "future_time",
93
- "late",
94
- ]);
95
- /**
96
- * `expired` is ingestion's, never `validateEventBatch`'s: an event whose day
97
- * has left the platform's raw hot window is refused alone, the rest of its
98
- * batch stored, because its evidence would not outlive the hour
99
- * ([spec/data.md] § Validation). The window is the platform's to set, so the
100
- * contract names the class and holds no age.
101
- */
102
- export const rejectionClassSchema = z.enum([
103
- "unknown_version",
104
- "invalid_schema",
105
- "too_large",
106
- "future_time",
107
- "expired",
108
- ]);
109
- /**
110
- * The tag sighting: which GA4, Meta and Google Ads tags the page requested
111
- * around a conversion, carried in that conversion's `context` under
112
- * `TAG_SIGHTINGS_CONTEXT_KEY` ([spec/capture.md] § Tag sightings). The
113
- * envelope does not validate it — `context` stays the free-form bag it is —
114
- * so a platform pinned at any 1.x accepts a conversion carrying it; the
115
- * platform parses it with `tagSightingReportSchema`, and a value that fails
116
- * is no report.
117
- */
118
- export const TAG_SIGHTINGS_CONTEXT_KEY = "__tl.tags";
119
- export const MAX_TAG_SIGHTINGS = 16;
120
- export const tagSightingKinds = ["ga4", "meta", "google_ads"];
121
- /** Source strings, so the bundle can inline them and both sides build one pattern. */
122
- export const TAG_ID_PATTERNS = {
123
- ga4: "^G-[A-Z0-9]{4,15}$",
124
- meta: "^[0-9]{6,20}$",
125
- google_ads: "^AW-[0-9]{6,15}(?:/[A-Za-z0-9_-]{1,64})?$",
126
- };
127
- export const TAG_EVENT_PATTERN = "^[A-Za-z0-9_]{1,64}$";
128
- const tagId = (kind) => z.string().regex(new RegExp(TAG_ID_PATTERNS[kind]));
129
- export const tagSightingSchema = z.discriminatedUnion("kind", [
130
- z.strictObject({ kind: z.literal("ga4"), id: tagId("ga4"), event: z.null() }),
131
- z.strictObject({
132
- kind: z.literal("meta"),
133
- id: tagId("meta"),
134
- event: z.string().regex(new RegExp(TAG_EVENT_PATTERN)).nullable(),
135
- }),
136
- z.strictObject({
137
- kind: z.literal("google_ads"),
138
- id: tagId("google_ads"),
139
- event: z.null(),
140
- }),
141
- ]);
142
- export const tagSightingReportSchema = z.strictObject({
143
- /** False when the conversion left before its window closed, or more was sighted than fits. */
144
- complete: z.boolean(),
145
- sightings: z.array(tagSightingSchema).max(MAX_TAG_SIGHTINGS),
146
- /**
147
- * From 1.2.0, in every report whose window the runtime watched whole: each
148
- * kind the page requested inside the window whose tag the runtime could
149
- * not read, once. A report without it could not tell.
150
- */
151
- unread: z
152
- .array(z.enum(tagSightingKinds))
153
- .max(tagSightingKinds.length)
154
- .refine((kinds) => new Set(kinds).size === kinds.length, {
155
- message: "each kind at most once",
156
- })
157
- .optional(),
158
- });
159
- function hasUnknownNumericVersion(input) {
160
- return (typeof input === "object" &&
161
- input !== null &&
162
- "v" in input &&
163
- typeof input.v === "number" &&
164
- input.v !== EVENT_ENVELOPE_VERSION);
165
- }
166
- export function validateEventBatch(input, clock) {
167
- const bodyBytes = serializedByteLength(input);
168
- if (bodyBytes !== undefined && bodyBytes > MAX_BATCH_BYTES) {
169
- return { accepted: false, classification: "too_large" };
170
- }
171
- if (hasUnknownNumericVersion(input)) {
172
- return { accepted: false, classification: "unknown_version" };
173
- }
174
- const parsed = eventBatchSchema.safeParse(input);
175
- if (!parsed.success) {
176
- return { accepted: false, classification: "invalid_schema" };
177
- }
178
- const now = clock.now().getTime();
179
- const flags = [];
180
- for (const event of parsed.data.events) {
181
- const occurredAt = new Date(event.occurredAt).getTime();
182
- if (occurredAt > now + FUTURE_TOLERANCE_MS) {
183
- return { accepted: false, classification: "future_time" };
184
- }
185
- if (occurredAt < now - LATE_AFTER_MS) {
186
- flags.push({ classification: "late", eventId: event.eventId });
187
- }
188
- }
189
- return { accepted: true, batch: parsed.data, flags };
190
- }
1
+ export * from "./limits.js";
2
+ export * from "./schema.js";
191
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,sBAAsB,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AE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;QAC5D,CAAC;QAED,IAAI,UAAU,GAAG,GAAG,GAAG,aAAa,EAAE,CAAC;YACrC,KAAK,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AACvD,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The envelope's limits and the tag sighting's constants, apart from the
3
+ * schemas: a runtime imports only these, and a module that builds no zod
4
+ * schema is one a bundler can keep while it drops `schema.ts` — and zod with
5
+ * it — from a bundle that never validates.
6
+ */
7
+ export declare const EVENT_ENVELOPE_VERSION: 1;
8
+ export declare const MAX_BATCH_EVENTS = 50;
9
+ export declare const MAX_BATCH_BYTES: number;
10
+ export declare const MAX_CONTEXT_BYTES: number;
11
+ export declare const MAX_ERROR_MESSAGE_BYTES = 1024;
12
+ export declare const FUTURE_TOLERANCE_MS: number;
13
+ export declare const LATE_AFTER_MS: number;
14
+ /**
15
+ * The items a conversion or a step carries ([spec/capture.md] § The
16
+ * conversion path): the largest conversion these allow is under 27 KB, so a
17
+ * second fits beside it in the runtime's 64 KiB keepalive budget.
18
+ */
19
+ export declare const MAX_ITEMS = 100;
20
+ export declare const MAX_ITEMS_BYTES: number;
21
+ export declare const MAX_ITEM_TEXT_LENGTH = 256;
22
+ /**
23
+ * The tag sighting: which GA4, Meta and Google Ads tags the page requested
24
+ * around a conversion, carried in that conversion's `context` under
25
+ * `TAG_SIGHTINGS_CONTEXT_KEY` ([spec/capture.md] § Tag sightings). The
26
+ * envelope does not validate it — `context` stays the free-form bag it is —
27
+ * so a platform pinned at any 1.x accepts a conversion carrying it; the
28
+ * platform parses it with `tagSightingReportSchema`, and a value that fails
29
+ * is no report.
30
+ */
31
+ export declare const TAG_SIGHTINGS_CONTEXT_KEY = "__tl.tags";
32
+ export declare const MAX_TAG_SIGHTINGS = 16;
33
+ export declare const tagSightingKinds: readonly ["ga4", "meta", "google_ads"];
34
+ export type TagSightingKind = (typeof tagSightingKinds)[number];
35
+ /** Source strings, so the bundle can inline them and both sides build one pattern. */
36
+ export declare const TAG_ID_PATTERNS: Readonly<Record<TagSightingKind, string>>;
37
+ export declare const TAG_EVENT_PATTERN = "^[A-Za-z0-9_]{1,64}$";
38
+ //# sourceMappingURL=limits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,EAAG,CAAU,CAAC;AACjD,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,eAAe,QAAa,CAAC;AAC1C,eAAO,MAAM,iBAAiB,QAAW,CAAC;AAC1C,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,eAAO,MAAM,mBAAmB,QAAgB,CAAC;AACjD,eAAO,MAAM,aAAa,QAA0B,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,SAAS,MAAM,CAAC;AAC7B,eAAO,MAAM,eAAe,QAAY,CAAC;AACzC,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,cAAc,CAAC;AACrD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,gBAAgB,wCAAyC,CAAC;AACvE,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAChE,sFAAsF;AACtF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAIrE,CAAC;AACF,eAAO,MAAM,iBAAiB,yBAAyB,CAAC"}
package/dist/limits.js ADDED
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The envelope's limits and the tag sighting's constants, apart from the
3
+ * schemas: a runtime imports only these, and a module that builds no zod
4
+ * schema is one a bundler can keep while it drops `schema.ts` — and zod with
5
+ * it — from a bundle that never validates.
6
+ */
7
+ export const EVENT_ENVELOPE_VERSION = 1;
8
+ export const MAX_BATCH_EVENTS = 50;
9
+ export const MAX_BATCH_BYTES = 256 * 1024;
10
+ export const MAX_CONTEXT_BYTES = 8 * 1024;
11
+ export const MAX_ERROR_MESSAGE_BYTES = 1024;
12
+ export const FUTURE_TOLERANCE_MS = 5 * 60 * 1000;
13
+ export const LATE_AFTER_MS = 7 * 24 * 60 * 60 * 1000;
14
+ /**
15
+ * The items a conversion or a step carries ([spec/capture.md] § The
16
+ * conversion path): the largest conversion these allow is under 27 KB, so a
17
+ * second fits beside it in the runtime's 64 KiB keepalive budget.
18
+ */
19
+ export const MAX_ITEMS = 100;
20
+ export const MAX_ITEMS_BYTES = 16 * 1024;
21
+ export const MAX_ITEM_TEXT_LENGTH = 256;
22
+ /**
23
+ * The tag sighting: which GA4, Meta and Google Ads tags the page requested
24
+ * around a conversion, carried in that conversion's `context` under
25
+ * `TAG_SIGHTINGS_CONTEXT_KEY` ([spec/capture.md] § Tag sightings). The
26
+ * envelope does not validate it — `context` stays the free-form bag it is —
27
+ * so a platform pinned at any 1.x accepts a conversion carrying it; the
28
+ * platform parses it with `tagSightingReportSchema`, and a value that fails
29
+ * is no report.
30
+ */
31
+ export const TAG_SIGHTINGS_CONTEXT_KEY = "__tl.tags";
32
+ export const MAX_TAG_SIGHTINGS = 16;
33
+ export const tagSightingKinds = ["ga4", "meta", "google_ads"];
34
+ /** Source strings, so the bundle can inline them and both sides build one pattern. */
35
+ export const TAG_ID_PATTERNS = {
36
+ ga4: "^G-[A-Z0-9]{4,15}$",
37
+ meta: "^[0-9]{6,20}$",
38
+ google_ads: "^AW-[0-9]{6,15}(?:/[A-Za-z0-9_-]{1,64})?$",
39
+ };
40
+ export const TAG_EVENT_PATTERN = "^[A-Za-z0-9_]{1,64}$";
41
+ //# sourceMappingURL=limits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limits.js","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAU,CAAC;AACjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,GAAG,IAAI,CAAC;AAC1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,GAAG,IAAI,CAAC;AAC1C,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAC5C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AACjD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAErD;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAC7B,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,CAAC;AACzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAExC;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,WAAW,CAAC;AACrD,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAU,CAAC;AAEvE,sFAAsF;AACtF,MAAM,CAAC,MAAM,eAAe,GAA8C;IACxE,GAAG,EAAE,oBAAoB;IACzB,IAAI,EAAE,eAAe;IACrB,UAAU,EAAE,2CAA2C;CACxD,CAAC;AACF,MAAM,CAAC,MAAM,iBAAiB,GAAG,sBAAsB,CAAC"}
@@ -0,0 +1,336 @@
1
+ import { z } from "zod";
2
+ export declare const eventIdSchema: z.ZodUUID;
3
+ export declare const sessionIdSchema: z.ZodUUID;
4
+ export declare const eventNameSchema: z.ZodString;
5
+ export declare const occurredAtSchema: z.ZodISODateTime;
6
+ export declare const eventModeSchema: z.ZodLiteral<"verification">;
7
+ export declare const contextSchema: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
8
+ export declare const utmSchema: z.ZodObject<{
9
+ source: z.ZodOptional<z.ZodString>;
10
+ medium: z.ZodOptional<z.ZodString>;
11
+ campaign: z.ZodOptional<z.ZodString>;
12
+ term: z.ZodOptional<z.ZodString>;
13
+ content: z.ZodOptional<z.ZodString>;
14
+ }, z.core.$strict>;
15
+ export declare const deviceSchema: z.ZodEnum<{
16
+ desktop: "desktop";
17
+ mobile: "mobile";
18
+ tablet: "tablet";
19
+ }>;
20
+ export declare const sessionStartEventSchema: z.ZodObject<{
21
+ kind: z.ZodLiteral<"session_start">;
22
+ referrer: z.ZodOptional<z.ZodString>;
23
+ utm: z.ZodObject<{
24
+ source: z.ZodOptional<z.ZodString>;
25
+ medium: z.ZodOptional<z.ZodString>;
26
+ campaign: z.ZodOptional<z.ZodString>;
27
+ term: z.ZodOptional<z.ZodString>;
28
+ content: z.ZodOptional<z.ZodString>;
29
+ }, z.core.$strict>;
30
+ landingPage: z.ZodString;
31
+ device: z.ZodEnum<{
32
+ desktop: "desktop";
33
+ mobile: "mobile";
34
+ tablet: "tablet";
35
+ }>;
36
+ eventId: z.ZodUUID;
37
+ sessionId: z.ZodUUID;
38
+ name: z.ZodString;
39
+ occurredAt: z.ZodISODateTime;
40
+ mode: z.ZodOptional<z.ZodLiteral<"verification">>;
41
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
42
+ }, z.core.$strict>;
43
+ export declare const itemSchema: z.ZodObject<{
44
+ id: z.ZodString;
45
+ name: z.ZodString;
46
+ category: z.ZodOptional<z.ZodString>;
47
+ quantity: z.ZodNumber;
48
+ price: z.ZodOptional<z.ZodNumber>;
49
+ }, z.core.$strict>;
50
+ export declare const itemsSchema: z.ZodArray<z.ZodObject<{
51
+ id: z.ZodString;
52
+ name: z.ZodString;
53
+ category: z.ZodOptional<z.ZodString>;
54
+ quantity: z.ZodNumber;
55
+ price: z.ZodOptional<z.ZodNumber>;
56
+ }, z.core.$strict>>;
57
+ /** A calendar day, leap years included. */
58
+ export declare const scheduledForSchema: z.ZodISODate;
59
+ export declare const stepEventSchema: z.ZodObject<{
60
+ kind: z.ZodLiteral<"step">;
61
+ items: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodObject<{
62
+ id: z.ZodString;
63
+ name: z.ZodString;
64
+ category: z.ZodOptional<z.ZodString>;
65
+ quantity: z.ZodNumber;
66
+ price: z.ZodOptional<z.ZodNumber>;
67
+ }, z.core.$strict>>>>;
68
+ eventId: z.ZodUUID;
69
+ sessionId: z.ZodUUID;
70
+ name: z.ZodString;
71
+ occurredAt: z.ZodISODateTime;
72
+ mode: z.ZodOptional<z.ZodLiteral<"verification">>;
73
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
74
+ }, z.core.$strict>;
75
+ export declare const currencySchema: z.ZodString;
76
+ export declare const conversionEventSchema: z.ZodObject<{
77
+ kind: z.ZodLiteral<"conversion">;
78
+ identifier: z.ZodString;
79
+ value: z.ZodOptional<z.ZodNumber>;
80
+ currency: z.ZodOptional<z.ZodString>;
81
+ items: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodObject<{
82
+ id: z.ZodString;
83
+ name: z.ZodString;
84
+ category: z.ZodOptional<z.ZodString>;
85
+ quantity: z.ZodNumber;
86
+ price: z.ZodOptional<z.ZodNumber>;
87
+ }, z.core.$strict>>>>;
88
+ scheduledFor: z.ZodCatch<z.ZodOptional<z.ZodISODate>>;
89
+ recurring: z.ZodCatch<z.ZodOptional<z.ZodBoolean>>;
90
+ eventId: z.ZodUUID;
91
+ sessionId: z.ZodUUID;
92
+ name: z.ZodString;
93
+ occurredAt: z.ZodISODateTime;
94
+ mode: z.ZodOptional<z.ZodLiteral<"verification">>;
95
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
96
+ }, z.core.$strict>;
97
+ export declare const errorMessageSchema: z.ZodString;
98
+ export declare const errorEventSchema: z.ZodObject<{
99
+ kind: z.ZodLiteral<"error">;
100
+ message: z.ZodString;
101
+ stepName: z.ZodString;
102
+ eventId: z.ZodUUID;
103
+ sessionId: z.ZodUUID;
104
+ name: z.ZodString;
105
+ occurredAt: z.ZodISODateTime;
106
+ mode: z.ZodOptional<z.ZodLiteral<"verification">>;
107
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
108
+ }, z.core.$strict>;
109
+ export declare const eventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
110
+ kind: z.ZodLiteral<"session_start">;
111
+ referrer: z.ZodOptional<z.ZodString>;
112
+ utm: z.ZodObject<{
113
+ source: z.ZodOptional<z.ZodString>;
114
+ medium: z.ZodOptional<z.ZodString>;
115
+ campaign: z.ZodOptional<z.ZodString>;
116
+ term: z.ZodOptional<z.ZodString>;
117
+ content: z.ZodOptional<z.ZodString>;
118
+ }, z.core.$strict>;
119
+ landingPage: z.ZodString;
120
+ device: z.ZodEnum<{
121
+ desktop: "desktop";
122
+ mobile: "mobile";
123
+ tablet: "tablet";
124
+ }>;
125
+ eventId: z.ZodUUID;
126
+ sessionId: z.ZodUUID;
127
+ name: z.ZodString;
128
+ occurredAt: z.ZodISODateTime;
129
+ mode: z.ZodOptional<z.ZodLiteral<"verification">>;
130
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
131
+ }, z.core.$strict>, z.ZodObject<{
132
+ kind: z.ZodLiteral<"step">;
133
+ items: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodObject<{
134
+ id: z.ZodString;
135
+ name: z.ZodString;
136
+ category: z.ZodOptional<z.ZodString>;
137
+ quantity: z.ZodNumber;
138
+ price: z.ZodOptional<z.ZodNumber>;
139
+ }, z.core.$strict>>>>;
140
+ eventId: z.ZodUUID;
141
+ sessionId: z.ZodUUID;
142
+ name: z.ZodString;
143
+ occurredAt: z.ZodISODateTime;
144
+ mode: z.ZodOptional<z.ZodLiteral<"verification">>;
145
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
146
+ }, z.core.$strict>, z.ZodObject<{
147
+ kind: z.ZodLiteral<"conversion">;
148
+ identifier: z.ZodString;
149
+ value: z.ZodOptional<z.ZodNumber>;
150
+ currency: z.ZodOptional<z.ZodString>;
151
+ items: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodObject<{
152
+ id: z.ZodString;
153
+ name: z.ZodString;
154
+ category: z.ZodOptional<z.ZodString>;
155
+ quantity: z.ZodNumber;
156
+ price: z.ZodOptional<z.ZodNumber>;
157
+ }, z.core.$strict>>>>;
158
+ scheduledFor: z.ZodCatch<z.ZodOptional<z.ZodISODate>>;
159
+ recurring: z.ZodCatch<z.ZodOptional<z.ZodBoolean>>;
160
+ eventId: z.ZodUUID;
161
+ sessionId: z.ZodUUID;
162
+ name: z.ZodString;
163
+ occurredAt: z.ZodISODateTime;
164
+ mode: z.ZodOptional<z.ZodLiteral<"verification">>;
165
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
166
+ }, z.core.$strict>, z.ZodObject<{
167
+ kind: z.ZodLiteral<"error">;
168
+ message: z.ZodString;
169
+ stepName: z.ZodString;
170
+ eventId: z.ZodUUID;
171
+ sessionId: z.ZodUUID;
172
+ name: z.ZodString;
173
+ occurredAt: z.ZodISODateTime;
174
+ mode: z.ZodOptional<z.ZodLiteral<"verification">>;
175
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
176
+ }, z.core.$strict>], "kind">;
177
+ export declare const eventBatchSchema: z.ZodObject<{
178
+ v: z.ZodLiteral<1>;
179
+ events: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
180
+ kind: z.ZodLiteral<"session_start">;
181
+ referrer: z.ZodOptional<z.ZodString>;
182
+ utm: z.ZodObject<{
183
+ source: z.ZodOptional<z.ZodString>;
184
+ medium: z.ZodOptional<z.ZodString>;
185
+ campaign: z.ZodOptional<z.ZodString>;
186
+ term: z.ZodOptional<z.ZodString>;
187
+ content: z.ZodOptional<z.ZodString>;
188
+ }, z.core.$strict>;
189
+ landingPage: z.ZodString;
190
+ device: z.ZodEnum<{
191
+ desktop: "desktop";
192
+ mobile: "mobile";
193
+ tablet: "tablet";
194
+ }>;
195
+ eventId: z.ZodUUID;
196
+ sessionId: z.ZodUUID;
197
+ name: z.ZodString;
198
+ occurredAt: z.ZodISODateTime;
199
+ mode: z.ZodOptional<z.ZodLiteral<"verification">>;
200
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
201
+ }, z.core.$strict>, z.ZodObject<{
202
+ kind: z.ZodLiteral<"step">;
203
+ items: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodObject<{
204
+ id: z.ZodString;
205
+ name: z.ZodString;
206
+ category: z.ZodOptional<z.ZodString>;
207
+ quantity: z.ZodNumber;
208
+ price: z.ZodOptional<z.ZodNumber>;
209
+ }, z.core.$strict>>>>;
210
+ eventId: z.ZodUUID;
211
+ sessionId: z.ZodUUID;
212
+ name: z.ZodString;
213
+ occurredAt: z.ZodISODateTime;
214
+ mode: z.ZodOptional<z.ZodLiteral<"verification">>;
215
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
216
+ }, z.core.$strict>, z.ZodObject<{
217
+ kind: z.ZodLiteral<"conversion">;
218
+ identifier: z.ZodString;
219
+ value: z.ZodOptional<z.ZodNumber>;
220
+ currency: z.ZodOptional<z.ZodString>;
221
+ items: z.ZodCatch<z.ZodOptional<z.ZodArray<z.ZodObject<{
222
+ id: z.ZodString;
223
+ name: z.ZodString;
224
+ category: z.ZodOptional<z.ZodString>;
225
+ quantity: z.ZodNumber;
226
+ price: z.ZodOptional<z.ZodNumber>;
227
+ }, z.core.$strict>>>>;
228
+ scheduledFor: z.ZodCatch<z.ZodOptional<z.ZodISODate>>;
229
+ recurring: z.ZodCatch<z.ZodOptional<z.ZodBoolean>>;
230
+ eventId: z.ZodUUID;
231
+ sessionId: z.ZodUUID;
232
+ name: z.ZodString;
233
+ occurredAt: z.ZodISODateTime;
234
+ mode: z.ZodOptional<z.ZodLiteral<"verification">>;
235
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
236
+ }, z.core.$strict>, z.ZodObject<{
237
+ kind: z.ZodLiteral<"error">;
238
+ message: z.ZodString;
239
+ stepName: z.ZodString;
240
+ eventId: z.ZodUUID;
241
+ sessionId: z.ZodUUID;
242
+ name: z.ZodString;
243
+ occurredAt: z.ZodISODateTime;
244
+ mode: z.ZodOptional<z.ZodLiteral<"verification">>;
245
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
246
+ }, z.core.$strict>], "kind">>;
247
+ }, z.core.$strict>;
248
+ export declare const validationClassSchema: z.ZodEnum<{
249
+ unknown_version: "unknown_version";
250
+ invalid_schema: "invalid_schema";
251
+ too_large: "too_large";
252
+ future_time: "future_time";
253
+ late: "late";
254
+ }>;
255
+ /**
256
+ * `expired` is ingestion's, never `validateEventBatch`'s: an event whose day
257
+ * has left the platform's raw hot window is refused alone, the rest of its
258
+ * batch stored, because its evidence would not outlive the hour
259
+ * ([spec/data.md] § Validation). The window is the platform's to set, so the
260
+ * contract names the class and holds no age.
261
+ */
262
+ export declare const rejectionClassSchema: z.ZodEnum<{
263
+ unknown_version: "unknown_version";
264
+ invalid_schema: "invalid_schema";
265
+ too_large: "too_large";
266
+ future_time: "future_time";
267
+ expired: "expired";
268
+ }>;
269
+ export declare const tagSightingSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
270
+ kind: z.ZodLiteral<"ga4">;
271
+ id: z.ZodString;
272
+ event: z.ZodNull;
273
+ }, z.core.$strict>, z.ZodObject<{
274
+ kind: z.ZodLiteral<"meta">;
275
+ id: z.ZodString;
276
+ event: z.ZodNullable<z.ZodString>;
277
+ }, z.core.$strict>, z.ZodObject<{
278
+ kind: z.ZodLiteral<"google_ads">;
279
+ id: z.ZodString;
280
+ event: z.ZodNull;
281
+ }, z.core.$strict>], "kind">;
282
+ export declare const tagSightingReportSchema: z.ZodObject<{
283
+ complete: z.ZodBoolean;
284
+ sightings: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
285
+ kind: z.ZodLiteral<"ga4">;
286
+ id: z.ZodString;
287
+ event: z.ZodNull;
288
+ }, z.core.$strict>, z.ZodObject<{
289
+ kind: z.ZodLiteral<"meta">;
290
+ id: z.ZodString;
291
+ event: z.ZodNullable<z.ZodString>;
292
+ }, z.core.$strict>, z.ZodObject<{
293
+ kind: z.ZodLiteral<"google_ads">;
294
+ id: z.ZodString;
295
+ event: z.ZodNull;
296
+ }, z.core.$strict>], "kind">>;
297
+ unread: z.ZodOptional<z.ZodArray<z.ZodEnum<{
298
+ ga4: "ga4";
299
+ meta: "meta";
300
+ google_ads: "google_ads";
301
+ }>>>;
302
+ }, z.core.$strict>;
303
+ export type TagSighting = z.infer<typeof tagSightingSchema>;
304
+ export type TagSightingReport = z.infer<typeof tagSightingReportSchema>;
305
+ export type EventId = z.infer<typeof eventIdSchema>;
306
+ export type SessionId = z.infer<typeof sessionIdSchema>;
307
+ export type EventName = z.infer<typeof eventNameSchema>;
308
+ export type EventMode = z.infer<typeof eventModeSchema>;
309
+ export type EventContext = z.infer<typeof contextSchema>;
310
+ export type Utm = z.infer<typeof utmSchema>;
311
+ export type Item = z.infer<typeof itemSchema>;
312
+ export type Device = z.infer<typeof deviceSchema>;
313
+ export type SessionStartEvent = z.infer<typeof sessionStartEventSchema>;
314
+ export type StepEvent = z.infer<typeof stepEventSchema>;
315
+ export type ConversionEvent = z.infer<typeof conversionEventSchema>;
316
+ export type ErrorEvent = z.infer<typeof errorEventSchema>;
317
+ export type Event = z.infer<typeof eventSchema>;
318
+ export type EventBatch = z.infer<typeof eventBatchSchema>;
319
+ export type ValidationClass = z.infer<typeof validationClassSchema>;
320
+ export type RejectionClass = z.infer<typeof rejectionClassSchema>;
321
+ export interface LateEventFlag {
322
+ classification: "late";
323
+ eventId: EventId;
324
+ }
325
+ export type EventBatchValidationResult = {
326
+ accepted: true;
327
+ batch: EventBatch;
328
+ flags: readonly LateEventFlag[];
329
+ } | {
330
+ accepted: false;
331
+ classification: RejectionClass;
332
+ };
333
+ export declare function validateEventBatch(input: unknown, clock: {
334
+ now(): Date;
335
+ }): EventBatchValidationResult;
336
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmCxB,eAAO,MAAM,aAAa,WAAa,CAAC;AACxC,eAAO,MAAM,eAAe,WAAa,CAAC;AAC1C,eAAO,MAAM,eAAe,aAA6C,CAAC;AAC1E,eAAO,MAAM,gBAAgB,kBAAmC,CAAC;AACjE,eAAO,MAAM,eAAe,8BAA4B,CAAC;AACzD,eAAO,MAAM,aAAa,2CAOvB,CAAC;AAWJ,eAAO,MAAM,SAAS;;;;;;kBAMpB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;EAA0C,CAAC;AAEpE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;kBAOlC,CAAC;AAGH,eAAO,MAAM,UAAU;;;;;;kBAOrB,CAAC;AACH,eAAO,MAAM,WAAW;;;;;;mBASrB,CAAC;AACJ,2CAA2C;AAC3C,eAAO,MAAM,kBAAkB,cAAe,CAAC;A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,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,OAAO,EACd,KAAK,EAAE;IAAE,GAAG,IAAI,IAAI,CAAA;CAAE,GACrB,0BAA0B,CA8B5B"}
package/dist/schema.js ADDED
@@ -0,0 +1,192 @@
1
+ import { z } from "zod";
2
+ import { EVENT_ENVELOPE_VERSION, FUTURE_TOLERANCE_MS, LATE_AFTER_MS, MAX_BATCH_BYTES, MAX_BATCH_EVENTS, MAX_CONTEXT_BYTES, MAX_ERROR_MESSAGE_BYTES, MAX_ITEM_TEXT_LENGTH, MAX_ITEMS, MAX_ITEMS_BYTES, MAX_TAG_SIGHTINGS, TAG_EVENT_PATTERN, TAG_ID_PATTERNS, tagSightingKinds, } from "./limits.js";
3
+ const textEncoder = new TextEncoder();
4
+ function utf8ByteLength(value) {
5
+ return textEncoder.encode(value).byteLength;
6
+ }
7
+ function serializedByteLength(value) {
8
+ try {
9
+ const serialized = JSON.stringify(value);
10
+ return serialized === undefined ? undefined : utf8ByteLength(serialized);
11
+ }
12
+ catch {
13
+ return undefined;
14
+ }
15
+ }
16
+ export const eventIdSchema = z.uuidv7();
17
+ export const sessionIdSchema = z.uuidv7();
18
+ export const eventNameSchema = z.string().regex(/^[a-z][a-z0-9_]{0,63}$/);
19
+ export const occurredAtSchema = z.iso.datetime({ precision: 3 });
20
+ export const eventModeSchema = z.literal("verification");
21
+ export const contextSchema = z
22
+ .record(z.string(), z.json())
23
+ .refine((context) => (serializedByteLength(context) ?? Number.POSITIVE_INFINITY) <=
24
+ MAX_CONTEXT_BYTES, { message: `context must serialize to at most ${MAX_CONTEXT_BYTES} bytes` });
25
+ const commonEventFields = {
26
+ eventId: eventIdSchema,
27
+ sessionId: sessionIdSchema,
28
+ name: eventNameSchema,
29
+ occurredAt: occurredAtSchema,
30
+ mode: eventModeSchema.optional(),
31
+ context: contextSchema.optional(),
32
+ };
33
+ export const utmSchema = z.strictObject({
34
+ source: z.string().optional(),
35
+ medium: z.string().optional(),
36
+ campaign: z.string().optional(),
37
+ term: z.string().optional(),
38
+ content: z.string().optional(),
39
+ });
40
+ export const deviceSchema = z.enum(["desktop", "mobile", "tablet"]);
41
+ export const sessionStartEventSchema = z.strictObject({
42
+ ...commonEventFields,
43
+ kind: z.literal("session_start"),
44
+ referrer: z.string().optional(),
45
+ utm: utmSchema,
46
+ landingPage: z.string(),
47
+ device: deviceSchema,
48
+ });
49
+ const itemTextSchema = z.string().min(1).max(MAX_ITEM_TEXT_LENGTH);
50
+ export const itemSchema = z.strictObject({
51
+ id: itemTextSchema,
52
+ name: itemTextSchema,
53
+ category: itemTextSchema.optional(),
54
+ quantity: z.number().int().positive(),
55
+ /** The price of one unit; on a conversion, in its currency. */
56
+ price: z.number().nonnegative().optional(),
57
+ });
58
+ export const itemsSchema = z
59
+ .array(itemSchema)
60
+ .min(1)
61
+ .max(MAX_ITEMS)
62
+ .refine((items) => (serializedByteLength(items) ?? Number.POSITIVE_INFINITY) <=
63
+ MAX_ITEMS_BYTES, { message: `items must serialize to at most ${MAX_ITEMS_BYTES} bytes` });
64
+ /** A calendar day, leap years included. */
65
+ export const scheduledForSchema = z.iso.date();
66
+ /**
67
+ * A malformed new field is read as absent and its event stands: a broken
68
+ * line must never lose an order ([spec/data.md] § Validation).
69
+ */
70
+ const dropped = (schema) => schema.optional().catch(undefined);
71
+ export const stepEventSchema = z.strictObject({
72
+ ...commonEventFields,
73
+ kind: z.literal("step"),
74
+ items: dropped(itemsSchema),
75
+ });
76
+ export const currencySchema = z.string().regex(/^[A-Z]{3}$/);
77
+ export const conversionEventSchema = z.strictObject({
78
+ ...commonEventFields,
79
+ kind: z.literal("conversion"),
80
+ identifier: z.string().min(1).max(256),
81
+ value: z.number().nonnegative().optional(),
82
+ currency: currencySchema.optional(),
83
+ items: dropped(itemsSchema),
84
+ scheduledFor: dropped(scheduledForSchema),
85
+ recurring: dropped(z.boolean()),
86
+ });
87
+ export const errorMessageSchema = z
88
+ .string()
89
+ .refine((message) => utf8ByteLength(message) <= MAX_ERROR_MESSAGE_BYTES, {
90
+ message: `message must be at most ${MAX_ERROR_MESSAGE_BYTES} bytes`,
91
+ });
92
+ export const errorEventSchema = z.strictObject({
93
+ ...commonEventFields,
94
+ kind: z.literal("error"),
95
+ message: errorMessageSchema,
96
+ stepName: eventNameSchema,
97
+ });
98
+ export const eventSchema = z.discriminatedUnion("kind", [
99
+ sessionStartEventSchema,
100
+ stepEventSchema,
101
+ conversionEventSchema,
102
+ errorEventSchema,
103
+ ]);
104
+ export const eventBatchSchema = z.strictObject({
105
+ v: z.literal(EVENT_ENVELOPE_VERSION),
106
+ events: z.array(eventSchema).max(MAX_BATCH_EVENTS),
107
+ });
108
+ export const validationClassSchema = z.enum([
109
+ "unknown_version",
110
+ "invalid_schema",
111
+ "too_large",
112
+ "future_time",
113
+ "late",
114
+ ]);
115
+ /**
116
+ * `expired` is ingestion's, never `validateEventBatch`'s: an event whose day
117
+ * has left the platform's raw hot window is refused alone, the rest of its
118
+ * batch stored, because its evidence would not outlive the hour
119
+ * ([spec/data.md] § Validation). The window is the platform's to set, so the
120
+ * contract names the class and holds no age.
121
+ */
122
+ export const rejectionClassSchema = z.enum([
123
+ "unknown_version",
124
+ "invalid_schema",
125
+ "too_large",
126
+ "future_time",
127
+ "expired",
128
+ ]);
129
+ const tagId = (kind) => z.string().regex(new RegExp(TAG_ID_PATTERNS[kind]));
130
+ export const tagSightingSchema = z.discriminatedUnion("kind", [
131
+ z.strictObject({ kind: z.literal("ga4"), id: tagId("ga4"), event: z.null() }),
132
+ z.strictObject({
133
+ kind: z.literal("meta"),
134
+ id: tagId("meta"),
135
+ event: z.string().regex(new RegExp(TAG_EVENT_PATTERN)).nullable(),
136
+ }),
137
+ z.strictObject({
138
+ kind: z.literal("google_ads"),
139
+ id: tagId("google_ads"),
140
+ event: z.null(),
141
+ }),
142
+ ]);
143
+ export const tagSightingReportSchema = z.strictObject({
144
+ /** False when the conversion left before its window closed, or more was sighted than fits. */
145
+ complete: z.boolean(),
146
+ sightings: z.array(tagSightingSchema).max(MAX_TAG_SIGHTINGS),
147
+ /**
148
+ * From 1.2.0, in every report whose window the runtime watched whole: each
149
+ * kind the page requested inside the window whose tag the runtime could
150
+ * not read, once. A report without it could not tell.
151
+ */
152
+ unread: z
153
+ .array(z.enum(tagSightingKinds))
154
+ .max(tagSightingKinds.length)
155
+ .refine((kinds) => new Set(kinds).size === kinds.length, {
156
+ message: "each kind at most once",
157
+ })
158
+ .optional(),
159
+ });
160
+ function hasUnknownNumericVersion(input) {
161
+ return (typeof input === "object" &&
162
+ input !== null &&
163
+ "v" in input &&
164
+ typeof input.v === "number" &&
165
+ input.v !== EVENT_ENVELOPE_VERSION);
166
+ }
167
+ export function validateEventBatch(input, clock) {
168
+ const bodyBytes = serializedByteLength(input);
169
+ if (bodyBytes !== undefined && bodyBytes > MAX_BATCH_BYTES) {
170
+ return { accepted: false, classification: "too_large" };
171
+ }
172
+ if (hasUnknownNumericVersion(input)) {
173
+ return { accepted: false, classification: "unknown_version" };
174
+ }
175
+ const parsed = eventBatchSchema.safeParse(input);
176
+ if (!parsed.success) {
177
+ return { accepted: false, classification: "invalid_schema" };
178
+ }
179
+ const now = clock.now().getTime();
180
+ const flags = [];
181
+ for (const event of parsed.data.events) {
182
+ const occurredAt = new Date(event.occurredAt).getTime();
183
+ if (occurredAt > now + FUTURE_TOLERANCE_MS) {
184
+ return { accepted: false, classification: "future_time" };
185
+ }
186
+ if (occurredAt < now - LATE_AFTER_MS) {
187
+ flags.push({ classification: "late", eventId: event.eventId });
188
+ }
189
+ }
190
+ return { accepted: true, batch: parsed.data, flags };
191
+ }
192
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,iBAAiB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C,SAAS,CAAC,KAAK,CAAC,CAAC;IACjD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;IAC/D,CAAC;IAED,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;IAClC,MAAM,KAAK,GAAoB,EAAE,CAAC;IAElC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACvC,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC;QACxD,IAAI,UAAU,GAAG,GAAG,GAAG,mBAAmB,EAAE,CAAC;YAC3C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;QAC5D,CAAC;QAED,IAAI,UAAU,GAAG,GAAG,GAAG,aAAa,EAAE,CAAC;YACrC,KAAK,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AACvD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tracelog/event-contract",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "The TraceLog event envelope: one definition of the wire format, its limits and its schemas.",
5
5
  "keywords": [
6
6
  "conversion",