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