@orpc/client 0.0.0-next.ee0aeaf → 0.0.0-next.f17a1a0
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/README.md +88 -0
- package/dist/chunk-4FUUNP74.js +212 -0
- package/dist/chunk-OGAGXWCU.js +281 -0
- package/dist/fetch.js +128 -0
- package/dist/index.js +70 -75
- package/dist/openapi.js +231 -0
- package/dist/rpc.js +10 -0
- package/dist/src/adapters/fetch/index.d.ts +3 -0
- package/dist/src/adapters/fetch/rpc-link.d.ts +98 -0
- package/dist/src/adapters/fetch/types.d.ts +5 -0
- package/dist/src/client.d.ts +9 -0
- package/dist/src/dynamic-link.d.ts +12 -0
- package/dist/src/error.d.ts +106 -0
- package/dist/src/event-iterator-state.d.ts +9 -0
- package/dist/src/event-iterator.d.ts +12 -0
- package/dist/src/index.d.ts +7 -5
- package/dist/src/openapi/bracket-notation.d.ts +9 -0
- package/dist/src/openapi/index.d.ts +4 -0
- package/dist/src/openapi/json-serializer.d.ts +7 -0
- package/dist/src/openapi/serializer.d.ts +11 -0
- package/dist/src/rpc/index.d.ts +3 -0
- package/dist/src/rpc/json-serializer.d.ts +12 -0
- package/dist/src/rpc/serializer.d.ts +9 -0
- package/dist/src/types.d.ts +29 -0
- package/dist/src/utils.d.ts +5 -0
- package/package.json +21 -10
- package/dist/src/procedure.d.ts +0 -24
- package/dist/src/router.d.ts +0 -9
@@ -0,0 +1,9 @@
|
|
1
|
+
import { type Segment } from '@orpc/shared';
|
2
|
+
export type BracketNotationSerialized = [string, unknown][];
|
3
|
+
export declare class BracketNotationSerializer {
|
4
|
+
serialize(data: unknown, segments?: Segment[], result?: BracketNotationSerialized): BracketNotationSerialized;
|
5
|
+
deserialize(serialized: BracketNotationSerialized): unknown;
|
6
|
+
stringifyPath(segments: readonly Segment[]): string;
|
7
|
+
parsePath(path: string): string[];
|
8
|
+
}
|
9
|
+
//# sourceMappingURL=bracket-notation.d.ts.map
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { BracketNotationSerializer } from './bracket-notation';
|
2
|
+
import { OpenAPIJsonSerializer } from './json-serializer';
|
3
|
+
export declare class OpenAPISerializer {
|
4
|
+
#private;
|
5
|
+
private readonly jsonSerializer;
|
6
|
+
private readonly bracketNotation;
|
7
|
+
constructor(jsonSerializer?: OpenAPIJsonSerializer, bracketNotation?: BracketNotationSerializer);
|
8
|
+
serialize(data: unknown): unknown;
|
9
|
+
deserialize(data: unknown): unknown;
|
10
|
+
}
|
11
|
+
//# sourceMappingURL=serializer.d.ts.map
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { type Segment } from '@orpc/shared';
|
2
|
+
export type RPCJsonSerializedMeta = [
|
3
|
+
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7,
|
4
|
+
Segment[]
|
5
|
+
][];
|
6
|
+
export type RPCJsonSerialized = [json: unknown, meta: RPCJsonSerializedMeta, maps: Segment[][], blobs: Blob[]];
|
7
|
+
export declare class RPCJsonSerializer {
|
8
|
+
serialize(data: unknown, segments?: Segment[], meta?: RPCJsonSerializedMeta, maps?: Segment[][], blobs?: Blob[]): RPCJsonSerialized;
|
9
|
+
deserialize(json: unknown, meta: RPCJsonSerializedMeta): unknown;
|
10
|
+
deserialize(json: unknown, meta: RPCJsonSerializedMeta, maps: Segment[][], getBlob: (index: number) => Blob): unknown;
|
11
|
+
}
|
12
|
+
//# sourceMappingURL=json-serializer.d.ts.map
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { RPCJsonSerializer } from './json-serializer';
|
2
|
+
export declare class RPCSerializer {
|
3
|
+
#private;
|
4
|
+
private readonly jsonSerializer;
|
5
|
+
constructor(jsonSerializer?: RPCJsonSerializer);
|
6
|
+
serialize(data: unknown): unknown;
|
7
|
+
deserialize(data: unknown): unknown;
|
8
|
+
}
|
9
|
+
//# sourceMappingURL=serializer.d.ts.map
|
@@ -0,0 +1,29 @@
|
|
1
|
+
export type ClientContext = Record<string, any>;
|
2
|
+
export type ClientOptions<TClientContext extends ClientContext> = {
|
3
|
+
signal?: AbortSignal;
|
4
|
+
lastEventId?: string | undefined;
|
5
|
+
} & (Record<never, never> extends TClientContext ? {
|
6
|
+
context?: TClientContext;
|
7
|
+
} : {
|
8
|
+
context: TClientContext;
|
9
|
+
});
|
10
|
+
export type ClientRest<TClientContext extends ClientContext, TInput> = Record<never, never> extends TClientContext ? undefined extends TInput ? [input?: TInput, options?: ClientOptions<TClientContext>] : [input: TInput, options?: ClientOptions<TClientContext>] : [input: TInput, options: ClientOptions<TClientContext>];
|
11
|
+
export type ClientPromiseResult<TOutput, TError extends Error> = Promise<TOutput> & {
|
12
|
+
__error?: {
|
13
|
+
type: TError;
|
14
|
+
};
|
15
|
+
};
|
16
|
+
export interface Client<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
|
17
|
+
(...rest: ClientRest<TClientContext, TInput>): ClientPromiseResult<TOutput, TError>;
|
18
|
+
}
|
19
|
+
export type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any, any> | {
|
20
|
+
[k: string]: NestedClient<TClientContext>;
|
21
|
+
};
|
22
|
+
export type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
|
23
|
+
export type ClientOptionsOut<TClientContext extends ClientContext> = ClientOptions<TClientContext> & {
|
24
|
+
context: TClientContext;
|
25
|
+
};
|
26
|
+
export interface ClientLink<TClientContext extends ClientContext> {
|
27
|
+
call: (path: readonly string[], input: unknown, options: ClientOptionsOut<TClientContext>) => Promise<unknown>;
|
28
|
+
}
|
29
|
+
//# sourceMappingURL=types.d.ts.map
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import type { ORPCError } from './error';
|
2
|
+
import type { ClientPromiseResult } from './types';
|
3
|
+
export type SafeResult<TOutput, TError extends Error> = [output: TOutput, error: undefined, isDefinedError: false] | [output: undefined, error: TError, isDefinedError: false] | [output: undefined, error: Extract<TError, ORPCError<any, any>>, isDefinedError: true];
|
4
|
+
export declare function safe<TOutput, TError extends Error>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
|
5
|
+
//# sourceMappingURL=utils.d.ts.map
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/client",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0-next.
|
4
|
+
"version": "0.0.0-next.f17a1a0",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -19,6 +19,21 @@
|
|
19
19
|
"import": "./dist/index.js",
|
20
20
|
"default": "./dist/index.js"
|
21
21
|
},
|
22
|
+
"./openapi": {
|
23
|
+
"types": "./dist/src/openapi/index.d.ts",
|
24
|
+
"import": "./dist/openapi.js",
|
25
|
+
"default": "./dist/openapi.js"
|
26
|
+
},
|
27
|
+
"./rpc": {
|
28
|
+
"types": "./dist/src/rpc/index.d.ts",
|
29
|
+
"import": "./dist/rpc.js",
|
30
|
+
"default": "./dist/rpc.js"
|
31
|
+
},
|
32
|
+
"./fetch": {
|
33
|
+
"types": "./dist/src/adapters/fetch/index.d.ts",
|
34
|
+
"import": "./dist/fetch.js",
|
35
|
+
"default": "./dist/fetch.js"
|
36
|
+
},
|
22
37
|
"./🔒/*": {
|
23
38
|
"types": "./dist/src/*.d.ts"
|
24
39
|
}
|
@@ -28,20 +43,16 @@
|
|
28
43
|
"!**/*.tsbuildinfo",
|
29
44
|
"dist"
|
30
45
|
],
|
31
|
-
"peerDependencies": {
|
32
|
-
"@orpc/contract": "0.0.0-next.ee0aeaf",
|
33
|
-
"@orpc/server": "0.0.0-next.ee0aeaf"
|
34
|
-
},
|
35
46
|
"dependencies": {
|
36
|
-
"@orpc/
|
37
|
-
"@orpc/
|
47
|
+
"@orpc/server-standard": "^0.4.0",
|
48
|
+
"@orpc/server-standard-fetch": "^0.4.0",
|
49
|
+
"@orpc/shared": "0.0.0-next.f17a1a0"
|
38
50
|
},
|
39
51
|
"devDependencies": {
|
40
|
-
"zod": "^3.24.1"
|
41
|
-
"@orpc/openapi": "0.0.0-next.ee0aeaf"
|
52
|
+
"zod": "^3.24.1"
|
42
53
|
},
|
43
54
|
"scripts": {
|
44
|
-
"build": "tsup --
|
55
|
+
"build": "tsup --onSuccess='tsc -b --noCheck'",
|
45
56
|
"build:watch": "pnpm run build --watch",
|
46
57
|
"type:check": "tsc -b"
|
47
58
|
}
|
package/dist/src/procedure.d.ts
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
import type { Caller } from '@orpc/server';
|
2
|
-
import type { Promisable } from '@orpc/shared';
|
3
|
-
export interface CreateProcedureClientOptions {
|
4
|
-
/**
|
5
|
-
* The base url of the server.
|
6
|
-
*/
|
7
|
-
baseURL: string;
|
8
|
-
/**
|
9
|
-
* The fetch function used to make the request.
|
10
|
-
* @default global fetch
|
11
|
-
*/
|
12
|
-
fetch?: typeof fetch;
|
13
|
-
/**
|
14
|
-
* The headers used to make the request.
|
15
|
-
* Invoked before the request is made.
|
16
|
-
*/
|
17
|
-
headers?: (input: unknown) => Promisable<Headers | Record<string, string>>;
|
18
|
-
/**
|
19
|
-
* The path of the procedure on server.
|
20
|
-
*/
|
21
|
-
path: string[];
|
22
|
-
}
|
23
|
-
export declare function createProcedureClient<TInput, TOutput>(options: CreateProcedureClientOptions): Caller<TInput, TOutput>;
|
24
|
-
//# sourceMappingURL=procedure.d.ts.map
|
package/dist/src/router.d.ts
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
import type { ContractProcedure, ContractRouter, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { Caller, Lazy, Procedure, Router } from '@orpc/server';
|
3
|
-
import type { SetOptional } from '@orpc/shared';
|
4
|
-
import type { CreateProcedureClientOptions } from './procedure';
|
5
|
-
export type RouterClient<T extends Router<any> | ContractRouter> = {
|
6
|
-
[K in keyof T]: T[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema> | Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput> | Lazy<Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput>> ? Caller<SchemaInput<UInputSchema>, SchemaOutput<UOutputSchema, UFuncOutput>> : T[K] extends Router<any> | ContractRouter ? RouterClient<T[K]> : never;
|
7
|
-
};
|
8
|
-
export declare function createRouterClient<T extends Router<any> | ContractRouter>(options: SetOptional<CreateProcedureClientOptions, 'path'>): RouterClient<T>;
|
9
|
-
//# sourceMappingURL=router.d.ts.map
|