@rippledb/zod 0.1.1 → 0.1.3
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 +62 -0
- package/package.json +30 -12
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @rippledb/zod
|
|
2
|
+
|
|
3
|
+
Zod schemas for runtime validation of RippleDB types.
|
|
4
|
+
|
|
5
|
+
📚 **Documentation:** [rippledb.dev/docs/reference/zod](https://rippledb.dev/docs/reference/zod)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @rippledb/zod zod
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import {
|
|
17
|
+
pullRequestSchema,
|
|
18
|
+
appendRequestSchema,
|
|
19
|
+
changeSchema,
|
|
20
|
+
createChangeSchema
|
|
21
|
+
} from '@rippledb/zod';
|
|
22
|
+
import { z } from 'zod';
|
|
23
|
+
|
|
24
|
+
// Validate a pull request
|
|
25
|
+
const result = pullRequestSchema.safeParse({
|
|
26
|
+
stream: 'my-stream',
|
|
27
|
+
cursor: null,
|
|
28
|
+
limit: 100,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (result.success) {
|
|
32
|
+
console.log('Valid:', result.data);
|
|
33
|
+
} else {
|
|
34
|
+
console.error('Invalid:', result.error);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Create a typed change schema for your entities
|
|
38
|
+
const todoSchema = z.object({
|
|
39
|
+
id: z.string(),
|
|
40
|
+
title: z.string(),
|
|
41
|
+
done: z.boolean(),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const todoChangeSchema = createChangeSchema(todoSchema);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Available Schemas
|
|
48
|
+
|
|
49
|
+
| Schema | Description |
|
|
50
|
+
|--------|-------------|
|
|
51
|
+
| `hlcSchema` | HLC timestamp format validation |
|
|
52
|
+
| `changeKindSchema` | Change kind ('upsert' \| 'delete') |
|
|
53
|
+
| `changeSchema` | Generic change object |
|
|
54
|
+
| `createChangeSchema(schema)` | Create typed change schema |
|
|
55
|
+
| `pullRequestSchema` | Pull request validation |
|
|
56
|
+
| `pullResponseSchema` | Pull response validation |
|
|
57
|
+
| `appendRequestSchema` | Append request validation |
|
|
58
|
+
| `appendResultSchema` | Append result validation |
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rippledb/zod",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Zod schemas for runtime validation of RippleDB types",
|
|
4
6
|
"private": false,
|
|
5
7
|
"type": "module",
|
|
6
8
|
"sideEffects": false,
|
|
9
|
+
"keywords": [
|
|
10
|
+
"rippledb",
|
|
11
|
+
"zod",
|
|
12
|
+
"validation",
|
|
13
|
+
"schema",
|
|
14
|
+
"sync",
|
|
15
|
+
"crdt",
|
|
16
|
+
"local-first",
|
|
17
|
+
"offline-first"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/eckerlein/rippledb.git",
|
|
22
|
+
"directory": "packages/zod"
|
|
23
|
+
},
|
|
7
24
|
"exports": {
|
|
8
25
|
".": {
|
|
9
26
|
"types": "./dist/index.d.ts",
|
|
@@ -11,27 +28,22 @@
|
|
|
11
28
|
}
|
|
12
29
|
},
|
|
13
30
|
"files": [
|
|
14
|
-
"dist"
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md"
|
|
15
33
|
],
|
|
16
34
|
"dependencies": {
|
|
17
|
-
"@rippledb/core": "
|
|
35
|
+
"@rippledb/core": "0.1.0"
|
|
18
36
|
},
|
|
19
37
|
"peerDependencies": {
|
|
20
38
|
"zod": "^3.0.0"
|
|
21
39
|
},
|
|
22
40
|
"devDependencies": {
|
|
23
|
-
"@rippledb/server": "workspace:*",
|
|
24
41
|
"eslint": "^9.37.0",
|
|
25
42
|
"tsup": "^8.5.0",
|
|
26
43
|
"typescript": "^5.9.3",
|
|
27
44
|
"vitest": "^3.2.4",
|
|
28
|
-
"zod": "^3.24.0"
|
|
29
|
-
|
|
30
|
-
"scripts": {
|
|
31
|
-
"build": "tsup && tsc -p tsconfig.build.json",
|
|
32
|
-
"test": "vitest run --pool=threads",
|
|
33
|
-
"test:watch": "vitest --pool=threads",
|
|
34
|
-
"lint": "eslint ."
|
|
45
|
+
"zod": "^3.24.0",
|
|
46
|
+
"@rippledb/server": "0.1.0"
|
|
35
47
|
},
|
|
36
48
|
"tsup": {
|
|
37
49
|
"entry": [
|
|
@@ -43,5 +55,11 @@
|
|
|
43
55
|
"dts": false,
|
|
44
56
|
"sourcemap": true,
|
|
45
57
|
"clean": true
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsup && tsc -p tsconfig.build.json",
|
|
61
|
+
"test": "vitest run --pool=threads",
|
|
62
|
+
"test:watch": "vitest --pool=threads",
|
|
63
|
+
"lint": "eslint ."
|
|
46
64
|
}
|
|
47
|
-
}
|
|
65
|
+
}
|