@vettly/shared 0.1.11 → 0.1.12

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 +117 -12
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,28 +1,133 @@
1
1
  # @vettly/shared
2
2
 
3
- Shared TypeScript types for the Vettly SDK ecosystem.
3
+ Foundational types, schemas, and utilities for Vettly decision infrastructure. Runtime-validated contracts that ensure type safety across all Vettly packages.
4
4
 
5
- ## Vettly Packages
5
+ ## Installation
6
6
 
7
- | Package | Description |
8
- |---------|-------------|
9
- | [@vettly/sdk](https://npmjs.com/package/@vettly/sdk) | Core TypeScript SDK |
10
- | [@vettly/react](https://npmjs.com/package/@vettly/react) | React components |
11
- | [@vettly/express](https://npmjs.com/package/@vettly/express) | Express middleware |
12
- | [@vettly/nextjs](https://npmjs.com/package/@vettly/nextjs) | Next.js integration |
7
+ ```bash
8
+ npm install @vettly/shared
9
+ ```
10
+
11
+ ## Overview
12
+
13
+ This package provides the canonical type definitions and Zod schemas used throughout the Vettly ecosystem. All Vettly packages (`@vettly/sdk`, `@vettly/react`, `@vettly/express`, `@vettly/nextjs`) depend on these shared contracts.
14
+
15
+ ## Core Types
13
16
 
14
- ## Usage
17
+ ### Decision Actions
18
+
19
+ ```typescript
20
+ import type { Action } from '@vettly/shared'
21
+
22
+ // 'block' | 'warn' | 'flag' | 'allow'
23
+ ```
24
+
25
+ ### Content Types
26
+
27
+ ```typescript
28
+ import type { ContentType, UseCaseType } from '@vettly/shared'
29
+
30
+ // ContentType: 'text' | 'image' | 'video'
31
+ // UseCaseType: 'social_post' | 'comment' | 'profile' | 'message' | 'review' | 'listing' | 'bio' | 'other'
32
+ ```
33
+
34
+ ### Categories
35
+
36
+ ```typescript
37
+ import type { Category } from '@vettly/shared'
38
+
39
+ // 'hate_speech' | 'harassment' | 'violence' | 'self_harm' | 'sexual' | 'spam' | 'profanity' | 'scam' | 'illegal'
40
+ ```
41
+
42
+ ### Policy Types
43
+
44
+ ```typescript
45
+ import type { Policy, Rule, Override, FallbackConfig } from '@vettly/shared'
46
+ ```
47
+
48
+ ### Request/Response Types
15
49
 
16
50
  ```typescript
17
51
  import type {
18
52
  CheckRequest,
19
53
  CheckResponse,
20
- Policy,
21
- Category,
22
- Action
54
+ MultiModalCheckRequest,
55
+ MultiModalCheckResponse,
56
+ Decision
23
57
  } from '@vettly/shared'
24
58
  ```
25
59
 
60
+ ## Zod Schemas
61
+
62
+ All types have corresponding Zod schemas for runtime validation:
63
+
64
+ ```typescript
65
+ import {
66
+ ActionSchema,
67
+ CategorySchema,
68
+ ContentTypeSchema,
69
+ PolicySchema,
70
+ CheckRequestSchema,
71
+ CheckResponseSchema,
72
+ DecisionSchema
73
+ } from '@vettly/shared'
74
+
75
+ // Validate incoming data
76
+ const result = CheckRequestSchema.safeParse(untrustedInput)
77
+ if (result.success) {
78
+ // result.data is fully typed
79
+ }
80
+ ```
81
+
82
+ ## Error Types
83
+
84
+ ```typescript
85
+ import {
86
+ ModerationError,
87
+ PolicyValidationError,
88
+ ProviderError
89
+ } from '@vettly/shared'
90
+
91
+ try {
92
+ await client.check(...)
93
+ } catch (error) {
94
+ if (error instanceof PolicyValidationError) {
95
+ // Invalid policy configuration
96
+ }
97
+ }
98
+ ```
99
+
100
+ ## Utilities
101
+
102
+ ```typescript
103
+ import {
104
+ hashContent,
105
+ generateUUID,
106
+ generateRequestId,
107
+ calculatePolicyVersion,
108
+ formatCost,
109
+ formatLatency
110
+ } from '@vettly/shared'
111
+
112
+ // SHA256 content hashing for deduplication
113
+ const hash = hashContent('user content')
114
+
115
+ // Generate idempotency keys
116
+ const requestId = generateRequestId()
117
+
118
+ // Format for display
119
+ formatCost(0.000123) // '$0.000123'
120
+ formatLatency(1250) // '1.25s'
121
+ ```
122
+
123
+ ## Webhook Types
124
+
125
+ ```typescript
126
+ import type { WebhookEventType, WebhookEndpoint } from '@vettly/shared'
127
+
128
+ // Events: 'decision.created' | 'decision.flagged' | 'decision.blocked' | 'policy.created' | 'policy.updated'
129
+ ```
130
+
26
131
  ## Links
27
132
 
28
133
  - [vettly.dev](https://vettly.dev) - Sign up
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vettly/shared",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "Shared TypeScript types for Vettly decision infrastructure",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -33,7 +33,7 @@
33
33
  "license": "MIT",
34
34
  "repository": {
35
35
  "type": "git",
36
- "url": "https://github.com/brian-nextaura/vettly-docs.git",
36
+ "url": "https://github.com/nextauralabs/vettly-docs.git",
37
37
  "directory": "packages/shared"
38
38
  },
39
39
  "homepage": "https://vettly.dev",
@@ -41,7 +41,7 @@
41
41
  "access": "public"
42
42
  },
43
43
  "bugs": {
44
- "url": "https://github.com/brian-nextaura/vettly-docs/issues"
44
+ "url": "https://github.com/nextauralabs/vettly-docs/issues"
45
45
  },
46
46
  "dependencies": {
47
47
  "zod": "^3.22.4"