@temporary-name/shared 1.9.3-alpha.f9f5ce625d5edee78250b87b3a64f1d9760c2244 → 1.9.3-alpha.fb7b7d19964e1b2def7056f4345b63d6fcacce10
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.d.mts +92 -154
- package/dist/index.d.ts +92 -154
- package/dist/index.mjs +22 -101
- package/package.json +4 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,35 +1,95 @@
|
|
|
1
|
-
import { MaybeOptionalOptions as MaybeOptionalOptions$1
|
|
1
|
+
import { MaybeOptionalOptions as MaybeOptionalOptions$1 } from '@temporary-name/shared';
|
|
2
2
|
import { Tracer, TraceAPI, ContextAPI, PropagationAPI, SpanOptions, Context, Span, AttributeValue, Exception } from '@opentelemetry/api';
|
|
3
3
|
export { group, guard, mapEntries, mapValues, omit, retry, sleep } from 'radash';
|
|
4
|
+
export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
|
|
4
5
|
|
|
5
|
-
type MaybeOptionalOptions<TOptions> =
|
|
6
|
+
type MaybeOptionalOptions<TOptions> = object extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
7
|
+
type OptionalIfEmpty<TOptions> = {} extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
6
8
|
declare function resolveMaybeOptionalOptions<T>(rest: MaybeOptionalOptions<T>): T;
|
|
7
9
|
|
|
8
10
|
declare function toArray<T>(value: T): T extends readonly any[] ? T : Exclude<T, undefined | null>[];
|
|
9
|
-
declare function splitInHalf<T>(arr: readonly T[]): [T[], T[]];
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
type StandardBody = undefined | unknown | Blob | URLSearchParams | FormData | AsyncIterator<unknown | void, unknown | void, undefined>;
|
|
13
|
+
interface StandardRequest {
|
|
14
|
+
method: string;
|
|
15
|
+
url: URL;
|
|
16
|
+
headers: Headers;
|
|
17
|
+
/**
|
|
18
|
+
* The body has been parsed based on the content-type header.
|
|
19
|
+
*/
|
|
20
|
+
body: StandardBody;
|
|
21
|
+
signal: AbortSignal | undefined;
|
|
22
|
+
}
|
|
23
|
+
interface StandardLazyRequest extends Omit<StandardRequest, 'body'> {
|
|
24
|
+
/**
|
|
25
|
+
* The body has been parsed based on the content-type header.
|
|
26
|
+
* This method can safely call multiple times (cached).
|
|
27
|
+
*/
|
|
28
|
+
body: () => Promise<StandardBody>;
|
|
29
|
+
}
|
|
30
|
+
interface StandardResponse {
|
|
31
|
+
status: number;
|
|
32
|
+
headers: Headers;
|
|
33
|
+
/**
|
|
34
|
+
* The body has been parsed based on the content-type header.
|
|
35
|
+
*/
|
|
36
|
+
body: StandardBody;
|
|
37
|
+
}
|
|
38
|
+
interface StandardLazyResponse extends Omit<StandardResponse, 'body'> {
|
|
39
|
+
/**
|
|
40
|
+
* The body has been parsed based on the content-type header.
|
|
41
|
+
* This method can safely call multiple times (cached).
|
|
42
|
+
*/
|
|
43
|
+
body: () => Promise<StandardBody>;
|
|
44
|
+
}
|
|
45
|
+
type HTTPPath = `/${string}`;
|
|
46
|
+
declare const HTTPMethods: readonly ["HEAD", "GET", "POST", "PUT", "DELETE", "PATCH"];
|
|
47
|
+
type HTTPMethod = (typeof HTTPMethods)[number];
|
|
48
|
+
type HTTPEndpoint = `${HTTPMethod} ${HTTPPath}`;
|
|
49
|
+
type ClientContext = object;
|
|
50
|
+
interface ClientOptions<T extends ClientContext> {
|
|
51
|
+
request?: StandardLazyRequest;
|
|
52
|
+
signal?: AbortSignal;
|
|
53
|
+
lastEventId?: string | undefined;
|
|
54
|
+
context: T;
|
|
55
|
+
}
|
|
56
|
+
type FriendlyClientOptions<T extends ClientContext> = Omit<ClientOptions<T>, 'context'> & (object extends T ? {
|
|
57
|
+
context?: T;
|
|
58
|
+
} : {
|
|
59
|
+
context: T;
|
|
60
|
+
});
|
|
61
|
+
type ClientRest<TClientContext extends ClientContext, TInput> = object extends TClientContext ? undefined extends TInput ? [
|
|
62
|
+
input?: TInput,
|
|
63
|
+
options?: FriendlyClientOptions<TClientContext>
|
|
64
|
+
] : [input: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options: FriendlyClientOptions<TClientContext>];
|
|
65
|
+
interface Client<TClientContext extends ClientContext, TInput, TOutput> {
|
|
66
|
+
(...rest: ClientRest<TClientContext, TInput>): Promise<TOutput>;
|
|
67
|
+
}
|
|
68
|
+
type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any> | {
|
|
69
|
+
[k: string]: NestedClient<TClientContext>;
|
|
28
70
|
};
|
|
71
|
+
type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
|
|
72
|
+
interface ClientLink<TClientContext extends ClientContext> {
|
|
73
|
+
call: (path: readonly string[], input: unknown, options: ClientOptions<TClientContext>) => Promise<unknown>;
|
|
74
|
+
}
|
|
75
|
+
type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
76
|
+
type IntersectPick<T, U> = Pick<T, keyof T & keyof U>;
|
|
77
|
+
type InferAsyncIterableYield<T> = T extends AsyncIterable<infer U> ? U : never;
|
|
78
|
+
type IsEqual<A, B> = (<G>() => G extends (A & G) | G ? 1 : 2) extends <G>() => G extends (B & G) | G ? 1 : 2 ? true : false;
|
|
79
|
+
type Promisable<T> = T | PromiseLike<T>;
|
|
80
|
+
|
|
81
|
+
type OutputStructure = 'compact' | 'detailed';
|
|
82
|
+
interface ContractConfig {
|
|
83
|
+
defaultMethod: HTTPMethod;
|
|
84
|
+
defaultSuccessStatus: number;
|
|
85
|
+
defaultSuccessDescription: string;
|
|
86
|
+
defaultOutputStructure: OutputStructure;
|
|
87
|
+
}
|
|
88
|
+
declare function fallbackContractConfig<T extends keyof ContractConfig>(key: T, value: ContractConfig[T] | undefined): ContractConfig[T];
|
|
29
89
|
|
|
30
90
|
declare const ORPC_NAME = "orpc";
|
|
31
91
|
declare const ORPC_SHARED_PACKAGE_NAME = "@temporary-name/shared";
|
|
32
|
-
declare const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.
|
|
92
|
+
declare const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.fb7b7d19964e1b2def7056f4345b63d6fcacce10";
|
|
33
93
|
|
|
34
94
|
declare const ORPC_CLIENT_PACKAGE_NAME = "__ORPC_CLIENT_PACKAGE_NAME_PLACEHOLDER__";
|
|
35
95
|
declare const ORPC_CLIENT_PACKAGE_VERSION = "__ORPC_CLIENT_PACKAGE_VERSION_PLACEHOLDER__";
|
|
@@ -218,104 +278,14 @@ declare class EventPublisher<T extends Record<PropertyKey, any>> {
|
|
|
218
278
|
subscribe<K extends keyof T>(event: K, options?: EventPublisherSubscribeIteratorOptions): AsyncGenerator<T[K]> & AsyncIteratorObject<T[K]>;
|
|
219
279
|
}
|
|
220
280
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
interface StandardHeaders {
|
|
227
|
-
[key: string]: string | string[] | undefined;
|
|
228
|
-
}
|
|
229
|
-
type StandardBody = undefined | unknown | Blob | URLSearchParams | FormData | AsyncIterator<unknown | void, unknown | void, undefined>;
|
|
230
|
-
interface StandardRequest {
|
|
231
|
-
method: string;
|
|
232
|
-
url: URL;
|
|
233
|
-
headers: StandardHeaders;
|
|
234
|
-
/**
|
|
235
|
-
* The body has been parsed based on the content-type header.
|
|
236
|
-
*/
|
|
237
|
-
body: StandardBody;
|
|
238
|
-
signal: AbortSignal | undefined;
|
|
239
|
-
}
|
|
240
|
-
interface StandardLazyRequest extends Omit<StandardRequest, 'body'> {
|
|
241
|
-
/**
|
|
242
|
-
* The body has been parsed based on the content-type header.
|
|
243
|
-
* This method can safely call multiple times (cached).
|
|
244
|
-
*/
|
|
245
|
-
body: () => Promise<StandardBody>;
|
|
246
|
-
}
|
|
247
|
-
interface StandardResponse {
|
|
248
|
-
status: number;
|
|
249
|
-
headers: StandardHeaders;
|
|
250
|
-
/**
|
|
251
|
-
* The body has been parsed based on the content-type header.
|
|
252
|
-
*/
|
|
253
|
-
body: StandardBody;
|
|
254
|
-
}
|
|
255
|
-
interface StandardLazyResponse extends Omit<StandardResponse, 'body'> {
|
|
256
|
-
/**
|
|
257
|
-
* The body has been parsed based on the content-type header.
|
|
258
|
-
* This method can safely call multiple times (cached).
|
|
259
|
-
*/
|
|
260
|
-
body: () => Promise<StandardBody>;
|
|
261
|
-
}
|
|
262
|
-
type HTTPPath = `/${string}`;
|
|
263
|
-
declare const HTTPMethods: readonly ["HEAD", "GET", "POST", "PUT", "DELETE", "PATCH"];
|
|
264
|
-
type HTTPMethod = (typeof HTTPMethods)[number];
|
|
265
|
-
type HTTPEndpoint = `${HTTPMethod} ${HTTPPath}`;
|
|
266
|
-
type ClientContext = Record<PropertyKey, any>;
|
|
267
|
-
interface ClientOptions<T extends ClientContext> {
|
|
268
|
-
request?: StandardLazyRequest;
|
|
269
|
-
signal?: AbortSignal;
|
|
270
|
-
lastEventId?: string | undefined;
|
|
271
|
-
context: T;
|
|
272
|
-
}
|
|
273
|
-
type FriendlyClientOptions<T extends ClientContext> = Omit<ClientOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
274
|
-
context?: T;
|
|
275
|
-
} : {
|
|
276
|
-
context: T;
|
|
277
|
-
});
|
|
278
|
-
type ClientRest<TClientContext extends ClientContext, TInput> = Record<never, never> extends TClientContext ? undefined extends TInput ? [
|
|
279
|
-
input?: TInput,
|
|
280
|
-
options?: FriendlyClientOptions<TClientContext>
|
|
281
|
-
] : [input: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options: FriendlyClientOptions<TClientContext>];
|
|
282
|
-
type ClientPromiseResult<TOutput, TError> = PromiseWithError<TOutput, TError>;
|
|
283
|
-
interface Client<TClientContext extends ClientContext, TInput, TOutput, TError> {
|
|
284
|
-
(...rest: ClientRest<TClientContext, TInput>): ClientPromiseResult<TOutput, TError>;
|
|
285
|
-
}
|
|
286
|
-
type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any, any> | {
|
|
287
|
-
[k: string]: NestedClient<TClientContext>;
|
|
288
|
-
};
|
|
289
|
-
type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
|
|
290
|
-
interface ClientLink<TClientContext extends ClientContext> {
|
|
291
|
-
call: (path: readonly string[], input: unknown, options: ClientOptions<TClientContext>) => Promise<unknown>;
|
|
292
|
-
}
|
|
293
|
-
type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
294
|
-
type IntersectPick<T, U> = Pick<T, keyof T & keyof U>;
|
|
295
|
-
type PromiseWithError<T, TError> = Promise<T> & {
|
|
296
|
-
__error?: {
|
|
297
|
-
type: TError;
|
|
298
|
-
};
|
|
299
|
-
};
|
|
281
|
+
type AnyFunction = (...args: any[]) => any;
|
|
282
|
+
declare function once<T extends () => any>(fn: T): () => ReturnType<T>;
|
|
283
|
+
declare function sequential<A extends any[], R>(fn: (...args: A) => Promise<R>): (...args: A) => Promise<R>;
|
|
300
284
|
/**
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
* - `throwableError` the error type that represent throwable errors should be `Error` or `null | undefined | {}` if you want more strict.
|
|
285
|
+
* Executes the callback function after the current call stack has been cleared.
|
|
304
286
|
*/
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
type ThrowableError = Registry extends {
|
|
308
|
-
throwableError: infer T;
|
|
309
|
-
} ? T : Error;
|
|
310
|
-
type InferAsyncIterableYield<T> = T extends AsyncIterable<infer U> ? U : never;
|
|
311
|
-
type IsEqual<A, B> = (<G>() => G extends (A & G) | G ? 1 : 2) extends <G>() => G extends (B & G) | G ? 1 : 2 ? true : false;
|
|
312
|
-
type Promisable<T> = T | PromiseLike<T>;
|
|
287
|
+
declare function defer(callback: () => void): void;
|
|
313
288
|
|
|
314
|
-
type InterceptableOptions = Record<string, any>;
|
|
315
|
-
type InterceptorOptions<TOptions extends InterceptableOptions, TResult> = Omit<TOptions, 'next'> & {
|
|
316
|
-
next(options?: TOptions): TResult;
|
|
317
|
-
};
|
|
318
|
-
type Interceptor<TOptions extends InterceptableOptions, TResult> = (options: InterceptorOptions<TOptions, TResult>) => TResult;
|
|
319
289
|
/**
|
|
320
290
|
* Can used for interceptors or middlewares
|
|
321
291
|
*/
|
|
@@ -333,15 +303,14 @@ declare function onSuccess<T, TOptions extends {
|
|
|
333
303
|
*/
|
|
334
304
|
declare function onError<T, TOptions extends {
|
|
335
305
|
next(): any;
|
|
336
|
-
}, TRest extends any[]>(callback: NoInfer<(error:
|
|
306
|
+
}, TRest extends any[]>(callback: NoInfer<(error: Error, options: TOptions, ...rest: TRest) => Promisable<void>>): (options: TOptions, ...rest: TRest) => T | Promise<Awaited<ReturnType<TOptions['next']>>>;
|
|
337
307
|
type OnFinishState<TResult, TError> = [error: TError, data: undefined, isSuccess: false] | [error: null, data: TResult, isSuccess: true];
|
|
338
308
|
/**
|
|
339
309
|
* Can used for interceptors or middlewares
|
|
340
310
|
*/
|
|
341
311
|
declare function onFinish<T, TOptions extends {
|
|
342
312
|
next(): any;
|
|
343
|
-
}, TRest extends any[]>(callback: NoInfer<(state: OnFinishState<Awaited<ReturnType<TOptions['next']>>,
|
|
344
|
-
declare function intercept<TOptions extends InterceptableOptions, TResult>(interceptors: Interceptor<TOptions, TResult>[], options: NoInfer<TOptions>, main: NoInfer<(options: TOptions) => TResult>): TResult;
|
|
313
|
+
}, TRest extends any[]>(callback: NoInfer<(state: OnFinishState<Awaited<ReturnType<TOptions['next']>>, Error>, options: TOptions, ...rest: TRest) => Promisable<void>>): (options: TOptions, ...rest: TRest) => T | Promise<Awaited<ReturnType<TOptions['next']>>>;
|
|
345
314
|
|
|
346
315
|
/**
|
|
347
316
|
* Only import types from @opentelemetry/api to avoid runtime dependencies.
|
|
@@ -473,17 +442,7 @@ declare const NullProtoObj: {
|
|
|
473
442
|
|
|
474
443
|
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
|
|
475
444
|
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
|
|
476
|
-
/**
|
|
477
|
-
* Returns the value if it is defined, otherwise returns the fallback
|
|
478
|
-
*/
|
|
479
|
-
declare function fallback<T>(value: T | undefined, fallback: T): T;
|
|
480
445
|
|
|
481
|
-
/**
|
|
482
|
-
* Prevents objects from being awaitable by intercepting the `then` method
|
|
483
|
-
* when called by the native await mechanism. This is useful for preventing
|
|
484
|
-
* accidental awaiting of objects that aren't meant to be promises.
|
|
485
|
-
*/
|
|
486
|
-
declare function preventNativeAwait<T extends object>(target: T): T;
|
|
487
446
|
/**
|
|
488
447
|
* Create a proxy that overlays one object (`overlay`) on top of another (`target`).
|
|
489
448
|
*
|
|
@@ -519,30 +478,9 @@ declare function asyncIteratorToStream<T>(iterator: AsyncIterator<T>): ReadableS
|
|
|
519
478
|
|
|
520
479
|
declare function tryDecodeURIComponent(value: string): string;
|
|
521
480
|
|
|
522
|
-
type SafeResult<TOutput, TError> = ([error: null, data: TOutput, isDefined: false, isSuccess: true] & {
|
|
523
|
-
error: null;
|
|
524
|
-
data: TOutput;
|
|
525
|
-
isDefined: false;
|
|
526
|
-
isSuccess: true;
|
|
527
|
-
}) | ([error: Exclude<TError, ORPCError<any, any>>, data: undefined, isDefined: false, isSuccess: false] & {
|
|
528
|
-
error: Exclude<TError, ORPCError<any, any>>;
|
|
529
|
-
data: undefined;
|
|
530
|
-
isDefined: false;
|
|
531
|
-
isSuccess: false;
|
|
532
|
-
}) | ([error: Extract<TError, ORPCError<any, any>>, data: undefined, isDefined: true, isSuccess: false] & {
|
|
533
|
-
error: Extract<TError, ORPCError<any, any>>;
|
|
534
|
-
data: undefined;
|
|
535
|
-
isDefined: true;
|
|
536
|
-
isSuccess: false;
|
|
537
|
-
});
|
|
538
|
-
/**
|
|
539
|
-
* Works like try/catch, but can infer error types.
|
|
540
|
-
*
|
|
541
|
-
* @info support both tuple `[error, data, isDefined, isSuccess]` and object `{ error, data, isDefined, isSuccess }` styles.
|
|
542
|
-
* @see {@link https://orpc.unnoq.com/docs/client/error-handling Client Error Handling Docs}
|
|
543
|
-
*/
|
|
544
|
-
declare function safe<TOutput, TError = ThrowableError$1>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
|
|
545
481
|
declare function toHttpPath(path: readonly string[]): HTTPPath;
|
|
482
|
+
declare function splitFirst(str: string, separator: string): [string, string];
|
|
483
|
+
declare function assertNever(value: never, message?: string): never;
|
|
546
484
|
|
|
547
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass, COMMON_ORPC_ERROR_DEFS, EventPublisher, HTTPMethods, NullProtoObj, ORPCError, ORPC_CLIENT_PACKAGE_NAME, ORPC_CLIENT_PACKAGE_VERSION, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION,
|
|
548
|
-
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, AsyncIteratorWithSpanOptions, Client, ClientContext, ClientLink, ClientOptions,
|
|
485
|
+
export { AbortError, AsyncIdQueue, AsyncIteratorClass, COMMON_ORPC_ERROR_DEFS, EventPublisher, HTTPMethods, NullProtoObj, ORPCError, ORPC_CLIENT_PACKAGE_NAME, ORPC_CLIENT_PACKAGE_VERSION, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, assertNever, asyncIteratorToStream, asyncIteratorWithSpan, clone, createORPCErrorFromJson, defer, fallbackContractConfig, fallbackORPCErrorMessage, fallbackORPCErrorStatus, findDeepMatches, get, getConstructor, getGlobalOtelConfig, isAsyncIteratorObject, isDefinedError, isORPCErrorJson, isORPCErrorStatus, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitFirst, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toHttpPath, toORPCError, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
|
486
|
+
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, AsyncIteratorWithSpanOptions, Client, ClientContext, ClientLink, ClientOptions, ClientRest, CommonORPCErrorCode, ContractConfig, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, FriendlyClientOptions, HTTPEndpoint, HTTPMethod, HTTPPath, InferAsyncIterableYield, InferClientContext, IntersectPick, IsEqual, MaybeOptionalOptions, NestedClient, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, OnFinishState, OptionalIfEmpty, OtelConfig, OutputStructure, Promisable, RunWithSpanOptions, Segment, SetOptional, SetSpanErrorOptions, StandardBody, StandardLazyRequest, StandardLazyResponse, StandardRequest, StandardResponse, Value };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,35 +1,95 @@
|
|
|
1
|
-
import { MaybeOptionalOptions as MaybeOptionalOptions$1
|
|
1
|
+
import { MaybeOptionalOptions as MaybeOptionalOptions$1 } from '@temporary-name/shared';
|
|
2
2
|
import { Tracer, TraceAPI, ContextAPI, PropagationAPI, SpanOptions, Context, Span, AttributeValue, Exception } from '@opentelemetry/api';
|
|
3
3
|
export { group, guard, mapEntries, mapValues, omit, retry, sleep } from 'radash';
|
|
4
|
+
export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
|
|
4
5
|
|
|
5
|
-
type MaybeOptionalOptions<TOptions> =
|
|
6
|
+
type MaybeOptionalOptions<TOptions> = object extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
7
|
+
type OptionalIfEmpty<TOptions> = {} extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
6
8
|
declare function resolveMaybeOptionalOptions<T>(rest: MaybeOptionalOptions<T>): T;
|
|
7
9
|
|
|
8
10
|
declare function toArray<T>(value: T): T extends readonly any[] ? T : Exclude<T, undefined | null>[];
|
|
9
|
-
declare function splitInHalf<T>(arr: readonly T[]): [T[], T[]];
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
type StandardBody = undefined | unknown | Blob | URLSearchParams | FormData | AsyncIterator<unknown | void, unknown | void, undefined>;
|
|
13
|
+
interface StandardRequest {
|
|
14
|
+
method: string;
|
|
15
|
+
url: URL;
|
|
16
|
+
headers: Headers;
|
|
17
|
+
/**
|
|
18
|
+
* The body has been parsed based on the content-type header.
|
|
19
|
+
*/
|
|
20
|
+
body: StandardBody;
|
|
21
|
+
signal: AbortSignal | undefined;
|
|
22
|
+
}
|
|
23
|
+
interface StandardLazyRequest extends Omit<StandardRequest, 'body'> {
|
|
24
|
+
/**
|
|
25
|
+
* The body has been parsed based on the content-type header.
|
|
26
|
+
* This method can safely call multiple times (cached).
|
|
27
|
+
*/
|
|
28
|
+
body: () => Promise<StandardBody>;
|
|
29
|
+
}
|
|
30
|
+
interface StandardResponse {
|
|
31
|
+
status: number;
|
|
32
|
+
headers: Headers;
|
|
33
|
+
/**
|
|
34
|
+
* The body has been parsed based on the content-type header.
|
|
35
|
+
*/
|
|
36
|
+
body: StandardBody;
|
|
37
|
+
}
|
|
38
|
+
interface StandardLazyResponse extends Omit<StandardResponse, 'body'> {
|
|
39
|
+
/**
|
|
40
|
+
* The body has been parsed based on the content-type header.
|
|
41
|
+
* This method can safely call multiple times (cached).
|
|
42
|
+
*/
|
|
43
|
+
body: () => Promise<StandardBody>;
|
|
44
|
+
}
|
|
45
|
+
type HTTPPath = `/${string}`;
|
|
46
|
+
declare const HTTPMethods: readonly ["HEAD", "GET", "POST", "PUT", "DELETE", "PATCH"];
|
|
47
|
+
type HTTPMethod = (typeof HTTPMethods)[number];
|
|
48
|
+
type HTTPEndpoint = `${HTTPMethod} ${HTTPPath}`;
|
|
49
|
+
type ClientContext = object;
|
|
50
|
+
interface ClientOptions<T extends ClientContext> {
|
|
51
|
+
request?: StandardLazyRequest;
|
|
52
|
+
signal?: AbortSignal;
|
|
53
|
+
lastEventId?: string | undefined;
|
|
54
|
+
context: T;
|
|
55
|
+
}
|
|
56
|
+
type FriendlyClientOptions<T extends ClientContext> = Omit<ClientOptions<T>, 'context'> & (object extends T ? {
|
|
57
|
+
context?: T;
|
|
58
|
+
} : {
|
|
59
|
+
context: T;
|
|
60
|
+
});
|
|
61
|
+
type ClientRest<TClientContext extends ClientContext, TInput> = object extends TClientContext ? undefined extends TInput ? [
|
|
62
|
+
input?: TInput,
|
|
63
|
+
options?: FriendlyClientOptions<TClientContext>
|
|
64
|
+
] : [input: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options: FriendlyClientOptions<TClientContext>];
|
|
65
|
+
interface Client<TClientContext extends ClientContext, TInput, TOutput> {
|
|
66
|
+
(...rest: ClientRest<TClientContext, TInput>): Promise<TOutput>;
|
|
67
|
+
}
|
|
68
|
+
type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any> | {
|
|
69
|
+
[k: string]: NestedClient<TClientContext>;
|
|
28
70
|
};
|
|
71
|
+
type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
|
|
72
|
+
interface ClientLink<TClientContext extends ClientContext> {
|
|
73
|
+
call: (path: readonly string[], input: unknown, options: ClientOptions<TClientContext>) => Promise<unknown>;
|
|
74
|
+
}
|
|
75
|
+
type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
76
|
+
type IntersectPick<T, U> = Pick<T, keyof T & keyof U>;
|
|
77
|
+
type InferAsyncIterableYield<T> = T extends AsyncIterable<infer U> ? U : never;
|
|
78
|
+
type IsEqual<A, B> = (<G>() => G extends (A & G) | G ? 1 : 2) extends <G>() => G extends (B & G) | G ? 1 : 2 ? true : false;
|
|
79
|
+
type Promisable<T> = T | PromiseLike<T>;
|
|
80
|
+
|
|
81
|
+
type OutputStructure = 'compact' | 'detailed';
|
|
82
|
+
interface ContractConfig {
|
|
83
|
+
defaultMethod: HTTPMethod;
|
|
84
|
+
defaultSuccessStatus: number;
|
|
85
|
+
defaultSuccessDescription: string;
|
|
86
|
+
defaultOutputStructure: OutputStructure;
|
|
87
|
+
}
|
|
88
|
+
declare function fallbackContractConfig<T extends keyof ContractConfig>(key: T, value: ContractConfig[T] | undefined): ContractConfig[T];
|
|
29
89
|
|
|
30
90
|
declare const ORPC_NAME = "orpc";
|
|
31
91
|
declare const ORPC_SHARED_PACKAGE_NAME = "@temporary-name/shared";
|
|
32
|
-
declare const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.
|
|
92
|
+
declare const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.fb7b7d19964e1b2def7056f4345b63d6fcacce10";
|
|
33
93
|
|
|
34
94
|
declare const ORPC_CLIENT_PACKAGE_NAME = "__ORPC_CLIENT_PACKAGE_NAME_PLACEHOLDER__";
|
|
35
95
|
declare const ORPC_CLIENT_PACKAGE_VERSION = "__ORPC_CLIENT_PACKAGE_VERSION_PLACEHOLDER__";
|
|
@@ -218,104 +278,14 @@ declare class EventPublisher<T extends Record<PropertyKey, any>> {
|
|
|
218
278
|
subscribe<K extends keyof T>(event: K, options?: EventPublisherSubscribeIteratorOptions): AsyncGenerator<T[K]> & AsyncIteratorObject<T[K]>;
|
|
219
279
|
}
|
|
220
280
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
interface StandardHeaders {
|
|
227
|
-
[key: string]: string | string[] | undefined;
|
|
228
|
-
}
|
|
229
|
-
type StandardBody = undefined | unknown | Blob | URLSearchParams | FormData | AsyncIterator<unknown | void, unknown | void, undefined>;
|
|
230
|
-
interface StandardRequest {
|
|
231
|
-
method: string;
|
|
232
|
-
url: URL;
|
|
233
|
-
headers: StandardHeaders;
|
|
234
|
-
/**
|
|
235
|
-
* The body has been parsed based on the content-type header.
|
|
236
|
-
*/
|
|
237
|
-
body: StandardBody;
|
|
238
|
-
signal: AbortSignal | undefined;
|
|
239
|
-
}
|
|
240
|
-
interface StandardLazyRequest extends Omit<StandardRequest, 'body'> {
|
|
241
|
-
/**
|
|
242
|
-
* The body has been parsed based on the content-type header.
|
|
243
|
-
* This method can safely call multiple times (cached).
|
|
244
|
-
*/
|
|
245
|
-
body: () => Promise<StandardBody>;
|
|
246
|
-
}
|
|
247
|
-
interface StandardResponse {
|
|
248
|
-
status: number;
|
|
249
|
-
headers: StandardHeaders;
|
|
250
|
-
/**
|
|
251
|
-
* The body has been parsed based on the content-type header.
|
|
252
|
-
*/
|
|
253
|
-
body: StandardBody;
|
|
254
|
-
}
|
|
255
|
-
interface StandardLazyResponse extends Omit<StandardResponse, 'body'> {
|
|
256
|
-
/**
|
|
257
|
-
* The body has been parsed based on the content-type header.
|
|
258
|
-
* This method can safely call multiple times (cached).
|
|
259
|
-
*/
|
|
260
|
-
body: () => Promise<StandardBody>;
|
|
261
|
-
}
|
|
262
|
-
type HTTPPath = `/${string}`;
|
|
263
|
-
declare const HTTPMethods: readonly ["HEAD", "GET", "POST", "PUT", "DELETE", "PATCH"];
|
|
264
|
-
type HTTPMethod = (typeof HTTPMethods)[number];
|
|
265
|
-
type HTTPEndpoint = `${HTTPMethod} ${HTTPPath}`;
|
|
266
|
-
type ClientContext = Record<PropertyKey, any>;
|
|
267
|
-
interface ClientOptions<T extends ClientContext> {
|
|
268
|
-
request?: StandardLazyRequest;
|
|
269
|
-
signal?: AbortSignal;
|
|
270
|
-
lastEventId?: string | undefined;
|
|
271
|
-
context: T;
|
|
272
|
-
}
|
|
273
|
-
type FriendlyClientOptions<T extends ClientContext> = Omit<ClientOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
274
|
-
context?: T;
|
|
275
|
-
} : {
|
|
276
|
-
context: T;
|
|
277
|
-
});
|
|
278
|
-
type ClientRest<TClientContext extends ClientContext, TInput> = Record<never, never> extends TClientContext ? undefined extends TInput ? [
|
|
279
|
-
input?: TInput,
|
|
280
|
-
options?: FriendlyClientOptions<TClientContext>
|
|
281
|
-
] : [input: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options: FriendlyClientOptions<TClientContext>];
|
|
282
|
-
type ClientPromiseResult<TOutput, TError> = PromiseWithError<TOutput, TError>;
|
|
283
|
-
interface Client<TClientContext extends ClientContext, TInput, TOutput, TError> {
|
|
284
|
-
(...rest: ClientRest<TClientContext, TInput>): ClientPromiseResult<TOutput, TError>;
|
|
285
|
-
}
|
|
286
|
-
type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any, any> | {
|
|
287
|
-
[k: string]: NestedClient<TClientContext>;
|
|
288
|
-
};
|
|
289
|
-
type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
|
|
290
|
-
interface ClientLink<TClientContext extends ClientContext> {
|
|
291
|
-
call: (path: readonly string[], input: unknown, options: ClientOptions<TClientContext>) => Promise<unknown>;
|
|
292
|
-
}
|
|
293
|
-
type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
294
|
-
type IntersectPick<T, U> = Pick<T, keyof T & keyof U>;
|
|
295
|
-
type PromiseWithError<T, TError> = Promise<T> & {
|
|
296
|
-
__error?: {
|
|
297
|
-
type: TError;
|
|
298
|
-
};
|
|
299
|
-
};
|
|
281
|
+
type AnyFunction = (...args: any[]) => any;
|
|
282
|
+
declare function once<T extends () => any>(fn: T): () => ReturnType<T>;
|
|
283
|
+
declare function sequential<A extends any[], R>(fn: (...args: A) => Promise<R>): (...args: A) => Promise<R>;
|
|
300
284
|
/**
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
* - `throwableError` the error type that represent throwable errors should be `Error` or `null | undefined | {}` if you want more strict.
|
|
285
|
+
* Executes the callback function after the current call stack has been cleared.
|
|
304
286
|
*/
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
type ThrowableError = Registry extends {
|
|
308
|
-
throwableError: infer T;
|
|
309
|
-
} ? T : Error;
|
|
310
|
-
type InferAsyncIterableYield<T> = T extends AsyncIterable<infer U> ? U : never;
|
|
311
|
-
type IsEqual<A, B> = (<G>() => G extends (A & G) | G ? 1 : 2) extends <G>() => G extends (B & G) | G ? 1 : 2 ? true : false;
|
|
312
|
-
type Promisable<T> = T | PromiseLike<T>;
|
|
287
|
+
declare function defer(callback: () => void): void;
|
|
313
288
|
|
|
314
|
-
type InterceptableOptions = Record<string, any>;
|
|
315
|
-
type InterceptorOptions<TOptions extends InterceptableOptions, TResult> = Omit<TOptions, 'next'> & {
|
|
316
|
-
next(options?: TOptions): TResult;
|
|
317
|
-
};
|
|
318
|
-
type Interceptor<TOptions extends InterceptableOptions, TResult> = (options: InterceptorOptions<TOptions, TResult>) => TResult;
|
|
319
289
|
/**
|
|
320
290
|
* Can used for interceptors or middlewares
|
|
321
291
|
*/
|
|
@@ -333,15 +303,14 @@ declare function onSuccess<T, TOptions extends {
|
|
|
333
303
|
*/
|
|
334
304
|
declare function onError<T, TOptions extends {
|
|
335
305
|
next(): any;
|
|
336
|
-
}, TRest extends any[]>(callback: NoInfer<(error:
|
|
306
|
+
}, TRest extends any[]>(callback: NoInfer<(error: Error, options: TOptions, ...rest: TRest) => Promisable<void>>): (options: TOptions, ...rest: TRest) => T | Promise<Awaited<ReturnType<TOptions['next']>>>;
|
|
337
307
|
type OnFinishState<TResult, TError> = [error: TError, data: undefined, isSuccess: false] | [error: null, data: TResult, isSuccess: true];
|
|
338
308
|
/**
|
|
339
309
|
* Can used for interceptors or middlewares
|
|
340
310
|
*/
|
|
341
311
|
declare function onFinish<T, TOptions extends {
|
|
342
312
|
next(): any;
|
|
343
|
-
}, TRest extends any[]>(callback: NoInfer<(state: OnFinishState<Awaited<ReturnType<TOptions['next']>>,
|
|
344
|
-
declare function intercept<TOptions extends InterceptableOptions, TResult>(interceptors: Interceptor<TOptions, TResult>[], options: NoInfer<TOptions>, main: NoInfer<(options: TOptions) => TResult>): TResult;
|
|
313
|
+
}, TRest extends any[]>(callback: NoInfer<(state: OnFinishState<Awaited<ReturnType<TOptions['next']>>, Error>, options: TOptions, ...rest: TRest) => Promisable<void>>): (options: TOptions, ...rest: TRest) => T | Promise<Awaited<ReturnType<TOptions['next']>>>;
|
|
345
314
|
|
|
346
315
|
/**
|
|
347
316
|
* Only import types from @opentelemetry/api to avoid runtime dependencies.
|
|
@@ -473,17 +442,7 @@ declare const NullProtoObj: {
|
|
|
473
442
|
|
|
474
443
|
type Value<T, TArgs extends any[] = []> = T | ((...args: TArgs) => T);
|
|
475
444
|
declare function value<T, TArgs extends any[]>(value: Value<T, TArgs>, ...args: NoInfer<TArgs>): T extends Value<infer U, any> ? U : never;
|
|
476
|
-
/**
|
|
477
|
-
* Returns the value if it is defined, otherwise returns the fallback
|
|
478
|
-
*/
|
|
479
|
-
declare function fallback<T>(value: T | undefined, fallback: T): T;
|
|
480
445
|
|
|
481
|
-
/**
|
|
482
|
-
* Prevents objects from being awaitable by intercepting the `then` method
|
|
483
|
-
* when called by the native await mechanism. This is useful for preventing
|
|
484
|
-
* accidental awaiting of objects that aren't meant to be promises.
|
|
485
|
-
*/
|
|
486
|
-
declare function preventNativeAwait<T extends object>(target: T): T;
|
|
487
446
|
/**
|
|
488
447
|
* Create a proxy that overlays one object (`overlay`) on top of another (`target`).
|
|
489
448
|
*
|
|
@@ -519,30 +478,9 @@ declare function asyncIteratorToStream<T>(iterator: AsyncIterator<T>): ReadableS
|
|
|
519
478
|
|
|
520
479
|
declare function tryDecodeURIComponent(value: string): string;
|
|
521
480
|
|
|
522
|
-
type SafeResult<TOutput, TError> = ([error: null, data: TOutput, isDefined: false, isSuccess: true] & {
|
|
523
|
-
error: null;
|
|
524
|
-
data: TOutput;
|
|
525
|
-
isDefined: false;
|
|
526
|
-
isSuccess: true;
|
|
527
|
-
}) | ([error: Exclude<TError, ORPCError<any, any>>, data: undefined, isDefined: false, isSuccess: false] & {
|
|
528
|
-
error: Exclude<TError, ORPCError<any, any>>;
|
|
529
|
-
data: undefined;
|
|
530
|
-
isDefined: false;
|
|
531
|
-
isSuccess: false;
|
|
532
|
-
}) | ([error: Extract<TError, ORPCError<any, any>>, data: undefined, isDefined: true, isSuccess: false] & {
|
|
533
|
-
error: Extract<TError, ORPCError<any, any>>;
|
|
534
|
-
data: undefined;
|
|
535
|
-
isDefined: true;
|
|
536
|
-
isSuccess: false;
|
|
537
|
-
});
|
|
538
|
-
/**
|
|
539
|
-
* Works like try/catch, but can infer error types.
|
|
540
|
-
*
|
|
541
|
-
* @info support both tuple `[error, data, isDefined, isSuccess]` and object `{ error, data, isDefined, isSuccess }` styles.
|
|
542
|
-
* @see {@link https://orpc.unnoq.com/docs/client/error-handling Client Error Handling Docs}
|
|
543
|
-
*/
|
|
544
|
-
declare function safe<TOutput, TError = ThrowableError$1>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
|
|
545
481
|
declare function toHttpPath(path: readonly string[]): HTTPPath;
|
|
482
|
+
declare function splitFirst(str: string, separator: string): [string, string];
|
|
483
|
+
declare function assertNever(value: never, message?: string): never;
|
|
546
484
|
|
|
547
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass, COMMON_ORPC_ERROR_DEFS, EventPublisher, HTTPMethods, NullProtoObj, ORPCError, ORPC_CLIENT_PACKAGE_NAME, ORPC_CLIENT_PACKAGE_VERSION, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION,
|
|
548
|
-
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, AsyncIteratorWithSpanOptions, Client, ClientContext, ClientLink, ClientOptions,
|
|
485
|
+
export { AbortError, AsyncIdQueue, AsyncIteratorClass, COMMON_ORPC_ERROR_DEFS, EventPublisher, HTTPMethods, NullProtoObj, ORPCError, ORPC_CLIENT_PACKAGE_NAME, ORPC_CLIENT_PACKAGE_VERSION, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, assertNever, asyncIteratorToStream, asyncIteratorWithSpan, clone, createORPCErrorFromJson, defer, fallbackContractConfig, fallbackORPCErrorMessage, fallbackORPCErrorStatus, findDeepMatches, get, getConstructor, getGlobalOtelConfig, isAsyncIteratorObject, isDefinedError, isORPCErrorJson, isORPCErrorStatus, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitFirst, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toHttpPath, toORPCError, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
|
486
|
+
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, AsyncIteratorWithSpanOptions, Client, ClientContext, ClientLink, ClientOptions, ClientRest, CommonORPCErrorCode, ContractConfig, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, FriendlyClientOptions, HTTPEndpoint, HTTPMethod, HTTPPath, InferAsyncIterableYield, InferClientContext, IntersectPick, IsEqual, MaybeOptionalOptions, NestedClient, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, OnFinishState, OptionalIfEmpty, OtelConfig, OutputStructure, Promisable, RunWithSpanOptions, Segment, SetOptional, SetSpanErrorOptions, StandardBody, StandardLazyRequest, StandardLazyResponse, StandardRequest, StandardResponse, Value };
|
package/dist/index.mjs
CHANGED
|
@@ -8,21 +8,23 @@ function resolveMaybeOptionalOptions(rest) {
|
|
|
8
8
|
function toArray(value) {
|
|
9
9
|
return Array.isArray(value) ? value : value === void 0 || value === null ? [] : [value];
|
|
10
10
|
}
|
|
11
|
-
function splitInHalf(arr) {
|
|
12
|
-
const half = Math.ceil(arr.length / 2);
|
|
13
|
-
return [arr.slice(0, half), arr.slice(half)];
|
|
14
|
-
}
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
const DEFAULT_CONFIG = {
|
|
13
|
+
defaultMethod: "POST",
|
|
14
|
+
defaultSuccessStatus: 200,
|
|
15
|
+
defaultSuccessDescription: "OK",
|
|
16
|
+
defaultOutputStructure: "compact"
|
|
17
|
+
};
|
|
18
|
+
function fallbackContractConfig(key, value) {
|
|
19
|
+
if (value === void 0) {
|
|
20
|
+
return DEFAULT_CONFIG[key];
|
|
19
21
|
}
|
|
20
|
-
return
|
|
22
|
+
return value;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
const ORPC_NAME = "orpc";
|
|
24
26
|
const ORPC_SHARED_PACKAGE_NAME = "@temporary-name/shared";
|
|
25
|
-
const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.
|
|
27
|
+
const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.fb7b7d19964e1b2def7056f4345b63d6fcacce10";
|
|
26
28
|
|
|
27
29
|
const ORPC_CLIENT_PACKAGE_NAME = "__ORPC_CLIENT_PACKAGE_NAME_PLACEHOLDER__";
|
|
28
30
|
const ORPC_CLIENT_PACKAGE_VERSION = "__ORPC_CLIENT_PACKAGE_VERSION_PLACEHOLDER__";
|
|
@@ -628,15 +630,6 @@ class EventPublisher {
|
|
|
628
630
|
}
|
|
629
631
|
}
|
|
630
632
|
|
|
631
|
-
class SequentialIdGenerator {
|
|
632
|
-
index = BigInt(0);
|
|
633
|
-
generate() {
|
|
634
|
-
const id = this.index.toString(32);
|
|
635
|
-
this.index++;
|
|
636
|
-
return id;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
|
|
640
633
|
function onStart(callback) {
|
|
641
634
|
return async (options, ...rest) => {
|
|
642
635
|
await callback(options, ...rest);
|
|
@@ -675,19 +668,6 @@ function onFinish(callback) {
|
|
|
675
668
|
}
|
|
676
669
|
};
|
|
677
670
|
}
|
|
678
|
-
function intercept(interceptors, options, main) {
|
|
679
|
-
const next = (options2, index) => {
|
|
680
|
-
const interceptor = interceptors[index];
|
|
681
|
-
if (!interceptor) {
|
|
682
|
-
return main(options2);
|
|
683
|
-
}
|
|
684
|
-
return interceptor({
|
|
685
|
-
...options2,
|
|
686
|
-
next: (newOptions = options2) => next(newOptions, index + 1)
|
|
687
|
-
});
|
|
688
|
-
};
|
|
689
|
-
return next(options, 0);
|
|
690
|
-
}
|
|
691
671
|
|
|
692
672
|
function parseEmptyableJSON(text) {
|
|
693
673
|
if (!text) {
|
|
@@ -771,46 +751,7 @@ function value(value2, ...args) {
|
|
|
771
751
|
}
|
|
772
752
|
return value2;
|
|
773
753
|
}
|
|
774
|
-
function fallback(value2, fallback2) {
|
|
775
|
-
return value2 === void 0 ? fallback2 : value2;
|
|
776
|
-
}
|
|
777
754
|
|
|
778
|
-
function preventNativeAwait(target) {
|
|
779
|
-
return new Proxy(target, {
|
|
780
|
-
get(target2, prop, receiver) {
|
|
781
|
-
const value2 = Reflect.get(target2, prop, receiver);
|
|
782
|
-
if (prop !== "then" || typeof value2 !== "function") {
|
|
783
|
-
return value2;
|
|
784
|
-
}
|
|
785
|
-
return new Proxy(value2, {
|
|
786
|
-
apply(targetFn, thisArg, args) {
|
|
787
|
-
if (args.length !== 2 || args.some((arg) => !isNativeFunction(arg))) {
|
|
788
|
-
return Reflect.apply(targetFn, thisArg, args);
|
|
789
|
-
}
|
|
790
|
-
let shouldOmit = true;
|
|
791
|
-
args[0].call(
|
|
792
|
-
thisArg,
|
|
793
|
-
preventNativeAwait(
|
|
794
|
-
new Proxy(target2, {
|
|
795
|
-
get: (target3, prop2, receiver2) => {
|
|
796
|
-
if (shouldOmit && prop2 === "then") {
|
|
797
|
-
shouldOmit = false;
|
|
798
|
-
return void 0;
|
|
799
|
-
}
|
|
800
|
-
return Reflect.get(target3, prop2, receiver2);
|
|
801
|
-
}
|
|
802
|
-
})
|
|
803
|
-
)
|
|
804
|
-
);
|
|
805
|
-
}
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
|
-
});
|
|
809
|
-
}
|
|
810
|
-
const NATIVE_FUNCTION_REGEX = /^\s*function\s*\(\)\s*\{\s*\[native code\]\s*\}\s*$/;
|
|
811
|
-
function isNativeFunction(fn) {
|
|
812
|
-
return typeof fn === "function" && NATIVE_FUNCTION_REGEX.test(fn.toString());
|
|
813
|
-
}
|
|
814
755
|
function overlayProxy(target, partial) {
|
|
815
756
|
const proxy = new Proxy(typeof target === "function" ? partial : target, {
|
|
816
757
|
get(_, prop) {
|
|
@@ -862,38 +803,18 @@ function tryDecodeURIComponent(value) {
|
|
|
862
803
|
}
|
|
863
804
|
}
|
|
864
805
|
|
|
865
|
-
async function safe(promise) {
|
|
866
|
-
try {
|
|
867
|
-
const output = await promise;
|
|
868
|
-
return Object.assign([null, output, false, true], {
|
|
869
|
-
error: null,
|
|
870
|
-
data: output,
|
|
871
|
-
isDefined: false,
|
|
872
|
-
isSuccess: true
|
|
873
|
-
});
|
|
874
|
-
} catch (e) {
|
|
875
|
-
const error = e;
|
|
876
|
-
if (isDefinedError(error)) {
|
|
877
|
-
return Object.assign([error, void 0, true, false], {
|
|
878
|
-
error,
|
|
879
|
-
data: void 0,
|
|
880
|
-
isDefined: true,
|
|
881
|
-
isSuccess: false
|
|
882
|
-
});
|
|
883
|
-
}
|
|
884
|
-
return Object.assign(
|
|
885
|
-
[error, void 0, false, false],
|
|
886
|
-
{
|
|
887
|
-
error,
|
|
888
|
-
data: void 0,
|
|
889
|
-
isDefined: false,
|
|
890
|
-
isSuccess: false
|
|
891
|
-
}
|
|
892
|
-
);
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
806
|
function toHttpPath(path) {
|
|
896
807
|
return `/${path.map(encodeURIComponent).join("/")}`;
|
|
897
808
|
}
|
|
809
|
+
function splitFirst(str, separator) {
|
|
810
|
+
const index = str.indexOf(separator);
|
|
811
|
+
if (index === -1) {
|
|
812
|
+
return [str, ""];
|
|
813
|
+
}
|
|
814
|
+
return [str.slice(0, index), str.slice(index + separator.length)];
|
|
815
|
+
}
|
|
816
|
+
function assertNever(value, message) {
|
|
817
|
+
throw new Error(message ?? `Unexpected value: ${value}`);
|
|
818
|
+
}
|
|
898
819
|
|
|
899
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass, COMMON_ORPC_ERROR_DEFS, EventPublisher, HTTPMethods, NullProtoObj, ORPCError, ORPC_CLIENT_PACKAGE_NAME, ORPC_CLIENT_PACKAGE_VERSION, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION,
|
|
820
|
+
export { AbortError, AsyncIdQueue, AsyncIteratorClass, COMMON_ORPC_ERROR_DEFS, EventPublisher, HTTPMethods, NullProtoObj, ORPCError, ORPC_CLIENT_PACKAGE_NAME, ORPC_CLIENT_PACKAGE_VERSION, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, assertNever, asyncIteratorToStream, asyncIteratorWithSpan, clone, createORPCErrorFromJson, defer, fallbackContractConfig, fallbackORPCErrorMessage, fallbackORPCErrorStatus, findDeepMatches, get, getConstructor, getGlobalOtelConfig, isAsyncIteratorObject, isDefinedError, isORPCErrorJson, isORPCErrorStatus, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitFirst, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toHttpPath, toORPCError, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporary-name/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.3-alpha.
|
|
4
|
+
"version": "1.9.3-alpha.fb7b7d19964e1b2def7056f4345b63d6fcacce10",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"openapi-types": "^12.1.3",
|
|
35
36
|
"radash": "^12.1.1"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
"scripts": {
|
|
42
43
|
"build": "unbuild",
|
|
43
44
|
"build:watch": "pnpm run build --watch",
|
|
44
|
-
"
|
|
45
|
+
"clean": "tsc -b --clean",
|
|
46
|
+
"lint:tsc": "tsc -b"
|
|
45
47
|
}
|
|
46
48
|
}
|