http-response-kit 1.1.0 → 2.0.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.
Files changed (47) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +357 -281
  3. package/dist/chunk-373JVXMN.mjs +1199 -0
  4. package/dist/chunk-373JVXMN.mjs.map +1 -0
  5. package/dist/chunk-FFRB2EUE.mjs +36 -0
  6. package/dist/chunk-FFRB2EUE.mjs.map +1 -0
  7. package/dist/express.d.mts +50 -0
  8. package/dist/express.d.ts +50 -0
  9. package/dist/express.js +1155 -0
  10. package/dist/express.js.map +1 -0
  11. package/dist/express.mjs +28 -0
  12. package/dist/express.mjs.map +1 -0
  13. package/dist/fastify.d.mts +45 -0
  14. package/dist/fastify.d.ts +45 -0
  15. package/dist/fastify.js +1170 -0
  16. package/dist/fastify.js.map +1 -0
  17. package/dist/fastify.mjs +43 -0
  18. package/dist/fastify.mjs.map +1 -0
  19. package/dist/hono.d.mts +33 -0
  20. package/dist/hono.d.ts +33 -0
  21. package/dist/hono.js +1139 -0
  22. package/dist/hono.js.map +1 -0
  23. package/dist/hono.mjs +18 -0
  24. package/dist/hono.mjs.map +1 -0
  25. package/dist/index.d.mts +75 -527
  26. package/dist/index.d.ts +75 -527
  27. package/dist/index.js +440 -188
  28. package/dist/index.js.map +1 -0
  29. package/dist/index.mjs +18 -939
  30. package/dist/index.mjs.map +1 -0
  31. package/dist/kit-nHfihlKE.d.mts +753 -0
  32. package/dist/kit-nHfihlKE.d.ts +753 -0
  33. package/dist/koa.d.mts +38 -0
  34. package/dist/koa.d.ts +38 -0
  35. package/dist/koa.js +1150 -0
  36. package/dist/koa.js.map +1 -0
  37. package/dist/koa.mjs +24 -0
  38. package/dist/koa.mjs.map +1 -0
  39. package/dist/schemas.d.mts +452 -0
  40. package/dist/schemas.d.ts +452 -0
  41. package/dist/schemas.js +124 -0
  42. package/dist/schemas.js.map +1 -0
  43. package/dist/schemas.mjs +119 -0
  44. package/dist/schemas.mjs.map +1 -0
  45. package/dist/shared-Czwmz6Xa.d.ts +22 -0
  46. package/dist/shared-DYq1Fic4.d.mts +22 -0
  47. package/package.json +104 -53
