@temporary-name/server 0.0.1-alpha.0cb08cf84b740850e7d8dcd1d8b87f78af26071b

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 +30 -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 +30 -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 +32 -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 +30 -0
  15. package/dist/handler/index.d.mts +22 -0
  16. package/dist/handler/index.d.ts +22 -0
  17. package/dist/handler/index.mjs +8 -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 +395 -0
  22. package/dist/index.d.ts +395 -0
  23. package/dist/index.mjs +831 -0
  24. package/dist/openapi/index.d.mts +167 -0
  25. package/dist/openapi/index.d.ts +167 -0
  26. package/dist/openapi/index.mjs +15 -0
  27. package/dist/shared/server.BOkueCuE.d.ts +39 -0
  28. package/dist/shared/server.BTVDgKdb.d.mts +9552 -0
  29. package/dist/shared/server.BTVDgKdb.d.ts +9552 -0
  30. package/dist/shared/server.C1RJffw4.mjs +30 -0
  31. package/dist/shared/server.CWiZN27E.d.mts +39 -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.D7jtfDRy.mjs +288 -0
  35. package/dist/shared/server.JwVIEHL6.mjs +386 -0
  36. package/dist/shared/server.RQr7F4gX.mjs +1292 -0
  37. package/package.json +87 -0
@@ -0,0 +1,167 @@
1
+ import { Contract } from '@temporary-name/server';
2
+ import { OpenAPI, Promisable, HTTPPath, HTTPMethod } from '@temporary-name/shared';
3
+ export { OpenAPI } from '@temporary-name/shared';
4
+ import { A as AnySchema, R as Resource, b as Contract$1, N as NotNoneAuthConfig } from '../shared/server.BTVDgKdb.mjs';
5
+ import { Z as ZodToJsonSchemaConverterOptions } from '../shared/server.CjPiuQYH.mjs';
6
+ import { JSONSchema } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
7
+ export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
8
+ import '@temporary-name/zod';
9
+ import 'zod/v4/core';
10
+ import '@temporary-name/server/openapi';
11
+
12
+ type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, contract: Contract) => OpenAPI.OperationObject);
13
+ /**
14
+ * Customize The Operation Object by proxy an error map item or a middleware.
15
+ */
16
+ declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
17
+ declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
18
+ declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: Contract): OpenAPI.OperationObject;
19
+
20
+ /**
21
+ * @internal
22
+ */
23
+ type ObjectSchema = JSONSchema & {
24
+ type: 'object';
25
+ } & object;
26
+ /**
27
+ * @internal
28
+ */
29
+ type FileSchema = JSONSchema & {
30
+ type: 'string';
31
+ contentMediaType: string;
32
+ } & object;
33
+ /**
34
+ * @internal
35
+ */
36
+ declare const LOGIC_KEYWORDS: string[];
37
+
38
+ interface SchemaConverterComponent {
39
+ allowedStrategies: readonly SchemaConvertOptions['strategy'][];
40
+ schema: AnySchema;
41
+ required: boolean;
42
+ ref: string;
43
+ }
44
+ interface SchemaConvertOptions {
45
+ strategy: 'input' | 'output';
46
+ /**
47
+ * Common components should use `$ref` to represent themselves if matched.
48
+ */
49
+ components?: readonly SchemaConverterComponent[];
50
+ /**
51
+ * Minimum schema structure depth required before using `$ref` for components.
52
+ *
53
+ * For example, if set to 2, `$ref` will only be used for schemas nested at depth 2 or greater.
54
+ *
55
+ * @default 0 - No depth limit;
56
+ */
57
+ minStructureDepthForRef?: number;
58
+ }
59
+ type SchemaConverter = (schemas: AnySchema | undefined, options: SchemaConvertOptions) => Promisable<[required: boolean, jsonSchema: JSONSchema]>;
60
+
61
+ interface OpenAPIGeneratorGenerateOptions {
62
+ spec?: Partial<Omit<OpenAPI.Document, 'openapi'>>;
63
+ schemaConverter?: ZodToJsonSchemaConverterOptions | SchemaConverter;
64
+ /**
65
+ * Common schemas to be used for $ref resolution.
66
+ */
67
+ commonSchemas?: Record<string, {
68
+ /**
69
+ * Determines which schema definition to use when input and output schemas differ.
70
+ * This is needed because some schemas transform data differently between input and output,
71
+ * making it impossible to use a single $ref for both cases.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * // This schema transforms a string input into a number output
76
+ * const Schema = z.string()
77
+ * .transform(v => Number(v))
78
+ * .pipe(z.number())
79
+ *
80
+ * // Input schema: { type: 'string' }
81
+ * // Output schema: { type: 'number' }
82
+ * ```
83
+ *
84
+ * When schemas differ between input and output, you must explicitly choose
85
+ * which version to use for the OpenAPI specification.
86
+ *
87
+ * @default 'input' - Uses the input schema definition by default
88
+ */
89
+ strategy?: SchemaConvertOptions['strategy'];
90
+ schema: AnySchema;
91
+ }>;
92
+ }
93
+ /**
94
+ * Generates OpenAPI specifications from Krusty methods/contracts.
95
+ */
96
+ declare function generateOpenApiSpec(resources: Resource[], options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
97
+ declare function getNamesByAuthConfig(contracts: Iterable<Contract$1>): Map<NotNoneAuthConfig, string>;
98
+
99
+ /**
100
+ * @internal
101
+ */
102
+ declare function toOpenAPIPath(path: HTTPPath): string;
103
+ /**
104
+ * @internal
105
+ */
106
+ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
107
+ /**
108
+ * @internal
109
+ */
110
+ declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
111
+ /**
112
+ * @internal
113
+ */
114
+ declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPI.MediaTypeObject>;
115
+ /**
116
+ * @internal
117
+ */
118
+ declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPI.ParameterObject[];
119
+ /**
120
+ * @internal
121
+ */
122
+ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
123
+ /**
124
+ * @internal
125
+ */
126
+ declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
127
+ declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
128
+
129
+ /**
130
+ *@internal
131
+ */
132
+ declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
133
+ /**
134
+ * @internal
135
+ */
136
+ declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
137
+ /**
138
+ * @internal
139
+ */
140
+ declare function isAnySchema(schema: JSONSchema): boolean;
141
+ /**
142
+ * @internal
143
+ */
144
+ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
145
+ /**
146
+ * @internal
147
+ */
148
+ declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
149
+ declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
150
+ /**
151
+ * Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),
152
+ * recursively expands it into an array of its constituent, non-union base schemas.
153
+ * If the schema is not a simple union or is a base type, it's returned as a single-element array.
154
+ */
155
+ declare function expandUnionSchema(schema: JSONSchema): JSONSchema[];
156
+ declare function expandArrayableSchema(schema: JSONSchema): undefined | [items: JSONSchema, array: JSONSchema & {
157
+ type: 'array';
158
+ items?: JSONSchema;
159
+ }];
160
+ declare function isPrimitiveSchema(schema: JSONSchema): boolean;
161
+
162
+ declare const oo: {
163
+ spec: typeof customOpenAPIOperation;
164
+ };
165
+
166
+ export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, generateOpenApiSpec, getCustomOpenAPIOperation, getNamesByAuthConfig, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
167
+ export type { FileSchema, ObjectSchema, OpenAPIGeneratorGenerateOptions, OverrideOperationValue, SchemaConvertOptions, SchemaConverter, SchemaConverterComponent };
@@ -0,0 +1,167 @@
1
+ import { Contract } from '@temporary-name/server';
2
+ import { OpenAPI, Promisable, HTTPPath, HTTPMethod } from '@temporary-name/shared';
3
+ export { OpenAPI } from '@temporary-name/shared';
4
+ import { A as AnySchema, R as Resource, b as Contract$1, N as NotNoneAuthConfig } from '../shared/server.BTVDgKdb.js';
5
+ import { Z as ZodToJsonSchemaConverterOptions } from '../shared/server.CjPiuQYH.js';
6
+ import { JSONSchema } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
7
+ export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
8
+ import '@temporary-name/zod';
9
+ import 'zod/v4/core';
10
+ import '@temporary-name/server/openapi';
11
+
12
+ type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, contract: Contract) => OpenAPI.OperationObject);
13
+ /**
14
+ * Customize The Operation Object by proxy an error map item or a middleware.
15
+ */
16
+ declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
17
+ declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
18
+ declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: Contract): OpenAPI.OperationObject;
19
+
20
+ /**
21
+ * @internal
22
+ */
23
+ type ObjectSchema = JSONSchema & {
24
+ type: 'object';
25
+ } & object;
26
+ /**
27
+ * @internal
28
+ */
29
+ type FileSchema = JSONSchema & {
30
+ type: 'string';
31
+ contentMediaType: string;
32
+ } & object;
33
+ /**
34
+ * @internal
35
+ */
36
+ declare const LOGIC_KEYWORDS: string[];
37
+
38
+ interface SchemaConverterComponent {
39
+ allowedStrategies: readonly SchemaConvertOptions['strategy'][];
40
+ schema: AnySchema;
41
+ required: boolean;
42
+ ref: string;
43
+ }
44
+ interface SchemaConvertOptions {
45
+ strategy: 'input' | 'output';
46
+ /**
47
+ * Common components should use `$ref` to represent themselves if matched.
48
+ */
49
+ components?: readonly SchemaConverterComponent[];
50
+ /**
51
+ * Minimum schema structure depth required before using `$ref` for components.
52
+ *
53
+ * For example, if set to 2, `$ref` will only be used for schemas nested at depth 2 or greater.
54
+ *
55
+ * @default 0 - No depth limit;
56
+ */
57
+ minStructureDepthForRef?: number;
58
+ }
59
+ type SchemaConverter = (schemas: AnySchema | undefined, options: SchemaConvertOptions) => Promisable<[required: boolean, jsonSchema: JSONSchema]>;
60
+
61
+ interface OpenAPIGeneratorGenerateOptions {
62
+ spec?: Partial<Omit<OpenAPI.Document, 'openapi'>>;
63
+ schemaConverter?: ZodToJsonSchemaConverterOptions | SchemaConverter;
64
+ /**
65
+ * Common schemas to be used for $ref resolution.
66
+ */
67
+ commonSchemas?: Record<string, {
68
+ /**
69
+ * Determines which schema definition to use when input and output schemas differ.
70
+ * This is needed because some schemas transform data differently between input and output,
71
+ * making it impossible to use a single $ref for both cases.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * // This schema transforms a string input into a number output
76
+ * const Schema = z.string()
77
+ * .transform(v => Number(v))
78
+ * .pipe(z.number())
79
+ *
80
+ * // Input schema: { type: 'string' }
81
+ * // Output schema: { type: 'number' }
82
+ * ```
83
+ *
84
+ * When schemas differ between input and output, you must explicitly choose
85
+ * which version to use for the OpenAPI specification.
86
+ *
87
+ * @default 'input' - Uses the input schema definition by default
88
+ */
89
+ strategy?: SchemaConvertOptions['strategy'];
90
+ schema: AnySchema;
91
+ }>;
92
+ }
93
+ /**
94
+ * Generates OpenAPI specifications from Krusty methods/contracts.
95
+ */
96
+ declare function generateOpenApiSpec(resources: Resource[], options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
97
+ declare function getNamesByAuthConfig(contracts: Iterable<Contract$1>): Map<NotNoneAuthConfig, string>;
98
+
99
+ /**
100
+ * @internal
101
+ */
102
+ declare function toOpenAPIPath(path: HTTPPath): string;
103
+ /**
104
+ * @internal
105
+ */
106
+ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
107
+ /**
108
+ * @internal
109
+ */
110
+ declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
111
+ /**
112
+ * @internal
113
+ */
114
+ declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPI.MediaTypeObject>;
115
+ /**
116
+ * @internal
117
+ */
118
+ declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPI.ParameterObject[];
119
+ /**
120
+ * @internal
121
+ */
122
+ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
123
+ /**
124
+ * @internal
125
+ */
126
+ declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
127
+ declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
128
+
129
+ /**
130
+ *@internal
131
+ */
132
+ declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
133
+ /**
134
+ * @internal
135
+ */
136
+ declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
137
+ /**
138
+ * @internal
139
+ */
140
+ declare function isAnySchema(schema: JSONSchema): boolean;
141
+ /**
142
+ * @internal
143
+ */
144
+ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
145
+ /**
146
+ * @internal
147
+ */
148
+ declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
149
+ declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
150
+ /**
151
+ * Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),
152
+ * recursively expands it into an array of its constituent, non-union base schemas.
153
+ * If the schema is not a simple union or is a base type, it's returned as a single-element array.
154
+ */
155
+ declare function expandUnionSchema(schema: JSONSchema): JSONSchema[];
156
+ declare function expandArrayableSchema(schema: JSONSchema): undefined | [items: JSONSchema, array: JSONSchema & {
157
+ type: 'array';
158
+ items?: JSONSchema;
159
+ }];
160
+ declare function isPrimitiveSchema(schema: JSONSchema): boolean;
161
+
162
+ declare const oo: {
163
+ spec: typeof customOpenAPIOperation;
164
+ };
165
+
166
+ export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, generateOpenApiSpec, getCustomOpenAPIOperation, getNamesByAuthConfig, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
167
+ export type { FileSchema, ObjectSchema, OpenAPIGeneratorGenerateOptions, OverrideOperationValue, SchemaConvertOptions, SchemaConverter, SchemaConverterComponent };
@@ -0,0 +1,15 @@
1
+ import { c as customOpenAPIOperation } from '../shared/server.RQr7F4gX.mjs';
2
+ export { L as LOGIC_KEYWORDS, a as applyCustomOpenAPIOperation, p as applySchemaOptionality, j as checkParamsSchema, u as expandArrayableSchema, q as expandUnionSchema, o as filterSchemaBranches, b as generateOpenApiSpec, g as getCustomOpenAPIOperation, d as getNamesByAuthConfig, n as isAnySchema, l as isFileSchema, m as isObjectSchema, v as isPrimitiveSchema, r as resolveOpenAPIJsonSchemaRef, s as separateObjectSchema, f as toOpenAPIContent, h as toOpenAPIEventIteratorContent, e as toOpenAPIMethod, i as toOpenAPIParameters, t as toOpenAPIPath, k as toOpenAPISchema } from '../shared/server.RQr7F4gX.mjs';
3
+ export { ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
4
+ import '@temporary-name/shared';
5
+ import '@temporary-name/zod';
6
+ import '../shared/server.D7jtfDRy.mjs';
7
+ import '@temporary-name/standard-server';
8
+ import '@temporary-name/server/openapi';
9
+ import 'zod/v4/core';
10
+
11
+ const oo = {
12
+ spec: customOpenAPIOperation
13
+ };
14
+
15
+ export { customOpenAPIOperation, oo };
@@ -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.BTVDgKdb.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 };