@orpc/client 0.0.0-next.b5ac9a3 → 0.0.0-next.b5b7502

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.
@@ -1,12 +1,11 @@
1
- import { C as ClientPlugin, S as StandardLinkOptions } from '../shared/client.DrOAzyMB.mjs';
2
- export { a as CompositeClientPlugin } from '../shared/client.DrOAzyMB.mjs';
3
1
  import { Value } from '@orpc/shared';
4
- import { C as ClientOptionsOut, a as ClientContext } from '../shared/client.CupM8eRP.mjs';
2
+ import { S as StandardLinkPlugin, a as StandardLinkOptions } from '../shared/client.5813Ufvs.mjs';
3
+ import { b as ClientOptions } from '../shared/client.C0lT7w02.mjs';
5
4
  import '@orpc/standard-server';
6
5
 
7
6
  interface ClientRetryPluginAttemptOptions {
8
- eventIteratorLastRetry: number | undefined;
9
- eventIteratorLastEventId: string | undefined;
7
+ lastEventRetry: number | undefined;
8
+ lastEventId: string | undefined;
10
9
  attemptIndex: number;
11
10
  error: unknown;
12
11
  }
@@ -17,15 +16,19 @@ interface ClientRetryPluginContext {
17
16
  *
18
17
  * @default 0
19
18
  */
20
- retry?: number;
19
+ retry?: Value<number, [
20
+ clientOptions: ClientOptions<ClientRetryPluginContext>,
21
+ path: readonly string[],
22
+ input: unknown
23
+ ]>;
21
24
  /**
22
25
  * Delay (in ms) before retrying.
23
26
  *
24
- * @default (o) => o.eventIteratorLastRetry ?? 2000
27
+ * @default (o) => o.lastEventRetry ?? 2000
25
28
  */
26
29
  retryDelay?: Value<number, [
27
30
  attemptOptions: ClientRetryPluginAttemptOptions,
28
- clientOptions: ClientOptionsOut<ClientRetryPluginContext>,
31
+ clientOptions: ClientOptions<ClientRetryPluginContext>,
29
32
  path: readonly string[],
30
33
  input: unknown
31
34
  ]>;
@@ -36,21 +39,21 @@ interface ClientRetryPluginContext {
36
39
  */
37
40
  shouldRetry?: Value<boolean, [
38
41
  attemptOptions: ClientRetryPluginAttemptOptions,
39
- clientOptions: ClientOptionsOut<ClientRetryPluginContext>,
42
+ clientOptions: ClientOptions<ClientRetryPluginContext>,
40
43
  path: readonly string[],
41
44
  input: unknown
42
45
  ]>;
43
46
  /**
44
47
  * The hook called when retrying, and return the unsubscribe function.
45
48
  */
46
- onRetry?: (options: ClientRetryPluginAttemptOptions, clientOptions: ClientOptionsOut<ClientRetryPluginContext>, path: readonly string[], input: unknown) => void | (() => void);
49
+ onRetry?: (options: ClientRetryPluginAttemptOptions, clientOptions: ClientOptions<ClientRetryPluginContext>, path: readonly string[], input: unknown) => void | (() => void);
47
50
  }
48
51
  declare class ClientRetryPluginInvalidEventIteratorRetryResponse extends Error {
49
52
  }
50
53
  interface ClientRetryPluginOptions {
51
54
  default?: ClientRetryPluginContext;
52
55
  }
53
- declare class ClientRetryPlugin<T extends ClientContext & ClientRetryPluginContext> implements ClientPlugin<T> {
56
+ declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements StandardLinkPlugin<T> {
54
57
  private readonly defaultRetry;
55
58
  private readonly defaultRetryDelay;
56
59
  private readonly defaultShouldRetry;
@@ -59,4 +62,4 @@ declare class ClientRetryPlugin<T extends ClientContext & ClientRetryPluginConte
59
62
  init(options: StandardLinkOptions<T>): void;
60
63
  }
61
64
 
62
- export { ClientPlugin, ClientRetryPlugin, type ClientRetryPluginAttemptOptions, type ClientRetryPluginContext, ClientRetryPluginInvalidEventIteratorRetryResponse, type ClientRetryPluginOptions };
65
+ export { ClientRetryPlugin, type ClientRetryPluginAttemptOptions, type ClientRetryPluginContext, ClientRetryPluginInvalidEventIteratorRetryResponse, type ClientRetryPluginOptions };
@@ -1,12 +1,11 @@
1
- import { C as ClientPlugin, S as StandardLinkOptions } from '../shared/client.aGal-uGY.js';
2
- export { a as CompositeClientPlugin } from '../shared/client.aGal-uGY.js';
3
1
  import { Value } from '@orpc/shared';
4
- import { C as ClientOptionsOut, a as ClientContext } from '../shared/client.CupM8eRP.js';
2
+ import { S as StandardLinkPlugin, a as StandardLinkOptions } from '../shared/client.grRbC25r.js';
3
+ import { b as ClientOptions } from '../shared/client.C0lT7w02.js';
5
4
  import '@orpc/standard-server';
6
5
 
7
6
  interface ClientRetryPluginAttemptOptions {
8
- eventIteratorLastRetry: number | undefined;
9
- eventIteratorLastEventId: string | undefined;
7
+ lastEventRetry: number | undefined;
8
+ lastEventId: string | undefined;
10
9
  attemptIndex: number;
11
10
  error: unknown;
12
11
  }
@@ -17,15 +16,19 @@ interface ClientRetryPluginContext {
17
16
  *
18
17
  * @default 0
19
18
  */
20
- retry?: number;
19
+ retry?: Value<number, [
20
+ clientOptions: ClientOptions<ClientRetryPluginContext>,
21
+ path: readonly string[],
22
+ input: unknown
23
+ ]>;
21
24
  /**
22
25
  * Delay (in ms) before retrying.
23
26
  *
24
- * @default (o) => o.eventIteratorLastRetry ?? 2000
27
+ * @default (o) => o.lastEventRetry ?? 2000
25
28
  */
26
29
  retryDelay?: Value<number, [
27
30
  attemptOptions: ClientRetryPluginAttemptOptions,
28
- clientOptions: ClientOptionsOut<ClientRetryPluginContext>,
31
+ clientOptions: ClientOptions<ClientRetryPluginContext>,
29
32
  path: readonly string[],
30
33
  input: unknown
31
34
  ]>;
@@ -36,21 +39,21 @@ interface ClientRetryPluginContext {
36
39
  */
37
40
  shouldRetry?: Value<boolean, [
38
41
  attemptOptions: ClientRetryPluginAttemptOptions,
39
- clientOptions: ClientOptionsOut<ClientRetryPluginContext>,
42
+ clientOptions: ClientOptions<ClientRetryPluginContext>,
40
43
  path: readonly string[],
41
44
  input: unknown
42
45
  ]>;
43
46
  /**
44
47
  * The hook called when retrying, and return the unsubscribe function.
45
48
  */
46
- onRetry?: (options: ClientRetryPluginAttemptOptions, clientOptions: ClientOptionsOut<ClientRetryPluginContext>, path: readonly string[], input: unknown) => void | (() => void);
49
+ onRetry?: (options: ClientRetryPluginAttemptOptions, clientOptions: ClientOptions<ClientRetryPluginContext>, path: readonly string[], input: unknown) => void | (() => void);
47
50
  }
48
51
  declare class ClientRetryPluginInvalidEventIteratorRetryResponse extends Error {
49
52
  }
50
53
  interface ClientRetryPluginOptions {
51
54
  default?: ClientRetryPluginContext;
52
55
  }
53
- declare class ClientRetryPlugin<T extends ClientContext & ClientRetryPluginContext> implements ClientPlugin<T> {
56
+ declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements StandardLinkPlugin<T> {
54
57
  private readonly defaultRetry;
55
58
  private readonly defaultRetryDelay;
56
59
  private readonly defaultShouldRetry;
@@ -59,4 +62,4 @@ declare class ClientRetryPlugin<T extends ClientContext & ClientRetryPluginConte
59
62
  init(options: StandardLinkOptions<T>): void;
60
63
  }
61
64
 
62
- export { ClientPlugin, ClientRetryPlugin, type ClientRetryPluginAttemptOptions, type ClientRetryPluginContext, ClientRetryPluginInvalidEventIteratorRetryResponse, type ClientRetryPluginOptions };
65
+ export { ClientRetryPlugin, type ClientRetryPluginAttemptOptions, type ClientRetryPluginContext, ClientRetryPluginInvalidEventIteratorRetryResponse, type ClientRetryPluginOptions };
@@ -1,5 +1,4 @@
1
- export { C as CompositeClientPlugin } from '../shared/client.CvnV7_uV.mjs';
2
- import { isAsyncIteratorObject, value } from '@orpc/shared';
1
+ import { value, isAsyncIteratorObject } from '@orpc/shared';
3
2
  import { getEventMeta } from '@orpc/standard-server';
4
3
 
5
4
  class ClientRetryPluginInvalidEventIteratorRetryResponse extends Error {
@@ -11,27 +10,33 @@ class ClientRetryPlugin {
11
10
  defaultOnRetry;
12
11
  constructor(options = {}) {
13
12
  this.defaultRetry = options.default?.retry ?? 0;
14
- this.defaultRetryDelay = options.default?.retryDelay ?? ((o) => o.eventIteratorLastRetry ?? 2e3);
13
+ this.defaultRetryDelay = options.default?.retryDelay ?? ((o) => o.lastEventRetry ?? 2e3);
15
14
  this.defaultShouldRetry = options.default?.shouldRetry ?? true;
16
15
  this.defaultOnRetry = options.default?.onRetry;
17
16
  }
18
17
  init(options) {
19
18
  options.interceptors ??= [];
20
19
  options.interceptors.push(async (interceptorOptions) => {
21
- const maxAttempts = interceptorOptions.options.context.retry ?? this.defaultRetry;
20
+ const maxAttempts = await value(
21
+ interceptorOptions.options.context.retry ?? this.defaultRetry,
22
+ interceptorOptions.options,
23
+ interceptorOptions.path,
24
+ interceptorOptions.input
25
+ );
22
26
  const retryDelay = interceptorOptions.options.context.retryDelay ?? this.defaultRetryDelay;
23
27
  const shouldRetry = interceptorOptions.options.context.shouldRetry ?? this.defaultShouldRetry;
24
28
  const onRetry = interceptorOptions.options.context.onRetry ?? this.defaultOnRetry;
25
29
  if (maxAttempts <= 0) {
26
30
  return interceptorOptions.next();
27
31
  }
28
- let eventIteratorLastEventId = interceptorOptions.options.lastEventId;
29
- let eventIteratorLastRetry;
32
+ let lastEventId = interceptorOptions.options.lastEventId;
33
+ let lastEventRetry;
30
34
  let unsubscribe;
31
35
  let attemptIndex = 0;
32
36
  const next = async (initial) => {
33
37
  let current = initial;
34
38
  while (true) {
39
+ const newClientOptions = { ...interceptorOptions.options, lastEventId };
35
40
  if (current) {
36
41
  if (attemptIndex >= maxAttempts) {
37
42
  throw current.error;
@@ -39,13 +44,13 @@ class ClientRetryPlugin {
39
44
  const attemptOptions = {
40
45
  attemptIndex,
41
46
  error: current.error,
42
- eventIteratorLastEventId,
43
- eventIteratorLastRetry
47
+ lastEventId,
48
+ lastEventRetry
44
49
  };
45
50
  const shouldRetryBool = await value(
46
51
  shouldRetry,
47
52
  attemptOptions,
48
- interceptorOptions.options,
53
+ newClientOptions,
49
54
  interceptorOptions.path,
50
55
  interceptorOptions.input
51
56
  );
@@ -54,14 +59,14 @@ class ClientRetryPlugin {
54
59
  }
55
60
  unsubscribe = onRetry?.(
56
61
  attemptOptions,
57
- interceptorOptions.options,
62
+ newClientOptions,
58
63
  interceptorOptions.path,
59
64
  interceptorOptions.input
60
65
  );
61
66
  const retryDelayMs = await value(
62
67
  retryDelay,
63
68
  attemptOptions,
64
- interceptorOptions.options,
69
+ newClientOptions,
65
70
  interceptorOptions.path,
66
71
  interceptorOptions.input
67
72
  );
@@ -69,14 +74,13 @@ class ClientRetryPlugin {
69
74
  attemptIndex++;
70
75
  }
71
76
  try {
72
- const newClientOptions = { ...interceptorOptions.options, lastEventId: eventIteratorLastEventId };
73
77
  const output2 = await interceptorOptions.next({
74
78
  ...interceptorOptions,
75
79
  options: newClientOptions
76
80
  });
77
81
  return output2;
78
82
  } catch (error) {
79
- if (interceptorOptions.options.signal?.aborted === true) {
83
+ if (newClientOptions.signal?.aborted === true) {
80
84
  throw error;
81
85
  }
82
86
  current = { error };
@@ -97,16 +101,16 @@ class ClientRetryPlugin {
97
101
  try {
98
102
  const item = await current.next();
99
103
  const meta = getEventMeta(item.value);
100
- eventIteratorLastEventId = meta?.id ?? eventIteratorLastEventId;
101
- eventIteratorLastRetry = meta?.retry ?? eventIteratorLastRetry;
104
+ lastEventId = meta?.id ?? lastEventId;
105
+ lastEventRetry = meta?.retry ?? lastEventRetry;
102
106
  if (item.done) {
103
107
  return item.value;
104
108
  }
105
109
  yield item.value;
106
110
  } catch (error) {
107
111
  const meta = getEventMeta(error);
108
- eventIteratorLastEventId = meta?.id ?? eventIteratorLastEventId;
109
- eventIteratorLastRetry = meta?.retry ?? eventIteratorLastRetry;
112
+ lastEventId = meta?.id ?? lastEventId;
113
+ lastEventRetry = meta?.retry ?? lastEventRetry;
110
114
  const maybeEventIterator = await next({ error });
111
115
  if (!isAsyncIteratorObject(maybeEventIterator)) {
112
116
  throw new ClientRetryPluginInvalidEventIteratorRetryResponse(
@@ -1,27 +1,30 @@
1
- import { Interceptor } from '@orpc/shared';
1
+ import { Interceptor, ThrowableError } from '@orpc/shared';
2
2
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
3
- import { a as ClientContext, C as ClientOptionsOut, b as ClientLink } from './client.CupM8eRP.js';
3
+ import { a as ClientContext, b as ClientOptions, C as ClientLink } from './client.C0lT7w02.mjs';
4
4
 
5
5
  interface StandardLinkCodec<T extends ClientContext> {
6
- encode(path: readonly string[], input: unknown, options: ClientOptionsOut<any>): Promise<StandardRequest>;
7
- decode(response: StandardLazyResponse, options: ClientOptionsOut<T>, path: readonly string[], input: unknown): Promise<unknown>;
6
+ encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
7
+ decode(response: StandardLazyResponse, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<unknown>;
8
8
  }
9
9
  interface StandardLinkClient<T extends ClientContext> {
10
- call(request: StandardRequest, options: ClientOptionsOut<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
10
+ call(request: StandardRequest, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
11
11
  }
12
12
 
13
13
  declare class InvalidEventIteratorRetryResponse extends Error {
14
14
  }
15
+ interface StandardLinkPlugin<T extends ClientContext> {
16
+ init?(options: StandardLinkOptions<T>): void;
17
+ }
15
18
  interface StandardLinkOptions<T extends ClientContext> {
16
19
  interceptors?: Interceptor<{
17
20
  path: readonly string[];
18
21
  input: unknown;
19
- options: ClientOptionsOut<T>;
20
- }, unknown, unknown>[];
22
+ options: ClientOptions<T>;
23
+ }, unknown, ThrowableError>[];
21
24
  clientInterceptors?: Interceptor<{
22
25
  request: StandardRequest;
23
- }, StandardLazyResponse, unknown>[];
24
- plugins?: ClientPlugin<T>[];
26
+ }, StandardLazyResponse, ThrowableError>[];
27
+ plugins?: StandardLinkPlugin<T>[];
25
28
  }
26
29
  declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
27
30
  #private;
@@ -30,16 +33,7 @@ declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
30
33
  private readonly interceptors;
31
34
  private readonly clientInterceptors;
32
35
  constructor(codec: StandardLinkCodec<T>, sender: StandardLinkClient<T>, options?: StandardLinkOptions<T>);
33
- call(path: readonly string[], input: unknown, options: ClientOptionsOut<T>): Promise<unknown>;
34
- }
35
-
36
- interface ClientPlugin<T extends ClientContext> {
37
- init?(options: StandardLinkOptions<T>): void;
38
- }
39
- declare class CompositeClientPlugin<T extends ClientContext> implements ClientPlugin<T> {
40
- private readonly plugins;
41
- constructor(plugins?: ClientPlugin<T>[]);
42
- init(options: StandardLinkOptions<T>): void;
36
+ call(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<unknown>;
43
37
  }
44
38
 
45
- export { type ClientPlugin as C, InvalidEventIteratorRetryResponse as I, type StandardLinkOptions as S, CompositeClientPlugin as a, type StandardLinkClient as b, type StandardLinkCodec as c, StandardLink as d };
39
+ export { InvalidEventIteratorRetryResponse as I, type StandardLinkPlugin as S, type StandardLinkOptions as a, StandardLink as b, type StandardLinkCodec as c, type StandardLinkClient as d };
@@ -0,0 +1,103 @@
1
+ import { a as ClientContext, b as ClientOptions, d as HTTPMethod } from './client.C0lT7w02.mjs';
2
+ import { c as StandardLinkCodec, a as StandardLinkOptions } from './client.5813Ufvs.mjs';
3
+ import { Segment, Value } from '@orpc/shared';
4
+ import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
5
+
6
+ declare const STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES: {
7
+ readonly BIGINT: 0;
8
+ readonly DATE: 1;
9
+ readonly NAN: 2;
10
+ readonly UNDEFINED: 3;
11
+ readonly URL: 4;
12
+ readonly REGEXP: 5;
13
+ readonly SET: 6;
14
+ readonly MAP: 7;
15
+ };
16
+ type StandardRPCJsonSerializedMetaItem = readonly [type: number, ...path: Segment[]];
17
+ type StandardRPCJsonSerialized = [json: unknown, meta: StandardRPCJsonSerializedMetaItem[], maps: Segment[][], blobs: Blob[]];
18
+ interface StandardRPCCustomJsonSerializer {
19
+ type: number;
20
+ condition(data: unknown): boolean;
21
+ serialize(data: any): unknown;
22
+ deserialize(serialized: any): unknown;
23
+ }
24
+ interface StandardRPCJsonSerializerOptions {
25
+ customJsonSerializers?: readonly StandardRPCCustomJsonSerializer[];
26
+ }
27
+ declare class StandardRPCJsonSerializer {
28
+ private readonly customSerializers;
29
+ constructor(options?: StandardRPCJsonSerializerOptions);
30
+ serialize(data: unknown, segments?: Segment[], meta?: StandardRPCJsonSerializedMetaItem[], maps?: Segment[][], blobs?: Blob[]): StandardRPCJsonSerialized;
31
+ deserialize(json: unknown, meta: readonly StandardRPCJsonSerializedMetaItem[]): unknown;
32
+ deserialize(json: unknown, meta: readonly StandardRPCJsonSerializedMetaItem[], maps: readonly Segment[][], getBlob: (index: number) => Blob): unknown;
33
+ }
34
+
35
+ declare class StandardRPCSerializer {
36
+ #private;
37
+ private readonly jsonSerializer;
38
+ constructor(jsonSerializer: StandardRPCJsonSerializer);
39
+ serialize(data: unknown): object;
40
+ deserialize(data: unknown): unknown;
41
+ }
42
+
43
+ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
44
+ /**
45
+ * Base url for all requests.
46
+ */
47
+ url: Value<string | URL, [
48
+ options: ClientOptions<T>,
49
+ path: readonly string[],
50
+ input: unknown
51
+ ]>;
52
+ /**
53
+ * The maximum length of the URL.
54
+ *
55
+ * @default 2083
56
+ */
57
+ maxUrlLength?: Value<number, [
58
+ options: ClientOptions<T>,
59
+ path: readonly string[],
60
+ input: unknown
61
+ ]>;
62
+ /**
63
+ * The method used to make the request.
64
+ *
65
+ * @default 'POST'
66
+ */
67
+ method?: Value<HTTPMethod, [
68
+ options: ClientOptions<T>,
69
+ path: readonly string[],
70
+ input: unknown
71
+ ]>;
72
+ /**
73
+ * The method to use when the payload cannot safely pass to the server with method return from method function.
74
+ * GET is not allowed, it's very dangerous.
75
+ *
76
+ * @default 'POST'
77
+ */
78
+ fallbackMethod?: Exclude<HTTPMethod, 'GET'>;
79
+ /**
80
+ * Inject headers to the request.
81
+ */
82
+ headers?: Value<StandardHeaders, [
83
+ options: ClientOptions<T>,
84
+ path: readonly string[],
85
+ input: unknown
86
+ ]>;
87
+ }
88
+ declare class StandardRPCLinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
89
+ private readonly serializer;
90
+ private readonly baseUrl;
91
+ private readonly maxUrlLength;
92
+ private readonly fallbackMethod;
93
+ private readonly expectedMethod;
94
+ private readonly headers;
95
+ constructor(serializer: StandardRPCSerializer, options: StandardRPCLinkCodecOptions<T>);
96
+ encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
97
+ decode(response: StandardLazyResponse): Promise<unknown>;
98
+ }
99
+
100
+ interface StandardRPCLinkOptions<T extends ClientContext> extends StandardLinkOptions<T>, StandardRPCLinkCodecOptions<T>, StandardRPCJsonSerializerOptions {
101
+ }
102
+
103
+ export { STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES as S, type StandardRPCJsonSerializedMetaItem as a, type StandardRPCJsonSerialized as b, type StandardRPCCustomJsonSerializer as c, type StandardRPCJsonSerializerOptions as d, StandardRPCJsonSerializer as e, type StandardRPCLinkOptions as f, type StandardRPCLinkCodecOptions as g, StandardRPCLinkCodec as h, StandardRPCSerializer as i };
@@ -0,0 +1,30 @@
1
+ import { PromiseWithError } from '@orpc/shared';
2
+
3
+ type HTTPPath = `/${string}`;
4
+ type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
5
+ type ClientContext = Record<PropertyKey, any>;
6
+ type FriendlyClientOptions<TClientContext extends ClientContext> = {
7
+ signal?: AbortSignal;
8
+ lastEventId?: string | undefined;
9
+ } & (Record<never, never> extends TClientContext ? {
10
+ context?: TClientContext;
11
+ } : {
12
+ context: TClientContext;
13
+ });
14
+ type ClientRest<TClientContext extends ClientContext, TInput> = Record<never, never> extends TClientContext ? undefined extends TInput ? [input?: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options: FriendlyClientOptions<TClientContext>];
15
+ type ClientPromiseResult<TOutput, TError> = PromiseWithError<TOutput, TError>;
16
+ interface Client<TClientContext extends ClientContext, TInput, TOutput, TError> {
17
+ (...rest: ClientRest<TClientContext, TInput>): ClientPromiseResult<TOutput, TError>;
18
+ }
19
+ type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any, any> | {
20
+ [k: string]: NestedClient<TClientContext>;
21
+ };
22
+ type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
23
+ type ClientOptions<TClientContext extends ClientContext> = FriendlyClientOptions<TClientContext> & {
24
+ context: TClientContext;
25
+ };
26
+ interface ClientLink<TClientContext extends ClientContext> {
27
+ call: (path: readonly string[], input: unknown, options: ClientOptions<TClientContext>) => Promise<unknown>;
28
+ }
29
+
30
+ export type { ClientLink as C, FriendlyClientOptions as F, HTTPPath as H, InferClientContext as I, NestedClient as N, ClientContext as a, ClientOptions as b, ClientPromiseResult as c, HTTPMethod as d, ClientRest as e, Client as f };
@@ -0,0 +1,30 @@
1
+ import { PromiseWithError } from '@orpc/shared';
2
+
3
+ type HTTPPath = `/${string}`;
4
+ type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
5
+ type ClientContext = Record<PropertyKey, any>;
6
+ type FriendlyClientOptions<TClientContext extends ClientContext> = {
7
+ signal?: AbortSignal;
8
+ lastEventId?: string | undefined;
9
+ } & (Record<never, never> extends TClientContext ? {
10
+ context?: TClientContext;
11
+ } : {
12
+ context: TClientContext;
13
+ });
14
+ type ClientRest<TClientContext extends ClientContext, TInput> = Record<never, never> extends TClientContext ? undefined extends TInput ? [input?: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options: FriendlyClientOptions<TClientContext>];
15
+ type ClientPromiseResult<TOutput, TError> = PromiseWithError<TOutput, TError>;
16
+ interface Client<TClientContext extends ClientContext, TInput, TOutput, TError> {
17
+ (...rest: ClientRest<TClientContext, TInput>): ClientPromiseResult<TOutput, TError>;
18
+ }
19
+ type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any, any> | {
20
+ [k: string]: NestedClient<TClientContext>;
21
+ };
22
+ type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
23
+ type ClientOptions<TClientContext extends ClientContext> = FriendlyClientOptions<TClientContext> & {
24
+ context: TClientContext;
25
+ };
26
+ interface ClientLink<TClientContext extends ClientContext> {
27
+ call: (path: readonly string[], input: unknown, options: ClientOptions<TClientContext>) => Promise<unknown>;
28
+ }
29
+
30
+ export type { ClientLink as C, FriendlyClientOptions as F, HTTPPath as H, InferClientContext as I, NestedClient as N, ClientContext as a, ClientOptions as b, ClientPromiseResult as c, HTTPMethod as d, ClientRest as e, Client as f };
@@ -0,0 +1,103 @@
1
+ import { a as ClientContext, b as ClientOptions, d as HTTPMethod } from './client.C0lT7w02.js';
2
+ import { c as StandardLinkCodec, a as StandardLinkOptions } from './client.grRbC25r.js';
3
+ import { Segment, Value } from '@orpc/shared';
4
+ import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
5
+
6
+ declare const STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES: {
7
+ readonly BIGINT: 0;
8
+ readonly DATE: 1;
9
+ readonly NAN: 2;
10
+ readonly UNDEFINED: 3;
11
+ readonly URL: 4;
12
+ readonly REGEXP: 5;
13
+ readonly SET: 6;
14
+ readonly MAP: 7;
15
+ };
16
+ type StandardRPCJsonSerializedMetaItem = readonly [type: number, ...path: Segment[]];
17
+ type StandardRPCJsonSerialized = [json: unknown, meta: StandardRPCJsonSerializedMetaItem[], maps: Segment[][], blobs: Blob[]];
18
+ interface StandardRPCCustomJsonSerializer {
19
+ type: number;
20
+ condition(data: unknown): boolean;
21
+ serialize(data: any): unknown;
22
+ deserialize(serialized: any): unknown;
23
+ }
24
+ interface StandardRPCJsonSerializerOptions {
25
+ customJsonSerializers?: readonly StandardRPCCustomJsonSerializer[];
26
+ }
27
+ declare class StandardRPCJsonSerializer {
28
+ private readonly customSerializers;
29
+ constructor(options?: StandardRPCJsonSerializerOptions);
30
+ serialize(data: unknown, segments?: Segment[], meta?: StandardRPCJsonSerializedMetaItem[], maps?: Segment[][], blobs?: Blob[]): StandardRPCJsonSerialized;
31
+ deserialize(json: unknown, meta: readonly StandardRPCJsonSerializedMetaItem[]): unknown;
32
+ deserialize(json: unknown, meta: readonly StandardRPCJsonSerializedMetaItem[], maps: readonly Segment[][], getBlob: (index: number) => Blob): unknown;
33
+ }
34
+
35
+ declare class StandardRPCSerializer {
36
+ #private;
37
+ private readonly jsonSerializer;
38
+ constructor(jsonSerializer: StandardRPCJsonSerializer);
39
+ serialize(data: unknown): object;
40
+ deserialize(data: unknown): unknown;
41
+ }
42
+
43
+ interface StandardRPCLinkCodecOptions<T extends ClientContext> {
44
+ /**
45
+ * Base url for all requests.
46
+ */
47
+ url: Value<string | URL, [
48
+ options: ClientOptions<T>,
49
+ path: readonly string[],
50
+ input: unknown
51
+ ]>;
52
+ /**
53
+ * The maximum length of the URL.
54
+ *
55
+ * @default 2083
56
+ */
57
+ maxUrlLength?: Value<number, [
58
+ options: ClientOptions<T>,
59
+ path: readonly string[],
60
+ input: unknown
61
+ ]>;
62
+ /**
63
+ * The method used to make the request.
64
+ *
65
+ * @default 'POST'
66
+ */
67
+ method?: Value<HTTPMethod, [
68
+ options: ClientOptions<T>,
69
+ path: readonly string[],
70
+ input: unknown
71
+ ]>;
72
+ /**
73
+ * The method to use when the payload cannot safely pass to the server with method return from method function.
74
+ * GET is not allowed, it's very dangerous.
75
+ *
76
+ * @default 'POST'
77
+ */
78
+ fallbackMethod?: Exclude<HTTPMethod, 'GET'>;
79
+ /**
80
+ * Inject headers to the request.
81
+ */
82
+ headers?: Value<StandardHeaders, [
83
+ options: ClientOptions<T>,
84
+ path: readonly string[],
85
+ input: unknown
86
+ ]>;
87
+ }
88
+ declare class StandardRPCLinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
89
+ private readonly serializer;
90
+ private readonly baseUrl;
91
+ private readonly maxUrlLength;
92
+ private readonly fallbackMethod;
93
+ private readonly expectedMethod;
94
+ private readonly headers;
95
+ constructor(serializer: StandardRPCSerializer, options: StandardRPCLinkCodecOptions<T>);
96
+ encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
97
+ decode(response: StandardLazyResponse): Promise<unknown>;
98
+ }
99
+
100
+ interface StandardRPCLinkOptions<T extends ClientContext> extends StandardLinkOptions<T>, StandardRPCLinkCodecOptions<T>, StandardRPCJsonSerializerOptions {
101
+ }
102
+
103
+ export { STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES as S, type StandardRPCJsonSerializedMetaItem as a, type StandardRPCJsonSerialized as b, type StandardRPCCustomJsonSerializer as c, type StandardRPCJsonSerializerOptions as d, StandardRPCJsonSerializer as e, type StandardRPCLinkOptions as f, type StandardRPCLinkCodecOptions as g, StandardRPCLinkCodec as h, StandardRPCSerializer as i };