@temporary-name/server 0.0.1-alpha.123c4256a169035efa84c708de3e315d2a7f5ae1

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 (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +31 -0
  3. package/dist/adapters/aws-lambda/index.d.mts +26 -0
  4. package/dist/adapters/aws-lambda/index.d.ts +26 -0
  5. package/dist/adapters/aws-lambda/index.mjs +29 -0
  6. package/dist/adapters/fastify/index.d.mts +23 -0
  7. package/dist/adapters/fastify/index.d.ts +23 -0
  8. package/dist/adapters/fastify/index.mjs +29 -0
  9. package/dist/adapters/fetch/index.d.mts +28 -0
  10. package/dist/adapters/fetch/index.d.ts +28 -0
  11. package/dist/adapters/fetch/index.mjs +31 -0
  12. package/dist/adapters/node/index.d.mts +26 -0
  13. package/dist/adapters/node/index.d.ts +26 -0
  14. package/dist/adapters/node/index.mjs +29 -0
  15. package/dist/handler/index.d.mts +27 -0
  16. package/dist/handler/index.d.ts +27 -0
  17. package/dist/handler/index.mjs +7 -0
  18. package/dist/helpers/index.d.mts +149 -0
  19. package/dist/helpers/index.d.ts +149 -0
  20. package/dist/helpers/index.mjs +142 -0
  21. package/dist/index.d.mts +414 -0
  22. package/dist/index.d.ts +414 -0
  23. package/dist/index.mjs +696 -0
  24. package/dist/openapi/index.d.mts +166 -0
  25. package/dist/openapi/index.d.ts +166 -0
  26. package/dist/openapi/index.mjs +834 -0
  27. package/dist/shared/server.7EG6rqbI.mjs +496 -0
  28. package/dist/shared/server.B3SSI6V6.d.mts +3026 -0
  29. package/dist/shared/server.B3SSI6V6.d.ts +3026 -0
  30. package/dist/shared/server.BwXNcNk_.mjs +275 -0
  31. package/dist/shared/server.C1RJffw4.mjs +30 -0
  32. package/dist/shared/server.CjPiuQYH.d.mts +51 -0
  33. package/dist/shared/server.CjPiuQYH.d.ts +51 -0
  34. package/dist/shared/server.Cuq0WHVy.mjs +529 -0
  35. package/dist/shared/server.DmZlW6xR.d.ts +39 -0
  36. package/dist/shared/server.KW5uPnMg.d.mts +39 -0
  37. package/package.json +86 -0
@@ -0,0 +1,529 @@
1
+ import { isAsyncIteratorObject, toArray } from '@temporary-name/shared';
2
+ import { mapEventIterator } from '@temporary-name/standard-server';
3
+ import { custom, safeParseAsync } from '@temporary-name/zod';
4
+ import { V as ValidationError } from './server.BwXNcNk_.mjs';
5
+ import { JSONSchemaFormat, JSONSchemaContentEncoding } from '@temporary-name/server/openapi';
6
+ import { registry, globalRegistry } from 'zod/v4/core';
7
+
8
+ const EVENT_ITERATOR_DETAILS_SYMBOL = Symbol("KRUSTY_EVENT_ITERATOR_DETAILS");
9
+ function eventIterator(yields, returns) {
10
+ const schema = custom(
11
+ (iterator) => isAsyncIteratorObject(iterator)
12
+ ).transform((iterator) => {
13
+ const mapped = mapEventIterator(iterator, {
14
+ async value(value, done) {
15
+ const schema2 = done ? returns : yields;
16
+ if (!schema2) {
17
+ return value;
18
+ }
19
+ const result = await safeParseAsync(schema2, value);
20
+ if (result.success) {
21
+ return result.data;
22
+ } else {
23
+ throw new Error("Event iterator validation failed", {
24
+ cause: new ValidationError({
25
+ issues: result.error.issues,
26
+ data: value
27
+ })
28
+ });
29
+ }
30
+ },
31
+ error: async (error) => error
32
+ });
33
+ return mapped;
34
+ });
35
+ schema[EVENT_ITERATOR_DETAILS_SYMBOL] = {
36
+ yields,
37
+ returns
38
+ };
39
+ return schema;
40
+ }
41
+ function getEventIteratorSchemaDetails(schema) {
42
+ if (schema === void 0) {
43
+ return void 0;
44
+ }
45
+ return schema[EVENT_ITERATOR_DETAILS_SYMBOL];
46
+ }
47
+
48
+ var JsonSchemaXNativeType = /* @__PURE__ */ ((JsonSchemaXNativeType2) => {
49
+ JsonSchemaXNativeType2["BigInt"] = "bigint";
50
+ JsonSchemaXNativeType2["RegExp"] = "regexp";
51
+ JsonSchemaXNativeType2["Date"] = "date";
52
+ JsonSchemaXNativeType2["Url"] = "url";
53
+ JsonSchemaXNativeType2["Set"] = "set";
54
+ JsonSchemaXNativeType2["Map"] = "map";
55
+ return JsonSchemaXNativeType2;
56
+ })(JsonSchemaXNativeType || {});
57
+
58
+ const JSON_SCHEMA_REGISTRY = registry();
59
+ const JSON_SCHEMA_INPUT_REGISTRY = registry();
60
+ const JSON_SCHEMA_OUTPUT_REGISTRY = registry();
61
+
62
+ class ZodToJsonSchemaConverter {
63
+ maxLazyDepth;
64
+ maxStructureDepth;
65
+ anyJsonSchema;
66
+ unsupportedJsonSchema;
67
+ undefinedJsonSchema;
68
+ constructor(options = {}) {
69
+ this.maxLazyDepth = options.maxLazyDepth ?? 2;
70
+ this.maxStructureDepth = options.maxStructureDepth ?? 10;
71
+ this.anyJsonSchema = options.anyJsonSchema ?? {};
72
+ this.unsupportedJsonSchema = options.unsupportedJsonSchema ?? { not: {} };
73
+ this.undefinedJsonSchema = options.undefinedJsonSchema ?? { not: {} };
74
+ }
75
+ convert = (schema, options) => {
76
+ return this.#convert(schema, options, 0, 0);
77
+ };
78
+ #convert(schema, options, lazyDepth, structureDepth, isHandledCustomJSONSchema = false) {
79
+ if (structureDepth > this.maxStructureDepth) {
80
+ return [false, this.anyJsonSchema];
81
+ }
82
+ if (!options.minStructureDepthForRef || options.minStructureDepthForRef <= structureDepth) {
83
+ const components = toArray(options.components);
84
+ for (const component of components) {
85
+ if (component.schema === schema && component.allowedStrategies.includes(options.strategy)) {
86
+ return [component.required, { $ref: component.ref }];
87
+ }
88
+ }
89
+ }
90
+ if (!isHandledCustomJSONSchema) {
91
+ const customJSONSchema = this.#getCustomJsonSchema(schema, options);
92
+ if (customJSONSchema) {
93
+ const [required, json] = this.#convert(schema, options, lazyDepth, structureDepth, true);
94
+ return [required, { ...json, ...customJSONSchema }];
95
+ }
96
+ }
97
+ switch (schema._zod.def.type) {
98
+ case "string": {
99
+ const string = schema;
100
+ const json = { type: "string" };
101
+ const { minimum, maximum, format, patterns, contentEncoding } = string._zod.bag;
102
+ if (typeof minimum === "number") {
103
+ json.minLength = minimum;
104
+ }
105
+ if (typeof maximum === "number") {
106
+ json.maxLength = maximum;
107
+ }
108
+ if (typeof contentEncoding === "string") {
109
+ json.contentEncoding = this.#handleContentEncoding(contentEncoding);
110
+ }
111
+ if (typeof format === "string" && format !== "regex" && json.contentEncoding === void 0) {
112
+ json.format = this.#handleStringFormat(format);
113
+ }
114
+ if (patterns instanceof Set && json.contentEncoding === void 0 && json.format === void 0) {
115
+ for (const pattern of patterns) {
116
+ if (json.pattern === void 0) {
117
+ json.pattern = pattern.source;
118
+ } else {
119
+ json.allOf ??= [];
120
+ json.allOf.push({ pattern: pattern.source });
121
+ }
122
+ }
123
+ }
124
+ if (format === "jwt" && json.contentEncoding === void 0 && json.format === void 0 && json.pattern === void 0) {
125
+ json.pattern = /^[\w-]+\.[\w-]+\.[\w-]+$/.source;
126
+ }
127
+ return [true, json];
128
+ }
129
+ case "number": {
130
+ const number = schema;
131
+ const json = { type: "number" };
132
+ const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = number._zod.bag;
133
+ if (typeof format === "string" && format?.includes("int")) {
134
+ json.type = "integer";
135
+ }
136
+ if (typeof minimum === "number") {
137
+ json.minimum = minimum;
138
+ }
139
+ if (typeof maximum === "number") {
140
+ json.maximum = maximum;
141
+ }
142
+ if (typeof exclusiveMinimum === "number") {
143
+ json.exclusiveMinimum = exclusiveMinimum;
144
+ }
145
+ if (typeof exclusiveMaximum === "number") {
146
+ json.exclusiveMaximum = exclusiveMaximum;
147
+ }
148
+ if (typeof multipleOf === "number") {
149
+ json.multipleOf = multipleOf;
150
+ }
151
+ return [true, json];
152
+ }
153
+ case "boolean": {
154
+ return [true, { type: "boolean" }];
155
+ }
156
+ case "bigint": {
157
+ return [
158
+ true,
159
+ {
160
+ type: "string",
161
+ pattern: "^-?[0-9]+$",
162
+ "x-native-type": JsonSchemaXNativeType.BigInt
163
+ }
164
+ ];
165
+ }
166
+ case "date": {
167
+ return [
168
+ true,
169
+ {
170
+ type: "string",
171
+ format: JSONSchemaFormat.DateTime,
172
+ "x-native-type": JsonSchemaXNativeType.Date
173
+ }
174
+ ];
175
+ }
176
+ case "null": {
177
+ return [true, { type: "null" }];
178
+ }
179
+ case "undefined":
180
+ case "void": {
181
+ return [false, this.undefinedJsonSchema];
182
+ }
183
+ case "any": {
184
+ return [false, this.anyJsonSchema];
185
+ }
186
+ case "unknown": {
187
+ return [false, this.anyJsonSchema];
188
+ }
189
+ case "never": {
190
+ return [true, this.unsupportedJsonSchema];
191
+ }
192
+ case "array": {
193
+ const array = schema;
194
+ const json = { type: "array" };
195
+ const { minimum, maximum } = array._zod.bag;
196
+ if (typeof minimum === "number") {
197
+ json.minItems = minimum;
198
+ }
199
+ if (typeof maximum === "number") {
200
+ json.maxItems = maximum;
201
+ }
202
+ json.items = this.#handleArrayItemJsonSchema(
203
+ this.#convert(array._zod.def.element, options, lazyDepth, structureDepth + 1),
204
+ options
205
+ );
206
+ return [true, json];
207
+ }
208
+ case "object": {
209
+ const object = schema;
210
+ const json = { type: "object" };
211
+ let required = true;
212
+ for (const [key, value] of Object.entries(object._zod.def.shape)) {
213
+ const [itemRequired, itemJson] = this.#convert(value, options, lazyDepth, structureDepth + 1);
214
+ json.properties ??= {};
215
+ json.properties[key] = itemJson;
216
+ if (itemRequired) {
217
+ json.required ??= [];
218
+ json.required.push(key);
219
+ }
220
+ }
221
+ if (object._zod.def.catchall) {
222
+ if (object._zod.def.catchall._zod.def.type === "never") {
223
+ json.additionalProperties = false;
224
+ } else {
225
+ const [_, addJson] = this.#convert(
226
+ object._zod.def.catchall,
227
+ options,
228
+ lazyDepth,
229
+ structureDepth + 1
230
+ );
231
+ json.additionalProperties = addJson;
232
+ }
233
+ } else if (options.strategy === "input") {
234
+ json.additionalProperties = false;
235
+ }
236
+ if (options.strategy === "input" && structureDepth === 0 && (!json.properties || Object.keys(json.properties).length === 0)) {
237
+ required = false;
238
+ }
239
+ return [required, json];
240
+ }
241
+ case "union": {
242
+ const union = schema;
243
+ const anyOf = [];
244
+ let required = true;
245
+ for (const item of union._zod.def.options) {
246
+ const [itemRequired, itemJson] = this.#convert(item, options, lazyDepth, structureDepth);
247
+ if (!itemRequired) {
248
+ required = false;
249
+ }
250
+ if (options.strategy === "input") {
251
+ if (itemJson !== this.undefinedJsonSchema && itemJson !== this.unsupportedJsonSchema) {
252
+ anyOf.push(itemJson);
253
+ }
254
+ } else {
255
+ if (itemJson !== this.undefinedJsonSchema) {
256
+ anyOf.push(itemJson);
257
+ }
258
+ }
259
+ }
260
+ return [required, anyOf.length === 1 ? anyOf[0] : { anyOf }];
261
+ }
262
+ case "intersection": {
263
+ const intersection = schema;
264
+ const json = { allOf: [] };
265
+ let required = false;
266
+ for (const item of [intersection._zod.def.left, intersection._zod.def.right]) {
267
+ const [itemRequired, itemJson] = this.#convert(item, options, lazyDepth, structureDepth);
268
+ json.allOf.push(itemJson);
269
+ if (itemRequired) {
270
+ required = true;
271
+ }
272
+ }
273
+ return [required, json];
274
+ }
275
+ case "tuple": {
276
+ const tuple = schema;
277
+ const json = { type: "array", prefixItems: [] };
278
+ for (const item of tuple._zod.def.items) {
279
+ json.prefixItems.push(
280
+ this.#handleArrayItemJsonSchema(
281
+ this.#convert(item, options, lazyDepth, structureDepth + 1),
282
+ options
283
+ )
284
+ );
285
+ }
286
+ if (tuple._zod.def.rest) {
287
+ json.items = this.#handleArrayItemJsonSchema(
288
+ this.#convert(tuple._zod.def.rest, options, lazyDepth, structureDepth + 1),
289
+ options
290
+ );
291
+ }
292
+ const { minimum, maximum } = tuple._zod.bag;
293
+ if (typeof minimum === "number") {
294
+ json.minItems = minimum;
295
+ }
296
+ if (typeof maximum === "number") {
297
+ json.maxItems = maximum;
298
+ }
299
+ return [true, json];
300
+ }
301
+ case "record": {
302
+ const record = schema;
303
+ const json = { type: "object" };
304
+ json.propertyNames = this.#convert(
305
+ record._zod.def.keyType,
306
+ options,
307
+ lazyDepth,
308
+ structureDepth + 1
309
+ )[1];
310
+ json.additionalProperties = this.#convert(
311
+ record._zod.def.valueType,
312
+ options,
313
+ lazyDepth,
314
+ structureDepth + 1
315
+ )[1];
316
+ return [true, json];
317
+ }
318
+ case "map": {
319
+ const map = schema;
320
+ return [
321
+ true,
322
+ {
323
+ type: "array",
324
+ items: {
325
+ type: "array",
326
+ prefixItems: [
327
+ this.#handleArrayItemJsonSchema(
328
+ this.#convert(map._zod.def.keyType, options, lazyDepth, structureDepth + 1),
329
+ options
330
+ ),
331
+ this.#handleArrayItemJsonSchema(
332
+ this.#convert(map._zod.def.valueType, options, lazyDepth, structureDepth + 1),
333
+ options
334
+ )
335
+ ],
336
+ maxItems: 2,
337
+ minItems: 2
338
+ },
339
+ "x-native-type": JsonSchemaXNativeType.Map
340
+ }
341
+ ];
342
+ }
343
+ case "set": {
344
+ const set = schema;
345
+ return [
346
+ true,
347
+ {
348
+ type: "array",
349
+ uniqueItems: true,
350
+ items: this.#handleArrayItemJsonSchema(
351
+ this.#convert(set._zod.def.valueType, options, lazyDepth, structureDepth + 1),
352
+ options
353
+ ),
354
+ "x-native-type": JsonSchemaXNativeType.Set
355
+ }
356
+ ];
357
+ }
358
+ case "enum": {
359
+ const enum_ = schema;
360
+ return [true, { enum: Object.values(enum_._zod.def.entries) }];
361
+ }
362
+ case "literal": {
363
+ const literal = schema;
364
+ let required = true;
365
+ const values = /* @__PURE__ */ new Set();
366
+ for (const value of literal._zod.def.values) {
367
+ if (value === void 0) {
368
+ required = false;
369
+ } else {
370
+ values.add(typeof value === "bigint" ? value.toString() : value);
371
+ }
372
+ }
373
+ const json = values.size === 0 ? this.undefinedJsonSchema : values.size === 1 ? { const: values.values().next().value } : { enum: Array.from(values) };
374
+ return [required, json];
375
+ }
376
+ case "file": {
377
+ const file = schema;
378
+ const oneOf = [];
379
+ const { mime } = file._zod.bag;
380
+ if (mime === void 0 || Array.isArray(mime) && mime.every((m) => typeof m === "string")) {
381
+ for (const type of mime ?? ["*/*"]) {
382
+ oneOf.push({
383
+ type: "string",
384
+ contentMediaType: type
385
+ });
386
+ }
387
+ }
388
+ return [true, oneOf.length === 1 ? oneOf[0] : { anyOf: oneOf }];
389
+ }
390
+ case "transform": {
391
+ return [false, this.anyJsonSchema];
392
+ }
393
+ case "nullable": {
394
+ const nullable = schema;
395
+ const [required, json] = this.#convert(
396
+ nullable._zod.def.innerType,
397
+ options,
398
+ lazyDepth,
399
+ structureDepth
400
+ );
401
+ return [required, { anyOf: [json, { type: "null" }] }];
402
+ }
403
+ case "nonoptional": {
404
+ const nonoptional = schema;
405
+ const [, json] = this.#convert(nonoptional._zod.def.innerType, options, lazyDepth, structureDepth);
406
+ return [true, json];
407
+ }
408
+ case "success": {
409
+ return [true, { type: "boolean" }];
410
+ }
411
+ case "default":
412
+ case "prefault": {
413
+ const default_ = schema;
414
+ const [, json] = this.#convert(default_._zod.def.innerType, options, lazyDepth, structureDepth);
415
+ return [
416
+ false,
417
+ {
418
+ ...json,
419
+ default: default_._zod.def.defaultValue
420
+ }
421
+ ];
422
+ }
423
+ case "catch": {
424
+ const catch_ = schema;
425
+ return this.#convert(catch_._zod.def.innerType, options, lazyDepth, structureDepth);
426
+ }
427
+ case "nan": {
428
+ return [true, options.strategy === "input" ? this.unsupportedJsonSchema : { type: "null" }];
429
+ }
430
+ case "pipe": {
431
+ const pipe = schema;
432
+ return this.#convert(
433
+ options.strategy === "input" ? pipe._zod.def.in : pipe._zod.def.out,
434
+ options,
435
+ lazyDepth,
436
+ structureDepth
437
+ );
438
+ }
439
+ case "readonly": {
440
+ const readonly_ = schema;
441
+ const [required, json] = this.#convert(
442
+ readonly_._zod.def.innerType,
443
+ options,
444
+ lazyDepth,
445
+ structureDepth
446
+ );
447
+ return [required, { ...json, readOnly: true }];
448
+ }
449
+ case "template_literal": {
450
+ const templateLiteral = schema;
451
+ return [
452
+ true,
453
+ {
454
+ type: "string",
455
+ pattern: templateLiteral._zod.pattern.source
456
+ }
457
+ ];
458
+ }
459
+ case "optional": {
460
+ const optional = schema;
461
+ const [, json] = this.#convert(optional._zod.def.innerType, options, lazyDepth, structureDepth);
462
+ return [false, json];
463
+ }
464
+ case "lazy": {
465
+ const lazy = schema;
466
+ const currentLazyDepth = lazyDepth + 1;
467
+ if (currentLazyDepth > this.maxLazyDepth) {
468
+ return [false, this.anyJsonSchema];
469
+ }
470
+ return this.#convert(lazy._zod.def.getter(), options, currentLazyDepth, structureDepth);
471
+ }
472
+ default: {
473
+ schema._zod.def.type;
474
+ return [true, this.unsupportedJsonSchema];
475
+ }
476
+ }
477
+ }
478
+ #getCustomJsonSchema(schema, options) {
479
+ if (options.strategy === "input" && JSON_SCHEMA_INPUT_REGISTRY.has(schema)) {
480
+ return JSON_SCHEMA_INPUT_REGISTRY.get(schema);
481
+ }
482
+ if (options.strategy === "output" && JSON_SCHEMA_OUTPUT_REGISTRY.has(schema)) {
483
+ return JSON_SCHEMA_OUTPUT_REGISTRY.get(schema);
484
+ }
485
+ if (JSON_SCHEMA_REGISTRY.has(schema)) {
486
+ return JSON_SCHEMA_REGISTRY.get(schema);
487
+ }
488
+ const global = globalRegistry.get(schema);
489
+ if (global) {
490
+ return {
491
+ title: global.title,
492
+ description: global.description,
493
+ examples: Array.isArray(global.examples) ? global.examples : void 0
494
+ };
495
+ }
496
+ }
497
+ #handleArrayItemJsonSchema([required, schema], options) {
498
+ if (required || options.strategy === "input" || schema.default !== void 0) {
499
+ return schema;
500
+ }
501
+ if (schema === this.undefinedJsonSchema) {
502
+ return { type: "null" };
503
+ }
504
+ return {
505
+ anyOf: [
506
+ // schema can contain { type: 'null' } so we should use anyOf instead of oneOf
507
+ schema,
508
+ { type: "null" }
509
+ ]
510
+ };
511
+ }
512
+ #handleStringFormat(format) {
513
+ if (format === "guid") {
514
+ return JSONSchemaFormat.UUID;
515
+ }
516
+ if (format === "url") {
517
+ return JSONSchemaFormat.URI;
518
+ }
519
+ if (format === "datetime") {
520
+ return JSONSchemaFormat.DateTime;
521
+ }
522
+ return Object.values(JSONSchemaFormat).includes(format) ? format : void 0;
523
+ }
524
+ #handleContentEncoding(contentEncoding) {
525
+ return Object.values(JSONSchemaContentEncoding).includes(contentEncoding) ? contentEncoding : void 0;
526
+ }
527
+ }
528
+
529
+ export { JsonSchemaXNativeType as J, ZodToJsonSchemaConverter as Z, JSON_SCHEMA_REGISTRY as a, JSON_SCHEMA_INPUT_REGISTRY as b, JSON_SCHEMA_OUTPUT_REGISTRY as c, eventIterator as e, getEventIteratorSchemaDetails as g };
@@ -0,0 +1,39 @@
1
+ import { HTTPPath, StandardResponse, StandardLazyRequest } from '@temporary-name/shared';
2
+ import { C as Context, I as ImplementedResource, a as InferResourceContext } from './server.B3SSI6V6.js';
3
+
4
+ interface StandardHandleOptions<T extends Context> {
5
+ prefix?: HTTPPath;
6
+ context: T;
7
+ }
8
+ type StandardHandleResult = {
9
+ matched: true;
10
+ response: StandardResponse;
11
+ } | {
12
+ matched: false;
13
+ response: undefined;
14
+ };
15
+ declare class StandardHandler<T extends ImplementedResource> {
16
+ private readonly matcher;
17
+ constructor(resources: T[]);
18
+ handle(request: StandardLazyRequest, options: StandardHandleOptions<InferResourceContext<T>>): Promise<StandardHandleResult>;
19
+ }
20
+
21
+ type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (object extends T ? {
22
+ context?: T;
23
+ } : {
24
+ context: T;
25
+ });
26
+ declare function resolveFriendlyStandardHandleOptions<T extends Context>(options: FriendlyStandardHandleOptions<T>): StandardHandleOptions<T>;
27
+ /**
28
+ * {@link https://github.com/unjs/rou3}
29
+ *
30
+ * @internal
31
+ */
32
+ declare function toRou3Pattern(path: HTTPPath): string;
33
+ /**
34
+ * @internal
35
+ */
36
+ declare function decodeParams(params: Record<string, string>): Record<string, string>;
37
+
38
+ export { StandardHandler as b, decodeParams as d, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
39
+ export type { FriendlyStandardHandleOptions as F, StandardHandleOptions as S, StandardHandleResult as a };
@@ -0,0 +1,39 @@
1
+ import { HTTPPath, StandardResponse, StandardLazyRequest } from '@temporary-name/shared';
2
+ import { C as Context, I as ImplementedResource, a as InferResourceContext } from './server.B3SSI6V6.mjs';
3
+
4
+ interface StandardHandleOptions<T extends Context> {
5
+ prefix?: HTTPPath;
6
+ context: T;
7
+ }
8
+ type StandardHandleResult = {
9
+ matched: true;
10
+ response: StandardResponse;
11
+ } | {
12
+ matched: false;
13
+ response: undefined;
14
+ };
15
+ declare class StandardHandler<T extends ImplementedResource> {
16
+ private readonly matcher;
17
+ constructor(resources: T[]);
18
+ handle(request: StandardLazyRequest, options: StandardHandleOptions<InferResourceContext<T>>): Promise<StandardHandleResult>;
19
+ }
20
+
21
+ type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (object extends T ? {
22
+ context?: T;
23
+ } : {
24
+ context: T;
25
+ });
26
+ declare function resolveFriendlyStandardHandleOptions<T extends Context>(options: FriendlyStandardHandleOptions<T>): StandardHandleOptions<T>;
27
+ /**
28
+ * {@link https://github.com/unjs/rou3}
29
+ *
30
+ * @internal
31
+ */
32
+ declare function toRou3Pattern(path: HTTPPath): string;
33
+ /**
34
+ * @internal
35
+ */
36
+ declare function decodeParams(params: Record<string, string>): Record<string, string>;
37
+
38
+ export { StandardHandler as b, decodeParams as d, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
39
+ export type { FriendlyStandardHandleOptions as F, StandardHandleOptions as S, StandardHandleResult as a };
package/package.json ADDED
@@ -0,0 +1,86 @@
1
+ {
2
+ "name": "@temporary-name/server",
3
+ "type": "module",
4
+ "version": "0.0.1-alpha.123c4256a169035efa84c708de3e315d2a7f5ae1",
5
+ "license": "MIT",
6
+ "homepage": "https://www.stainless.com/",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/stainless-api/krusty.git",
10
+ "directory": "packages/server"
11
+ },
12
+ "keywords": [
13
+ "krusty"
14
+ ],
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.mts",
18
+ "import": "./dist/index.mjs",
19
+ "default": "./dist/index.mjs"
20
+ },
21
+ "./helpers": {
22
+ "types": "./dist/helpers/index.d.mts",
23
+ "import": "./dist/helpers/index.mjs",
24
+ "default": "./dist/helpers/index.mjs"
25
+ },
26
+ "./standard": {
27
+ "types": "./dist/handler/index.d.mts",
28
+ "import": "./dist/handler/index.mjs",
29
+ "default": "./dist/handler/index.mjs"
30
+ },
31
+ "./fetch": {
32
+ "types": "./dist/adapters/fetch/index.d.mts",
33
+ "import": "./dist/adapters/fetch/index.mjs",
34
+ "default": "./dist/adapters/fetch/index.mjs"
35
+ },
36
+ "./node": {
37
+ "types": "./dist/adapters/node/index.d.mts",
38
+ "import": "./dist/adapters/node/index.mjs",
39
+ "default": "./dist/adapters/node/index.mjs"
40
+ },
41
+ "./aws-lambda": {
42
+ "types": "./dist/adapters/aws-lambda/index.d.mts",
43
+ "import": "./dist/adapters/aws-lambda/index.mjs",
44
+ "default": "./dist/adapters/aws-lambda/index.mjs"
45
+ },
46
+ "./fastify": {
47
+ "types": "./dist/adapters/fastify/index.d.mts",
48
+ "import": "./dist/adapters/fastify/index.mjs",
49
+ "default": "./dist/adapters/fastify/index.mjs"
50
+ },
51
+ "./openapi": {
52
+ "types": "./dist/openapi/index.d.mts",
53
+ "import": "./dist/openapi/index.mjs",
54
+ "default": "./dist/openapi/index.mjs"
55
+ }
56
+ },
57
+ "files": [
58
+ "dist"
59
+ ],
60
+ "dependencies": {
61
+ "cookie": "^1.0.2",
62
+ "rou3": "^0.7.7",
63
+ "zod": "^4.1.12",
64
+ "@temporary-name/interop": "0.0.1-alpha.123c4256a169035efa84c708de3e315d2a7f5ae1",
65
+ "@temporary-name/shared": "0.0.1-alpha.123c4256a169035efa84c708de3e315d2a7f5ae1",
66
+ "@temporary-name/standard-server-aws-lambda": "0.0.1-alpha.123c4256a169035efa84c708de3e315d2a7f5ae1",
67
+ "@temporary-name/standard-server": "0.0.1-alpha.123c4256a169035efa84c708de3e315d2a7f5ae1",
68
+ "@temporary-name/standard-server-fastify": "1.13.5-alpha.123c4256a169035efa84c708de3e315d2a7f5ae1",
69
+ "@temporary-name/standard-server-node": "0.0.1-alpha.123c4256a169035efa84c708de3e315d2a7f5ae1",
70
+ "@temporary-name/standard-server-fetch": "0.0.1-alpha.123c4256a169035efa84c708de3e315d2a7f5ae1",
71
+ "@temporary-name/zod": "0.0.1-alpha.123c4256a169035efa84c708de3e315d2a7f5ae1"
72
+ },
73
+ "devDependencies": {
74
+ "@types/supertest": "^6.0.3",
75
+ "@types/ws": "^8.18.1",
76
+ "fastify": "^5.7.4",
77
+ "json-schema-to-typescript": "^15.0.4",
78
+ "supertest": "^7.1.4"
79
+ },
80
+ "scripts": {
81
+ "build": "unbuild",
82
+ "build:watch": "pnpm run build --watch",
83
+ "clean": "tsc -b --clean",
84
+ "lint:tsc": "tsc -b"
85
+ }
86
+ }