blendsdk 5.33.0
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/README.md +125 -0
- package/dist/cmdline/cmdline.d.ts +144 -0
- package/dist/cmdline/cmdline.d.ts.map +1 -0
- package/dist/cmdline/cmdline.js +683 -0
- package/dist/cmdline/cmdline.js.map +1 -0
- package/dist/cmdline/errors.d.ts +105 -0
- package/dist/cmdline/errors.d.ts.map +1 -0
- package/dist/cmdline/errors.js +153 -0
- package/dist/cmdline/errors.js.map +1 -0
- package/dist/cmdline/index.d.ts +5 -0
- package/dist/cmdline/index.d.ts.map +1 -0
- package/dist/cmdline/index.js +5 -0
- package/dist/cmdline/index.js.map +1 -0
- package/dist/cmdline/types.d.ts +260 -0
- package/dist/cmdline/types.d.ts.map +1 -0
- package/dist/cmdline/types.js +9 -0
- package/dist/cmdline/types.js.map +1 -0
- package/dist/cmdline/validators.d.ts +28 -0
- package/dist/cmdline/validators.d.ts.map +1 -0
- package/dist/cmdline/validators.js +211 -0
- package/dist/cmdline/validators.js.map +1 -0
- package/dist/codegen/database/index.d.ts +3 -0
- package/dist/codegen/database/index.d.ts.map +1 -0
- package/dist/codegen/database/index.js +3 -0
- package/dist/codegen/database/index.js.map +1 -0
- package/dist/codegen/database/introspect/index.d.ts +3 -0
- package/dist/codegen/database/introspect/index.d.ts.map +1 -0
- package/dist/codegen/database/introspect/index.js +3 -0
- package/dist/codegen/database/introspect/index.js.map +1 -0
- package/dist/codegen/database/introspect/introspect-query.d.ts +2 -0
- package/dist/codegen/database/introspect/introspect-query.d.ts.map +1 -0
- package/dist/codegen/database/introspect/introspect-query.js +416 -0
- package/dist/codegen/database/introspect/introspect-query.js.map +1 -0
- package/dist/codegen/database/introspect/introspect-types.d.ts +45 -0
- package/dist/codegen/database/introspect/introspect-types.d.ts.map +1 -0
- package/dist/codegen/database/introspect/introspect-types.js +2 -0
- package/dist/codegen/database/introspect/introspect-types.js.map +1 -0
- package/dist/codegen/database/introspect/introspect.d.ts +21 -0
- package/dist/codegen/database/introspect/introspect.d.ts.map +1 -0
- package/dist/codegen/database/introspect/introspect.js +223 -0
- package/dist/codegen/database/introspect/introspect.js.map +1 -0
- package/dist/codegen/database/schema/check-constraint.d.ts +8 -0
- package/dist/codegen/database/schema/check-constraint.d.ts.map +1 -0
- package/dist/codegen/database/schema/check-constraint.js +12 -0
- package/dist/codegen/database/schema/check-constraint.js.map +1 -0
- package/dist/codegen/database/schema/column-schema.d.ts +7 -0
- package/dist/codegen/database/schema/column-schema.d.ts.map +1 -0
- package/dist/codegen/database/schema/column-schema.js +9 -0
- package/dist/codegen/database/schema/column-schema.js.map +1 -0
- package/dist/codegen/database/schema/constraint-base.d.ts +13 -0
- package/dist/codegen/database/schema/constraint-base.d.ts.map +1 -0
- package/dist/codegen/database/schema/constraint-base.js +32 -0
- package/dist/codegen/database/schema/constraint-base.js.map +1 -0
- package/dist/codegen/database/schema/database-schema.d.ts +19 -0
- package/dist/codegen/database/schema/database-schema.d.ts.map +1 -0
- package/dist/codegen/database/schema/database-schema.js +48 -0
- package/dist/codegen/database/schema/database-schema.js.map +1 -0
- package/dist/codegen/database/schema/dataobject-schema.d.ts +9 -0
- package/dist/codegen/database/schema/dataobject-schema.d.ts.map +1 -0
- package/dist/codegen/database/schema/dataobject-schema.js +18 -0
- package/dist/codegen/database/schema/dataobject-schema.js.map +1 -0
- package/dist/codegen/database/schema/fkey-constraints.d.ts +21 -0
- package/dist/codegen/database/schema/fkey-constraints.d.ts.map +1 -0
- package/dist/codegen/database/schema/fkey-constraints.js +58 -0
- package/dist/codegen/database/schema/fkey-constraints.js.map +1 -0
- package/dist/codegen/database/schema/index-constraint.d.ts +34 -0
- package/dist/codegen/database/schema/index-constraint.d.ts.map +1 -0
- package/dist/codegen/database/schema/index-constraint.js +79 -0
- package/dist/codegen/database/schema/index-constraint.js.map +1 -0
- package/dist/codegen/database/schema/index.d.ts +5 -0
- package/dist/codegen/database/schema/index.d.ts.map +1 -0
- package/dist/codegen/database/schema/index.js +5 -0
- package/dist/codegen/database/schema/index.js.map +1 -0
- package/dist/codegen/database/schema/primarykey-constraint.d.ts +4 -0
- package/dist/codegen/database/schema/primarykey-constraint.d.ts.map +1 -0
- package/dist/codegen/database/schema/primarykey-constraint.js +4 -0
- package/dist/codegen/database/schema/primarykey-constraint.js.map +1 -0
- package/dist/codegen/database/schema/relation-schema.d.ts +16 -0
- package/dist/codegen/database/schema/relation-schema.d.ts.map +1 -0
- package/dist/codegen/database/schema/relation-schema.js +32 -0
- package/dist/codegen/database/schema/relation-schema.js.map +1 -0
- package/dist/codegen/database/schema/table-column-schema.d.ts +59 -0
- package/dist/codegen/database/schema/table-column-schema.d.ts.map +1 -0
- package/dist/codegen/database/schema/table-column-schema.js +137 -0
- package/dist/codegen/database/schema/table-column-schema.js.map +1 -0
- package/dist/codegen/database/schema/table-schema.d.ts +48 -0
- package/dist/codegen/database/schema/table-schema.d.ts.map +1 -0
- package/dist/codegen/database/schema/table-schema.js +219 -0
- package/dist/codegen/database/schema/table-schema.js.map +1 -0
- package/dist/codegen/database/schema/types.d.ts +13 -0
- package/dist/codegen/database/schema/types.d.ts.map +1 -0
- package/dist/codegen/database/schema/types.js +175 -0
- package/dist/codegen/database/schema/types.js.map +1 -0
- package/dist/codegen/database/schema/unique-constraint.d.ts +4 -0
- package/dist/codegen/database/schema/unique-constraint.d.ts.map +1 -0
- package/dist/codegen/database/schema/unique-constraint.js +4 -0
- package/dist/codegen/database/schema/unique-constraint.js.map +1 -0
- package/dist/codegen/database/schema/view-schema.d.ts +14 -0
- package/dist/codegen/database/schema/view-schema.d.ts.map +1 -0
- package/dist/codegen/database/schema/view-schema.js +32 -0
- package/dist/codegen/database/schema/view-schema.js.map +1 -0
- package/dist/codegen/generator/ctype-generator.d.ts +5 -0
- package/dist/codegen/generator/ctype-generator.d.ts.map +1 -0
- package/dist/codegen/generator/ctype-generator.js +26 -0
- package/dist/codegen/generator/ctype-generator.js.map +1 -0
- package/dist/codegen/generator/generator.d.ts +17 -0
- package/dist/codegen/generator/generator.d.ts.map +1 -0
- package/dist/codegen/generator/generator.js +57 -0
- package/dist/codegen/generator/generator.js.map +1 -0
- package/dist/codegen/generator/index.d.ts +8 -0
- package/dist/codegen/generator/index.d.ts.map +1 -0
- package/dist/codegen/generator/index.js +8 -0
- package/dist/codegen/generator/index.js.map +1 -0
- package/dist/codegen/generator/openapi-generator.d.ts +239 -0
- package/dist/codegen/generator/openapi-generator.d.ts.map +1 -0
- package/dist/codegen/generator/openapi-generator.js +434 -0
- package/dist/codegen/generator/openapi-generator.js.map +1 -0
- package/dist/codegen/generator/openapi-types.d.ts +263 -0
- package/dist/codegen/generator/openapi-types.d.ts.map +1 -0
- package/dist/codegen/generator/openapi-types.js +11 -0
- package/dist/codegen/generator/openapi-types.js.map +1 -0
- package/dist/codegen/generator/postgres-schema-generator.d.ts +48 -0
- package/dist/codegen/generator/postgres-schema-generator.d.ts.map +1 -0
- package/dist/codegen/generator/postgres-schema-generator.js +339 -0
- package/dist/codegen/generator/postgres-schema-generator.js.map +1 -0
- package/dist/codegen/generator/type-generator.d.ts +113 -0
- package/dist/codegen/generator/type-generator.d.ts.map +1 -0
- package/dist/codegen/generator/type-generator.js +249 -0
- package/dist/codegen/generator/type-generator.js.map +1 -0
- package/dist/codegen/generator/zod-generator.d.ts +15 -0
- package/dist/codegen/generator/zod-generator.d.ts.map +1 -0
- package/dist/codegen/generator/zod-generator.js +86 -0
- package/dist/codegen/generator/zod-generator.js.map +1 -0
- package/dist/codegen/generator/zod-to-openapi.d.ts +69 -0
- package/dist/codegen/generator/zod-to-openapi.d.ts.map +1 -0
- package/dist/codegen/generator/zod-to-openapi.js +480 -0
- package/dist/codegen/generator/zod-to-openapi.js.map +1 -0
- package/dist/codegen/index.d.ts +4 -0
- package/dist/codegen/index.d.ts.map +1 -0
- package/dist/codegen/index.js +4 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/codegen/schema/any-schema.d.ts +6 -0
- package/dist/codegen/schema/any-schema.d.ts.map +1 -0
- package/dist/codegen/schema/any-schema.js +12 -0
- package/dist/codegen/schema/any-schema.js.map +1 -0
- package/dist/codegen/schema/boolean-schema.d.ts +6 -0
- package/dist/codegen/schema/boolean-schema.d.ts.map +1 -0
- package/dist/codegen/schema/boolean-schema.js +12 -0
- package/dist/codegen/schema/boolean-schema.js.map +1 -0
- package/dist/codegen/schema/date-schema.d.ts +6 -0
- package/dist/codegen/schema/date-schema.d.ts.map +1 -0
- package/dist/codegen/schema/date-schema.js +12 -0
- package/dist/codegen/schema/date-schema.js.map +1 -0
- package/dist/codegen/schema/index.d.ts +10 -0
- package/dist/codegen/schema/index.d.ts.map +1 -0
- package/dist/codegen/schema/index.js +10 -0
- package/dist/codegen/schema/index.js.map +1 -0
- package/dist/codegen/schema/object-schema.d.ts +10 -0
- package/dist/codegen/schema/object-schema.d.ts.map +1 -0
- package/dist/codegen/schema/object-schema.js +21 -0
- package/dist/codegen/schema/object-schema.js.map +1 -0
- package/dist/codegen/schema/primitive-schema.d.ts +20 -0
- package/dist/codegen/schema/primitive-schema.d.ts.map +1 -0
- package/dist/codegen/schema/primitive-schema.js +48 -0
- package/dist/codegen/schema/primitive-schema.js.map +1 -0
- package/dist/codegen/schema/ref-schema.d.ts +6 -0
- package/dist/codegen/schema/ref-schema.d.ts.map +1 -0
- package/dist/codegen/schema/ref-schema.js +11 -0
- package/dist/codegen/schema/ref-schema.js.map +1 -0
- package/dist/codegen/schema/schema-container.d.ts +14 -0
- package/dist/codegen/schema/schema-container.d.ts.map +1 -0
- package/dist/codegen/schema/schema-container.js +38 -0
- package/dist/codegen/schema/schema-container.js.map +1 -0
- package/dist/codegen/schema/schema-object.d.ts +42 -0
- package/dist/codegen/schema/schema-object.d.ts.map +1 -0
- package/dist/codegen/schema/schema-object.js +90 -0
- package/dist/codegen/schema/schema-object.js.map +1 -0
- package/dist/codegen/schema/schema-scope.d.ts +23 -0
- package/dist/codegen/schema/schema-scope.d.ts.map +1 -0
- package/dist/codegen/schema/schema-scope.js +67 -0
- package/dist/codegen/schema/schema-scope.js.map +1 -0
- package/dist/codegen/schema/utils.d.ts +17 -0
- package/dist/codegen/schema/utils.d.ts.map +1 -0
- package/dist/codegen/schema/utils.js +47 -0
- package/dist/codegen/schema/utils.js.map +1 -0
- package/dist/dbcore/crud-statement.d.ts +67 -0
- package/dist/dbcore/crud-statement.d.ts.map +1 -0
- package/dist/dbcore/crud-statement.js +75 -0
- package/dist/dbcore/crud-statement.js.map +1 -0
- package/dist/dbcore/database.d.ts +272 -0
- package/dist/dbcore/database.d.ts.map +1 -0
- package/dist/dbcore/database.js +53 -0
- package/dist/dbcore/database.js.map +1 -0
- package/dist/dbcore/dataservice-base.d.ts +18 -0
- package/dist/dbcore/dataservice-base.d.ts.map +1 -0
- package/dist/dbcore/dataservice-base.js +19 -0
- package/dist/dbcore/dataservice-base.js.map +1 -0
- package/dist/dbcore/delete-statement.d.ts +29 -0
- package/dist/dbcore/delete-statement.d.ts.map +1 -0
- package/dist/dbcore/delete-statement.js +30 -0
- package/dist/dbcore/delete-statement.js.map +1 -0
- package/dist/dbcore/filterable-statement.d.ts +126 -0
- package/dist/dbcore/filterable-statement.d.ts.map +1 -0
- package/dist/dbcore/filterable-statement.js +178 -0
- package/dist/dbcore/filterable-statement.js.map +1 -0
- package/dist/dbcore/from-statement.d.ts +120 -0
- package/dist/dbcore/from-statement.d.ts.map +1 -0
- package/dist/dbcore/from-statement.js +150 -0
- package/dist/dbcore/from-statement.js.map +1 -0
- package/dist/dbcore/index.d.ts +21 -0
- package/dist/dbcore/index.d.ts.map +1 -0
- package/dist/dbcore/index.js +21 -0
- package/dist/dbcore/index.js.map +1 -0
- package/dist/dbcore/insert-statement.d.ts +48 -0
- package/dist/dbcore/insert-statement.d.ts.map +1 -0
- package/dist/dbcore/insert-statement.js +52 -0
- package/dist/dbcore/insert-statement.js.map +1 -0
- package/dist/dbcore/query-dataservice.d.ts +144 -0
- package/dist/dbcore/query-dataservice.d.ts.map +1 -0
- package/dist/dbcore/query-dataservice.js +144 -0
- package/dist/dbcore/query-dataservice.js.map +1 -0
- package/dist/dbcore/statement.d.ts +133 -0
- package/dist/dbcore/statement.d.ts.map +1 -0
- package/dist/dbcore/statement.js +138 -0
- package/dist/dbcore/statement.js.map +1 -0
- package/dist/dbcore/update-statement.d.ts +48 -0
- package/dist/dbcore/update-statement.d.ts.map +1 -0
- package/dist/dbcore/update-statement.js +52 -0
- package/dist/dbcore/update-statement.js.map +1 -0
- package/dist/expression/builders/comparison-builder.d.ts +47 -0
- package/dist/expression/builders/comparison-builder.d.ts.map +1 -0
- package/dist/expression/builders/comparison-builder.js +197 -0
- package/dist/expression/builders/comparison-builder.js.map +1 -0
- package/dist/expression/builders/query-builder.d.ts +80 -0
- package/dist/expression/builders/query-builder.d.ts.map +1 -0
- package/dist/expression/builders/query-builder.js +229 -0
- package/dist/expression/builders/query-builder.js.map +1 -0
- package/dist/expression/compiler/postgresql-compiler.d.ts +56 -0
- package/dist/expression/compiler/postgresql-compiler.d.ts.map +1 -0
- package/dist/expression/compiler/postgresql-compiler.js +217 -0
- package/dist/expression/compiler/postgresql-compiler.js.map +1 -0
- package/dist/expression/core/ast-node.d.ts +47 -0
- package/dist/expression/core/ast-node.d.ts.map +1 -0
- package/dist/expression/core/ast-node.js +154 -0
- package/dist/expression/core/ast-node.js.map +1 -0
- package/dist/expression/core/parameter-manager.d.ts +84 -0
- package/dist/expression/core/parameter-manager.d.ts.map +1 -0
- package/dist/expression/core/parameter-manager.js +164 -0
- package/dist/expression/core/parameter-manager.js.map +1 -0
- package/dist/expression/core/query-builder-interfaces.d.ts +188 -0
- package/dist/expression/core/query-builder-interfaces.d.ts.map +1 -0
- package/dist/expression/core/query-builder-interfaces.js +6 -0
- package/dist/expression/core/query-builder-interfaces.js.map +1 -0
- package/dist/expression/core/types.d.ts +239 -0
- package/dist/expression/core/types.d.ts.map +1 -0
- package/dist/expression/core/types.js +121 -0
- package/dist/expression/core/types.js.map +1 -0
- package/dist/expression/index.d.ts +11 -0
- package/dist/expression/index.d.ts.map +1 -0
- package/dist/expression/index.js +11 -0
- package/dist/expression/index.js.map +1 -0
- package/dist/i18n/content-file-source.d.ts +109 -0
- package/dist/i18n/content-file-source.d.ts.map +1 -0
- package/dist/i18n/content-file-source.js +218 -0
- package/dist/i18n/content-file-source.js.map +1 -0
- package/dist/i18n/index.d.ts +19 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +21 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/json-file-source.d.ts +96 -0
- package/dist/i18n/json-file-source.d.ts.map +1 -0
- package/dist/i18n/json-file-source.js +258 -0
- package/dist/i18n/json-file-source.js.map +1 -0
- package/dist/i18n/merge-catalogs.d.ts +20 -0
- package/dist/i18n/merge-catalogs.d.ts.map +1 -0
- package/dist/i18n/merge-catalogs.js +34 -0
- package/dist/i18n/merge-catalogs.js.map +1 -0
- package/dist/i18n/node.d.ts +20 -0
- package/dist/i18n/node.d.ts.map +1 -0
- package/dist/i18n/node.js +19 -0
- package/dist/i18n/node.js.map +1 -0
- package/dist/i18n/translation-source.d.ts +35 -0
- package/dist/i18n/translation-source.d.ts.map +1 -0
- package/dist/i18n/translation-source.js +2 -0
- package/dist/i18n/translation-source.js.map +1 -0
- package/dist/i18n/translator.d.ts +162 -0
- package/dist/i18n/translator.d.ts.map +1 -0
- package/dist/i18n/translator.js +259 -0
- package/dist/i18n/translator.js.map +1 -0
- package/dist/i18n/types.d.ts +80 -0
- package/dist/i18n/types.d.ts.map +1 -0
- package/dist/i18n/types.js +2 -0
- package/dist/i18n/types.js.map +1 -0
- package/dist/postgresql/database.d.ts +204 -0
- package/dist/postgresql/database.d.ts.map +1 -0
- package/dist/postgresql/database.js +321 -0
- package/dist/postgresql/database.js.map +1 -0
- package/dist/postgresql/delete-statement.d.ts +36 -0
- package/dist/postgresql/delete-statement.d.ts.map +1 -0
- package/dist/postgresql/delete-statement.js +54 -0
- package/dist/postgresql/delete-statement.js.map +1 -0
- package/dist/postgresql/index.d.ts +12 -0
- package/dist/postgresql/index.d.ts.map +1 -0
- package/dist/postgresql/index.js +12 -0
- package/dist/postgresql/index.js.map +1 -0
- package/dist/postgresql/insert-statement.d.ts +34 -0
- package/dist/postgresql/insert-statement.d.ts.map +1 -0
- package/dist/postgresql/insert-statement.js +48 -0
- package/dist/postgresql/insert-statement.js.map +1 -0
- package/dist/postgresql/update-statement.d.ts +38 -0
- package/dist/postgresql/update-statement.d.ts.map +1 -0
- package/dist/postgresql/update-statement.js +75 -0
- package/dist/postgresql/update-statement.js.map +1 -0
- package/dist/stdlib/formatString.d.ts +52 -0
- package/dist/stdlib/formatString.d.ts.map +1 -0
- package/dist/stdlib/formatString.js +118 -0
- package/dist/stdlib/formatString.js.map +1 -0
- package/dist/stdlib/index.d.ts +8 -0
- package/dist/stdlib/index.d.ts.map +1 -0
- package/dist/stdlib/index.js +8 -0
- package/dist/stdlib/index.js.map +1 -0
- package/dist/stdlib/isBoolean.d.ts +15 -0
- package/dist/stdlib/isBoolean.d.ts.map +1 -0
- package/dist/stdlib/isBoolean.js +17 -0
- package/dist/stdlib/isBoolean.js.map +1 -0
- package/dist/stdlib/isNullOrUndef.d.ts +24 -0
- package/dist/stdlib/isNullOrUndef.d.ts.map +1 -0
- package/dist/stdlib/isNullOrUndef.js +28 -0
- package/dist/stdlib/isNullOrUndef.js.map +1 -0
- package/dist/stdlib/isNumeric.d.ts +20 -0
- package/dist/stdlib/isNumeric.d.ts.map +1 -0
- package/dist/stdlib/isNumeric.js +39 -0
- package/dist/stdlib/isNumeric.js.map +1 -0
- package/dist/stdlib/isString.d.ts +15 -0
- package/dist/stdlib/isString.d.ts.map +1 -0
- package/dist/stdlib/isString.js +17 -0
- package/dist/stdlib/isString.js.map +1 -0
- package/dist/stdlib/isTemplateString.d.ts +18 -0
- package/dist/stdlib/isTemplateString.d.ts.map +1 -0
- package/dist/stdlib/isTemplateString.js +38 -0
- package/dist/stdlib/isTemplateString.js.map +1 -0
- package/dist/stdlib/wrapInArray.d.ts +14 -0
- package/dist/stdlib/wrapInArray.d.ts.map +1 -0
- package/dist/stdlib/wrapInArray.js +17 -0
- package/dist/stdlib/wrapInArray.js.map +1 -0
- package/dist/webafx/application/application-settings.d.ts +129 -0
- package/dist/webafx/application/application-settings.d.ts.map +1 -0
- package/dist/webafx/application/application-settings.js +162 -0
- package/dist/webafx/application/application-settings.js.map +1 -0
- package/dist/webafx/application/base-controller.d.ts +128 -0
- package/dist/webafx/application/base-controller.d.ts.map +1 -0
- package/dist/webafx/application/base-controller.js +122 -0
- package/dist/webafx/application/base-controller.js.map +1 -0
- package/dist/webafx/application/console-logger.d.ts +81 -0
- package/dist/webafx/application/console-logger.d.ts.map +1 -0
- package/dist/webafx/application/console-logger.js +111 -0
- package/dist/webafx/application/console-logger.js.map +1 -0
- package/dist/webafx/application/controller-registry.d.ts +34 -0
- package/dist/webafx/application/controller-registry.d.ts.map +1 -0
- package/dist/webafx/application/controller-registry.js +32 -0
- package/dist/webafx/application/controller-registry.js.map +1 -0
- package/dist/webafx/application/error-handler-middleware.d.ts +22 -0
- package/dist/webafx/application/error-handler-middleware.d.ts.map +1 -0
- package/dist/webafx/application/error-handler-middleware.js +70 -0
- package/dist/webafx/application/error-handler-middleware.js.map +1 -0
- package/dist/webafx/application/index.d.ts +13 -0
- package/dist/webafx/application/index.d.ts.map +1 -0
- package/dist/webafx/application/index.js +13 -0
- package/dist/webafx/application/index.js.map +1 -0
- package/dist/webafx/application/logger.d.ts +2 -0
- package/dist/webafx/application/logger.d.ts.map +1 -0
- package/dist/webafx/application/logger.js +2 -0
- package/dist/webafx/application/logger.js.map +1 -0
- package/dist/webafx/application/plugin.d.ts +73 -0
- package/dist/webafx/application/plugin.d.ts.map +1 -0
- package/dist/webafx/application/plugin.js +90 -0
- package/dist/webafx/application/plugin.js.map +1 -0
- package/dist/webafx/application/rate-limiter.d.ts +35 -0
- package/dist/webafx/application/rate-limiter.d.ts.map +1 -0
- package/dist/webafx/application/rate-limiter.js +74 -0
- package/dist/webafx/application/rate-limiter.js.map +1 -0
- package/dist/webafx/application/request-context.d.ts +62 -0
- package/dist/webafx/application/request-context.d.ts.map +1 -0
- package/dist/webafx/application/request-context.js +54 -0
- package/dist/webafx/application/request-context.js.map +1 -0
- package/dist/webafx/application/request-id-middleware.d.ts +30 -0
- package/dist/webafx/application/request-id-middleware.d.ts.map +1 -0
- package/dist/webafx/application/request-id-middleware.js +57 -0
- package/dist/webafx/application/request-id-middleware.js.map +1 -0
- package/dist/webafx/application/route-builder.d.ts +231 -0
- package/dist/webafx/application/route-builder.d.ts.map +1 -0
- package/dist/webafx/application/route-builder.js +182 -0
- package/dist/webafx/application/route-builder.js.map +1 -0
- package/dist/webafx/application/service-container.d.ts +144 -0
- package/dist/webafx/application/service-container.d.ts.map +1 -0
- package/dist/webafx/application/service-container.js +192 -0
- package/dist/webafx/application/service-container.js.map +1 -0
- package/dist/webafx/application/services.d.ts +27 -0
- package/dist/webafx/application/services.d.ts.map +1 -0
- package/dist/webafx/application/services.js +33 -0
- package/dist/webafx/application/services.js.map +1 -0
- package/dist/webafx/application/structured-logger.d.ts +99 -0
- package/dist/webafx/application/structured-logger.d.ts.map +1 -0
- package/dist/webafx/application/structured-logger.js +132 -0
- package/dist/webafx/application/structured-logger.js.map +1 -0
- package/dist/webafx/application/type.d.ts +29 -0
- package/dist/webafx/application/type.d.ts.map +1 -0
- package/dist/webafx/application/type.js +2 -0
- package/dist/webafx/application/type.js.map +1 -0
- package/dist/webafx/application/web-application.d.ts +257 -0
- package/dist/webafx/application/web-application.d.ts.map +1 -0
- package/dist/webafx/application/web-application.js +611 -0
- package/dist/webafx/application/web-application.js.map +1 -0
- package/dist/webafx/errors/api-error.d.ts +21 -0
- package/dist/webafx/errors/api-error.d.ts.map +1 -0
- package/dist/webafx/errors/api-error.js +38 -0
- package/dist/webafx/errors/api-error.js.map +1 -0
- package/dist/webafx/errors/http-errors.d.ts +56 -0
- package/dist/webafx/errors/http-errors.d.ts.map +1 -0
- package/dist/webafx/errors/http-errors.js +74 -0
- package/dist/webafx/errors/http-errors.js.map +1 -0
- package/dist/webafx/errors/index.d.ts +4 -0
- package/dist/webafx/errors/index.d.ts.map +1 -0
- package/dist/webafx/errors/index.js +4 -0
- package/dist/webafx/errors/index.js.map +1 -0
- package/dist/webafx/errors/types.d.ts +42 -0
- package/dist/webafx/errors/types.d.ts.map +1 -0
- package/dist/webafx/errors/types.js +2 -0
- package/dist/webafx/errors/types.js.map +1 -0
- package/dist/webafx/index.d.ts +3 -0
- package/dist/webafx/index.d.ts.map +1 -0
- package/dist/webafx/index.js +3 -0
- package/dist/webafx/index.js.map +1 -0
- package/dist/webafx-auth/abstract-auth-provider.d.ts +178 -0
- package/dist/webafx-auth/abstract-auth-provider.d.ts.map +1 -0
- package/dist/webafx-auth/abstract-auth-provider.js +240 -0
- package/dist/webafx-auth/abstract-auth-provider.js.map +1 -0
- package/dist/webafx-auth/index.d.ts +27 -0
- package/dist/webafx-auth/index.d.ts.map +1 -0
- package/dist/webafx-auth/index.js +32 -0
- package/dist/webafx-auth/index.js.map +1 -0
- package/dist/webafx-auth/jwt-auth-provider.d.ts +100 -0
- package/dist/webafx-auth/jwt-auth-provider.d.ts.map +1 -0
- package/dist/webafx-auth/jwt-auth-provider.js +154 -0
- package/dist/webafx-auth/jwt-auth-provider.js.map +1 -0
- package/dist/webafx-auth/memory-auth-provider.d.ts +100 -0
- package/dist/webafx-auth/memory-auth-provider.d.ts.map +1 -0
- package/dist/webafx-auth/memory-auth-provider.js +122 -0
- package/dist/webafx-auth/memory-auth-provider.js.map +1 -0
- package/dist/webafx-auth/types.d.ts +333 -0
- package/dist/webafx-auth/types.d.ts.map +1 -0
- package/dist/webafx-auth/types.js +24 -0
- package/dist/webafx-auth/types.js.map +1 -0
- package/dist/webafx-cache/abstract-cache-provider.d.ts +185 -0
- package/dist/webafx-cache/abstract-cache-provider.d.ts.map +1 -0
- package/dist/webafx-cache/abstract-cache-provider.js +133 -0
- package/dist/webafx-cache/abstract-cache-provider.js.map +1 -0
- package/dist/webafx-cache/abstract-pubsub-provider.d.ts +170 -0
- package/dist/webafx-cache/abstract-pubsub-provider.d.ts.map +1 -0
- package/dist/webafx-cache/abstract-pubsub-provider.js +132 -0
- package/dist/webafx-cache/abstract-pubsub-provider.js.map +1 -0
- package/dist/webafx-cache/cache-plugin.d.ts +114 -0
- package/dist/webafx-cache/cache-plugin.d.ts.map +1 -0
- package/dist/webafx-cache/cache-plugin.js +176 -0
- package/dist/webafx-cache/cache-plugin.js.map +1 -0
- package/dist/webafx-cache/index.d.ts +33 -0
- package/dist/webafx-cache/index.d.ts.map +1 -0
- package/dist/webafx-cache/index.js +44 -0
- package/dist/webafx-cache/index.js.map +1 -0
- package/dist/webafx-cache/memory-cache-provider.d.ts +99 -0
- package/dist/webafx-cache/memory-cache-provider.d.ts.map +1 -0
- package/dist/webafx-cache/memory-cache-provider.js +251 -0
- package/dist/webafx-cache/memory-cache-provider.js.map +1 -0
- package/dist/webafx-cache/memory-pubsub-provider.d.ts +124 -0
- package/dist/webafx-cache/memory-pubsub-provider.d.ts.map +1 -0
- package/dist/webafx-cache/memory-pubsub-provider.js +195 -0
- package/dist/webafx-cache/memory-pubsub-provider.js.map +1 -0
- package/dist/webafx-cache/pubsub-plugin.d.ts +128 -0
- package/dist/webafx-cache/pubsub-plugin.d.ts.map +1 -0
- package/dist/webafx-cache/pubsub-plugin.js +182 -0
- package/dist/webafx-cache/pubsub-plugin.js.map +1 -0
- package/dist/webafx-cache/redis-cache-provider.d.ts +81 -0
- package/dist/webafx-cache/redis-cache-provider.d.ts.map +1 -0
- package/dist/webafx-cache/redis-cache-provider.js +209 -0
- package/dist/webafx-cache/redis-cache-provider.js.map +1 -0
- package/dist/webafx-cache/redis-pubsub-provider.d.ts +164 -0
- package/dist/webafx-cache/redis-pubsub-provider.d.ts.map +1 -0
- package/dist/webafx-cache/redis-pubsub-provider.js +329 -0
- package/dist/webafx-cache/redis-pubsub-provider.js.map +1 -0
- package/dist/webafx-cache/types.d.ts +206 -0
- package/dist/webafx-cache/types.d.ts.map +1 -0
- package/dist/webafx-cache/types.js +27 -0
- package/dist/webafx-cache/types.js.map +1 -0
- package/dist/webafx-i18n/i18n-plugin.d.ts +29 -0
- package/dist/webafx-i18n/i18n-plugin.d.ts.map +1 -0
- package/dist/webafx-i18n/i18n-plugin.js +145 -0
- package/dist/webafx-i18n/i18n-plugin.js.map +1 -0
- package/dist/webafx-i18n/index.d.ts +12 -0
- package/dist/webafx-i18n/index.d.ts.map +1 -0
- package/dist/webafx-i18n/index.js +12 -0
- package/dist/webafx-i18n/index.js.map +1 -0
- package/dist/webafx-i18n/locale-resolver.d.ts +33 -0
- package/dist/webafx-i18n/locale-resolver.d.ts.map +1 -0
- package/dist/webafx-i18n/locale-resolver.js +67 -0
- package/dist/webafx-i18n/locale-resolver.js.map +1 -0
- package/dist/webafx-i18n/postgresql-source.d.ts +101 -0
- package/dist/webafx-i18n/postgresql-source.d.ts.map +1 -0
- package/dist/webafx-i18n/postgresql-source.js +101 -0
- package/dist/webafx-i18n/postgresql-source.js.map +1 -0
- package/dist/webafx-i18n/types.d.ts +70 -0
- package/dist/webafx-i18n/types.d.ts.map +1 -0
- package/dist/webafx-i18n/types.js +2 -0
- package/dist/webafx-i18n/types.js.map +1 -0
- package/dist/webafx-mailer/abstract-mail-provider.d.ts +55 -0
- package/dist/webafx-mailer/abstract-mail-provider.d.ts.map +1 -0
- package/dist/webafx-mailer/abstract-mail-provider.js +37 -0
- package/dist/webafx-mailer/abstract-mail-provider.js.map +1 -0
- package/dist/webafx-mailer/index.d.ts +24 -0
- package/dist/webafx-mailer/index.d.ts.map +1 -0
- package/dist/webafx-mailer/index.js +34 -0
- package/dist/webafx-mailer/index.js.map +1 -0
- package/dist/webafx-mailer/mail-plugin.d.ts +98 -0
- package/dist/webafx-mailer/mail-plugin.d.ts.map +1 -0
- package/dist/webafx-mailer/mail-plugin.js +155 -0
- package/dist/webafx-mailer/mail-plugin.js.map +1 -0
- package/dist/webafx-mailer/memory-mail-provider.d.ts +85 -0
- package/dist/webafx-mailer/memory-mail-provider.d.ts.map +1 -0
- package/dist/webafx-mailer/memory-mail-provider.js +111 -0
- package/dist/webafx-mailer/memory-mail-provider.js.map +1 -0
- package/dist/webafx-mailer/smtp-mail-provider.d.ts +65 -0
- package/dist/webafx-mailer/smtp-mail-provider.d.ts.map +1 -0
- package/dist/webafx-mailer/smtp-mail-provider.js +113 -0
- package/dist/webafx-mailer/smtp-mail-provider.js.map +1 -0
- package/dist/webafx-mailer/types.d.ts +136 -0
- package/dist/webafx-mailer/types.d.ts.map +1 -0
- package/dist/webafx-mailer/types.js +13 -0
- package/dist/webafx-mailer/types.js.map +1 -0
- package/package.json +159 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import type { RouteDefinition, HttpMethod } from '../../webafx/index.js';
|
|
2
|
+
import type { OpenAPIDocument, OpenAPIGeneratorConfig, OpenAPIOperation, OpenAPIPathItem, OpenAPIResponse, OpenAPIParameter, OpenAPISchema, SecurityRequirement } from './openapi-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Constructor type for webafx controllers.
|
|
5
|
+
* Controllers must accept (settings, services) and implement routes().
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Uses a loose constructor signature so codegen doesn't need to import
|
|
9
|
+
* the full ApplicationSettings/ServiceContainer types at runtime.
|
|
10
|
+
*/
|
|
11
|
+
export type ControllerConstructor = new (settings: any, services: any) => {
|
|
12
|
+
routes(): RouteDefinition[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Internal representation of a collected route with its base path.
|
|
16
|
+
* Routes are collected from controllers and stored for document generation.
|
|
17
|
+
*/
|
|
18
|
+
interface CollectedRoute {
|
|
19
|
+
/** The controller's base path (e.g., '/api/products') */
|
|
20
|
+
basePath: string;
|
|
21
|
+
/** The complete route definition from the controller */
|
|
22
|
+
definition: RouteDefinition;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Generates OpenAPI v3.1 specification documents from webafx controller routes.
|
|
26
|
+
*
|
|
27
|
+
* This generator reads route definitions (with their Zod validation schemas
|
|
28
|
+
* and OpenAPI metadata) and produces a complete OpenAPI 3.1.0 document.
|
|
29
|
+
* Only routes that have been annotated with `.openapi()` metadata are included
|
|
30
|
+
* in the generated specification — this is the opt-in mechanism.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* - This class does NOT extend the existing codegen `Generator` base class
|
|
34
|
+
* because it operates on webafx routes, not on database schemas.
|
|
35
|
+
* - Controllers are instantiated with empty mock settings/services since
|
|
36
|
+
* `routes()` only builds RouteDefinition objects (no side effects).
|
|
37
|
+
* - Zod→OpenAPI schema conversion is handled by dedicated protected methods
|
|
38
|
+
* that can be overridden or extended.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import { OpenAPIGenerator } from '../index.js';
|
|
43
|
+
* import { ProductsController } from './controllers/products.controller.js';
|
|
44
|
+
*
|
|
45
|
+
* const generator = new OpenAPIGenerator({
|
|
46
|
+
* title: 'My API',
|
|
47
|
+
* version: '1.0.0',
|
|
48
|
+
* servers: [{ url: 'http://localhost:3000' }],
|
|
49
|
+
* securitySchemes: {
|
|
50
|
+
* bearerAuth: { type: 'http', scheme: 'bearer', bearerFormat: 'JWT' }
|
|
51
|
+
* },
|
|
52
|
+
* defaultSecurity: [{ bearerAuth: [] }]
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* generator.addController('/api/products', ProductsController);
|
|
56
|
+
*
|
|
57
|
+
* const spec = generator.generate();
|
|
58
|
+
* generator.toFile('./openapi.json');
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare class OpenAPIGenerator {
|
|
62
|
+
/** Generator configuration (API info, servers, security) */
|
|
63
|
+
protected config: OpenAPIGeneratorConfig;
|
|
64
|
+
/** Collected routes from controllers (only those with .openapi() metadata) */
|
|
65
|
+
protected routes: CollectedRoute[];
|
|
66
|
+
/**
|
|
67
|
+
* Creates a new OpenAPIGenerator instance.
|
|
68
|
+
*
|
|
69
|
+
* @param config - Generator configuration with API metadata and security settings
|
|
70
|
+
*/
|
|
71
|
+
constructor(config: OpenAPIGeneratorConfig);
|
|
72
|
+
/**
|
|
73
|
+
* Add a controller class — instantiates it with mock settings/services
|
|
74
|
+
* and collects routes that have OpenAPI metadata.
|
|
75
|
+
*
|
|
76
|
+
* @param basePath - The base URL path for all controller routes (e.g., '/api/products')
|
|
77
|
+
* @param ControllerClass - The controller class constructor
|
|
78
|
+
* @returns This generator instance for method chaining
|
|
79
|
+
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* The controller is instantiated with empty objects as settings and services.
|
|
82
|
+
* This is safe because `routes()` only builds `RouteDefinition` objects —
|
|
83
|
+
* it does not access the database, make HTTP calls, or produce side effects.
|
|
84
|
+
*/
|
|
85
|
+
addController(basePath: string, ControllerClass: ControllerConstructor): this;
|
|
86
|
+
/**
|
|
87
|
+
* Add individual route definitions directly.
|
|
88
|
+
* Only routes with `.openapi()` metadata are collected (opt-in filtering).
|
|
89
|
+
*
|
|
90
|
+
* @param basePath - The base URL path for these routes
|
|
91
|
+
* @param routeDefinitions - Array of route definitions to add
|
|
92
|
+
* @returns This generator instance for method chaining
|
|
93
|
+
*/
|
|
94
|
+
addRoutes(basePath: string, routeDefinitions: RouteDefinition[]): this;
|
|
95
|
+
/**
|
|
96
|
+
* Generate the complete OpenAPI v3.1 document from collected routes.
|
|
97
|
+
*
|
|
98
|
+
* @returns The assembled OpenAPI document object
|
|
99
|
+
*/
|
|
100
|
+
generate(): OpenAPIDocument;
|
|
101
|
+
/**
|
|
102
|
+
* Generate and return the specification as a formatted JSON string.
|
|
103
|
+
*
|
|
104
|
+
* @param indent - Number of spaces for JSON indentation (default: 2)
|
|
105
|
+
* @returns Formatted JSON string of the OpenAPI document
|
|
106
|
+
*/
|
|
107
|
+
toJSON(indent?: number): string;
|
|
108
|
+
/**
|
|
109
|
+
* Generate and write the specification to a file.
|
|
110
|
+
* Creates parent directories if they don't exist.
|
|
111
|
+
*
|
|
112
|
+
* @param filePath - The path where the JSON file should be written
|
|
113
|
+
*/
|
|
114
|
+
toFile(filePath: string): void;
|
|
115
|
+
/**
|
|
116
|
+
* Build the paths object from all collected routes.
|
|
117
|
+
* Groups routes by their full path (basePath + route path) and
|
|
118
|
+
* creates an operation for each HTTP method on that path.
|
|
119
|
+
*
|
|
120
|
+
* @returns The paths object for the OpenAPI document
|
|
121
|
+
*/
|
|
122
|
+
protected buildPaths(): Record<string, OpenAPIPathItem>;
|
|
123
|
+
/**
|
|
124
|
+
* Combine a base path and route path into a full path.
|
|
125
|
+
* Handles trailing/leading slashes and avoids double slashes.
|
|
126
|
+
*
|
|
127
|
+
* @param basePath - The controller's base path (e.g., '/api/products')
|
|
128
|
+
* @param routePath - The route's relative path (e.g., '/:id')
|
|
129
|
+
* @returns The combined full path (e.g., '/api/products/:id')
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```
|
|
133
|
+
* buildFullPath('/api/products', '/') → '/api/products'
|
|
134
|
+
* buildFullPath('/api/products', '/:id') → '/api/products/:id'
|
|
135
|
+
* buildFullPath('/api', '/users/:id') → '/api/users/:id'
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
protected buildFullPath(basePath: string, routePath: string): string;
|
|
139
|
+
/**
|
|
140
|
+
* Convert Express-style path parameters to OpenAPI format.
|
|
141
|
+
* Express uses `:param` syntax, OpenAPI uses `{param}` syntax.
|
|
142
|
+
*
|
|
143
|
+
* @param expressPath - Express-style path (e.g., '/users/:userId/posts/:postId')
|
|
144
|
+
* @returns OpenAPI-style path (e.g., '/users/{userId}/posts/{postId}')
|
|
145
|
+
*/
|
|
146
|
+
protected convertExpressPathToOpenAPI(expressPath: string): string;
|
|
147
|
+
/**
|
|
148
|
+
* Extract path parameter names from an Express-style path.
|
|
149
|
+
*
|
|
150
|
+
* @param expressPath - Express-style path (e.g., '/users/:userId/posts/:postId')
|
|
151
|
+
* @returns Array of parameter names (e.g., ['userId', 'postId'])
|
|
152
|
+
*/
|
|
153
|
+
protected extractPathParamNames(expressPath: string): string[];
|
|
154
|
+
/**
|
|
155
|
+
* Build an OpenAPI operation object from a route definition.
|
|
156
|
+
* Assembles summary, description, tags, operationId, parameters,
|
|
157
|
+
* requestBody, responses, security, and deprecated flag.
|
|
158
|
+
*
|
|
159
|
+
* @param definition - The route definition to convert
|
|
160
|
+
* @returns The assembled OpenAPI operation object
|
|
161
|
+
*/
|
|
162
|
+
protected buildOperation(definition: RouteDefinition): OpenAPIOperation;
|
|
163
|
+
/**
|
|
164
|
+
* Build path parameters from the route path and metadata.
|
|
165
|
+
*
|
|
166
|
+
* @remarks
|
|
167
|
+
* Path parameters are extracted from Express `:param` syntax in the URL.
|
|
168
|
+
* If the metadata includes `pathParams` with schemas and descriptions,
|
|
169
|
+
* those are used to enrich the parameter definitions.
|
|
170
|
+
*
|
|
171
|
+
* For GET/DELETE routes with a validation schema, query parameters are
|
|
172
|
+
* also generated (handled in Session 2.2 — Zod conversion).
|
|
173
|
+
*
|
|
174
|
+
* @param definition - The route definition
|
|
175
|
+
* @returns Array of OpenAPI parameter objects
|
|
176
|
+
*/
|
|
177
|
+
protected buildParameters(definition: RouteDefinition): OpenAPIParameter[];
|
|
178
|
+
/**
|
|
179
|
+
* Build request body from validation schema for POST/PUT/PATCH routes.
|
|
180
|
+
*
|
|
181
|
+
* @param definition - The route definition
|
|
182
|
+
* @returns OpenAPI request body object, or undefined for GET/DELETE routes
|
|
183
|
+
*/
|
|
184
|
+
protected buildRequestBody(definition: RouteDefinition): {
|
|
185
|
+
description?: string;
|
|
186
|
+
required?: boolean;
|
|
187
|
+
content: Record<string, {
|
|
188
|
+
schema?: any;
|
|
189
|
+
}>;
|
|
190
|
+
} | undefined;
|
|
191
|
+
/**
|
|
192
|
+
* Build response objects from OpenAPI metadata.
|
|
193
|
+
*
|
|
194
|
+
* @param definition - The route definition
|
|
195
|
+
* @returns Record of status code → response object
|
|
196
|
+
*/
|
|
197
|
+
protected buildResponses(definition: RouteDefinition): Record<string, OpenAPIResponse>;
|
|
198
|
+
/**
|
|
199
|
+
* Build security requirements for the operation.
|
|
200
|
+
* Routes with `secure: true` get the configured `defaultSecurity` applied.
|
|
201
|
+
* Routes without `secure` or with `secure: false` have no security.
|
|
202
|
+
*
|
|
203
|
+
* @param definition - The route definition
|
|
204
|
+
* @returns Array of security requirements, or undefined for public routes
|
|
205
|
+
*/
|
|
206
|
+
protected buildSecurity(definition: RouteDefinition): SecurityRequirement[] | undefined;
|
|
207
|
+
/**
|
|
208
|
+
* Check if the HTTP method typically uses query parameters instead of request body.
|
|
209
|
+
* GET and DELETE routes use query parameters; POST, PUT, PATCH use request body.
|
|
210
|
+
*
|
|
211
|
+
* @param method - The HTTP method
|
|
212
|
+
* @returns True for GET and DELETE, false otherwise
|
|
213
|
+
*/
|
|
214
|
+
protected isQueryParamMethod(method: HttpMethod): boolean;
|
|
215
|
+
/**
|
|
216
|
+
* Convert a Zod schema to an OpenAPI JSON Schema object.
|
|
217
|
+
*
|
|
218
|
+
* Delegates to the `zodToOpenAPISchema` function from the zod-to-openapi module,
|
|
219
|
+
* which introspects Zod v4's internal `_zod.def` structure to produce a complete
|
|
220
|
+
* OpenAPI-compatible JSON Schema.
|
|
221
|
+
*
|
|
222
|
+
* @param zodSchema - The Zod schema to convert (any Zod type)
|
|
223
|
+
* @returns An OpenAPI schema object with type, constraints, and nested definitions
|
|
224
|
+
*/
|
|
225
|
+
protected convertZodToSchema(zodSchema: unknown): OpenAPISchema;
|
|
226
|
+
/**
|
|
227
|
+
* Convert a Zod object schema to an array of OpenAPI query parameters.
|
|
228
|
+
* Each top-level property of the Zod object becomes a separate query parameter.
|
|
229
|
+
*
|
|
230
|
+
* Delegates to the `zodToQueryParameters` function from the zod-to-openapi module.
|
|
231
|
+
* Optional properties become non-required parameters. Default values are preserved.
|
|
232
|
+
*
|
|
233
|
+
* @param zodSchema - The Zod schema (expected to be z.object())
|
|
234
|
+
* @returns Array of OpenAPI parameter objects with `in: 'query'`
|
|
235
|
+
*/
|
|
236
|
+
protected convertZodToQueryParameters(zodSchema: unknown): OpenAPIParameter[];
|
|
237
|
+
}
|
|
238
|
+
export {};
|
|
239
|
+
//# sourceMappingURL=openapi-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-generator.d.ts","sourceRoot":"","sources":["../../src/generator/openapi-generator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAG5B;;;;;;;GAOG;AACH,MAAM,MAAM,qBAAqB,GAAG,KAAK,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,KAAK;IACxE,MAAM,IAAI,eAAe,EAAE,CAAC;CAC7B,CAAC;AAEF;;;GAGG;AACH,UAAU,cAAc;IACtB,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,UAAU,EAAE,eAAe,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,gBAAgB;IAC3B,4DAA4D;IAC5D,SAAS,CAAC,MAAM,EAAE,sBAAsB,CAAC;IAEzC,8EAA8E;IAC9E,SAAS,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IAEnC;;;;OAIG;gBACS,MAAM,EAAE,sBAAsB;IAK1C;;;;;;;;;;;;OAYG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,qBAAqB,GAAG,IAAI;IAQ7E;;;;;;;OAOG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAE,GAAG,IAAI;IAUtE;;;;OAIG;IACH,QAAQ,IAAI,eAAe;IA6B3B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,GAAE,MAAU,GAAG,MAAM;IAKlC;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAe9B;;;;;;OAMG;IACH,SAAS,CAAC,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IAuBvD;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IAcpE;;;;;;OAMG;IACH,SAAS,CAAC,2BAA2B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAIlE;;;;;OAKG;IACH,SAAS,CAAC,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE;IAU9D;;;;;;;OAOG;IACH,SAAS,CAAC,cAAc,CAAC,UAAU,EAAE,eAAe,GAAG,gBAAgB;IAgDvE;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,eAAe,CAAC,UAAU,EAAE,eAAe,GAAG,gBAAgB,EAAE;IA2C1E;;;;;OAKG;IACH,SAAS,CAAC,gBAAgB,CACxB,UAAU,EAAE,eAAe,GAC1B;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,MAAM,CAAC,EAAE,GAAG,CAAA;SAAE,CAAC,CAAA;KAAE,GAAG,SAAS;IAwBtG;;;;;OAKG;IACH,SAAS,CAAC,cAAc,CAAC,UAAU,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC;IA8BtF;;;;;;;OAOG;IACH,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,eAAe,GAAG,mBAAmB,EAAE,GAAG,SAAS;IAevF;;;;;;OAMG;IACH,SAAS,CAAC,kBAAkB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO;IAMzD;;;;;;;;;OASG;IACH,SAAS,CAAC,kBAAkB,CAAC,SAAS,EAAE,OAAO,GAAG,aAAa;IAI/D;;;;;;;;;OASG;IACH,SAAS,CAAC,2BAA2B,CAAC,SAAS,EAAE,OAAO,GAAG,gBAAgB,EAAE;CAG9E"}
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { zodToOpenAPISchema, zodToQueryParameters } from './zod-to-openapi.js';
|
|
4
|
+
/**
|
|
5
|
+
* Generates OpenAPI v3.1 specification documents from webafx controller routes.
|
|
6
|
+
*
|
|
7
|
+
* This generator reads route definitions (with their Zod validation schemas
|
|
8
|
+
* and OpenAPI metadata) and produces a complete OpenAPI 3.1.0 document.
|
|
9
|
+
* Only routes that have been annotated with `.openapi()` metadata are included
|
|
10
|
+
* in the generated specification — this is the opt-in mechanism.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* - This class does NOT extend the existing codegen `Generator` base class
|
|
14
|
+
* because it operates on webafx routes, not on database schemas.
|
|
15
|
+
* - Controllers are instantiated with empty mock settings/services since
|
|
16
|
+
* `routes()` only builds RouteDefinition objects (no side effects).
|
|
17
|
+
* - Zod→OpenAPI schema conversion is handled by dedicated protected methods
|
|
18
|
+
* that can be overridden or extended.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import { OpenAPIGenerator } from '../index.js';
|
|
23
|
+
* import { ProductsController } from './controllers/products.controller.js';
|
|
24
|
+
*
|
|
25
|
+
* const generator = new OpenAPIGenerator({
|
|
26
|
+
* title: 'My API',
|
|
27
|
+
* version: '1.0.0',
|
|
28
|
+
* servers: [{ url: 'http://localhost:3000' }],
|
|
29
|
+
* securitySchemes: {
|
|
30
|
+
* bearerAuth: { type: 'http', scheme: 'bearer', bearerFormat: 'JWT' }
|
|
31
|
+
* },
|
|
32
|
+
* defaultSecurity: [{ bearerAuth: [] }]
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* generator.addController('/api/products', ProductsController);
|
|
36
|
+
*
|
|
37
|
+
* const spec = generator.generate();
|
|
38
|
+
* generator.toFile('./openapi.json');
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export class OpenAPIGenerator {
|
|
42
|
+
/** Generator configuration (API info, servers, security) */
|
|
43
|
+
config;
|
|
44
|
+
/** Collected routes from controllers (only those with .openapi() metadata) */
|
|
45
|
+
routes;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new OpenAPIGenerator instance.
|
|
48
|
+
*
|
|
49
|
+
* @param config - Generator configuration with API metadata and security settings
|
|
50
|
+
*/
|
|
51
|
+
constructor(config) {
|
|
52
|
+
this.config = config;
|
|
53
|
+
this.routes = [];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Add a controller class — instantiates it with mock settings/services
|
|
57
|
+
* and collects routes that have OpenAPI metadata.
|
|
58
|
+
*
|
|
59
|
+
* @param basePath - The base URL path for all controller routes (e.g., '/api/products')
|
|
60
|
+
* @param ControllerClass - The controller class constructor
|
|
61
|
+
* @returns This generator instance for method chaining
|
|
62
|
+
*
|
|
63
|
+
* @remarks
|
|
64
|
+
* The controller is instantiated with empty objects as settings and services.
|
|
65
|
+
* This is safe because `routes()` only builds `RouteDefinition` objects —
|
|
66
|
+
* it does not access the database, make HTTP calls, or produce side effects.
|
|
67
|
+
*/
|
|
68
|
+
addController(basePath, ControllerClass) {
|
|
69
|
+
// Instantiate controller with minimal mock dependencies.
|
|
70
|
+
// routes() only builds RouteDefinition objects — no side effects.
|
|
71
|
+
const controller = new ControllerClass({}, {});
|
|
72
|
+
const routeDefinitions = controller.routes();
|
|
73
|
+
return this.addRoutes(basePath, routeDefinitions);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Add individual route definitions directly.
|
|
77
|
+
* Only routes with `.openapi()` metadata are collected (opt-in filtering).
|
|
78
|
+
*
|
|
79
|
+
* @param basePath - The base URL path for these routes
|
|
80
|
+
* @param routeDefinitions - Array of route definitions to add
|
|
81
|
+
* @returns This generator instance for method chaining
|
|
82
|
+
*/
|
|
83
|
+
addRoutes(basePath, routeDefinitions) {
|
|
84
|
+
for (const definition of routeDefinitions) {
|
|
85
|
+
// Only include routes with OpenAPI metadata (opt-in mechanism)
|
|
86
|
+
if (definition.openapi) {
|
|
87
|
+
this.routes.push({ basePath, definition });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Generate the complete OpenAPI v3.1 document from collected routes.
|
|
94
|
+
*
|
|
95
|
+
* @returns The assembled OpenAPI document object
|
|
96
|
+
*/
|
|
97
|
+
generate() {
|
|
98
|
+
const document = {
|
|
99
|
+
openapi: '3.1.0',
|
|
100
|
+
info: {
|
|
101
|
+
title: this.config.title,
|
|
102
|
+
version: this.config.version,
|
|
103
|
+
...(this.config.description ? { description: this.config.description } : {}),
|
|
104
|
+
},
|
|
105
|
+
paths: {},
|
|
106
|
+
};
|
|
107
|
+
// Add servers if configured
|
|
108
|
+
if (this.config.servers && this.config.servers.length > 0) {
|
|
109
|
+
document.servers = this.config.servers;
|
|
110
|
+
}
|
|
111
|
+
// Build paths from collected routes
|
|
112
|
+
document.paths = this.buildPaths();
|
|
113
|
+
// Add components section if security schemes are configured
|
|
114
|
+
if (this.config.securitySchemes && Object.keys(this.config.securitySchemes).length > 0) {
|
|
115
|
+
document.components = {
|
|
116
|
+
securitySchemes: this.config.securitySchemes,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return document;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Generate and return the specification as a formatted JSON string.
|
|
123
|
+
*
|
|
124
|
+
* @param indent - Number of spaces for JSON indentation (default: 2)
|
|
125
|
+
* @returns Formatted JSON string of the OpenAPI document
|
|
126
|
+
*/
|
|
127
|
+
toJSON(indent = 2) {
|
|
128
|
+
const document = this.generate();
|
|
129
|
+
return JSON.stringify(document, null, indent);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Generate and write the specification to a file.
|
|
133
|
+
* Creates parent directories if they don't exist.
|
|
134
|
+
*
|
|
135
|
+
* @param filePath - The path where the JSON file should be written
|
|
136
|
+
*/
|
|
137
|
+
toFile(filePath) {
|
|
138
|
+
const resolvedPath = path.resolve(filePath);
|
|
139
|
+
const dir = path.dirname(resolvedPath);
|
|
140
|
+
// Ensure the output directory exists
|
|
141
|
+
if (!fs.existsSync(dir)) {
|
|
142
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
143
|
+
}
|
|
144
|
+
const json = this.toJSON();
|
|
145
|
+
fs.writeFileSync(resolvedPath, json, 'utf-8');
|
|
146
|
+
}
|
|
147
|
+
// ─── Protected Methods ──────────────────────────────────────────────────
|
|
148
|
+
/**
|
|
149
|
+
* Build the paths object from all collected routes.
|
|
150
|
+
* Groups routes by their full path (basePath + route path) and
|
|
151
|
+
* creates an operation for each HTTP method on that path.
|
|
152
|
+
*
|
|
153
|
+
* @returns The paths object for the OpenAPI document
|
|
154
|
+
*/
|
|
155
|
+
buildPaths() {
|
|
156
|
+
const paths = {};
|
|
157
|
+
for (const { basePath, definition } of this.routes) {
|
|
158
|
+
const fullPath = this.buildFullPath(basePath, definition.path);
|
|
159
|
+
const openApiPath = this.convertExpressPathToOpenAPI(fullPath);
|
|
160
|
+
// Initialize path item if it doesn't exist yet
|
|
161
|
+
if (!paths[openApiPath]) {
|
|
162
|
+
paths[openApiPath] = {};
|
|
163
|
+
}
|
|
164
|
+
// Build the operation for this route's HTTP method
|
|
165
|
+
const operation = this.buildOperation(definition);
|
|
166
|
+
// Assign the operation to the correct HTTP method
|
|
167
|
+
const method = definition.method;
|
|
168
|
+
paths[openApiPath][method] = operation;
|
|
169
|
+
}
|
|
170
|
+
return paths;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Combine a base path and route path into a full path.
|
|
174
|
+
* Handles trailing/leading slashes and avoids double slashes.
|
|
175
|
+
*
|
|
176
|
+
* @param basePath - The controller's base path (e.g., '/api/products')
|
|
177
|
+
* @param routePath - The route's relative path (e.g., '/:id')
|
|
178
|
+
* @returns The combined full path (e.g., '/api/products/:id')
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```
|
|
182
|
+
* buildFullPath('/api/products', '/') → '/api/products'
|
|
183
|
+
* buildFullPath('/api/products', '/:id') → '/api/products/:id'
|
|
184
|
+
* buildFullPath('/api', '/users/:id') → '/api/users/:id'
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
buildFullPath(basePath, routePath) {
|
|
188
|
+
// Remove trailing slash from basePath
|
|
189
|
+
const normalizedBase = basePath.replace(/\/+$/, '');
|
|
190
|
+
// Ensure routePath starts with /
|
|
191
|
+
const normalizedRoute = routePath.startsWith('/') ? routePath : `/${routePath}`;
|
|
192
|
+
// If route is just '/', return basePath alone
|
|
193
|
+
if (normalizedRoute === '/') {
|
|
194
|
+
return normalizedBase || '/';
|
|
195
|
+
}
|
|
196
|
+
return `${normalizedBase}${normalizedRoute}`;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Convert Express-style path parameters to OpenAPI format.
|
|
200
|
+
* Express uses `:param` syntax, OpenAPI uses `{param}` syntax.
|
|
201
|
+
*
|
|
202
|
+
* @param expressPath - Express-style path (e.g., '/users/:userId/posts/:postId')
|
|
203
|
+
* @returns OpenAPI-style path (e.g., '/users/{userId}/posts/{postId}')
|
|
204
|
+
*/
|
|
205
|
+
convertExpressPathToOpenAPI(expressPath) {
|
|
206
|
+
return expressPath.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g, '{$1}');
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Extract path parameter names from an Express-style path.
|
|
210
|
+
*
|
|
211
|
+
* @param expressPath - Express-style path (e.g., '/users/:userId/posts/:postId')
|
|
212
|
+
* @returns Array of parameter names (e.g., ['userId', 'postId'])
|
|
213
|
+
*/
|
|
214
|
+
extractPathParamNames(expressPath) {
|
|
215
|
+
const paramRegex = /:([a-zA-Z_][a-zA-Z0-9_]*)/g;
|
|
216
|
+
const params = [];
|
|
217
|
+
let match;
|
|
218
|
+
while ((match = paramRegex.exec(expressPath)) !== null) {
|
|
219
|
+
params.push(match[1]);
|
|
220
|
+
}
|
|
221
|
+
return params;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Build an OpenAPI operation object from a route definition.
|
|
225
|
+
* Assembles summary, description, tags, operationId, parameters,
|
|
226
|
+
* requestBody, responses, security, and deprecated flag.
|
|
227
|
+
*
|
|
228
|
+
* @param definition - The route definition to convert
|
|
229
|
+
* @returns The assembled OpenAPI operation object
|
|
230
|
+
*/
|
|
231
|
+
buildOperation(definition) {
|
|
232
|
+
const metadata = definition.openapi;
|
|
233
|
+
const operation = {};
|
|
234
|
+
// Basic metadata from .openapi()
|
|
235
|
+
if (metadata.summary) {
|
|
236
|
+
operation.summary = metadata.summary;
|
|
237
|
+
}
|
|
238
|
+
if (metadata.description) {
|
|
239
|
+
operation.description = metadata.description;
|
|
240
|
+
}
|
|
241
|
+
if (metadata.tags && metadata.tags.length > 0) {
|
|
242
|
+
operation.tags = metadata.tags;
|
|
243
|
+
}
|
|
244
|
+
if (metadata.operationId) {
|
|
245
|
+
operation.operationId = metadata.operationId;
|
|
246
|
+
}
|
|
247
|
+
if (metadata.deprecated) {
|
|
248
|
+
operation.deprecated = true;
|
|
249
|
+
}
|
|
250
|
+
// Build parameters (path params + query params for GET/DELETE)
|
|
251
|
+
const parameters = this.buildParameters(definition);
|
|
252
|
+
if (parameters.length > 0) {
|
|
253
|
+
operation.parameters = parameters;
|
|
254
|
+
}
|
|
255
|
+
// Build request body (for POST/PUT/PATCH with validation schema)
|
|
256
|
+
const requestBody = this.buildRequestBody(definition);
|
|
257
|
+
if (requestBody) {
|
|
258
|
+
operation.requestBody = requestBody;
|
|
259
|
+
}
|
|
260
|
+
// Build responses from metadata
|
|
261
|
+
const responses = this.buildResponses(definition);
|
|
262
|
+
if (Object.keys(responses).length > 0) {
|
|
263
|
+
operation.responses = responses;
|
|
264
|
+
}
|
|
265
|
+
// Apply security requirements for secure routes
|
|
266
|
+
const security = this.buildSecurity(definition);
|
|
267
|
+
if (security) {
|
|
268
|
+
operation.security = security;
|
|
269
|
+
}
|
|
270
|
+
return operation;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Build path parameters from the route path and metadata.
|
|
274
|
+
*
|
|
275
|
+
* @remarks
|
|
276
|
+
* Path parameters are extracted from Express `:param` syntax in the URL.
|
|
277
|
+
* If the metadata includes `pathParams` with schemas and descriptions,
|
|
278
|
+
* those are used to enrich the parameter definitions.
|
|
279
|
+
*
|
|
280
|
+
* For GET/DELETE routes with a validation schema, query parameters are
|
|
281
|
+
* also generated (handled in Session 2.2 — Zod conversion).
|
|
282
|
+
*
|
|
283
|
+
* @param definition - The route definition
|
|
284
|
+
* @returns Array of OpenAPI parameter objects
|
|
285
|
+
*/
|
|
286
|
+
buildParameters(definition) {
|
|
287
|
+
const parameters = [];
|
|
288
|
+
const fullPath = this.buildFullPath(this.routes.find(r => r.definition === definition)?.basePath || '', definition.path);
|
|
289
|
+
const pathParamNames = this.extractPathParamNames(fullPath);
|
|
290
|
+
const metadata = definition.openapi;
|
|
291
|
+
// Add path parameters
|
|
292
|
+
for (const paramName of pathParamNames) {
|
|
293
|
+
const paramMeta = metadata.pathParams?.[paramName];
|
|
294
|
+
const param = {
|
|
295
|
+
name: paramName,
|
|
296
|
+
in: 'path',
|
|
297
|
+
required: true, // Path parameters are always required per OpenAPI spec
|
|
298
|
+
};
|
|
299
|
+
if (paramMeta?.description) {
|
|
300
|
+
param.description = paramMeta.description;
|
|
301
|
+
}
|
|
302
|
+
// Schema conversion from Zod pathParams will be added in Session 2.2
|
|
303
|
+
// For now, default to string type
|
|
304
|
+
if (paramMeta?.schema) {
|
|
305
|
+
param.schema = this.convertZodToSchema(paramMeta.schema);
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
param.schema = { type: 'string' };
|
|
309
|
+
}
|
|
310
|
+
parameters.push(param);
|
|
311
|
+
}
|
|
312
|
+
// Query parameters for GET/DELETE routes with validation schemas
|
|
313
|
+
// (Zod→OpenAPI conversion will be implemented in Session 2.2)
|
|
314
|
+
if (this.isQueryParamMethod(definition.method) && definition.validation) {
|
|
315
|
+
const queryParams = this.convertZodToQueryParameters(definition.validation);
|
|
316
|
+
parameters.push(...queryParams);
|
|
317
|
+
}
|
|
318
|
+
return parameters;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Build request body from validation schema for POST/PUT/PATCH routes.
|
|
322
|
+
*
|
|
323
|
+
* @param definition - The route definition
|
|
324
|
+
* @returns OpenAPI request body object, or undefined for GET/DELETE routes
|
|
325
|
+
*/
|
|
326
|
+
buildRequestBody(definition) {
|
|
327
|
+
// Only POST, PUT, PATCH have request bodies
|
|
328
|
+
if (this.isQueryParamMethod(definition.method)) {
|
|
329
|
+
return undefined;
|
|
330
|
+
}
|
|
331
|
+
// Need a validation schema to generate request body
|
|
332
|
+
if (!definition.validation) {
|
|
333
|
+
return undefined;
|
|
334
|
+
}
|
|
335
|
+
// Zod→OpenAPI schema conversion (Session 2.2 will implement convertZodToSchema)
|
|
336
|
+
const schema = this.convertZodToSchema(definition.validation);
|
|
337
|
+
return {
|
|
338
|
+
required: true,
|
|
339
|
+
content: {
|
|
340
|
+
'application/json': {
|
|
341
|
+
schema,
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Build response objects from OpenAPI metadata.
|
|
348
|
+
*
|
|
349
|
+
* @param definition - The route definition
|
|
350
|
+
* @returns Record of status code → response object
|
|
351
|
+
*/
|
|
352
|
+
buildResponses(definition) {
|
|
353
|
+
const responses = {};
|
|
354
|
+
const metadata = definition.openapi;
|
|
355
|
+
if (!metadata.responses || metadata.responses.length === 0) {
|
|
356
|
+
return responses;
|
|
357
|
+
}
|
|
358
|
+
for (const responseDef of metadata.responses) {
|
|
359
|
+
const statusCode = String(responseDef.statusCode);
|
|
360
|
+
const response = {
|
|
361
|
+
description: responseDef.description,
|
|
362
|
+
};
|
|
363
|
+
// If a response schema is provided, convert it
|
|
364
|
+
// (Zod→OpenAPI conversion will be fully implemented in Session 2.2)
|
|
365
|
+
if (responseDef.schema) {
|
|
366
|
+
response.content = {
|
|
367
|
+
'application/json': {
|
|
368
|
+
schema: this.convertZodToSchema(responseDef.schema),
|
|
369
|
+
},
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
responses[statusCode] = response;
|
|
373
|
+
}
|
|
374
|
+
return responses;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Build security requirements for the operation.
|
|
378
|
+
* Routes with `secure: true` get the configured `defaultSecurity` applied.
|
|
379
|
+
* Routes without `secure` or with `secure: false` have no security.
|
|
380
|
+
*
|
|
381
|
+
* @param definition - The route definition
|
|
382
|
+
* @returns Array of security requirements, or undefined for public routes
|
|
383
|
+
*/
|
|
384
|
+
buildSecurity(definition) {
|
|
385
|
+
if (!definition.secure) {
|
|
386
|
+
return undefined;
|
|
387
|
+
}
|
|
388
|
+
// Apply default security from config when route is secure
|
|
389
|
+
if (this.config.defaultSecurity && this.config.defaultSecurity.length > 0) {
|
|
390
|
+
return this.config.defaultSecurity;
|
|
391
|
+
}
|
|
392
|
+
// Secure route but no default security configured — return empty array
|
|
393
|
+
// (indicates security is required but no specific scheme defined)
|
|
394
|
+
return [];
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Check if the HTTP method typically uses query parameters instead of request body.
|
|
398
|
+
* GET and DELETE routes use query parameters; POST, PUT, PATCH use request body.
|
|
399
|
+
*
|
|
400
|
+
* @param method - The HTTP method
|
|
401
|
+
* @returns True for GET and DELETE, false otherwise
|
|
402
|
+
*/
|
|
403
|
+
isQueryParamMethod(method) {
|
|
404
|
+
return method === 'get' || method === 'delete';
|
|
405
|
+
}
|
|
406
|
+
// ─── Zod → OpenAPI Conversion ───────────────────────────────────────────
|
|
407
|
+
/**
|
|
408
|
+
* Convert a Zod schema to an OpenAPI JSON Schema object.
|
|
409
|
+
*
|
|
410
|
+
* Delegates to the `zodToOpenAPISchema` function from the zod-to-openapi module,
|
|
411
|
+
* which introspects Zod v4's internal `_zod.def` structure to produce a complete
|
|
412
|
+
* OpenAPI-compatible JSON Schema.
|
|
413
|
+
*
|
|
414
|
+
* @param zodSchema - The Zod schema to convert (any Zod type)
|
|
415
|
+
* @returns An OpenAPI schema object with type, constraints, and nested definitions
|
|
416
|
+
*/
|
|
417
|
+
convertZodToSchema(zodSchema) {
|
|
418
|
+
return zodToOpenAPISchema(zodSchema);
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Convert a Zod object schema to an array of OpenAPI query parameters.
|
|
422
|
+
* Each top-level property of the Zod object becomes a separate query parameter.
|
|
423
|
+
*
|
|
424
|
+
* Delegates to the `zodToQueryParameters` function from the zod-to-openapi module.
|
|
425
|
+
* Optional properties become non-required parameters. Default values are preserved.
|
|
426
|
+
*
|
|
427
|
+
* @param zodSchema - The Zod schema (expected to be z.object())
|
|
428
|
+
* @returns Array of OpenAPI parameter objects with `in: 'query'`
|
|
429
|
+
*/
|
|
430
|
+
convertZodToQueryParameters(zodSchema) {
|
|
431
|
+
return zodToQueryParameters(zodSchema);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
//# sourceMappingURL=openapi-generator.js.map
|