reliant-type 1.0.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/LICENSE +21 -0
- package/README.md +1305 -0
- package/dist/cjs/constants/SECURITY_CONSTANTS.js +49 -0
- package/dist/cjs/constants/SECURITY_CONSTANTS.js.map +1 -0
- package/dist/cjs/constants/VALIDATION_CONSTANTS.js +103 -0
- package/dist/cjs/constants/VALIDATION_CONSTANTS.js.map +1 -0
- package/dist/cjs/core/schema/extensions/SmartInference.js +200 -0
- package/dist/cjs/core/schema/extensions/SmartInference.js.map +1 -0
- package/dist/cjs/core/schema/extensions/components/AutoDocumentation/Docs.js +100 -0
- package/dist/cjs/core/schema/extensions/components/AutoDocumentation/Docs.js.map +1 -0
- package/dist/cjs/core/schema/extensions/components/AutoDocumentation/DocumentationGenerator.js +192 -0
- package/dist/cjs/core/schema/extensions/components/AutoDocumentation/DocumentationGenerator.js.map +1 -0
- package/dist/cjs/core/schema/extensions/components/AutoDocumentation/InteractiveDocumentationGenerator.js +174 -0
- package/dist/cjs/core/schema/extensions/components/AutoDocumentation/InteractiveDocumentationGenerator.js.map +1 -0
- package/dist/cjs/core/schema/extensions/components/AutoDocumentation/SchemaAnalyzer.js +54 -0
- package/dist/cjs/core/schema/extensions/components/AutoDocumentation/SchemaAnalyzer.js.map +1 -0
- package/dist/cjs/core/schema/extensions/components/AutoDocumentation/TypeScriptGenerator.js +50 -0
- package/dist/cjs/core/schema/extensions/components/AutoDocumentation/TypeScriptGenerator.js.map +1 -0
- package/dist/cjs/core/schema/extensions/components/AutoDocumentation/index.js +15 -0
- package/dist/cjs/core/schema/extensions/components/AutoDocumentation/index.js.map +1 -0
- package/dist/cjs/core/schema/extensions/components/ConditionalValidation/ConditionalBuilder.js +70 -0
- package/dist/cjs/core/schema/extensions/components/ConditionalValidation/ConditionalBuilder.js.map +1 -0
- package/dist/cjs/core/schema/extensions/components/ConditionalValidation/ConditionalElse.js +40 -0
- package/dist/cjs/core/schema/extensions/components/ConditionalValidation/ConditionalElse.js.map +1 -0
- package/dist/cjs/core/schema/extensions/components/ConditionalValidation/ConditionalThen.js +19 -0
- package/dist/cjs/core/schema/extensions/components/ConditionalValidation/ConditionalThen.js.map +1 -0
- package/dist/cjs/core/schema/extensions/components/ConditionalValidation/MultiConditionalBuilder.js +20 -0
- package/dist/cjs/core/schema/extensions/components/ConditionalValidation/MultiConditionalBuilder.js.map +1 -0
- package/dist/cjs/core/schema/extensions/components/ConditionalValidation/MultiConditionalThen.js +49 -0
- package/dist/cjs/core/schema/extensions/components/ConditionalValidation/MultiConditionalThen.js.map +1 -0
- package/dist/cjs/core/schema/extensions/components/ConditionalValidation/index.js +98 -0
- package/dist/cjs/core/schema/extensions/components/ConditionalValidation/index.js.map +1 -0
- package/dist/cjs/core/schema/extensions/components/RealtimeValidation/FormValidator.js +85 -0
- package/dist/cjs/core/schema/extensions/components/RealtimeValidation/FormValidator.js.map +1 -0
- package/dist/cjs/core/schema/extensions/components/RealtimeValidation/LiveValidator.js +133 -0
- package/dist/cjs/core/schema/extensions/components/RealtimeValidation/LiveValidator.js.map +1 -0
- package/dist/cjs/core/schema/extensions/components/RealtimeValidation/StreamValidator.js +351 -0
- package/dist/cjs/core/schema/extensions/components/RealtimeValidation/StreamValidator.js.map +1 -0
- package/dist/cjs/core/schema/extensions/components/RealtimeValidation/index.js +109 -0
- package/dist/cjs/core/schema/extensions/components/RealtimeValidation/index.js.map +1 -0
- package/dist/cjs/core/schema/extensions/index.js +61 -0
- package/dist/cjs/core/schema/extensions/index.js.map +1 -0
- package/dist/cjs/core/schema/extensions/mods/index.js +51 -0
- package/dist/cjs/core/schema/extensions/mods/index.js.map +1 -0
- package/dist/cjs/core/schema/extensions/mods/openapi-converter.js +227 -0
- package/dist/cjs/core/schema/extensions/mods/openapi-converter.js.map +1 -0
- package/dist/cjs/core/schema/extensions/mods/typescript-generator.js +287 -0
- package/dist/cjs/core/schema/extensions/mods/typescript-generator.js.map +1 -0
- package/dist/cjs/core/schema/extensions/mods/validation-engine.js +224 -0
- package/dist/cjs/core/schema/extensions/mods/validation-engine.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/Interface.js +277 -0
- package/dist/cjs/core/schema/mode/interfaces/Interface.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/InterfaceSchema.js +1431 -0
- package/dist/cjs/core/schema/mode/interfaces/InterfaceSchema.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/conditional/evaluator/ConditionalEvaluator.js +520 -0
- package/dist/cjs/core/schema/mode/interfaces/conditional/evaluator/ConditionalEvaluator.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/conditional/parser/ConditionalAST.js +624 -0
- package/dist/cjs/core/schema/mode/interfaces/conditional/parser/ConditionalAST.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/conditional/parser/ConditionalLexer.js +811 -0
- package/dist/cjs/core/schema/mode/interfaces/conditional/parser/ConditionalLexer.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/conditional/parser/ConditionalParser.js +599 -0
- package/dist/cjs/core/schema/mode/interfaces/conditional/parser/ConditionalParser.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/conditional/types/ConditionalTypes.js +89 -0
- package/dist/cjs/core/schema/mode/interfaces/conditional/types/ConditionalTypes.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/errors/ErrorHandler.js +356 -0
- package/dist/cjs/core/schema/mode/interfaces/errors/ErrorHandler.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/errors/types/errors.type.js +80 -0
- package/dist/cjs/core/schema/mode/interfaces/errors/types/errors.type.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/precompilation/FieldPrecompilers.js +778 -0
- package/dist/cjs/core/schema/mode/interfaces/precompilation/FieldPrecompilers.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/precompilation/SchemaPrecompiler.js +523 -0
- package/dist/cjs/core/schema/mode/interfaces/precompilation/SchemaPrecompiler.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/typescript/ConditionalTypes.js +681 -0
- package/dist/cjs/core/schema/mode/interfaces/typescript/ConditionalTypes.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/typescript/IDESupport.js +430 -0
- package/dist/cjs/core/schema/mode/interfaces/typescript/IDESupport.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/typescript/TypeInference.js +225 -0
- package/dist/cjs/core/schema/mode/interfaces/typescript/TypeInference.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/typescript/index.js +44 -0
- package/dist/cjs/core/schema/mode/interfaces/typescript/index.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/validators/ConstraintParser.js +1134 -0
- package/dist/cjs/core/schema/mode/interfaces/validators/ConstraintParser.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/validators/TypeGuards.js +256 -0
- package/dist/cjs/core/schema/mode/interfaces/validators/TypeGuards.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/validators/TypeValidators.js +429 -0
- package/dist/cjs/core/schema/mode/interfaces/validators/TypeValidators.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/validators/UnionCache.js +404 -0
- package/dist/cjs/core/schema/mode/interfaces/validators/UnionCache.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/validators/ValidationHelpers.js +851 -0
- package/dist/cjs/core/schema/mode/interfaces/validators/ValidationHelpers.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/validators/mods/passValidator.js +262 -0
- package/dist/cjs/core/schema/mode/interfaces/validators/mods/passValidator.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/validators/mods/securityValidator.js +887 -0
- package/dist/cjs/core/schema/mode/interfaces/validators/mods/securityValidator.js.map +1 -0
- package/dist/cjs/core/schema/mode/interfaces/validators/mods/urlValidation.js +191 -0
- package/dist/cjs/core/schema/mode/interfaces/validators/mods/urlValidation.js.map +1 -0
- package/dist/cjs/core/schema/optimization/ObjectValidationCache.js +462 -0
- package/dist/cjs/core/schema/optimization/ObjectValidationCache.js.map +1 -0
- package/dist/cjs/core/schema/optimization/PerformanceMonitor.js +773 -0
- package/dist/cjs/core/schema/optimization/PerformanceMonitor.js.map +1 -0
- package/dist/cjs/core/schema/optimization/SchemaCompiler.js +600 -0
- package/dist/cjs/core/schema/optimization/SchemaCompiler.js.map +1 -0
- package/dist/cjs/core/types/ValidatorTypes.js +70 -0
- package/dist/cjs/core/types/ValidatorTypes.js.map +1 -0
- package/dist/cjs/core/types/parser.type.js +12 -0
- package/dist/cjs/core/types/parser.type.js.map +1 -0
- package/dist/cjs/core/utils/Make.js +61 -0
- package/dist/cjs/core/utils/Make.js.map +1 -0
- package/dist/cjs/core/utils/Mod.js +1033 -0
- package/dist/cjs/core/utils/Mod.js.map +1 -0
- package/dist/cjs/core/utils/UrlArgs.js +102 -0
- package/dist/cjs/core/utils/UrlArgs.js.map +1 -0
- package/dist/cjs/core/utils/arrayToEnum.js +18 -0
- package/dist/cjs/core/utils/arrayToEnum.js.map +1 -0
- package/dist/cjs/core/utils/createUrlArgsEnumFArray.js +13 -0
- package/dist/cjs/core/utils/createUrlArgsEnumFArray.js.map +1 -0
- package/dist/cjs/core/utils/securityHelpers.js +215 -0
- package/dist/cjs/core/utils/securityHelpers.js.map +1 -0
- package/dist/cjs/core/utils/securityValidatorHelpers.js +65 -0
- package/dist/cjs/core/utils/securityValidatorHelpers.js.map +1 -0
- package/dist/cjs/index.js +31 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/esm/constants/SECURITY_CONSTANTS.js +47 -0
- package/dist/esm/constants/SECURITY_CONSTANTS.js.map +1 -0
- package/dist/esm/constants/VALIDATION_CONSTANTS.js +98 -0
- package/dist/esm/constants/VALIDATION_CONSTANTS.js.map +1 -0
- package/dist/esm/core/schema/extensions/SmartInference.js +197 -0
- package/dist/esm/core/schema/extensions/SmartInference.js.map +1 -0
- package/dist/esm/core/schema/extensions/components/AutoDocumentation/Docs.js +98 -0
- package/dist/esm/core/schema/extensions/components/AutoDocumentation/Docs.js.map +1 -0
- package/dist/esm/core/schema/extensions/components/AutoDocumentation/DocumentationGenerator.js +190 -0
- package/dist/esm/core/schema/extensions/components/AutoDocumentation/DocumentationGenerator.js.map +1 -0
- package/dist/esm/core/schema/extensions/components/AutoDocumentation/InteractiveDocumentationGenerator.js +172 -0
- package/dist/esm/core/schema/extensions/components/AutoDocumentation/InteractiveDocumentationGenerator.js.map +1 -0
- package/dist/esm/core/schema/extensions/components/AutoDocumentation/SchemaAnalyzer.js +52 -0
- package/dist/esm/core/schema/extensions/components/AutoDocumentation/SchemaAnalyzer.js.map +1 -0
- package/dist/esm/core/schema/extensions/components/AutoDocumentation/TypeScriptGenerator.js +48 -0
- package/dist/esm/core/schema/extensions/components/AutoDocumentation/TypeScriptGenerator.js.map +1 -0
- package/dist/esm/core/schema/extensions/components/AutoDocumentation/index.js +12 -0
- package/dist/esm/core/schema/extensions/components/AutoDocumentation/index.js.map +1 -0
- package/dist/esm/core/schema/extensions/components/ConditionalValidation/ConditionalBuilder.js +68 -0
- package/dist/esm/core/schema/extensions/components/ConditionalValidation/ConditionalBuilder.js.map +1 -0
- package/dist/esm/core/schema/extensions/components/ConditionalValidation/ConditionalElse.js +38 -0
- package/dist/esm/core/schema/extensions/components/ConditionalValidation/ConditionalElse.js.map +1 -0
- package/dist/esm/core/schema/extensions/components/ConditionalValidation/ConditionalThen.js +17 -0
- package/dist/esm/core/schema/extensions/components/ConditionalValidation/ConditionalThen.js.map +1 -0
- package/dist/esm/core/schema/extensions/components/ConditionalValidation/MultiConditionalBuilder.js +18 -0
- package/dist/esm/core/schema/extensions/components/ConditionalValidation/MultiConditionalBuilder.js.map +1 -0
- package/dist/esm/core/schema/extensions/components/ConditionalValidation/MultiConditionalThen.js +45 -0
- package/dist/esm/core/schema/extensions/components/ConditionalValidation/MultiConditionalThen.js.map +1 -0
- package/dist/esm/core/schema/extensions/components/ConditionalValidation/index.js +92 -0
- package/dist/esm/core/schema/extensions/components/ConditionalValidation/index.js.map +1 -0
- package/dist/esm/core/schema/extensions/components/RealtimeValidation/FormValidator.js +83 -0
- package/dist/esm/core/schema/extensions/components/RealtimeValidation/FormValidator.js.map +1 -0
- package/dist/esm/core/schema/extensions/components/RealtimeValidation/LiveValidator.js +131 -0
- package/dist/esm/core/schema/extensions/components/RealtimeValidation/LiveValidator.js.map +1 -0
- package/dist/esm/core/schema/extensions/components/RealtimeValidation/StreamValidator.js +349 -0
- package/dist/esm/core/schema/extensions/components/RealtimeValidation/StreamValidator.js.map +1 -0
- package/dist/esm/core/schema/extensions/components/RealtimeValidation/index.js +103 -0
- package/dist/esm/core/schema/extensions/components/RealtimeValidation/index.js.map +1 -0
- package/dist/esm/core/schema/extensions/index.js +53 -0
- package/dist/esm/core/schema/extensions/index.js.map +1 -0
- package/dist/esm/core/schema/extensions/mods/index.js +47 -0
- package/dist/esm/core/schema/extensions/mods/index.js.map +1 -0
- package/dist/esm/core/schema/extensions/mods/openapi-converter.js +225 -0
- package/dist/esm/core/schema/extensions/mods/openapi-converter.js.map +1 -0
- package/dist/esm/core/schema/extensions/mods/typescript-generator.js +284 -0
- package/dist/esm/core/schema/extensions/mods/typescript-generator.js.map +1 -0
- package/dist/esm/core/schema/extensions/mods/validation-engine.js +222 -0
- package/dist/esm/core/schema/extensions/mods/validation-engine.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/Interface.js +269 -0
- package/dist/esm/core/schema/mode/interfaces/Interface.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/InterfaceSchema.js +1429 -0
- package/dist/esm/core/schema/mode/interfaces/InterfaceSchema.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/conditional/evaluator/ConditionalEvaluator.js +518 -0
- package/dist/esm/core/schema/mode/interfaces/conditional/evaluator/ConditionalEvaluator.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/conditional/parser/ConditionalAST.js +620 -0
- package/dist/esm/core/schema/mode/interfaces/conditional/parser/ConditionalAST.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/conditional/parser/ConditionalLexer.js +809 -0
- package/dist/esm/core/schema/mode/interfaces/conditional/parser/ConditionalLexer.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/conditional/parser/ConditionalParser.js +597 -0
- package/dist/esm/core/schema/mode/interfaces/conditional/parser/ConditionalParser.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/conditional/types/ConditionalTypes.js +89 -0
- package/dist/esm/core/schema/mode/interfaces/conditional/types/ConditionalTypes.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/errors/ErrorHandler.js +354 -0
- package/dist/esm/core/schema/mode/interfaces/errors/ErrorHandler.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/errors/types/errors.type.js +80 -0
- package/dist/esm/core/schema/mode/interfaces/errors/types/errors.type.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/precompilation/FieldPrecompilers.js +776 -0
- package/dist/esm/core/schema/mode/interfaces/precompilation/FieldPrecompilers.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/precompilation/SchemaPrecompiler.js +521 -0
- package/dist/esm/core/schema/mode/interfaces/precompilation/SchemaPrecompiler.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/typescript/ConditionalTypes.js +681 -0
- package/dist/esm/core/schema/mode/interfaces/typescript/ConditionalTypes.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/typescript/IDESupport.js +428 -0
- package/dist/esm/core/schema/mode/interfaces/typescript/IDESupport.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/typescript/TypeInference.js +223 -0
- package/dist/esm/core/schema/mode/interfaces/typescript/TypeInference.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/typescript/index.js +35 -0
- package/dist/esm/core/schema/mode/interfaces/typescript/index.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/validators/ConstraintParser.js +1132 -0
- package/dist/esm/core/schema/mode/interfaces/validators/ConstraintParser.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/validators/TypeGuards.js +254 -0
- package/dist/esm/core/schema/mode/interfaces/validators/TypeGuards.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/validators/TypeValidators.js +427 -0
- package/dist/esm/core/schema/mode/interfaces/validators/TypeValidators.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/validators/UnionCache.js +400 -0
- package/dist/esm/core/schema/mode/interfaces/validators/UnionCache.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/validators/ValidationHelpers.js +849 -0
- package/dist/esm/core/schema/mode/interfaces/validators/ValidationHelpers.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/validators/mods/passValidator.js +260 -0
- package/dist/esm/core/schema/mode/interfaces/validators/mods/passValidator.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/validators/mods/securityValidator.js +881 -0
- package/dist/esm/core/schema/mode/interfaces/validators/mods/securityValidator.js.map +1 -0
- package/dist/esm/core/schema/mode/interfaces/validators/mods/urlValidation.js +189 -0
- package/dist/esm/core/schema/mode/interfaces/validators/mods/urlValidation.js.map +1 -0
- package/dist/esm/core/schema/optimization/ObjectValidationCache.js +460 -0
- package/dist/esm/core/schema/optimization/ObjectValidationCache.js.map +1 -0
- package/dist/esm/core/schema/optimization/PerformanceMonitor.js +771 -0
- package/dist/esm/core/schema/optimization/PerformanceMonitor.js.map +1 -0
- package/dist/esm/core/schema/optimization/SchemaCompiler.js +598 -0
- package/dist/esm/core/schema/optimization/SchemaCompiler.js.map +1 -0
- package/dist/esm/core/types/ValidatorTypes.js +65 -0
- package/dist/esm/core/types/ValidatorTypes.js.map +1 -0
- package/dist/esm/core/types/parser.type.js +12 -0
- package/dist/esm/core/types/parser.type.js.map +1 -0
- package/dist/esm/core/utils/Make.js +59 -0
- package/dist/esm/core/utils/Make.js.map +1 -0
- package/dist/esm/core/utils/Mod.js +1031 -0
- package/dist/esm/core/utils/Mod.js.map +1 -0
- package/dist/esm/core/utils/UrlArgs.js +98 -0
- package/dist/esm/core/utils/UrlArgs.js.map +1 -0
- package/dist/esm/core/utils/arrayToEnum.js +16 -0
- package/dist/esm/core/utils/arrayToEnum.js.map +1 -0
- package/dist/esm/core/utils/createUrlArgsEnumFArray.js +11 -0
- package/dist/esm/core/utils/createUrlArgsEnumFArray.js.map +1 -0
- package/dist/esm/core/utils/securityHelpers.js +207 -0
- package/dist/esm/core/utils/securityHelpers.js.map +1 -0
- package/dist/esm/core/utils/securityValidatorHelpers.js +62 -0
- package/dist/esm/core/utils/securityValidatorHelpers.js.map +1 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/schema.d.ts +2595 -0
- package/docs/ALL_TYPES.md +120 -0
- package/docs/API-STABILITY.md +336 -0
- package/docs/CONDITIONAL-VALIDATION.md +637 -0
- package/docs/EXAMPLES.md +876 -0
- package/docs/FIELD-TYPES.md +829 -0
- package/docs/GETTING-STARTED.md +394 -0
- package/docs/LIVE-UTILITY.md +1137 -0
- package/docs/QUICK-REFERENCE.md +346 -0
- package/docs/README.md +205 -0
- package/docs/VSCODE-EXTENSION.md +458 -0
- package/package.json +219 -0
- package/src/bench/BENCHMARK-RESULTS.md +211 -0
- package/src/bench/benchmark-results.json +148 -0
- package/src/bench/performance-comparison.ts +218 -0
- package/src/bench/precompilation-benchmark.ts +218 -0
- package/src/constants/SECURITY_CONSTANTS.ts +44 -0
- package/src/constants/VALIDATION_CONSTANTS.ts +176 -0
- package/src/core/README.md +395 -0
- package/src/core/compiler/SchemaTransformer.ts +279 -0
- package/src/core/compiler/TypeAnalyzer.ts +378 -0
- package/src/core/compiler/TypeScriptCompilerIntegration.ts +220 -0
- package/src/core/compiler/TypeToSchemaConverter.ts +288 -0
- package/src/core/index.ts +70 -0
- package/src/core/schema/extensions/AutoDocumentation.ts +572 -0
- package/src/core/schema/extensions/ConditionalValidation.ts +330 -0
- package/src/core/schema/extensions/README.md +171 -0
- package/src/core/schema/extensions/RealtimeValidation.ts +656 -0
- package/src/core/schema/extensions/SmartInference.ts +224 -0
- package/src/core/schema/extensions/components/AutoDocumentation/Docs.ts +98 -0
- package/src/core/schema/extensions/components/AutoDocumentation/DocumentationGenerator.ts +201 -0
- package/src/core/schema/extensions/components/AutoDocumentation/InteractiveDocumentationGenerator.ts +176 -0
- package/src/core/schema/extensions/components/AutoDocumentation/OpenAPIGenerator.ts +175 -0
- package/src/core/schema/extensions/components/AutoDocumentation/SchemaAnalyzer.ts +49 -0
- package/src/core/schema/extensions/components/AutoDocumentation/TypeScriptGenerator.ts +54 -0
- package/src/core/schema/extensions/components/AutoDocumentation/index.ts +17 -0
- package/src/core/schema/extensions/components/ConditionalValidation/ConditionalBuilder.ts +101 -0
- package/src/core/schema/extensions/components/ConditionalValidation/ConditionalElse.ts +65 -0
- package/src/core/schema/extensions/components/ConditionalValidation/ConditionalThen.ts +33 -0
- package/src/core/schema/extensions/components/ConditionalValidation/Extend.ts +75 -0
- package/src/core/schema/extensions/components/ConditionalValidation/MultiConditionalBuilder.ts +16 -0
- package/src/core/schema/extensions/components/ConditionalValidation/MultiConditionalThen.ts +50 -0
- package/src/core/schema/extensions/components/ConditionalValidation/index.ts +104 -0
- package/src/core/schema/extensions/components/RealtimeValidation/FormValidator.ts +88 -0
- package/src/core/schema/extensions/components/RealtimeValidation/LiveValidator.ts +171 -0
- package/src/core/schema/extensions/components/RealtimeValidation/StreamValidator.ts +397 -0
- package/src/core/schema/extensions/components/RealtimeValidation/index.ts +114 -0
- package/src/core/schema/extensions/index.ts +76 -0
- package/src/core/schema/extensions/mods/index.ts +131 -0
- package/src/core/schema/extensions/mods/openapi-converter.ts +338 -0
- package/src/core/schema/extensions/mods/typescript-generator.ts +379 -0
- package/src/core/schema/extensions/mods/validation-engine.ts +295 -0
- package/src/core/schema/mode/interfaces/Interface.ts +364 -0
- package/src/core/schema/mode/interfaces/InterfaceSchema.ts +1838 -0
- package/src/core/schema/mode/interfaces/README.md +278 -0
- package/src/core/schema/mode/interfaces/conditional/evaluator/ConditionalEvaluator.ts +657 -0
- package/src/core/schema/mode/interfaces/conditional/parser/ConditionalAST.ts +826 -0
- package/src/core/schema/mode/interfaces/conditional/parser/ConditionalLexer.ts +992 -0
- package/src/core/schema/mode/interfaces/conditional/parser/ConditionalParser.ts +803 -0
- package/src/core/schema/mode/interfaces/conditional/parser/readme.md +406 -0
- package/src/core/schema/mode/interfaces/conditional/types/ConditionalTypes.ts +273 -0
- package/src/core/schema/mode/interfaces/errors/ErrorHandler.ts +624 -0
- package/src/core/schema/mode/interfaces/errors/types/errors.type.ts +102 -0
- package/src/core/schema/mode/interfaces/precompilation/FieldPrecompilers.ts +962 -0
- package/src/core/schema/mode/interfaces/precompilation/SchemaPrecompiler.ts +667 -0
- package/src/core/schema/mode/interfaces/typescript/ConditionalTypes.ts +1534 -0
- package/src/core/schema/mode/interfaces/typescript/IDESupport.ts +534 -0
- package/src/core/schema/mode/interfaces/typescript/TypeInference.ts +737 -0
- package/src/core/schema/mode/interfaces/typescript/index.ts +92 -0
- package/src/core/schema/mode/interfaces/validators/ConstraintParser.ts +1438 -0
- package/src/core/schema/mode/interfaces/validators/EnhancedErrorReporting.ts +227 -0
- package/src/core/schema/mode/interfaces/validators/TypeGuards.ts +288 -0
- package/src/core/schema/mode/interfaces/validators/TypeValidators.ts +660 -0
- package/src/core/schema/mode/interfaces/validators/UnionCache.ts +508 -0
- package/src/core/schema/mode/interfaces/validators/ValidationHelpers.ts +1257 -0
- package/src/core/schema/mode/interfaces/validators/index.ts +21 -0
- package/src/core/schema/mode/interfaces/validators/mods/passValidator.ts +424 -0
- package/src/core/schema/mode/interfaces/validators/mods/securityValidator.ts +1634 -0
- package/src/core/schema/mode/interfaces/validators/mods/urlValidation.ts +333 -0
- package/src/core/schema/optimization/ObjectValidationCache.ts +560 -0
- package/src/core/schema/optimization/PerformanceInitializer.ts +188 -0
- package/src/core/schema/optimization/PerformanceMonitor.ts +898 -0
- package/src/core/schema/optimization/SchemaCompiler.ts +730 -0
- package/src/core/testing/TestDataGenerator.ts +590 -0
- package/src/core/types/SchemaValidator.type.ts +210 -0
- package/src/core/types/ValidatorTypes.ts +93 -0
- package/src/core/types/extension.type.ts +109 -0
- package/src/core/types/objValidationCache.ts +17 -0
- package/src/core/types/parser.type.ts +15 -0
- package/src/core/types/perfoMonitor.ts +37 -0
- package/src/core/types/scompiler.ts +22 -0
- package/src/core/types/securityValidator.type.ts +10 -0
- package/src/core/types/types.ts +154 -0
- package/src/core/utils/Make.ts +97 -0
- package/src/core/utils/Mod.ts +1168 -0
- package/src/core/utils/UrlArgs.ts +124 -0
- package/src/core/utils/arrayToEnum.ts +89 -0
- package/src/core/utils/createUrlArgsEnumFArray.ts +11 -0
- package/src/core/utils/securityHelpers.ts +341 -0
- package/src/core/utils/securityValidatorHelpers.ts +76 -0
- package/src/index.ts +124 -0
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto Documentation - schema documentation generator
|
|
3
|
+
*
|
|
4
|
+
* This module automatically generates beautiful documentation from schemas,
|
|
5
|
+
* including API docs, type definitions, and interactive examples.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { SchemaInterface } from "../mode/interfaces/Interface";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Auto documentation utilities
|
|
12
|
+
*/
|
|
13
|
+
export const Docs = {
|
|
14
|
+
/**
|
|
15
|
+
* Generate comprehensive documentation from schema
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const UserSchema = Interface({
|
|
20
|
+
* id: "uuid",
|
|
21
|
+
* email: "email",
|
|
22
|
+
* name: "string(2,50)",
|
|
23
|
+
* age: "int(18,120)?",
|
|
24
|
+
* role: Make.union("user", "admin", "moderator")
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* const documentation = Docs.generate(UserSchema, {
|
|
28
|
+
* title: "User API",
|
|
29
|
+
* description: "User management endpoints",
|
|
30
|
+
* examples: true,
|
|
31
|
+
* interactive: true
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* console.log(documentation.markdown);
|
|
35
|
+
* console.log(documentation.html);
|
|
36
|
+
* console.log(documentation.openapi);
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
generate(schema: SchemaInterface, options: DocumentationOptions = {}): Documentation {
|
|
40
|
+
return new DocumentationGenerator(schema, options).generate();
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Generate OpenAPI specification from schema
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const openApiSpec = Docs.openapi(UserSchema, {
|
|
49
|
+
* title: "User API",
|
|
50
|
+
* version: "1.0.0",
|
|
51
|
+
* servers: ["https://api.example.com"]
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
openapi(schema: SchemaInterface, options: OpenAPIOptions): OpenAPISpec {
|
|
56
|
+
return new OpenAPIGenerator(schema, options).generate();
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Generate TypeScript type definitions
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const typeDefinitions = Docs.typescript(UserSchema, {
|
|
65
|
+
* exportName: "User",
|
|
66
|
+
* namespace: "API"
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* // Generates:
|
|
70
|
+
* // export interface User {
|
|
71
|
+
* // id: string;
|
|
72
|
+
* // email: string;
|
|
73
|
+
* // name: string;
|
|
74
|
+
* // age?: number;
|
|
75
|
+
* // role: "user" | "admin" | "moderator";
|
|
76
|
+
* // }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
typescript(schema: SchemaInterface, options: TypeScriptOptions = {}): string {
|
|
80
|
+
return new TypeScriptGenerator(schema, options).generate();
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Generate interactive documentation with live examples
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* const interactiveDocs = Docs.interactive(UserSchema, {
|
|
89
|
+
* title: "User Schema Playground",
|
|
90
|
+
* theme: "dark",
|
|
91
|
+
* showExamples: true,
|
|
92
|
+
* allowTesting: true
|
|
93
|
+
* });
|
|
94
|
+
*
|
|
95
|
+
* document.body.innerHTML = interactiveDocs.html;
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
interactive(schema: SchemaInterface, options: InteractiveOptions = {}): InteractiveDocumentation {
|
|
99
|
+
return new InteractiveDocumentationGenerator(schema, options).generate();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Main documentation generator
|
|
105
|
+
*/
|
|
106
|
+
class DocumentationGenerator {
|
|
107
|
+
constructor(
|
|
108
|
+
private schema: SchemaInterface,
|
|
109
|
+
private options: DocumentationOptions
|
|
110
|
+
) {}
|
|
111
|
+
|
|
112
|
+
generate(): Documentation {
|
|
113
|
+
const analyzer = new SchemaAnalyzer(this.schema);
|
|
114
|
+
const analysis = analyzer.analyze();
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
markdown: this.generateMarkdown(analysis),
|
|
118
|
+
html: this.generateHTML(analysis),
|
|
119
|
+
openapi: this.generateOpenAPI(analysis),
|
|
120
|
+
json: this.generateJSON(analysis),
|
|
121
|
+
examples: this.generateExamples(analysis)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private generateMarkdown(analysis: SchemaAnalysis): string {
|
|
126
|
+
const { title = "Schema Documentation", description = "" } = this.options;
|
|
127
|
+
|
|
128
|
+
let markdown = `# ${title}\n\n`;
|
|
129
|
+
if (description) {
|
|
130
|
+
markdown += `${description}\n\n`;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
markdown += "## Schema Structure\n\n";
|
|
134
|
+
markdown += this.generateFieldTable(analysis.fields);
|
|
135
|
+
|
|
136
|
+
if (this.options.examples) {
|
|
137
|
+
markdown += "\n## Examples\n\n";
|
|
138
|
+
markdown += this.generateExampleMarkdown(analysis);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return markdown;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private generateHTML(analysis: SchemaAnalysis): string {
|
|
145
|
+
const { title = "Schema Documentation" } = this.options;
|
|
146
|
+
|
|
147
|
+
return `
|
|
148
|
+
<!DOCTYPE html>
|
|
149
|
+
<html>
|
|
150
|
+
<head>
|
|
151
|
+
<title>${title}</title>
|
|
152
|
+
<style>
|
|
153
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
|
|
154
|
+
.field { margin: 1rem 0; padding: 1rem; border: 1px solid #e1e5e9; border-radius: 6px; }
|
|
155
|
+
.field-name { font-weight: bold; color: #0366d6; }
|
|
156
|
+
.field-type { color: #6f42c1; font-family: monospace; }
|
|
157
|
+
.field-description { color: #586069; margin-top: 0.5rem; }
|
|
158
|
+
.example { background: #f6f8fa; padding: 1rem; border-radius: 6px; margin: 1rem 0; }
|
|
159
|
+
pre { background: #f6f8fa; padding: 1rem; border-radius: 6px; overflow-x: auto; }
|
|
160
|
+
</style>
|
|
161
|
+
</head>
|
|
162
|
+
<body>
|
|
163
|
+
<h1>${title}</h1>
|
|
164
|
+
${this.generateFieldHTML(analysis.fields)}
|
|
165
|
+
${this.options.examples ? this.generateExampleHTML(analysis) : ''}
|
|
166
|
+
</body>
|
|
167
|
+
</html>`;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
private generateOpenAPI(analysis: SchemaAnalysis): OpenAPISpec {
|
|
171
|
+
return {
|
|
172
|
+
openapi: "3.0.0",
|
|
173
|
+
info: {
|
|
174
|
+
title: this.options.title || "API Documentation",
|
|
175
|
+
version: "1.0.0"
|
|
176
|
+
},
|
|
177
|
+
components: {
|
|
178
|
+
schemas: {
|
|
179
|
+
[this.options.title || "Schema"]: this.convertToOpenAPISchema(analysis)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
private generateJSON(analysis: SchemaAnalysis): any {
|
|
186
|
+
return {
|
|
187
|
+
schema: this.schema,
|
|
188
|
+
analysis,
|
|
189
|
+
metadata: {
|
|
190
|
+
generatedAt: new Date().toISOString(),
|
|
191
|
+
version: "1.0.0"
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private generateExamples(analysis: SchemaAnalysis): any[] {
|
|
197
|
+
return [
|
|
198
|
+
this.generateValidExample(analysis),
|
|
199
|
+
this.generateInvalidExample(analysis)
|
|
200
|
+
];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
private generateFieldTable(fields: FieldInfo[]): string {
|
|
204
|
+
let table = "| Field | Type | Required | Description |\n";
|
|
205
|
+
table += "|-------|------|----------|-------------|\n";
|
|
206
|
+
|
|
207
|
+
fields.forEach(field => {
|
|
208
|
+
table += `| ${field.name} | \`${field.type}\` | ${field.required ? 'Yes' : 'No'} | ${field.description || ''} |\n`;
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
return table;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
private generateFieldHTML(fields: FieldInfo[]): string {
|
|
215
|
+
return fields.map(field => `
|
|
216
|
+
<div class="field">
|
|
217
|
+
<div class="field-name">${field.name}</div>
|
|
218
|
+
<div class="field-type">${field.type}</div>
|
|
219
|
+
<div class="field-description">${field.description || ''}</div>
|
|
220
|
+
</div>
|
|
221
|
+
`).join('');
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private generateExampleMarkdown(analysis: SchemaAnalysis): string {
|
|
225
|
+
const example = this.generateValidExample(analysis);
|
|
226
|
+
return `\`\`\`json\n${JSON.stringify(example, null, 2)}\n\`\`\``;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
private generateExampleHTML(analysis: SchemaAnalysis): string {
|
|
230
|
+
const example = this.generateValidExample(analysis);
|
|
231
|
+
return `<div class="example"><pre>${JSON.stringify(example, null, 2)}</pre></div>`;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private generateValidExample(analysis: SchemaAnalysis): any {
|
|
235
|
+
const example: any = {};
|
|
236
|
+
|
|
237
|
+
analysis.fields.forEach(field => {
|
|
238
|
+
if (field.required || Math.random() > 0.3) { // Include some optional fields
|
|
239
|
+
example[field.name] = this.generateExampleValue(field.type);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
return example;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
private generateInvalidExample(analysis: SchemaAnalysis): any {
|
|
247
|
+
const example = this.generateValidExample(analysis);
|
|
248
|
+
// Introduce some invalid data
|
|
249
|
+
if (example.email) example.email = "invalid-email";
|
|
250
|
+
if (example.age) example.age = -5;
|
|
251
|
+
return example;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
private generateExampleValue(type: string): any {
|
|
255
|
+
if (type === "email") return "user@example.com";
|
|
256
|
+
if (type === "uuid") return "550e8400-e29b-41d4-a716-446655440000";
|
|
257
|
+
if (type === "url") return "https://example.com";
|
|
258
|
+
if (type.startsWith("string")) return "Example string";
|
|
259
|
+
if (type.includes("number") || type === "positive" || type === "int") return 42;
|
|
260
|
+
if (type === "boolean") return true;
|
|
261
|
+
if (type === "date") return new Date().toISOString();
|
|
262
|
+
if (type.includes("[]")) return ["item1", "item2"];
|
|
263
|
+
return "example";
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
private convertToOpenAPISchema(analysis: SchemaAnalysis): any {
|
|
267
|
+
const properties: any = {};
|
|
268
|
+
const required: string[] = [];
|
|
269
|
+
|
|
270
|
+
analysis.fields.forEach(field => {
|
|
271
|
+
properties[field.name] = this.convertFieldToOpenAPI(field);
|
|
272
|
+
if (field.required) {
|
|
273
|
+
required.push(field.name);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
return {
|
|
278
|
+
type: "object",
|
|
279
|
+
properties,
|
|
280
|
+
required
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
private convertFieldToOpenAPI(field: FieldInfo): any {
|
|
285
|
+
const type = field.type;
|
|
286
|
+
|
|
287
|
+
if (type === "email") return { type: "string", format: "email" };
|
|
288
|
+
if (type === "uuid") return { type: "string", format: "uuid" };
|
|
289
|
+
if (type === "url") return { type: "string", format: "uri" };
|
|
290
|
+
if (type.startsWith("string")) return { type: "string" };
|
|
291
|
+
if (type.includes("number") || type === "positive" || type === "int") return { type: "number" };
|
|
292
|
+
if (type === "boolean") return { type: "boolean" };
|
|
293
|
+
if (type === "date") return { type: "string", format: "date-time" };
|
|
294
|
+
if (type.includes("[]")) return { type: "array", items: { type: "string" } };
|
|
295
|
+
|
|
296
|
+
return { type: "string" };
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Schema analyzer for extracting field information
|
|
302
|
+
*/
|
|
303
|
+
class SchemaAnalyzer {
|
|
304
|
+
constructor(private schema: SchemaInterface) {}
|
|
305
|
+
|
|
306
|
+
analyze(): SchemaAnalysis {
|
|
307
|
+
const fields: FieldInfo[] = [];
|
|
308
|
+
|
|
309
|
+
Object.entries(this.schema).forEach(([name, type]) => {
|
|
310
|
+
fields.push(this.analyzeField(name, type));
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
return {
|
|
314
|
+
fields,
|
|
315
|
+
totalFields: fields.length,
|
|
316
|
+
requiredFields: fields.filter(f => f.required).length,
|
|
317
|
+
optionalFields: fields.filter(f => !f.required).length
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private analyzeField(name: string, type: any): FieldInfo {
|
|
322
|
+
const typeStr = typeof type === "string" ? type : JSON.stringify(type);
|
|
323
|
+
const required = !typeStr.includes("?");
|
|
324
|
+
|
|
325
|
+
return {
|
|
326
|
+
name,
|
|
327
|
+
type: typeStr,
|
|
328
|
+
required,
|
|
329
|
+
description: this.generateFieldDescription(name, typeStr)
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
private generateFieldDescription(name: string, type: string): string {
|
|
334
|
+
if (type === "email") return "Email address";
|
|
335
|
+
if (type === "uuid") return "Unique identifier";
|
|
336
|
+
if (type === "url") return "URL address";
|
|
337
|
+
if (type.includes("string")) return "Text value";
|
|
338
|
+
if (type.includes("number")) return "Numeric value";
|
|
339
|
+
if (type === "boolean") return "True/false value";
|
|
340
|
+
if (type === "date") return "Date and time";
|
|
341
|
+
if (type.includes("[]")) return "Array of values";
|
|
342
|
+
|
|
343
|
+
return `${name} field`;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* TypeScript generator
|
|
349
|
+
*/
|
|
350
|
+
class TypeScriptGenerator {
|
|
351
|
+
constructor(
|
|
352
|
+
private schema: SchemaInterface,
|
|
353
|
+
private options: TypeScriptOptions
|
|
354
|
+
) {}
|
|
355
|
+
|
|
356
|
+
generate(): string {
|
|
357
|
+
const { exportName = "Schema", namespace } = this.options;
|
|
358
|
+
|
|
359
|
+
let output = "";
|
|
360
|
+
|
|
361
|
+
if (namespace) {
|
|
362
|
+
output += `export namespace ${namespace} {\n`;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
output += `export interface ${exportName} {\n`;
|
|
366
|
+
|
|
367
|
+
Object.entries(this.schema).forEach(([name, type]) => {
|
|
368
|
+
const tsType = this.convertToTypeScript(type);
|
|
369
|
+
const optional = typeof type === "string" && type.includes("?") ? "?" : "";
|
|
370
|
+
output += ` ${name}${optional}: ${tsType};\n`;
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
output += "}\n";
|
|
374
|
+
|
|
375
|
+
if (namespace) {
|
|
376
|
+
output += "}\n";
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
return output;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
private convertToTypeScript(type: any): string {
|
|
383
|
+
if (typeof type === "string") {
|
|
384
|
+
const cleanType = type.replace("?", "");
|
|
385
|
+
|
|
386
|
+
if (cleanType === "email" || cleanType === "uuid" || cleanType === "url") return "string";
|
|
387
|
+
if (cleanType.startsWith("string")) return "string";
|
|
388
|
+
if (cleanType.includes("number") || cleanType === "positive" || cleanType === "int") return "number";
|
|
389
|
+
if (cleanType === "boolean") return "boolean";
|
|
390
|
+
if (cleanType === "date") return "Date";
|
|
391
|
+
if (cleanType.includes("[]")) return `${this.convertToTypeScript(cleanType.replace("[]", ""))}[]`;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
return "any";
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Interactive documentation generator
|
|
400
|
+
*/
|
|
401
|
+
class InteractiveDocumentationGenerator {
|
|
402
|
+
constructor(
|
|
403
|
+
private schema: SchemaInterface,
|
|
404
|
+
private options: InteractiveOptions
|
|
405
|
+
) {}
|
|
406
|
+
|
|
407
|
+
generate(): InteractiveDocumentation {
|
|
408
|
+
return {
|
|
409
|
+
html: this.generateInteractiveHTML(),
|
|
410
|
+
css: this.generateCSS(),
|
|
411
|
+
javascript: this.generateJavaScript()
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
private generateInteractiveHTML(): string {
|
|
416
|
+
return `
|
|
417
|
+
<div id="schema-playground">
|
|
418
|
+
<h1>${this.options.title || 'Schema Playground'}</h1>
|
|
419
|
+
<div class="playground-container">
|
|
420
|
+
<div class="schema-panel">
|
|
421
|
+
<h2>Schema</h2>
|
|
422
|
+
<pre id="schema-display"></pre>
|
|
423
|
+
</div>
|
|
424
|
+
<div class="input-panel">
|
|
425
|
+
<h2>Test Data</h2>
|
|
426
|
+
<textarea id="test-input" placeholder="Enter JSON data to validate..."></textarea>
|
|
427
|
+
<button id="validate-btn">Validate</button>
|
|
428
|
+
</div>
|
|
429
|
+
<div class="result-panel">
|
|
430
|
+
<h2>Result</h2>
|
|
431
|
+
<div id="validation-result"></div>
|
|
432
|
+
</div>
|
|
433
|
+
</div>
|
|
434
|
+
</div>`;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
private generateCSS(): string {
|
|
438
|
+
return `
|
|
439
|
+
.playground-container { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
|
|
440
|
+
.schema-panel, .input-panel, .result-panel { border: 1px solid #e1e5e9; border-radius: 6px; padding: 1rem; }
|
|
441
|
+
#test-input { width: 100%; height: 200px; font-family: monospace; }
|
|
442
|
+
#validate-btn { background: #0366d6; color: white; border: none; padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; }
|
|
443
|
+
.valid { color: #28a745; }
|
|
444
|
+
.invalid { color: #dc3545; }`;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
private generateJavaScript(): string {
|
|
448
|
+
return `
|
|
449
|
+
document.getElementById('schema-display').textContent = ${JSON.stringify(this.schema, null, 2)};
|
|
450
|
+
document.getElementById('validate-btn').addEventListener('click', function() {
|
|
451
|
+
const input = document.getElementById('test-input').value;
|
|
452
|
+
const result = document.getElementById('validation-result');
|
|
453
|
+
|
|
454
|
+
try {
|
|
455
|
+
const data = JSON.parse(input);
|
|
456
|
+
// Validation logic would go here
|
|
457
|
+
result.innerHTML = '<div class="valid">✓ Valid data</div>';
|
|
458
|
+
} catch (e) {
|
|
459
|
+
result.innerHTML = '<div class="invalid">✗ Invalid JSON</div>';
|
|
460
|
+
}
|
|
461
|
+
});`;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* OpenAPI generator
|
|
467
|
+
*/
|
|
468
|
+
class OpenAPIGenerator {
|
|
469
|
+
constructor(
|
|
470
|
+
private schema: SchemaInterface,
|
|
471
|
+
private options: OpenAPIOptions
|
|
472
|
+
) {}
|
|
473
|
+
|
|
474
|
+
generate(): OpenAPISpec {
|
|
475
|
+
return {
|
|
476
|
+
openapi: "3.0.0",
|
|
477
|
+
info: {
|
|
478
|
+
title: this.options.title,
|
|
479
|
+
version: this.options.version
|
|
480
|
+
},
|
|
481
|
+
servers: this.options.servers?.map(url => ({ url })) || [],
|
|
482
|
+
components: {
|
|
483
|
+
schemas: {
|
|
484
|
+
[this.options.title]: this.convertSchema()
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
private convertSchema(): any {
|
|
491
|
+
// Implementation would convert schema to OpenAPI format
|
|
492
|
+
return {
|
|
493
|
+
type: "object",
|
|
494
|
+
properties: {},
|
|
495
|
+
required: []
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Type definitions
|
|
502
|
+
*/
|
|
503
|
+
interface DocumentationOptions {
|
|
504
|
+
title?: string;
|
|
505
|
+
description?: string;
|
|
506
|
+
examples?: boolean;
|
|
507
|
+
interactive?: boolean;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
interface OpenAPIOptions {
|
|
511
|
+
title: string;
|
|
512
|
+
version: string;
|
|
513
|
+
servers?: string[];
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
interface TypeScriptOptions {
|
|
517
|
+
exportName?: string;
|
|
518
|
+
namespace?: string;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
interface InteractiveOptions {
|
|
522
|
+
title?: string;
|
|
523
|
+
theme?: "light" | "dark";
|
|
524
|
+
showExamples?: boolean;
|
|
525
|
+
allowTesting?: boolean;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
interface Documentation {
|
|
529
|
+
markdown: string;
|
|
530
|
+
html: string;
|
|
531
|
+
openapi: OpenAPISpec;
|
|
532
|
+
json: any;
|
|
533
|
+
examples: any[];
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
interface InteractiveDocumentation {
|
|
537
|
+
html: string;
|
|
538
|
+
css: string;
|
|
539
|
+
javascript: string;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
interface OpenAPISpec {
|
|
543
|
+
openapi: string;
|
|
544
|
+
info: {
|
|
545
|
+
title: string;
|
|
546
|
+
version: string;
|
|
547
|
+
};
|
|
548
|
+
servers?: Array<{ url: string }>;
|
|
549
|
+
components: {
|
|
550
|
+
schemas: Record<string, any>;
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
interface SchemaAnalysis {
|
|
555
|
+
fields: FieldInfo[];
|
|
556
|
+
totalFields: number;
|
|
557
|
+
requiredFields: number;
|
|
558
|
+
optionalFields: number;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
interface FieldInfo {
|
|
562
|
+
name: string;
|
|
563
|
+
type: string;
|
|
564
|
+
required: boolean;
|
|
565
|
+
description: string;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* Export all utilities
|
|
570
|
+
*/
|
|
571
|
+
export { DocumentationGenerator, SchemaAnalyzer, TypeScriptGenerator };
|
|
572
|
+
export default Docs;
|