hono-takibi 0.0.1

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 (88) hide show
  1. package/README.md +471 -0
  2. package/dist/core/schema/references/find-references.d.ts +35 -0
  3. package/dist/core/schema/references/find-references.js +42 -0
  4. package/dist/core/schema/references/get-camel-case-schema-name.d.ts +7 -0
  5. package/dist/core/schema/references/get-camel-case-schema-name.js +14 -0
  6. package/dist/core/schema/references/get-ref-name.d.ts +38 -0
  7. package/dist/core/schema/references/get-ref-name.js +47 -0
  8. package/dist/core/schema/references/resolve-schema-order.d.ts +30 -0
  9. package/dist/core/schema/references/resolve-schema-order.js +48 -0
  10. package/dist/core/schema/references/resolve-schema-references.d.ts +49 -0
  11. package/dist/core/schema/references/resolve-schema-references.js +61 -0
  12. package/dist/core/schema/references/resolve-schemas-dependencies.d.ts +49 -0
  13. package/dist/core/schema/references/resolve-schemas-dependencies.js +65 -0
  14. package/dist/core/schema/references/traverse_schema.d.ts +48 -0
  15. package/dist/core/schema/references/traverse_schema.js +70 -0
  16. package/dist/core/text/capitalize.d.ts +18 -0
  17. package/dist/core/text/capitalize.js +23 -0
  18. package/dist/core/text/decapitalize.d.ts +17 -0
  19. package/dist/core/text/decapitalize.js +22 -0
  20. package/dist/core/text/remove-zod-prefix.d.ts +8 -0
  21. package/dist/core/text/remove-zod-prefix.js +13 -0
  22. package/dist/core/validator/is-format-number.d.ts +2 -0
  23. package/dist/core/validator/is-format-number.js +6 -0
  24. package/dist/core/validator/is-format-string.d.ts +2 -0
  25. package/dist/core/validator/is-format-string.js +24 -0
  26. package/dist/core/validator/is-http-method.d.ts +9 -0
  27. package/dist/core/validator/is-http-method.js +19 -0
  28. package/dist/core/validator/is-operation.d.ts +15 -0
  29. package/dist/core/validator/is-operation.js +19 -0
  30. package/dist/core/zod/get-zod-string-format.d.ts +30 -0
  31. package/dist/core/zod/get-zod-string-format.js +66 -0
  32. package/dist/generators/hono/generate-hono.d.ts +9 -0
  33. package/dist/generators/hono/generate-hono.js +29 -0
  34. package/dist/generators/openapi/components/generate-components-code.d.ts +46 -0
  35. package/dist/generators/openapi/components/generate-components-code.js +79 -0
  36. package/dist/generators/openapi/paths/generate-create-route.d.ts +58 -0
  37. package/dist/generators/openapi/paths/generate-create-route.js +61 -0
  38. package/dist/generators/openapi/paths/generate-route-code.d.ts +53 -0
  39. package/dist/generators/openapi/paths/generate-route-code.js +85 -0
  40. package/dist/generators/openapi/paths/generate-route-name.d.ts +30 -0
  41. package/dist/generators/openapi/paths/generate-route-name.js +48 -0
  42. package/dist/generators/openapi/paths/generate-route.d.ts +51 -0
  43. package/dist/generators/openapi/paths/generate-route.js +73 -0
  44. package/dist/generators/openapi/paths/generate-schemas-export.d.ts +11 -0
  45. package/dist/generators/openapi/paths/generate-schemas-export.js +18 -0
  46. package/dist/generators/request/body/generate-insert-request-body.d.ts +32 -0
  47. package/dist/generators/request/body/generate-insert-request-body.js +37 -0
  48. package/dist/generators/request/body/generate-request-body.d.ts +18 -0
  49. package/dist/generators/request/body/generate-request-body.js +23 -0
  50. package/dist/generators/request/object/generate-format-request-object.d.ts +29 -0
  51. package/dist/generators/request/object/generate-format-request-object.js +34 -0
  52. package/dist/generators/request/params/generate-params-object.d.ts +62 -0
  53. package/dist/generators/request/params/generate-params-object.js +93 -0
  54. package/dist/generators/request/params/generate-request-parameter.d.ts +49 -0
  55. package/dist/generators/request/params/generate-request-parameter.js +79 -0
  56. package/dist/generators/request/params/generate-request-params-array.d.ts +37 -0
  57. package/dist/generators/request/params/generate-request-params-array.js +56 -0
  58. package/dist/generators/request/params/generate-request-params.d.ts +34 -0
  59. package/dist/generators/request/params/generate-request-params.js +39 -0
  60. package/dist/generators/response/schemas/generate-response-schema.d.ts +59 -0
  61. package/dist/generators/response/schemas/generate-response-schema.js +83 -0
  62. package/dist/generators/zod/generate-zod-array.d.ts +31 -0
  63. package/dist/generators/zod/generate-zod-array.js +36 -0
  64. package/dist/generators/zod/generate-zod-coerce.d.ts +10 -0
  65. package/dist/generators/zod/generate-zod-coerce.js +17 -0
  66. package/dist/generators/zod/generate-zod-integer-schema.d.ts +15 -0
  67. package/dist/generators/zod/generate-zod-integer-schema.js +24 -0
  68. package/dist/generators/zod/generate-zod-number-schema.d.ts +16 -0
  69. package/dist/generators/zod/generate-zod-number-schema.js +26 -0
  70. package/dist/generators/zod/generate-zod-object-schema.d.ts +36 -0
  71. package/dist/generators/zod/generate-zod-object-schema.js +43 -0
  72. package/dist/generators/zod/generate-zod-properties-schema.d.ts +50 -0
  73. package/dist/generators/zod/generate-zod-properties-schema.js +60 -0
  74. package/dist/generators/zod/generate-zod-property-schema.d.ts +25 -0
  75. package/dist/generators/zod/generate-zod-property-schema.js +47 -0
  76. package/dist/generators/zod/generate-zod-record-schema.d.ts +34 -0
  77. package/dist/generators/zod/generate-zod-record-schema.js +37 -0
  78. package/dist/generators/zod/generate-zod-schema-definition.d.ts +22 -0
  79. package/dist/generators/zod/generate-zod-schema-definition.js +27 -0
  80. package/dist/generators/zod/generate-zod-schema.d.ts +59 -0
  81. package/dist/generators/zod/generate-zod-schema.js +136 -0
  82. package/dist/generators/zod/generate-zod-string-schema.d.ts +46 -0
  83. package/dist/generators/zod/generate-zod-string-schema.js +54 -0
  84. package/dist/index.d.ts +20 -0
  85. package/dist/index.js +85 -0
  86. package/dist/types/index.d.ts +170 -0
  87. package/dist/types/index.js +2 -0
  88. package/package.json +47 -0
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveSchemaOrder = resolveSchemaOrder;
4
+ /**
5
+ * Resolves the order of schema processing based on their dependencies using depth-first search
6
+ *
7
+ * @function resolveSchemaOrder
8
+ * @param name - The name of the current schema to process
9
+ * @param dependencies - Map of schema names to their dependent schema names
10
+ * @param visited - Set of schema names that have been processed
11
+ * @param ordered - Array to store the resolved order of schema names
12
+ * @returns void
13
+ *
14
+ * @example
15
+ * const dependencies = new Map([
16
+ * ['User', new Set(['Address'])],
17
+ * ['Address', new Set(['Country'])],
18
+ * ['Country', new Set()]
19
+ * ])
20
+ *
21
+ * const visited = new Set<string>()
22
+ * const ordered: string[] = []
23
+ *
24
+ * resolveSchemaOrder('User', dependencies, visited, ordered)
25
+ * // ordered will be: ['Country', 'Address', 'User']
26
+ *
27
+ * @note
28
+ * - Uses depth-first search to resolve dependencies
29
+ * - Prevents circular references by tracking visited schemas
30
+ * - Ensures dependent schemas appear before schemas that depend on them
31
+ * - Modifies the ordered array in-place to build the final sequence
32
+ */
33
+ function resolveSchemaOrder(name, dependencies, visited, ordered) {
34
+ // 1. circulation reference prevention check
35
+ if (visited.has(name))
36
+ return;
37
+ // 2. mark current schema as visited
38
+ visited.add(name);
39
+ // 3. get dependencies of current schema
40
+ const deps = dependencies.get(name);
41
+ if (deps) {
42
+ for (const dep of deps) {
43
+ resolveSchemaOrder(dep, dependencies, visited, ordered);
44
+ }
45
+ }
46
+ // 4. add current schema to ordered list
47
+ ordered.push(name);
48
+ }
@@ -0,0 +1,49 @@
1
+ import type { Schema } from '../../../types';
2
+ /**
3
+ * Creates a dependency map for all schemas and their references in an OpenAPI specification
4
+ *
5
+ * @function resolveSchemaReferences
6
+ * @param schemas - Record mapping schema names to their Schema objects
7
+ * @returns A Map where keys are schema names and values are Sets of referenced schema names
8
+ *
9
+ * @example
10
+ * const schemas = {
11
+ * User: {
12
+ * type: 'object',
13
+ * properties: {
14
+ * profile: { $ref: '#/components/schemas/Profile' },
15
+ * addresses: {
16
+ * type: 'array',
17
+ * items: { $ref: '#/components/schemas/Address' }
18
+ * }
19
+ * }
20
+ * },
21
+ * Profile: {
22
+ * type: 'object',
23
+ * properties: {
24
+ * name: { type: 'string' }
25
+ * }
26
+ * },
27
+ * Address: {
28
+ * type: 'object',
29
+ * properties: {
30
+ * street: { type: 'string' }
31
+ * }
32
+ * }
33
+ * }
34
+ *
35
+ * const dependencies = resolveSchemaReferences(schemas)
36
+ * // dependencies contains:
37
+ * // Map {
38
+ * // 'User' => Set { 'Profile', 'Address' },
39
+ * // 'Profile' => Set {},
40
+ * // 'Address' => Set {}
41
+ * // }
42
+ *
43
+ * @note
44
+ * - Creates a complete dependency graph for all schemas
45
+ * - Handles nested references in arrays and objects
46
+ * - Empty Sets indicate schemas with no dependencies
47
+ * - Used for determining the correct order of schema generation
48
+ */
49
+ export declare function resolveSchemaReferences(schemas: Record<string, Schema>): Map<string, Set<string>>;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveSchemaReferences = resolveSchemaReferences;
4
+ const find_references_1 = require("./find-references");
5
+ /**
6
+ * Creates a dependency map for all schemas and their references in an OpenAPI specification
7
+ *
8
+ * @function resolveSchemaReferences
9
+ * @param schemas - Record mapping schema names to their Schema objects
10
+ * @returns A Map where keys are schema names and values are Sets of referenced schema names
11
+ *
12
+ * @example
13
+ * const schemas = {
14
+ * User: {
15
+ * type: 'object',
16
+ * properties: {
17
+ * profile: { $ref: '#/components/schemas/Profile' },
18
+ * addresses: {
19
+ * type: 'array',
20
+ * items: { $ref: '#/components/schemas/Address' }
21
+ * }
22
+ * }
23
+ * },
24
+ * Profile: {
25
+ * type: 'object',
26
+ * properties: {
27
+ * name: { type: 'string' }
28
+ * }
29
+ * },
30
+ * Address: {
31
+ * type: 'object',
32
+ * properties: {
33
+ * street: { type: 'string' }
34
+ * }
35
+ * }
36
+ * }
37
+ *
38
+ * const dependencies = resolveSchemaReferences(schemas)
39
+ * // dependencies contains:
40
+ * // Map {
41
+ * // 'User' => Set { 'Profile', 'Address' },
42
+ * // 'Profile' => Set {},
43
+ * // 'Address' => Set {}
44
+ * // }
45
+ *
46
+ * @note
47
+ * - Creates a complete dependency graph for all schemas
48
+ * - Handles nested references in arrays and objects
49
+ * - Empty Sets indicate schemas with no dependencies
50
+ * - Used for determining the correct order of schema generation
51
+ */
52
+ function resolveSchemaReferences(schemas) {
53
+ // 1. initialize dependencies map
54
+ const dependencies = new Map();
55
+ // 2. resolve each schema reference
56
+ for (const [name, schema] of Object.entries(schemas)) {
57
+ dependencies.set(name, (0, find_references_1.findReferences)(schema));
58
+ }
59
+ // 3. return dependencies map
60
+ return dependencies;
61
+ }
@@ -0,0 +1,49 @@
1
+ import type { Schema } from '../../../types';
2
+ /**
3
+ * Resolves dependencies between schemas and returns them in topological order for safe processing
4
+ *
5
+ * @function resolveSchemasDependencies
6
+ * @param schemas - Record mapping schema names to their Schema objects
7
+ * @returns Array of schema names ordered by their dependencies
8
+ *
9
+ * @example
10
+ * const schemas = {
11
+ * User: {
12
+ * type: 'object',
13
+ * properties: {
14
+ * profile: { $ref: '#/components/schemas/Profile' },
15
+ * settings: { $ref: '#/components/schemas/Settings' }
16
+ * }
17
+ * },
18
+ * Profile: {
19
+ * type: 'object',
20
+ * properties: {
21
+ * address: { $ref: '#/components/schemas/Address' }
22
+ * }
23
+ * },
24
+ * Settings: {
25
+ * type: 'object',
26
+ * properties: {
27
+ * theme: { type: 'string' }
28
+ * }
29
+ * },
30
+ * Address: {
31
+ * type: 'object',
32
+ * properties: {
33
+ * street: { type: 'string' }
34
+ * }
35
+ * }
36
+ * }
37
+ *
38
+ * const orderedSchemas = resolveSchemasDependencies(schemas)
39
+ * // Returns: ['Address', 'Profile', 'Settings', 'User']
40
+ *
41
+ * @note
42
+ * - Performs topological sorting of schemas based on their dependencies
43
+ * - Ensures each schema appears after all its dependencies
44
+ * - Handles multi-level dependency chains correctly
45
+ * - Essential for generating valid code where dependent types must be defined first
46
+ * - Uses depth-first search for dependency resolution
47
+ * - Automatically handles circular dependencies by preventing infinite recursion
48
+ */
49
+ export declare function resolveSchemasDependencies(schemas: Record<string, Schema>): string[];
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveSchemasDependencies = resolveSchemasDependencies;
4
+ const resolve_schema_order_1 = require("./resolve-schema-order");
5
+ const resolve_schema_references_1 = require("./resolve-schema-references");
6
+ /**
7
+ * Resolves dependencies between schemas and returns them in topological order for safe processing
8
+ *
9
+ * @function resolveSchemasDependencies
10
+ * @param schemas - Record mapping schema names to their Schema objects
11
+ * @returns Array of schema names ordered by their dependencies
12
+ *
13
+ * @example
14
+ * const schemas = {
15
+ * User: {
16
+ * type: 'object',
17
+ * properties: {
18
+ * profile: { $ref: '#/components/schemas/Profile' },
19
+ * settings: { $ref: '#/components/schemas/Settings' }
20
+ * }
21
+ * },
22
+ * Profile: {
23
+ * type: 'object',
24
+ * properties: {
25
+ * address: { $ref: '#/components/schemas/Address' }
26
+ * }
27
+ * },
28
+ * Settings: {
29
+ * type: 'object',
30
+ * properties: {
31
+ * theme: { type: 'string' }
32
+ * }
33
+ * },
34
+ * Address: {
35
+ * type: 'object',
36
+ * properties: {
37
+ * street: { type: 'string' }
38
+ * }
39
+ * }
40
+ * }
41
+ *
42
+ * const orderedSchemas = resolveSchemasDependencies(schemas)
43
+ * // Returns: ['Address', 'Profile', 'Settings', 'User']
44
+ *
45
+ * @note
46
+ * - Performs topological sorting of schemas based on their dependencies
47
+ * - Ensures each schema appears after all its dependencies
48
+ * - Handles multi-level dependency chains correctly
49
+ * - Essential for generating valid code where dependent types must be defined first
50
+ * - Uses depth-first search for dependency resolution
51
+ * - Automatically handles circular dependencies by preventing infinite recursion
52
+ */
53
+ function resolveSchemasDependencies(schemas) {
54
+ // 1. get schema reference relations as a map
55
+ const dependencies = (0, resolve_schema_references_1.resolveSchemaReferences)(schemas);
56
+ // 2. initialize ordered list and visited set
57
+ const ordered = [];
58
+ const visited = new Set();
59
+ // 3. resolve schema order
60
+ for (const name of Object.keys(schemas)) {
61
+ (0, resolve_schema_order_1.resolveSchemaOrder)(name, dependencies, visited, ordered);
62
+ }
63
+ // 4. return ordered list
64
+ return ordered;
65
+ }
@@ -0,0 +1,48 @@
1
+ import type { Schema } from '../../../types';
2
+ /**
3
+ * Recursively traverses an OpenAPI schema to collect all $ref references
4
+ *
5
+ * @function traverseSchema
6
+ * @param schema - The OpenAPI schema object to traverse
7
+ * @param refs - Set to collect found reference names
8
+ *
9
+ * @example
10
+ * const refs = new Set<string>()
11
+ * const schema = {
12
+ * type: 'object',
13
+ * properties: {
14
+ * user: {
15
+ * $ref: '#/components/schemas/User'
16
+ * },
17
+ * orders: {
18
+ * type: 'array',
19
+ * items: {
20
+ * $ref: '#/components/schemas/Order'
21
+ * }
22
+ * },
23
+ * address: {
24
+ * type: 'object',
25
+ * properties: {
26
+ * country: {
27
+ * $ref: '#/components/schemas/Country'
28
+ * }
29
+ * }
30
+ * }
31
+ * }
32
+ * }
33
+ *
34
+ * traverseSchema(schema, refs)
35
+ * // refs contains: Set { 'User', 'Order', 'Country' }
36
+ *
37
+ * @note
38
+ * - Mutates the provided refs Set by adding found references
39
+ * - Handles nested references in:
40
+ * - Object properties
41
+ * - Array items
42
+ * - Nested objects
43
+ * - Skips invalid or non-object schemas
44
+ * - Extracts only the schema name from $ref paths
45
+ * (e.g., '#/components/schemas/User' → 'User')
46
+ * - Performs depth-first traversal of the schema structure
47
+ */
48
+ export declare function traverseSchema(schema: Schema, refs: Set<string>): void;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.traverseSchema = traverseSchema;
4
+ const get_ref_name_1 = require("./get-ref-name");
5
+ /**
6
+ * Recursively traverses an OpenAPI schema to collect all $ref references
7
+ *
8
+ * @function traverseSchema
9
+ * @param schema - The OpenAPI schema object to traverse
10
+ * @param refs - Set to collect found reference names
11
+ *
12
+ * @example
13
+ * const refs = new Set<string>()
14
+ * const schema = {
15
+ * type: 'object',
16
+ * properties: {
17
+ * user: {
18
+ * $ref: '#/components/schemas/User'
19
+ * },
20
+ * orders: {
21
+ * type: 'array',
22
+ * items: {
23
+ * $ref: '#/components/schemas/Order'
24
+ * }
25
+ * },
26
+ * address: {
27
+ * type: 'object',
28
+ * properties: {
29
+ * country: {
30
+ * $ref: '#/components/schemas/Country'
31
+ * }
32
+ * }
33
+ * }
34
+ * }
35
+ * }
36
+ *
37
+ * traverseSchema(schema, refs)
38
+ * // refs contains: Set { 'User', 'Order', 'Country' }
39
+ *
40
+ * @note
41
+ * - Mutates the provided refs Set by adding found references
42
+ * - Handles nested references in:
43
+ * - Object properties
44
+ * - Array items
45
+ * - Nested objects
46
+ * - Skips invalid or non-object schemas
47
+ * - Extracts only the schema name from $ref paths
48
+ * (e.g., '#/components/schemas/User' → 'User')
49
+ * - Performs depth-first traversal of the schema structure
50
+ */
51
+ function traverseSchema(schema, refs) {
52
+ // 1. input check
53
+ if (!schema || typeof schema !== 'object')
54
+ return;
55
+ // 2. $ref process
56
+ if (schema.$ref) {
57
+ const ref = (0, get_ref_name_1.getRefName)(schema.$ref);
58
+ if (ref)
59
+ refs.add(ref);
60
+ }
61
+ // 3. recursive property search
62
+ if (schema.properties) {
63
+ for (const property of Object.values(schema.properties)) {
64
+ traverseSchema(property, refs);
65
+ }
66
+ }
67
+ // 4. recursive items search
68
+ if (schema.items)
69
+ traverseSchema(schema.items, refs);
70
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Capitalizes the first letter of a string
3
+ *
4
+ * @function capitalize
5
+ * @param str - String to capitalize
6
+ * @returns String with first letter capitalized
7
+ *
8
+ * @example
9
+ * capitalize('posts') // Returns: 'Posts'
10
+ * capitalize('user') // Returns: 'User'
11
+ * capitalize('api') // Returns: 'Api'
12
+ *
13
+ * @remarks
14
+ * - Leaves rest of the string unchanged
15
+ * - Returns empty string if input is empty
16
+ * - Commonly used for generating type names and class names
17
+ */
18
+ export declare function capitalize(str: string): string;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.capitalize = capitalize;
4
+ /**
5
+ * Capitalizes the first letter of a string
6
+ *
7
+ * @function capitalize
8
+ * @param str - String to capitalize
9
+ * @returns String with first letter capitalized
10
+ *
11
+ * @example
12
+ * capitalize('posts') // Returns: 'Posts'
13
+ * capitalize('user') // Returns: 'User'
14
+ * capitalize('api') // Returns: 'Api'
15
+ *
16
+ * @remarks
17
+ * - Leaves rest of the string unchanged
18
+ * - Returns empty string if input is empty
19
+ * - Commonly used for generating type names and class names
20
+ */
21
+ function capitalize(str) {
22
+ return `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
23
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Decapitalizes the first letter of a string
3
+ *
4
+ * @function decapitalize
5
+ * @param str - String to decapitalize
6
+ * @returns String with the first letter in lowercase
7
+ *
8
+ * @example
9
+ * decapitalize('Posts') // Returns: 'posts'
10
+ * decapitalize('User') // Returns: 'user'
11
+ * decapitalize('Api') // Returns: 'api'
12
+ *
13
+ * @remarks
14
+ * - Leaves the rest of the string unchanged
15
+ * - Returns an empty string if the input is empty
16
+ */
17
+ export declare function decapitalize(str: string): string;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decapitalize = decapitalize;
4
+ /**
5
+ * Decapitalizes the first letter of a string
6
+ *
7
+ * @function decapitalize
8
+ * @param str - String to decapitalize
9
+ * @returns String with the first letter in lowercase
10
+ *
11
+ * @example
12
+ * decapitalize('Posts') // Returns: 'posts'
13
+ * decapitalize('User') // Returns: 'user'
14
+ * decapitalize('Api') // Returns: 'api'
15
+ *
16
+ * @remarks
17
+ * - Leaves the rest of the string unchanged
18
+ * - Returns an empty string if the input is empty
19
+ */
20
+ function decapitalize(str) {
21
+ return `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
22
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Removes the zod prefix from a zod schema.
3
+ *
4
+ * @function removeZodPrefix
5
+ * @param zodSchema - The zod schema to remove the prefix from.
6
+ * @returns The zod schema without the prefix.
7
+ */
8
+ export declare function removeZodPrefix(zodSchema: string): string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeZodPrefix = removeZodPrefix;
4
+ /**
5
+ * Removes the zod prefix from a zod schema.
6
+ *
7
+ * @function removeZodPrefix
8
+ * @param zodSchema - The zod schema to remove the prefix from.
9
+ * @returns The zod schema without the prefix.
10
+ */
11
+ function removeZodPrefix(zodSchema) {
12
+ return zodSchema.replace('z.', '');
13
+ }
@@ -0,0 +1,2 @@
1
+ import type { Format, FormatNumber } from '../../types';
2
+ export declare function isFormatNumber(format: Format): format is FormatNumber;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isFormatNumber = isFormatNumber;
4
+ function isFormatNumber(format) {
5
+ return ['int32', 'int64', 'float', 'double'].includes(format);
6
+ }
@@ -0,0 +1,2 @@
1
+ import type { Format, FormatString } from '../../types';
2
+ export declare function isFormatString(format: Format): format is FormatString;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isFormatString = isFormatString;
4
+ function isFormatString(format) {
5
+ return [
6
+ 'email',
7
+ 'uri',
8
+ 'emoji',
9
+ 'uuid',
10
+ 'cuid',
11
+ 'cuid2',
12
+ 'ulid',
13
+ 'date-time',
14
+ 'ip',
15
+ 'cidr',
16
+ 'trim',
17
+ 'toLowerCase',
18
+ 'toUpperCase',
19
+ 'date',
20
+ 'time',
21
+ 'duration',
22
+ 'base64',
23
+ ].includes(format);
24
+ }
@@ -0,0 +1,9 @@
1
+ import type { HttpMethod } from '../../types';
2
+ /**
3
+ * Type guard function to check if a string is a valid HTTP method
4
+ *
5
+ * @function
6
+ * @param method - The string to check against valid HTTP methods
7
+ * @returns True if the string is a valid HTTP method, with type narrowing to HttpMethod
8
+ */
9
+ export declare function isHttpMethod(method: string): method is HttpMethod;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isHttpMethod = isHttpMethod;
4
+ /**
5
+ * Type guard function to check if a string is a valid HTTP method
6
+ *
7
+ * @function
8
+ * @param method - The string to check against valid HTTP methods
9
+ * @returns True if the string is a valid HTTP method, with type narrowing to HttpMethod
10
+ */
11
+ function isHttpMethod(method) {
12
+ return (method === 'get' ||
13
+ method === 'post' ||
14
+ method === 'put' ||
15
+ method === 'delete' ||
16
+ method === 'patch' ||
17
+ method === 'options' ||
18
+ method === 'head');
19
+ }
@@ -0,0 +1,15 @@
1
+ import type { Operation } from '../../types';
2
+ /**
3
+ * Type guard function to check if an object is an Operation
4
+ *
5
+ * @function isOperation
6
+ * @param obj - The object to check
7
+ * @returns True if the object is an Operation, with type narrowing support
8
+ *
9
+ * @note Consider using `unknown` type instead of `Operation` for better type guarding:
10
+ * ```typescript
11
+ * function isOperation(obj: unknown): obj is Operation
12
+ * ```
13
+ * This would provide more strict type checking for arbitrary values.
14
+ */
15
+ export declare function isOperation(obj: Operation): obj is Operation;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isOperation = isOperation;
4
+ /**
5
+ * Type guard function to check if an object is an Operation
6
+ *
7
+ * @function isOperation
8
+ * @param obj - The object to check
9
+ * @returns True if the object is an Operation, with type narrowing support
10
+ *
11
+ * @note Consider using `unknown` type instead of `Operation` for better type guarding:
12
+ * ```typescript
13
+ * function isOperation(obj: unknown): obj is Operation
14
+ * ```
15
+ * This would provide more strict type checking for arbitrary values.
16
+ */
17
+ function isOperation(obj) {
18
+ return obj && typeof obj === 'object' && 'responses' in obj;
19
+ }
@@ -0,0 +1,30 @@
1
+ import type { FormatString } from '../../types';
2
+ /**
3
+ * Converts OpenAPI format to Zod validation method
4
+ *
5
+ * @function getZodFormatString
6
+ * @param format - OpenAPI format type
7
+ * @returns Zod validation method string
8
+ *
9
+ * @example
10
+ * // String validations
11
+ * getZodFormatString('email') // Returns: '.email()'
12
+ * getZodFormatString('uri') // Returns: '.url()'
13
+ * getZodFormatString('uuid') // Returns: '.uuid()'
14
+ * getZodFormatString('date-time') // Returns: '.datetime()'
15
+ *
16
+ * @example
17
+ * // Number types
18
+ * getZodFormatString('int32') // Returns: 'z.number()'
19
+ * getZodFormatString('float') // Returns: 'z.number()'
20
+ *
21
+ * @example
22
+ * // Unknown format
23
+ * getZodFormatString('unknown') // Returns: ''
24
+ *
25
+ * @remarks
26
+ * - Returns the corresponding Zod validation method for known formats
27
+ * - Returns empty string for unrecognized formats
28
+ * - Used in schema generation for request/response validation
29
+ */
30
+ export declare function getZodFormatString(format: FormatString): string;