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,811 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ConditionalTypes = require('../types/ConditionalTypes.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Enhanced Conditional Lexer
|
|
7
|
+
*
|
|
8
|
+
* Tokenizes conditional syntax with support for:
|
|
9
|
+
* - Nested conditions
|
|
10
|
+
* - Logical operators (&&, ||)
|
|
11
|
+
* - Method calls (.in(), .exists, etc.)
|
|
12
|
+
* - Complex expressions
|
|
13
|
+
* - Improved error handling and recovery
|
|
14
|
+
* - Performance optimizations
|
|
15
|
+
* - Better memory management
|
|
16
|
+
*/
|
|
17
|
+
class ConditionalLexer {
|
|
18
|
+
constructor(input) {
|
|
19
|
+
this._position = 0;
|
|
20
|
+
this._line = 1;
|
|
21
|
+
this._column = 1;
|
|
22
|
+
this._tokens = [];
|
|
23
|
+
this._errors = [];
|
|
24
|
+
this._currentTokenStart = 0;
|
|
25
|
+
this._parenDepth = 0; // Track parentheses depth for method arguments
|
|
26
|
+
if (typeof input !== "string") {
|
|
27
|
+
throw new TypeError("Input must be a string");
|
|
28
|
+
}
|
|
29
|
+
this._input = input;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Tokenize the input string
|
|
33
|
+
*/
|
|
34
|
+
tokenize() {
|
|
35
|
+
this._resetState();
|
|
36
|
+
try {
|
|
37
|
+
while (!this._isAtEnd()) {
|
|
38
|
+
this._currentTokenStart = this._position;
|
|
39
|
+
this._scanToken();
|
|
40
|
+
}
|
|
41
|
+
// Add EOF token
|
|
42
|
+
this._addToken(ConditionalTypes.TokenType.EOF, "");
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
this._addError(ConditionalTypes.ErrorType.SYNTAX_ERROR, `Unexpected error during tokenization: ${error instanceof Error ? error.message : "Unknown error"}`, "Check the input syntax for correctness");
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
tokens: [...this._tokens],
|
|
49
|
+
errors: [...this._errors],
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Reset lexer state for reuse
|
|
54
|
+
*/
|
|
55
|
+
_resetState() {
|
|
56
|
+
this._position = 0;
|
|
57
|
+
this._line = 1;
|
|
58
|
+
this._column = 1;
|
|
59
|
+
this._currentTokenStart = 0;
|
|
60
|
+
this._tokens.length = 0;
|
|
61
|
+
this._errors.length = 0;
|
|
62
|
+
this._parenDepth = 0;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Scan next token with improved error recovery
|
|
66
|
+
*/
|
|
67
|
+
_scanToken() {
|
|
68
|
+
const char = this._advance();
|
|
69
|
+
// Skip whitespace efficiently
|
|
70
|
+
if (this._isWhitespace(char)) {
|
|
71
|
+
this._skipWhitespace();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// Handle constant values (=value) ONLY in type definition contexts
|
|
75
|
+
// This should only trigger after *? operator, not in comparison contexts like role=admin
|
|
76
|
+
if (char === "=" &&
|
|
77
|
+
this._peek() !== "=" &&
|
|
78
|
+
this._peek() !== "!" &&
|
|
79
|
+
this._isConstantContext()) {
|
|
80
|
+
this._scanConstant();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// Handle unquoted literals in method arguments BEFORE operators
|
|
84
|
+
if (this._parenDepth > 0 && this._isLiteralStartChar(char)) {
|
|
85
|
+
this._scanUnquotedLiteral();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
// Handle operators (multi-character first)
|
|
89
|
+
if (this._tryOperator()) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// Handle strings
|
|
93
|
+
if (ConditionalLexer._STRING_QUOTES.has(char)) {
|
|
94
|
+
this._scanString(char);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// Handle numbers (including negative numbers)
|
|
98
|
+
if (this._isDigit(char)) {
|
|
99
|
+
this._scanNumber();
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
// Handle negative numbers (- followed by digit)
|
|
103
|
+
if (char === "-" && this._isDigit(this._peek())) {
|
|
104
|
+
this._scanNumber();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
// Handle identifiers and keywords
|
|
108
|
+
if (this._isAlpha(char)) {
|
|
109
|
+
this._scanIdentifier();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
// Handle method names that start with ! (like !exists, !empty) when after a dot
|
|
113
|
+
if (char === "!" && this._isAfterDotToken()) {
|
|
114
|
+
this._scanMethodName();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
// Handle special characters that are part of type syntax
|
|
118
|
+
const typeToken = ConditionalLexer._TYPE_SYNTAX_CHARS.get(char);
|
|
119
|
+
if (typeToken) {
|
|
120
|
+
// Track parentheses depth for method argument parsing
|
|
121
|
+
if (char === "(") {
|
|
122
|
+
this._parenDepth++;
|
|
123
|
+
}
|
|
124
|
+
else if (char === ")") {
|
|
125
|
+
this._parenDepth--;
|
|
126
|
+
}
|
|
127
|
+
this._addToken(typeToken, char);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
// Handle forward slash patterns (like /secure/, /admin/)
|
|
131
|
+
if (char === "/" && this._isRegexSlashContext()) {
|
|
132
|
+
this._scanSlashPattern();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
// Handle regex patterns after ~ operator
|
|
136
|
+
if (this._isRegexContext()) {
|
|
137
|
+
this._scanRegexPattern();
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
// Allow special regex characters in certain contexts
|
|
141
|
+
if (ConditionalLexer._REGEX_SPECIAL_CHARS.has(char)) {
|
|
142
|
+
this._addToken(this._getRegexCharToken(char), char);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// Unknown character - add error but continue parsing
|
|
146
|
+
this._addError(ConditionalTypes.ErrorType.SYNTAX_ERROR, `Unexpected character: '${char}'`, `Remove or escape the character '${char}'`);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Try to match multi-character operators with improved efficiency
|
|
150
|
+
*/
|
|
151
|
+
_tryOperator() {
|
|
152
|
+
// Get remaining input from current position - 1 (since we already advanced)
|
|
153
|
+
const remaining = this._input.substring(this._position - 1);
|
|
154
|
+
if (remaining.length === 0)
|
|
155
|
+
return false;
|
|
156
|
+
// Check if we're after a dot - if so, don't treat !exists/!empty as operators
|
|
157
|
+
const isAfterDot = this._isAfterDotToken();
|
|
158
|
+
for (const [op, tokenType] of ConditionalLexer._OPERATORS) {
|
|
159
|
+
if (remaining.startsWith(op)) {
|
|
160
|
+
// Skip !exists and !empty when after a dot (they should be method names)
|
|
161
|
+
if (isAfterDot &&
|
|
162
|
+
(op === "!exists" ||
|
|
163
|
+
op === "!empty" ||
|
|
164
|
+
op === "!null" ||
|
|
165
|
+
op === "!in" ||
|
|
166
|
+
op === "!contains")) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
// Advance position for multi-character operators
|
|
170
|
+
for (let i = 1; i < op.length; i++) {
|
|
171
|
+
this._advance();
|
|
172
|
+
}
|
|
173
|
+
this._addToken(tokenType, op);
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Check if the last token is a DOT token
|
|
181
|
+
*/
|
|
182
|
+
_isAfterDotToken() {
|
|
183
|
+
return (this._tokens.length > 0 &&
|
|
184
|
+
this._tokens[this._tokens.length - 1].type === ConditionalTypes.TokenType.DOT);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Check if we're in a constant context (after *? operator in type definitions)
|
|
188
|
+
* This prevents treating comparison operators like role=admin as constants
|
|
189
|
+
*/
|
|
190
|
+
_isConstantContext() {
|
|
191
|
+
if (this._tokens.length === 0)
|
|
192
|
+
return false;
|
|
193
|
+
// Look for the *? (CONDITIONAL_THEN) token in recent tokens
|
|
194
|
+
// Constants should only appear after *? in patterns like "when condition *? =value : type"
|
|
195
|
+
for (let i = this._tokens.length - 1; i >= Math.max(0, this._tokens.length - 5); i--) {
|
|
196
|
+
const token = this._tokens[i];
|
|
197
|
+
// If we find *? operator, we're in a type definition context
|
|
198
|
+
if (token.type === ConditionalTypes.TokenType.CONDITIONAL_THEN) {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
// If we find : (colon), we're past the constant context
|
|
202
|
+
if (token.type === ConditionalTypes.TokenType.COLON) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
// If we find logical operators, we're in a condition context, not type context
|
|
206
|
+
if (token.type === ConditionalTypes.TokenType.AND || token.type === ConditionalTypes.TokenType.OR) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Check if character is an operator character that should stop identifier scanning
|
|
214
|
+
*/
|
|
215
|
+
_isOperatorChar(char) {
|
|
216
|
+
// Check if the character starts any operator
|
|
217
|
+
for (const [op] of ConditionalLexer._OPERATORS) {
|
|
218
|
+
if (op.startsWith(char)) {
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Scan string literal with improved escape handling
|
|
226
|
+
*/
|
|
227
|
+
_scanString(quote) {
|
|
228
|
+
let value = "";
|
|
229
|
+
const startLine = this._line;
|
|
230
|
+
const startColumn = this._column - 1;
|
|
231
|
+
while (!this._isAtEnd() && this._peek() !== quote) {
|
|
232
|
+
if (this._peek() === "\n") {
|
|
233
|
+
this._line++;
|
|
234
|
+
this._column = 1;
|
|
235
|
+
}
|
|
236
|
+
// Handle escape sequences
|
|
237
|
+
if (this._peek() === "\\") {
|
|
238
|
+
this._advance(); // Skip backslash
|
|
239
|
+
if (this._isAtEnd()) {
|
|
240
|
+
this._addError(ConditionalTypes.ErrorType.SYNTAX_ERROR, "Unterminated escape sequence in string", `Add a character after \\ or close the string with ${quote}`);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const escaped = this._advance();
|
|
244
|
+
const escapedValue = ConditionalLexer._ESCAPE_SEQUENCES.get(escaped);
|
|
245
|
+
if (escapedValue !== undefined) {
|
|
246
|
+
value += escapedValue;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
// Unknown escape sequence - keep the character
|
|
250
|
+
value += escaped;
|
|
251
|
+
this._addError(ConditionalTypes.ErrorType.SYNTAX_ERROR, `Unknown escape sequence: \\${escaped}`, `Use a valid escape sequence or remove the backslash`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
value += this._advance();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (this._isAtEnd()) {
|
|
259
|
+
this._addError(ConditionalTypes.ErrorType.SYNTAX_ERROR, `Unterminated string starting at line ${startLine}, column ${startColumn}`, `Add closing ${quote} to complete the string`);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
// Consume closing quote
|
|
263
|
+
this._advance();
|
|
264
|
+
this._addToken(ConditionalTypes.TokenType.STRING, value);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Scan numeric literal with improved validation
|
|
268
|
+
*/
|
|
269
|
+
_scanNumber() {
|
|
270
|
+
let value = this._input[this._position - 1];
|
|
271
|
+
// Scan integer part
|
|
272
|
+
while (this._isDigit(this._peek())) {
|
|
273
|
+
value += this._advance();
|
|
274
|
+
}
|
|
275
|
+
// Handle decimal point
|
|
276
|
+
if (this._peek() === "." && this._isDigit(this._peekNext())) {
|
|
277
|
+
value += this._advance(); // Consume '.'
|
|
278
|
+
while (this._isDigit(this._peek())) {
|
|
279
|
+
value += this._advance();
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
// Validate number format
|
|
283
|
+
if (value === "." || value.endsWith(".") || value === "-") {
|
|
284
|
+
this._addError(ConditionalTypes.ErrorType.SYNTAX_ERROR, "Invalid number format", "Ensure the number has digits before and after the decimal point");
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
this._addToken(ConditionalTypes.TokenType.NUMBER, value);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Scan identifier, keyword, or method with improved logic
|
|
291
|
+
*/
|
|
292
|
+
_scanIdentifier() {
|
|
293
|
+
let value = this._input[this._position - 1];
|
|
294
|
+
// Handle multi-byte Unicode characters (like emojis)
|
|
295
|
+
// FIXED: Stop at operator characters to prevent consuming "role=admin" as single token
|
|
296
|
+
while ((this._isAlphaNumeric(this._peek()) || this._isEmojiContinuation()) &&
|
|
297
|
+
!this._isOperatorChar(this._peek())) {
|
|
298
|
+
value += this._advance();
|
|
299
|
+
}
|
|
300
|
+
// Check if it's a keyword (case-insensitive)
|
|
301
|
+
const keywordType = ConditionalLexer._KEYWORDS.get(value.toLowerCase());
|
|
302
|
+
if (keywordType) {
|
|
303
|
+
this._addToken(keywordType, value);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
// Check if it's followed by a method call
|
|
307
|
+
if (this._peek() === ".") {
|
|
308
|
+
const methodName = this._peekMethodName();
|
|
309
|
+
if (methodName && ConditionalLexer._METHODS.has(methodName)) {
|
|
310
|
+
// This is a field access followed by a method
|
|
311
|
+
this._addToken(ConditionalTypes.TokenType.IDENTIFIER, value);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
this._addToken(ConditionalTypes.TokenType.IDENTIFIER, value);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Check if the current character is part of an emoji continuation
|
|
319
|
+
*/
|
|
320
|
+
_isEmojiContinuation() {
|
|
321
|
+
const char = this._peek();
|
|
322
|
+
const code = char.charCodeAt(0);
|
|
323
|
+
// Low surrogate range (second part of emoji)
|
|
324
|
+
return code >= 0xdc00 && code <= 0xdfff;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Peek ahead to get the method name after a dot
|
|
328
|
+
*/
|
|
329
|
+
_peekMethodName() {
|
|
330
|
+
const nextPos = this._position + 1;
|
|
331
|
+
if (nextPos >= this._input.length)
|
|
332
|
+
return null;
|
|
333
|
+
let methodName = "";
|
|
334
|
+
let pos = nextPos;
|
|
335
|
+
// Handle methods that start with ! (like !exists, !empty)
|
|
336
|
+
if (pos < this._input.length && this._input[pos] === "!") {
|
|
337
|
+
methodName += this._input[pos];
|
|
338
|
+
pos++;
|
|
339
|
+
}
|
|
340
|
+
// Scan the rest of the method name
|
|
341
|
+
while (pos < this._input.length && this._isAlphaNumeric(this._input[pos])) {
|
|
342
|
+
methodName += this._input[pos];
|
|
343
|
+
pos++;
|
|
344
|
+
}
|
|
345
|
+
return methodName || null;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Scan method name that starts with ! (like !exists, !empty)
|
|
349
|
+
*/
|
|
350
|
+
_scanMethodName() {
|
|
351
|
+
let value = this._input[this._position - 1]; // Start with the '!' character
|
|
352
|
+
// Scan the rest of the method name
|
|
353
|
+
while (this._isAlphaNumeric(this._peek())) {
|
|
354
|
+
value += this._advance();
|
|
355
|
+
}
|
|
356
|
+
// Check if it's a valid method name
|
|
357
|
+
const methodType = ConditionalLexer._METHODS.get(value);
|
|
358
|
+
if (methodType) {
|
|
359
|
+
this._addToken(ConditionalTypes.TokenType.IDENTIFIER, value);
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
this._addError(ConditionalTypes.ErrorType.SYNTAX_ERROR, `Unknown method: ${value}`, `Check if the method name is correct. Valid methods include: ${Array.from(ConditionalLexer._METHODS.keys()).join(", ")}`);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Scan constant value (=value syntax) with improved validation
|
|
367
|
+
*/
|
|
368
|
+
_scanConstant() {
|
|
369
|
+
let value = "";
|
|
370
|
+
// Skip the '=' character (already consumed)
|
|
371
|
+
// Handle negative numbers by allowing minus sign at the start
|
|
372
|
+
if (this._peek() === "-") {
|
|
373
|
+
// Check if it's a negative number (- followed by digit or .)
|
|
374
|
+
const nextChar = this._peekNext();
|
|
375
|
+
if (this._isDigit(nextChar) || nextChar === ".") {
|
|
376
|
+
value += this._advance(); // consume '-'
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
// Check if this is an array or object literal
|
|
380
|
+
const isArrayLiteral = this._peek() === "[";
|
|
381
|
+
const isObjectLiteral = this._peek() === "{";
|
|
382
|
+
if (isArrayLiteral || isObjectLiteral) {
|
|
383
|
+
// Handle complex literals with bracket/brace matching
|
|
384
|
+
value += this._scanComplexLiteral();
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
// Handle simple constants (strings, numbers, booleans)
|
|
388
|
+
while (!this._isAtEnd() &&
|
|
389
|
+
!this._isWhitespace(this._peek()) &&
|
|
390
|
+
this._peek() !== ":" &&
|
|
391
|
+
this._peek() !== ")" &&
|
|
392
|
+
this._peek() !== "]" &&
|
|
393
|
+
this._peek() !== ",") {
|
|
394
|
+
value += this._advance();
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
if (value.length === 0) {
|
|
398
|
+
this._addError(ConditionalTypes.ErrorType.SYNTAX_ERROR, "Empty constant value after =", "Provide a value after = (e.g., =admin, =true, =42, =-1, =[1,2,3])");
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
this._addToken(ConditionalTypes.TokenType.CONSTANT, value);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Scan complex literal (array or object) with proper bracket/brace matching
|
|
405
|
+
*/
|
|
406
|
+
_scanComplexLiteral() {
|
|
407
|
+
let value = "";
|
|
408
|
+
let depth = 0;
|
|
409
|
+
const startChar = this._peek();
|
|
410
|
+
const endChar = startChar === "[" ? "]" : "}";
|
|
411
|
+
// Consume the opening bracket/brace
|
|
412
|
+
value += this._advance();
|
|
413
|
+
depth++;
|
|
414
|
+
while (!this._isAtEnd() && depth > 0) {
|
|
415
|
+
const char = this._peek();
|
|
416
|
+
if (char === startChar) {
|
|
417
|
+
depth++;
|
|
418
|
+
}
|
|
419
|
+
else if (char === endChar) {
|
|
420
|
+
depth--;
|
|
421
|
+
}
|
|
422
|
+
value += this._advance();
|
|
423
|
+
// Stop at whitespace or conditional operators only if we're at depth 0
|
|
424
|
+
if (depth === 0 &&
|
|
425
|
+
(this._isWhitespace(char) || char === ":" || char === "*")) {
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return value;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Skip whitespace characters efficiently
|
|
433
|
+
*/
|
|
434
|
+
_skipWhitespace() {
|
|
435
|
+
while (!this._isAtEnd() && this._isWhitespace(this._peek())) {
|
|
436
|
+
if (this._advance() === "\n") {
|
|
437
|
+
this._line++;
|
|
438
|
+
this._column = 1;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Check if we're in a regex context (after ~ or !~ operator)
|
|
444
|
+
*/
|
|
445
|
+
_isRegexContext() {
|
|
446
|
+
if (this._tokens.length === 0)
|
|
447
|
+
return false;
|
|
448
|
+
const lastToken = this._tokens[this._tokens.length - 1];
|
|
449
|
+
return (lastToken.type === ConditionalTypes.TokenType.MATCHES ||
|
|
450
|
+
lastToken.type === ConditionalTypes.TokenType.NOT_MATCHES);
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Check if we're in a context where forward slashes should be treated as regex delimiters
|
|
454
|
+
*/
|
|
455
|
+
_isRegexSlashContext() {
|
|
456
|
+
if (this._tokens.length < 2)
|
|
457
|
+
return false;
|
|
458
|
+
const lastToken = this._tokens[this._tokens.length - 1];
|
|
459
|
+
const secondLastToken = this._tokens[this._tokens.length - 2];
|
|
460
|
+
// Check if we're inside method arguments like .contains(/pattern/)
|
|
461
|
+
const regexMethodTypes = new Set([
|
|
462
|
+
ConditionalTypes.TokenType.CONTAINS,
|
|
463
|
+
ConditionalTypes.TokenType.NOT_CONTAINS,
|
|
464
|
+
ConditionalTypes.TokenType.STARTS_WITH,
|
|
465
|
+
ConditionalTypes.TokenType.ENDS_WITH,
|
|
466
|
+
]);
|
|
467
|
+
return (lastToken.type === ConditionalTypes.TokenType.LPAREN &&
|
|
468
|
+
regexMethodTypes.has(secondLastToken.type));
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Scan slash-delimited pattern (like /secure/, /admin/) with improved error handling
|
|
472
|
+
*/
|
|
473
|
+
_scanSlashPattern() {
|
|
474
|
+
let pattern = "";
|
|
475
|
+
const startLine = this._line;
|
|
476
|
+
const startColumn = this._column - 1;
|
|
477
|
+
// Skip the opening slash (already consumed)
|
|
478
|
+
while (!this._isAtEnd() && this._peek() !== "/") {
|
|
479
|
+
if (this._peek() === "\n") {
|
|
480
|
+
this._line++;
|
|
481
|
+
this._column = 1;
|
|
482
|
+
}
|
|
483
|
+
pattern += this._advance();
|
|
484
|
+
}
|
|
485
|
+
if (this._peek() === "/") {
|
|
486
|
+
this._advance(); // Consume closing slash
|
|
487
|
+
this._addToken(ConditionalTypes.TokenType.STRING, pattern);
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
this._addError(ConditionalTypes.ErrorType.SYNTAX_ERROR, `Unterminated regex pattern starting at line ${startLine}, column ${startColumn}`, "Add closing / to complete the pattern");
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Scan regex pattern (handles complex patterns with special characters)
|
|
495
|
+
*/
|
|
496
|
+
_scanRegexPattern() {
|
|
497
|
+
let pattern = "";
|
|
498
|
+
let depth = 0;
|
|
499
|
+
while (!this._isAtEnd()) {
|
|
500
|
+
const char = this._peek();
|
|
501
|
+
// Stop at whitespace or conditional operators
|
|
502
|
+
if (this._isWhitespace(char) || char === "*" || char === ":") {
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
// Handle parentheses depth
|
|
506
|
+
if (char === "(") {
|
|
507
|
+
depth++;
|
|
508
|
+
}
|
|
509
|
+
else if (char === ")") {
|
|
510
|
+
depth--;
|
|
511
|
+
if (depth < 0)
|
|
512
|
+
break; // Unmatched closing paren
|
|
513
|
+
}
|
|
514
|
+
pattern += this._advance();
|
|
515
|
+
}
|
|
516
|
+
if (pattern.length > 0) {
|
|
517
|
+
this._addToken(ConditionalTypes.TokenType.REGEX_PATTERN, pattern);
|
|
518
|
+
}
|
|
519
|
+
else {
|
|
520
|
+
this._addError(ConditionalTypes.ErrorType.SYNTAX_ERROR, "Empty regex pattern", "Provide a valid regex pattern after the ~ operator");
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Get token type for regex special characters
|
|
525
|
+
*/
|
|
526
|
+
_getRegexCharToken(char) {
|
|
527
|
+
switch (char) {
|
|
528
|
+
case "|":
|
|
529
|
+
return ConditionalTypes.TokenType.PIPE;
|
|
530
|
+
case "^":
|
|
531
|
+
return ConditionalTypes.TokenType.CARET;
|
|
532
|
+
case "$":
|
|
533
|
+
return ConditionalTypes.TokenType.DOLLAR;
|
|
534
|
+
case "@":
|
|
535
|
+
return ConditionalTypes.TokenType.AT;
|
|
536
|
+
default:
|
|
537
|
+
return ConditionalTypes.TokenType.UNKNOWN;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Utility methods with improved type safety
|
|
542
|
+
*/
|
|
543
|
+
_advance() {
|
|
544
|
+
if (this._isAtEnd())
|
|
545
|
+
return "\0";
|
|
546
|
+
this._column++;
|
|
547
|
+
return this._input[this._position++];
|
|
548
|
+
}
|
|
549
|
+
_peek() {
|
|
550
|
+
if (this._isAtEnd())
|
|
551
|
+
return "\0";
|
|
552
|
+
return this._input[this._position];
|
|
553
|
+
}
|
|
554
|
+
_peekNext() {
|
|
555
|
+
if (this._position + 1 >= this._input.length)
|
|
556
|
+
return "\0";
|
|
557
|
+
return this._input[this._position + 1];
|
|
558
|
+
}
|
|
559
|
+
_isAtEnd() {
|
|
560
|
+
return this._position >= this._input.length;
|
|
561
|
+
}
|
|
562
|
+
_isWhitespace(char) {
|
|
563
|
+
return ConditionalLexer._WHITESPACE_CHARS.has(char);
|
|
564
|
+
}
|
|
565
|
+
_isDigit(char) {
|
|
566
|
+
return char >= "0" && char <= "9";
|
|
567
|
+
}
|
|
568
|
+
_isAlpha(char) {
|
|
569
|
+
return ((char >= "a" && char <= "z") ||
|
|
570
|
+
(char >= "A" && char <= "Z") ||
|
|
571
|
+
char === "_" ||
|
|
572
|
+
this._isUnicodeAlpha(char));
|
|
573
|
+
}
|
|
574
|
+
_isAlphaNumeric(char) {
|
|
575
|
+
return this._isAlpha(char) || this._isDigit(char);
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Check if character is Unicode alphabetic (for international identifiers)
|
|
579
|
+
*/
|
|
580
|
+
_isUnicodeAlpha(char) {
|
|
581
|
+
try {
|
|
582
|
+
// Enhanced Unicode support including emojis and symbols
|
|
583
|
+
return (/\p{L}/u.test(char) || // Letters
|
|
584
|
+
/\p{Emoji}/u.test(char) || // Emojis
|
|
585
|
+
/\p{Symbol}/u.test(char) || // Symbols
|
|
586
|
+
/\p{Mark}/u.test(char) || // Combining marks
|
|
587
|
+
this._isEmojiCharacter(char) // Additional emoji detection
|
|
588
|
+
);
|
|
589
|
+
}
|
|
590
|
+
catch (error) {
|
|
591
|
+
// Fallback for older environments
|
|
592
|
+
return this._isUnicodeAlphaFallback(char);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Enhanced emoji character detection
|
|
597
|
+
*/
|
|
598
|
+
_isEmojiCharacter(char) {
|
|
599
|
+
const code = char.charCodeAt(0);
|
|
600
|
+
// Common emoji ranges
|
|
601
|
+
return (
|
|
602
|
+
// Emoticons
|
|
603
|
+
(code >= 0x1f600 && code <= 0x1f64f) ||
|
|
604
|
+
// Miscellaneous Symbols and Pictographs
|
|
605
|
+
(code >= 0x1f300 && code <= 0x1f5ff) ||
|
|
606
|
+
// Transport and Map Symbols
|
|
607
|
+
(code >= 0x1f680 && code <= 0x1f6ff) ||
|
|
608
|
+
// Additional Symbols
|
|
609
|
+
(code >= 0x1f700 && code <= 0x1f77f) ||
|
|
610
|
+
// Geometric Shapes Extended
|
|
611
|
+
(code >= 0x1f780 && code <= 0x1f7ff) ||
|
|
612
|
+
// Supplemental Arrows-C
|
|
613
|
+
(code >= 0x1f800 && code <= 0x1f8ff) ||
|
|
614
|
+
// Supplemental Symbols and Pictographs
|
|
615
|
+
(code >= 0x1f900 && code <= 0x1f9ff) ||
|
|
616
|
+
// Chess Symbols
|
|
617
|
+
(code >= 0x1fa00 && code <= 0x1fa6f) ||
|
|
618
|
+
// Symbols and Pictographs Extended-A
|
|
619
|
+
(code >= 0x1fa70 && code <= 0x1faff) ||
|
|
620
|
+
// High surrogate range (for multi-byte emojis)
|
|
621
|
+
(code >= 0xd800 && code <= 0xdbff));
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Fallback Unicode detection for older environments
|
|
625
|
+
*/
|
|
626
|
+
_isUnicodeAlphaFallback(char) {
|
|
627
|
+
const code = char.charCodeAt(0);
|
|
628
|
+
return (
|
|
629
|
+
// Latin Extended
|
|
630
|
+
(code >= 0x00c0 && code <= 0x024f) ||
|
|
631
|
+
// Greek and Coptic
|
|
632
|
+
(code >= 0x0370 && code <= 0x03ff) ||
|
|
633
|
+
// Cyrillic
|
|
634
|
+
(code >= 0x0400 && code <= 0x04ff) ||
|
|
635
|
+
// CJK (Chinese, Japanese, Korean)
|
|
636
|
+
(code >= 0x4e00 && code <= 0x9fff) ||
|
|
637
|
+
// Arabic
|
|
638
|
+
(code >= 0x0600 && code <= 0x06ff) ||
|
|
639
|
+
// Hebrew
|
|
640
|
+
(code >= 0x0590 && code <= 0x05ff) ||
|
|
641
|
+
// Basic emoji ranges
|
|
642
|
+
(code >= 0x1f300 && code <= 0x1f9ff) ||
|
|
643
|
+
// High surrogate range
|
|
644
|
+
(code >= 0xd800 && code <= 0xdbff));
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Add token to the list with improved position tracking
|
|
648
|
+
*/
|
|
649
|
+
_addToken(type, value) {
|
|
650
|
+
this._tokens.push({
|
|
651
|
+
type,
|
|
652
|
+
value,
|
|
653
|
+
position: this._currentTokenStart,
|
|
654
|
+
line: this._line,
|
|
655
|
+
column: this._column - value.length,
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Add error to the list with improved context
|
|
660
|
+
*/
|
|
661
|
+
_addError(type, message, suggestion) {
|
|
662
|
+
this._errors.push({
|
|
663
|
+
type,
|
|
664
|
+
message,
|
|
665
|
+
position: this._currentTokenStart,
|
|
666
|
+
line: this._line,
|
|
667
|
+
column: this._column - (this._position - this._currentTokenStart),
|
|
668
|
+
suggestion,
|
|
669
|
+
context: {
|
|
670
|
+
nearbyTokens: this._tokens.slice(-3), // Last 3 tokens for context
|
|
671
|
+
expectedTokens: [], // Will be filled by parser
|
|
672
|
+
},
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* Check if character can start an unquoted literal in method arguments
|
|
677
|
+
*/
|
|
678
|
+
_isLiteralStartChar(char) {
|
|
679
|
+
// Allow letters, digits, and common special characters as literal starts
|
|
680
|
+
return (this._isAlphaNumeric(char) ||
|
|
681
|
+
char === "!" ||
|
|
682
|
+
char === "@" ||
|
|
683
|
+
char === "#" ||
|
|
684
|
+
char === "$" ||
|
|
685
|
+
char === "%" ||
|
|
686
|
+
char === "^" ||
|
|
687
|
+
char === "&" ||
|
|
688
|
+
char === "*" ||
|
|
689
|
+
char === "+" ||
|
|
690
|
+
char === "=" ||
|
|
691
|
+
char === "|" ||
|
|
692
|
+
char === "\\" ||
|
|
693
|
+
char === ":" ||
|
|
694
|
+
char === ";" ||
|
|
695
|
+
char === "<" ||
|
|
696
|
+
char === ">" ||
|
|
697
|
+
char === "?" ||
|
|
698
|
+
char === "/" ||
|
|
699
|
+
char === "~" ||
|
|
700
|
+
char === "`" ||
|
|
701
|
+
char === "[" ||
|
|
702
|
+
char === "]" ||
|
|
703
|
+
char === "{" ||
|
|
704
|
+
char === "}" ||
|
|
705
|
+
char === "_" ||
|
|
706
|
+
char === "-" ||
|
|
707
|
+
char === ".");
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Scan unquoted literal in method arguments
|
|
711
|
+
*/
|
|
712
|
+
_scanUnquotedLiteral() {
|
|
713
|
+
let value = this._input[this._position - 1];
|
|
714
|
+
// Continue scanning until we hit a delimiter
|
|
715
|
+
while (!this._isAtEnd() &&
|
|
716
|
+
!this._isWhitespace(this._peek()) &&
|
|
717
|
+
this._peek() !== "," &&
|
|
718
|
+
this._peek() !== ")" &&
|
|
719
|
+
this._peek() !== "(") {
|
|
720
|
+
value += this._advance();
|
|
721
|
+
}
|
|
722
|
+
if (value.length > 0) {
|
|
723
|
+
this._addToken(ConditionalTypes.TokenType.STRING, value);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
// Operator patterns for efficient matching (order matters - longest first!)
|
|
728
|
+
ConditionalLexer._OPERATORS = new Map([
|
|
729
|
+
// Multi-character operators first
|
|
730
|
+
["!~", ConditionalTypes.TokenType.NOT_MATCHES],
|
|
731
|
+
["!exists", ConditionalTypes.TokenType.NOT_EXISTS],
|
|
732
|
+
["!empty", ConditionalTypes.TokenType.NOT_EMPTY],
|
|
733
|
+
["!null", ConditionalTypes.TokenType.NOT_NULL],
|
|
734
|
+
["!in", ConditionalTypes.TokenType.NOT_IN],
|
|
735
|
+
["!contains", ConditionalTypes.TokenType.NOT_CONTAINS],
|
|
736
|
+
[">=", ConditionalTypes.TokenType.GREATER_EQUAL],
|
|
737
|
+
["<=", ConditionalTypes.TokenType.LESS_EQUAL],
|
|
738
|
+
["!=", ConditionalTypes.TokenType.NOT_EQUALS],
|
|
739
|
+
["==", ConditionalTypes.TokenType.EQUALS],
|
|
740
|
+
["*?", ConditionalTypes.TokenType.CONDITIONAL_THEN],
|
|
741
|
+
["&&", ConditionalTypes.TokenType.AND],
|
|
742
|
+
["||", ConditionalTypes.TokenType.OR],
|
|
743
|
+
// Single character operators
|
|
744
|
+
["=", ConditionalTypes.TokenType.EQUALS],
|
|
745
|
+
[">", ConditionalTypes.TokenType.GREATER_THAN],
|
|
746
|
+
["<", ConditionalTypes.TokenType.LESS_THAN],
|
|
747
|
+
["~", ConditionalTypes.TokenType.MATCHES],
|
|
748
|
+
["!", ConditionalTypes.TokenType.NOT],
|
|
749
|
+
[":", ConditionalTypes.TokenType.COLON],
|
|
750
|
+
["(", ConditionalTypes.TokenType.LPAREN],
|
|
751
|
+
[")", ConditionalTypes.TokenType.RPAREN],
|
|
752
|
+
["[", ConditionalTypes.TokenType.LBRACKET],
|
|
753
|
+
["]", ConditionalTypes.TokenType.RBRACKET],
|
|
754
|
+
[",", ConditionalTypes.TokenType.COMMA],
|
|
755
|
+
[".", ConditionalTypes.TokenType.DOT],
|
|
756
|
+
["|", ConditionalTypes.TokenType.PIPE], // For regex alternation
|
|
757
|
+
["^", ConditionalTypes.TokenType.CARET], // For regex start anchor
|
|
758
|
+
["$", ConditionalTypes.TokenType.DOLLAR], // For regex end anchor
|
|
759
|
+
["@", ConditionalTypes.TokenType.AT], // For email patterns
|
|
760
|
+
]);
|
|
761
|
+
// Method patterns
|
|
762
|
+
ConditionalLexer._METHODS = new Map([
|
|
763
|
+
["in", ConditionalTypes.TokenType.IN],
|
|
764
|
+
["notIn", ConditionalTypes.TokenType.NOT_IN],
|
|
765
|
+
["!in", ConditionalTypes.TokenType.NOT_IN], // Support .!in() syntax
|
|
766
|
+
["exists", ConditionalTypes.TokenType.EXISTS],
|
|
767
|
+
["notExists", ConditionalTypes.TokenType.NOT_EXISTS],
|
|
768
|
+
["!exists", ConditionalTypes.TokenType.NOT_EXISTS], // Support .!exists syntax
|
|
769
|
+
["empty", ConditionalTypes.TokenType.EMPTY],
|
|
770
|
+
["!empty", ConditionalTypes.TokenType.NOT_EMPTY], // Support .!empty syntax
|
|
771
|
+
["null", ConditionalTypes.TokenType.NULL], // Support .null syntax
|
|
772
|
+
["!null", ConditionalTypes.TokenType.NOT_NULL], // Support .!null syntax
|
|
773
|
+
["contains", ConditionalTypes.TokenType.CONTAINS],
|
|
774
|
+
["notContains", ConditionalTypes.TokenType.NOT_CONTAINS],
|
|
775
|
+
["!contains", ConditionalTypes.TokenType.NOT_CONTAINS], // Support .!contains() syntax
|
|
776
|
+
["startsWith", ConditionalTypes.TokenType.STARTS_WITH],
|
|
777
|
+
["endsWith", ConditionalTypes.TokenType.ENDS_WITH],
|
|
778
|
+
["between", ConditionalTypes.TokenType.BETWEEN],
|
|
779
|
+
]);
|
|
780
|
+
// Keywords
|
|
781
|
+
ConditionalLexer._KEYWORDS = new Map([
|
|
782
|
+
["when", ConditionalTypes.TokenType.WHEN],
|
|
783
|
+
["true", ConditionalTypes.TokenType.BOOLEAN],
|
|
784
|
+
["false", ConditionalTypes.TokenType.BOOLEAN],
|
|
785
|
+
]);
|
|
786
|
+
// Special characters that can appear in regex patterns
|
|
787
|
+
ConditionalLexer._REGEX_SPECIAL_CHARS = new Set(["|", "^", "$", "@"]);
|
|
788
|
+
// Characters that should be treated as special in type syntax
|
|
789
|
+
ConditionalLexer._TYPE_SYNTAX_CHARS = new Map([
|
|
790
|
+
["?", ConditionalTypes.TokenType.UNKNOWN], // Will be handled as part of type syntax
|
|
791
|
+
["[", ConditionalTypes.TokenType.LBRACKET],
|
|
792
|
+
["]", ConditionalTypes.TokenType.RBRACKET],
|
|
793
|
+
["{", ConditionalTypes.TokenType.LBRACE],
|
|
794
|
+
["}", ConditionalTypes.TokenType.RBRACE],
|
|
795
|
+
]);
|
|
796
|
+
// Whitespace characters
|
|
797
|
+
ConditionalLexer._WHITESPACE_CHARS = new Set([" ", "\t", "\n", "\r"]);
|
|
798
|
+
// String quote characters
|
|
799
|
+
ConditionalLexer._STRING_QUOTES = new Set(['"', "'"]);
|
|
800
|
+
// Escape sequence mappings
|
|
801
|
+
ConditionalLexer._ESCAPE_SEQUENCES = new Map([
|
|
802
|
+
["n", "\n"],
|
|
803
|
+
["t", "\t"],
|
|
804
|
+
["r", "\r"],
|
|
805
|
+
["\\", "\\"],
|
|
806
|
+
['"', '"'],
|
|
807
|
+
["'", "'"],
|
|
808
|
+
]);
|
|
809
|
+
|
|
810
|
+
exports.ConditionalLexer = ConditionalLexer;
|
|
811
|
+
//# sourceMappingURL=ConditionalLexer.js.map
|