@orpc/contract 0.0.0-next.b4e6d3a → 0.0.0-next.b825e0c
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/index.js +2 -2
- package/dist/src/client.d.ts +6 -6
- package/dist/src/error-orpc.d.ts +2 -2
- package/dist/src/error-utils.d.ts +2 -2
- package/dist/src/index.d.ts +1 -0
- package/dist/src/procedure-client.d.ts +2 -2
- package/dist/src/router-client.d.ts +1 -2
- package/dist/src/types.d.ts +3 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -161,7 +161,7 @@ var oc = new ContractBuilder({
|
|
|
161
161
|
});
|
|
162
162
|
|
|
163
163
|
// src/error-orpc.ts
|
|
164
|
-
import {
|
|
164
|
+
import { isPlainObject } from "@orpc/shared";
|
|
165
165
|
var COMMON_ORPC_ERROR_DEFS = {
|
|
166
166
|
BAD_REQUEST: {
|
|
167
167
|
status: 400,
|
|
@@ -275,7 +275,7 @@ var ORPCError = class _ORPCError extends Error {
|
|
|
275
275
|
return new _ORPCError(json.code, json);
|
|
276
276
|
}
|
|
277
277
|
static isValidJSON(json) {
|
|
278
|
-
return
|
|
278
|
+
return isPlainObject(json) && "defined" in json && typeof json.defined === "boolean" && "code" in json && typeof json.code === "string" && "status" in json && typeof json.status === "number" && "message" in json && typeof json.message === "string";
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
281
|
|
package/dist/src/client.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
export type ClientOptions<TClientContext
|
|
1
|
+
import type { AbortSignal } from './types';
|
|
2
|
+
export type ClientOptions<TClientContext> = {
|
|
3
3
|
signal?: AbortSignal;
|
|
4
|
-
} & (
|
|
4
|
+
} & (undefined extends TClientContext ? {
|
|
5
5
|
context?: TClientContext;
|
|
6
6
|
} : {
|
|
7
7
|
context: TClientContext;
|
|
8
8
|
});
|
|
9
|
-
export type ClientRest<TClientContext
|
|
9
|
+
export type ClientRest<TClientContext, TInput> = [input: TInput, options: ClientOptions<TClientContext>] | (undefined extends TInput & TClientContext ? [] : never) | (undefined extends TClientContext ? [input: TInput] : never);
|
|
10
10
|
export type ClientPromiseResult<TOutput, TError extends Error> = Promise<TOutput> & {
|
|
11
11
|
__error?: {
|
|
12
12
|
type: TError;
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
export interface Client<TClientContext
|
|
15
|
+
export interface Client<TClientContext, TInput, TOutput, TError extends Error> {
|
|
16
16
|
(...rest: ClientRest<TClientContext, TInput>): ClientPromiseResult<TOutput, TError>;
|
|
17
17
|
}
|
|
18
|
-
export type NestedClient<TClientContext
|
|
18
|
+
export type NestedClient<TClientContext> = Client<TClientContext, any, any, any> | {
|
|
19
19
|
[k: string]: NestedClient<TClientContext>;
|
|
20
20
|
};
|
|
21
21
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/src/error-orpc.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
1
|
import type { ErrorMap, ErrorMapItem } from './error-map';
|
|
3
2
|
import type { SchemaOutput } from './schema';
|
|
4
3
|
export type ORPCErrorFromErrorMap<TErrorMap extends ErrorMap> = {
|
|
@@ -95,12 +94,13 @@ export type ORPCErrorOptions<TData> = ErrorOptions & {
|
|
|
95
94
|
} : {
|
|
96
95
|
data: TData;
|
|
97
96
|
});
|
|
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]: ORPCErrorOptionsRest<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';
|
|
2
1
|
import type { ErrorMap, ErrorMapItem } from './error-map';
|
|
3
2
|
import type { ORPCErrorCode, ORPCErrorOptions } from './error-orpc';
|
|
4
3
|
import type { SchemaInput } from './schema';
|
|
5
4
|
import { ORPCError } from './error-orpc';
|
|
6
5
|
export declare function isDefinedError<T>(error: T): error is Extract<T, ORPCError<any, any>>;
|
|
7
6
|
export type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
|
|
8
|
-
export type
|
|
7
|
+
export type ORPCErrorConstructorMapItemRest<TData> = [options: ORPCErrorConstructorMapItemOptions<TData>] | (undefined extends TData ? [] : never);
|
|
8
|
+
export type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: ORPCErrorConstructorMapItemRest<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
|
};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Client
|
|
1
|
+
import type { Client } 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
|
|
5
|
+
export type ContractProcedureClient<TClientContext, 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,8 +1,7 @@
|
|
|
1
|
-
import type { ClientContext } from './client';
|
|
2
1
|
import type { ContractProcedure } from './procedure';
|
|
3
2
|
import type { ContractProcedureClient } from './procedure-client';
|
|
4
3
|
import type { AnyContractRouter } from './router';
|
|
5
|
-
export type ContractRouterClient<TRouter extends AnyContractRouter, TClientContext
|
|
4
|
+
export type ContractRouterClient<TRouter extends AnyContractRouter, TClientContext> = TRouter extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ContractProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
|
|
6
5
|
[K in keyof TRouter]: TRouter[K] extends AnyContractRouter ? ContractRouterClient<TRouter[K], TClientContext> : never;
|
|
7
6
|
};
|
|
8
7
|
//# 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.0.0-next.
|
|
4
|
+
"version": "0.0.0-next.b825e0c",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@standard-schema/spec": "1.0.0",
|
|
33
|
-
"@orpc/shared": "0.0.0-next.
|
|
32
|
+
"@standard-schema/spec": "1.0.0-rc.0",
|
|
33
|
+
"@orpc/shared": "0.0.0-next.b825e0c"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"arktype": "2.0.0-rc.26",
|
|
37
37
|
"valibot": "1.0.0-beta.9",
|
|
38
|
-
"zod": "
|
|
38
|
+
"zod": "3.24.1"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
|