@orpc/contract 0.36.1 → 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/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 +0 -1
- package/dist/src/procedure-client.d.ts +2 -2
- package/dist/src/router-client.d.ts +2 -1
- package/package.json +2 -2
- package/dist/src/types.d.ts +0 -3
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 { isObject } 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 isObject(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
|
+
export type ClientContext = Record<string, any>;
|
|
2
|
+
export type ClientOptions<TClientContext extends ClientContext> = {
|
|
3
3
|
signal?: AbortSignal;
|
|
4
|
-
} & (
|
|
4
|
+
} & (Record<never, never> extends TClientContext ? {
|
|
5
5
|
context?: TClientContext;
|
|
6
6
|
} : {
|
|
7
7
|
context: TClientContext;
|
|
8
8
|
});
|
|
9
|
-
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);
|
|
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, TInput, TOutput, TError extends Error> {
|
|
15
|
+
export interface Client<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
|
|
16
16
|
(...rest: ClientRest<TClientContext, TInput>): ClientPromiseResult<TOutput, TError>;
|
|
17
17
|
}
|
|
18
|
-
export type NestedClient<TClientContext> = Client<TClientContext, any, any, any> | {
|
|
18
|
+
export type NestedClient<TClientContext extends ClientContext> = 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,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
|
};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -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",
|
package/dist/src/types.d.ts
DELETED