@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/ingest.d.ts
CHANGED
|
@@ -1,86 +1,74 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* `POST /api/track` — the ingest contract.
|
|
6
|
-
*
|
|
7
|
-
* The request shape is shared by both credential modes. The *response* shape
|
|
8
|
-
* is where server-ingest differs: it reports per-event rejections instead of
|
|
9
|
-
* failing a whole batch, because a forwarder that stalls on one malformed row
|
|
10
|
-
* stops forwarding forever.
|
|
11
|
-
*
|
|
12
|
-
* Absorbed from the former internal `@reopt/ingest-contract`; that package is
|
|
13
|
-
* now a deprecated re-export of this module.
|
|
14
|
-
*/
|
|
15
|
-
|
|
1
|
+
import { f as RELEASE_PROPERTY, g as scrollDepthBucket, h as ScrollDepthBucket, i as AutoEventName, m as SCROLL_DEPTH_BUCKETS, n as AUTO_EVENT_PROPERTIES, p as RESERVED_EVENT_NAMES, r as AUTO_EVENT_ROLLUP_KEYS, t as AUTO_EVENT_NAMES } from "./events-BUIeU60t.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//#region src/ingest.d.ts
|
|
16
4
|
/** Hard cap enforced by the route before the body is even parsed. */
|
|
17
5
|
declare const MAX_TRACK_PAYLOAD_BYTES = 512000;
|
|
18
6
|
declare const zTrackPayload: z.ZodObject<{
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
9
|
+
profileId: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
declare const zIdentifyPayload: z.ZodObject<{
|
|
12
|
+
profileId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
13
|
+
firstName: z.ZodOptional<z.ZodString>;
|
|
14
|
+
lastName: z.ZodOptional<z.ZodString>;
|
|
15
|
+
email: z.ZodOptional<z.ZodEmail>;
|
|
16
|
+
avatar: z.ZodOptional<z.ZodURL>;
|
|
17
|
+
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
declare const zIncrementPayload: z.ZodObject<{
|
|
20
|
+
profileId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
21
|
+
property: z.ZodString;
|
|
22
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
declare const zDecrementPayload: z.ZodObject<{
|
|
25
|
+
profileId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
26
|
+
property: z.ZodString;
|
|
27
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
declare const zTrackHandlerPayload: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
30
|
+
eventId: z.ZodUUID;
|
|
31
|
+
timestamp: z.ZodNumber;
|
|
32
|
+
deviceId: z.ZodOptional<z.ZodString>;
|
|
33
|
+
type: z.ZodLiteral<"track">;
|
|
34
|
+
payload: z.ZodObject<{
|
|
19
35
|
name: z.ZodString;
|
|
20
36
|
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
21
37
|
profileId: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
22
|
-
}, z.core.$strip>;
|
|
23
|
-
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
40
|
+
eventId: z.ZodUUID;
|
|
41
|
+
timestamp: z.ZodNumber;
|
|
42
|
+
deviceId: z.ZodOptional<z.ZodString>;
|
|
43
|
+
type: z.ZodLiteral<"identify">;
|
|
44
|
+
payload: z.ZodObject<{
|
|
24
45
|
profileId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
25
46
|
firstName: z.ZodOptional<z.ZodString>;
|
|
26
47
|
lastName: z.ZodOptional<z.ZodString>;
|
|
27
48
|
email: z.ZodOptional<z.ZodEmail>;
|
|
28
49
|
avatar: z.ZodOptional<z.ZodURL>;
|
|
29
50
|
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
30
|
-
}, z.core.$strip>;
|
|
31
|
-
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
53
|
+
eventId: z.ZodUUID;
|
|
54
|
+
timestamp: z.ZodNumber;
|
|
55
|
+
deviceId: z.ZodOptional<z.ZodString>;
|
|
56
|
+
type: z.ZodLiteral<"increment">;
|
|
57
|
+
payload: z.ZodObject<{
|
|
32
58
|
profileId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
33
59
|
property: z.ZodString;
|
|
34
60
|
value: z.ZodOptional<z.ZodNumber>;
|
|
35
|
-
}, z.core.$strip>;
|
|
36
|
-
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
63
|
+
eventId: z.ZodUUID;
|
|
64
|
+
timestamp: z.ZodNumber;
|
|
65
|
+
deviceId: z.ZodOptional<z.ZodString>;
|
|
66
|
+
type: z.ZodLiteral<"decrement">;
|
|
67
|
+
payload: z.ZodObject<{
|
|
37
68
|
profileId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
38
69
|
property: z.ZodString;
|
|
39
70
|
value: z.ZodOptional<z.ZodNumber>;
|
|
40
|
-
}, z.core.$strip>;
|
|
41
|
-
declare const zTrackHandlerPayload: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
42
|
-
eventId: z.ZodUUID;
|
|
43
|
-
timestamp: z.ZodNumber;
|
|
44
|
-
deviceId: z.ZodOptional<z.ZodString>;
|
|
45
|
-
type: z.ZodLiteral<"track">;
|
|
46
|
-
payload: z.ZodObject<{
|
|
47
|
-
name: z.ZodString;
|
|
48
|
-
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
49
|
-
profileId: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
50
|
-
}, z.core.$strip>;
|
|
51
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
52
|
-
eventId: z.ZodUUID;
|
|
53
|
-
timestamp: z.ZodNumber;
|
|
54
|
-
deviceId: z.ZodOptional<z.ZodString>;
|
|
55
|
-
type: z.ZodLiteral<"identify">;
|
|
56
|
-
payload: z.ZodObject<{
|
|
57
|
-
profileId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
58
|
-
firstName: z.ZodOptional<z.ZodString>;
|
|
59
|
-
lastName: z.ZodOptional<z.ZodString>;
|
|
60
|
-
email: z.ZodOptional<z.ZodEmail>;
|
|
61
|
-
avatar: z.ZodOptional<z.ZodURL>;
|
|
62
|
-
properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
63
|
-
}, z.core.$strip>;
|
|
64
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
65
|
-
eventId: z.ZodUUID;
|
|
66
|
-
timestamp: z.ZodNumber;
|
|
67
|
-
deviceId: z.ZodOptional<z.ZodString>;
|
|
68
|
-
type: z.ZodLiteral<"increment">;
|
|
69
|
-
payload: z.ZodObject<{
|
|
70
|
-
profileId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
71
|
-
property: z.ZodString;
|
|
72
|
-
value: z.ZodOptional<z.ZodNumber>;
|
|
73
|
-
}, z.core.$strip>;
|
|
74
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
75
|
-
eventId: z.ZodUUID;
|
|
76
|
-
timestamp: z.ZodNumber;
|
|
77
|
-
deviceId: z.ZodOptional<z.ZodString>;
|
|
78
|
-
type: z.ZodLiteral<"decrement">;
|
|
79
|
-
payload: z.ZodObject<{
|
|
80
|
-
profileId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
81
|
-
property: z.ZodString;
|
|
82
|
-
value: z.ZodOptional<z.ZodNumber>;
|
|
83
|
-
}, z.core.$strip>;
|
|
71
|
+
}, z.core.$strip>;
|
|
84
72
|
}, z.core.$strip>], "type">;
|
|
85
73
|
type ITrackPayload = z.infer<typeof zTrackPayload>;
|
|
86
74
|
type IIdentifyPayload = z.infer<typeof zIdentifyPayload>;
|
|
@@ -100,8 +88,8 @@ type ITrackHandlerPayload = z.infer<typeof zTrackHandlerPayload>;
|
|
|
100
88
|
*/
|
|
101
89
|
declare const INGEST_MODES: readonly ["browser", "server"];
|
|
102
90
|
declare const zIngestMode: z.ZodEnum<{
|
|
103
|
-
|
|
104
|
-
|
|
91
|
+
browser: "browser";
|
|
92
|
+
server: "server";
|
|
105
93
|
}>;
|
|
106
94
|
type IngestMode = z.infer<typeof zIngestMode>;
|
|
107
95
|
/**
|
|
@@ -111,20 +99,20 @@ type IngestMode = z.infer<typeof zIngestMode>;
|
|
|
111
99
|
*/
|
|
112
100
|
declare const INGEST_REJECTION_REASONS: readonly ["validation_failed", "reserved_name", "duplicate_in_batch"];
|
|
113
101
|
declare const zIngestRejectionReason: z.ZodEnum<{
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
102
|
+
validation_failed: "validation_failed";
|
|
103
|
+
reserved_name: "reserved_name";
|
|
104
|
+
duplicate_in_batch: "duplicate_in_batch";
|
|
117
105
|
}>;
|
|
118
106
|
type IngestRejectionReason = z.infer<typeof zIngestRejectionReason>;
|
|
119
107
|
declare const zIngestRejection: z.ZodObject<{
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
108
|
+
eventId: z.ZodString;
|
|
109
|
+
index: z.ZodNumber;
|
|
110
|
+
reason: z.ZodEnum<{
|
|
111
|
+
validation_failed: "validation_failed";
|
|
112
|
+
reserved_name: "reserved_name";
|
|
113
|
+
duplicate_in_batch: "duplicate_in_batch";
|
|
114
|
+
}>;
|
|
115
|
+
message: z.ZodOptional<z.ZodString>;
|
|
128
116
|
}, z.core.$strip>;
|
|
129
117
|
type IngestRejection = z.infer<typeof zIngestRejection>;
|
|
130
118
|
/**
|
|
@@ -134,35 +122,35 @@ type IngestRejection = z.infer<typeof zIngestRejection>;
|
|
|
134
122
|
* absent when the batch carried no sessionable event.
|
|
135
123
|
*/
|
|
136
124
|
declare const zSessionCredential: z.ZodObject<{
|
|
137
|
-
|
|
138
|
-
|
|
125
|
+
id: z.ZodString;
|
|
126
|
+
token: z.ZodString;
|
|
139
127
|
}, z.core.$strip>;
|
|
140
128
|
type SessionCredential = z.infer<typeof zSessionCredential>;
|
|
141
129
|
/** 200 — accepted and handed to the materialize queue. */
|
|
142
130
|
declare const zIngestOkResponse: z.ZodObject<{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}>;
|
|
158
|
-
message: z.ZodOptional<z.ZodString>;
|
|
159
|
-
}, z.core.$strip>>;
|
|
160
|
-
status: z.ZodLiteral<"ok">;
|
|
161
|
-
requestId: z.ZodString;
|
|
162
|
-
mode: z.ZodEnum<{
|
|
163
|
-
browser: "browser";
|
|
164
|
-
server: "server";
|
|
131
|
+
queued: z.ZodBoolean;
|
|
132
|
+
session: z.ZodOptional<z.ZodObject<{
|
|
133
|
+
id: z.ZodString;
|
|
134
|
+
token: z.ZodString;
|
|
135
|
+
}, z.core.$strip>>;
|
|
136
|
+
accepted: z.ZodNumber;
|
|
137
|
+
duplicates: z.ZodNumber;
|
|
138
|
+
rejected: z.ZodArray<z.ZodObject<{
|
|
139
|
+
eventId: z.ZodString;
|
|
140
|
+
index: z.ZodNumber;
|
|
141
|
+
reason: z.ZodEnum<{
|
|
142
|
+
validation_failed: "validation_failed";
|
|
143
|
+
reserved_name: "reserved_name";
|
|
144
|
+
duplicate_in_batch: "duplicate_in_batch";
|
|
165
145
|
}>;
|
|
146
|
+
message: z.ZodOptional<z.ZodString>;
|
|
147
|
+
}, z.core.$strip>>;
|
|
148
|
+
status: z.ZodLiteral<"ok">;
|
|
149
|
+
requestId: z.ZodString;
|
|
150
|
+
mode: z.ZodEnum<{
|
|
151
|
+
browser: "browser";
|
|
152
|
+
server: "server";
|
|
153
|
+
}>;
|
|
166
154
|
}, z.core.$strip>;
|
|
167
155
|
/**
|
|
168
156
|
* 202 — raw events landed, but enqueueing the materialize task failed. No data
|
|
@@ -171,80 +159,80 @@ declare const zIngestOkResponse: z.ZodObject<{
|
|
|
171
159
|
* so the reconciliation below works here too.
|
|
172
160
|
*/
|
|
173
161
|
declare const zIngestAcceptedResponse: z.ZodObject<{
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}>;
|
|
190
|
-
message: z.ZodOptional<z.ZodString>;
|
|
191
|
-
}, z.core.$strip>>;
|
|
192
|
-
status: z.ZodLiteral<"accepted">;
|
|
193
|
-
requestId: z.ZodString;
|
|
194
|
-
mode: z.ZodEnum<{
|
|
195
|
-
browser: "browser";
|
|
196
|
-
server: "server";
|
|
162
|
+
backgroundQueued: z.ZodLiteral<false>;
|
|
163
|
+
replay: z.ZodLiteral<"unmaterialized-raw-events">;
|
|
164
|
+
session: z.ZodOptional<z.ZodObject<{
|
|
165
|
+
id: z.ZodString;
|
|
166
|
+
token: z.ZodString;
|
|
167
|
+
}, z.core.$strip>>;
|
|
168
|
+
accepted: z.ZodNumber;
|
|
169
|
+
duplicates: z.ZodNumber;
|
|
170
|
+
rejected: z.ZodArray<z.ZodObject<{
|
|
171
|
+
eventId: z.ZodString;
|
|
172
|
+
index: z.ZodNumber;
|
|
173
|
+
reason: z.ZodEnum<{
|
|
174
|
+
validation_failed: "validation_failed";
|
|
175
|
+
reserved_name: "reserved_name";
|
|
176
|
+
duplicate_in_batch: "duplicate_in_batch";
|
|
197
177
|
}>;
|
|
178
|
+
message: z.ZodOptional<z.ZodString>;
|
|
179
|
+
}, z.core.$strip>>;
|
|
180
|
+
status: z.ZodLiteral<"accepted">;
|
|
181
|
+
requestId: z.ZodString;
|
|
182
|
+
mode: z.ZodEnum<{
|
|
183
|
+
browser: "browser";
|
|
184
|
+
server: "server";
|
|
185
|
+
}>;
|
|
198
186
|
}, z.core.$strip>;
|
|
199
187
|
declare const zIngestResponse: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}>;
|
|
215
|
-
message: z.ZodOptional<z.ZodString>;
|
|
216
|
-
}, z.core.$strip>>;
|
|
217
|
-
status: z.ZodLiteral<"ok">;
|
|
218
|
-
requestId: z.ZodString;
|
|
219
|
-
mode: z.ZodEnum<{
|
|
220
|
-
browser: "browser";
|
|
221
|
-
server: "server";
|
|
188
|
+
queued: z.ZodBoolean;
|
|
189
|
+
session: z.ZodOptional<z.ZodObject<{
|
|
190
|
+
id: z.ZodString;
|
|
191
|
+
token: z.ZodString;
|
|
192
|
+
}, z.core.$strip>>;
|
|
193
|
+
accepted: z.ZodNumber;
|
|
194
|
+
duplicates: z.ZodNumber;
|
|
195
|
+
rejected: z.ZodArray<z.ZodObject<{
|
|
196
|
+
eventId: z.ZodString;
|
|
197
|
+
index: z.ZodNumber;
|
|
198
|
+
reason: z.ZodEnum<{
|
|
199
|
+
validation_failed: "validation_failed";
|
|
200
|
+
reserved_name: "reserved_name";
|
|
201
|
+
duplicate_in_batch: "duplicate_in_batch";
|
|
222
202
|
}>;
|
|
203
|
+
message: z.ZodOptional<z.ZodString>;
|
|
204
|
+
}, z.core.$strip>>;
|
|
205
|
+
status: z.ZodLiteral<"ok">;
|
|
206
|
+
requestId: z.ZodString;
|
|
207
|
+
mode: z.ZodEnum<{
|
|
208
|
+
browser: "browser";
|
|
209
|
+
server: "server";
|
|
210
|
+
}>;
|
|
223
211
|
}, z.core.$strip>, z.ZodObject<{
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}>;
|
|
240
|
-
message: z.ZodOptional<z.ZodString>;
|
|
241
|
-
}, z.core.$strip>>;
|
|
242
|
-
status: z.ZodLiteral<"accepted">;
|
|
243
|
-
requestId: z.ZodString;
|
|
244
|
-
mode: z.ZodEnum<{
|
|
245
|
-
browser: "browser";
|
|
246
|
-
server: "server";
|
|
212
|
+
backgroundQueued: z.ZodLiteral<false>;
|
|
213
|
+
replay: z.ZodLiteral<"unmaterialized-raw-events">;
|
|
214
|
+
session: z.ZodOptional<z.ZodObject<{
|
|
215
|
+
id: z.ZodString;
|
|
216
|
+
token: z.ZodString;
|
|
217
|
+
}, z.core.$strip>>;
|
|
218
|
+
accepted: z.ZodNumber;
|
|
219
|
+
duplicates: z.ZodNumber;
|
|
220
|
+
rejected: z.ZodArray<z.ZodObject<{
|
|
221
|
+
eventId: z.ZodString;
|
|
222
|
+
index: z.ZodNumber;
|
|
223
|
+
reason: z.ZodEnum<{
|
|
224
|
+
validation_failed: "validation_failed";
|
|
225
|
+
reserved_name: "reserved_name";
|
|
226
|
+
duplicate_in_batch: "duplicate_in_batch";
|
|
247
227
|
}>;
|
|
228
|
+
message: z.ZodOptional<z.ZodString>;
|
|
229
|
+
}, z.core.$strip>>;
|
|
230
|
+
status: z.ZodLiteral<"accepted">;
|
|
231
|
+
requestId: z.ZodString;
|
|
232
|
+
mode: z.ZodEnum<{
|
|
233
|
+
browser: "browser";
|
|
234
|
+
server: "server";
|
|
235
|
+
}>;
|
|
248
236
|
}, z.core.$strip>], "status">;
|
|
249
237
|
type IngestOkResponse = z.infer<typeof zIngestOkResponse>;
|
|
250
238
|
type IngestAcceptedResponse = z.infer<typeof zIngestAcceptedResponse>;
|
|
@@ -264,6 +252,22 @@ declare function reconcileIngestResponse(response: IngestResponse, sentCount: nu
|
|
|
264
252
|
*/
|
|
265
253
|
declare const INGEST_ERROR_CODES: readonly ["unauthorized", "invalid_json", "payload_too_large", "empty_batch", "alias_unsupported", "project_without_organization", "validation_failed", "rate_limited", "quota_exceeded", "project_purging", "internal_error"];
|
|
266
254
|
declare const zIngestErrorCode: z.ZodEnum<{
|
|
255
|
+
validation_failed: "validation_failed";
|
|
256
|
+
unauthorized: "unauthorized";
|
|
257
|
+
invalid_json: "invalid_json";
|
|
258
|
+
payload_too_large: "payload_too_large";
|
|
259
|
+
empty_batch: "empty_batch";
|
|
260
|
+
alias_unsupported: "alias_unsupported";
|
|
261
|
+
project_without_organization: "project_without_organization";
|
|
262
|
+
rate_limited: "rate_limited";
|
|
263
|
+
quota_exceeded: "quota_exceeded";
|
|
264
|
+
project_purging: "project_purging";
|
|
265
|
+
internal_error: "internal_error";
|
|
266
|
+
}>;
|
|
267
|
+
type IngestErrorCode = z.infer<typeof zIngestErrorCode>;
|
|
268
|
+
declare const zIngestError: z.ZodObject<{
|
|
269
|
+
status: z.ZodNumber;
|
|
270
|
+
code: z.ZodEnum<{
|
|
267
271
|
validation_failed: "validation_failed";
|
|
268
272
|
unauthorized: "unauthorized";
|
|
269
273
|
invalid_json: "invalid_json";
|
|
@@ -275,28 +279,13 @@ declare const zIngestErrorCode: z.ZodEnum<{
|
|
|
275
279
|
quota_exceeded: "quota_exceeded";
|
|
276
280
|
project_purging: "project_purging";
|
|
277
281
|
internal_error: "internal_error";
|
|
278
|
-
}>;
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
validation_failed: "validation_failed";
|
|
284
|
-
unauthorized: "unauthorized";
|
|
285
|
-
invalid_json: "invalid_json";
|
|
286
|
-
payload_too_large: "payload_too_large";
|
|
287
|
-
empty_batch: "empty_batch";
|
|
288
|
-
alias_unsupported: "alias_unsupported";
|
|
289
|
-
project_without_organization: "project_without_organization";
|
|
290
|
-
rate_limited: "rate_limited";
|
|
291
|
-
quota_exceeded: "quota_exceeded";
|
|
292
|
-
project_purging: "project_purging";
|
|
293
|
-
internal_error: "internal_error";
|
|
294
|
-
}>;
|
|
295
|
-
error: z.ZodString;
|
|
296
|
-
message: z.ZodOptional<z.ZodString>;
|
|
297
|
-
errors: z.ZodOptional<z.ZodUnknown>;
|
|
298
|
-
requestId: z.ZodOptional<z.ZodString>;
|
|
282
|
+
}>;
|
|
283
|
+
error: z.ZodString;
|
|
284
|
+
message: z.ZodOptional<z.ZodString>;
|
|
285
|
+
errors: z.ZodOptional<z.ZodUnknown>;
|
|
286
|
+
requestId: z.ZodOptional<z.ZodString>;
|
|
299
287
|
}, z.core.$strip>;
|
|
300
288
|
type IngestError = z.infer<typeof zIngestError>;
|
|
301
|
-
|
|
302
|
-
export { type IDecrementPayload,
|
|
289
|
+
//#endregion
|
|
290
|
+
export { AUTO_EVENT_NAMES, AUTO_EVENT_PROPERTIES, AUTO_EVENT_ROLLUP_KEYS, type AutoEventName, IDecrementPayload, IIdentifyPayload, IIncrementPayload, INGEST_ERROR_CODES, INGEST_MODES, INGEST_REJECTION_REASONS, ITrackHandlerPayload, ITrackPayload, IngestAcceptedResponse, IngestError, IngestErrorCode, IngestMode, IngestOkResponse, IngestRejection, IngestRejectionReason, IngestResponse, MAX_TRACK_PAYLOAD_BYTES, RELEASE_PROPERTY, RESERVED_EVENT_NAMES, SCROLL_DEPTH_BUCKETS, type ScrollDepthBucket, SessionCredential, reconcileIngestResponse, scrollDepthBucket, zDecrementPayload, zIdentifyPayload, zIncrementPayload, zIngestAcceptedResponse, zIngestError, zIngestErrorCode, zIngestMode, zIngestOkResponse, zIngestRejection, zIngestRejectionReason, zIngestResponse, zSessionCredential, zTrackHandlerPayload, zTrackPayload };
|
|
291
|
+
//# sourceMappingURL=ingest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ingest.d.ts","names":[],"sources":["../src/ingest.ts"],"mappings":";;;;cA4Ba;cA2BA,eAAa,EAAA;;;;GAStB,EAAA,KAAA;cAES,kBAAgB,EAAA;;;;;;;GAO3B,EAAA,KAAA;cAEW,mBAAiB,EAAA;;;;GAI5B,EAAA,KAAA;cAEW,mBAAiB,EAAA;;;;GAI5B,EAAA,KAAA;cAEW,sBAAoB,EAAA,uBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAK/B,EAAA,KAAA;KAEU,gBAAgB,EAAE,aAAa;KAC/B,mBAAmB,EAAE,aAAa;KAClC,oBAAoB,EAAE,aAAa;KACnC,oBAAoB,EAAE,aAAa;KACnC,uBAAuB,EAAE,aAAa;;;;;;;;;;;;cAerC;cACA,aAAW,EAAA;;;;KACZ,aAAa,EAAE,aAAa;;;;;;cAS3B;cAQA,wBAAsB,EAAA;;;;;KACvB,wBAAwB,EAAE,aAAa;cAEtC,kBAAgB,EAAA;;;;;;;;;GAO3B,EAAA,KAAA;KACU,kBAAkB,EAAE,aAAa;;;;;;;cAqBhC,oBAAkB,EAAA;;;GAG7B,EAAA,KAAA;KACU,oBAAoB,EAAE,aAAa;;cAGlC,mBAAiB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;GAO5B,EAAA,KAAA;;;;;;;cAQW,yBAAuB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAQlC,EAAA,KAAA;cAEW,iBAAe,EAAA,uBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA+E,EAAA,KAAA;KAE/F,mBAAmB,EAAE,aAAa;KAClC,yBAAyB,EAAE,aAAa;KACxC,iBAAiB,EAAE,aAAa;;;;;;;;;iBAU5B,wBAAwB,UAAU,gBAAgB;;;;;cAUrD;cAwBA,kBAAgB,EAAA;;;;;;;;;;;;;KACjB,kBAAkB,EAAE,aAAa;cAEhC,cAAY,EAAA;;;;;;;;;;;;;;;;;;;GAQvB,EAAA,KAAA;KACU,cAAc,EAAE,aAAa"}
|
package/dist/ingest.js
CHANGED
|
@@ -1,59 +1,128 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
zIngestAcceptedResponse,
|
|
11
|
-
zIngestError,
|
|
12
|
-
zIngestErrorCode,
|
|
13
|
-
zIngestMode,
|
|
14
|
-
zIngestOkResponse,
|
|
15
|
-
zIngestRejection,
|
|
16
|
-
zIngestRejectionReason,
|
|
17
|
-
zIngestResponse,
|
|
18
|
-
zSessionCredential,
|
|
19
|
-
zTrackHandlerPayload,
|
|
20
|
-
zTrackPayload
|
|
21
|
-
} from "./chunk-RU26QFM2.js";
|
|
22
|
-
import "./chunk-7W33YGRO.js";
|
|
23
|
-
import "./chunk-PSUINLW7.js";
|
|
24
|
-
import {
|
|
25
|
-
AUTO_EVENT_NAMES,
|
|
26
|
-
AUTO_EVENT_PROPERTIES,
|
|
27
|
-
AUTO_EVENT_ROLLUP_KEYS,
|
|
28
|
-
RESERVED_EVENT_NAMES,
|
|
29
|
-
SCROLL_DEPTH_BUCKETS,
|
|
30
|
-
scrollDepthBucket
|
|
31
|
-
} from "./chunk-FP2X3PRK.js";
|
|
32
|
-
export {
|
|
33
|
-
AUTO_EVENT_NAMES,
|
|
34
|
-
AUTO_EVENT_PROPERTIES,
|
|
35
|
-
AUTO_EVENT_ROLLUP_KEYS,
|
|
36
|
-
INGEST_ERROR_CODES,
|
|
37
|
-
INGEST_MODES,
|
|
38
|
-
INGEST_REJECTION_REASONS,
|
|
39
|
-
MAX_TRACK_PAYLOAD_BYTES,
|
|
40
|
-
RESERVED_EVENT_NAMES,
|
|
41
|
-
SCROLL_DEPTH_BUCKETS,
|
|
42
|
-
reconcileIngestResponse,
|
|
43
|
-
scrollDepthBucket,
|
|
44
|
-
zDecrementPayload,
|
|
45
|
-
zIdentifyPayload,
|
|
46
|
-
zIncrementPayload,
|
|
47
|
-
zIngestAcceptedResponse,
|
|
48
|
-
zIngestError,
|
|
49
|
-
zIngestErrorCode,
|
|
50
|
-
zIngestMode,
|
|
51
|
-
zIngestOkResponse,
|
|
52
|
-
zIngestRejection,
|
|
53
|
-
zIngestRejectionReason,
|
|
54
|
-
zIngestResponse,
|
|
55
|
-
zSessionCredential,
|
|
56
|
-
zTrackHandlerPayload,
|
|
57
|
-
zTrackPayload
|
|
1
|
+
import { IDENTITY_ID_PATTERN } from "./identity.js";
|
|
2
|
+
import { AUTO_EVENT_NAMES, AUTO_EVENT_PROPERTIES, AUTO_EVENT_ROLLUP_KEYS, RELEASE_PROPERTY, RESERVED_EVENT_NAMES, SCROLL_DEPTH_BUCKETS, scrollDepthBucket } from "./events.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/ingest.ts
|
|
5
|
+
const MAX_TRACK_PAYLOAD_BYTES = 512e3;
|
|
6
|
+
const zClientEventMetadata = {
|
|
7
|
+
eventId: z.uuid(),
|
|
8
|
+
timestamp: z.number().int().nonnegative(),
|
|
9
|
+
deviceId: z.string().regex(IDENTITY_ID_PATTERN, "expected an identity id").optional()
|
|
58
10
|
};
|
|
11
|
+
const zTrackPayload = z.object({
|
|
12
|
+
name: z.string().min(1).max(200),
|
|
13
|
+
properties: z.record(z.string(), z.unknown()).optional(),
|
|
14
|
+
profileId: z.string().max(500).or(z.number()).optional()
|
|
15
|
+
}).refine((data) => !RESERVED_EVENT_NAMES.includes(data.name), {
|
|
16
|
+
message: `Event name cannot be one of the reserved names: ${RESERVED_EVENT_NAMES.join(", ")}`,
|
|
17
|
+
path: ["name"]
|
|
18
|
+
});
|
|
19
|
+
const zIdentifyPayload = z.object({
|
|
20
|
+
profileId: z.string().min(1).max(500).or(z.number()),
|
|
21
|
+
firstName: z.string().max(200).optional(),
|
|
22
|
+
lastName: z.string().max(200).optional(),
|
|
23
|
+
email: z.email().max(320).optional(),
|
|
24
|
+
avatar: z.url().max(2e3).optional(),
|
|
25
|
+
properties: z.record(z.string(), z.unknown()).optional()
|
|
26
|
+
});
|
|
27
|
+
const zIncrementPayload = z.object({
|
|
28
|
+
profileId: z.string().min(1).max(500).or(z.number()),
|
|
29
|
+
property: z.string().min(1).max(200),
|
|
30
|
+
value: z.number().positive().optional()
|
|
31
|
+
});
|
|
32
|
+
const zDecrementPayload = z.object({
|
|
33
|
+
profileId: z.string().min(1).max(500).or(z.number()),
|
|
34
|
+
property: z.string().min(1).max(200),
|
|
35
|
+
value: z.number().positive().optional()
|
|
36
|
+
});
|
|
37
|
+
const zTrackHandlerPayload = z.discriminatedUnion("type", [
|
|
38
|
+
z.object({
|
|
39
|
+
type: z.literal("track"),
|
|
40
|
+
payload: zTrackPayload,
|
|
41
|
+
...zClientEventMetadata
|
|
42
|
+
}),
|
|
43
|
+
z.object({
|
|
44
|
+
type: z.literal("identify"),
|
|
45
|
+
payload: zIdentifyPayload,
|
|
46
|
+
...zClientEventMetadata
|
|
47
|
+
}),
|
|
48
|
+
z.object({
|
|
49
|
+
type: z.literal("increment"),
|
|
50
|
+
payload: zIncrementPayload,
|
|
51
|
+
...zClientEventMetadata
|
|
52
|
+
}),
|
|
53
|
+
z.object({
|
|
54
|
+
type: z.literal("decrement"),
|
|
55
|
+
payload: zDecrementPayload,
|
|
56
|
+
...zClientEventMetadata
|
|
57
|
+
})
|
|
58
|
+
]);
|
|
59
|
+
const INGEST_MODES = ["browser", "server"];
|
|
60
|
+
const zIngestMode = z.enum(INGEST_MODES);
|
|
61
|
+
const INGEST_REJECTION_REASONS = [
|
|
62
|
+
"validation_failed",
|
|
63
|
+
"reserved_name",
|
|
64
|
+
"duplicate_in_batch"
|
|
65
|
+
];
|
|
66
|
+
const zIngestRejectionReason = z.enum(INGEST_REJECTION_REASONS);
|
|
67
|
+
const zIngestRejection = z.object({
|
|
68
|
+
eventId: z.string(),
|
|
69
|
+
index: z.number().int().nonnegative(),
|
|
70
|
+
reason: zIngestRejectionReason,
|
|
71
|
+
message: z.string().optional()
|
|
72
|
+
});
|
|
73
|
+
const ingestCounts = {
|
|
74
|
+
accepted: z.number().int().nonnegative(),
|
|
75
|
+
duplicates: z.number().int().nonnegative(),
|
|
76
|
+
rejected: z.array(zIngestRejection)
|
|
77
|
+
};
|
|
78
|
+
const zSessionCredential = z.object({
|
|
79
|
+
id: z.string().regex(IDENTITY_ID_PATTERN),
|
|
80
|
+
token: z.string().regex(/^[A-Za-z0-9_-]{43}$/)
|
|
81
|
+
});
|
|
82
|
+
const zIngestOkResponse = z.object({
|
|
83
|
+
status: z.literal("ok"),
|
|
84
|
+
requestId: z.string(),
|
|
85
|
+
mode: zIngestMode,
|
|
86
|
+
...ingestCounts,
|
|
87
|
+
queued: z.boolean(),
|
|
88
|
+
session: zSessionCredential.optional()
|
|
89
|
+
});
|
|
90
|
+
const zIngestAcceptedResponse = z.object({
|
|
91
|
+
status: z.literal("accepted"),
|
|
92
|
+
requestId: z.string(),
|
|
93
|
+
mode: zIngestMode,
|
|
94
|
+
...ingestCounts,
|
|
95
|
+
backgroundQueued: z.literal(false),
|
|
96
|
+
replay: z.literal("unmaterialized-raw-events"),
|
|
97
|
+
session: zSessionCredential.optional()
|
|
98
|
+
});
|
|
99
|
+
const zIngestResponse = z.discriminatedUnion("status", [zIngestOkResponse, zIngestAcceptedResponse]);
|
|
100
|
+
function reconcileIngestResponse(response, sentCount) {
|
|
101
|
+
return response.accepted + response.duplicates + response.rejected.length === sentCount;
|
|
102
|
+
}
|
|
103
|
+
const INGEST_ERROR_CODES = [
|
|
104
|
+
"unauthorized",
|
|
105
|
+
"invalid_json",
|
|
106
|
+
"payload_too_large",
|
|
107
|
+
"empty_batch",
|
|
108
|
+
"alias_unsupported",
|
|
109
|
+
"project_without_organization",
|
|
110
|
+
"validation_failed",
|
|
111
|
+
"rate_limited",
|
|
112
|
+
"quota_exceeded",
|
|
113
|
+
"project_purging",
|
|
114
|
+
"internal_error"
|
|
115
|
+
];
|
|
116
|
+
const zIngestErrorCode = z.enum(INGEST_ERROR_CODES);
|
|
117
|
+
const zIngestError = z.object({
|
|
118
|
+
status: z.number().int(),
|
|
119
|
+
code: zIngestErrorCode,
|
|
120
|
+
error: z.string(),
|
|
121
|
+
message: z.string().optional(),
|
|
122
|
+
errors: z.unknown().optional(),
|
|
123
|
+
requestId: z.string().optional()
|
|
124
|
+
});
|
|
125
|
+
//#endregion
|
|
126
|
+
export { AUTO_EVENT_NAMES, AUTO_EVENT_PROPERTIES, AUTO_EVENT_ROLLUP_KEYS, INGEST_ERROR_CODES, INGEST_MODES, INGEST_REJECTION_REASONS, MAX_TRACK_PAYLOAD_BYTES, RELEASE_PROPERTY, RESERVED_EVENT_NAMES, SCROLL_DEPTH_BUCKETS, reconcileIngestResponse, scrollDepthBucket, zDecrementPayload, zIdentifyPayload, zIncrementPayload, zIngestAcceptedResponse, zIngestError, zIngestErrorCode, zIngestMode, zIngestOkResponse, zIngestRejection, zIngestRejectionReason, zIngestResponse, zSessionCredential, zTrackHandlerPayload, zTrackPayload };
|
|
127
|
+
|
|
59
128
|
//# sourceMappingURL=ingest.js.map
|