@temporary-name/shared 1.9.3-alpha.fb7b7d19964e1b2def7056f4345b63d6fcacce10 → 1.9.3-alpha.fb7e3a67f82deaeffad5063e136b2f3c03c4b5b3
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 +3 -124
- package/dist/index.d.ts +3 -124
- package/dist/index.mjs +2 -171
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { MaybeOptionalOptions as MaybeOptionalOptions$1 } from '@temporary-name/shared';
|
|
2
1
|
import { Tracer, TraceAPI, ContextAPI, PropagationAPI, SpanOptions, Context, Span, AttributeValue, Exception } from '@opentelemetry/api';
|
|
3
2
|
export { group, guard, mapEntries, mapValues, omit, retry, sleep } from 'radash';
|
|
4
3
|
export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
|
|
@@ -89,128 +88,8 @@ declare function fallbackContractConfig<T extends keyof ContractConfig>(key: T,
|
|
|
89
88
|
|
|
90
89
|
declare const ORPC_NAME = "orpc";
|
|
91
90
|
declare const ORPC_SHARED_PACKAGE_NAME = "@temporary-name/shared";
|
|
92
|
-
declare const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.
|
|
91
|
+
declare const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.fb7e3a67f82deaeffad5063e136b2f3c03c4b5b3";
|
|
93
92
|
|
|
94
|
-
declare const ORPC_CLIENT_PACKAGE_NAME = "__ORPC_CLIENT_PACKAGE_NAME_PLACEHOLDER__";
|
|
95
|
-
declare const ORPC_CLIENT_PACKAGE_VERSION = "__ORPC_CLIENT_PACKAGE_VERSION_PLACEHOLDER__";
|
|
96
|
-
declare const COMMON_ORPC_ERROR_DEFS: {
|
|
97
|
-
readonly BAD_REQUEST: {
|
|
98
|
-
readonly status: 400;
|
|
99
|
-
readonly message: "Bad Request";
|
|
100
|
-
};
|
|
101
|
-
readonly UNAUTHORIZED: {
|
|
102
|
-
readonly status: 401;
|
|
103
|
-
readonly message: "Unauthorized";
|
|
104
|
-
};
|
|
105
|
-
readonly FORBIDDEN: {
|
|
106
|
-
readonly status: 403;
|
|
107
|
-
readonly message: "Forbidden";
|
|
108
|
-
};
|
|
109
|
-
readonly NOT_FOUND: {
|
|
110
|
-
readonly status: 404;
|
|
111
|
-
readonly message: "Not Found";
|
|
112
|
-
};
|
|
113
|
-
readonly METHOD_NOT_SUPPORTED: {
|
|
114
|
-
readonly status: 405;
|
|
115
|
-
readonly message: "Method Not Supported";
|
|
116
|
-
};
|
|
117
|
-
readonly NOT_ACCEPTABLE: {
|
|
118
|
-
readonly status: 406;
|
|
119
|
-
readonly message: "Not Acceptable";
|
|
120
|
-
};
|
|
121
|
-
readonly TIMEOUT: {
|
|
122
|
-
readonly status: 408;
|
|
123
|
-
readonly message: "Request Timeout";
|
|
124
|
-
};
|
|
125
|
-
readonly CONFLICT: {
|
|
126
|
-
readonly status: 409;
|
|
127
|
-
readonly message: "Conflict";
|
|
128
|
-
};
|
|
129
|
-
readonly PRECONDITION_FAILED: {
|
|
130
|
-
readonly status: 412;
|
|
131
|
-
readonly message: "Precondition Failed";
|
|
132
|
-
};
|
|
133
|
-
readonly PAYLOAD_TOO_LARGE: {
|
|
134
|
-
readonly status: 413;
|
|
135
|
-
readonly message: "Payload Too Large";
|
|
136
|
-
};
|
|
137
|
-
readonly UNSUPPORTED_MEDIA_TYPE: {
|
|
138
|
-
readonly status: 415;
|
|
139
|
-
readonly message: "Unsupported Media Type";
|
|
140
|
-
};
|
|
141
|
-
readonly UNPROCESSABLE_CONTENT: {
|
|
142
|
-
readonly status: 422;
|
|
143
|
-
readonly message: "Unprocessable Content";
|
|
144
|
-
};
|
|
145
|
-
readonly TOO_MANY_REQUESTS: {
|
|
146
|
-
readonly status: 429;
|
|
147
|
-
readonly message: "Too Many Requests";
|
|
148
|
-
};
|
|
149
|
-
readonly CLIENT_CLOSED_REQUEST: {
|
|
150
|
-
readonly status: 499;
|
|
151
|
-
readonly message: "Client Closed Request";
|
|
152
|
-
};
|
|
153
|
-
readonly INTERNAL_SERVER_ERROR: {
|
|
154
|
-
readonly status: 500;
|
|
155
|
-
readonly message: "Internal Server Error";
|
|
156
|
-
};
|
|
157
|
-
readonly NOT_IMPLEMENTED: {
|
|
158
|
-
readonly status: 501;
|
|
159
|
-
readonly message: "Not Implemented";
|
|
160
|
-
};
|
|
161
|
-
readonly BAD_GATEWAY: {
|
|
162
|
-
readonly status: 502;
|
|
163
|
-
readonly message: "Bad Gateway";
|
|
164
|
-
};
|
|
165
|
-
readonly SERVICE_UNAVAILABLE: {
|
|
166
|
-
readonly status: 503;
|
|
167
|
-
readonly message: "Service Unavailable";
|
|
168
|
-
};
|
|
169
|
-
readonly GATEWAY_TIMEOUT: {
|
|
170
|
-
readonly status: 504;
|
|
171
|
-
readonly message: "Gateway Timeout";
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
type CommonORPCErrorCode = keyof typeof COMMON_ORPC_ERROR_DEFS;
|
|
175
|
-
type ORPCErrorCode = CommonORPCErrorCode | (string & {});
|
|
176
|
-
declare function fallbackORPCErrorStatus(code: ORPCErrorCode, status: number | undefined): number;
|
|
177
|
-
declare function fallbackORPCErrorMessage(code: ORPCErrorCode, message: string | undefined): string;
|
|
178
|
-
type ORPCErrorOptions<TData> = ErrorOptions & {
|
|
179
|
-
defined?: boolean;
|
|
180
|
-
status?: number;
|
|
181
|
-
message?: string;
|
|
182
|
-
} & (undefined extends TData ? {
|
|
183
|
-
data?: TData;
|
|
184
|
-
} : {
|
|
185
|
-
data: TData;
|
|
186
|
-
});
|
|
187
|
-
declare class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
|
|
188
|
-
readonly defined: boolean;
|
|
189
|
-
readonly code: TCode;
|
|
190
|
-
readonly status: number;
|
|
191
|
-
readonly data: TData;
|
|
192
|
-
constructor(code: TCode, ...rest: MaybeOptionalOptions$1<ORPCErrorOptions<TData>>);
|
|
193
|
-
toJSON(): ORPCErrorJSON<TCode, TData>;
|
|
194
|
-
/**
|
|
195
|
-
* Workaround for Next.js where different contexts use separate
|
|
196
|
-
* dependency graphs, causing multiple ORPCError constructors existing and breaking
|
|
197
|
-
* `instanceof` checks across contexts.
|
|
198
|
-
*
|
|
199
|
-
* This is particularly problematic with "Optimized SSR", where orpc-client
|
|
200
|
-
* executes in one context but is invoked from another. When an error is thrown
|
|
201
|
-
* in the execution context, `instanceof ORPCError` checks fail in the
|
|
202
|
-
* invocation context due to separate class constructors.
|
|
203
|
-
*
|
|
204
|
-
* @todo Remove this and related code if Next.js resolves the multiple dependency graph issue.
|
|
205
|
-
*/
|
|
206
|
-
static [Symbol.hasInstance](instance: unknown): boolean;
|
|
207
|
-
}
|
|
208
|
-
type ORPCErrorJSON<TCode extends string, TData> = Pick<ORPCError<TCode, TData>, 'defined' | 'code' | 'status' | 'message' | 'data'>;
|
|
209
|
-
declare function isDefinedError<T>(error: T): error is Extract<T, ORPCError<any, any>>;
|
|
210
|
-
declare function toORPCError(error: unknown): ORPCError<any, any>;
|
|
211
|
-
declare function isORPCErrorStatus(status: number): boolean;
|
|
212
|
-
declare function isORPCErrorJson(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
|
213
|
-
declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
|
214
93
|
/**
|
|
215
94
|
* Error thrown when an operation is aborted.
|
|
216
95
|
* Uses the standardized 'AbortError' name for consistency with JavaScript APIs.
|
|
@@ -482,5 +361,5 @@ declare function toHttpPath(path: readonly string[]): HTTPPath;
|
|
|
482
361
|
declare function splitFirst(str: string, separator: string): [string, string];
|
|
483
362
|
declare function assertNever(value: never, message?: string): never;
|
|
484
363
|
|
|
485
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass,
|
|
486
|
-
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, AsyncIteratorWithSpanOptions, Client, ClientContext, ClientLink, ClientOptions, ClientRest,
|
|
364
|
+
export { AbortError, AsyncIdQueue, AsyncIteratorClass, EventPublisher, HTTPMethods, NullProtoObj, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, assertNever, asyncIteratorToStream, asyncIteratorWithSpan, clone, defer, fallbackContractConfig, findDeepMatches, get, getConstructor, getGlobalOtelConfig, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitFirst, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toHttpPath, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
|
365
|
+
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, AsyncIteratorWithSpanOptions, Client, ClientContext, ClientLink, ClientOptions, ClientRest, ContractConfig, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, FriendlyClientOptions, HTTPEndpoint, HTTPMethod, HTTPPath, InferAsyncIterableYield, InferClientContext, IntersectPick, IsEqual, MaybeOptionalOptions, NestedClient, OnFinishState, OptionalIfEmpty, OtelConfig, OutputStructure, Promisable, RunWithSpanOptions, Segment, SetOptional, SetSpanErrorOptions, StandardBody, StandardLazyRequest, StandardLazyResponse, StandardRequest, StandardResponse, Value };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { MaybeOptionalOptions as MaybeOptionalOptions$1 } from '@temporary-name/shared';
|
|
2
1
|
import { Tracer, TraceAPI, ContextAPI, PropagationAPI, SpanOptions, Context, Span, AttributeValue, Exception } from '@opentelemetry/api';
|
|
3
2
|
export { group, guard, mapEntries, mapValues, omit, retry, sleep } from 'radash';
|
|
4
3
|
export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
|
|
@@ -89,128 +88,8 @@ declare function fallbackContractConfig<T extends keyof ContractConfig>(key: T,
|
|
|
89
88
|
|
|
90
89
|
declare const ORPC_NAME = "orpc";
|
|
91
90
|
declare const ORPC_SHARED_PACKAGE_NAME = "@temporary-name/shared";
|
|
92
|
-
declare const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.
|
|
91
|
+
declare const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.fb7e3a67f82deaeffad5063e136b2f3c03c4b5b3";
|
|
93
92
|
|
|
94
|
-
declare const ORPC_CLIENT_PACKAGE_NAME = "__ORPC_CLIENT_PACKAGE_NAME_PLACEHOLDER__";
|
|
95
|
-
declare const ORPC_CLIENT_PACKAGE_VERSION = "__ORPC_CLIENT_PACKAGE_VERSION_PLACEHOLDER__";
|
|
96
|
-
declare const COMMON_ORPC_ERROR_DEFS: {
|
|
97
|
-
readonly BAD_REQUEST: {
|
|
98
|
-
readonly status: 400;
|
|
99
|
-
readonly message: "Bad Request";
|
|
100
|
-
};
|
|
101
|
-
readonly UNAUTHORIZED: {
|
|
102
|
-
readonly status: 401;
|
|
103
|
-
readonly message: "Unauthorized";
|
|
104
|
-
};
|
|
105
|
-
readonly FORBIDDEN: {
|
|
106
|
-
readonly status: 403;
|
|
107
|
-
readonly message: "Forbidden";
|
|
108
|
-
};
|
|
109
|
-
readonly NOT_FOUND: {
|
|
110
|
-
readonly status: 404;
|
|
111
|
-
readonly message: "Not Found";
|
|
112
|
-
};
|
|
113
|
-
readonly METHOD_NOT_SUPPORTED: {
|
|
114
|
-
readonly status: 405;
|
|
115
|
-
readonly message: "Method Not Supported";
|
|
116
|
-
};
|
|
117
|
-
readonly NOT_ACCEPTABLE: {
|
|
118
|
-
readonly status: 406;
|
|
119
|
-
readonly message: "Not Acceptable";
|
|
120
|
-
};
|
|
121
|
-
readonly TIMEOUT: {
|
|
122
|
-
readonly status: 408;
|
|
123
|
-
readonly message: "Request Timeout";
|
|
124
|
-
};
|
|
125
|
-
readonly CONFLICT: {
|
|
126
|
-
readonly status: 409;
|
|
127
|
-
readonly message: "Conflict";
|
|
128
|
-
};
|
|
129
|
-
readonly PRECONDITION_FAILED: {
|
|
130
|
-
readonly status: 412;
|
|
131
|
-
readonly message: "Precondition Failed";
|
|
132
|
-
};
|
|
133
|
-
readonly PAYLOAD_TOO_LARGE: {
|
|
134
|
-
readonly status: 413;
|
|
135
|
-
readonly message: "Payload Too Large";
|
|
136
|
-
};
|
|
137
|
-
readonly UNSUPPORTED_MEDIA_TYPE: {
|
|
138
|
-
readonly status: 415;
|
|
139
|
-
readonly message: "Unsupported Media Type";
|
|
140
|
-
};
|
|
141
|
-
readonly UNPROCESSABLE_CONTENT: {
|
|
142
|
-
readonly status: 422;
|
|
143
|
-
readonly message: "Unprocessable Content";
|
|
144
|
-
};
|
|
145
|
-
readonly TOO_MANY_REQUESTS: {
|
|
146
|
-
readonly status: 429;
|
|
147
|
-
readonly message: "Too Many Requests";
|
|
148
|
-
};
|
|
149
|
-
readonly CLIENT_CLOSED_REQUEST: {
|
|
150
|
-
readonly status: 499;
|
|
151
|
-
readonly message: "Client Closed Request";
|
|
152
|
-
};
|
|
153
|
-
readonly INTERNAL_SERVER_ERROR: {
|
|
154
|
-
readonly status: 500;
|
|
155
|
-
readonly message: "Internal Server Error";
|
|
156
|
-
};
|
|
157
|
-
readonly NOT_IMPLEMENTED: {
|
|
158
|
-
readonly status: 501;
|
|
159
|
-
readonly message: "Not Implemented";
|
|
160
|
-
};
|
|
161
|
-
readonly BAD_GATEWAY: {
|
|
162
|
-
readonly status: 502;
|
|
163
|
-
readonly message: "Bad Gateway";
|
|
164
|
-
};
|
|
165
|
-
readonly SERVICE_UNAVAILABLE: {
|
|
166
|
-
readonly status: 503;
|
|
167
|
-
readonly message: "Service Unavailable";
|
|
168
|
-
};
|
|
169
|
-
readonly GATEWAY_TIMEOUT: {
|
|
170
|
-
readonly status: 504;
|
|
171
|
-
readonly message: "Gateway Timeout";
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
type CommonORPCErrorCode = keyof typeof COMMON_ORPC_ERROR_DEFS;
|
|
175
|
-
type ORPCErrorCode = CommonORPCErrorCode | (string & {});
|
|
176
|
-
declare function fallbackORPCErrorStatus(code: ORPCErrorCode, status: number | undefined): number;
|
|
177
|
-
declare function fallbackORPCErrorMessage(code: ORPCErrorCode, message: string | undefined): string;
|
|
178
|
-
type ORPCErrorOptions<TData> = ErrorOptions & {
|
|
179
|
-
defined?: boolean;
|
|
180
|
-
status?: number;
|
|
181
|
-
message?: string;
|
|
182
|
-
} & (undefined extends TData ? {
|
|
183
|
-
data?: TData;
|
|
184
|
-
} : {
|
|
185
|
-
data: TData;
|
|
186
|
-
});
|
|
187
|
-
declare class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
|
|
188
|
-
readonly defined: boolean;
|
|
189
|
-
readonly code: TCode;
|
|
190
|
-
readonly status: number;
|
|
191
|
-
readonly data: TData;
|
|
192
|
-
constructor(code: TCode, ...rest: MaybeOptionalOptions$1<ORPCErrorOptions<TData>>);
|
|
193
|
-
toJSON(): ORPCErrorJSON<TCode, TData>;
|
|
194
|
-
/**
|
|
195
|
-
* Workaround for Next.js where different contexts use separate
|
|
196
|
-
* dependency graphs, causing multiple ORPCError constructors existing and breaking
|
|
197
|
-
* `instanceof` checks across contexts.
|
|
198
|
-
*
|
|
199
|
-
* This is particularly problematic with "Optimized SSR", where orpc-client
|
|
200
|
-
* executes in one context but is invoked from another. When an error is thrown
|
|
201
|
-
* in the execution context, `instanceof ORPCError` checks fail in the
|
|
202
|
-
* invocation context due to separate class constructors.
|
|
203
|
-
*
|
|
204
|
-
* @todo Remove this and related code if Next.js resolves the multiple dependency graph issue.
|
|
205
|
-
*/
|
|
206
|
-
static [Symbol.hasInstance](instance: unknown): boolean;
|
|
207
|
-
}
|
|
208
|
-
type ORPCErrorJSON<TCode extends string, TData> = Pick<ORPCError<TCode, TData>, 'defined' | 'code' | 'status' | 'message' | 'data'>;
|
|
209
|
-
declare function isDefinedError<T>(error: T): error is Extract<T, ORPCError<any, any>>;
|
|
210
|
-
declare function toORPCError(error: unknown): ORPCError<any, any>;
|
|
211
|
-
declare function isORPCErrorStatus(status: number): boolean;
|
|
212
|
-
declare function isORPCErrorJson(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
|
213
|
-
declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
|
214
93
|
/**
|
|
215
94
|
* Error thrown when an operation is aborted.
|
|
216
95
|
* Uses the standardized 'AbortError' name for consistency with JavaScript APIs.
|
|
@@ -482,5 +361,5 @@ declare function toHttpPath(path: readonly string[]): HTTPPath;
|
|
|
482
361
|
declare function splitFirst(str: string, separator: string): [string, string];
|
|
483
362
|
declare function assertNever(value: never, message?: string): never;
|
|
484
363
|
|
|
485
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass,
|
|
486
|
-
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, AsyncIteratorWithSpanOptions, Client, ClientContext, ClientLink, ClientOptions, ClientRest,
|
|
364
|
+
export { AbortError, AsyncIdQueue, AsyncIteratorClass, EventPublisher, HTTPMethods, NullProtoObj, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, assertNever, asyncIteratorToStream, asyncIteratorWithSpan, clone, defer, fallbackContractConfig, findDeepMatches, get, getConstructor, getGlobalOtelConfig, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitFirst, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toHttpPath, toOtelException, toSpanAttributeValue, tryDecodeURIComponent, value };
|
|
365
|
+
export type { AnyFunction, AsyncIdQueueCloseOptions, AsyncIteratorClassCleanupFn, AsyncIteratorClassNextFn, AsyncIteratorWithSpanOptions, Client, ClientContext, ClientLink, ClientOptions, ClientRest, ContractConfig, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, FriendlyClientOptions, HTTPEndpoint, HTTPMethod, HTTPPath, InferAsyncIterableYield, InferClientContext, IntersectPick, IsEqual, MaybeOptionalOptions, NestedClient, OnFinishState, OptionalIfEmpty, OtelConfig, OutputStructure, Promisable, RunWithSpanOptions, Segment, SetOptional, SetSpanErrorOptions, StandardBody, StandardLazyRequest, StandardLazyResponse, StandardRequest, StandardResponse, Value };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { resolveMaybeOptionalOptions as resolveMaybeOptionalOptions$1, getConstructor as getConstructor$1, isObject as isObject$1 } from '@temporary-name/shared';
|
|
2
1
|
export { group, guard, mapEntries, mapValues, omit, retry, sleep } from 'radash';
|
|
3
2
|
|
|
4
3
|
function resolveMaybeOptionalOptions(rest) {
|
|
@@ -24,176 +23,8 @@ function fallbackContractConfig(key, value) {
|
|
|
24
23
|
|
|
25
24
|
const ORPC_NAME = "orpc";
|
|
26
25
|
const ORPC_SHARED_PACKAGE_NAME = "@temporary-name/shared";
|
|
27
|
-
const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.
|
|
26
|
+
const ORPC_SHARED_PACKAGE_VERSION = "1.9.3-alpha.fb7e3a67f82deaeffad5063e136b2f3c03c4b5b3";
|
|
28
27
|
|
|
29
|
-
const ORPC_CLIENT_PACKAGE_NAME = "__ORPC_CLIENT_PACKAGE_NAME_PLACEHOLDER__";
|
|
30
|
-
const ORPC_CLIENT_PACKAGE_VERSION = "__ORPC_CLIENT_PACKAGE_VERSION_PLACEHOLDER__";
|
|
31
|
-
const COMMON_ORPC_ERROR_DEFS = {
|
|
32
|
-
BAD_REQUEST: {
|
|
33
|
-
status: 400,
|
|
34
|
-
message: "Bad Request"
|
|
35
|
-
},
|
|
36
|
-
UNAUTHORIZED: {
|
|
37
|
-
status: 401,
|
|
38
|
-
message: "Unauthorized"
|
|
39
|
-
},
|
|
40
|
-
FORBIDDEN: {
|
|
41
|
-
status: 403,
|
|
42
|
-
message: "Forbidden"
|
|
43
|
-
},
|
|
44
|
-
NOT_FOUND: {
|
|
45
|
-
status: 404,
|
|
46
|
-
message: "Not Found"
|
|
47
|
-
},
|
|
48
|
-
METHOD_NOT_SUPPORTED: {
|
|
49
|
-
status: 405,
|
|
50
|
-
message: "Method Not Supported"
|
|
51
|
-
},
|
|
52
|
-
NOT_ACCEPTABLE: {
|
|
53
|
-
status: 406,
|
|
54
|
-
message: "Not Acceptable"
|
|
55
|
-
},
|
|
56
|
-
TIMEOUT: {
|
|
57
|
-
status: 408,
|
|
58
|
-
message: "Request Timeout"
|
|
59
|
-
},
|
|
60
|
-
CONFLICT: {
|
|
61
|
-
status: 409,
|
|
62
|
-
message: "Conflict"
|
|
63
|
-
},
|
|
64
|
-
PRECONDITION_FAILED: {
|
|
65
|
-
status: 412,
|
|
66
|
-
message: "Precondition Failed"
|
|
67
|
-
},
|
|
68
|
-
PAYLOAD_TOO_LARGE: {
|
|
69
|
-
status: 413,
|
|
70
|
-
message: "Payload Too Large"
|
|
71
|
-
},
|
|
72
|
-
UNSUPPORTED_MEDIA_TYPE: {
|
|
73
|
-
status: 415,
|
|
74
|
-
message: "Unsupported Media Type"
|
|
75
|
-
},
|
|
76
|
-
UNPROCESSABLE_CONTENT: {
|
|
77
|
-
status: 422,
|
|
78
|
-
message: "Unprocessable Content"
|
|
79
|
-
},
|
|
80
|
-
TOO_MANY_REQUESTS: {
|
|
81
|
-
status: 429,
|
|
82
|
-
message: "Too Many Requests"
|
|
83
|
-
},
|
|
84
|
-
CLIENT_CLOSED_REQUEST: {
|
|
85
|
-
status: 499,
|
|
86
|
-
message: "Client Closed Request"
|
|
87
|
-
},
|
|
88
|
-
INTERNAL_SERVER_ERROR: {
|
|
89
|
-
status: 500,
|
|
90
|
-
message: "Internal Server Error"
|
|
91
|
-
},
|
|
92
|
-
NOT_IMPLEMENTED: {
|
|
93
|
-
status: 501,
|
|
94
|
-
message: "Not Implemented"
|
|
95
|
-
},
|
|
96
|
-
BAD_GATEWAY: {
|
|
97
|
-
status: 502,
|
|
98
|
-
message: "Bad Gateway"
|
|
99
|
-
},
|
|
100
|
-
SERVICE_UNAVAILABLE: {
|
|
101
|
-
status: 503,
|
|
102
|
-
message: "Service Unavailable"
|
|
103
|
-
},
|
|
104
|
-
GATEWAY_TIMEOUT: {
|
|
105
|
-
status: 504,
|
|
106
|
-
message: "Gateway Timeout"
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
function fallbackORPCErrorStatus(code, status) {
|
|
110
|
-
return status ?? COMMON_ORPC_ERROR_DEFS[code]?.status ?? 500;
|
|
111
|
-
}
|
|
112
|
-
function fallbackORPCErrorMessage(code, message) {
|
|
113
|
-
return message || COMMON_ORPC_ERROR_DEFS[code]?.message || code;
|
|
114
|
-
}
|
|
115
|
-
const GLOBAL_ORPC_ERROR_CONSTRUCTORS_SYMBOL = Symbol.for(
|
|
116
|
-
`__${ORPC_CLIENT_PACKAGE_NAME}@${ORPC_CLIENT_PACKAGE_VERSION}/error/ORPC_ERROR_CONSTRUCTORS__`
|
|
117
|
-
);
|
|
118
|
-
void (globalThis[GLOBAL_ORPC_ERROR_CONSTRUCTORS_SYMBOL] ??= /* @__PURE__ */ new WeakSet());
|
|
119
|
-
const globalORPCErrorConstructors = globalThis[GLOBAL_ORPC_ERROR_CONSTRUCTORS_SYMBOL];
|
|
120
|
-
class ORPCError extends Error {
|
|
121
|
-
defined;
|
|
122
|
-
code;
|
|
123
|
-
status;
|
|
124
|
-
data;
|
|
125
|
-
constructor(code, ...rest) {
|
|
126
|
-
const options = resolveMaybeOptionalOptions$1(rest);
|
|
127
|
-
if (options.status !== void 0 && !isORPCErrorStatus(options.status)) {
|
|
128
|
-
throw new Error("[ORPCError] Invalid error status code.");
|
|
129
|
-
}
|
|
130
|
-
const message = fallbackORPCErrorMessage(code, options.message);
|
|
131
|
-
super(message, options);
|
|
132
|
-
this.code = code;
|
|
133
|
-
this.status = fallbackORPCErrorStatus(code, options.status);
|
|
134
|
-
this.defined = options.defined ?? false;
|
|
135
|
-
this.data = options.data;
|
|
136
|
-
}
|
|
137
|
-
toJSON() {
|
|
138
|
-
return {
|
|
139
|
-
defined: this.defined,
|
|
140
|
-
code: this.code,
|
|
141
|
-
status: this.status,
|
|
142
|
-
message: this.message,
|
|
143
|
-
data: this.data
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Workaround for Next.js where different contexts use separate
|
|
148
|
-
* dependency graphs, causing multiple ORPCError constructors existing and breaking
|
|
149
|
-
* `instanceof` checks across contexts.
|
|
150
|
-
*
|
|
151
|
-
* This is particularly problematic with "Optimized SSR", where orpc-client
|
|
152
|
-
* executes in one context but is invoked from another. When an error is thrown
|
|
153
|
-
* in the execution context, `instanceof ORPCError` checks fail in the
|
|
154
|
-
* invocation context due to separate class constructors.
|
|
155
|
-
*
|
|
156
|
-
* @todo Remove this and related code if Next.js resolves the multiple dependency graph issue.
|
|
157
|
-
*/
|
|
158
|
-
static [Symbol.hasInstance](instance) {
|
|
159
|
-
if (globalORPCErrorConstructors.has(this)) {
|
|
160
|
-
const constructor = getConstructor$1(instance);
|
|
161
|
-
if (constructor && globalORPCErrorConstructors.has(constructor)) {
|
|
162
|
-
return true;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return super[Symbol.hasInstance](instance);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
globalORPCErrorConstructors.add(ORPCError);
|
|
169
|
-
function isDefinedError(error) {
|
|
170
|
-
return error instanceof ORPCError && error.defined;
|
|
171
|
-
}
|
|
172
|
-
function toORPCError(error) {
|
|
173
|
-
return error instanceof ORPCError ? error : new ORPCError("INTERNAL_SERVER_ERROR", {
|
|
174
|
-
message: "Internal server error",
|
|
175
|
-
cause: error
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
function isORPCErrorStatus(status) {
|
|
179
|
-
return status < 200 || status >= 400;
|
|
180
|
-
}
|
|
181
|
-
function isORPCErrorJson(json) {
|
|
182
|
-
if (!isObject$1(json)) {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
const validKeys = ["defined", "code", "status", "message", "data"];
|
|
186
|
-
if (Object.keys(json).some((k) => !validKeys.includes(k))) {
|
|
187
|
-
return false;
|
|
188
|
-
}
|
|
189
|
-
return "defined" in json && typeof json.defined === "boolean" && "code" in json && typeof json.code === "string" && "status" in json && typeof json.status === "number" && isORPCErrorStatus(json.status) && "message" in json && typeof json.message === "string";
|
|
190
|
-
}
|
|
191
|
-
function createORPCErrorFromJson(json, options = {}) {
|
|
192
|
-
return new ORPCError(json.code, {
|
|
193
|
-
...options,
|
|
194
|
-
...json
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
28
|
class AbortError extends Error {
|
|
198
29
|
constructor(...rest) {
|
|
199
30
|
super(...rest);
|
|
@@ -817,4 +648,4 @@ function assertNever(value, message) {
|
|
|
817
648
|
throw new Error(message ?? `Unexpected value: ${value}`);
|
|
818
649
|
}
|
|
819
650
|
|
|
820
|
-
export { AbortError, AsyncIdQueue, AsyncIteratorClass,
|
|
651
|
+
export { AbortError, AsyncIdQueue, AsyncIteratorClass, EventPublisher, HTTPMethods, NullProtoObj, ORPC_NAME, ORPC_SHARED_PACKAGE_NAME, ORPC_SHARED_PACKAGE_VERSION, assertNever, asyncIteratorToStream, asyncIteratorWithSpan, clone, defer, fallbackContractConfig, findDeepMatches, get, getConstructor, getGlobalOtelConfig, isAsyncIteratorObject, isObject, isPropertyKey, isTypescriptObject, onError, onFinish, onStart, onSuccess, once, overlayProxy, parseEmptyableJSON, replicateAsyncIterator, resolveMaybeOptionalOptions, runInSpanContext, runWithSpan, sequential, setGlobalOtelConfig, setSpanAttribute, setSpanError, splitFirst, startSpan, streamToAsyncIteratorClass, stringifyJSON, toArray, toHttpPath, 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.fb7e3a67f82deaeffad5063e136b2f3c03c4b5b3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|