@orpc/contract 0.37.0 → 0.38.0
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/dist/src/client.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type ClientContext = Record<string, any>;
|
|
2
|
+
export type ClientOptions<TClientContext extends ClientContext> = {
|
|
2
3
|
signal?: AbortSignal;
|
|
3
|
-
} & (
|
|
4
|
+
} & (Record<never, never> extends TClientContext ? {
|
|
4
5
|
context?: TClientContext;
|
|
5
6
|
} : {
|
|
6
7
|
context: TClientContext;
|
|
7
8
|
});
|
|
8
|
-
export type ClientRest<TClientContext, TInput> = [input: TInput, options: ClientOptions<TClientContext>] | (
|
|
9
|
+
export type ClientRest<TClientContext extends ClientContext, TInput> = [input: TInput, options: ClientOptions<TClientContext>] | (Record<never, never> extends TClientContext ? (undefined extends TInput ? [input?: TInput] : [input: TInput]) : never);
|
|
9
10
|
export type ClientPromiseResult<TOutput, TError extends Error> = Promise<TOutput> & {
|
|
10
11
|
__error?: {
|
|
11
12
|
type: TError;
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
|
-
export interface Client<TClientContext, TInput, TOutput, TError extends Error> {
|
|
15
|
+
export interface Client<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
|
|
15
16
|
(...rest: ClientRest<TClientContext, TInput>): ClientPromiseResult<TOutput, TError>;
|
|
16
17
|
}
|
|
17
|
-
export type NestedClient<TClientContext> = Client<TClientContext, any, any, any> | {
|
|
18
|
+
export type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any, any> | {
|
|
18
19
|
[k: string]: NestedClient<TClientContext>;
|
|
19
20
|
};
|
|
20
21
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/src/error-orpc.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
|
1
2
|
import type { ErrorMap, ErrorMapItem } from './error-map';
|
|
2
3
|
import type { SchemaOutput } from './schema';
|
|
3
4
|
export type ORPCErrorFromErrorMap<TErrorMap extends ErrorMap> = {
|
|
@@ -94,13 +95,12 @@ export type ORPCErrorOptions<TData> = ErrorOptions & {
|
|
|
94
95
|
} : {
|
|
95
96
|
data: TData;
|
|
96
97
|
});
|
|
97
|
-
export type ORPCErrorOptionsRest<TData> = [options: ORPCErrorOptions<TData>] | (undefined extends TData ? [] : never);
|
|
98
98
|
export declare class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
|
|
99
99
|
readonly defined: boolean;
|
|
100
100
|
readonly code: TCode;
|
|
101
101
|
readonly status: number;
|
|
102
102
|
readonly data: TData;
|
|
103
|
-
constructor(code: TCode, ...[options]:
|
|
103
|
+
constructor(code: TCode, ...[options]: MaybeOptionalOptions<ORPCErrorOptions<TData>>);
|
|
104
104
|
toJSON(): ORPCErrorJSON<TCode, TData>;
|
|
105
105
|
static fromJSON<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>): ORPCError<TCode, TData>;
|
|
106
106
|
static isValidJSON(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
|
1
2
|
import type { ErrorMap, ErrorMapItem } from './error-map';
|
|
2
3
|
import type { ORPCErrorCode, ORPCErrorOptions } from './error-orpc';
|
|
3
4
|
import type { SchemaInput } from './schema';
|
|
4
5
|
import { ORPCError } from './error-orpc';
|
|
5
6
|
export declare function isDefinedError<T>(error: T): error is Extract<T, ORPCError<any, any>>;
|
|
6
7
|
export type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
|
|
7
|
-
export type
|
|
8
|
-
export type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: ORPCErrorConstructorMapItemRest<TInData>) => ORPCError<TCode, TInData>;
|
|
8
|
+
export type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
|
|
9
9
|
export type ORPCErrorConstructorMap<T extends ErrorMap> = {
|
|
10
10
|
[K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, SchemaInput<UInputSchema>> : never : never;
|
|
11
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Client } from './client';
|
|
1
|
+
import type { Client, ClientContext } from './client';
|
|
2
2
|
import type { ErrorFromErrorMap } from './error';
|
|
3
3
|
import type { ErrorMap } from './error-map';
|
|
4
4
|
import type { Schema, SchemaInput, SchemaOutput } from './schema';
|
|
5
|
-
export type ContractProcedureClient<TClientContext, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap> = Client<TClientContext, SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
|
5
|
+
export type ContractProcedureClient<TClientContext extends ClientContext, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap> = Client<TClientContext, SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
|
6
6
|
//# sourceMappingURL=procedure-client.d.ts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { ClientContext } from './client';
|
|
1
2
|
import type { ContractProcedure } from './procedure';
|
|
2
3
|
import type { ContractProcedureClient } from './procedure-client';
|
|
3
4
|
import type { AnyContractRouter } from './router';
|
|
4
|
-
export type ContractRouterClient<TRouter extends AnyContractRouter, TClientContext> = TRouter extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ContractProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
|
|
5
|
+
export type ContractRouterClient<TRouter extends AnyContractRouter, TClientContext extends ClientContext> = TRouter extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ContractProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
|
|
5
6
|
[K in keyof TRouter]: TRouter[K] extends AnyContractRouter ? ContractRouterClient<TRouter[K], TClientContext> : never;
|
|
6
7
|
};
|
|
7
8
|
//# sourceMappingURL=router-client.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/contract",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.38.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@standard-schema/spec": "1.0.0",
|
|
33
|
-
"@orpc/shared": "0.
|
|
33
|
+
"@orpc/shared": "0.38.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"arktype": "2.0.0-rc.26",
|