Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/command-zod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"tsc-alias": "^1.8.7",
"typescript": "^4.6.3",
"vitest": "^0.26.2",
"zod": "^3.15.1"
"zod": "^4.1.11"
},
"maintainers": [
"Thomas Aribart",
Expand All @@ -75,6 +75,6 @@
},
"peerDependencies": {
"@castore/core": "*",
"zod": "^3.0.0"
"zod": "^3.25.0 || ^4.0.0"
}
}
12 changes: 9 additions & 3 deletions packages/command-zod/src/command.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { z, ZodType } from 'zod';
import type * as z3 from 'zod/v3';
import type * as z4 from 'zod/v4/core';

import {
Command,
Expand All @@ -7,6 +8,11 @@ import {
OnEventAlreadyExistsCallback,
} from '@castore/core';

type ZodType = z3.ZodTypeAny | z4.$ZodType;
type inferZodType<T extends ZodType> = T extends z3.ZodTypeAny
? z3.infer<T>
: z4.infer<T>;

export class ZodCommand<
COMMAND_ID extends string = string,
EVENT_STORES extends EventStore[] = EventStore[],
Expand All @@ -18,13 +24,13 @@ export class ZodCommand<
INPUT = $Contravariant<
INPUT_SCHEMA,
ZodType,
INPUT_SCHEMA extends ZodType ? z.infer<INPUT_SCHEMA> : never
INPUT_SCHEMA extends ZodType ? inferZodType<INPUT_SCHEMA> : never
>,
OUTPUT_SCHEMA extends ZodType | undefined = ZodType | undefined,
OUTPUT = $Contravariant<
OUTPUT_SCHEMA,
ZodType,
OUTPUT_SCHEMA extends ZodType ? z.infer<OUTPUT_SCHEMA> : never
OUTPUT_SCHEMA extends ZodType ? inferZodType<OUTPUT_SCHEMA> : never
>,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
CONTEXT extends any[] = any[],
Expand Down
4 changes: 2 additions & 2 deletions packages/event-type-zod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"tsc-alias": "^1.8.7",
"typescript": "^4.6.3",
"vitest": "^0.26.2",
"zod": "^3.15.1"
"zod": "^4.1.11"
},
"maintainers": [
"Thomas Aribart",
Expand All @@ -75,6 +75,6 @@
},
"peerDependencies": {
"@castore/core": "*",
"zod": "^3.0.0"
"zod": "^3.25.0 || ^4.0.0"
}
}
12 changes: 9 additions & 3 deletions packages/event-type-zod/src/eventType.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import type { z, ZodType } from 'zod';
import type * as z3 from 'zod/v3';
import type * as z4 from 'zod/v4/core';

import { EventType } from '@castore/core';

type ZodType = z3.ZodTypeAny | z4.$ZodType;
type inferZodType<T extends ZodType> = T extends z3.ZodTypeAny
? z3.infer<T>
: z4.infer<T>;

export class ZodEventType<
TYPE extends string = string,
PAYLOAD_SCHEMA extends ZodType | undefined = ZodType | undefined,
Expand All @@ -10,15 +16,15 @@ export class ZodEventType<
? unknown
: never
: PAYLOAD_SCHEMA extends ZodType
? z.infer<PAYLOAD_SCHEMA>
? inferZodType<PAYLOAD_SCHEMA>
: never,
METADATA_SCHEMA extends ZodType | undefined = ZodType | undefined,
METADATA = ZodType extends METADATA_SCHEMA
? string extends TYPE
? unknown
: never
: METADATA_SCHEMA extends ZodType
? z.infer<METADATA_SCHEMA>
? inferZodType<METADATA_SCHEMA>
: never,
> extends EventType<TYPE, PAYLOAD, METADATA> {
payloadSchema?: PAYLOAD_SCHEMA;
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6068,7 +6068,7 @@ __metadata:
tsc-alias: ^1.8.7
typescript: ^4.6.3
vitest: ^0.26.2
zod: ^3.15.1
zod: ^4.1.11
peerDependencies:
"@castore/core": "*"
zod: ^3.0.0
Expand Down Expand Up @@ -6418,10 +6418,10 @@ __metadata:
tsc-alias: ^1.8.7
typescript: ^4.6.3
vitest: ^0.26.2
zod: ^3.15.1
zod: ^4.1.11
peerDependencies:
"@castore/core": "*"
zod: ^3.0.0
zod: ^3.25.0 || ^4.0.0
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -28266,10 +28266,10 @@ __metadata:
languageName: node
linkType: hard

"zod@npm:^3.15.1":
version: 3.15.1
resolution: "zod@npm:3.15.1"
checksum: d1ceec91b1b19fe26233c2e6be7625c6d5937c6c667ce23ff7d59948eb1239a24819227c615096a5e6a6377a17fc2df3720e8d613d2176dc482c0a1e8d02e1e2
"zod@npm:^4.1.11":
version: 4.1.11
resolution: "zod@npm:4.1.11"
checksum: 022d59f85ebe054835fbcdc96a93c01479a64321104f846cb5644812c91e00d17ae3479f823956ec9b04e4351dd32841e1f12c567e81bc43f6e21ef5cc02ce3c
languageName: node
linkType: hard

Expand Down
Loading