@@ -0,0 +1,452 @@
1
+ /**
2
+ * HTTP Response Kit - JSON Schemas
3
+ *
4
+ * Machine-readable JSON Schema (draft 2020-12) definitions of the response
5
+ * shapes, usable for contract testing, gateway validation, and OpenAPI specs.
6
+ *
7
+ * Import from the dedicated subpath to keep your main bundle lean:
8
+ * `import { errorResponseSchema } from 'http-response-kit/schemas'`
9
+ *
10
+ * @module schemas
11
+ */
12
+ /** JSON Schema for the standard success envelope */
13
+ declare const successResponseSchema: {
14
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
15
+ readonly $id: "https://github.com/matteo-teodori/http-response-kit/schemas/success-response.json";
16
+ readonly title: "SuccessResponse";
17
+ readonly type: "object";
18
+ readonly required: readonly ["success", "status_code"];
19
+ readonly properties: {
20
+ readonly success: {
21
+ readonly const: true;
22
+ };
23
+ readonly status_code: {
24
+ readonly type: "integer";
25
+ readonly minimum: 100;
26
+ readonly maximum: 399;
27
+ };
28
+ readonly timestamp: {
29
+ readonly type: "string";
30
+ readonly format: "date-time";
31
+ };
32
+ readonly request_id: {
33
+ readonly type: "string";
34
+ };
35
+ readonly data: {};
36
+ readonly message: {
37
+ readonly type: "string";
38
+ };
39
+ readonly metadata: {
40
+ readonly type: "object";
41
+ };
42
+ };
43
+ };
44
+ /** JSON Schema for the standard error envelope */
45
+ declare const errorResponseSchema: {
46
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
47
+ readonly $id: "https://github.com/matteo-teodori/http-response-kit/schemas/error-response.json";
48
+ readonly title: "ErrorResponse";
49
+ readonly type: "object";
50
+ readonly required: readonly ["success", "status_code", "error"];
51
+ readonly properties: {
52
+ readonly success: {
53
+ readonly const: false;
54
+ };
55
+ readonly status_code: {
56
+ readonly type: "integer";
57
+ readonly minimum: 400;
58
+ readonly maximum: 599;
59
+ };
60
+ readonly timestamp: {
61
+ readonly type: "string";
62
+ readonly format: "date-time";
63
+ };
64
+ readonly request_id: {
65
+ readonly type: "string";
66
+ };
67
+ readonly retry_after: {
68
+ readonly type: "number";
69
+ };
70
+ readonly error: {
71
+ readonly type: "object";
72
+ readonly required: readonly ["type", "title", "message"];
73
+ readonly properties: {
74
+ readonly type: {
75
+ readonly type: "string";
76
+ };
77
+ readonly title: {
78
+ readonly type: "string";
79
+ };
80
+ readonly message: {
81
+ readonly type: "string";
82
+ };
83
+ readonly code: {
84
+ readonly type: "string";
85
+ };
86
+ readonly details: {
87
+ readonly type: "string";
88
+ };
89
+ readonly errors: {
90
+ readonly type: "array";
91
+ readonly items: {
92
+ readonly type: "object";
93
+ readonly required: readonly ["field", "message"];
94
+ readonly properties: {
95
+ readonly field: {
96
+ readonly type: "string";
97
+ readonly description: "Field/path that failed validation";
98
+ };
99
+ readonly message: {
100
+ readonly type: "string";
101
+ readonly description: "Human-readable description";
102
+ };
103
+ readonly code: {
104
+ readonly type: "string";
105
+ readonly description: "Stable machine-readable code";
106
+ };
107
+ };
108
+ readonly additionalProperties: false;
109
+ };
110
+ };
111
+ readonly stack: {
112
+ readonly type: "string";
113
+ };
114
+ readonly causes: {
115
+ readonly type: "array";
116
+ readonly items: {
117
+ readonly type: "string";
118
+ };
119
+ };
120
+ };
121
+ };
122
+ readonly metadata: {
123
+ readonly type: "object";
124
+ };
125
+ };
126
+ };
127
+ /** JSON Schema for RFC 9457 Problem Details (with common extensions) */
128
+ declare const problemDetailsSchema: {
129
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
130
+ readonly $id: "https://github.com/matteo-teodori/http-response-kit/schemas/problem-details.json";
131
+ readonly title: "ProblemDetails";
132
+ readonly description: "RFC 9457 Problem Details for HTTP APIs";
133
+ readonly type: "object";
134
+ readonly required: readonly ["type", "title", "status"];
135
+ readonly properties: {
136
+ readonly type: {
137
+ readonly type: "string";
138
+ readonly format: "uri-reference";
139
+ readonly default: "about:blank";
140
+ };
141
+ readonly title: {
142
+ readonly type: "string";
143
+ };
144
+ readonly status: {
145
+ readonly type: "integer";
146
+ readonly minimum: 100;
147
+ readonly maximum: 599;
148
+ };
149
+ readonly detail: {
150
+ readonly type: "string";
151
+ };
152
+ readonly instance: {
153
+ readonly type: "string";
154
+ readonly format: "uri-reference";
155
+ };
156
+ readonly code: {
157
+ readonly type: "string";
158
+ };
159
+ readonly errors: {
160
+ readonly type: "array";
161
+ readonly items: {
162
+ readonly type: "object";
163
+ readonly required: readonly ["field", "message"];
164
+ readonly properties: {
165
+ readonly field: {
166
+ readonly type: "string";
167
+ readonly description: "Field/path that failed validation";
168
+ };
169
+ readonly message: {
170
+ readonly type: "string";
171
+ readonly description: "Human-readable description";
172
+ };
173
+ readonly code: {
174
+ readonly type: "string";
175
+ readonly description: "Stable machine-readable code";
176
+ };
177
+ };
178
+ readonly additionalProperties: false;
179
+ };
180
+ };
181
+ readonly request_id: {
182
+ readonly type: "string";
183
+ };
184
+ };
185
+ };
186
+ /**
187
+ * Ready-to-merge OpenAPI 3.1 `components` fragment.
188
+ *
189
+ * @example
190
+ * ```ts
191
+ * const spec = { openapi: '3.1.0', ...yourSpec, components: { schemas: { ...openApiComponents.schemas } } };
192
+ * ```
193
+ */
194
+ declare const openApiComponents: {
195
+ readonly schemas: {
196
+ readonly SuccessResponse: {
197
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
198
+ readonly $id: "https://github.com/matteo-teodori/http-response-kit/schemas/success-response.json";
199
+ readonly title: "SuccessResponse";
200
+ readonly type: "object";
201
+ readonly required: readonly ["success", "status_code"];
202
+ readonly properties: {
203
+ readonly success: {
204
+ readonly const: true;
205
+ };
206
+ readonly status_code: {
207
+ readonly type: "integer";
208
+ readonly minimum: 100;
209
+ readonly maximum: 399;
210
+ };
211
+ readonly timestamp: {
212
+ readonly type: "string";
213
+ readonly format: "date-time";
214
+ };
215
+ readonly request_id: {
216
+ readonly type: "string";
217
+ };
218
+ readonly data: {};
219
+ readonly message: {
220
+ readonly type: "string";
221
+ };
222
+ readonly metadata: {
223
+ readonly type: "object";
224
+ };
225
+ };
226
+ };
227
+ readonly ErrorResponse: {
228
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
229
+ readonly $id: "https://github.com/matteo-teodori/http-response-kit/schemas/error-response.json";
230
+ readonly title: "ErrorResponse";
231
+ readonly type: "object";
232
+ readonly required: readonly ["success", "status_code", "error"];
233
+ readonly properties: {
234
+ readonly success: {
235
+ readonly const: false;
236
+ };
237
+ readonly status_code: {
238
+ readonly type: "integer";
239
+ readonly minimum: 400;
240
+ readonly maximum: 599;
241
+ };
242
+ readonly timestamp: {
243
+ readonly type: "string";
244
+ readonly format: "date-time";
245
+ };
246
+ readonly request_id: {
247
+ readonly type: "string";
248
+ };
249
+ readonly retry_after: {
250
+ readonly type: "number";
251
+ };
252
+ readonly error: {
253
+ readonly type: "object";
254
+ readonly required: readonly ["type", "title", "message"];
255
+ readonly properties: {
256
+ readonly type: {
257
+ readonly type: "string";
258
+ };
259
+ readonly title: {
260
+ readonly type: "string";
261
+ };
262
+ readonly message: {
263
+ readonly type: "string";
264
+ };
265
+ readonly code: {
266
+ readonly type: "string";
267
+ };
268
+ readonly details: {
269
+ readonly type: "string";
270
+ };
271
+ readonly errors: {
272
+ readonly type: "array";
273
+ readonly items: {
274
+ readonly type: "object";
275
+ readonly required: readonly ["field", "message"];
276
+ readonly properties: {
277
+ readonly field: {
278
+ readonly type: "string";
279
+ readonly description: "Field/path that failed validation";
280
+ };
281
+ readonly message: {
282
+ readonly type: "string";
283
+ readonly description: "Human-readable description";
284
+ };
285
+ readonly code: {
286
+ readonly type: "string";
287
+ readonly description: "Stable machine-readable code";
288
+ };
289
+ };
290
+ readonly additionalProperties: false;
291
+ };
292
+ };
293
+ readonly stack: {
294
+ readonly type: "string";
295
+ };
296
+ readonly causes: {
297
+ readonly type: "array";
298
+ readonly items: {
299
+ readonly type: "string";
300
+ };
301
+ };
302
+ };
303
+ };
304
+ readonly metadata: {
305
+ readonly type: "object";
306
+ };
307
+ };
308
+ };
309
+ readonly ProblemDetails: {
310
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
311
+ readonly $id: "https://github.com/matteo-teodori/http-response-kit/schemas/problem-details.json";
312
+ readonly title: "ProblemDetails";
313
+ readonly description: "RFC 9457 Problem Details for HTTP APIs";
314
+ readonly type: "object";
315
+ readonly required: readonly ["type", "title", "status"];
316
+ readonly properties: {
317
+ readonly type: {
318
+ readonly type: "string";
319
+ readonly format: "uri-reference";
320
+ readonly default: "about:blank";
321
+ };
322
+ readonly title: {
323
+ readonly type: "string";
324
+ };
325
+ readonly status: {
326
+ readonly type: "integer";
327
+ readonly minimum: 100;
328
+ readonly maximum: 599;
329
+ };
330
+ readonly detail: {
331
+ readonly type: "string";
332
+ };
333
+ readonly instance: {
334
+ readonly type: "string";
335
+ readonly format: "uri-reference";
336
+ };
337
+ readonly code: {
338
+ readonly type: "string";
339
+ };
340
+ readonly errors: {
341
+ readonly type: "array";
342
+ readonly items: {
343
+ readonly type: "object";
344
+ readonly required: readonly ["field", "message"];
345
+ readonly properties: {
346
+ readonly field: {
347
+ readonly type: "string";
348
+ readonly description: "Field/path that failed validation";
349
+ };
350
+ readonly message: {
351
+ readonly type: "string";
352
+ readonly description: "Human-readable description";
353
+ };
354
+ readonly code: {
355
+ readonly type: "string";
356
+ readonly description: "Stable machine-readable code";
357
+ };
358
+ };
359
+ readonly additionalProperties: false;
360
+ };
361
+ };
362
+ readonly request_id: {
363
+ readonly type: "string";
364
+ };
365
+ };
366
+ };
367
+ };
368
+ readonly responses: {
369
+ readonly BadRequest: {
370
+ readonly description: "Bad Request";
371
+ readonly content: {
372
+ readonly 'application/json': {
373
+ readonly schema: {
374
+ readonly $ref: "#/components/schemas/ErrorResponse";
375
+ };
376
+ };
377
+ };
378
+ };
379
+ readonly Unauthorized: {
380
+ readonly description: "Unauthorized";
381
+ readonly content: {
382
+ readonly 'application/json': {
383
+ readonly schema: {
384
+ readonly $ref: "#/components/schemas/ErrorResponse";
385
+ };
386
+ };
387
+ };
388
+ };
389
+ readonly Forbidden: {
390
+ readonly description: "Forbidden";
391
+ readonly content: {
392
+ readonly 'application/json': {
393
+ readonly schema: {
394
+ readonly $ref: "#/components/schemas/ErrorResponse";
395
+ };
396
+ };
397
+ };
398
+ };
399
+ readonly NotFound: {
400
+ readonly description: "Not Found";
401
+ readonly content: {
402
+ readonly 'application/json': {
403
+ readonly schema: {
404
+ readonly $ref: "#/components/schemas/ErrorResponse";
405
+ };
406
+ };
407
+ };
408
+ };
409
+ readonly UnprocessableEntity: {
410
+ readonly description: "Validation failed";
411
+ readonly content: {
412
+ readonly 'application/json': {
413
+ readonly schema: {
414
+ readonly $ref: "#/components/schemas/ErrorResponse";
415
+ };
416
+ };
417
+ };
418
+ };
419
+ readonly TooManyRequests: {
420
+ readonly description: "Too Many Requests";
421
+ readonly content: {
422
+ readonly 'application/json': {
423
+ readonly schema: {
424
+ readonly $ref: "#/components/schemas/ErrorResponse";
425
+ };
426
+ };
427
+ };
428
+ };
429
+ readonly InternalServerError: {
430
+ readonly description: "Internal Server Error";
431
+ readonly content: {
432
+ readonly 'application/json': {
433
+ readonly schema: {
434
+ readonly $ref: "#/components/schemas/ErrorResponse";
435
+ };
436
+ };
437
+ };
438
+ };
439
+ readonly Problem: {
440
+ readonly description: "RFC 9457 Problem Details";
441
+ readonly content: {
442
+ readonly 'application/problem+json': {
443
+ readonly schema: {
444
+ readonly $ref: "#/components/schemas/ProblemDetails";
445
+ };
446
+ };
447
+ };
448
+ };
449
+ };
450
+ };
451
+
452
+ export { errorResponseSchema, openApiComponents, problemDetailsSchema, successResponseSchema };