Skip to content

Commit ff96b07

Browse files
committed
wip
1 parent cd494c6 commit ff96b07

File tree

3 files changed

+18
-26
lines changed

3 files changed

+18
-26
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"typescript",
3333
"socket",
3434
"tcp",
35-
"typebox"
35+
"zod"
3636
],
3737
"author": "Alec Larson",
3838
"contributors": [
@@ -46,7 +46,7 @@
4646
"license": "MIT",
4747
"peerDependencies": {
4848
"@arrowood.dev/socket": ">=0.2.0",
49-
"@sinclair/typebox": "*"
49+
"zod": ">=4.1.0"
5050
},
5151
"peerDependenciesMeta": {
5252
"@arrowood.dev/socket": {
@@ -56,7 +56,6 @@
5656
"devDependencies": {
5757
"@arrowood.dev/socket": "0.2.0",
5858
"@cloudflare/workers-types": "^4.20241011.0",
59-
"@sinclair/typebox": "^0.34.21",
6059
"@types/node": "^22.7.5",
6160
"jsonpath-ts": "^0.1.1",
6261
"prettier": "^3.3.3",
@@ -66,7 +65,8 @@
6665
"tsup": "^8.3.0",
6766
"tsx": "^4.19.1",
6867
"typescript": "^5.6.3",
69-
"vitest": "^3.0.6"
68+
"vitest": "^3.0.6",
69+
"zod": "^4.1.12"
7070
},
7171
"pnpm": {
7272
"patchedDependencies": {

pnpm-lock.yaml

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/transform.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
1-
import * as Type from "@sinclair/typebox/type";
2-
import {
3-
StaticEncode,
4-
TBoolean,
5-
TNumber,
6-
Transform,
7-
TSchema,
8-
} from "@sinclair/typebox/type";
9-
import { Decode, Encode } from "@sinclair/typebox/value";
1+
import * as z from 'zod/v4/classic'
102
import { RedisValue } from "./command";
113

12-
export abstract class RedisTransform<T extends TSchema = TSchema> {
4+
type ZodRedisType = z.ZodType<unknown, RedisValue>
5+
6+
export abstract class RedisTransform<T extends ZodRedisType = ZodRedisType> {
137
readonly schema: T;
148
constructor(schema: T) {
159
this.schema = wrapSchemaForRedis(schema, this.constructor.name) as any;
@@ -18,10 +12,8 @@ export abstract class RedisTransform<T extends TSchema = TSchema> {
1812
/**
1913
* Get a Redis-encoded value from a JS value.
2014
*/
21-
encode(value: unknown): RedisValue {
22-
// The schema is defined for JS, not Redis, so a "decoded" value
23-
// represents a Redis value.
24-
return Decode(this.schema as TSchema, value);
15+
encode(value: z.output<T>): RedisValue {
16+
return this.schema.encode(value)
2517
}
2618

2719
/**

0 commit comments

Comments
 (0)