Skip to content

Commit afe026c

Browse files
committed
chore: tweaks on schema & generics
Signed-off-by: tunnckoCore <5038030+tunnckoCore@users.noreply.github.com>
1 parent 2816ad6 commit afe026c

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src-v4/sscore.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,17 @@ type SpreadTuple<T extends readonly any[], R> = T extends readonly [infer A]
108108

109109
export type ZagoraResult<
110110
TOutput,
111-
TErrors extends Record<string, any> | undefined = undefined,
111+
TErrorsMap extends Record<string, AnySchema> | undefined = undefined,
112112
> = {
113113
data: TOutput;
114-
error: TErrors extends Record<string, any>
115-
? TErrors[keyof TErrors] | ZagoraError | null
114+
error: TErrorsMap extends Record<string, any>
115+
? TErrorsMap[keyof TErrorsMap] | ZagoraError | null
116116
: ZagoraError | null;
117117
isTypedError: boolean;
118118
};
119119

120120
export function handleTupleDefaults(
121-
schema: StandardSchemaV1,
121+
schema: AnySchema,
122122
rawArgs: unknown[],
123123
): unknown[] {
124124
// Check if this might be a tuple schema by examining the schema structure
@@ -217,7 +217,7 @@ export interface BuilderDef<
217217
TContext,
218218
TInputSchema extends AnySchema | undefined,
219219
TOutputSchema extends AnySchema | undefined,
220-
TErrorsMap extends Record<string, StandardSchemaV1> | undefined,
220+
TErrorsMap extends Record<string, AnySchema> | undefined,
221221
> {
222222
initialContext: any;
223223
inputSchema: TInputSchema;
@@ -232,29 +232,27 @@ export interface BuilderDef<
232232
export type IsPromise<T> = T extends Promise<any> ? true : false;
233233

234234
export type ErrorHelpers<
235-
TErrorsMap extends Record<string, StandardSchemaV1> | undefined,
236-
> = TErrorsMap extends Record<string, StandardSchemaV1>
235+
TErrorsMap extends Record<string, AnySchema> | undefined,
236+
> = TErrorsMap extends Record<string, AnySchema>
237237
? {
238238
[K in keyof TErrorsMap]: (
239-
data: Prettify<
240-
Omit<StandardSchemaV1.InferInput<TErrorsMap[K]>, "type">
241-
>,
239+
data: Prettify<Omit<InferSchemaInput<TErrorsMap[K]>, "type">>,
242240
) => never;
243241
}
244242
: never;
245243

246244
export type ErrorsMapResolved<
247-
TErrorsMap extends Record<string, StandardSchemaV1> | undefined,
248-
> = TErrorsMap extends Record<string, StandardSchemaV1>
249-
? { [K in keyof TErrorsMap]: StandardSchemaV1.InferInput<TErrorsMap[K]> }
245+
TErrorsMap extends Record<string, AnySchema> | undefined,
246+
> = TErrorsMap extends Record<string, AnySchema>
247+
? { [K in keyof TErrorsMap]: InferSchemaInput<TErrorsMap[K]> }
250248
: undefined;
251249

252250
export interface ProcedureOptions<
253251
TContext,
254-
TErrorsMap extends Record<string, StandardSchemaV1> | undefined,
252+
TErrorsMap extends Record<string, AnySchema> | undefined,
255253
> {
256254
context: TContext;
257-
errors: TErrorsMap extends Record<string, StandardSchemaV1>
255+
errors: TErrorsMap extends Record<string, AnySchema>
258256
? ErrorHelpers<TErrorsMap>
259257
: undefined;
260258
}
@@ -265,7 +263,7 @@ class Builder<
265263
TContext extends any | undefined = undefined,
266264
TInputSchema extends AnySchema = never,
267265
TOutputSchema extends AnySchema = never,
268-
TErrorsMap extends Record<string, StandardSchemaV1> | undefined = undefined,
266+
TErrorsMap extends Record<string, AnySchema> | undefined = undefined,
269267
> {
270268
constructor(
271269
private def: Partial<
@@ -321,7 +319,7 @@ class Builder<
321319
}) as any;
322320
}
323321

324-
errors<TErrors extends Record<string, StandardSchemaV1>>(
322+
errors<TErrors extends Record<string, AnySchema>>(
325323
errorsMap: TErrors,
326324
): Builder<
327325
TIsHandlerAsync,

0 commit comments

Comments
 (0)