@sygnl/event-schema 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +98 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # @sygnl/event-schema
2
+
3
+ Unified event schemas for e-commerce and SaaS analytics with TypeScript and Zod validation.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @sygnl/event-schema
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { validateEvent, PurchaseEventSchema } from '@sygnl/event-schema';
15
+
16
+ // Validate event
17
+ const result = validateEvent({
18
+ event_type: 'purchase',
19
+ timestamp: Date.now(),
20
+ order_id: 'order_123',
21
+ total: 99.99,
22
+ currency: 'USD',
23
+ products: [
24
+ { id: 'prod_1', name: 'Widget', price: 99.99, quantity: 1 }
25
+ ]
26
+ });
27
+
28
+ if (result.success) {
29
+ console.log('Valid event:', result.data);
30
+ } else {
31
+ console.error('Invalid:', result.errors);
32
+ }
33
+ ```
34
+
35
+ ## Features
36
+
37
+ - E-commerce events (purchase, add_to_cart, view_item, etc.)
38
+ - SaaS events (signup, subscription, trial, etc.)
39
+ - Custom event support with type safety
40
+ - Zod schema validation
41
+ - TypeScript types derived from schemas
42
+ - Extensible and composable
43
+
44
+ ## Event Types
45
+
46
+ ### E-commerce
47
+
48
+ - product_viewed
49
+ - add_to_cart
50
+ - remove_from_cart
51
+ - checkout_started
52
+ - purchase
53
+ - refund
54
+
55
+ ### SaaS
56
+
57
+ - user_signed_up
58
+ - user_logged_in
59
+ - subscription_started
60
+ - subscription_cancelled
61
+ - trial_started
62
+ - trial_converted
63
+
64
+ ### Custom Events
65
+
66
+ ```typescript
67
+ import { createCustomEventSchema } from '@sygnl/event-schema';
68
+ import { z } from 'zod';
69
+
70
+ const VideoPlayedSchema = createCustomEventSchema('video_played', z.object({
71
+ video_id: z.string(),
72
+ duration_seconds: z.number(),
73
+ progress_percent: z.number()
74
+ }));
75
+
76
+ const result = VideoPlayedSchema.safeParse(event);
77
+ ```
78
+
79
+ ## API
80
+
81
+ ```typescript
82
+ // Validate any event
83
+ validateEvent(event);
84
+
85
+ // Validate specific type
86
+ PurchaseEventSchema.parse(event);
87
+ AddToCartEventSchema.parse(event);
88
+ UserSignedUpEventSchema.parse(event);
89
+
90
+ // Type inference
91
+ type PurchaseEvent = z.infer<typeof PurchaseEventSchema>;
92
+ ```
93
+
94
+ ## License
95
+
96
+ Apache-2.0
97
+
98
+ Copyright 2026 Edge Foundry, Inc.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sygnl/event-schema",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Unified event schemas for e-commerce and SaaS analytics with TypeScript and Zod validation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",