silgi 0.4.11 → 0.5.0
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/_chunks/index.mjs +1 -1
- package/dist/cli/prepare.mjs +9 -3
- package/dist/core/index.d.mts +185 -38
- package/dist/core/index.d.ts +185 -38
- package/dist/core/index.mjs +314 -108
- package/dist/kit/index.d.mts +6 -3
- package/dist/kit/index.d.ts +6 -3
- package/dist/kit/index.mjs +24 -1
- package/dist/meta/index.d.mts +1 -1
- package/dist/meta/index.d.ts +1 -1
- package/dist/presets/_types.gen.d.ts +1 -1
- package/dist/runtime/internal/nitro.mjs +46 -35
- package/dist/runtime/internal/nuxt.d.ts +4 -4
- package/dist/shared/{silgi.yr8vHHvd.d.ts → silgi.CN_giHTc.d.mts} +67 -267
- package/dist/shared/{silgi.DQSwjP5u.d.mts → silgi.CN_giHTc.d.ts} +67 -267
- package/dist/shared/{silgi.40ZJYm8F.d.mts → silgi.DGmIWx95.d.mts} +2 -2
- package/dist/shared/{silgi.40ZJYm8F.d.ts → silgi.DGmIWx95.d.ts} +2 -2
- package/dist/types/index.d.mts +196 -9
- package/dist/types/index.d.ts +196 -9
- package/package.json +1 -1
package/dist/_chunks/index.mjs
CHANGED
package/dist/cli/prepare.mjs
CHANGED
|
@@ -250,11 +250,12 @@ async function generateRouterDTS(silgi) {
|
|
|
250
250
|
silgi.hook("close", async () => {
|
|
251
251
|
const { object } = await data();
|
|
252
252
|
const uris = object.uris;
|
|
253
|
+
const subPath = "srn";
|
|
253
254
|
const groupedPaths = /* @__PURE__ */ new Map();
|
|
254
255
|
Object.entries(uris || {}).forEach(([key, params]) => {
|
|
255
256
|
const [service, resource, method, action] = key.split("/");
|
|
256
|
-
const basePath = params ? `${service}/${resource}/${action}/${params}` : `${service}/${resource}/${action}`;
|
|
257
|
-
const fullPath = `${service}/${resource}/${action}`;
|
|
257
|
+
const basePath = params ? `${subPath}/${service}/${resource}/${action}/${params}` : `${subPath}/${service}/${resource}/${action}`;
|
|
258
|
+
const fullPath = `${subPath}/${service}/${resource}/${action}`;
|
|
258
259
|
if (!groupedPaths.has(basePath)) {
|
|
259
260
|
groupedPaths.set(basePath, /* @__PURE__ */ new Map());
|
|
260
261
|
}
|
|
@@ -272,7 +273,7 @@ async function generateRouterDTS(silgi) {
|
|
|
272
273
|
].join("\n");
|
|
273
274
|
const groupedRoutes = Object.entries(uris || {}).reduce((acc, [key, _params]) => {
|
|
274
275
|
const [service, resource, method, action] = key.split("/");
|
|
275
|
-
const routePath = `${service}/${resource}/${action}`;
|
|
276
|
+
const routePath = `${subPath}/${service}/${resource}/${action}`;
|
|
276
277
|
if (!acc[routePath]) {
|
|
277
278
|
acc[routePath] = {};
|
|
278
279
|
}
|
|
@@ -614,6 +615,7 @@ async function silgiCoreFile(data, frameworkContext, silgi) {
|
|
|
614
615
|
"",
|
|
615
616
|
"",
|
|
616
617
|
"export async function buildSilgi(framework: FrameworkContext, options?: Partial<SilgiModuleOptions>) {",
|
|
618
|
+
" try {",
|
|
617
619
|
" const silgi = await createSilgi({",
|
|
618
620
|
" framework,",
|
|
619
621
|
" shared: shareds as any,",
|
|
@@ -624,6 +626,7 @@ async function silgiCoreFile(data, frameworkContext, silgi) {
|
|
|
624
626
|
` plugins: [${plugins.join(", ")}],`,
|
|
625
627
|
"",
|
|
626
628
|
" options: {",
|
|
629
|
+
` present: '${silgi.options.preset}',`,
|
|
627
630
|
" ...options,",
|
|
628
631
|
" },",
|
|
629
632
|
" })",
|
|
@@ -633,6 +636,9 @@ async function silgiCoreFile(data, frameworkContext, silgi) {
|
|
|
633
636
|
...buildSilgiExtraContent,
|
|
634
637
|
"",
|
|
635
638
|
" return silgi",
|
|
639
|
+
" } catch (error) {",
|
|
640
|
+
" throw new Error(error.message)",
|
|
641
|
+
" }",
|
|
636
642
|
"}",
|
|
637
643
|
""
|
|
638
644
|
];
|
package/dist/core/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SilgiCLIConfig, LoadConfigOptions, SilgiCLIOptions, SilgiCLI, SilgiConfig, Silgi, SilgiRouterTypes, SilgiOperation, MergedSilgiSchema, ServiceType, SilgiSchema, RequiredServiceType, SilgiModuleShared, SilgiEvent, DefaultNamespaces, BaseSchemaType } from 'silgi/types';
|
|
2
2
|
import { TSConfig } from 'pkg-types';
|
|
3
3
|
import { FetchOptions } from 'ofetch';
|
|
4
|
-
export { c as createStorage, s as silgi } from '../shared/silgi.
|
|
4
|
+
export { c as createStorage, s as silgi } from '../shared/silgi.DGmIWx95.mjs';
|
|
5
5
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
6
6
|
import 'unstorage';
|
|
7
7
|
|
|
@@ -14,7 +14,7 @@ declare function silgiGenerateType(silgi: SilgiCLI): Promise<{
|
|
|
14
14
|
|
|
15
15
|
declare function createSilgi(config: SilgiConfig): Promise<Silgi>;
|
|
16
16
|
|
|
17
|
-
type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer _}` ? `/${S1}/${S2}/${S3}` : T;
|
|
17
|
+
type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer S4}/${infer _}` ? `/${S1}/${S2}/${S3}/${S4}` : T;
|
|
18
18
|
type AllPaths = SilgiRouterTypes extends {
|
|
19
19
|
keys: infer U;
|
|
20
20
|
} ? keyof U extends never ? string : keyof U : string;
|
|
@@ -37,7 +37,7 @@ type RouterParams<R extends ValidRoute> = ExtractPathParams<R>;
|
|
|
37
37
|
type SilgiFetchOptions<R extends ValidRoute, M extends Method<R>> = {
|
|
38
38
|
method: M;
|
|
39
39
|
} & RequestBodyOption<R, M> & (RouterParams<R> extends object ? {
|
|
40
|
-
params
|
|
40
|
+
params?: RouterParams<R>;
|
|
41
41
|
} : {
|
|
42
42
|
params?: never;
|
|
43
43
|
}) & Omit<FetchOptions, 'query' | 'body' | 'method'>;
|
|
@@ -98,47 +98,194 @@ declare function createService<T extends SilgiSchema>(variables: ServiceType<T>)
|
|
|
98
98
|
|
|
99
99
|
declare function createShared(shared: Partial<SilgiModuleShared>): SilgiModuleShared;
|
|
100
100
|
|
|
101
|
-
declare enum
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
101
|
+
declare enum HttpStatus {
|
|
102
|
+
/** [100] Server has received the request headers and client should proceed to send the request body */
|
|
103
|
+
CONTINUE = 100,
|
|
104
|
+
/** [101] Server is switching protocols according to Upgrade header */
|
|
105
|
+
SWITCHING_PROTOCOLS = 101,
|
|
106
|
+
/** [102] Server is processing the request but no response is available yet */
|
|
107
|
+
PROCESSING = 102,
|
|
108
|
+
/** [103] Server is likely to send a final response with the header fields in the informational response */
|
|
109
|
+
EARLY_HINTS = 103,
|
|
110
|
+
/** [200] Request succeeded and response contains requested data */
|
|
111
|
+
OK = 200,
|
|
112
|
+
/** [201] Request succeeded and new resource has been created */
|
|
113
|
+
CREATED = 201,
|
|
114
|
+
/** [202] Request accepted for processing but processing not completed */
|
|
115
|
+
ACCEPTED = 202,
|
|
116
|
+
/** [203] Request processed successfully but response may be from another source */
|
|
117
|
+
NON_AUTHORITATIVE_INFORMATION = 203,
|
|
118
|
+
/** [204] Request processed successfully but response has no content */
|
|
119
|
+
NO_CONTENT = 204,
|
|
120
|
+
/** [205] Server fulfilled the request and client should reset the document view */
|
|
121
|
+
RESET_CONTENT = 205,
|
|
122
|
+
/** [206] Server delivered only part of the resource due to range header */
|
|
123
|
+
PARTIAL_CONTENT = 206,
|
|
124
|
+
/** [207] Response conveys information about multiple resources for XML messages */
|
|
125
|
+
MULTI_STATUS = 207,
|
|
126
|
+
/** [208] Members of DAV binding have already been enumerated and not included again */
|
|
127
|
+
ALREADY_REPORTED = 208,
|
|
128
|
+
/** [226] Server has fulfilled a GET request, response is result of transformations */
|
|
129
|
+
IM_USED = 226,
|
|
130
|
+
/** [300] Multiple options for the resource from which client may choose */
|
|
131
|
+
MULTIPLE_CHOICES = 300,
|
|
132
|
+
/** [301] Resource permanently moved to new URL */
|
|
133
|
+
MOVED_PERMANENTLY = 301,
|
|
134
|
+
/** [302] Resource temporarily moved to different URL */
|
|
135
|
+
FOUND = 302,
|
|
136
|
+
/** [303] Response to request found at another URL using GET */
|
|
137
|
+
SEE_OTHER = 303,
|
|
138
|
+
/** [304] Resource has not been modified since last requested */
|
|
139
|
+
NOT_MODIFIED = 304,
|
|
140
|
+
/** [305] Deprecated. Resource must be accessed through proxy */
|
|
141
|
+
USE_PROXY = 305,
|
|
142
|
+
/** [307] Resource temporarily moved to different URL, keep method */
|
|
143
|
+
TEMPORARY_REDIRECT = 307,
|
|
144
|
+
/** [308] Resource permanently moved to different URL, keep method */
|
|
145
|
+
PERMANENT_REDIRECT = 308,
|
|
146
|
+
/** [400] Request malformed, syntax error or invalid request */
|
|
147
|
+
BAD_REQUEST = 400,
|
|
148
|
+
/** [401] Request requires user authentication or authorization */
|
|
149
|
+
UNAUTHORIZED = 401,
|
|
150
|
+
/** [402] Reserved for future use, payment required */
|
|
151
|
+
PAYMENT_REQUIRED = 402,
|
|
152
|
+
/** [403] Server understood request but refuses to authorize it */
|
|
153
|
+
FORBIDDEN = 403,
|
|
154
|
+
/** [404] Server cannot find the requested resource */
|
|
155
|
+
NOT_FOUND = 404,
|
|
156
|
+
/** [405] Request method (GET, POST, etc.) not supported for this resource */
|
|
157
|
+
METHOD_NOT_ALLOWED = 405,
|
|
158
|
+
/** [406] Resource cannot generate response matching accept headers */
|
|
159
|
+
NOT_ACCEPTABLE = 406,
|
|
160
|
+
/** [407] Client must first authenticate with the proxy */
|
|
161
|
+
PROXY_AUTHENTICATION_REQUIRED = 407,
|
|
162
|
+
/** [408] Server timed out waiting for the request */
|
|
163
|
+
REQUEST_TIMEOUT = 408,
|
|
164
|
+
/** [409] Request conflicts with current state of the server */
|
|
165
|
+
CONFLICT = 409,
|
|
166
|
+
/** [410] Resource requested is no longer available and will not be available again */
|
|
167
|
+
GONE = 410,
|
|
168
|
+
/** [411] Server requires Content-Length header field */
|
|
169
|
+
LENGTH_REQUIRED = 411,
|
|
170
|
+
/** [412] Precondition given in request headers evaluated to false */
|
|
171
|
+
PRECONDITION_FAILED = 412,
|
|
172
|
+
/** [413] Request entity larger than limits defined by server */
|
|
173
|
+
PAYLOAD_TOO_LARGE = 413,
|
|
174
|
+
/** [414] URI requested by client is longer than server can interpret */
|
|
175
|
+
URI_TOO_LONG = 414,
|
|
176
|
+
/** [415] Media format of requested data not supported by server */
|
|
177
|
+
UNSUPPORTED_MEDIA_TYPE = 415,
|
|
178
|
+
/** [416] Range specified by Range header cannot be fulfilled */
|
|
179
|
+
RANGE_NOT_SATISFIABLE = 416,
|
|
180
|
+
/** [417] Expectation indicated by Expect header cannot be met */
|
|
181
|
+
EXPECTATION_FAILED = 417,
|
|
182
|
+
/** [418] April Fools' joke by RFC 2324 - Server refuses to brew coffee in a teapot */
|
|
183
|
+
IM_A_TEAPOT = 418,
|
|
184
|
+
/** [421] Request directed at a server that is not configured to produce a response */
|
|
185
|
+
MISDIRECTED_REQUEST = 421,
|
|
186
|
+
/** [422] Server understands content type but cannot process contained instructions */
|
|
187
|
+
UNPROCESSABLE_ENTITY = 422,
|
|
188
|
+
/** [423] Requested resource is currently locked */
|
|
189
|
+
LOCKED = 423,
|
|
190
|
+
/** [424] Request failed due to failure of a previous request */
|
|
191
|
+
FAILED_DEPENDENCY = 424,
|
|
192
|
+
/** [425] Server is unwilling to risk processing a request that might be replayed */
|
|
193
|
+
TOO_EARLY = 425,
|
|
194
|
+
/** [426] Server requires client to upgrade to a different protocol */
|
|
195
|
+
UPGRADE_REQUIRED = 426,
|
|
196
|
+
/** [428] Origin server requires request to be conditional */
|
|
197
|
+
PRECONDITION_REQUIRED = 428,
|
|
198
|
+
/** [429] User has sent too many requests in a given time period */
|
|
199
|
+
TOO_MANY_REQUESTS = 429,
|
|
200
|
+
/** [431] Server refusing to process request due to oversized headers */
|
|
201
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
|
|
202
|
+
/** [451] Server denies access for legal reasons (e.g., censorship) */
|
|
203
|
+
UNAVAILABLE_FOR_LEGAL_REASONS = 451,
|
|
204
|
+
/** [500] Generic server error, no specific message */
|
|
205
|
+
INTERNAL_SERVER_ERROR = 500,
|
|
206
|
+
/** [501] Server does not recognize method or lacks ability to fulfill */
|
|
207
|
+
NOT_IMPLEMENTED = 501,
|
|
208
|
+
/** [502] Bad response received from upstream server */
|
|
209
|
+
BAD_GATEWAY = 502,
|
|
210
|
+
/** [503] Server temporarily unavailable (overloaded/maintenance) */
|
|
211
|
+
SERVICE_UNAVAILABLE = 503,
|
|
212
|
+
/** [504] Gateway server did not get response from upstream server */
|
|
213
|
+
GATEWAY_TIMEOUT = 504,
|
|
214
|
+
/** [505] Server does not support the HTTP protocol version */
|
|
215
|
+
HTTP_VERSION_NOT_SUPPORTED = 505,
|
|
216
|
+
/** [506] Server has a circular reference in content negotiation */
|
|
217
|
+
VARIANT_ALSO_NEGOTIATES = 506,
|
|
218
|
+
/** [507] Server has insufficient storage to complete request */
|
|
219
|
+
INSUFFICIENT_STORAGE = 507,
|
|
220
|
+
/** [508] Server detected an infinite loop while processing request */
|
|
221
|
+
LOOP_DETECTED = 508,
|
|
222
|
+
/** [510] Further extensions needed for server to fulfill request */
|
|
223
|
+
NOT_EXTENDED = 510,
|
|
224
|
+
/** [511] Client needs to authenticate to gain network access */
|
|
225
|
+
NETWORK_AUTHENTICATION_REQUIRED = 511
|
|
113
226
|
}
|
|
114
|
-
|
|
115
|
-
|
|
227
|
+
declare enum ErrorSeverity {
|
|
228
|
+
DEBUG = "DEBUG",
|
|
229
|
+
INFO = "INFO",
|
|
230
|
+
WARNING = "WARNING",
|
|
231
|
+
ERROR = "ERROR",
|
|
232
|
+
CRITICAL = "CRITICAL"
|
|
233
|
+
}
|
|
234
|
+
declare enum ErrorCategory {
|
|
235
|
+
AUTHENTICATION = "auth",
|
|
236
|
+
AUTHORIZATION = "authorization",
|
|
237
|
+
VALIDATION = "validation",
|
|
238
|
+
BUSINESS = "business",
|
|
239
|
+
INFRASTRUCTURE = "infrastructure",
|
|
240
|
+
EXTERNAL = "external",
|
|
241
|
+
UNKNOWN = "unknown"
|
|
242
|
+
}
|
|
243
|
+
interface ErrorMetadata {
|
|
244
|
+
timestamp: number;
|
|
245
|
+
correlationId?: string;
|
|
246
|
+
requestId?: string;
|
|
247
|
+
userId?: string;
|
|
248
|
+
path?: string;
|
|
249
|
+
source?: string;
|
|
250
|
+
[key: string]: unknown;
|
|
251
|
+
}
|
|
252
|
+
interface BaseError {
|
|
253
|
+
code: number;
|
|
116
254
|
message: string;
|
|
255
|
+
category: ErrorCategory;
|
|
256
|
+
severity: ErrorSeverity;
|
|
257
|
+
httpStatus: HttpStatus;
|
|
258
|
+
metadata?: ErrorMetadata;
|
|
117
259
|
cause?: Error;
|
|
118
|
-
|
|
119
|
-
meta?: Record<string, unknown>;
|
|
260
|
+
context?: Record<string, unknown>;
|
|
120
261
|
}
|
|
121
|
-
declare class
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
readonly meta?: Record<string, unknown>;
|
|
125
|
-
readonly timestamp: number;
|
|
126
|
-
cause?: Error;
|
|
127
|
-
constructor(options: SilgiErrorOptions);
|
|
128
|
-
toString(): string;
|
|
129
|
-
toJSON(): {
|
|
130
|
-
name: string;
|
|
131
|
-
code: string;
|
|
262
|
+
declare class ErrorFactory {
|
|
263
|
+
private static createMetadata;
|
|
264
|
+
static create(options: Partial<BaseError> & {
|
|
132
265
|
message: string;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
static
|
|
139
|
-
|
|
266
|
+
}): SilgiError;
|
|
267
|
+
static authenticationError(message: string, context?: Record<string, unknown>): SilgiError;
|
|
268
|
+
static authorizationError(message: string, context?: Record<string, unknown>): SilgiError;
|
|
269
|
+
static validationError(message: string, context?: Record<string, unknown>): SilgiError;
|
|
270
|
+
static notFoundError(message: string, context?: Record<string, unknown>): SilgiError;
|
|
271
|
+
static internalError(message: string, cause?: Error): SilgiError;
|
|
272
|
+
}
|
|
273
|
+
declare class SilgiError extends Error implements BaseError {
|
|
274
|
+
readonly code: number;
|
|
275
|
+
readonly category: ErrorCategory;
|
|
276
|
+
readonly severity: ErrorSeverity;
|
|
277
|
+
readonly httpStatus: HttpStatus;
|
|
278
|
+
readonly metadata: ErrorMetadata;
|
|
279
|
+
readonly context?: Record<string, unknown>;
|
|
280
|
+
readonly cause?: Error;
|
|
281
|
+
constructor(error: BaseError);
|
|
282
|
+
toString(): string;
|
|
283
|
+
toJSON(): Record<string, unknown>;
|
|
284
|
+
static isError(error: unknown): error is SilgiError;
|
|
285
|
+
static from(error: unknown): SilgiError;
|
|
140
286
|
}
|
|
287
|
+
declare function isBaseError(error: unknown): error is BaseError;
|
|
141
288
|
|
|
142
289
|
declare function useSilgi(): Silgi;
|
|
143
290
|
|
|
144
|
-
export { SchemaParser, SilgiError, createSchema, createService, createShared, createSilgi, createSilgiFetch, getEvent, loadOptions, mergeSchemas, mergeServices, mergeShared, parseURI, silgiGenerateType, useSilgi };
|
|
291
|
+
export { type BaseError, ErrorCategory, ErrorFactory, type ErrorMetadata, ErrorSeverity, HttpStatus, SchemaParser, SilgiError, createSchema, createService, createShared, createSilgi, createSilgiFetch, getEvent, isBaseError, loadOptions, mergeSchemas, mergeServices, mergeShared, parseURI, silgiGenerateType, useSilgi };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SilgiCLIConfig, LoadConfigOptions, SilgiCLIOptions, SilgiCLI, SilgiConfig, Silgi, SilgiRouterTypes, SilgiOperation, MergedSilgiSchema, ServiceType, SilgiSchema, RequiredServiceType, SilgiModuleShared, SilgiEvent, DefaultNamespaces, BaseSchemaType } from 'silgi/types';
|
|
2
2
|
import { TSConfig } from 'pkg-types';
|
|
3
3
|
import { FetchOptions } from 'ofetch';
|
|
4
|
-
export { c as createStorage, s as silgi } from '../shared/silgi.
|
|
4
|
+
export { c as createStorage, s as silgi } from '../shared/silgi.DGmIWx95.js';
|
|
5
5
|
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
6
6
|
import 'unstorage';
|
|
7
7
|
|
|
@@ -14,7 +14,7 @@ declare function silgiGenerateType(silgi: SilgiCLI): Promise<{
|
|
|
14
14
|
|
|
15
15
|
declare function createSilgi(config: SilgiConfig): Promise<Silgi>;
|
|
16
16
|
|
|
17
|
-
type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer _}` ? `/${S1}/${S2}/${S3}` : T;
|
|
17
|
+
type TrimAfterFourSlashes<T extends string> = T extends `/${infer S1}/${infer S2}/${infer S3}/${infer S4}/${infer _}` ? `/${S1}/${S2}/${S3}/${S4}` : T;
|
|
18
18
|
type AllPaths = SilgiRouterTypes extends {
|
|
19
19
|
keys: infer U;
|
|
20
20
|
} ? keyof U extends never ? string : keyof U : string;
|
|
@@ -37,7 +37,7 @@ type RouterParams<R extends ValidRoute> = ExtractPathParams<R>;
|
|
|
37
37
|
type SilgiFetchOptions<R extends ValidRoute, M extends Method<R>> = {
|
|
38
38
|
method: M;
|
|
39
39
|
} & RequestBodyOption<R, M> & (RouterParams<R> extends object ? {
|
|
40
|
-
params
|
|
40
|
+
params?: RouterParams<R>;
|
|
41
41
|
} : {
|
|
42
42
|
params?: never;
|
|
43
43
|
}) & Omit<FetchOptions, 'query' | 'body' | 'method'>;
|
|
@@ -98,47 +98,194 @@ declare function createService<T extends SilgiSchema>(variables: ServiceType<T>)
|
|
|
98
98
|
|
|
99
99
|
declare function createShared(shared: Partial<SilgiModuleShared>): SilgiModuleShared;
|
|
100
100
|
|
|
101
|
-
declare enum
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
101
|
+
declare enum HttpStatus {
|
|
102
|
+
/** [100] Server has received the request headers and client should proceed to send the request body */
|
|
103
|
+
CONTINUE = 100,
|
|
104
|
+
/** [101] Server is switching protocols according to Upgrade header */
|
|
105
|
+
SWITCHING_PROTOCOLS = 101,
|
|
106
|
+
/** [102] Server is processing the request but no response is available yet */
|
|
107
|
+
PROCESSING = 102,
|
|
108
|
+
/** [103] Server is likely to send a final response with the header fields in the informational response */
|
|
109
|
+
EARLY_HINTS = 103,
|
|
110
|
+
/** [200] Request succeeded and response contains requested data */
|
|
111
|
+
OK = 200,
|
|
112
|
+
/** [201] Request succeeded and new resource has been created */
|
|
113
|
+
CREATED = 201,
|
|
114
|
+
/** [202] Request accepted for processing but processing not completed */
|
|
115
|
+
ACCEPTED = 202,
|
|
116
|
+
/** [203] Request processed successfully but response may be from another source */
|
|
117
|
+
NON_AUTHORITATIVE_INFORMATION = 203,
|
|
118
|
+
/** [204] Request processed successfully but response has no content */
|
|
119
|
+
NO_CONTENT = 204,
|
|
120
|
+
/** [205] Server fulfilled the request and client should reset the document view */
|
|
121
|
+
RESET_CONTENT = 205,
|
|
122
|
+
/** [206] Server delivered only part of the resource due to range header */
|
|
123
|
+
PARTIAL_CONTENT = 206,
|
|
124
|
+
/** [207] Response conveys information about multiple resources for XML messages */
|
|
125
|
+
MULTI_STATUS = 207,
|
|
126
|
+
/** [208] Members of DAV binding have already been enumerated and not included again */
|
|
127
|
+
ALREADY_REPORTED = 208,
|
|
128
|
+
/** [226] Server has fulfilled a GET request, response is result of transformations */
|
|
129
|
+
IM_USED = 226,
|
|
130
|
+
/** [300] Multiple options for the resource from which client may choose */
|
|
131
|
+
MULTIPLE_CHOICES = 300,
|
|
132
|
+
/** [301] Resource permanently moved to new URL */
|
|
133
|
+
MOVED_PERMANENTLY = 301,
|
|
134
|
+
/** [302] Resource temporarily moved to different URL */
|
|
135
|
+
FOUND = 302,
|
|
136
|
+
/** [303] Response to request found at another URL using GET */
|
|
137
|
+
SEE_OTHER = 303,
|
|
138
|
+
/** [304] Resource has not been modified since last requested */
|
|
139
|
+
NOT_MODIFIED = 304,
|
|
140
|
+
/** [305] Deprecated. Resource must be accessed through proxy */
|
|
141
|
+
USE_PROXY = 305,
|
|
142
|
+
/** [307] Resource temporarily moved to different URL, keep method */
|
|
143
|
+
TEMPORARY_REDIRECT = 307,
|
|
144
|
+
/** [308] Resource permanently moved to different URL, keep method */
|
|
145
|
+
PERMANENT_REDIRECT = 308,
|
|
146
|
+
/** [400] Request malformed, syntax error or invalid request */
|
|
147
|
+
BAD_REQUEST = 400,
|
|
148
|
+
/** [401] Request requires user authentication or authorization */
|
|
149
|
+
UNAUTHORIZED = 401,
|
|
150
|
+
/** [402] Reserved for future use, payment required */
|
|
151
|
+
PAYMENT_REQUIRED = 402,
|
|
152
|
+
/** [403] Server understood request but refuses to authorize it */
|
|
153
|
+
FORBIDDEN = 403,
|
|
154
|
+
/** [404] Server cannot find the requested resource */
|
|
155
|
+
NOT_FOUND = 404,
|
|
156
|
+
/** [405] Request method (GET, POST, etc.) not supported for this resource */
|
|
157
|
+
METHOD_NOT_ALLOWED = 405,
|
|
158
|
+
/** [406] Resource cannot generate response matching accept headers */
|
|
159
|
+
NOT_ACCEPTABLE = 406,
|
|
160
|
+
/** [407] Client must first authenticate with the proxy */
|
|
161
|
+
PROXY_AUTHENTICATION_REQUIRED = 407,
|
|
162
|
+
/** [408] Server timed out waiting for the request */
|
|
163
|
+
REQUEST_TIMEOUT = 408,
|
|
164
|
+
/** [409] Request conflicts with current state of the server */
|
|
165
|
+
CONFLICT = 409,
|
|
166
|
+
/** [410] Resource requested is no longer available and will not be available again */
|
|
167
|
+
GONE = 410,
|
|
168
|
+
/** [411] Server requires Content-Length header field */
|
|
169
|
+
LENGTH_REQUIRED = 411,
|
|
170
|
+
/** [412] Precondition given in request headers evaluated to false */
|
|
171
|
+
PRECONDITION_FAILED = 412,
|
|
172
|
+
/** [413] Request entity larger than limits defined by server */
|
|
173
|
+
PAYLOAD_TOO_LARGE = 413,
|
|
174
|
+
/** [414] URI requested by client is longer than server can interpret */
|
|
175
|
+
URI_TOO_LONG = 414,
|
|
176
|
+
/** [415] Media format of requested data not supported by server */
|
|
177
|
+
UNSUPPORTED_MEDIA_TYPE = 415,
|
|
178
|
+
/** [416] Range specified by Range header cannot be fulfilled */
|
|
179
|
+
RANGE_NOT_SATISFIABLE = 416,
|
|
180
|
+
/** [417] Expectation indicated by Expect header cannot be met */
|
|
181
|
+
EXPECTATION_FAILED = 417,
|
|
182
|
+
/** [418] April Fools' joke by RFC 2324 - Server refuses to brew coffee in a teapot */
|
|
183
|
+
IM_A_TEAPOT = 418,
|
|
184
|
+
/** [421] Request directed at a server that is not configured to produce a response */
|
|
185
|
+
MISDIRECTED_REQUEST = 421,
|
|
186
|
+
/** [422] Server understands content type but cannot process contained instructions */
|
|
187
|
+
UNPROCESSABLE_ENTITY = 422,
|
|
188
|
+
/** [423] Requested resource is currently locked */
|
|
189
|
+
LOCKED = 423,
|
|
190
|
+
/** [424] Request failed due to failure of a previous request */
|
|
191
|
+
FAILED_DEPENDENCY = 424,
|
|
192
|
+
/** [425] Server is unwilling to risk processing a request that might be replayed */
|
|
193
|
+
TOO_EARLY = 425,
|
|
194
|
+
/** [426] Server requires client to upgrade to a different protocol */
|
|
195
|
+
UPGRADE_REQUIRED = 426,
|
|
196
|
+
/** [428] Origin server requires request to be conditional */
|
|
197
|
+
PRECONDITION_REQUIRED = 428,
|
|
198
|
+
/** [429] User has sent too many requests in a given time period */
|
|
199
|
+
TOO_MANY_REQUESTS = 429,
|
|
200
|
+
/** [431] Server refusing to process request due to oversized headers */
|
|
201
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
|
|
202
|
+
/** [451] Server denies access for legal reasons (e.g., censorship) */
|
|
203
|
+
UNAVAILABLE_FOR_LEGAL_REASONS = 451,
|
|
204
|
+
/** [500] Generic server error, no specific message */
|
|
205
|
+
INTERNAL_SERVER_ERROR = 500,
|
|
206
|
+
/** [501] Server does not recognize method or lacks ability to fulfill */
|
|
207
|
+
NOT_IMPLEMENTED = 501,
|
|
208
|
+
/** [502] Bad response received from upstream server */
|
|
209
|
+
BAD_GATEWAY = 502,
|
|
210
|
+
/** [503] Server temporarily unavailable (overloaded/maintenance) */
|
|
211
|
+
SERVICE_UNAVAILABLE = 503,
|
|
212
|
+
/** [504] Gateway server did not get response from upstream server */
|
|
213
|
+
GATEWAY_TIMEOUT = 504,
|
|
214
|
+
/** [505] Server does not support the HTTP protocol version */
|
|
215
|
+
HTTP_VERSION_NOT_SUPPORTED = 505,
|
|
216
|
+
/** [506] Server has a circular reference in content negotiation */
|
|
217
|
+
VARIANT_ALSO_NEGOTIATES = 506,
|
|
218
|
+
/** [507] Server has insufficient storage to complete request */
|
|
219
|
+
INSUFFICIENT_STORAGE = 507,
|
|
220
|
+
/** [508] Server detected an infinite loop while processing request */
|
|
221
|
+
LOOP_DETECTED = 508,
|
|
222
|
+
/** [510] Further extensions needed for server to fulfill request */
|
|
223
|
+
NOT_EXTENDED = 510,
|
|
224
|
+
/** [511] Client needs to authenticate to gain network access */
|
|
225
|
+
NETWORK_AUTHENTICATION_REQUIRED = 511
|
|
113
226
|
}
|
|
114
|
-
|
|
115
|
-
|
|
227
|
+
declare enum ErrorSeverity {
|
|
228
|
+
DEBUG = "DEBUG",
|
|
229
|
+
INFO = "INFO",
|
|
230
|
+
WARNING = "WARNING",
|
|
231
|
+
ERROR = "ERROR",
|
|
232
|
+
CRITICAL = "CRITICAL"
|
|
233
|
+
}
|
|
234
|
+
declare enum ErrorCategory {
|
|
235
|
+
AUTHENTICATION = "auth",
|
|
236
|
+
AUTHORIZATION = "authorization",
|
|
237
|
+
VALIDATION = "validation",
|
|
238
|
+
BUSINESS = "business",
|
|
239
|
+
INFRASTRUCTURE = "infrastructure",
|
|
240
|
+
EXTERNAL = "external",
|
|
241
|
+
UNKNOWN = "unknown"
|
|
242
|
+
}
|
|
243
|
+
interface ErrorMetadata {
|
|
244
|
+
timestamp: number;
|
|
245
|
+
correlationId?: string;
|
|
246
|
+
requestId?: string;
|
|
247
|
+
userId?: string;
|
|
248
|
+
path?: string;
|
|
249
|
+
source?: string;
|
|
250
|
+
[key: string]: unknown;
|
|
251
|
+
}
|
|
252
|
+
interface BaseError {
|
|
253
|
+
code: number;
|
|
116
254
|
message: string;
|
|
255
|
+
category: ErrorCategory;
|
|
256
|
+
severity: ErrorSeverity;
|
|
257
|
+
httpStatus: HttpStatus;
|
|
258
|
+
metadata?: ErrorMetadata;
|
|
117
259
|
cause?: Error;
|
|
118
|
-
|
|
119
|
-
meta?: Record<string, unknown>;
|
|
260
|
+
context?: Record<string, unknown>;
|
|
120
261
|
}
|
|
121
|
-
declare class
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
readonly meta?: Record<string, unknown>;
|
|
125
|
-
readonly timestamp: number;
|
|
126
|
-
cause?: Error;
|
|
127
|
-
constructor(options: SilgiErrorOptions);
|
|
128
|
-
toString(): string;
|
|
129
|
-
toJSON(): {
|
|
130
|
-
name: string;
|
|
131
|
-
code: string;
|
|
262
|
+
declare class ErrorFactory {
|
|
263
|
+
private static createMetadata;
|
|
264
|
+
static create(options: Partial<BaseError> & {
|
|
132
265
|
message: string;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
static
|
|
139
|
-
|
|
266
|
+
}): SilgiError;
|
|
267
|
+
static authenticationError(message: string, context?: Record<string, unknown>): SilgiError;
|
|
268
|
+
static authorizationError(message: string, context?: Record<string, unknown>): SilgiError;
|
|
269
|
+
static validationError(message: string, context?: Record<string, unknown>): SilgiError;
|
|
270
|
+
static notFoundError(message: string, context?: Record<string, unknown>): SilgiError;
|
|
271
|
+
static internalError(message: string, cause?: Error): SilgiError;
|
|
272
|
+
}
|
|
273
|
+
declare class SilgiError extends Error implements BaseError {
|
|
274
|
+
readonly code: number;
|
|
275
|
+
readonly category: ErrorCategory;
|
|
276
|
+
readonly severity: ErrorSeverity;
|
|
277
|
+
readonly httpStatus: HttpStatus;
|
|
278
|
+
readonly metadata: ErrorMetadata;
|
|
279
|
+
readonly context?: Record<string, unknown>;
|
|
280
|
+
readonly cause?: Error;
|
|
281
|
+
constructor(error: BaseError);
|
|
282
|
+
toString(): string;
|
|
283
|
+
toJSON(): Record<string, unknown>;
|
|
284
|
+
static isError(error: unknown): error is SilgiError;
|
|
285
|
+
static from(error: unknown): SilgiError;
|
|
140
286
|
}
|
|
287
|
+
declare function isBaseError(error: unknown): error is BaseError;
|
|
141
288
|
|
|
142
289
|
declare function useSilgi(): Silgi;
|
|
143
290
|
|
|
144
|
-
export { SchemaParser, SilgiError, createSchema, createService, createShared, createSilgi, createSilgiFetch, getEvent, loadOptions, mergeSchemas, mergeServices, mergeShared, parseURI, silgiGenerateType, useSilgi };
|
|
291
|
+
export { type BaseError, ErrorCategory, ErrorFactory, type ErrorMetadata, ErrorSeverity, HttpStatus, SchemaParser, SilgiError, createSchema, createService, createShared, createSilgi, createSilgiFetch, getEvent, isBaseError, loadOptions, mergeSchemas, mergeServices, mergeShared, parseURI, silgiGenerateType, useSilgi };
|