@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,166 @@
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 } from '../shared/server.B3SSI6V6.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, procedure: 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 routers/contracts.
95
+ */
96
+ declare function generateOpenApiSpec(resources: Resource[], options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
97
+
98
+ /**
99
+ * @internal
100
+ */
101
+ declare function toOpenAPIPath(path: HTTPPath): string;
102
+ /**
103
+ * @internal
104
+ */
105
+ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
106
+ /**
107
+ * @internal
108
+ */
109
+ declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
110
+ /**
111
+ * @internal
112
+ */
113
+ declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPI.MediaTypeObject>;
114
+ /**
115
+ * @internal
116
+ */
117
+ declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPI.ParameterObject[];
118
+ /**
119
+ * @internal
120
+ */
121
+ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
122
+ /**
123
+ * @internal
124
+ */
125
+ declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
126
+ declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
127
+
128
+ /**
129
+ *@internal
130
+ */
131
+ declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
132
+ /**
133
+ * @internal
134
+ */
135
+ declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
136
+ /**
137
+ * @internal
138
+ */
139
+ declare function isAnySchema(schema: JSONSchema): boolean;
140
+ /**
141
+ * @internal
142
+ */
143
+ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
144
+ /**
145
+ * @internal
146
+ */
147
+ declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
148
+ declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
149
+ /**
150
+ * Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),
151
+ * recursively expands it into an array of its constituent, non-union base schemas.
152
+ * If the schema is not a simple union or is a base type, it's returned as a single-element array.
153
+ */
154
+ declare function expandUnionSchema(schema: JSONSchema): JSONSchema[];
155
+ declare function expandArrayableSchema(schema: JSONSchema): undefined | [items: JSONSchema, array: JSONSchema & {
156
+ type: 'array';
157
+ items?: JSONSchema;
158
+ }];
159
+ declare function isPrimitiveSchema(schema: JSONSchema): boolean;
160
+
161
+ declare const oo: {
162
+ spec: typeof customOpenAPIOperation;
163
+ };
164
+
165
+ export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, generateOpenApiSpec, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
166
+ export type { FileSchema, ObjectSchema, OpenAPIGeneratorGenerateOptions, OverrideOperationValue, SchemaConvertOptions, SchemaConverter, SchemaConverterComponent };
@@ -0,0 +1,166 @@
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 } from '../shared/server.B3SSI6V6.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, procedure: 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 routers/contracts.
95
+ */
96
+ declare function generateOpenApiSpec(resources: Resource[], options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
97
+
98
+ /**
99
+ * @internal
100
+ */
101
+ declare function toOpenAPIPath(path: HTTPPath): string;
102
+ /**
103
+ * @internal
104
+ */
105
+ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
106
+ /**
107
+ * @internal
108
+ */
109
+ declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
110
+ /**
111
+ * @internal
112
+ */
113
+ declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPI.MediaTypeObject>;
114
+ /**
115
+ * @internal
116
+ */
117
+ declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPI.ParameterObject[];
118
+ /**
119
+ * @internal
120
+ */
121
+ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
122
+ /**
123
+ * @internal
124
+ */
125
+ declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
126
+ declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
127
+
128
+ /**
129
+ *@internal
130
+ */
131
+ declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
132
+ /**
133
+ * @internal
134
+ */
135
+ declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
136
+ /**
137
+ * @internal
138
+ */
139
+ declare function isAnySchema(schema: JSONSchema): boolean;
140
+ /**
141
+ * @internal
142
+ */
143
+ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
144
+ /**
145
+ * @internal
146
+ */
147
+ declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
148
+ declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
149
+ /**
150
+ * Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),
151
+ * recursively expands it into an array of its constituent, non-union base schemas.
152
+ * If the schema is not a simple union or is a base type, it's returned as a single-element array.
153
+ */
154
+ declare function expandUnionSchema(schema: JSONSchema): JSONSchema[];
155
+ declare function expandArrayableSchema(schema: JSONSchema): undefined | [items: JSONSchema, array: JSONSchema & {
156
+ type: 'array';
157
+ items?: JSONSchema;
158
+ }];
159
+ declare function isPrimitiveSchema(schema: JSONSchema): boolean;
160
+
161
+ declare const oo: {
162
+ spec: typeof customOpenAPIOperation;
163
+ };
164
+
165
+ export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, generateOpenApiSpec, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
166
+ export type { FileSchema, ObjectSchema, OpenAPIGeneratorGenerateOptions, OverrideOperationValue, SchemaConvertOptions, SchemaConverter, SchemaConverterComponent };