hono-takibi 0.6.4 → 0.6.5
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.
- package/LICENSE +21 -0
- package/dist/config/index.js +6 -13
- package/dist/core/helper/get-camel-case-schema-name-helper.js +3 -6
- package/dist/core/helper/get-pascal-case-schema-name-helper.js +3 -6
- package/dist/core/helper/get-to-safe-identifier-helper.js +3 -6
- package/dist/core/helper/get-variable-name-helper.js +4 -7
- package/dist/core/helper/get-variable-schema-name-helper.js +5 -8
- package/dist/core/schema/references/extract-refs.js +4 -7
- package/dist/core/schema/references/find-references.js +3 -6
- package/dist/core/schema/references/get-ref-name.js +1 -4
- package/dist/core/schema/references/get-ref-schema-name.js +5 -8
- package/dist/core/schema/references/resolve-schemas-dependencies.js +3 -6
- package/dist/core/schema/references/traverse-schema-dependencies.js +3 -6
- package/dist/core/schema/references/traverse-schema.js +3 -6
- package/dist/core/text/capitalize.js +3 -6
- package/dist/core/text/decapitalize.js +3 -6
- package/dist/core/text/escape-str.js +3 -6
- package/dist/core/text/regex-pattern.js +3 -6
- package/dist/core/text/remove-zod-prefix.js +3 -6
- package/dist/core/validator/is-all-optional.js +3 -6
- package/dist/core/validator/is-array-with-schema-reference.js +3 -6
- package/dist/core/validator/is-format-number.js +1 -4
- package/dist/core/validator/is-format-string.js +3 -6
- package/dist/core/validator/is-http-method.js +3 -6
- package/dist/core/validator/is-nullable-schema.js +3 -6
- package/dist/core/validator/is-operation.js +3 -6
- package/dist/core/validator/is-ref-object.js +3 -6
- package/dist/core/validator/is-schema-reference.js +3 -6
- package/dist/core/validator/is-unique-content-schema.js +4 -7
- package/dist/core/zod/get-zod-string-format.js +1 -4
- package/dist/format/index.js +3 -6
- package/dist/generator/zod/generate-zod-array.js +1 -4
- package/dist/generator/zod/generate-zod-coerce.js +3 -6
- package/dist/generator/zod/generate-zod-default.js +1 -4
- package/dist/generator/zod/generate-zod-enum.js +3 -6
- package/dist/generator/zod/generate-zod-gt.js +1 -4
- package/dist/generator/zod/generate-zod-infer.js +1 -4
- package/dist/generator/zod/generate-zod-integer-schema.js +13 -16
- package/dist/generator/zod/generate-zod-intersection.js +1 -4
- package/dist/generator/zod/generate-zod-length.js +1 -4
- package/dist/generator/zod/generate-zod-lt.js +1 -4
- package/dist/generator/zod/generate-zod-max.js +1 -4
- package/dist/generator/zod/generate-zod-min.js +1 -4
- package/dist/generator/zod/generate-zod-nullable.js +1 -4
- package/dist/generator/zod/generate-zod-number.js +17 -20
- package/dist/generator/zod/generate-zod-object-schema.js +1 -4
- package/dist/generator/zod/generate-zod-object.js +14 -17
- package/dist/generator/zod/generate-zod-partial-schema.js +1 -4
- package/dist/generator/zod/generate-zod-passthrough.js +1 -4
- package/dist/generator/zod/generate-zod-record.js +3 -6
- package/dist/generator/zod/generate-zod-regex.js +3 -6
- package/dist/generator/zod/generate-zod-string.js +15 -18
- package/dist/generator/zod/generate-zod-union.js +1 -4
- package/dist/generator/zod/generate-zod.js +46 -50
- package/dist/generator/zod/helper/strip-max-if-lt-exist-helper.js +1 -4
- package/dist/generator/zod/helper/strip-min-if-gt-exist-helper.js +1 -4
- package/dist/generator/zod/helper/strip-min-max-exist-helper.js +1 -4
- package/dist/generator/zod/openapi/generate-zod-to-openapi-schema-definition.js +7 -10
- package/dist/generator/zod/openapi/generate-zod-to-openapi.js +1 -4
- package/dist/generator/zod/property/generate-zod-properties-schema.js +10 -13
- package/dist/generator/zod/property/generate-zod-property-schema.js +11 -14
- package/dist/generator/zod/reference/generate-array-reference-schema.js +9 -12
- package/dist/generator/zod/reference/generate-reference-schema.js +5 -8
- package/dist/generator/zod/sub/generate-zod-schema-from-sub-schema.js +4 -7
- package/dist/generator/zod-openapi-hono/app/docs/generate-docs.js +1 -4
- package/dist/generator/zod-openapi-hono/app/generate-app-route-handler.js +1 -4
- package/dist/generator/zod-openapi-hono/app/generators/generate-apply-openapi-routes.js +3 -6
- package/dist/generator/zod-openapi-hono/app/generators/generate-import-routes.js +1 -4
- package/dist/generator/zod-openapi-hono/app/helper/get-route-maps.js +5 -8
- package/dist/generator/zod-openapi-hono/app/helper/process-import-map.js +1 -4
- package/dist/generator/zod-openapi-hono/app/index.js +17 -20
- package/dist/generator/zod-openapi-hono/app/register-component/generate-register-component.js +1 -4
- package/dist/generator/zod-openapi-hono/handler/generate-handler-name.js +3 -6
- package/dist/generator/zod-openapi-hono/handler/generate-handler.js +1 -4
- package/dist/generator/zod-openapi-hono/handler/generate-zod-openapi-hono-handler.js +15 -21
- package/dist/generator/zod-openapi-hono/handler/helper/group-handlers-by-file-name-helper.js +1 -4
- package/dist/generator/zod-openapi-hono/handler/import/generate-import-handlers.js +1 -4
- package/dist/generator/zod-openapi-hono/handler/import/get-handler-imports.js +1 -4
- package/dist/generator/zod-openapi-hono/openapi/component/allof/generate-allof-code.js +5 -8
- package/dist/generator/zod-openapi-hono/openapi/component/allof/process/process-alllof.js +5 -8
- package/dist/generator/zod-openapi-hono/openapi/component/anyof/generate-anyof-code.js +7 -10
- package/dist/generator/zod-openapi-hono/openapi/component/generate-components-code.js +7 -10
- package/dist/generator/zod-openapi-hono/openapi/component/not/generate-not-code.js +1 -4
- package/dist/generator/zod-openapi-hono/openapi/component/oneof/generate-oneof-code.js +7 -10
- package/dist/generator/zod-openapi-hono/openapi/generate-zod-openapi-hono.js +5 -8
- package/dist/generator/zod-openapi-hono/openapi/route/generate-create-route.js +1 -4
- package/dist/generator/zod-openapi-hono/openapi/route/generate-route-code.js +7 -10
- package/dist/generator/zod-openapi-hono/openapi/route/generate-route-name.js +3 -6
- package/dist/generator/zod-openapi-hono/openapi/route/generate-route.js +12 -15
- package/dist/generator/zod-openapi-hono/openapi/route/params/generate-params-object.js +6 -9
- package/dist/generator/zod-openapi-hono/openapi/route/params/generate-request-parameter.js +15 -18
- package/dist/generator/zod-openapi-hono/openapi/route/params/generate-request-params-array.js +3 -6
- package/dist/generator/zod-openapi-hono/openapi/route/params/generate-request-params.js +1 -4
- package/dist/generator/zod-openapi-hono/openapi/route/request/body/generate-insert-request-body.js +1 -4
- package/dist/generator/zod-openapi-hono/openapi/route/request/body/generate-request-body.js +3 -6
- package/dist/generator/zod-openapi-hono/openapi/route/request/object/generate-format-request-object.js +1 -4
- package/dist/generator/zod-openapi-hono/openapi/route/response/generate-response-schema.js +8 -11
- package/dist/index.js +29 -37
- package/dist/types/index.js +1 -0
- package/dist/vite-plugin/index.js +5 -8
- package/dist/vite-plugin/vite-mode.js +14 -20
- package/package.json +13 -12
- package/dist/config/index.d.ts +0 -18
- package/dist/core/helper/get-camel-case-schema-name-helper.d.ts +0 -6
- package/dist/core/helper/get-pascal-case-schema-name-helper.d.ts +0 -6
- package/dist/core/helper/get-to-safe-identifier-helper.d.ts +0 -6
- package/dist/core/helper/get-variable-name-helper.d.ts +0 -8
- package/dist/core/helper/get-variable-schema-name-helper.d.ts +0 -8
- package/dist/core/schema/references/extract-refs.d.ts +0 -7
- package/dist/core/schema/references/find-references.d.ts +0 -25
- package/dist/core/schema/references/get-ref-name.d.ts +0 -33
- package/dist/core/schema/references/get-ref-schema-name.d.ts +0 -10
- package/dist/core/schema/references/resolve-schemas-dependencies.d.ts +0 -59
- package/dist/core/schema/references/traverse-schema-dependencies.d.ts +0 -10
- package/dist/core/schema/references/traverse-schema.d.ts +0 -45
- package/dist/core/text/capitalize.d.ts +0 -16
- package/dist/core/text/decapitalize.d.ts +0 -15
- package/dist/core/text/escape-str.d.ts +0 -6
- package/dist/core/text/regex-pattern.d.ts +0 -6
- package/dist/core/text/remove-zod-prefix.d.ts +0 -6
- package/dist/core/validator/is-all-optional.d.ts +0 -6
- package/dist/core/validator/is-array-with-schema-reference.d.ts +0 -7
- package/dist/core/validator/is-format-number.d.ts +0 -7
- package/dist/core/validator/is-format-string.d.ts +0 -7
- package/dist/core/validator/is-http-method.d.ts +0 -7
- package/dist/core/validator/is-nullable-schema.d.ts +0 -7
- package/dist/core/validator/is-operation.d.ts +0 -13
- package/dist/core/validator/is-ref-object.d.ts +0 -11
- package/dist/core/validator/is-schema-reference.d.ts +0 -7
- package/dist/core/validator/is-unique-content-schema.d.ts +0 -8
- package/dist/core/zod/get-zod-string-format.d.ts +0 -30
- package/dist/format/index.d.ts +0 -6
- package/dist/generator/zod/generate-zod-array.d.ts +0 -22
- package/dist/generator/zod/generate-zod-coerce.d.ts +0 -7
- package/dist/generator/zod/generate-zod-default.d.ts +0 -7
- package/dist/generator/zod/generate-zod-enum.d.ts +0 -7
- package/dist/generator/zod/generate-zod-gt.d.ts +0 -6
- package/dist/generator/zod/generate-zod-infer.d.ts +0 -7
- package/dist/generator/zod/generate-zod-integer-schema.d.ts +0 -19
- package/dist/generator/zod/generate-zod-intersection.d.ts +0 -6
- package/dist/generator/zod/generate-zod-length.d.ts +0 -9
- package/dist/generator/zod/generate-zod-lt.d.ts +0 -6
- package/dist/generator/zod/generate-zod-max.d.ts +0 -6
- package/dist/generator/zod/generate-zod-min.d.ts +0 -9
- package/dist/generator/zod/generate-zod-nullable.d.ts +0 -7
- package/dist/generator/zod/generate-zod-number.d.ts +0 -21
- package/dist/generator/zod/generate-zod-object-schema.d.ts +0 -33
- package/dist/generator/zod/generate-zod-object.d.ts +0 -9
- package/dist/generator/zod/generate-zod-partial-schema.d.ts +0 -6
- package/dist/generator/zod/generate-zod-passthrough.d.ts +0 -6
- package/dist/generator/zod/generate-zod-record.d.ts +0 -29
- package/dist/generator/zod/generate-zod-regex.d.ts +0 -6
- package/dist/generator/zod/generate-zod-string.d.ts +0 -44
- package/dist/generator/zod/generate-zod-union.d.ts +0 -9
- package/dist/generator/zod/generate-zod.d.ts +0 -48
- package/dist/generator/zod/helper/strip-max-if-lt-exist-helper.d.ts +0 -7
- package/dist/generator/zod/helper/strip-min-if-gt-exist-helper.d.ts +0 -7
- package/dist/generator/zod/helper/strip-min-max-exist-helper.d.ts +0 -8
- package/dist/generator/zod/openapi/generate-zod-to-openapi-schema-definition.d.ts +0 -19
- package/dist/generator/zod/openapi/generate-zod-to-openapi.d.ts +0 -9
- package/dist/generator/zod/property/generate-zod-properties-schema.d.ts +0 -45
- package/dist/generator/zod/property/generate-zod-property-schema.d.ts +0 -30
- package/dist/generator/zod/reference/generate-array-reference-schema.d.ts +0 -9
- package/dist/generator/zod/reference/generate-reference-schema.d.ts +0 -9
- package/dist/generator/zod/sub/generate-zod-schema-from-sub-schema.d.ts +0 -9
- package/dist/generator/zod-openapi-hono/app/docs/generate-docs.d.ts +0 -13
- package/dist/generator/zod-openapi-hono/app/generate-app-route-handler.d.ts +0 -7
- package/dist/generator/zod-openapi-hono/app/generators/generate-apply-openapi-routes.d.ts +0 -12
- package/dist/generator/zod-openapi-hono/app/generators/generate-import-routes.d.ts +0 -10
- package/dist/generator/zod-openapi-hono/app/helper/get-route-maps.d.ts +0 -11
- package/dist/generator/zod-openapi-hono/app/helper/process-import-map.d.ts +0 -14
- package/dist/generator/zod-openapi-hono/app/index.d.ts +0 -12
- package/dist/generator/zod-openapi-hono/app/register-component/generate-register-component.d.ts +0 -7
- package/dist/generator/zod-openapi-hono/handler/generate-handler-name.d.ts +0 -7
- package/dist/generator/zod-openapi-hono/handler/generate-handler.d.ts +0 -7
- package/dist/generator/zod-openapi-hono/handler/generate-zod-openapi-hono-handler.d.ts +0 -16
- package/dist/generator/zod-openapi-hono/handler/helper/group-handlers-by-file-name-helper.d.ts +0 -7
- package/dist/generator/zod-openapi-hono/handler/import/generate-import-handlers.d.ts +0 -10
- package/dist/generator/zod-openapi-hono/handler/import/get-handler-imports.d.ts +0 -12
- package/dist/generator/zod-openapi-hono/openapi/component/allof/generate-allof-code.d.ts +0 -9
- package/dist/generator/zod-openapi-hono/openapi/component/allof/process/process-alllof.d.ts +0 -14
- package/dist/generator/zod-openapi-hono/openapi/component/anyof/generate-anyof-code.d.ts +0 -9
- package/dist/generator/zod-openapi-hono/openapi/component/generate-components-code.d.ts +0 -17
- package/dist/generator/zod-openapi-hono/openapi/component/not/generate-not-code.d.ts +0 -7
- package/dist/generator/zod-openapi-hono/openapi/component/oneof/generate-oneof-code.d.ts +0 -9
- package/dist/generator/zod-openapi-hono/openapi/generate-zod-openapi-hono.d.ts +0 -9
- package/dist/generator/zod-openapi-hono/openapi/route/generate-create-route.d.ts +0 -56
- package/dist/generator/zod-openapi-hono/openapi/route/generate-route-code.d.ts +0 -20
- package/dist/generator/zod-openapi-hono/openapi/route/generate-route-name.d.ts +0 -15
- package/dist/generator/zod-openapi-hono/openapi/route/generate-route.d.ts +0 -23
- package/dist/generator/zod-openapi-hono/openapi/route/params/generate-params-object.d.ts +0 -14
- package/dist/generator/zod-openapi-hono/openapi/route/params/generate-request-parameter.d.ts +0 -20
- package/dist/generator/zod-openapi-hono/openapi/route/params/generate-request-params-array.d.ts +0 -7
- package/dist/generator/zod-openapi-hono/openapi/route/params/generate-request-params.d.ts +0 -6
- package/dist/generator/zod-openapi-hono/openapi/route/request/body/generate-insert-request-body.d.ts +0 -7
- package/dist/generator/zod-openapi-hono/openapi/route/request/body/generate-request-body.d.ts +0 -9
- package/dist/generator/zod-openapi-hono/openapi/route/request/object/generate-format-request-object.d.ts +0 -25
- package/dist/generator/zod-openapi-hono/openapi/route/response/generate-response-schema.d.ts +0 -21
- package/dist/index.d.ts +0 -21
- package/dist/type/index.d.ts +0 -215
- package/dist/type/index.js +0 -2
- package/dist/vite-plugin/index.d.ts +0 -4
- package/dist/vite-plugin/vite-mode.d.ts +0 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 - present, Hono Takibi Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/config/index.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DEFAULT_CONFIG = void 0;
|
|
7
|
-
exports.getConfig = getConfig;
|
|
8
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
-
exports.DEFAULT_CONFIG = {
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
export const DEFAULT_CONFIG = {
|
|
10
3
|
schema: {
|
|
11
4
|
name: 'PascalCase',
|
|
12
5
|
export: false,
|
|
@@ -20,9 +13,9 @@ exports.DEFAULT_CONFIG = {
|
|
|
20
13
|
* Loads the configuration from the `hono-takibi.json` file or returns the default configuration.
|
|
21
14
|
* @returns { Config } The configuration object.
|
|
22
15
|
*/
|
|
23
|
-
function getConfig() {
|
|
24
|
-
const config =
|
|
25
|
-
? { ...
|
|
26
|
-
:
|
|
16
|
+
export function getConfig() {
|
|
17
|
+
const config = fs.existsSync('hono-takibi.json')
|
|
18
|
+
? { ...DEFAULT_CONFIG, ...JSON.parse(fs.readFileSync('hono-takibi.json', 'utf-8')) }
|
|
19
|
+
: DEFAULT_CONFIG;
|
|
27
20
|
return config;
|
|
28
21
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCamelCaseSchemaNameHelper = getCamelCaseSchemaNameHelper;
|
|
4
|
-
const decapitalize_1 = require("../text/decapitalize");
|
|
1
|
+
import { decapitalize } from '../text/decapitalize.js';
|
|
5
2
|
/**
|
|
6
3
|
* Generates a camelCase schema name from a given schema name.
|
|
7
4
|
* @param { string } schemaName - The original schema name.
|
|
8
5
|
* @returns { string } The camelCase schema name.
|
|
9
6
|
*/
|
|
10
|
-
function getCamelCaseSchemaNameHelper(schemaName) {
|
|
11
|
-
const decapitalizedSchemaName =
|
|
7
|
+
export function getCamelCaseSchemaNameHelper(schemaName) {
|
|
8
|
+
const decapitalizedSchemaName = decapitalize(schemaName);
|
|
12
9
|
return `${decapitalizedSchemaName}Schema`;
|
|
13
10
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPascalCaseSchemaNameHelper = getPascalCaseSchemaNameHelper;
|
|
4
|
-
const capitalize_1 = require("../text/capitalize");
|
|
1
|
+
import { capitalize } from '../text/capitalize.js';
|
|
5
2
|
/**
|
|
6
3
|
* Generates a PascalCase schema name from a given schema name.
|
|
7
4
|
* @param { string } schemaName - The original schema name.
|
|
8
5
|
* @returns { string } The PascalCase schema name.
|
|
9
6
|
*/
|
|
10
|
-
function getPascalCaseSchemaNameHelper(schemaName) {
|
|
11
|
-
const capitalizedSchemaName =
|
|
7
|
+
export function getPascalCaseSchemaNameHelper(schemaName) {
|
|
8
|
+
const capitalizedSchemaName = capitalize(schemaName);
|
|
12
9
|
return `${capitalizedSchemaName}Schema`;
|
|
13
10
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getToSafeIdentifierHelper = getToSafeIdentifierHelper;
|
|
4
1
|
/**
|
|
5
2
|
* getToSafeIdentifierHelper
|
|
6
|
-
* @param {string} str - The string to be converted to a safe identifier
|
|
7
|
-
* @returns {string} - A normalized, safe identifier
|
|
3
|
+
* @param { string } str - The string to be converted to a safe identifier
|
|
4
|
+
* @returns { string } - A normalized, safe identifier
|
|
8
5
|
*/
|
|
9
|
-
function getToSafeIdentifierHelper(str) {
|
|
6
|
+
export function getToSafeIdentifierHelper(str) {
|
|
10
7
|
const trimmed = str.trim();
|
|
11
8
|
if (trimmed.includes('-')) {
|
|
12
9
|
return trimmed.replace(/\s*-\s*/g, '_');
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getVariableNameHelper = getVariableNameHelper;
|
|
4
|
-
const capitalize_1 = require("../text/capitalize");
|
|
5
|
-
const decapitalize_1 = require("../text/decapitalize");
|
|
1
|
+
import { capitalize } from '../text/capitalize.js';
|
|
2
|
+
import { decapitalize } from '../text/decapitalize.js';
|
|
6
3
|
/**
|
|
7
4
|
* Generates a variable name from a given name and config.
|
|
8
5
|
* @param { string } name - The name of the schema.
|
|
9
6
|
* @param { Config } config - The config of the schema.
|
|
10
7
|
* @returns { string } The variable name.
|
|
11
8
|
*/
|
|
12
|
-
function getVariableNameHelper(name, config) {
|
|
13
|
-
return config.type.name === 'camelCase' ?
|
|
9
|
+
export function getVariableNameHelper(name, config) {
|
|
10
|
+
return config.type.name === 'camelCase' ? decapitalize(name) : capitalize(name);
|
|
14
11
|
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getVariableSchemaNameHelper = getVariableSchemaNameHelper;
|
|
4
|
-
const get_camel_case_schema_name_helper_1 = require("./get-camel-case-schema-name-helper");
|
|
5
|
-
const get_pascal_case_schema_name_helper_1 = require("./get-pascal-case-schema-name-helper");
|
|
1
|
+
import { getCamelCaseSchemaNameHelper } from './get-camel-case-schema-name-helper.js';
|
|
2
|
+
import { getPascalCaseSchemaNameHelper } from './get-pascal-case-schema-name-helper.js';
|
|
6
3
|
/**
|
|
7
4
|
* Generates a variable schema name from a given name and config.
|
|
8
5
|
* @param { string } name - The name of the schema.
|
|
9
6
|
* @param { Config } config - The config of the schema.
|
|
10
7
|
* @returns { string } The variable schema name.
|
|
11
8
|
*/
|
|
12
|
-
function getVariableSchemaNameHelper(name, config) {
|
|
9
|
+
export function getVariableSchemaNameHelper(name, config) {
|
|
13
10
|
return config.schema.name === 'camelCase'
|
|
14
|
-
?
|
|
15
|
-
:
|
|
11
|
+
? getCamelCaseSchemaNameHelper(name)
|
|
12
|
+
: getPascalCaseSchemaNameHelper(name);
|
|
16
13
|
}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractRefs = extractRefs;
|
|
4
|
-
const is_ref_object_1 = require("../../validator/is-ref-object");
|
|
1
|
+
import { isRefObject } from '../../validator/is-ref-object.js';
|
|
5
2
|
/**
|
|
6
3
|
* Extracts all references from a given schema
|
|
7
4
|
* @param { Schema } schema - The schema to extract references from
|
|
8
5
|
* @returns { string[] } An array of reference names
|
|
9
6
|
*/
|
|
10
|
-
function extractRefs(schema) {
|
|
7
|
+
export function extractRefs(schema) {
|
|
11
8
|
const refs = [];
|
|
12
9
|
const traverse = (obj) => {
|
|
13
|
-
if (!
|
|
10
|
+
if (!isRefObject(obj))
|
|
14
11
|
return;
|
|
15
12
|
for (const [key, value] of Object.entries(obj)) {
|
|
16
13
|
if (key !== '$ref') {
|
|
17
|
-
if (
|
|
14
|
+
if (isRefObject(value)) {
|
|
18
15
|
traverse(value);
|
|
19
16
|
}
|
|
20
17
|
continue;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findReferences = findReferences;
|
|
4
|
-
const traverse_schema_1 = require("./traverse-schema");
|
|
1
|
+
import { traverseSchema } from './traverse-schema.js';
|
|
5
2
|
/**
|
|
6
3
|
* Collects all $ref references from an OpenAPI schema by recursively traversing it
|
|
7
4
|
* @param { Schema } schema - The schema to search for references
|
|
@@ -25,8 +22,8 @@ const traverse_schema_1 = require("./traverse-schema");
|
|
|
25
22
|
* const refs = findReferences(schema)
|
|
26
23
|
* // refs contains: Set { 'Tag', 'Category' }
|
|
27
24
|
*/
|
|
28
|
-
function findReferences(schema) {
|
|
25
|
+
export function findReferences(schema) {
|
|
29
26
|
const refs = new Set();
|
|
30
|
-
|
|
27
|
+
traverseSchema(schema, refs);
|
|
31
28
|
return refs;
|
|
32
29
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRefName = getRefName;
|
|
4
1
|
/**
|
|
5
2
|
* Extracts the type name from an OpenAPI schema reference ($ref)
|
|
6
3
|
* @param { string } ref - OpenAPI schema reference path (e.g., '#/components/schemas/Address')
|
|
@@ -33,7 +30,7 @@ exports.getRefName = getRefName;
|
|
|
33
30
|
* Process: Splits by '/' -> ['#', 'components', 'schemas', 'Address']
|
|
34
31
|
* Output: Returns 'Address'
|
|
35
32
|
*/
|
|
36
|
-
function getRefName(ref) {
|
|
33
|
+
export function getRefName(ref) {
|
|
37
34
|
// split('/'): Split a string into an array using slashes
|
|
38
35
|
// 1. ["#", "components", "schemas", "Address"]
|
|
39
36
|
// pop() to get the last element
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getRefSchemaName = getRefSchemaName;
|
|
4
|
-
const get_variable_schema_name_helper_1 = require("../../helper/get-variable-schema-name-helper");
|
|
5
|
-
const get_ref_name_1 = require("./get-ref-name");
|
|
1
|
+
import { getVariableSchemaNameHelper } from '../../helper/get-variable-schema-name-helper.js';
|
|
2
|
+
import { getRefName } from './get-ref-name.js';
|
|
6
3
|
/**
|
|
7
4
|
* Retrieves the referenced schema name from a schema object.
|
|
8
5
|
* @param { Schema } schema - The schema object
|
|
@@ -10,13 +7,13 @@ const get_ref_name_1 = require("./get-ref-name");
|
|
|
10
7
|
* @returns { string } The referenced schema name
|
|
11
8
|
* @throws { Error } Will throw an error if the $ref property or the reference name is not found
|
|
12
9
|
*/
|
|
13
|
-
function getRefSchemaName(schema, config) {
|
|
10
|
+
export function getRefSchemaName(schema, config) {
|
|
14
11
|
if (!schema.$ref) {
|
|
15
12
|
throw new Error('refName is not found');
|
|
16
13
|
}
|
|
17
|
-
const refName =
|
|
14
|
+
const refName = getRefName(schema.$ref);
|
|
18
15
|
if (!refName) {
|
|
19
16
|
throw new Error('refName is not found');
|
|
20
17
|
}
|
|
21
|
-
return
|
|
18
|
+
return getVariableSchemaNameHelper(refName, config);
|
|
22
19
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveSchemasDependencies = resolveSchemasDependencies;
|
|
4
|
-
const traverse_schema_dependencies_1 = require("./traverse-schema-dependencies");
|
|
1
|
+
import { traverseSchemaDependencies } from './traverse-schema-dependencies.js';
|
|
5
2
|
/**
|
|
6
3
|
* Resolves dependencies between schemas and returns them in topological order for safe processing
|
|
7
4
|
* @param { Record<string, Schema> } schemas - Record mapping schema names to their Schema objects
|
|
@@ -59,13 +56,13 @@ const traverse_schema_dependencies_1 = require("./traverse-schema-dependencies")
|
|
|
59
56
|
* - Uses depth-first search for dependency resolution
|
|
60
57
|
* - Automatically handles circular dependencies by preventing infinite recursion
|
|
61
58
|
*/
|
|
62
|
-
function resolveSchemasDependencies(schemas) {
|
|
59
|
+
export function resolveSchemasDependencies(schemas) {
|
|
63
60
|
const visited = new Set();
|
|
64
61
|
const recursionStack = new Set();
|
|
65
62
|
const orderedSchemas = [];
|
|
66
63
|
for (const schemaName of Object.keys(schemas)) {
|
|
67
64
|
if (!visited.has(schemaName)) {
|
|
68
|
-
|
|
65
|
+
traverseSchemaDependencies(schemaName, schemas, visited, recursionStack, orderedSchemas);
|
|
69
66
|
}
|
|
70
67
|
}
|
|
71
68
|
return orderedSchemas;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.traverseSchemaDependencies = traverseSchemaDependencies;
|
|
4
|
-
const extract_refs_1 = require("./extract-refs");
|
|
1
|
+
import { extractRefs } from './extract-refs.js';
|
|
5
2
|
/**
|
|
6
3
|
* Traverses the schema dependencies and returns them in topological order
|
|
7
4
|
* @param { string } schemaName - The name of the schema to traverse
|
|
@@ -10,7 +7,7 @@ const extract_refs_1 = require("./extract-refs");
|
|
|
10
7
|
* @param { Set<string> } recursionStack - The recursion stack
|
|
11
8
|
* @param { string[] } orderedSchemas - The ordered schemas
|
|
12
9
|
*/
|
|
13
|
-
function traverseSchemaDependencies(schemaName, schemas, visited, recursionStack, orderedSchemas) {
|
|
10
|
+
export function traverseSchemaDependencies(schemaName, schemas, visited, recursionStack, orderedSchemas) {
|
|
14
11
|
if (visited.has(schemaName))
|
|
15
12
|
return;
|
|
16
13
|
if (recursionStack.has(schemaName)) {
|
|
@@ -19,7 +16,7 @@ function traverseSchemaDependencies(schemaName, schemas, visited, recursionStack
|
|
|
19
16
|
recursionStack.add(schemaName);
|
|
20
17
|
const schema = schemas[schemaName];
|
|
21
18
|
if (schema) {
|
|
22
|
-
for (const ref of
|
|
19
|
+
for (const ref of extractRefs(schema)) {
|
|
23
20
|
if (schemas[ref]) {
|
|
24
21
|
traverseSchemaDependencies(ref, schemas, visited, recursionStack, orderedSchemas);
|
|
25
22
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.traverseSchema = traverseSchema;
|
|
4
|
-
const get_ref_name_1 = require("./get-ref-name");
|
|
1
|
+
import { getRefName } from './get-ref-name.js';
|
|
5
2
|
/**
|
|
6
3
|
* Recursively traverses an OpenAPI schema to collect all $ref references
|
|
7
4
|
* @param { Schema } schema - The OpenAPI schema object to traverse
|
|
@@ -45,13 +42,13 @@ const get_ref_name_1 = require("./get-ref-name");
|
|
|
45
42
|
* (e.g., '#/components/schemas/User' → 'User')
|
|
46
43
|
* - Performs depth-first traversal of the schema structure
|
|
47
44
|
*/
|
|
48
|
-
function traverseSchema(schema, refs) {
|
|
45
|
+
export function traverseSchema(schema, refs) {
|
|
49
46
|
// Exit if schema is undefined or not an object
|
|
50
47
|
if (!schema || typeof schema !== 'object')
|
|
51
48
|
return;
|
|
52
49
|
// If schema has a $ref property, extract and store the referenced schema name
|
|
53
50
|
if (schema.$ref) {
|
|
54
|
-
const ref =
|
|
51
|
+
const ref = getRefName(schema.$ref);
|
|
55
52
|
if (ref)
|
|
56
53
|
refs.add(ref);
|
|
57
54
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.capitalize = capitalize;
|
|
4
1
|
/**
|
|
5
2
|
* Capitalize the first letter of a string
|
|
6
|
-
* @param {string} str - String to capitalize
|
|
7
|
-
* @returns {string} String with first letter capitalized
|
|
3
|
+
* @param { string } str - String to capitalize
|
|
4
|
+
* @returns { string } String with first letter capitalized
|
|
8
5
|
*
|
|
9
6
|
* @example
|
|
10
7
|
* capitalize('posts') // Returns: 'Posts'
|
|
@@ -16,6 +13,6 @@ exports.capitalize = capitalize;
|
|
|
16
13
|
* - Returns empty string if input is empty
|
|
17
14
|
* - Commonly used for generating type names and class names
|
|
18
15
|
*/
|
|
19
|
-
function capitalize(str) {
|
|
16
|
+
export function capitalize(str) {
|
|
20
17
|
return `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
|
|
21
18
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decapitalize = decapitalize;
|
|
4
1
|
/**
|
|
5
2
|
* Decapitalize the first letter of a string
|
|
6
|
-
* @param {string} str - String to decapitalize
|
|
7
|
-
* @returns {string} String with the first letter in lowercase
|
|
3
|
+
* @param { string } str - String to decapitalize
|
|
4
|
+
* @returns { string } String with the first letter in lowercase
|
|
8
5
|
*
|
|
9
6
|
* @example
|
|
10
7
|
* decapitalize('Posts') // Returns: 'posts'
|
|
@@ -15,6 +12,6 @@ exports.decapitalize = decapitalize;
|
|
|
15
12
|
* - Leaves the rest of the string unchanged
|
|
16
13
|
* - Returns an empty string if the input is empty
|
|
17
14
|
*/
|
|
18
|
-
function decapitalize(str) {
|
|
15
|
+
export function decapitalize(str) {
|
|
19
16
|
return `${str.charAt(0).toLowerCase()}${str.slice(1)}`;
|
|
20
17
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.escapeStr = escapeStr;
|
|
4
1
|
/**
|
|
5
2
|
* Escape text for use in TypeScript code
|
|
6
|
-
* @param {string} text - The text to escape
|
|
7
|
-
* @returns {string} The escaped text
|
|
3
|
+
* @param { string } text - The text to escape
|
|
4
|
+
* @returns { string } The escaped text
|
|
8
5
|
*/
|
|
9
|
-
function escapeStr(text) {
|
|
6
|
+
export function escapeStr(text) {
|
|
10
7
|
return (text
|
|
11
8
|
// Basic text cleaning
|
|
12
9
|
.replace(/\n/g, ' ') // Replace line breaks with spaces
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.regexPattern = regexPattern;
|
|
4
1
|
/**
|
|
5
2
|
* Generates a regex pattern from a string
|
|
6
|
-
* @param {string} pattern - The pattern to generate a regex from
|
|
7
|
-
* @returns {string} Generated regex pattern
|
|
3
|
+
* @param { string } pattern - The pattern to generate a regex from
|
|
4
|
+
* @returns { string } Generated regex pattern
|
|
8
5
|
*/
|
|
9
|
-
function regexPattern(pattern) {
|
|
6
|
+
export function regexPattern(pattern) {
|
|
10
7
|
const escapedPattern = pattern.replace(/(?<!\\)\//g, '\\/');
|
|
11
8
|
const res = `/${escapedPattern}/`;
|
|
12
9
|
return res;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeZodPrefix = removeZodPrefix;
|
|
4
1
|
/**
|
|
5
2
|
* Remove the zod prefix from a zod schema
|
|
6
|
-
* @param {string} zodSchema - The zod schema to remove the prefix from
|
|
7
|
-
* @returns {string} The zod schema without the prefix
|
|
3
|
+
* @param { string } zodSchema - The zod schema to remove the prefix from
|
|
4
|
+
* @returns { string } The zod schema without the prefix
|
|
8
5
|
*/
|
|
9
|
-
function removeZodPrefix(zodSchema) {
|
|
6
|
+
export function removeZodPrefix(zodSchema) {
|
|
10
7
|
return zodSchema.replace('z.', '');
|
|
11
8
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isAllOptional = isAllOptional;
|
|
4
1
|
/**
|
|
5
2
|
* Check if all properties in the object are optional
|
|
6
|
-
* @param {string[]} objectProperties - An array of strings representing the object properties
|
|
7
|
-
* @returns {boolean} A boolean indicating if all properties are optional
|
|
3
|
+
* @param { string[] } objectProperties - An array of strings representing the object properties
|
|
4
|
+
* @returns { boolean } A boolean indicating if all properties are optional
|
|
8
5
|
*/
|
|
9
|
-
function isAllOptional(objectProperties) {
|
|
6
|
+
export function isAllOptional(objectProperties) {
|
|
10
7
|
return objectProperties.every((prop) => prop.includes('.optional()'));
|
|
11
8
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isArrayWithSchemaReference = isArrayWithSchemaReference;
|
|
4
1
|
/**
|
|
5
2
|
* Check if an array has a schema reference
|
|
6
|
-
* @param {Schema} schema - The schema to check
|
|
7
|
-
* @returns {boolean} A boolean indicating if the array has a schema reference
|
|
3
|
+
* @param { Schema } schema - The schema to check
|
|
4
|
+
* @returns { boolean } A boolean indicating if the array has a schema reference
|
|
8
5
|
*/
|
|
9
|
-
function isArrayWithSchemaReference(schema) {
|
|
6
|
+
export function isArrayWithSchemaReference(schema) {
|
|
10
7
|
return schema.type === 'array' && Boolean(schema.items?.$ref);
|
|
11
8
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFormatNumber = isFormatNumber;
|
|
4
1
|
/**
|
|
5
2
|
* Check if the format is a number type
|
|
6
3
|
* @param {Format} format - OpenAPI format type
|
|
7
4
|
* @returns {boolean} true if the format is a number type, false otherwise
|
|
8
5
|
*/
|
|
9
|
-
function isFormatNumber(format) {
|
|
6
|
+
export function isFormatNumber(format) {
|
|
10
7
|
return ['int32', 'int64', 'float', 'double'].includes(format);
|
|
11
8
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFormatString = isFormatString;
|
|
4
1
|
/**
|
|
5
2
|
* Check if the format is a string type
|
|
6
|
-
* @param {Format} format - OpenAPI format type
|
|
7
|
-
* @returns {boolean} true if the format is a string type, false otherwise
|
|
3
|
+
* @param { Format } format - OpenAPI format type
|
|
4
|
+
* @returns { boolean } true if the format is a string type, false otherwise
|
|
8
5
|
*/
|
|
9
|
-
function isFormatString(format) {
|
|
6
|
+
export function isFormatString(format) {
|
|
10
7
|
return [
|
|
11
8
|
'email',
|
|
12
9
|
'uri',
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isHttpMethod = isHttpMethod;
|
|
4
1
|
/**
|
|
5
2
|
* Check if a string is a valid HTTP method
|
|
6
|
-
* @param {string} method - The string to check against valid HTTP methods
|
|
7
|
-
* @returns {boolean} True if the string is a valid HTTP method, with type narrowing to HttpMethod
|
|
3
|
+
* @param { string } method - The string to check against valid HTTP methods
|
|
4
|
+
* @returns { boolean } True if the string is a valid HTTP method, with type narrowing to HttpMethod
|
|
8
5
|
*/
|
|
9
|
-
function isHttpMethod(method) {
|
|
6
|
+
export function isHttpMethod(method) {
|
|
10
7
|
return (method === 'get' ||
|
|
11
8
|
method === 'post' ||
|
|
12
9
|
method === 'put' ||
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNullableSchema = isNullableSchema;
|
|
4
1
|
/**
|
|
5
2
|
* Check if a given sub-schema is `nullable`
|
|
6
|
-
* @param {Schema} schema - The sub-schema to evaluate
|
|
7
|
-
* @returns {boolean} `true` if `nullable` is set to `true` and it is the only key in the schema, otherwise `false`
|
|
3
|
+
* @param { Schema } schema - The sub-schema to evaluate
|
|
4
|
+
* @returns { boolean } `true` if `nullable` is set to `true` and it is the only key in the schema, otherwise `false`
|
|
8
5
|
*/
|
|
9
|
-
function isNullableSchema(schema) {
|
|
6
|
+
export function isNullableSchema(schema) {
|
|
10
7
|
return 'nullable' in schema && schema.nullable === true && Object.keys(schema).length === 1;
|
|
11
8
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isOperation = isOperation;
|
|
4
1
|
/**
|
|
5
2
|
* Check if an object is an Operation
|
|
6
|
-
* @param {Operation} obj - The object to check
|
|
7
|
-
* @returns {boolean} True if the object is an Operation, with type narrowing support
|
|
3
|
+
* @param { Operation } obj - The object to check
|
|
4
|
+
* @returns { boolean } True if the object is an Operation, with type narrowing support
|
|
8
5
|
*
|
|
9
6
|
* Consider using `unknown` type instead of `Operation` for better type guarding:
|
|
10
7
|
* ```typescript
|
|
@@ -12,6 +9,6 @@ exports.isOperation = isOperation;
|
|
|
12
9
|
* ```
|
|
13
10
|
* This would provide more strict type checking for arbitrary values.
|
|
14
11
|
*/
|
|
15
|
-
function isOperation(obj) {
|
|
12
|
+
export function isOperation(obj) {
|
|
16
13
|
return obj && typeof obj === 'object' && 'responses' in obj;
|
|
17
14
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRefObject = isRefObject;
|
|
4
1
|
/**
|
|
5
2
|
* Check if the value is a reference object
|
|
6
|
-
* @param {unknown} value - The value to check
|
|
7
|
-
* @returns {boolean} true if the value is a reference object, false otherwise
|
|
3
|
+
* @param { unknown } value - The value to check
|
|
4
|
+
* @returns { boolean } true if the value is a reference object, false otherwise
|
|
8
5
|
*/
|
|
9
|
-
function isRefObject(value) {
|
|
6
|
+
export function isRefObject(value) {
|
|
10
7
|
return typeof value === 'object' && value !== null;
|
|
11
8
|
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSchemaReference = isSchemaReference;
|
|
4
1
|
/**
|
|
5
2
|
* Check if the schema is a reference
|
|
6
|
-
* @param {Schema} schema - The schema to check
|
|
7
|
-
* @returns {boolean} A boolean indicating if the schema is a reference
|
|
3
|
+
* @param { Schema } schema - The schema to check
|
|
4
|
+
* @returns { boolean } A boolean indicating if the schema is a reference
|
|
8
5
|
*/
|
|
9
|
-
function isSchemaReference(schema) {
|
|
6
|
+
export function isSchemaReference(schema) {
|
|
10
7
|
return Boolean(schema.$ref);
|
|
11
8
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isUniqueContentSchema = isUniqueContentSchema;
|
|
4
1
|
/**
|
|
5
2
|
* Get unique content schema
|
|
6
|
-
* @param {string[]} contentTypes - Content types
|
|
7
|
-
* @param {Content} content - Content
|
|
8
|
-
* @returns {boolean} Unique content schema
|
|
3
|
+
* @param { string[] } contentTypes - Content types
|
|
4
|
+
* @param { Content } content - Content
|
|
5
|
+
* @returns { boolean } Unique content schema
|
|
9
6
|
*/
|
|
10
|
-
function isUniqueContentSchema(contentTypes, content) {
|
|
7
|
+
export function isUniqueContentSchema(contentTypes, content) {
|
|
11
8
|
const schema = new Set(contentTypes.map((type) => JSON.stringify(content?.[type].schema)));
|
|
12
9
|
return schema.size === 1;
|
|
13
10
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getZodFormatString = getZodFormatString;
|
|
4
1
|
/**
|
|
5
2
|
* Mapping of OpenAPI formats to Zod validation methods
|
|
6
3
|
*
|
|
@@ -61,6 +58,6 @@ const FORMAT_STRING_TO_ZOD_VALIDATION = {
|
|
|
61
58
|
* - Returns empty string for unrecognized formats
|
|
62
59
|
* - Used in schema generation for request/response validation
|
|
63
60
|
*/
|
|
64
|
-
function getZodFormatString(format) {
|
|
61
|
+
export function getZodFormatString(format) {
|
|
65
62
|
return FORMAT_STRING_TO_ZOD_VALIDATION[format];
|
|
66
63
|
}
|
package/dist/format/index.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatCode = formatCode;
|
|
4
|
-
const prettier_1 = require("prettier");
|
|
1
|
+
import { format } from 'prettier';
|
|
5
2
|
/**
|
|
6
3
|
* Formats TypeScript code using Prettier
|
|
7
4
|
* @param { string } code - The TypeScript code to format
|
|
8
5
|
* @returns { Promise<string> } The formatted code
|
|
9
6
|
*/
|
|
10
|
-
async function formatCode(code) {
|
|
11
|
-
return await
|
|
7
|
+
export async function formatCode(code) {
|
|
8
|
+
return await format(code, {
|
|
12
9
|
parser: 'typescript',
|
|
13
10
|
printWidth: 100,
|
|
14
11
|
singleQuote: true,
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateZodArray = generateZodArray;
|
|
4
1
|
/**
|
|
5
2
|
* Generates a Zod array schema with the specified schema type
|
|
6
3
|
* @param { string } zodSchema - Schema type for array elements (e.g., 'Address', 'z.string().min(3)')
|
|
@@ -22,6 +19,6 @@ exports.generateZodArray = generateZodArray;
|
|
|
22
19
|
* generateZodArray('z.object({ name: z.string() })')
|
|
23
20
|
* // Returns: 'z.array(z.object({ name: z.string() }))'
|
|
24
21
|
*/
|
|
25
|
-
function generateZodArray(zodSchema) {
|
|
22
|
+
export function generateZodArray(zodSchema) {
|
|
26
23
|
return `z.array(${zodSchema})`;
|
|
27
24
|
}
|