@temporary-name/server 1.9.3-alpha.205fb2d0874fa3b8bbf83112a63016937380442e → 1.9.3-alpha.25c9bb040aec8c367ea668ebd2fedbdb6ee024ff
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/adapters/aws-lambda/index.d.mts +2 -2
- package/dist/adapters/aws-lambda/index.d.ts +2 -2
- package/dist/adapters/aws-lambda/index.mjs +3 -3
- package/dist/adapters/fetch/index.d.mts +2 -2
- package/dist/adapters/fetch/index.d.ts +2 -2
- package/dist/adapters/fetch/index.mjs +3 -3
- package/dist/adapters/node/index.d.mts +2 -2
- package/dist/adapters/node/index.d.ts +2 -2
- package/dist/adapters/node/index.mjs +3 -3
- package/dist/handler/index.d.mts +2 -2
- package/dist/handler/index.d.ts +2 -2
- package/dist/handler/index.mjs +3 -3
- package/dist/index.d.mts +2 -3
- package/dist/index.d.ts +2 -3
- package/dist/index.mjs +9 -10
- package/dist/openapi/index.d.mts +1 -1
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.mjs +5 -5
- package/dist/shared/{server.BGG3eatg.mjs → server.0XttqWC4.mjs} +31 -7
- package/dist/shared/{server.X8F6e8eV.mjs → server.BT6UIZKq.mjs} +63 -130
- package/dist/shared/{server.Coz0LFSE.d.ts → server.CDPDcFfG.d.ts} +1 -1
- package/dist/shared/{server.CmNVzZVe.mjs → server.CqRXKroQ.mjs} +1 -1
- package/dist/shared/{server.BM9lK_Yv.mjs → server.gacqwfQ1.mjs} +1 -1
- package/dist/shared/{server.BxyeakF-.d.mts → server.pPvU6DyC.d.mts} +1 -1
- package/dist/shared/{server.B5ntjz_x.d.mts → server.yrTiAhAF.d.mts} +76 -361
- package/dist/shared/{server.B5ntjz_x.d.ts → server.yrTiAhAF.d.ts} +76 -361
- package/package.json +8 -8
|
@@ -10,12 +10,8 @@ class ValidationError extends Error {
|
|
|
10
10
|
this.data = options.data;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
class
|
|
13
|
+
class ApiError extends Error {
|
|
14
14
|
extra;
|
|
15
|
-
static extraSchema = {};
|
|
16
|
-
static status;
|
|
17
|
-
static type;
|
|
18
|
-
static staticDefaultMessage = void 0;
|
|
19
15
|
constructor(...args) {
|
|
20
16
|
const { message, cause, ...extra } = args[0] ?? {};
|
|
21
17
|
super(message, { cause });
|
|
@@ -23,7 +19,7 @@ class APIError extends Error {
|
|
|
23
19
|
this.extra = extra;
|
|
24
20
|
}
|
|
25
21
|
static get defaultMessage() {
|
|
26
|
-
return this.
|
|
22
|
+
return this.type.split("_").map((word) => word[0]?.toUpperCase() + word.slice(1)).join(" ");
|
|
27
23
|
}
|
|
28
24
|
toJSON() {
|
|
29
25
|
return {
|
|
@@ -33,150 +29,87 @@ class APIError extends Error {
|
|
|
33
29
|
};
|
|
34
30
|
}
|
|
35
31
|
}
|
|
36
|
-
class BadRequestError extends
|
|
32
|
+
class BadRequestError extends ApiError {
|
|
37
33
|
static status = 400;
|
|
38
34
|
static type = "bad_request";
|
|
39
35
|
static extraSchema = { code: z.string() };
|
|
40
36
|
}
|
|
41
|
-
class UnauthorizedError extends
|
|
37
|
+
class UnauthorizedError extends ApiError {
|
|
42
38
|
static status = 401;
|
|
43
39
|
static type = "unauthorized";
|
|
44
40
|
}
|
|
45
|
-
class ForbiddenError extends
|
|
41
|
+
class ForbiddenError extends ApiError {
|
|
46
42
|
static status = 403;
|
|
47
43
|
static type = "forbidden";
|
|
48
44
|
}
|
|
49
|
-
class NotFoundError extends
|
|
45
|
+
class NotFoundError extends ApiError {
|
|
50
46
|
static status = 404;
|
|
51
47
|
static type = "not_found";
|
|
52
48
|
}
|
|
53
|
-
class
|
|
49
|
+
class MethodNotAllowedError extends ApiError {
|
|
50
|
+
static status = 405;
|
|
51
|
+
static type = "method_not_allowed";
|
|
52
|
+
}
|
|
53
|
+
class NotAcceptableError extends ApiError {
|
|
54
|
+
static status = 406;
|
|
55
|
+
static type = "not_acceptable";
|
|
56
|
+
}
|
|
57
|
+
class RequestTimeoutError extends ApiError {
|
|
58
|
+
static status = 408;
|
|
59
|
+
static type = "request_timeout";
|
|
60
|
+
}
|
|
61
|
+
class ConflictError extends ApiError {
|
|
62
|
+
static status = 409;
|
|
63
|
+
static type = "conflict";
|
|
64
|
+
}
|
|
65
|
+
class PreconditionFailedError extends ApiError {
|
|
66
|
+
static status = 412;
|
|
67
|
+
static type = "precondition_failed";
|
|
68
|
+
}
|
|
69
|
+
class ContentTooLargeError extends ApiError {
|
|
70
|
+
static status = 413;
|
|
71
|
+
static type = "content_too_large";
|
|
72
|
+
}
|
|
73
|
+
class UnsupportedMediaTypeError extends ApiError {
|
|
74
|
+
static status = 415;
|
|
75
|
+
static type = "unsupported_media_type";
|
|
76
|
+
}
|
|
77
|
+
class UnprocessableContentError extends ApiError {
|
|
78
|
+
static status = 422;
|
|
79
|
+
static type = "unprocessable_content";
|
|
80
|
+
}
|
|
81
|
+
class TooManyRequestsError extends ApiError {
|
|
82
|
+
static status = 429;
|
|
83
|
+
static type = "too_many_requests";
|
|
84
|
+
}
|
|
85
|
+
class InternalServerError extends ApiError {
|
|
54
86
|
static status = 500;
|
|
55
87
|
static type = "internal_server_error";
|
|
56
88
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
static type = "request_timeout";
|
|
73
|
-
},
|
|
74
|
-
ConflictError: class ConflictError extends APIError {
|
|
75
|
-
static status = 409;
|
|
76
|
-
static type = "conflict";
|
|
77
|
-
},
|
|
78
|
-
PreconditionFailedError: class PreconditionFailedError extends APIError {
|
|
79
|
-
static status = 412;
|
|
80
|
-
static type = "precondition_failed";
|
|
81
|
-
},
|
|
82
|
-
ContentTooLargeError: class ContentTooLargeError extends APIError {
|
|
83
|
-
static status = 413;
|
|
84
|
-
static type = "content_too_large";
|
|
85
|
-
},
|
|
86
|
-
UnsupportedMediaTypeError: class UnsupportedMediaTypeError extends APIError {
|
|
87
|
-
static status = 415;
|
|
88
|
-
static type = "unsupported_media_type";
|
|
89
|
-
},
|
|
90
|
-
UnprocessableContentError: class UnprocessableContentError extends APIError {
|
|
91
|
-
static status = 422;
|
|
92
|
-
static type = "unprocessable_content";
|
|
93
|
-
},
|
|
94
|
-
TooManyRequestsError: class TooManyRequestsError extends APIError {
|
|
95
|
-
static status = 429;
|
|
96
|
-
static type = "too_many_requests";
|
|
97
|
-
},
|
|
98
|
-
InternalServerError,
|
|
99
|
-
NotImplementedError: class NotImplementedError extends APIError {
|
|
100
|
-
static status = 501;
|
|
101
|
-
static type = "not_implemented";
|
|
102
|
-
},
|
|
103
|
-
BadGatewayError: class BadGatewayError extends APIError {
|
|
104
|
-
static status = 502;
|
|
105
|
-
static type = "bad_gateway";
|
|
106
|
-
},
|
|
107
|
-
ServiceUnavailableError: class ServiceUnavailableError extends APIError {
|
|
108
|
-
static status = 503;
|
|
109
|
-
static type = "service_unavailable";
|
|
110
|
-
},
|
|
111
|
-
GatewayTimeoutError: class GatewayTimeoutError extends APIError {
|
|
112
|
-
static status = 504;
|
|
113
|
-
static type = "gateway_timeout";
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
function errorsConfig(errorsConfig2) {
|
|
117
|
-
return errorsConfig2;
|
|
118
|
-
}
|
|
119
|
-
const DEFAULT_ERRORS_CONFIG = errorsConfig({
|
|
120
|
-
BadRequestError: { extraFields: { code: z.string() } },
|
|
121
|
-
UnauthorizedError: true,
|
|
122
|
-
ForbiddenError: true,
|
|
123
|
-
NotFoundError: true,
|
|
124
|
-
InternalServerError: true
|
|
125
|
-
});
|
|
126
|
-
function makeErrors(config) {
|
|
127
|
-
const configWithDefaults = { ...DEFAULT_ERRORS_CONFIG, ...config };
|
|
128
|
-
const errors = {};
|
|
129
|
-
for (const [key, value] of Object.entries(configWithDefaults)) {
|
|
130
|
-
if (key in COMMON_ERRORS) {
|
|
131
|
-
const errorClass = COMMON_ERRORS[key];
|
|
132
|
-
if (value === true) {
|
|
133
|
-
errors[key] = errorClass;
|
|
134
|
-
} else if (typeof value === "object") {
|
|
135
|
-
if ("status" in value || "type" in value || "defaultMessage" in value) {
|
|
136
|
-
throw new Error(
|
|
137
|
-
`Invalid error config for ${key}: cannot use custom status, type, or defaultMessage for pre-defined error class. Use a different name or remove these keys.`
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
const extraSchema = value.extraFields;
|
|
141
|
-
const childErrorClass = class extends errorClass {
|
|
142
|
-
static extraSchema = { ...errorClass.extraSchema, ...extraSchema };
|
|
143
|
-
};
|
|
144
|
-
Object.defineProperty(childErrorClass, "name", { value: key });
|
|
145
|
-
errors[key] = childErrorClass;
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
if (typeof value === "boolean") {
|
|
149
|
-
throw new Error(
|
|
150
|
-
`Unknown error class ${key}: custom error classes should be defined as a class, not a boolean`
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
if (!("status" in value) || !("type" in value)) {
|
|
154
|
-
throw new Error(
|
|
155
|
-
`Invalid error config for ${key}: custom error classes must have a "status" and "type" property`
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
const { status, type, defaultMessage, extraFields } = value;
|
|
159
|
-
const childErrorClass = class extends APIError {
|
|
160
|
-
static status = status;
|
|
161
|
-
static type = type;
|
|
162
|
-
static staticDefaultMessage = defaultMessage;
|
|
163
|
-
static extraSchema = extraFields ?? {};
|
|
164
|
-
};
|
|
165
|
-
Object.defineProperty(childErrorClass, "name", { value: key });
|
|
166
|
-
errors[key] = childErrorClass;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return errors;
|
|
89
|
+
class NotImplementedError extends ApiError {
|
|
90
|
+
static status = 501;
|
|
91
|
+
static type = "not_implemented";
|
|
92
|
+
}
|
|
93
|
+
class BadGatewayError extends ApiError {
|
|
94
|
+
static status = 502;
|
|
95
|
+
static type = "bad_gateway";
|
|
96
|
+
}
|
|
97
|
+
class ServiceUnavailableError extends ApiError {
|
|
98
|
+
static status = 503;
|
|
99
|
+
static type = "service_unavailable";
|
|
100
|
+
}
|
|
101
|
+
class GatewayTimeoutError extends ApiError {
|
|
102
|
+
static status = 504;
|
|
103
|
+
static type = "gateway_timeout";
|
|
170
104
|
}
|
|
171
|
-
function
|
|
105
|
+
function isApiErrorStatus(status) {
|
|
172
106
|
return status < 200 || status >= 400;
|
|
173
107
|
}
|
|
174
|
-
function
|
|
175
|
-
if (error instanceof
|
|
108
|
+
function toApiError(error) {
|
|
109
|
+
if (error instanceof ApiError) {
|
|
176
110
|
return error;
|
|
177
111
|
}
|
|
178
112
|
return new InternalServerError({
|
|
179
|
-
message: error instanceof Error ? error.message : void 0,
|
|
180
113
|
cause: error
|
|
181
114
|
});
|
|
182
115
|
}
|
|
@@ -184,7 +117,7 @@ function encodeError(error) {
|
|
|
184
117
|
return {
|
|
185
118
|
status: error.constructor.status,
|
|
186
119
|
headers: new Headers(),
|
|
187
|
-
body: error.toJSON()
|
|
120
|
+
body: { error: error.toJSON() }
|
|
188
121
|
};
|
|
189
122
|
}
|
|
190
123
|
|
|
@@ -496,4 +429,4 @@ function parseEndpointDefinition(stringsOrEndpoint, values) {
|
|
|
496
429
|
return { method, path, pathSchema };
|
|
497
430
|
}
|
|
498
431
|
|
|
499
|
-
export {
|
|
432
|
+
export { ApiError as A, BadRequestError as B, Contract as C, isLazy as D, isStartWithMiddlewares as E, ForbiddenError as F, GatewayTimeoutError as G, mergeMiddlewares as H, InternalServerError as I, getRouter as J, createAccessibleLazyRouter as K, LAZY_SYMBOL as L, MethodNotAllowedError as M, NotFoundError as N, traverseContractProcedures as O, Procedure as P, unlazyRouter as Q, RequestTimeoutError as R, ServiceUnavailableError as S, TooManyRequestsError as T, UnauthorizedError as U, ValidationError as V, endpointRegex as W, isDevelopment as X, mergeTags as a, enhanceRouter as b, mergeRoute as c, prefixRoute as d, encodeError as e, addMiddleware as f, getDynamicParams as g, getLazyMeta as h, isApiErrorStatus as i, isProcedure as j, NotAcceptableError as k, lazyInternal as l, mergePrefix as m, ConflictError as n, PreconditionFailedError as o, parseEndpointDefinition as p, ContentTooLargeError as q, resolveContractProcedures as r, standardizeHTTPPath as s, toApiError as t, unlazy as u, UnsupportedMediaTypeError as v, UnprocessableContentError as w, NotImplementedError as x, BadGatewayError as y, lazy as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HTTPPath, StandardResponse, StandardLazyRequest } from '@temporary-name/shared';
|
|
2
|
-
import { C as Context, m as Router } from './server.
|
|
2
|
+
import { C as Context, m as Router } from './server.yrTiAhAF.js';
|
|
3
3
|
|
|
4
4
|
interface StandardHandleOptions<T extends Context> {
|
|
5
5
|
prefix?: HTTPPath;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolveMaybeOptionalOptions, toArray, value, runWithSpan, isAsyncIteratorObject, overlayProxy, asyncIteratorWithSpan } from '@temporary-name/shared';
|
|
2
2
|
import { HibernationEventIterator, mapEventIterator } from '@temporary-name/standard-server';
|
|
3
3
|
import { safeDecodeAsync, safeEncodeAsync } from '@temporary-name/zod';
|
|
4
|
-
import { u as unlazy, B as BadRequestError, V as ValidationError, I as InternalServerError } from './server.
|
|
4
|
+
import { u as unlazy, B as BadRequestError, V as ValidationError, I as InternalServerError } from './server.BT6UIZKq.mjs';
|
|
5
5
|
|
|
6
6
|
function mergeCurrentContext(context, other) {
|
|
7
7
|
return { ...context, ...other };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isAsyncIteratorObject, toArray } from '@temporary-name/shared';
|
|
2
2
|
import { mapEventIterator } from '@temporary-name/standard-server';
|
|
3
3
|
import { custom, safeParseAsync } from '@temporary-name/zod';
|
|
4
|
-
import { V as ValidationError } from './server.
|
|
4
|
+
import { V as ValidationError } from './server.BT6UIZKq.mjs';
|
|
5
5
|
import { JSONSchemaFormat, JSONSchemaContentEncoding } from '@temporary-name/server/openapi';
|
|
6
6
|
import { registry, globalRegistry } from 'zod/v4/core';
|
|
7
7
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HTTPPath, StandardResponse, StandardLazyRequest } from '@temporary-name/shared';
|
|
2
|
-
import { C as Context, m as Router } from './server.
|
|
2
|
+
import { C as Context, m as Router } from './server.yrTiAhAF.mjs';
|
|
3
3
|
|
|
4
4
|
interface StandardHandleOptions<T extends Context> {
|
|
5
5
|
prefix?: HTTPPath;
|