ata-validator 1.30.0 → 1.30.2
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/lib/js-compiler.js +25 -9
- package/lib/version.js +1 -1
- package/package.json +9 -9
package/lib/js-compiler.js
CHANGED
|
@@ -1838,6 +1838,13 @@ function genCode(schema, v, lines, ctx, knownType) {
|
|
|
1838
1838
|
ctx.regExpMap = new Map();
|
|
1839
1839
|
}
|
|
1840
1840
|
|
|
1841
|
+
// Bookkeeping about THIS node, so it stays in this call. On `ctx` it outlived
|
|
1842
|
+
// the node: a sibling that set one made the next node skip a check it owed,
|
|
1843
|
+
// and `propertyNames` then vanished from the emitted program. Same class as
|
|
1844
|
+
// the deferred additionalProperties bug, so same answer, a local.
|
|
1845
|
+
let ppHandledPropertyNames = false
|
|
1846
|
+
let earlyKeyCount = false
|
|
1847
|
+
|
|
1841
1848
|
// $ref — guard against circular references
|
|
1842
1849
|
// In 2020-12 with unevaluated*, $ref can coexist with siblings — don't early return
|
|
1843
1850
|
// Only when THIS schema has unevaluated keywords directly (not via $ref target)
|
|
@@ -1865,7 +1872,15 @@ function genCode(schema, v, lines, ctx, knownType) {
|
|
|
1865
1872
|
fnName = '_def' + ctx.defFns.size + '_' + defName.replace(/[^A-Za-z0-9_]/g, '_')
|
|
1866
1873
|
ctx.defFns.set(defName, fnName)
|
|
1867
1874
|
const bodyLines = []
|
|
1875
|
+
// The def is compiled as its own function over its own `d`, so the
|
|
1876
|
+
// checks _deferOrInline holds back belong at the end of this body.
|
|
1877
|
+
// The list hangs off ctx, so without the swap they are flushed into
|
|
1878
|
+
// whatever function is compiling, carrying this def's key set.
|
|
1879
|
+
const outerDeferred = ctx.deferredChecks
|
|
1880
|
+
ctx.deferredChecks = null
|
|
1868
1881
|
genCode(ctx.rootDefs[defName], 'd', bodyLines, ctx)
|
|
1882
|
+
if (ctx.deferredChecks) for (const dc of ctx.deferredChecks) bodyLines.push(dc)
|
|
1883
|
+
ctx.deferredChecks = outerDeferred
|
|
1869
1884
|
// Entered through the cycle guard: see emitGuardState. In the fast
|
|
1870
1885
|
// pass the wrapper only counts depth; the set is used by the second,
|
|
1871
1886
|
// guarded pass that runs when data turns out to point back at
|
|
@@ -2054,7 +2069,7 @@ function genCode(schema, v, lines, ctx, knownType) {
|
|
|
2054
2069
|
} else {
|
|
2055
2070
|
lines.push(`if(Object.keys(${v}).length!==${propCount})return false`)
|
|
2056
2071
|
}
|
|
2057
|
-
|
|
2072
|
+
earlyKeyCount = true // this node emitted its key count already
|
|
2058
2073
|
}
|
|
2059
2074
|
}
|
|
2060
2075
|
}
|
|
@@ -2270,8 +2285,7 @@ function genCode(schema, v, lines, ctx, knownType) {
|
|
|
2270
2285
|
// A key that is neither declared nor matched by any pattern is
|
|
2271
2286
|
// additional: rejected outright, or run through the additionalProperties
|
|
2272
2287
|
// schema when there is one.
|
|
2273
|
-
|
|
2274
|
-
ctx._ppHandledPropertyNames = !!pn
|
|
2288
|
+
ppHandledPropertyNames = !!pn
|
|
2275
2289
|
const propKeys = Object.keys(schema.properties || {})
|
|
2276
2290
|
let apCheck = null
|
|
2277
2291
|
if (apSchema) {
|
|
@@ -2329,7 +2343,7 @@ function genCode(schema, v, lines, ctx, knownType) {
|
|
|
2329
2343
|
lines.push(`}}`)
|
|
2330
2344
|
} else {
|
|
2331
2345
|
// No additionalProperties: validate matching keys + propertyNames
|
|
2332
|
-
|
|
2346
|
+
ppHandledPropertyNames = !!pn
|
|
2333
2347
|
lines.push(`${guard}{for(const ${kVar} in ${v}){`)
|
|
2334
2348
|
// propertyNames checks (merged)
|
|
2335
2349
|
if (pn) {
|
|
@@ -2381,7 +2395,7 @@ function genCode(schema, v, lines, ctx, knownType) {
|
|
|
2381
2395
|
}
|
|
2382
2396
|
|
|
2383
2397
|
// propertyNames — only emit if not already merged into patternProperties loop
|
|
2384
|
-
if (schema.propertyNames && typeof schema.propertyNames === 'object' && !
|
|
2398
|
+
if (schema.propertyNames && typeof schema.propertyNames === 'object' && !ppHandledPropertyNames) {
|
|
2385
2399
|
const pn = schema.propertyNames
|
|
2386
2400
|
const ki = ctx.varCounter++
|
|
2387
2401
|
const guard = isObj ? '' : `if(typeof ${v}==='object'&&${v}!==null&&!Array.isArray(${v}))`
|
|
@@ -2612,7 +2626,7 @@ function genCode(schema, v, lines, ctx, knownType) {
|
|
|
2612
2626
|
let inner
|
|
2613
2627
|
if (allRequired && propCount > 0) {
|
|
2614
2628
|
// TRICK 1: required covers all — key count check only
|
|
2615
|
-
if (!
|
|
2629
|
+
if (!earlyKeyCount) {
|
|
2616
2630
|
// Adaptive: for-in for <=15 keys, Object.keys for >15
|
|
2617
2631
|
inner = propCount <= 15
|
|
2618
2632
|
? `var _n=0;for(var _k in ${v})_n++;if(_n!==${propCount})return false`
|
|
@@ -4283,6 +4297,8 @@ function compileToJSCombined(schema, VALID_RESULT, schemaMap, userFormats) {
|
|
|
4283
4297
|
// If type check fails → push error, skip property checks (they'd crash).
|
|
4284
4298
|
function genCodeC(schema, v, pathExpr, lines, ctx, schemaPrefix) {
|
|
4285
4299
|
if (!schemaPrefix) schemaPrefix = '#'
|
|
4300
|
+
// Per-node, for the reason spelled out in genCode.
|
|
4301
|
+
let ppHandledPropertyNames = false
|
|
4286
4302
|
if (schema === false) {
|
|
4287
4303
|
// Leading semicolon: the previous generated line may end in an
|
|
4288
4304
|
// expression, and a line starting with `(` would be parsed as a call.
|
|
@@ -4684,7 +4700,7 @@ function genCodeC(schema, v, pathExpr, lines, ctx, schemaPrefix) {
|
|
|
4684
4700
|
const kVar = `_k${pi}`
|
|
4685
4701
|
|
|
4686
4702
|
if (schema.additionalProperties === false && schema.properties) {
|
|
4687
|
-
|
|
4703
|
+
ppHandledPropertyNames = !!pn
|
|
4688
4704
|
const propKeys = Object.keys(schema.properties)
|
|
4689
4705
|
// Inline key comparison for small property sets
|
|
4690
4706
|
const keyCheck = propKeys.length <= 8
|
|
@@ -4732,7 +4748,7 @@ function genCodeC(schema, v, pathExpr, lines, ctx, schemaPrefix) {
|
|
|
4732
4748
|
lines.push(`if(!_m${pi}){${fail('additionalProperties', 'additionalProperties', `{additionalProperty:${kVar}}`, "'must NOT have additional properties'")}}`)
|
|
4733
4749
|
lines.push(`}}`)
|
|
4734
4750
|
} else {
|
|
4735
|
-
|
|
4751
|
+
ppHandledPropertyNames = !!pn
|
|
4736
4752
|
lines.push(`${guard}{for(const ${kVar} in ${v}){`)
|
|
4737
4753
|
if (pn) {
|
|
4738
4754
|
if (pn.minLength !== undefined) lines.push(`if(${kVar}.length<${pn.minLength}){${fail('minLength', 'propertyNames/minLength', `{limit:${pn.minLength}}`, `'must NOT have fewer than ${pn.minLength} characters'`)}}`)
|
|
@@ -4781,7 +4797,7 @@ function genCodeC(schema, v, pathExpr, lines, ctx, schemaPrefix) {
|
|
|
4781
4797
|
}
|
|
4782
4798
|
|
|
4783
4799
|
// propertyNames — skip if already merged into patternProperties loop
|
|
4784
|
-
if (schema.propertyNames && typeof schema.propertyNames === 'object' && !
|
|
4800
|
+
if (schema.propertyNames && typeof schema.propertyNames === 'object' && !ppHandledPropertyNames) {
|
|
4785
4801
|
const pn = schema.propertyNames
|
|
4786
4802
|
const ki = ctx.varCounter++
|
|
4787
4803
|
lines.push(`if(typeof ${v}==='object'&&${v}!==null&&!Array.isArray(${v})){for(const _k${ki} in ${v}){`)
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ata-validator",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.2",
|
|
4
4
|
"description": "JSON Schema validation that compiles for speed and still runs where code generation is blocked. Compiled and interpreted engines answer identically at 100% of the official suite. TypeScript inference, Standard Schema V1, and a build step that emits dependency-free modules.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"release:check": "node scripts/regen-safe-regex-source.js && node tests/test_pack_purity.js && node scripts/check-doc-coverage.js && node tests/test_error_codes_lock.js && node tests/test_safe_regex_source_sync.js && node tests/test_version_sync.js",
|
|
52
52
|
"build": "cmake-js build --target ata",
|
|
53
53
|
"rebuild": "cmake-js rebuild --target ata",
|
|
54
|
-
"test": "node test.js && node tests/test_removed_aot_methods.js && node tests/test_no_native.js && node tests/test_no_eval.js && node tests/test_property_dependencies.js && node tests/test_v1_dialect.js && node tests/test_buffer_path_parity.js && node tests/test_buffer_gate.js && node tests/test_scanner_differential.js && node tests/test_validate_json_scanner_cost.js && node tests/test_buffer_reject_cost.js && node tests/test_nan_verdict.js && node tests/test_remove_additional_nested.js && node tests/test_exclusive_bounds.js && node tests/test_engine_differential.js && node tests/test_error_shape_differential.js && node tests/test_output_format.js && node tests/test_retry_message.js && node tests/test_describe_schema.js && node tests/test_aot_parse.js && node tests/test_draft7_semantics.js && node tests/test_metaschema_ref.js && node tests/test_pure_js_unsupported.js && node tests/test_native_load_order.js && node tests/test_pack_purity.js && node tests/test_make_native_package.js && node tests/test_browser_nofs.js && node tests/test_browser_imports_guard.js && node tests/test_version_sync.js && node tests/test_native_loaded.js && node tests/test_safe_regex_source_sync.js && node tests/test_t_builder.js && node tests/test_async_refine.js && node tests/test_safe_regex.js && node tests/test_safe_regex_integration.js && node tests/test_aot_build.js && node tests/test_aot_differential.js && node tests/test_aot_cli_build.js && node tests/test_aot_cli_smoke.js && node tests/test_bundle_standalone.js && node tests/test_standalone_anyof.js && node tests/test_standalone_formats.js && node tests/test_aot_format_mode.js && node tests/test_aot_additional_props_errors.js && node tests/test_id_anchor_refs.js && node tests/test_engine_routing.js && node tests/test_engine_option.js && node tests/test_compile_cache_order.js && node tests/test_engine_diagnostic.js && node tests/test_format_engine_parity.js && node tests/test_error_accumulator_collision.js && node tests/test_uri_helper_parity.js && node tests/test_formats_single_pass.js && node tests/test_email_format_cost.js && node tests/test_format_single_error.js && node tests/test_defs_pointer_alias.js && node tests/test_cross_doc_root_ref.js && node tests/test_codegen_entrypoint_agreement.js && node tests/test_hybrid_agreement.js && node tests/test_codegen_edge_shapes.js && node tests/test_ajv_errors.js && node tests/test_custom_keywords.js && node tests/test_strict_schema.js && node tests/test_aot_external_checks.js && node tests/test_ajv_parity.js && node tests/test_user_format_error_path.js && node tests/test_unevaluated_error_path.js && node tests/test_unevaluated_error_shape.js && node tests/test_pattern_properties_errors.js && node tests/test_additional_properties_scaling.js && node tests/test_additional_props_combined_cost.js && node tests/test_no_input_mutation.js && node tests/test_typed_validator_runner.js && node tests/test_define_schema.js && node tests/test_error_codes_lock.js && node tests/test_error_code_lookup.js && node tests/test_error_order.js && node tests/test_error_order_ordinal.js && node tests/test_rejection_shape.js && node tests/test_lazy_normalization.js && node tests/test_value_equality.js && node tests/test_vocabulary.js && node tests/test_schema_scan.js && node tests/test_lazy_errors.js && node tests/test_single_pass_errors.js && node tests/test_lazy_json_errors.js && node tests/test_lazy_instance.js && node tests/test_cyclic_input.js && node tests/test_native_error_codes.js && node tests/test_verdict_preprocess.js && node tests/test_defaults_own_keys.js && node tests/test_plan_compiler.js && node tests/test_nullable.js && node tests/test_validate_and_parse.js && node tests/test_validate_data.js && node tests/test_enrich_error.js && node tests/test_enrich_received.js && node tests/test_rich_errors_optout.js && node tests/test_error_messages.js && node tests/test_source_positions.js && node tests/fuzz_positions.js && node tests/test_malformed_json_termination.js && node tests/test_data_positions.js && node tests/test_targeted_positions.js && node tests/test_position_map_cost.js && node tests/test_targeted_positions_cost.js && node tests/test_aot_staleness.js && node tests/test_file_positions.js && node tests/test_aot_positions_cost.js && node tests/test_schema_hash.js && node tests/test_render_shared.js && node tests/test_renderers.js && node tests/test_additive_fields.js && node tests/test_diagnostic_source.js && node tests/test_diagnose.js && node tests/test_correlate.js && node tests/test_diagnostics_score.js && node tests/test_runtime_error_dx.js && node tests/test_aot_error_dx.js && node tests/test_abort_early.js && node tests/test_branch_collapse.js && node tests/test_suggestions.js && node tests/test_cli_validate.js && node tests/test_cli_version.js && node benchmark/bench_aot_size.mjs",
|
|
54
|
+
"test": "node test.js && node tests/test_removed_aot_methods.js && node tests/test_no_native.js && node tests/test_no_eval.js && node tests/test_property_dependencies.js && node tests/test_v1_dialect.js && node tests/test_buffer_path_parity.js && node tests/test_buffer_gate.js && node tests/test_scanner_differential.js && node tests/test_validate_json_scanner_cost.js && node tests/test_buffer_reject_cost.js && node tests/test_nan_verdict.js && node tests/test_remove_additional_nested.js && node tests/test_exclusive_bounds.js && node tests/test_engine_differential.js && node tests/test_error_shape_differential.js && node tests/test_output_format.js && node tests/test_retry_message.js && node tests/test_describe_schema.js && node tests/test_aot_parse.js && node tests/test_draft7_semantics.js && node tests/test_metaschema_ref.js && node tests/test_pure_js_unsupported.js && node tests/test_native_load_order.js && node tests/test_pack_purity.js && node tests/test_make_native_package.js && node tests/test_browser_nofs.js && node tests/test_browser_imports_guard.js && node tests/test_version_sync.js && node tests/test_native_loaded.js && node tests/test_safe_regex_source_sync.js && node tests/test_t_builder.js && node tests/test_async_refine.js && node tests/test_safe_regex.js && node tests/test_safe_regex_integration.js && node tests/test_aot_build.js && node tests/test_aot_differential.js && node tests/test_aot_cli_build.js && node tests/test_aot_cli_smoke.js && node tests/test_bundle_standalone.js && node tests/test_standalone_anyof.js && node tests/test_standalone_formats.js && node tests/test_aot_format_mode.js && node tests/test_aot_additional_props_errors.js && node tests/test_id_anchor_refs.js && node tests/test_engine_routing.js && node tests/test_engine_option.js && node tests/test_compile_cache_order.js && node tests/test_engine_diagnostic.js && node tests/test_format_engine_parity.js && node tests/test_error_accumulator_collision.js && node tests/test_uri_helper_parity.js && node tests/test_formats_single_pass.js && node tests/test_email_format_cost.js && node tests/test_format_single_error.js && node tests/test_defs_pointer_alias.js && node tests/test_cross_doc_root_ref.js && node tests/test_codegen_entrypoint_agreement.js && node tests/test_hybrid_agreement.js && node tests/test_codegen_edge_shapes.js && node tests/test_deferred_def_scope.js && node tests/test_node_scoped_ctx_flags.js && node tests/test_ajv_errors.js && node tests/test_custom_keywords.js && node tests/test_strict_schema.js && node tests/test_aot_external_checks.js && node tests/test_ajv_parity.js && node tests/test_user_format_error_path.js && node tests/test_unevaluated_error_path.js && node tests/test_unevaluated_error_shape.js && node tests/test_pattern_properties_errors.js && node tests/test_additional_properties_scaling.js && node tests/test_additional_props_combined_cost.js && node tests/test_no_input_mutation.js && node tests/test_typed_validator_runner.js && node tests/test_define_schema.js && node tests/test_error_codes_lock.js && node tests/test_error_code_lookup.js && node tests/test_error_order.js && node tests/test_error_order_ordinal.js && node tests/test_rejection_shape.js && node tests/test_lazy_normalization.js && node tests/test_value_equality.js && node tests/test_vocabulary.js && node tests/test_schema_scan.js && node tests/test_lazy_errors.js && node tests/test_single_pass_errors.js && node tests/test_lazy_json_errors.js && node tests/test_lazy_instance.js && node tests/test_cyclic_input.js && node tests/test_native_error_codes.js && node tests/test_verdict_preprocess.js && node tests/test_defaults_own_keys.js && node tests/test_plan_compiler.js && node tests/test_nullable.js && node tests/test_validate_and_parse.js && node tests/test_validate_data.js && node tests/test_enrich_error.js && node tests/test_enrich_received.js && node tests/test_rich_errors_optout.js && node tests/test_error_messages.js && node tests/test_source_positions.js && node tests/fuzz_positions.js && node tests/test_malformed_json_termination.js && node tests/test_data_positions.js && node tests/test_targeted_positions.js && node tests/test_position_map_cost.js && node tests/test_targeted_positions_cost.js && node tests/test_aot_staleness.js && node tests/test_file_positions.js && node tests/test_aot_positions_cost.js && node tests/test_schema_hash.js && node tests/test_render_shared.js && node tests/test_renderers.js && node tests/test_additive_fields.js && node tests/test_diagnostic_source.js && node tests/test_diagnose.js && node tests/test_correlate.js && node tests/test_diagnostics_score.js && node tests/test_runtime_error_dx.js && node tests/test_aot_error_dx.js && node tests/test_abort_early.js && node tests/test_branch_collapse.js && node tests/test_suggestions.js && node tests/test_cli_validate.js && node tests/test_cli_version.js && node benchmark/bench_aot_size.mjs",
|
|
55
55
|
"bench:size": "node benchmark/bench_aot_size.mjs",
|
|
56
56
|
"test:suite": "node tests/run_suite.js && node tests/run_suite.js draft7 && node tests/run_suite.js v1",
|
|
57
57
|
"test:compat": "node tests/test_compat.js",
|
|
@@ -121,13 +121,13 @@
|
|
|
121
121
|
"LICENSE"
|
|
122
122
|
],
|
|
123
123
|
"optionalDependencies": {
|
|
124
|
-
"@ata-validator/native-darwin-arm64": "1.30.
|
|
125
|
-
"@ata-validator/native-darwin-x64": "1.30.
|
|
126
|
-
"@ata-validator/native-linux-arm64-gnu": "1.30.
|
|
127
|
-
"@ata-validator/native-linux-arm64-musl": "1.30.
|
|
128
|
-
"@ata-validator/native-linux-x64-gnu": "1.30.
|
|
129
|
-
"@ata-validator/native-linux-x64-musl": "1.30.
|
|
130
|
-
"@ata-validator/native-win32-x64": "1.30.
|
|
124
|
+
"@ata-validator/native-darwin-arm64": "1.30.2",
|
|
125
|
+
"@ata-validator/native-darwin-x64": "1.30.2",
|
|
126
|
+
"@ata-validator/native-linux-arm64-gnu": "1.30.2",
|
|
127
|
+
"@ata-validator/native-linux-arm64-musl": "1.30.2",
|
|
128
|
+
"@ata-validator/native-linux-x64-gnu": "1.30.2",
|
|
129
|
+
"@ata-validator/native-linux-x64-musl": "1.30.2",
|
|
130
|
+
"@ata-validator/native-win32-x64": "1.30.2"
|
|
131
131
|
},
|
|
132
132
|
"peerDependencies": {
|
|
133
133
|
"yaml": "^2.0.0"
|