@walkeros/server-source-fetch 0.5.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/README.md ADDED
@@ -0,0 +1,258 @@
1
+ # @walkeros/server-source-fetch
2
+
3
+ > Web Standard Fetch API source for walkerOS - Deploy to any modern
4
+ > edge/serverless platform
5
+
6
+ ## What This Source Does
7
+
8
+ **Accepts** walkerOS events via HTTP (Fetch API) **Forwards** events to
9
+ collector for processing **Returns** HTTP responses with CORS support
10
+
11
+ This is an HTTP transport layer - it accepts events in walkerOS format and
12
+ forwards them to the collector. Not a transformation source.
13
+
14
+ ## Features
15
+
16
+ - ✅ **Web Standard Fetch API** - Native `(Request) => Response` signature
17
+ - ✅ **Platform Agnostic** - Cloudflare Workers, Vercel Edge, Deno, Bun, Node.js
18
+ 18+
19
+ - ✅ **Event Validation** - Zod schema validation with detailed error messages
20
+ - ✅ **Batch Processing** - Handle multiple events in single request
21
+ - ✅ **CORS Support** - Configurable cross-origin resource sharing
22
+ - ✅ **Pixel Tracking** - 1x1 transparent GIF for GET requests
23
+ - ✅ **Request Limits** - Configurable size and batch limits
24
+ - ✅ **Health Checks** - Built-in `/health` endpoint
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ npm install @walkeros/server-source-fetch @walkeros/collector @walkeros/core
30
+ ```
31
+
32
+ ## Quick Start
33
+
34
+ ```typescript
35
+ import { sourceFetch, type SourceFetch } from '@walkeros/server-source-fetch';
36
+ import { startFlow } from '@walkeros/collector';
37
+
38
+ const { elb } = await startFlow<SourceFetch.Push>({
39
+ sources: { api: { code: sourceFetch } },
40
+ });
41
+
42
+ export default { fetch: elb };
43
+ ```
44
+
45
+ ## Platform Deployment
46
+
47
+ ### Cloudflare Workers
48
+
49
+ ```typescript
50
+ import { sourceFetch, type SourceFetch } from '@walkeros/server-source-fetch';
51
+ import { startFlow } from '@walkeros/collector';
52
+
53
+ const { elb } = await startFlow<SourceFetch.Push>({
54
+ sources: {
55
+ api: {
56
+ code: sourceFetch,
57
+ config: { settings: { cors: true } },
58
+ },
59
+ },
60
+ destinations: {
61
+ // Your destinations
62
+ },
63
+ });
64
+
65
+ export default { fetch: elb };
66
+ ```
67
+
68
+ **Deploy:** `wrangler deploy`
69
+
70
+ ### Vercel Edge Functions
71
+
72
+ ```typescript
73
+ // api/collect.ts
74
+ export const config = { runtime: 'edge' };
75
+
76
+ import { sourceFetch, type SourceFetch } from '@walkeros/server-source-fetch';
77
+ import { startFlow } from '@walkeros/collector';
78
+
79
+ const { elb } = await startFlow<SourceFetch.Push>({
80
+ sources: { api: { code: sourceFetch } },
81
+ });
82
+
83
+ export default elb;
84
+ ```
85
+
86
+ ### Deno Deploy
87
+
88
+ ```typescript
89
+ import { sourceFetch, type SourceFetch } from '@walkeros/server-source-fetch';
90
+ import { startFlow } from '@walkeros/collector';
91
+
92
+ const { elb } = await startFlow<SourceFetch.Push>({
93
+ sources: { api: { code: sourceFetch } },
94
+ });
95
+
96
+ Deno.serve(elb);
97
+ ```
98
+
99
+ ### Bun
100
+
101
+ ```typescript
102
+ import { sourceFetch, type SourceFetch } from '@walkeros/server-source-fetch';
103
+ import { startFlow } from '@walkeros/collector';
104
+
105
+ const { elb } = await startFlow<SourceFetch.Push>({
106
+ sources: { api: { code: sourceFetch } },
107
+ });
108
+
109
+ Bun.serve({ fetch: elb, port: 3000 });
110
+ ```
111
+
112
+ ## Usage Examples
113
+
114
+ ### Single Event (POST)
115
+
116
+ ```javascript
117
+ fetch('https://your-endpoint.com/collect', {
118
+ method: 'POST',
119
+ headers: { 'Content-Type': 'application/json' },
120
+ body: JSON.stringify({
121
+ name: 'page view',
122
+ data: { title: 'Home', path: '/' },
123
+ user: { id: 'user-123' },
124
+ globals: { language: 'en' },
125
+ }),
126
+ });
127
+ ```
128
+
129
+ ### Batch Events (POST)
130
+
131
+ ```javascript
132
+ fetch('https://your-endpoint.com/collect', {
133
+ method: 'POST',
134
+ headers: { 'Content-Type': 'application/json' },
135
+ body: JSON.stringify({
136
+ batch: [
137
+ { name: 'page view', data: { title: 'Home' } },
138
+ { name: 'button click', data: { id: 'cta' } },
139
+ { name: 'form submit', data: { formId: 'contact' } },
140
+ ],
141
+ }),
142
+ });
143
+ ```
144
+
145
+ ### Pixel Tracking (GET)
146
+
147
+ ```html
148
+ <img
149
+ src="https://your-endpoint.com/collect?event=page%20view&data[title]=Home&user[id]=user123"
150
+ width="1"
151
+ height="1"
152
+ />
153
+ ```
154
+
155
+ ### Health Check
156
+
157
+ ```bash
158
+ curl https://your-endpoint.com/health
159
+ # {"status":"ok","timestamp":1234567890,"source":"fetch"}
160
+ ```
161
+
162
+ ## Configuration
163
+
164
+ ```typescript
165
+ interface Settings {
166
+ path: string; // Collection path (default: '/collect')
167
+ cors: boolean | CorsOptions; // CORS config (default: true)
168
+ healthPath: string; // Health check path (default: '/health')
169
+ maxRequestSize: number; // Max bytes (default: 102400 = 100KB)
170
+ maxBatchSize: number; // Max events per batch (default: 100)
171
+ }
172
+
173
+ interface CorsOptions {
174
+ origin?: string | string[] | '*';
175
+ methods?: string[];
176
+ headers?: string[];
177
+ credentials?: boolean;
178
+ maxAge?: number;
179
+ }
180
+ ```
181
+
182
+ ## Error Responses
183
+
184
+ ### Validation Error
185
+
186
+ ```json
187
+ {
188
+ "success": false,
189
+ "error": "Event validation failed",
190
+ "validationErrors": [
191
+ { "path": "name", "message": "Event name is required" },
192
+ { "path": "nested.0.entity", "message": "Required" }
193
+ ]
194
+ }
195
+ ```
196
+
197
+ ### Batch Partial Failure (207 Multi-Status)
198
+
199
+ ```json
200
+ {
201
+ "success": false,
202
+ "processed": 2,
203
+ "failed": 1,
204
+ "errors": [
205
+ { "index": 1, "error": "Validation failed: Event name is required" }
206
+ ]
207
+ }
208
+ ```
209
+
210
+ ## Input Format
211
+
212
+ Accepts standard walkerOS events. See
213
+ [@walkeros/core Event documentation](../../../core#event-structure).
214
+
215
+ Required field:
216
+
217
+ - `name` (string) - Event name in "entity action" format (e.g., "page view")
218
+
219
+ Optional fields:
220
+
221
+ - `data` - Event-specific properties
222
+ - `user` - User identification
223
+ - `context` - Ordered context properties
224
+ - `globals` - Global properties
225
+ - `custom` - Custom properties
226
+ - `nested` - Nested entities
227
+ - `consent` - Consent flags
228
+
229
+ ## Testing
230
+
231
+ ```bash
232
+ npm test # Run tests
233
+ npm run dev # Watch mode
234
+ npm run lint # Type check + lint
235
+ npm run build # Build package
236
+ ```
237
+
238
+ ## Development
239
+
240
+ Follows walkerOS XP principles:
241
+
242
+ - **DRY** - Uses @walkeros/core utilities
243
+ - **KISS** - Minimal HTTP wrapper
244
+ - **TDD** - Example-driven tests
245
+ - **No `any`** - Strict TypeScript
246
+
247
+ See [AGENT.md](../../../../AGENT.md) for walkerOS development guide.
248
+
249
+ ## Related
250
+
251
+ - [understanding-sources skill](../../../../skills/understanding-sources/SKILL.md)
252
+ - [using-logger skill](../../../../skills/using-logger/SKILL.md)
253
+ - [@walkeros/server-source-express](../express/) - Alternative for Express.js
254
+ - [@walkeros/core](../../../../packages/core/) - Core utilities
255
+
256
+ ## License
257
+
258
+ MIT
package/dist/dev.d.mts ADDED
@@ -0,0 +1,177 @@
1
+ import { z } from '@walkeros/core/dev';
2
+ import { WalkerOS } from '@walkeros/core';
3
+
4
+ declare const HttpMethod: z.ZodEnum<{
5
+ GET: "GET";
6
+ POST: "POST";
7
+ PUT: "PUT";
8
+ PATCH: "PATCH";
9
+ DELETE: "DELETE";
10
+ OPTIONS: "OPTIONS";
11
+ HEAD: "HEAD";
12
+ }>;
13
+ declare const CorsOrigin: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodLiteral<"*">]>;
14
+ declare const CorsOptionsSchema: z.ZodObject<{
15
+ origin: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodLiteral<"*">]>>;
16
+ methods: z.ZodOptional<z.ZodArray<z.ZodEnum<{
17
+ GET: "GET";
18
+ POST: "POST";
19
+ PUT: "PUT";
20
+ PATCH: "PATCH";
21
+ DELETE: "DELETE";
22
+ OPTIONS: "OPTIONS";
23
+ HEAD: "HEAD";
24
+ }>>>;
25
+ headers: z.ZodOptional<z.ZodArray<z.ZodString>>;
26
+ credentials: z.ZodOptional<z.ZodBoolean>;
27
+ maxAge: z.ZodOptional<z.ZodNumber>;
28
+ }, z.core.$strip>;
29
+ type CorsOptions = z.infer<typeof CorsOptionsSchema>;
30
+
31
+ declare const SettingsSchema: z.ZodObject<{
32
+ path: z.ZodDefault<z.ZodString>;
33
+ cors: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
34
+ origin: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodLiteral<"*">]>>;
35
+ methods: z.ZodOptional<z.ZodArray<z.ZodEnum<{
36
+ GET: "GET";
37
+ POST: "POST";
38
+ PUT: "PUT";
39
+ PATCH: "PATCH";
40
+ DELETE: "DELETE";
41
+ OPTIONS: "OPTIONS";
42
+ HEAD: "HEAD";
43
+ }>>>;
44
+ headers: z.ZodOptional<z.ZodArray<z.ZodString>>;
45
+ credentials: z.ZodOptional<z.ZodBoolean>;
46
+ maxAge: z.ZodOptional<z.ZodNumber>;
47
+ }, z.core.$strip>]>>;
48
+ healthPath: z.ZodDefault<z.ZodString>;
49
+ maxRequestSize: z.ZodDefault<z.ZodNumber>;
50
+ maxBatchSize: z.ZodDefault<z.ZodNumber>;
51
+ }, z.core.$strip>;
52
+ type Settings = z.infer<typeof SettingsSchema>;
53
+
54
+ declare const EventSchema: z.ZodObject<{
55
+ name: z.ZodString;
56
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodAny>]>>>;
57
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodAny>]>, z.ZodNumber], null>>>;
58
+ globals: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodAny>]>>>;
59
+ custom: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodAny>]>>>;
60
+ user: z.ZodOptional<z.ZodObject<{
61
+ id: z.ZodOptional<z.ZodString>;
62
+ device: z.ZodOptional<z.ZodString>;
63
+ session: z.ZodOptional<z.ZodString>;
64
+ email: z.ZodOptional<z.ZodString>;
65
+ hash: z.ZodOptional<z.ZodString>;
66
+ }, z.core.$loose>>;
67
+ nested: z.ZodOptional<z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
68
+ consent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
69
+ id: z.ZodOptional<z.ZodString>;
70
+ trigger: z.ZodOptional<z.ZodString>;
71
+ entity: z.ZodOptional<z.ZodString>;
72
+ action: z.ZodOptional<z.ZodString>;
73
+ timestamp: z.ZodOptional<z.ZodNumber>;
74
+ timing: z.ZodOptional<z.ZodNumber>;
75
+ group: z.ZodOptional<z.ZodString>;
76
+ count: z.ZodOptional<z.ZodNumber>;
77
+ version: z.ZodOptional<z.ZodObject<{
78
+ source: z.ZodString;
79
+ tagging: z.ZodNumber;
80
+ }, z.core.$strip>>;
81
+ source: z.ZodOptional<z.ZodObject<{
82
+ type: z.ZodString;
83
+ id: z.ZodString;
84
+ previous_id: z.ZodString;
85
+ }, z.core.$loose>>;
86
+ }, z.core.$loose>;
87
+ type ValidatedEvent = z.infer<typeof EventSchema>;
88
+
89
+ /**
90
+ * Example walkerOS events that HTTP clients send to this source.
91
+ * These are the CONTRACT - tests verify implementation handles these inputs.
92
+ */
93
+ declare const pageView: WalkerOS.DeepPartialEvent;
94
+ declare const productAdd: WalkerOS.DeepPartialEvent;
95
+ declare const completeEvent: WalkerOS.DeepPartialEvent;
96
+ declare const minimal: WalkerOS.DeepPartialEvent;
97
+ declare const batch: WalkerOS.DeepPartialEvent[];
98
+
99
+ declare const inputs_batch: typeof batch;
100
+ declare const inputs_completeEvent: typeof completeEvent;
101
+ declare const inputs_minimal: typeof minimal;
102
+ declare const inputs_pageView: typeof pageView;
103
+ declare const inputs_productAdd: typeof productAdd;
104
+ declare namespace inputs {
105
+ export { inputs_batch as batch, inputs_completeEvent as completeEvent, inputs_minimal as minimal, inputs_pageView as pageView, inputs_productAdd as productAdd };
106
+ }
107
+
108
+ /**
109
+ * HTTP request examples for testing the fetch source.
110
+ * Shows what external HTTP clients will send.
111
+ */
112
+ declare const validPostRequest: {
113
+ method: string;
114
+ url: string;
115
+ headers: {
116
+ 'Content-Type': string;
117
+ };
118
+ body: string;
119
+ };
120
+ declare const batchPostRequest: {
121
+ method: string;
122
+ url: string;
123
+ headers: {
124
+ 'Content-Type': string;
125
+ };
126
+ body: string;
127
+ };
128
+ declare const pixelGetRequest: {
129
+ method: string;
130
+ url: string;
131
+ };
132
+ declare const healthCheckRequest: {
133
+ method: string;
134
+ url: string;
135
+ };
136
+ declare const optionsRequest: {
137
+ method: string;
138
+ url: string;
139
+ headers: {
140
+ Origin: string;
141
+ };
142
+ };
143
+ declare const invalidJsonRequest: {
144
+ method: string;
145
+ url: string;
146
+ headers: {
147
+ 'Content-Type': string;
148
+ };
149
+ body: string;
150
+ };
151
+ declare const oversizedRequest: {
152
+ method: string;
153
+ url: string;
154
+ headers: {
155
+ 'Content-Type': string;
156
+ };
157
+ body: string;
158
+ };
159
+
160
+ declare const requests_batchPostRequest: typeof batchPostRequest;
161
+ declare const requests_healthCheckRequest: typeof healthCheckRequest;
162
+ declare const requests_invalidJsonRequest: typeof invalidJsonRequest;
163
+ declare const requests_optionsRequest: typeof optionsRequest;
164
+ declare const requests_oversizedRequest: typeof oversizedRequest;
165
+ declare const requests_pixelGetRequest: typeof pixelGetRequest;
166
+ declare const requests_validPostRequest: typeof validPostRequest;
167
+ declare namespace requests {
168
+ export { requests_batchPostRequest as batchPostRequest, requests_healthCheckRequest as healthCheckRequest, requests_invalidJsonRequest as invalidJsonRequest, requests_optionsRequest as optionsRequest, requests_oversizedRequest as oversizedRequest, requests_pixelGetRequest as pixelGetRequest, requests_validPostRequest as validPostRequest };
169
+ }
170
+
171
+ declare const index_inputs: typeof inputs;
172
+ declare const index_requests: typeof requests;
173
+ declare namespace index {
174
+ export { index_inputs as inputs, index_requests as requests };
175
+ }
176
+
177
+ export { type CorsOptions, CorsOptionsSchema, CorsOrigin, EventSchema, HttpMethod, type Settings, SettingsSchema, type ValidatedEvent, index as examples };
package/dist/dev.d.ts ADDED
@@ -0,0 +1,177 @@
1
+ import { z } from '@walkeros/core/dev';
2
+ import { WalkerOS } from '@walkeros/core';
3
+
4
+ declare const HttpMethod: z.ZodEnum<{
5
+ GET: "GET";
6
+ POST: "POST";
7
+ PUT: "PUT";
8
+ PATCH: "PATCH";
9
+ DELETE: "DELETE";
10
+ OPTIONS: "OPTIONS";
11
+ HEAD: "HEAD";
12
+ }>;
13
+ declare const CorsOrigin: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodLiteral<"*">]>;
14
+ declare const CorsOptionsSchema: z.ZodObject<{
15
+ origin: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodLiteral<"*">]>>;
16
+ methods: z.ZodOptional<z.ZodArray<z.ZodEnum<{
17
+ GET: "GET";
18
+ POST: "POST";
19
+ PUT: "PUT";
20
+ PATCH: "PATCH";
21
+ DELETE: "DELETE";
22
+ OPTIONS: "OPTIONS";
23
+ HEAD: "HEAD";
24
+ }>>>;
25
+ headers: z.ZodOptional<z.ZodArray<z.ZodString>>;
26
+ credentials: z.ZodOptional<z.ZodBoolean>;
27
+ maxAge: z.ZodOptional<z.ZodNumber>;
28
+ }, z.core.$strip>;
29
+ type CorsOptions = z.infer<typeof CorsOptionsSchema>;
30
+
31
+ declare const SettingsSchema: z.ZodObject<{
32
+ path: z.ZodDefault<z.ZodString>;
33
+ cors: z.ZodDefault<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
34
+ origin: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>, z.ZodLiteral<"*">]>>;
35
+ methods: z.ZodOptional<z.ZodArray<z.ZodEnum<{
36
+ GET: "GET";
37
+ POST: "POST";
38
+ PUT: "PUT";
39
+ PATCH: "PATCH";
40
+ DELETE: "DELETE";
41
+ OPTIONS: "OPTIONS";
42
+ HEAD: "HEAD";
43
+ }>>>;
44
+ headers: z.ZodOptional<z.ZodArray<z.ZodString>>;
45
+ credentials: z.ZodOptional<z.ZodBoolean>;
46
+ maxAge: z.ZodOptional<z.ZodNumber>;
47
+ }, z.core.$strip>]>>;
48
+ healthPath: z.ZodDefault<z.ZodString>;
49
+ maxRequestSize: z.ZodDefault<z.ZodNumber>;
50
+ maxBatchSize: z.ZodDefault<z.ZodNumber>;
51
+ }, z.core.$strip>;
52
+ type Settings = z.infer<typeof SettingsSchema>;
53
+
54
+ declare const EventSchema: z.ZodObject<{
55
+ name: z.ZodString;
56
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodAny>]>>>;
57
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodTuple<[z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodAny>]>, z.ZodNumber], null>>>;
58
+ globals: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodAny>]>>>;
59
+ custom: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodAny>]>>>;
60
+ user: z.ZodOptional<z.ZodObject<{
61
+ id: z.ZodOptional<z.ZodString>;
62
+ device: z.ZodOptional<z.ZodString>;
63
+ session: z.ZodOptional<z.ZodString>;
64
+ email: z.ZodOptional<z.ZodString>;
65
+ hash: z.ZodOptional<z.ZodString>;
66
+ }, z.core.$loose>>;
67
+ nested: z.ZodOptional<z.ZodArray<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
68
+ consent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodBoolean>>;
69
+ id: z.ZodOptional<z.ZodString>;
70
+ trigger: z.ZodOptional<z.ZodString>;
71
+ entity: z.ZodOptional<z.ZodString>;
72
+ action: z.ZodOptional<z.ZodString>;
73
+ timestamp: z.ZodOptional<z.ZodNumber>;
74
+ timing: z.ZodOptional<z.ZodNumber>;
75
+ group: z.ZodOptional<z.ZodString>;
76
+ count: z.ZodOptional<z.ZodNumber>;
77
+ version: z.ZodOptional<z.ZodObject<{
78
+ source: z.ZodString;
79
+ tagging: z.ZodNumber;
80
+ }, z.core.$strip>>;
81
+ source: z.ZodOptional<z.ZodObject<{
82
+ type: z.ZodString;
83
+ id: z.ZodString;
84
+ previous_id: z.ZodString;
85
+ }, z.core.$loose>>;
86
+ }, z.core.$loose>;
87
+ type ValidatedEvent = z.infer<typeof EventSchema>;
88
+
89
+ /**
90
+ * Example walkerOS events that HTTP clients send to this source.
91
+ * These are the CONTRACT - tests verify implementation handles these inputs.
92
+ */
93
+ declare const pageView: WalkerOS.DeepPartialEvent;
94
+ declare const productAdd: WalkerOS.DeepPartialEvent;
95
+ declare const completeEvent: WalkerOS.DeepPartialEvent;
96
+ declare const minimal: WalkerOS.DeepPartialEvent;
97
+ declare const batch: WalkerOS.DeepPartialEvent[];
98
+
99
+ declare const inputs_batch: typeof batch;
100
+ declare const inputs_completeEvent: typeof completeEvent;
101
+ declare const inputs_minimal: typeof minimal;
102
+ declare const inputs_pageView: typeof pageView;
103
+ declare const inputs_productAdd: typeof productAdd;
104
+ declare namespace inputs {
105
+ export { inputs_batch as batch, inputs_completeEvent as completeEvent, inputs_minimal as minimal, inputs_pageView as pageView, inputs_productAdd as productAdd };
106
+ }
107
+
108
+ /**
109
+ * HTTP request examples for testing the fetch source.
110
+ * Shows what external HTTP clients will send.
111
+ */
112
+ declare const validPostRequest: {
113
+ method: string;
114
+ url: string;
115
+ headers: {
116
+ 'Content-Type': string;
117
+ };
118
+ body: string;
119
+ };
120
+ declare const batchPostRequest: {
121
+ method: string;
122
+ url: string;
123
+ headers: {
124
+ 'Content-Type': string;
125
+ };
126
+ body: string;
127
+ };
128
+ declare const pixelGetRequest: {
129
+ method: string;
130
+ url: string;
131
+ };
132
+ declare const healthCheckRequest: {
133
+ method: string;
134
+ url: string;
135
+ };
136
+ declare const optionsRequest: {
137
+ method: string;
138
+ url: string;
139
+ headers: {
140
+ Origin: string;
141
+ };
142
+ };
143
+ declare const invalidJsonRequest: {
144
+ method: string;
145
+ url: string;
146
+ headers: {
147
+ 'Content-Type': string;
148
+ };
149
+ body: string;
150
+ };
151
+ declare const oversizedRequest: {
152
+ method: string;
153
+ url: string;
154
+ headers: {
155
+ 'Content-Type': string;
156
+ };
157
+ body: string;
158
+ };
159
+
160
+ declare const requests_batchPostRequest: typeof batchPostRequest;
161
+ declare const requests_healthCheckRequest: typeof healthCheckRequest;
162
+ declare const requests_invalidJsonRequest: typeof invalidJsonRequest;
163
+ declare const requests_optionsRequest: typeof optionsRequest;
164
+ declare const requests_oversizedRequest: typeof oversizedRequest;
165
+ declare const requests_pixelGetRequest: typeof pixelGetRequest;
166
+ declare const requests_validPostRequest: typeof validPostRequest;
167
+ declare namespace requests {
168
+ export { requests_batchPostRequest as batchPostRequest, requests_healthCheckRequest as healthCheckRequest, requests_invalidJsonRequest as invalidJsonRequest, requests_optionsRequest as optionsRequest, requests_oversizedRequest as oversizedRequest, requests_pixelGetRequest as pixelGetRequest, requests_validPostRequest as validPostRequest };
169
+ }
170
+
171
+ declare const index_inputs: typeof inputs;
172
+ declare const index_requests: typeof requests;
173
+ declare namespace index {
174
+ export { index_inputs as inputs, index_requests as requests };
175
+ }
176
+
177
+ export { type CorsOptions, CorsOptionsSchema, CorsOrigin, EventSchema, HttpMethod, type Settings, SettingsSchema, type ValidatedEvent, index as examples };
package/dist/dev.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e,t=Object.defineProperty,o=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,i=(e,o)=>{for(var a in o)t(e,a,{get:o[a],enumerable:!0})},r={};i(r,{CorsOptionsSchema:()=>c,CorsOrigin:()=>p,EventSchema:()=>x,HttpMethod:()=>l,SettingsSchema:()=>u,examples:()=>f}),module.exports=(e=r,((e,i,r,s)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let l of a(i))n.call(e,l)||l===r||t(e,l,{get:()=>i[l],enumerable:!(s=o(i,l))||s.enumerable});return e})(t({},"__esModule",{value:!0}),e));var s=require("@walkeros/core/dev"),l=s.z.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),p=s.z.union([s.z.string(),s.z.array(s.z.string()),s.z.literal("*")]),c=s.z.object({origin:p.optional(),methods:s.z.array(l).optional(),headers:s.z.array(s.z.string()).optional(),credentials:s.z.boolean().optional(),maxAge:s.z.number().int().positive().optional()}),m=require("@walkeros/core/dev"),u=m.z.object({path:m.z.string().default("/collect"),cors:m.z.union([m.z.boolean(),c]).default(!0),healthPath:m.z.string().default("/health"),maxRequestSize:m.z.number().int().positive().default(102400),maxBatchSize:m.z.number().int().positive().default(100)}),d=require("@walkeros/core/dev"),g=d.z.record(d.z.string(),d.z.union([d.z.string(),d.z.number(),d.z.boolean(),d.z.record(d.z.string(),d.z.any())])),z=d.z.record(d.z.string(),d.z.tuple([d.z.union([d.z.string(),d.z.number(),d.z.boolean(),d.z.record(d.z.string(),d.z.any())]),d.z.number()])),h=d.z.object({id:d.z.string().optional(),device:d.z.string().optional(),session:d.z.string().optional(),email:d.z.string().optional(),hash:d.z.string().optional()}).passthrough(),b=d.z.record(d.z.string(),d.z.boolean()),y=d.z.lazy(()=>d.z.object({entity:d.z.string(),data:g.optional(),nested:d.z.array(y).optional(),context:z.optional()}).passthrough()),v=d.z.object({source:d.z.string(),tagging:d.z.number()}),O=d.z.object({type:d.z.string(),id:d.z.string(),previous_id:d.z.string()}).passthrough(),x=d.z.object({name:d.z.string().min(1,"Event name is required"),data:g.optional(),context:z.optional(),globals:g.optional(),custom:g.optional(),user:h.optional(),nested:d.z.array(y).optional(),consent:b.optional(),id:d.z.string().optional(),trigger:d.z.string().optional(),entity:d.z.string().optional(),action:d.z.string().optional(),timestamp:d.z.number().optional(),timing:d.z.number().optional(),group:d.z.string().optional(),count:d.z.number().optional(),version:v.optional(),source:O.optional()}).passthrough(),f={};i(f,{inputs:()=>P,requests:()=>w});var P={};i(P,{batch:()=>E,completeEvent:()=>T,minimal:()=>q,pageView:()=>S,productAdd:()=>j});var S={name:"page view",data:{title:"Home Page",path:"/",referrer:"https://google.com"},user:{id:"user-123",session:"session-456"},timestamp:17e11},j={name:"product add",data:{id:"P-123",name:"Laptop",price:999.99,quantity:1},context:{stage:["shopping",1]},globals:{language:"en",currency:"USD"},user:{id:"user-123"},nested:[{entity:"category",data:{name:"Electronics",path:"/electronics"}}],consent:{functional:!0,marketing:!0}},T={name:"order complete",data:{id:"ORDER-123",total:999.99,currency:"USD"},context:{stage:["checkout",3],test:["variant-A",0]},globals:{language:"en",country:"US"},custom:{campaignId:"summer-sale",source:"email"},user:{id:"user-123",email:"user@example.com",session:"session-456"},nested:[{entity:"product",data:{id:"P-123",price:999.99}}],consent:{functional:!0,marketing:!0,analytics:!1},trigger:"click",group:"ecommerce"},q={name:"ping"},E=[S,j,{name:"button click",data:{id:"cta"}}],w={};i(w,{batchPostRequest:()=>R,healthCheckRequest:()=>H,invalidJsonRequest:()=>N,optionsRequest:()=>D,oversizedRequest:()=>A,pixelGetRequest:()=>C,validPostRequest:()=>k});var k={method:"POST",url:"https://example.com/collect",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"page view",data:{title:"Home"}})},R={method:"POST",url:"https://example.com/collect",headers:{"Content-Type":"application/json"},body:JSON.stringify({batch:[{name:"page view",data:{title:"Home"}},{name:"button click",data:{id:"cta"}}]})},C={method:"GET",url:"https://example.com/collect?event=page%20view&data[title]=Home&user[id]=user123"},H={method:"GET",url:"https://example.com/health"},D={method:"OPTIONS",url:"https://example.com/collect",headers:{Origin:"https://example.com"}},N={method:"POST",url:"https://example.com/collect",headers:{"Content-Type":"application/json"},body:"invalid json{"},A={method:"POST",url:"https://example.com/collect",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"test",data:{payload:"x".repeat(2e5)}})};//# sourceMappingURL=dev.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/dev.ts","../src/schemas/primitives.ts","../src/schemas/settings.ts","../src/schemas/event.ts","../src/examples/index.ts","../src/examples/inputs.ts","../src/examples/requests.ts"],"sourcesContent":["export * from './schemas';\nexport * as examples from './examples';\n","import { z } from '@walkeros/core/dev';\n\nexport const HttpMethod = z.enum([\n 'GET',\n 'POST',\n 'PUT',\n 'PATCH',\n 'DELETE',\n 'OPTIONS',\n 'HEAD',\n]);\n\nexport const CorsOrigin = z.union([\n z.string(),\n z.array(z.string()),\n z.literal('*'),\n]);\n\nexport const CorsOptionsSchema = z.object({\n origin: CorsOrigin.optional(),\n methods: z.array(HttpMethod).optional(),\n headers: z.array(z.string()).optional(),\n credentials: z.boolean().optional(),\n maxAge: z.number().int().positive().optional(),\n});\n\nexport type CorsOptions = z.infer<typeof CorsOptionsSchema>;\n","import { z } from '@walkeros/core/dev';\nimport { CorsOptionsSchema } from './primitives';\n\nexport const SettingsSchema = z.object({\n path: z.string().default('/collect'),\n cors: z.union([z.boolean(), CorsOptionsSchema]).default(true),\n healthPath: z.string().default('/health'),\n maxRequestSize: z\n .number()\n .int()\n .positive()\n .default(1024 * 100), // 100KB\n maxBatchSize: z.number().int().positive().default(100), // 100 events\n});\n\nexport type Settings = z.infer<typeof SettingsSchema>;\n","import { z } from '@walkeros/core/dev';\n\n// Properties schema - flexible key-value pairs\nconst PropertiesSchema = z.record(\n z.string(),\n z.union([z.string(), z.number(), z.boolean(), z.record(z.string(), z.any())]),\n);\n\n// Ordered properties - [value, order] tuples\nconst OrderedPropertiesSchema = z.record(\n z.string(),\n z.tuple([\n z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.record(z.string(), z.any()),\n ]),\n z.number(),\n ]),\n);\n\n// User schema with optional fields\nconst UserSchema = z\n .object({\n id: z.string().optional(),\n device: z.string().optional(),\n session: z.string().optional(),\n email: z.string().optional(),\n hash: z.string().optional(),\n })\n .passthrough();\n\n// Consent schema - boolean flags\nconst ConsentSchema = z.record(z.string(), z.boolean());\n\n// Entity schema (recursive for nested entities)\nconst EntitySchema: z.ZodTypeAny = z.lazy(() =>\n z\n .object({\n entity: z.string(),\n data: PropertiesSchema.optional(),\n nested: z.array(EntitySchema).optional(),\n context: OrderedPropertiesSchema.optional(),\n })\n .passthrough(),\n);\n\n// Version schema\nconst VersionSchema = z.object({\n source: z.string(),\n tagging: z.number(),\n});\n\n// Source schema\nconst SourceSchema = z\n .object({\n type: z.string(),\n id: z.string(),\n previous_id: z.string(),\n })\n .passthrough();\n\n// Main event schema - validates incoming events\nexport const EventSchema = z\n .object({\n // Required\n name: z.string().min(1, 'Event name is required'),\n\n // Core properties\n data: PropertiesSchema.optional(),\n context: OrderedPropertiesSchema.optional(),\n globals: PropertiesSchema.optional(),\n custom: PropertiesSchema.optional(),\n user: UserSchema.optional(),\n nested: z.array(EntitySchema).optional(),\n consent: ConsentSchema.optional(),\n\n // System fields (optional for incoming events)\n id: z.string().optional(),\n trigger: z.string().optional(),\n entity: z.string().optional(),\n action: z.string().optional(),\n timestamp: z.number().optional(),\n timing: z.number().optional(),\n group: z.string().optional(),\n count: z.number().optional(),\n version: VersionSchema.optional(),\n source: SourceSchema.optional(),\n })\n .passthrough(); // Allow additional fields\n\nexport type ValidatedEvent = z.infer<typeof EventSchema>;\n","export * as inputs from './inputs';\nexport * as requests from './requests';\n","import type { WalkerOS } from '@walkeros/core';\n\n/**\n * Example walkerOS events that HTTP clients send to this source.\n * These are the CONTRACT - tests verify implementation handles these inputs.\n */\n\n// Simple page view event\nexport const pageView: WalkerOS.DeepPartialEvent = {\n name: 'page view',\n data: {\n title: 'Home Page',\n path: '/',\n referrer: 'https://google.com',\n },\n user: {\n id: 'user-123',\n session: 'session-456',\n },\n timestamp: 1700000000000,\n};\n\n// E-commerce event with nested entities\nexport const productAdd: WalkerOS.DeepPartialEvent = {\n name: 'product add',\n data: {\n id: 'P-123',\n name: 'Laptop',\n price: 999.99,\n quantity: 1,\n },\n context: {\n stage: ['shopping', 1],\n },\n globals: {\n language: 'en',\n currency: 'USD',\n },\n user: {\n id: 'user-123',\n },\n nested: [\n {\n entity: 'category',\n data: {\n name: 'Electronics',\n path: '/electronics',\n },\n },\n ],\n consent: {\n functional: true,\n marketing: true,\n },\n};\n\n// Complete event with all optional fields\nexport const completeEvent: WalkerOS.DeepPartialEvent = {\n name: 'order complete',\n data: {\n id: 'ORDER-123',\n total: 999.99,\n currency: 'USD',\n },\n context: {\n stage: ['checkout', 3],\n test: ['variant-A', 0],\n },\n globals: {\n language: 'en',\n country: 'US',\n },\n custom: {\n campaignId: 'summer-sale',\n source: 'email',\n },\n user: {\n id: 'user-123',\n email: 'user@example.com',\n session: 'session-456',\n },\n nested: [\n {\n entity: 'product',\n data: {\n id: 'P-123',\n price: 999.99,\n },\n },\n ],\n consent: {\n functional: true,\n marketing: true,\n analytics: false,\n },\n trigger: 'click',\n group: 'ecommerce',\n};\n\n// Minimal valid event\nexport const minimal: WalkerOS.DeepPartialEvent = {\n name: 'ping',\n};\n\n// Batch of events\nexport const batch: WalkerOS.DeepPartialEvent[] = [\n pageView,\n productAdd,\n { name: 'button click', data: { id: 'cta' } },\n];\n","/**\n * HTTP request examples for testing the fetch source.\n * Shows what external HTTP clients will send.\n */\n\nexport const validPostRequest = {\n method: 'POST',\n url: 'https://example.com/collect',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n name: 'page view',\n data: { title: 'Home' },\n }),\n};\n\nexport const batchPostRequest = {\n method: 'POST',\n url: 'https://example.com/collect',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n batch: [\n { name: 'page view', data: { title: 'Home' } },\n { name: 'button click', data: { id: 'cta' } },\n ],\n }),\n};\n\nexport const pixelGetRequest = {\n method: 'GET',\n url: 'https://example.com/collect?event=page%20view&data[title]=Home&user[id]=user123',\n};\n\nexport const healthCheckRequest = {\n method: 'GET',\n url: 'https://example.com/health',\n};\n\nexport const optionsRequest = {\n method: 'OPTIONS',\n url: 'https://example.com/collect',\n headers: { Origin: 'https://example.com' },\n};\n\nexport const invalidJsonRequest = {\n method: 'POST',\n url: 'https://example.com/collect',\n headers: { 'Content-Type': 'application/json' },\n body: 'invalid json{',\n};\n\nexport const oversizedRequest = {\n method: 'POST',\n url: 'https://example.com/collect',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n name: 'test',\n data: { payload: 'x'.repeat(200000) }, // 200KB\n }),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAkB;AAEX,IAAM,aAAa,aAAE,KAAK;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,aAAa,aAAE,MAAM;AAAA,EAChC,aAAE,OAAO;AAAA,EACT,aAAE,MAAM,aAAE,OAAO,CAAC;AAAA,EAClB,aAAE,QAAQ,GAAG;AACf,CAAC;AAEM,IAAM,oBAAoB,aAAE,OAAO;AAAA,EACxC,QAAQ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AAE,IAAI,MAAM,EAAE;AAAA,IAC9C;AAAA,EACF,CAAC;AACH;AAEO,IAAM,kBAAkB;AAAA,EAC7B,QAAQ;AAAA,EACR,KAAK;AACP;AAEO,IAAM,qBAAqB;AAAA,EAChC,QAAQ;AAAA,EACR,KAAK;AACP;AAEO,IAAM,iBAAiB;AAAA,EAC5B,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,SAAS,EAAE,QAAQ,sBAAsB;AAC3C;AAEO,IAAM,qBAAqB;AAAA,EAChC,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,EAC9C,MAAM;AACR;AAEO,IAAM,mBAAmB;AAAA,EAC9B,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,SAAS,EAAE,gBAAgB,mBAAmB;AAAA,EAC9C,MAAM,KAAK,UAAU;AAAA,IACnB,MAAM;AAAA,IACN,MAAM,EAAE,SAAS,IAAI,OAAO,GAAM,EAAE;AAAA;AAAA,EACtC,CAAC;AACH;","names":["import_dev","import_dev"]}
package/dist/dev.mjs ADDED
@@ -0,0 +1 @@
1
+ var e=Object.defineProperty,t=(t,o)=>{for(var a in o)e(t,a,{get:o[a],enumerable:!0})};import{z as o}from"@walkeros/core/dev";var a=o.enum(["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"]),n=o.union([o.string(),o.array(o.string()),o.literal("*")]),i=o.object({origin:n.optional(),methods:o.array(a).optional(),headers:o.array(o.string()).optional(),credentials:o.boolean().optional(),maxAge:o.number().int().positive().optional()});import{z as r}from"@walkeros/core/dev";var s=r.object({path:r.string().default("/collect"),cors:r.union([r.boolean(),i]).default(!0),healthPath:r.string().default("/health"),maxRequestSize:r.number().int().positive().default(102400),maxBatchSize:r.number().int().positive().default(100)});import{z as l}from"@walkeros/core/dev";var p=l.record(l.string(),l.union([l.string(),l.number(),l.boolean(),l.record(l.string(),l.any())])),c=l.record(l.string(),l.tuple([l.union([l.string(),l.number(),l.boolean(),l.record(l.string(),l.any())]),l.number()])),m=l.object({id:l.string().optional(),device:l.string().optional(),session:l.string().optional(),email:l.string().optional(),hash:l.string().optional()}).passthrough(),d=l.record(l.string(),l.boolean()),u=l.lazy(()=>l.object({entity:l.string(),data:p.optional(),nested:l.array(u).optional(),context:c.optional()}).passthrough()),g=l.object({source:l.string(),tagging:l.number()}),h=l.object({type:l.string(),id:l.string(),previous_id:l.string()}).passthrough(),b=l.object({name:l.string().min(1,"Event name is required"),data:p.optional(),context:c.optional(),globals:p.optional(),custom:p.optional(),user:m.optional(),nested:l.array(u).optional(),consent:d.optional(),id:l.string().optional(),trigger:l.string().optional(),entity:l.string().optional(),action:l.string().optional(),timestamp:l.number().optional(),timing:l.number().optional(),group:l.string().optional(),count:l.number().optional(),version:g.optional(),source:h.optional()}).passthrough(),y={};t(y,{inputs:()=>v,requests:()=>S});var v={};t(v,{batch:()=>O,completeEvent:()=>f,minimal:()=>P,pageView:()=>x,productAdd:()=>T});var x={name:"page view",data:{title:"Home Page",path:"/",referrer:"https://google.com"},user:{id:"user-123",session:"session-456"},timestamp:17e11},T={name:"product add",data:{id:"P-123",name:"Laptop",price:999.99,quantity:1},context:{stage:["shopping",1]},globals:{language:"en",currency:"USD"},user:{id:"user-123"},nested:[{entity:"category",data:{name:"Electronics",path:"/electronics"}}],consent:{functional:!0,marketing:!0}},f={name:"order complete",data:{id:"ORDER-123",total:999.99,currency:"USD"},context:{stage:["checkout",3],test:["variant-A",0]},globals:{language:"en",country:"US"},custom:{campaignId:"summer-sale",source:"email"},user:{id:"user-123",email:"user@example.com",session:"session-456"},nested:[{entity:"product",data:{id:"P-123",price:999.99}}],consent:{functional:!0,marketing:!0,analytics:!1},trigger:"click",group:"ecommerce"},P={name:"ping"},O=[x,T,{name:"button click",data:{id:"cta"}}],S={};t(S,{batchPostRequest:()=>q,healthCheckRequest:()=>k,invalidJsonRequest:()=>w,optionsRequest:()=>R,oversizedRequest:()=>z,pixelGetRequest:()=>E,validPostRequest:()=>j});var j={method:"POST",url:"https://example.com/collect",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"page view",data:{title:"Home"}})},q={method:"POST",url:"https://example.com/collect",headers:{"Content-Type":"application/json"},body:JSON.stringify({batch:[{name:"page view",data:{title:"Home"}},{name:"button click",data:{id:"cta"}}]})},E={method:"GET",url:"https://example.com/collect?event=page%20view&data[title]=Home&user[id]=user123"},k={method:"GET",url:"https://example.com/health"},R={method:"OPTIONS",url:"https://example.com/collect",headers:{Origin:"https://example.com"}},w={method:"POST",url:"https://example.com/collect",headers:{"Content-Type":"application/json"},body:"invalid json{"},z={method:"POST",url:"https://example.com/collect",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"test",data:{payload:"x".repeat(2e5)}})};export{i as CorsOptionsSchema,n as CorsOrigin,b as EventSchema,a as HttpMethod,s as SettingsSchema,y as examples};//# sourceMappingURL=dev.mjs.map