@temporary-name/shared 1.9.3-alpha.0d2fa3247b6b23bbc2e3097a95f631b86740e4d8 → 1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f
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 +51 -51
- package/dist/index.d.ts +51 -51
- package/dist/index.mjs +14 -32
- package/package.json +3 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { MaybeOptionalOptions as MaybeOptionalOptions$1
|
|
2
|
-
import { Promisable } from 'type-fest';
|
|
3
|
-
export { IsEqual, IsNever, JsonValue, PartialDeep, Promisable } from 'type-fest';
|
|
1
|
+
import { MaybeOptionalOptions as MaybeOptionalOptions$1 } from '@temporary-name/shared';
|
|
4
2
|
import { Tracer, TraceAPI, ContextAPI, PropagationAPI, SpanOptions, Context, Span, AttributeValue, Exception } from '@opentelemetry/api';
|
|
5
3
|
export { group, guard, mapEntries, mapValues, omit, retry, sleep } from 'radash';
|
|
6
4
|
|
|
7
5
|
type MaybeOptionalOptions<TOptions> = Record<never, never> extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
6
|
+
type OptionalIfEmpty<TOptions> = {} extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
8
7
|
declare function resolveMaybeOptionalOptions<T>(rest: MaybeOptionalOptions<T>): T;
|
|
9
8
|
|
|
10
9
|
declare function toArray<T>(value: T): T extends readonly any[] ? T : Exclude<T, undefined | null>[];
|
|
@@ -31,7 +30,7 @@ type OmitChainMethodDeep<T extends object, K extends keyof any> = {
|
|
|
31
30
|
|
|
32
31
|
declare const ORPC_NAME = "orpc";
|
|
33
32
|
declare const ORPC_SHARED_PACKAGE_NAME = "@temporary-name/shared";
|
|
34
|
-
declare const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.
|
|
33
|
+
declare const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f";
|
|
35
34
|
|
|
36
35
|
declare const ORPC_CLIENT_PACKAGE_NAME = "__ORPC_CLIENT_PACKAGE_NAME_PLACEHOLDER__";
|
|
37
36
|
declare const ORPC_CLIENT_PACKAGE_VERSION = "__ORPC_CLIENT_PACKAGE_VERSION_PLACEHOLDER__";
|
|
@@ -225,10 +224,46 @@ declare class SequentialIdGenerator {
|
|
|
225
224
|
generate(): string;
|
|
226
225
|
}
|
|
227
226
|
|
|
227
|
+
type StandardBody = undefined | unknown | Blob | URLSearchParams | FormData | AsyncIterator<unknown | void, unknown | void, undefined>;
|
|
228
|
+
interface StandardRequest {
|
|
229
|
+
method: string;
|
|
230
|
+
url: URL;
|
|
231
|
+
headers: Headers;
|
|
232
|
+
/**
|
|
233
|
+
* The body has been parsed based on the content-type header.
|
|
234
|
+
*/
|
|
235
|
+
body: StandardBody;
|
|
236
|
+
signal: AbortSignal | undefined;
|
|
237
|
+
}
|
|
238
|
+
interface StandardLazyRequest extends Omit<StandardRequest, 'body'> {
|
|
239
|
+
/**
|
|
240
|
+
* The body has been parsed based on the content-type header.
|
|
241
|
+
* This method can safely call multiple times (cached).
|
|
242
|
+
*/
|
|
243
|
+
body: () => Promise<StandardBody>;
|
|
244
|
+
}
|
|
245
|
+
interface StandardResponse {
|
|
246
|
+
status: number;
|
|
247
|
+
headers: Headers;
|
|
248
|
+
/**
|
|
249
|
+
* The body has been parsed based on the content-type header.
|
|
250
|
+
*/
|
|
251
|
+
body: StandardBody;
|
|
252
|
+
}
|
|
253
|
+
interface StandardLazyResponse extends Omit<StandardResponse, 'body'> {
|
|
254
|
+
/**
|
|
255
|
+
* The body has been parsed based on the content-type header.
|
|
256
|
+
* This method can safely call multiple times (cached).
|
|
257
|
+
*/
|
|
258
|
+
body: () => Promise<StandardBody>;
|
|
259
|
+
}
|
|
228
260
|
type HTTPPath = `/${string}`;
|
|
229
|
-
|
|
261
|
+
declare const HTTPMethods: readonly ["HEAD", "GET", "POST", "PUT", "DELETE", "PATCH"];
|
|
262
|
+
type HTTPMethod = (typeof HTTPMethods)[number];
|
|
263
|
+
type HTTPEndpoint = `${HTTPMethod} ${HTTPPath}`;
|
|
230
264
|
type ClientContext = Record<PropertyKey, any>;
|
|
231
265
|
interface ClientOptions<T extends ClientContext> {
|
|
266
|
+
request?: StandardLazyRequest;
|
|
232
267
|
signal?: AbortSignal;
|
|
233
268
|
lastEventId?: string | undefined;
|
|
234
269
|
context: T;
|
|
@@ -242,11 +277,10 @@ type ClientRest<TClientContext extends ClientContext, TInput> = Record<never, ne
|
|
|
242
277
|
input?: TInput,
|
|
243
278
|
options?: FriendlyClientOptions<TClientContext>
|
|
244
279
|
] : [input: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options: FriendlyClientOptions<TClientContext>];
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
(...rest: ClientRest<TClientContext, TInput>): ClientPromiseResult<TOutput, TError>;
|
|
280
|
+
interface Client<TClientContext extends ClientContext, TInput, TOutput> {
|
|
281
|
+
(...rest: ClientRest<TClientContext, TInput>): Promise<TOutput>;
|
|
248
282
|
}
|
|
249
|
-
type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any
|
|
283
|
+
type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any> | {
|
|
250
284
|
[k: string]: NestedClient<TClientContext>;
|
|
251
285
|
};
|
|
252
286
|
type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
|
|
@@ -255,22 +289,9 @@ interface ClientLink<TClientContext extends ClientContext> {
|
|
|
255
289
|
}
|
|
256
290
|
type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
257
291
|
type IntersectPick<T, U> = Pick<T, keyof T & keyof U>;
|
|
258
|
-
type PromiseWithError<T, TError> = Promise<T> & {
|
|
259
|
-
__error?: {
|
|
260
|
-
type: TError;
|
|
261
|
-
};
|
|
262
|
-
};
|
|
263
|
-
/**
|
|
264
|
-
* The place where you can config the orpc types.
|
|
265
|
-
*
|
|
266
|
-
* - `throwableError` the error type that represent throwable errors should be `Error` or `null | undefined | {}` if you want more strict.
|
|
267
|
-
*/
|
|
268
|
-
interface Registry {
|
|
269
|
-
}
|
|
270
|
-
type ThrowableError = Registry extends {
|
|
271
|
-
throwableError: infer T;
|
|
272
|
-
} ? T : Error;
|
|
273
292
|
type InferAsyncIterableYield<T> = T extends AsyncIterable<infer U> ? U : never;
|
|
293
|
+
type IsEqual<A, B> = (<G>() => G extends (A & G) | G ? 1 : 2) extends <G>() => G extends (B & G) | G ? 1 : 2 ? true : false;
|
|
294
|
+
type Promisable<T> = T | PromiseLike<T>;
|
|
274
295
|
|
|
275
296
|
type InterceptableOptions = Record<string, any>;
|
|
276
297
|
type InterceptorOptions<TOptions extends InterceptableOptions, TResult> = Omit<TOptions, 'next'> & {
|
|
@@ -294,14 +315,14 @@ declare function onSuccess<T, TOptions extends {
|
|
|
294
315
|
*/
|
|
295
316
|
declare function onError<T, TOptions extends {
|
|
296
317
|
next(): any;
|
|
297
|
-
}, TRest extends any[]>(callback: NoInfer<(error:
|
|
318
|
+
}, TRest extends any[]>(callback: NoInfer<(error: Error, options: TOptions, ...rest: TRest) => Promisable<void>>): (options: TOptions, ...rest: TRest) => T | Promise<Awaited<ReturnType<TOptions['next']>>>;
|
|
298
319
|
type OnFinishState<TResult, TError> = [error: TError, data: undefined, isSuccess: false] | [error: null, data: TResult, isSuccess: true];
|
|
299
320
|
/**
|
|
300
321
|
* Can used for interceptors or middlewares
|
|
301
322
|
*/
|
|
302
323
|
declare function onFinish<T, TOptions extends {
|
|
303
324
|
next(): any;
|
|
304
|
-
}, TRest extends any[]>(callback: NoInfer<(state: OnFinishState<Awaited<ReturnType<TOptions['next']>>,
|
|
325
|
+
}, 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']>>>;
|
|
305
326
|
declare function intercept<TOptions extends InterceptableOptions, TResult>(interceptors: Interceptor<TOptions, TResult>[], options: NoInfer<TOptions>, main: NoInfer<(options: TOptions) => TResult>): TResult;
|
|
306
327
|
|
|
307
328
|
/**
|
|
@@ -480,30 +501,9 @@ declare function asyncIteratorToStream<T>(iterator: AsyncIterator<T>): ReadableS
|
|
|
480
501
|
|
|
481
502
|
declare function tryDecodeURIComponent(value: string): string;
|
|
482
503
|
|
|
483
|
-
type SafeResult<TOutput, TError> = ([error: null, data: TOutput, isDefined: false, isSuccess: true] & {
|
|
484
|
-
error: null;
|
|
485
|
-
data: TOutput;
|
|
486
|
-
isDefined: false;
|
|
487
|
-
isSuccess: true;
|
|
488
|
-
}) | ([error: Exclude<TError, ORPCError<any, any>>, data: undefined, isDefined: false, isSuccess: false] & {
|
|
489
|
-
error: Exclude<TError, ORPCError<any, any>>;
|
|
490
|
-
data: undefined;
|
|
491
|
-
isDefined: false;
|
|
492
|
-
isSuccess: false;
|
|
493
|
-
}) | ([error: Extract<TError, ORPCError<any, any>>, data: undefined, isDefined: true, isSuccess: false] & {
|
|
494
|
-
error: Extract<TError, ORPCError<any, any>>;
|
|
495
|
-
data: undefined;
|
|
496
|
-
isDefined: true;
|
|
497
|
-
isSuccess: false;
|
|
498
|
-
});
|
|
499
|
-
/**
|
|
500
|
-
* Works like try/catch, but can infer error types.
|
|
501
|
-
*
|
|
502
|
-
* @info support both tuple `[error, data, isDefined, isSuccess]` and object `{ error, data, isDefined, isSuccess }` styles.
|
|
503
|
-
* @see {@link https://orpc.unnoq.com/docs/client/error-handling Client Error Handling Docs}
|
|
504
|
-
*/
|
|
505
|
-
declare function safe<TOutput, TError = ThrowableError$1>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
|
|
506
504
|
declare function toHttpPath(path: readonly string[]): HTTPPath;
|
|
505
|
+
declare function splitFirst(str: string, separator: string): [string, string];
|
|
506
|
+
declare function assertNever(value: never): never;
|
|
507
507
|
|
|
508
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass, COMMON_ORPC_ERROR_DEFS, EventPublisher, NullProtoObj, ORPCError, ORPC_CLIENT_PACKAGE_NAME, ORPC_CLIENT_PACKAGE_VERSION, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, SequentialIdGenerator, asyncIteratorToStream, asyncIteratorWithSpan, clone, createORPCErrorFromJson, defer, fallback, fallbackORPCErrorMessage, fallbackORPCErrorStatus, findDeepMatches, get, getConstructor, getGlobalOtelConfig, intercept, isAsyncIteratorObject, isDefinedError, isORPCErrorJson, isORPCErrorStatus, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, preventNativeAwait, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan,
|
|
509
|
-
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, AsyncIteratorWithSpanOptions, Client, ClientContext, ClientLink, ClientOptions,
|
|
508
|
+
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, SequentialIdGenerator, assertNever, asyncIteratorToStream, asyncIteratorWithSpan, clone, createORPCErrorFromJson, defer, fallback, fallbackORPCErrorMessage, fallbackORPCErrorStatus, findDeepMatches, get, getConstructor, getGlobalOtelConfig, intercept, isAsyncIteratorObject, isDefinedError, isORPCErrorJson, isORPCErrorStatus, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, preventNativeAwait, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitFirst, splitInHalf, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toHttpPath, toORPCError, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
|
509
|
+
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, AsyncIteratorWithSpanOptions, Client, ClientContext, ClientLink, ClientOptions, ClientRest, CommonORPCErrorCode, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, FriendlyClientOptions, HTTPEndpoint, HTTPMethod, HTTPPath, InferAsyncIterableYield, InferClientContext, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, IsEqual, MaybeOptionalOptions, NestedClient, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, OmitChainMethodDeep, OnFinishState, OptionalIfEmpty, OtelConfig, Promisable, RunWithSpanOptions, Segment, SetOptional, SetSpanErrorOptions, StandardBody, StandardLazyRequest, StandardLazyResponse, StandardRequest, StandardResponse, Value };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { MaybeOptionalOptions as MaybeOptionalOptions$1
|
|
2
|
-
import { Promisable } from 'type-fest';
|
|
3
|
-
export { IsEqual, IsNever, JsonValue, PartialDeep, Promisable } from 'type-fest';
|
|
1
|
+
import { MaybeOptionalOptions as MaybeOptionalOptions$1 } from '@temporary-name/shared';
|
|
4
2
|
import { Tracer, TraceAPI, ContextAPI, PropagationAPI, SpanOptions, Context, Span, AttributeValue, Exception } from '@opentelemetry/api';
|
|
5
3
|
export { group, guard, mapEntries, mapValues, omit, retry, sleep } from 'radash';
|
|
6
4
|
|
|
7
5
|
type MaybeOptionalOptions<TOptions> = Record<never, never> extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
6
|
+
type OptionalIfEmpty<TOptions> = {} extends TOptions ? [options?: TOptions] : [options: TOptions];
|
|
8
7
|
declare function resolveMaybeOptionalOptions<T>(rest: MaybeOptionalOptions<T>): T;
|
|
9
8
|
|
|
10
9
|
declare function toArray<T>(value: T): T extends readonly any[] ? T : Exclude<T, undefined | null>[];
|
|
@@ -31,7 +30,7 @@ type OmitChainMethodDeep<T extends object, K extends keyof any> = {
|
|
|
31
30
|
|
|
32
31
|
declare const ORPC_NAME = "orpc";
|
|
33
32
|
declare const ORPC_SHARED_PACKAGE_NAME = "@temporary-name/shared";
|
|
34
|
-
declare const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.
|
|
33
|
+
declare const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f";
|
|
35
34
|
|
|
36
35
|
declare const ORPC_CLIENT_PACKAGE_NAME = "__ORPC_CLIENT_PACKAGE_NAME_PLACEHOLDER__";
|
|
37
36
|
declare const ORPC_CLIENT_PACKAGE_VERSION = "__ORPC_CLIENT_PACKAGE_VERSION_PLACEHOLDER__";
|
|
@@ -225,10 +224,46 @@ declare class SequentialIdGenerator {
|
|
|
225
224
|
generate(): string;
|
|
226
225
|
}
|
|
227
226
|
|
|
227
|
+
type StandardBody = undefined | unknown | Blob | URLSearchParams | FormData | AsyncIterator<unknown | void, unknown | void, undefined>;
|
|
228
|
+
interface StandardRequest {
|
|
229
|
+
method: string;
|
|
230
|
+
url: URL;
|
|
231
|
+
headers: Headers;
|
|
232
|
+
/**
|
|
233
|
+
* The body has been parsed based on the content-type header.
|
|
234
|
+
*/
|
|
235
|
+
body: StandardBody;
|
|
236
|
+
signal: AbortSignal | undefined;
|
|
237
|
+
}
|
|
238
|
+
interface StandardLazyRequest extends Omit<StandardRequest, 'body'> {
|
|
239
|
+
/**
|
|
240
|
+
* The body has been parsed based on the content-type header.
|
|
241
|
+
* This method can safely call multiple times (cached).
|
|
242
|
+
*/
|
|
243
|
+
body: () => Promise<StandardBody>;
|
|
244
|
+
}
|
|
245
|
+
interface StandardResponse {
|
|
246
|
+
status: number;
|
|
247
|
+
headers: Headers;
|
|
248
|
+
/**
|
|
249
|
+
* The body has been parsed based on the content-type header.
|
|
250
|
+
*/
|
|
251
|
+
body: StandardBody;
|
|
252
|
+
}
|
|
253
|
+
interface StandardLazyResponse extends Omit<StandardResponse, 'body'> {
|
|
254
|
+
/**
|
|
255
|
+
* The body has been parsed based on the content-type header.
|
|
256
|
+
* This method can safely call multiple times (cached).
|
|
257
|
+
*/
|
|
258
|
+
body: () => Promise<StandardBody>;
|
|
259
|
+
}
|
|
228
260
|
type HTTPPath = `/${string}`;
|
|
229
|
-
|
|
261
|
+
declare const HTTPMethods: readonly ["HEAD", "GET", "POST", "PUT", "DELETE", "PATCH"];
|
|
262
|
+
type HTTPMethod = (typeof HTTPMethods)[number];
|
|
263
|
+
type HTTPEndpoint = `${HTTPMethod} ${HTTPPath}`;
|
|
230
264
|
type ClientContext = Record<PropertyKey, any>;
|
|
231
265
|
interface ClientOptions<T extends ClientContext> {
|
|
266
|
+
request?: StandardLazyRequest;
|
|
232
267
|
signal?: AbortSignal;
|
|
233
268
|
lastEventId?: string | undefined;
|
|
234
269
|
context: T;
|
|
@@ -242,11 +277,10 @@ type ClientRest<TClientContext extends ClientContext, TInput> = Record<never, ne
|
|
|
242
277
|
input?: TInput,
|
|
243
278
|
options?: FriendlyClientOptions<TClientContext>
|
|
244
279
|
] : [input: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options: FriendlyClientOptions<TClientContext>];
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
(...rest: ClientRest<TClientContext, TInput>): ClientPromiseResult<TOutput, TError>;
|
|
280
|
+
interface Client<TClientContext extends ClientContext, TInput, TOutput> {
|
|
281
|
+
(...rest: ClientRest<TClientContext, TInput>): Promise<TOutput>;
|
|
248
282
|
}
|
|
249
|
-
type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any
|
|
283
|
+
type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any> | {
|
|
250
284
|
[k: string]: NestedClient<TClientContext>;
|
|
251
285
|
};
|
|
252
286
|
type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
|
|
@@ -255,22 +289,9 @@ interface ClientLink<TClientContext extends ClientContext> {
|
|
|
255
289
|
}
|
|
256
290
|
type SetOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
257
291
|
type IntersectPick<T, U> = Pick<T, keyof T & keyof U>;
|
|
258
|
-
type PromiseWithError<T, TError> = Promise<T> & {
|
|
259
|
-
__error?: {
|
|
260
|
-
type: TError;
|
|
261
|
-
};
|
|
262
|
-
};
|
|
263
|
-
/**
|
|
264
|
-
* The place where you can config the orpc types.
|
|
265
|
-
*
|
|
266
|
-
* - `throwableError` the error type that represent throwable errors should be `Error` or `null | undefined | {}` if you want more strict.
|
|
267
|
-
*/
|
|
268
|
-
interface Registry {
|
|
269
|
-
}
|
|
270
|
-
type ThrowableError = Registry extends {
|
|
271
|
-
throwableError: infer T;
|
|
272
|
-
} ? T : Error;
|
|
273
292
|
type InferAsyncIterableYield<T> = T extends AsyncIterable<infer U> ? U : never;
|
|
293
|
+
type IsEqual<A, B> = (<G>() => G extends (A & G) | G ? 1 : 2) extends <G>() => G extends (B & G) | G ? 1 : 2 ? true : false;
|
|
294
|
+
type Promisable<T> = T | PromiseLike<T>;
|
|
274
295
|
|
|
275
296
|
type InterceptableOptions = Record<string, any>;
|
|
276
297
|
type InterceptorOptions<TOptions extends InterceptableOptions, TResult> = Omit<TOptions, 'next'> & {
|
|
@@ -294,14 +315,14 @@ declare function onSuccess<T, TOptions extends {
|
|
|
294
315
|
*/
|
|
295
316
|
declare function onError<T, TOptions extends {
|
|
296
317
|
next(): any;
|
|
297
|
-
}, TRest extends any[]>(callback: NoInfer<(error:
|
|
318
|
+
}, TRest extends any[]>(callback: NoInfer<(error: Error, options: TOptions, ...rest: TRest) => Promisable<void>>): (options: TOptions, ...rest: TRest) => T | Promise<Awaited<ReturnType<TOptions['next']>>>;
|
|
298
319
|
type OnFinishState<TResult, TError> = [error: TError, data: undefined, isSuccess: false] | [error: null, data: TResult, isSuccess: true];
|
|
299
320
|
/**
|
|
300
321
|
* Can used for interceptors or middlewares
|
|
301
322
|
*/
|
|
302
323
|
declare function onFinish<T, TOptions extends {
|
|
303
324
|
next(): any;
|
|
304
|
-
}, TRest extends any[]>(callback: NoInfer<(state: OnFinishState<Awaited<ReturnType<TOptions['next']>>,
|
|
325
|
+
}, 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']>>>;
|
|
305
326
|
declare function intercept<TOptions extends InterceptableOptions, TResult>(interceptors: Interceptor<TOptions, TResult>[], options: NoInfer<TOptions>, main: NoInfer<(options: TOptions) => TResult>): TResult;
|
|
306
327
|
|
|
307
328
|
/**
|
|
@@ -480,30 +501,9 @@ declare function asyncIteratorToStream<T>(iterator: AsyncIterator<T>): ReadableS
|
|
|
480
501
|
|
|
481
502
|
declare function tryDecodeURIComponent(value: string): string;
|
|
482
503
|
|
|
483
|
-
type SafeResult<TOutput, TError> = ([error: null, data: TOutput, isDefined: false, isSuccess: true] & {
|
|
484
|
-
error: null;
|
|
485
|
-
data: TOutput;
|
|
486
|
-
isDefined: false;
|
|
487
|
-
isSuccess: true;
|
|
488
|
-
}) | ([error: Exclude<TError, ORPCError<any, any>>, data: undefined, isDefined: false, isSuccess: false] & {
|
|
489
|
-
error: Exclude<TError, ORPCError<any, any>>;
|
|
490
|
-
data: undefined;
|
|
491
|
-
isDefined: false;
|
|
492
|
-
isSuccess: false;
|
|
493
|
-
}) | ([error: Extract<TError, ORPCError<any, any>>, data: undefined, isDefined: true, isSuccess: false] & {
|
|
494
|
-
error: Extract<TError, ORPCError<any, any>>;
|
|
495
|
-
data: undefined;
|
|
496
|
-
isDefined: true;
|
|
497
|
-
isSuccess: false;
|
|
498
|
-
});
|
|
499
|
-
/**
|
|
500
|
-
* Works like try/catch, but can infer error types.
|
|
501
|
-
*
|
|
502
|
-
* @info support both tuple `[error, data, isDefined, isSuccess]` and object `{ error, data, isDefined, isSuccess }` styles.
|
|
503
|
-
* @see {@link https://orpc.unnoq.com/docs/client/error-handling Client Error Handling Docs}
|
|
504
|
-
*/
|
|
505
|
-
declare function safe<TOutput, TError = ThrowableError$1>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
|
|
506
504
|
declare function toHttpPath(path: readonly string[]): HTTPPath;
|
|
505
|
+
declare function splitFirst(str: string, separator: string): [string, string];
|
|
506
|
+
declare function assertNever(value: never): never;
|
|
507
507
|
|
|
508
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass, COMMON_ORPC_ERROR_DEFS, EventPublisher, NullProtoObj, ORPCError, ORPC_CLIENT_PACKAGE_NAME, ORPC_CLIENT_PACKAGE_VERSION, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, SequentialIdGenerator, asyncIteratorToStream, asyncIteratorWithSpan, clone, createORPCErrorFromJson, defer, fallback, fallbackORPCErrorMessage, fallbackORPCErrorStatus, findDeepMatches, get, getConstructor, getGlobalOtelConfig, intercept, isAsyncIteratorObject, isDefinedError, isORPCErrorJson, isORPCErrorStatus, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, preventNativeAwait, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan,
|
|
509
|
-
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, AsyncIteratorWithSpanOptions, Client, ClientContext, ClientLink, ClientOptions,
|
|
508
|
+
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, SequentialIdGenerator, assertNever, asyncIteratorToStream, asyncIteratorWithSpan, clone, createORPCErrorFromJson, defer, fallback, fallbackORPCErrorMessage, fallbackORPCErrorStatus, findDeepMatches, get, getConstructor, getGlobalOtelConfig, intercept, isAsyncIteratorObject, isDefinedError, isORPCErrorJson, isORPCErrorStatus, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, preventNativeAwait, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitFirst, splitInHalf, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toHttpPath, toORPCError, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
|
509
|
+
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, AsyncIteratorWithSpanOptions, Client, ClientContext, ClientLink, ClientOptions, ClientRest, CommonORPCErrorCode, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, FriendlyClientOptions, HTTPEndpoint, HTTPMethod, HTTPPath, InferAsyncIterableYield, InferClientContext, InterceptableOptions, Interceptor, InterceptorOptions, IntersectPick, IsEqual, MaybeOptionalOptions, NestedClient, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, OmitChainMethodDeep, OnFinishState, OptionalIfEmpty, OtelConfig, Promisable, RunWithSpanOptions, Segment, SetOptional, SetSpanErrorOptions, StandardBody, StandardLazyRequest, StandardLazyResponse, StandardRequest, StandardResponse, Value };
|
package/dist/index.mjs
CHANGED
|
@@ -22,7 +22,7 @@ function readAsBuffer(source) {
|
|
|
22
22
|
|
|
23
23
|
const ORPC_NAME = "orpc";
|
|
24
24
|
const ORPC_SHARED_PACKAGE_NAME = "@temporary-name/shared";
|
|
25
|
-
const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.
|
|
25
|
+
const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f";
|
|
26
26
|
|
|
27
27
|
const ORPC_CLIENT_PACKAGE_NAME = "__ORPC_CLIENT_PACKAGE_NAME_PLACEHOLDER__";
|
|
28
28
|
const ORPC_CLIENT_PACKAGE_VERSION = "__ORPC_CLIENT_PACKAGE_VERSION_PLACEHOLDER__";
|
|
@@ -852,6 +852,8 @@ function asyncIteratorToStream(iterator) {
|
|
|
852
852
|
});
|
|
853
853
|
}
|
|
854
854
|
|
|
855
|
+
const HTTPMethods = ["HEAD", "GET", "POST", "PUT", "DELETE", "PATCH"];
|
|
856
|
+
|
|
855
857
|
function tryDecodeURIComponent(value) {
|
|
856
858
|
try {
|
|
857
859
|
return decodeURIComponent(value);
|
|
@@ -860,38 +862,18 @@ function tryDecodeURIComponent(value) {
|
|
|
860
862
|
}
|
|
861
863
|
}
|
|
862
864
|
|
|
863
|
-
async function safe(promise) {
|
|
864
|
-
try {
|
|
865
|
-
const output = await promise;
|
|
866
|
-
return Object.assign([null, output, false, true], {
|
|
867
|
-
error: null,
|
|
868
|
-
data: output,
|
|
869
|
-
isDefined: false,
|
|
870
|
-
isSuccess: true
|
|
871
|
-
});
|
|
872
|
-
} catch (e) {
|
|
873
|
-
const error = e;
|
|
874
|
-
if (isDefinedError(error)) {
|
|
875
|
-
return Object.assign([error, void 0, true, false], {
|
|
876
|
-
error,
|
|
877
|
-
data: void 0,
|
|
878
|
-
isDefined: true,
|
|
879
|
-
isSuccess: false
|
|
880
|
-
});
|
|
881
|
-
}
|
|
882
|
-
return Object.assign(
|
|
883
|
-
[error, void 0, false, false],
|
|
884
|
-
{
|
|
885
|
-
error,
|
|
886
|
-
data: void 0,
|
|
887
|
-
isDefined: false,
|
|
888
|
-
isSuccess: false
|
|
889
|
-
}
|
|
890
|
-
);
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
865
|
function toHttpPath(path) {
|
|
894
866
|
return `/${path.map(encodeURIComponent).join("/")}`;
|
|
895
867
|
}
|
|
868
|
+
function splitFirst(str, separator) {
|
|
869
|
+
const index = str.indexOf(separator);
|
|
870
|
+
if (index === -1) {
|
|
871
|
+
return [str, ""];
|
|
872
|
+
}
|
|
873
|
+
return [str.slice(0, index), str.slice(index + separator.length)];
|
|
874
|
+
}
|
|
875
|
+
function assertNever(value) {
|
|
876
|
+
throw new Error(`Unexpected value: ${value}`);
|
|
877
|
+
}
|
|
896
878
|
|
|
897
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass, COMMON_ORPC_ERROR_DEFS, EventPublisher, NullProtoObj, ORPCError, ORPC_CLIENT_PACKAGE_NAME, ORPC_CLIENT_PACKAGE_VERSION, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, SequentialIdGenerator, asyncIteratorToStream, asyncIteratorWithSpan, clone, createORPCErrorFromJson, defer, fallback, fallbackORPCErrorMessage, fallbackORPCErrorStatus, findDeepMatches, get, getConstructor, getGlobalOtelConfig, intercept, isAsyncIteratorObject, isDefinedError, isORPCErrorJson, isORPCErrorStatus, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, preventNativeAwait, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan,
|
|
879
|
+
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, SequentialIdGenerator, assertNever, asyncIteratorToStream, asyncIteratorWithSpan, clone, createORPCErrorFromJson, defer, fallback, fallbackORPCErrorMessage, fallbackORPCErrorStatus, findDeepMatches, get, getConstructor, getGlobalOtelConfig, intercept, isAsyncIteratorObject, isDefinedError, isORPCErrorJson, isORPCErrorStatus, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, preventNativeAwait, readAsBuffer, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitFirst, splitInHalf, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toHttpPath, toORPCError, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporary-name/shared",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.3-alpha.
|
|
4
|
+
"version": "1.9.3-alpha.0f2e1f4d66464608b85c66977bff51174cbb238f",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/
|
|
9
|
+
"url": "git+https://github.com/stainless-api/krusty.git",
|
|
10
10
|
"directory": "packages/shared"
|
|
11
11
|
},
|
|
12
12
|
"keywords": [
|
|
@@ -32,13 +32,10 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"radash": "^12.1.1"
|
|
36
|
-
"type-fest": "^5.0.1"
|
|
35
|
+
"radash": "^12.1.1"
|
|
37
36
|
},
|
|
38
37
|
"devDependencies": {
|
|
39
38
|
"@opentelemetry/api": "^1.9.0",
|
|
40
|
-
"arktype": "2.1.22",
|
|
41
|
-
"valibot": "^1.1.0",
|
|
42
39
|
"zod": "^4.1.11"
|
|
43
40
|
},
|
|
44
41
|
"scripts": {
|