@divmain/jdm-asm 0.2.0 → 0.2.3
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/dist/index.js +2227 -29
- package/dist/index.js.map +1 -1
- package/package.json +8 -2
- package/.github/workflows/ci.yml +0 -53
- package/.oxfmtrc.json +0 -16
- package/.oxlintrc.json +0 -183
- package/AGENTS.md +0 -81
- package/asconfig.json +0 -23
- package/benchmarks/fixtures.ts +0 -111
- package/benchmarks/input-fixtures.ts +0 -80
- package/benchmarks/run.ts +0 -913
- package/benchmarks/worker-pool.ts +0 -223
- package/benchmarks/worker.ts +0 -374
- package/scripts/run-all-tests.ts +0 -220
- package/src/compiler/EXPRESSION_SUBSETS.md +0 -228
- package/src/compiler/asc-compiler.ts +0 -315
- package/src/compiler/ast-types.ts +0 -215
- package/src/compiler/build.ts +0 -56
- package/src/compiler/cache.ts +0 -414
- package/src/compiler/code-generators.ts +0 -211
- package/src/compiler/codegen/index.ts +0 -15
- package/src/compiler/codegen/js-marshal.ts +0 -999
- package/src/compiler/codegen/js-validation.ts +0 -243
- package/src/compiler/codegen.ts +0 -19
- package/src/compiler/compile-time-validation.ts +0 -507
- package/src/compiler/cst-visitor.ts +0 -434
- package/src/compiler/errors.ts +0 -227
- package/src/compiler/expression-parser.ts +0 -536
- package/src/compiler/graph.ts +0 -197
- package/src/compiler/index.ts +0 -199
- package/src/compiler/input-validation.ts +0 -33
- package/src/compiler/marshal-gen.ts +0 -21
- package/src/compiler/nodes/context-resolvers.ts +0 -197
- package/src/compiler/nodes/decision-table.ts +0 -507
- package/src/compiler/nodes/decision.ts +0 -292
- package/src/compiler/nodes/expression-compiler.ts +0 -526
- package/src/compiler/nodes/expression.ts +0 -425
- package/src/compiler/nodes/function.ts +0 -316
- package/src/compiler/nodes/input.ts +0 -60
- package/src/compiler/nodes/switch.ts +0 -547
- package/src/compiler/optimizer.ts +0 -948
- package/src/compiler/orchestrator.ts +0 -352
- package/src/compiler/parser.ts +0 -115
- package/src/compiler/result-selection.ts +0 -161
- package/src/compiler/runtime/index.ts +0 -26
- package/src/compiler/runtime-codegen.ts +0 -211
- package/src/compiler/runtime-validation-codegen.ts +0 -294
- package/src/compiler/runtime.ts +0 -452
- package/src/compiler/schema.ts +0 -245
- package/src/compiler/switch-branch-detection.ts +0 -92
- package/src/compiler/types.ts +0 -136
- package/src/compiler/unary-ast-transforms.ts +0 -148
- package/src/compiler/unary-parser.ts +0 -301
- package/src/compiler/unary-transform.ts +0 -161
- package/src/compiler/utils.ts +0 -27
- package/src/compiler/virtual-fs.ts +0 -90
- package/src/compiler/wasm-instantiate.ts +0 -127
- package/src/index.ts +0 -1
- package/src/runtime/arrays.ts +0 -579
- package/src/runtime/context.ts +0 -189
- package/src/runtime/expressions.ts +0 -1811
- package/src/runtime/index.ts +0 -8
- package/src/runtime/memory.ts +0 -607
- package/src/runtime/strings.ts +0 -260
- package/src/runtime/tables.ts +0 -96
- package/src/runtime/tsconfig.json +0 -4
- package/src/runtime/values.ts +0 -209
- package/test-data/README.md +0 -83
- package/test-data/decision-tables/basic/8k.json +0 -87992
- package/test-data/decision-tables/basic/affiliate-commission-calculator.json +0 -228
- package/test-data/decision-tables/basic/airline-loyalty-points-calculations.json +0 -285
- package/test-data/decision-tables/basic/airline-upgrade-eligibility.json +0 -466
- package/test-data/decision-tables/basic/auto-insurance-premium-calculator.json +0 -412
- package/test-data/decision-tables/basic/booking-personalization-system.json +0 -553
- package/test-data/decision-tables/basic/care-team-assignment-system.json +0 -585
- package/test-data/decision-tables/basic/claim-validation-system.json +0 -307
- package/test-data/decision-tables/basic/clinical-lab-result-interpreter.json +0 -433
- package/test-data/decision-tables/basic/clinical-treatment-protocol.json +0 -474
- package/test-data/decision-tables/basic/credit-limit-adjustment.json +0 -479
- package/test-data/decision-tables/basic/customer-eligibility-engine.json +0 -551
- package/test-data/decision-tables/basic/customer-lifetime-value.json +0 -200
- package/test-data/decision-tables/basic/customer-onboarding-kyc-verification.json +0 -611
- package/test-data/decision-tables/basic/customer-service-escalation.json +0 -191
- package/test-data/decision-tables/basic/decision-table-discounts.json +0 -168
- package/test-data/decision-tables/basic/decision-table-shipping.json +0 -398
- package/test-data/decision-tables/basic/delivery-route-optimizer.json +0 -271
- package/test-data/decision-tables/basic/device-compatibility-checker.json +0 -303
- package/test-data/decision-tables/basic/disaster-relief-fund-allocation.json +0 -296
- package/test-data/decision-tables/basic/dynamic-fx-rate-pricing-system.json +0 -237
- package/test-data/decision-tables/basic/dynamic-marketplace-comission-calculator.json +0 -242
- package/test-data/decision-tables/basic/dynamic-shipping-cost-calculator.json +0 -378
- package/test-data/decision-tables/basic/dynamic-tarrif-engine.json +0 -289
- package/test-data/decision-tables/basic/dynamic-ticket-pricing.json +0 -325
- package/test-data/decision-tables/basic/empty-column-with-space.json +0 -100
- package/test-data/decision-tables/basic/empty-column-without-space.json +0 -100
- package/test-data/decision-tables/basic/environment-compliance-assessment.json +0 -386
- package/test-data/decision-tables/basic/expression-table-map.json +0 -313
- package/test-data/decision-tables/basic/flash-sale-eligibility.json +0 -366
- package/test-data/decision-tables/basic/flight-dispatch-decision-system.json +0 -455
- package/test-data/decision-tables/basic/flight-rebooking-fee-calculator.json +0 -406
- package/test-data/decision-tables/basic/government-assistance.json +0 -299
- package/test-data/decision-tables/basic/grant-funding-distribution.json +0 -307
- package/test-data/decision-tables/basic/hazardous-materials-management-system.json +0 -414
- package/test-data/decision-tables/basic/immigration-eligibility-evaluator.json +0 -765
- package/test-data/decision-tables/basic/import-duties-calculator.json +0 -318
- package/test-data/decision-tables/basic/insurance-agent-commission.json +0 -228
- package/test-data/decision-tables/basic/insurance-coverage-calculator.json +0 -362
- package/test-data/decision-tables/basic/insurance-underwriting-risk.json +0 -321
- package/test-data/decision-tables/basic/international-roaming-policy-manager.json +0 -199
- package/test-data/decision-tables/basic/legacy-plan-management.json +0 -434
- package/test-data/decision-tables/basic/marketplace-listing-verification-system.json +0 -334
- package/test-data/decision-tables/basic/medication-dosage-calculator.json +0 -318
- package/test-data/decision-tables/basic/merch-bags.json +0 -171
- package/test-data/decision-tables/basic/municipal-permit-evaluation-system.json +0 -364
- package/test-data/decision-tables/basic/mvno-partner-enablement.json +0 -313
- package/test-data/decision-tables/basic/partner-revenue-sharing.json +0 -244
- package/test-data/decision-tables/basic/payment-routing-and-fee-calculator.json +0 -475
- package/test-data/decision-tables/basic/policy-discount-calculator.json +0 -307
- package/test-data/decision-tables/basic/policy-eligibility-analyzer.json +0 -299
- package/test-data/decision-tables/basic/product-listing-scoring.json +0 -358
- package/test-data/decision-tables/basic/realtime-fraud-detection.json +0 -235
- package/test-data/decision-tables/basic/regional-compliance-manager.json +0 -278
- package/test-data/decision-tables/basic/returns-and-refund-policy.json +0 -366
- package/test-data/decision-tables/basic/returns-processing-system.json +0 -448
- package/test-data/decision-tables/basic/school-district-resource-allocation.json +0 -282
- package/test-data/decision-tables/basic/seat-map-optimization.json +0 -325
- package/test-data/decision-tables/basic/seller-fee-calculator.json +0 -307
- package/test-data/decision-tables/basic/service-level-agreement-enforcement.json +0 -575
- package/test-data/decision-tables/basic/smart-financial-product-matcher.json +0 -249
- package/test-data/decision-tables/basic/supply-chain-risk.json +0 -316
- package/test-data/decision-tables/basic/table-loop.json +0 -93
- package/test-data/decision-tables/basic/table.json +0 -76
- package/test-data/decision-tables/basic/traffic-violation-penalty-calculator.json +0 -436
- package/test-data/decision-tables/basic/transaction-compliance-classifier.json +0 -525
- package/test-data/decision-tables/basic/vehicle-claims-resolution.json +0 -310
- package/test-data/decision-tables/basic/warehouse-storage-location.json +0 -345
- package/test-data/decision-tables/hit-policy-collect/collect-multiple-matches.json +0 -127
- package/test-data/decision-tables/hit-policy-collect/collect-no-match.json +0 -95
- package/test-data/decision-tables/hit-policy-first/first-match.json +0 -103
- package/test-data/decision-tables/hit-policy-first/no-match.json +0 -95
- package/test-data/decision-tables/hit-policy-output-order/output-order-respected.json +0 -94
- package/test-data/decision-tables/hit-policy-output-order/string-output-order.json +0 -94
- package/test-data/decision-tables/hit-policy-priority/priority-respected.json +0 -86
- package/test-data/decision-tables/hit-policy-rule-order/rule-order-respected.json +0 -94
- package/test-data/decision-tables/hit-policy-unique/all-match-error.json +0 -89
- package/test-data/decision-tables/hit-policy-unique/multiple-match-error.json +0 -89
- package/test-data/decision-tables/hit-policy-unique/no-match.json +0 -88
- package/test-data/decision-tables/hit-policy-unique/unique-match.json +0 -99
- package/test-data/expressions/arithmetic/error-cyclic.json +0 -114
- package/test-data/expressions/arithmetic/error-missing-input.json +0 -54
- package/test-data/expressions/arithmetic/error-missing-output.json +0 -54
- package/test-data/expressions/arithmetic/expression-default.json +0 -93
- package/test-data/expressions/arithmetic/expression-fields.json +0 -94
- package/test-data/expressions/arithmetic/expression-loop.json +0 -94
- package/test-data/expressions/arithmetic/expression-passthrough.json +0 -108
- package/test-data/expressions/arithmetic/expression.json +0 -69
- package/test-data/expressions/arithmetic/nested-request.json +0 -125
- package/test-data/expressions/arithmetic/number-function.json +0 -58
- package/test-data/expressions/arithmetic/test-number-functions.json +0 -68
- package/test-data/expressions/functions/all.json +0 -149
- package/test-data/expressions/functions/avg.json +0 -89
- package/test-data/expressions/functions/filter.json +0 -109
- package/test-data/expressions/functions/flat.json +0 -167
- package/test-data/expressions/functions/map-strings.json +0 -65
- package/test-data/expressions/functions/map.json +0 -73
- package/test-data/expressions/functions/reduce.json +0 -49
- package/test-data/expressions/functions/some.json +0 -175
- package/test-data/expressions/functions/sort-strings.json +0 -97
- package/test-data/expressions/functions/sort.json +0 -97
- package/test-data/expressions/logical/logical-and.json +0 -116
- package/test-data/expressions/logical/logical-complex.json +0 -260
- package/test-data/expressions/logical/logical-not.json +0 -111
- package/test-data/expressions/logical/logical-or.json +0 -123
- package/test-data/expressions/string/string-comparison.json +0 -128
- package/test-data/expressions/string/string-concat.json +0 -106
- package/test-data/expressions/string/string-contains.json +0 -125
- package/test-data/expressions/string/string-endsWith.json +0 -113
- package/test-data/expressions/string/string-indexOf.json +0 -131
- package/test-data/expressions/string/string-join.json +0 -92
- package/test-data/expressions/string/string-lower.json +0 -94
- package/test-data/expressions/string/string-replace.json +0 -130
- package/test-data/expressions/string/string-split.json +0 -101
- package/test-data/expressions/string/string-startsWith.json +0 -113
- package/test-data/expressions/string/string-substring.json +0 -138
- package/test-data/expressions/string/string-trim.json +0 -100
- package/test-data/expressions/string/string-upper.json +0 -94
- package/test-data/other/custom.json +0 -51
- package/test-data/other/customer-input-schema.json +0 -34
- package/test-data/other/customer-output-schema.json +0 -34
- package/test-data/other/passthrough.json +0 -31
- package/test-data/sub-decisions/basic/$nodes-child.json +0 -31
- package/test-data/sub-decisions/basic/$nodes-parent.json +0 -49
- package/test-data/sub-decisions/basic/recursive-table1.json +0 -49
- package/test-data/sub-decisions/basic/recursive-table2.json +0 -49
- package/test-data/sub-decisions/complex-multi/approval-decision.json +0 -31
- package/test-data/sub-decisions/complex-multi/complex-dag.json +0 -175
- package/test-data/sub-decisions/complex-multi/credit-check.json +0 -31
- package/test-data/sub-decisions/complex-multi/customer-segmentation.json +0 -31
- package/test-data/sub-decisions/complex-multi/discount-eligibility.json +0 -31
- package/test-data/sub-decisions/complex-multi/eligibility-check.json +0 -31
- package/test-data/sub-decisions/complex-multi/final-offer.json +0 -31
- package/test-data/sub-decisions/complex-multi/income-verification.json +0 -31
- package/test-data/sub-decisions/complex-multi/linear-chain.json +0 -121
- package/test-data/sub-decisions/complex-multi/pricing-calculation.json +0 -31
- package/test-data/sub-decisions/complex-multi/product-eligibility.json +0 -31
- package/test-data/sub-decisions/complex-multi/risk-assessment.json +0 -31
- package/test-data/sub-decisions/complex-multi/shared-validation.json +0 -31
- package/test-data/sub-decisions/complex-multi/validation.json +0 -31
- package/test-data/sub-decisions/diamond/decision-a.json +0 -31
- package/test-data/sub-decisions/diamond/decision-b.json +0 -31
- package/test-data/sub-decisions/diamond/decision-c.json +0 -31
- package/test-data/sub-decisions/diamond/decision-shared.json +0 -31
- package/test-data/sub-decisions/diamond/diamond-pattern.json +0 -109
- package/test-data/sub-decisions/error-propagation/parent-calls-error.json +0 -44
- package/test-data/sub-decisions/error-propagation/sub-decision-with-error.json +0 -60
- package/test-data/switch-nodes/basic/account-dormancy-management.json +0 -245
- package/test-data/switch-nodes/basic/application-risk-assessment.json +0 -474
- package/test-data/switch-nodes/basic/cellular-data-rollover-system.json +0 -281
- package/test-data/switch-nodes/basic/clinical-pathway-selection.json +0 -454
- package/test-data/switch-nodes/basic/insurance-prior-authorization.json +0 -467
- package/test-data/switch-nodes/basic/last-mile-delivery-assignment.json +0 -373
- package/test-data/switch-nodes/basic/loan-approval.json +0 -469
- package/test-data/switch-nodes/basic/multi-switch.json +0 -498
- package/test-data/switch-nodes/basic/online-checkin-eligibility.json +0 -285
- package/test-data/switch-nodes/basic/order-consolidation-system.json +0 -493
- package/test-data/switch-nodes/basic/seller-approval-workflow.json +0 -383
- package/test-data/switch-nodes/basic/set-fee.json +0 -243
- package/test-data/switch-nodes/basic/shipping-carrier-selector.json +0 -379
- package/test-data/switch-nodes/basic/switch-node.json +0 -167
- package/test-data/switch-nodes/basic/switch-performance-2.json +0 -1307
- package/test-data/switch-nodes/basic/switch-performance.json +0 -691
- package/test-data/switch-nodes/basic/tax-exemption.json +0 -295
- package/test-data/switch-nodes/basic/warehouse-cross-docking.json +0 -313
- package/test-data/switch-nodes/default-cases/switch-with-default.json +0 -134
- package/test-data/zen-reference/$nodes-child.json +0 -69
- package/test-data/zen-reference/$nodes-parent.json +0 -34
- package/test-data/zen-reference/8k.json +0 -87992
- package/test-data/zen-reference/credit-analysis.json +0 -324
- package/test-data/zen-reference/custom.json +0 -51
- package/test-data/zen-reference/customer-input-schema.json +0 -34
- package/test-data/zen-reference/customer-output-schema.json +0 -34
- package/test-data/zen-reference/error-cyclic.json +0 -114
- package/test-data/zen-reference/error-missing-input.json +0 -54
- package/test-data/zen-reference/error-missing-output.json +0 -54
- package/test-data/zen-reference/expression.json +0 -69
- package/test-data/zen-reference/function-v2.json +0 -48
- package/test-data/zen-reference/function.json +0 -46
- package/test-data/zen-reference/graphs/account-dormancy-management.json +0 -245
- package/test-data/zen-reference/graphs/affiliate-commission-calculator.json +0 -228
- package/test-data/zen-reference/graphs/airline-loyalty-points-calculations.json +0 -285
- package/test-data/zen-reference/graphs/airline-upgrade-eligibility.json +0 -466
- package/test-data/zen-reference/graphs/aml.json +0 -537
- package/test-data/zen-reference/graphs/application-risk-assessment.json +0 -474
- package/test-data/zen-reference/graphs/auto-insurance-premium-calculator.json +0 -412
- package/test-data/zen-reference/graphs/booking-personalization-system.json +0 -553
- package/test-data/zen-reference/graphs/care-team-assignment-system.json +0 -585
- package/test-data/zen-reference/graphs/cellular-data-rollover-system.json +0 -281
- package/test-data/zen-reference/graphs/claim-validation-system.json +0 -307
- package/test-data/zen-reference/graphs/clinical-lab-result-interpreter.json +0 -433
- package/test-data/zen-reference/graphs/clinical-pathway-selection.json +0 -454
- package/test-data/zen-reference/graphs/clinical-treatment-protocol.json +0 -474
- package/test-data/zen-reference/graphs/company-analysis.json +0 -390
- package/test-data/zen-reference/graphs/credit-limit-adjustment.json +0 -479
- package/test-data/zen-reference/graphs/customer-eligibility-engine.json +0 -551
- package/test-data/zen-reference/graphs/customer-lifetime-value.json +0 -200
- package/test-data/zen-reference/graphs/customer-onboarding-kyc-verification.json +0 -611
- package/test-data/zen-reference/graphs/customer-service-escalation.json +0 -191
- package/test-data/zen-reference/graphs/decision-table-discounts.json +0 -168
- package/test-data/zen-reference/graphs/decision-table-shipping.json +0 -398
- package/test-data/zen-reference/graphs/delivery-route-optimizer.json +0 -271
- package/test-data/zen-reference/graphs/device-compatibility-checker.json +0 -303
- package/test-data/zen-reference/graphs/disaster-relief-fund-allocation.json +0 -296
- package/test-data/zen-reference/graphs/dynamic-fx-rate-pricing-system.json +0 -237
- package/test-data/zen-reference/graphs/dynamic-marketplace-comission-calculator.json +0 -242
- package/test-data/zen-reference/graphs/dynamic-shipping-cost-calculator.json +0 -378
- package/test-data/zen-reference/graphs/dynamic-tarrif-engine.json +0 -289
- package/test-data/zen-reference/graphs/dynamic-ticket-pricing.json +0 -325
- package/test-data/zen-reference/graphs/empty-column-with-space.json +0 -100
- package/test-data/zen-reference/graphs/empty-column-without-space.json +0 -100
- package/test-data/zen-reference/graphs/environment-compliance-assessment.json +0 -386
- package/test-data/zen-reference/graphs/expression-default.json +0 -93
- package/test-data/zen-reference/graphs/expression-fields.json +0 -94
- package/test-data/zen-reference/graphs/expression-loop.json +0 -94
- package/test-data/zen-reference/graphs/expression-passthrough.json +0 -108
- package/test-data/zen-reference/graphs/expression-table-map.json +0 -313
- package/test-data/zen-reference/graphs/flash-sale-eligibility.json +0 -366
- package/test-data/zen-reference/graphs/flight-dispatch-decision-system.json +0 -455
- package/test-data/zen-reference/graphs/flight-rebooking-fee-calculator.json +0 -406
- package/test-data/zen-reference/graphs/government-assistance.json +0 -299
- package/test-data/zen-reference/graphs/grant-funding-distribution.json +0 -307
- package/test-data/zen-reference/graphs/hazardous-materials-management-system.json +0 -414
- package/test-data/zen-reference/graphs/immigration-eligibility-evaluator.json +0 -765
- package/test-data/zen-reference/graphs/import-duties-calculator.json +0 -318
- package/test-data/zen-reference/graphs/insurance-agent-commission.json +0 -228
- package/test-data/zen-reference/graphs/insurance-breakdown.json +0 -421
- package/test-data/zen-reference/graphs/insurance-coverage-calculator.json +0 -362
- package/test-data/zen-reference/graphs/insurance-prior-authorization.json +0 -467
- package/test-data/zen-reference/graphs/insurance-underwriting-risk.json +0 -321
- package/test-data/zen-reference/graphs/international-roaming-policy-manager.json +0 -199
- package/test-data/zen-reference/graphs/last-mile-delivery-assignment.json +0 -373
- package/test-data/zen-reference/graphs/legacy-plan-management.json +0 -434
- package/test-data/zen-reference/graphs/loan-approval.json +0 -469
- package/test-data/zen-reference/graphs/marketplace-listing-verification-system.json +0 -334
- package/test-data/zen-reference/graphs/medication-dosage-calculator.json +0 -318
- package/test-data/zen-reference/graphs/merch-bags.json +0 -171
- package/test-data/zen-reference/graphs/multi-switch.json +0 -498
- package/test-data/zen-reference/graphs/municipal-permit-evaluation-system.json +0 -364
- package/test-data/zen-reference/graphs/mvno-partner-enablement.json +0 -313
- package/test-data/zen-reference/graphs/nested-request.json +0 -125
- package/test-data/zen-reference/graphs/online-checkin-eligibility.json +0 -285
- package/test-data/zen-reference/graphs/order-consolidation-system.json +0 -493
- package/test-data/zen-reference/graphs/partner-revenue-sharing.json +0 -244
- package/test-data/zen-reference/graphs/payment-routing-and-fee-calculator.json +0 -475
- package/test-data/zen-reference/graphs/policy-discount-calculator.json +0 -307
- package/test-data/zen-reference/graphs/policy-eligibility-analyzer.json +0 -299
- package/test-data/zen-reference/graphs/product-listing-scoring.json +0 -358
- package/test-data/zen-reference/graphs/realtime-fraud-detection.json +0 -235
- package/test-data/zen-reference/graphs/regional-compliance-manager.json +0 -278
- package/test-data/zen-reference/graphs/returns-and-refund-policy.json +0 -366
- package/test-data/zen-reference/graphs/returns-processing-system.json +0 -448
- package/test-data/zen-reference/graphs/school-district-resource-allocation.json +0 -282
- package/test-data/zen-reference/graphs/seat-map-optimization.json +0 -325
- package/test-data/zen-reference/graphs/seller-approval-workflow.json +0 -383
- package/test-data/zen-reference/graphs/seller-fee-calculator.json +0 -307
- package/test-data/zen-reference/graphs/service-level-agreement-enforcement.json +0 -575
- package/test-data/zen-reference/graphs/set-fee.json +0 -243
- package/test-data/zen-reference/graphs/shipping-carrier-selector.json +0 -379
- package/test-data/zen-reference/graphs/smart-financial-product-matcher.json +0 -249
- package/test-data/zen-reference/graphs/supply-chain-risk.json +0 -316
- package/test-data/zen-reference/graphs/table-loop.json +0 -93
- package/test-data/zen-reference/graphs/tax-exemption.json +0 -295
- package/test-data/zen-reference/graphs/traffic-violation-penalty-calculator.json +0 -436
- package/test-data/zen-reference/graphs/transaction-compliance-classifier.json +0 -525
- package/test-data/zen-reference/graphs/vehicle-claims-resolution.json +0 -310
- package/test-data/zen-reference/graphs/warehouse-cross-docking.json +0 -313
- package/test-data/zen-reference/graphs/warehouse-storage-location.json +0 -345
- package/test-data/zen-reference/http-function.json +0 -34
- package/test-data/zen-reference/infinite-function.json +0 -46
- package/test-data/zen-reference/js/imports.js +0 -25
- package/test-data/zen-reference/passthrough.json +0 -31
- package/test-data/zen-reference/recursive-table1.json +0 -49
- package/test-data/zen-reference/recursive-table2.json +0 -49
- package/test-data/zen-reference/sleep-function.json +0 -34
- package/test-data/zen-reference/switch-node.json +0 -167
- package/test-data/zen-reference/switch-performance-2.json +0 -1307
- package/test-data/zen-reference/switch-performance.json +0 -691
- package/test-data/zen-reference/table.json +0 -76
- package/tests/helpers/index.ts +0 -73
- package/tests/helpers/mock-context.ts +0 -231
- package/tests/helpers/round-trip.ts +0 -398
- package/tests/helpers/test-harness-comparison.ts +0 -325
- package/tests/helpers/test-harness-wasm.ts +0 -710
- package/tests/helpers/test-harness.ts +0 -28
- package/tests/helpers/wasm-test.ts +0 -659
- package/tests/integration/compilation-errors.test.ts +0 -864
- package/tests/integration/decision-tables.test.ts +0 -531
- package/tests/integration/edge-cases.test.ts +0 -787
- package/tests/integration/expressions.test.ts +0 -513
- package/tests/integration/function-node-integration.test.ts +0 -182
- package/tests/integration/sub-decisions.test.ts +0 -108
- package/tests/integration/switch-nodes.test.ts +0 -399
- package/tests/integration/unary-or-matching.test.ts +0 -53
- package/tests/integration/wasm-data-types.test.ts +0 -398
- package/tests/integration/wasm-errors.test.ts +0 -199
- package/tests/integration/wasm-execution.test.ts +0 -348
- package/tests/integration/wasm-memory.test.ts +0 -228
- package/tests/scripts/analyze-coverage.ts +0 -166
- package/tests/scripts/categorize-tests.ts +0 -396
- package/tests/scripts/coverage-analysis.ts +0 -836
- package/tests/unit/compiler/cache.test.ts +0 -238
- package/tests/unit/compiler/errors.test.ts +0 -316
- package/tests/unit/compiler/graph-scalability.test.ts +0 -510
- package/tests/unit/compiler/graph.test.ts +0 -878
- package/tests/unit/compiler/input-validation.test.ts +0 -447
- package/tests/unit/compiler/logical-and-parser.test.ts +0 -143
- package/tests/unit/compiler/logical-not-parser.test.ts +0 -107
- package/tests/unit/compiler/logical-or-parser.test.ts +0 -236
- package/tests/unit/compiler/marshal-gen/marshal-gen.test.ts +0 -97
- package/tests/unit/compiler/nodes/decision-table.test.ts +0 -103
- package/tests/unit/compiler/nodes/decision.test.ts +0 -182
- package/tests/unit/compiler/nodes/function-compile.test.ts +0 -204
- package/tests/unit/compiler/nodes/function.test.ts +0 -176
- package/tests/unit/compiler/nodes/input.test.ts +0 -30
- package/tests/unit/compiler/nodes/switch.test.ts +0 -127
- package/tests/unit/compiler/optimizer-cache.test.ts +0 -327
- package/tests/unit/compiler/optimizer-implementation.test.ts +0 -625
- package/tests/unit/compiler/parser.test.ts +0 -508
- package/tests/unit/compiler/runtime-error-cleanup.test.ts +0 -426
- package/tests/unit/compiler/runtime-validation.test.ts +0 -303
- package/tests/unit/compiler/runtime.test.ts +0 -221
- package/tests/unit/compiler/schema/schema.test.ts +0 -248
- package/tests/unit/compiler/unary-ast-transforms.test.ts +0 -245
- package/tsconfig.json +0 -27
- package/tsup.config.ts +0 -11
- package/vitest.config.ts +0 -12
|
@@ -1,864 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compilation Error Tests
|
|
3
|
-
*
|
|
4
|
-
* Tests that the compiler fails appropriately for invalid JDM structures.
|
|
5
|
-
* Verifies error messages, error codes, and source location information.
|
|
6
|
-
*
|
|
7
|
-
* This is Phase 7 of the test improvement plan - negative test cases.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { describe, it, expect } from 'vitest';
|
|
11
|
-
import { Type } from '@sinclair/typebox';
|
|
12
|
-
import { compile, type JDMDecision } from '../../src/compiler';
|
|
13
|
-
import { CompilationError, ErrorCode } from '../../src/compiler/errors';
|
|
14
|
-
import { buildGraph, validateGraph } from '../../src/compiler/graph';
|
|
15
|
-
import { parseJDM, NodeType } from '../../src/compiler/parser';
|
|
16
|
-
import { createExpressionJDM } from '../helpers';
|
|
17
|
-
|
|
18
|
-
const defaultInputSchema = Type.Object({ x: Type.Number() });
|
|
19
|
-
const defaultOutputSchema = Type.Object({ result: Type.Number() });
|
|
20
|
-
|
|
21
|
-
describe('Compilation Error Tests', () => {
|
|
22
|
-
describe('Missing Required Nodes', () => {
|
|
23
|
-
it('should throw error when input node is missing', () => {
|
|
24
|
-
const jdm: JDMDecision = {
|
|
25
|
-
nodes: [
|
|
26
|
-
{
|
|
27
|
-
id: 'output-1',
|
|
28
|
-
type: NodeType.OUTPUT,
|
|
29
|
-
position: { x: 0, y: 0 },
|
|
30
|
-
name: 'Response',
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
edges: [],
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const graph = buildGraph(jdm);
|
|
37
|
-
expect(() => validateGraph(graph)).toThrow(CompilationError);
|
|
38
|
-
expect(() => validateGraph(graph)).toThrow(/input node/i);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('should throw error when output node is missing', () => {
|
|
42
|
-
const jdm: JDMDecision = {
|
|
43
|
-
nodes: [
|
|
44
|
-
{
|
|
45
|
-
id: 'input-1',
|
|
46
|
-
type: NodeType.INPUT,
|
|
47
|
-
position: { x: 0, y: 0 },
|
|
48
|
-
name: 'Request',
|
|
49
|
-
},
|
|
50
|
-
],
|
|
51
|
-
edges: [],
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const graph = buildGraph(jdm);
|
|
55
|
-
expect(() => validateGraph(graph)).toThrow(CompilationError);
|
|
56
|
-
expect(() => validateGraph(graph)).toThrow(/output node/i);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('should throw error when multiple input nodes exist', () => {
|
|
60
|
-
const jdm: JDMDecision = {
|
|
61
|
-
nodes: [
|
|
62
|
-
{
|
|
63
|
-
id: 'input-1',
|
|
64
|
-
type: NodeType.INPUT,
|
|
65
|
-
position: { x: 0, y: 0 },
|
|
66
|
-
name: 'Request1',
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
id: 'input-2',
|
|
70
|
-
type: NodeType.INPUT,
|
|
71
|
-
position: { x: 0, y: 100 },
|
|
72
|
-
name: 'Request2',
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
id: 'output-1',
|
|
76
|
-
type: NodeType.OUTPUT,
|
|
77
|
-
position: { x: 200, y: 0 },
|
|
78
|
-
name: 'Response',
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
edges: [
|
|
82
|
-
{ id: 'e1', sourceId: 'input-1', targetId: 'output-1', type: 'edge' },
|
|
83
|
-
{ id: 'e2', sourceId: 'input-2', targetId: 'output-1', type: 'edge' },
|
|
84
|
-
],
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const graph = buildGraph(jdm);
|
|
88
|
-
expect(() => validateGraph(graph)).toThrow(CompilationError);
|
|
89
|
-
expect(() => validateGraph(graph)).toThrow(/input node.*found 2/i);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe('Circular Dependencies', () => {
|
|
94
|
-
it('should throw error for simple cycle between two nodes', () => {
|
|
95
|
-
const jdm: JDMDecision = {
|
|
96
|
-
nodes: [
|
|
97
|
-
{
|
|
98
|
-
id: 'input-1',
|
|
99
|
-
type: NodeType.INPUT,
|
|
100
|
-
position: { x: 0, y: 0 },
|
|
101
|
-
name: 'Request',
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
id: 'expr-1',
|
|
105
|
-
type: NodeType.EXPRESSION,
|
|
106
|
-
position: { x: 100, y: 0 },
|
|
107
|
-
name: 'ExprA',
|
|
108
|
-
content: { expressions: [] },
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
id: 'expr-2',
|
|
112
|
-
type: NodeType.EXPRESSION,
|
|
113
|
-
position: { x: 200, y: 0 },
|
|
114
|
-
name: 'ExprB',
|
|
115
|
-
content: { expressions: [] },
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
id: 'output-1',
|
|
119
|
-
type: NodeType.OUTPUT,
|
|
120
|
-
position: { x: 300, y: 0 },
|
|
121
|
-
name: 'Response',
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
edges: [
|
|
125
|
-
{ id: 'e1', sourceId: 'input-1', targetId: 'expr-1', type: 'edge' },
|
|
126
|
-
{ id: 'e2', sourceId: 'expr-1', targetId: 'expr-2', type: 'edge' },
|
|
127
|
-
{ id: 'e3', sourceId: 'expr-2', targetId: 'expr-1', type: 'edge' }, // Creates cycle
|
|
128
|
-
],
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const graph = buildGraph(jdm);
|
|
132
|
-
expect(() => validateGraph(graph)).toThrow(CompilationError);
|
|
133
|
-
expect(() => validateGraph(graph)).toThrow(/circular/i);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('should throw error for self-referencing node', () => {
|
|
137
|
-
const jdm: JDMDecision = {
|
|
138
|
-
nodes: [
|
|
139
|
-
{
|
|
140
|
-
id: 'input-1',
|
|
141
|
-
type: NodeType.INPUT,
|
|
142
|
-
position: { x: 0, y: 0 },
|
|
143
|
-
name: 'Request',
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
id: 'expr-1',
|
|
147
|
-
type: NodeType.EXPRESSION,
|
|
148
|
-
position: { x: 100, y: 0 },
|
|
149
|
-
name: 'SelfRef',
|
|
150
|
-
content: { expressions: [] },
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
id: 'output-1',
|
|
154
|
-
type: NodeType.OUTPUT,
|
|
155
|
-
position: { x: 200, y: 0 },
|
|
156
|
-
name: 'Response',
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
edges: [
|
|
160
|
-
{ id: 'e1', sourceId: 'input-1', targetId: 'expr-1', type: 'edge' },
|
|
161
|
-
{ id: 'e2', sourceId: 'expr-1', targetId: 'expr-1', type: 'edge' }, // Self-reference
|
|
162
|
-
{ id: 'e3', sourceId: 'expr-1', targetId: 'output-1', type: 'edge' },
|
|
163
|
-
],
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
expect(() => buildGraph(jdm)).toThrow(CompilationError);
|
|
167
|
-
expect(() => buildGraph(jdm)).toThrow(/self-reference/i);
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it('should throw error for longer cycle (A -> B -> C -> A)', () => {
|
|
171
|
-
const jdm: JDMDecision = {
|
|
172
|
-
nodes: [
|
|
173
|
-
{
|
|
174
|
-
id: 'input-1',
|
|
175
|
-
type: NodeType.INPUT,
|
|
176
|
-
position: { x: 0, y: 0 },
|
|
177
|
-
name: 'Request',
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
id: 'expr-a',
|
|
181
|
-
type: NodeType.EXPRESSION,
|
|
182
|
-
position: { x: 100, y: 0 },
|
|
183
|
-
name: 'NodeA',
|
|
184
|
-
content: { expressions: [] },
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
id: 'expr-b',
|
|
188
|
-
type: NodeType.EXPRESSION,
|
|
189
|
-
position: { x: 200, y: 0 },
|
|
190
|
-
name: 'NodeB',
|
|
191
|
-
content: { expressions: [] },
|
|
192
|
-
},
|
|
193
|
-
{
|
|
194
|
-
id: 'expr-c',
|
|
195
|
-
type: NodeType.EXPRESSION,
|
|
196
|
-
position: { x: 300, y: 0 },
|
|
197
|
-
name: 'NodeC',
|
|
198
|
-
content: { expressions: [] },
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
id: 'output-1',
|
|
202
|
-
type: NodeType.OUTPUT,
|
|
203
|
-
position: { x: 400, y: 0 },
|
|
204
|
-
name: 'Response',
|
|
205
|
-
},
|
|
206
|
-
],
|
|
207
|
-
edges: [
|
|
208
|
-
{ id: 'e1', sourceId: 'input-1', targetId: 'expr-a', type: 'edge' },
|
|
209
|
-
{ id: 'e2', sourceId: 'expr-a', targetId: 'expr-b', type: 'edge' },
|
|
210
|
-
{ id: 'e3', sourceId: 'expr-b', targetId: 'expr-c', type: 'edge' },
|
|
211
|
-
{ id: 'e4', sourceId: 'expr-c', targetId: 'expr-a', type: 'edge' }, // Creates cycle
|
|
212
|
-
],
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
const graph = buildGraph(jdm);
|
|
216
|
-
expect(() => validateGraph(graph)).toThrow(CompilationError);
|
|
217
|
-
expect(() => validateGraph(graph)).toThrow(/circular/i);
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
describe('Invalid Expression Syntax', () => {
|
|
222
|
-
it('should throw error for invalid arithmetic syntax', async () => {
|
|
223
|
-
const jdm = createExpressionJDM([{ key: 'result', value: 'x + + y' }]);
|
|
224
|
-
|
|
225
|
-
await expect(
|
|
226
|
-
compile({
|
|
227
|
-
jdm,
|
|
228
|
-
inputSchema: Type.Object({ x: Type.Number(), y: Type.Number() }),
|
|
229
|
-
outputSchema: defaultOutputSchema,
|
|
230
|
-
}),
|
|
231
|
-
).rejects.toThrow();
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('should throw error for unclosed parentheses', async () => {
|
|
235
|
-
const jdm = createExpressionJDM([{ key: 'result', value: '(x + y' }]);
|
|
236
|
-
|
|
237
|
-
await expect(
|
|
238
|
-
compile({
|
|
239
|
-
jdm,
|
|
240
|
-
inputSchema: Type.Object({ x: Type.Number(), y: Type.Number() }),
|
|
241
|
-
outputSchema: defaultOutputSchema,
|
|
242
|
-
}),
|
|
243
|
-
).rejects.toThrow();
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
it('should throw error for unclosed string literal', async () => {
|
|
247
|
-
const jdm = createExpressionJDM([{ key: 'result', value: '"hello' }]);
|
|
248
|
-
|
|
249
|
-
await expect(
|
|
250
|
-
compile({
|
|
251
|
-
jdm,
|
|
252
|
-
inputSchema: Type.Object({}),
|
|
253
|
-
outputSchema: Type.Object({ result: Type.String() }),
|
|
254
|
-
}),
|
|
255
|
-
).rejects.toThrow();
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it('should throw error for empty expression', async () => {
|
|
259
|
-
const jdm = createExpressionJDM([{ key: 'result', value: '' }]);
|
|
260
|
-
|
|
261
|
-
await expect(
|
|
262
|
-
compile({
|
|
263
|
-
jdm,
|
|
264
|
-
inputSchema: defaultInputSchema,
|
|
265
|
-
outputSchema: defaultOutputSchema,
|
|
266
|
-
}),
|
|
267
|
-
).rejects.toThrow();
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
it('should throw error for whitespace-only expression', async () => {
|
|
271
|
-
const jdm = createExpressionJDM([{ key: 'result', value: ' ' }]);
|
|
272
|
-
|
|
273
|
-
await expect(
|
|
274
|
-
compile({
|
|
275
|
-
jdm,
|
|
276
|
-
inputSchema: defaultInputSchema,
|
|
277
|
-
outputSchema: defaultOutputSchema,
|
|
278
|
-
}),
|
|
279
|
-
).rejects.toThrow();
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
describe('Invalid Edges', () => {
|
|
284
|
-
it('should throw error for edge referencing non-existent source node', () => {
|
|
285
|
-
const jdm: JDMDecision = {
|
|
286
|
-
nodes: [
|
|
287
|
-
{
|
|
288
|
-
id: 'input-1',
|
|
289
|
-
type: NodeType.INPUT,
|
|
290
|
-
position: { x: 0, y: 0 },
|
|
291
|
-
name: 'Request',
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
id: 'output-1',
|
|
295
|
-
type: NodeType.OUTPUT,
|
|
296
|
-
position: { x: 200, y: 0 },
|
|
297
|
-
name: 'Response',
|
|
298
|
-
},
|
|
299
|
-
],
|
|
300
|
-
edges: [
|
|
301
|
-
{
|
|
302
|
-
id: 'edge-1',
|
|
303
|
-
sourceId: 'nonexistent-node',
|
|
304
|
-
targetId: 'output-1',
|
|
305
|
-
type: 'edge',
|
|
306
|
-
},
|
|
307
|
-
],
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
expect(() => buildGraph(jdm)).toThrow(CompilationError);
|
|
311
|
-
expect(() => buildGraph(jdm)).toThrow(/non-existent node/i);
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
it('should throw error for edge referencing non-existent target node', () => {
|
|
315
|
-
const jdm: JDMDecision = {
|
|
316
|
-
nodes: [
|
|
317
|
-
{
|
|
318
|
-
id: 'input-1',
|
|
319
|
-
type: NodeType.INPUT,
|
|
320
|
-
position: { x: 0, y: 0 },
|
|
321
|
-
name: 'Request',
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
id: 'output-1',
|
|
325
|
-
type: NodeType.OUTPUT,
|
|
326
|
-
position: { x: 200, y: 0 },
|
|
327
|
-
name: 'Response',
|
|
328
|
-
},
|
|
329
|
-
],
|
|
330
|
-
edges: [
|
|
331
|
-
{
|
|
332
|
-
id: 'edge-1',
|
|
333
|
-
sourceId: 'input-1',
|
|
334
|
-
targetId: 'nonexistent-node',
|
|
335
|
-
type: 'edge',
|
|
336
|
-
},
|
|
337
|
-
],
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
expect(() => buildGraph(jdm)).toThrow(CompilationError);
|
|
341
|
-
expect(() => buildGraph(jdm)).toThrow(/non-existent node/i);
|
|
342
|
-
});
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
describe('Function Node Parsing', () => {
|
|
346
|
-
it('should parse function nodes successfully', () => {
|
|
347
|
-
const jdm = {
|
|
348
|
-
nodes: [
|
|
349
|
-
{
|
|
350
|
-
id: 'input-1',
|
|
351
|
-
type: 'inputNode',
|
|
352
|
-
position: { x: 0, y: 0 },
|
|
353
|
-
name: 'Request',
|
|
354
|
-
},
|
|
355
|
-
{
|
|
356
|
-
id: 'func-1',
|
|
357
|
-
type: 'functionNode',
|
|
358
|
-
position: { x: 200, y: 0 },
|
|
359
|
-
name: 'CustomFunction',
|
|
360
|
-
content: { source: 'export const handler = (input) => ({ result: input.x * 2 });' },
|
|
361
|
-
},
|
|
362
|
-
{
|
|
363
|
-
id: 'output-1',
|
|
364
|
-
type: 'outputNode',
|
|
365
|
-
position: { x: 400, y: 0 },
|
|
366
|
-
name: 'Response',
|
|
367
|
-
},
|
|
368
|
-
],
|
|
369
|
-
edges: [
|
|
370
|
-
{ id: 'edge-1', sourceId: 'input-1', targetId: 'func-1', type: 'edge' },
|
|
371
|
-
{ id: 'edge-2', sourceId: 'func-1', targetId: 'output-1', type: 'edge' },
|
|
372
|
-
],
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
// Should parse without error
|
|
376
|
-
const parsed = parseJDM(jdm);
|
|
377
|
-
expect(parsed.nodes.length).toBe(3);
|
|
378
|
-
expect(parsed.nodes[1].type).toBe('functionNode');
|
|
379
|
-
expect(parsed.nodes[1].parsedContent).toBeDefined();
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
it('should throw error for function node with invalid JavaScript syntax', () => {
|
|
383
|
-
const jdm = {
|
|
384
|
-
nodes: [
|
|
385
|
-
{
|
|
386
|
-
id: 'func-1',
|
|
387
|
-
type: 'functionNode',
|
|
388
|
-
position: { x: 200, y: 0 },
|
|
389
|
-
name: 'CustomFunction',
|
|
390
|
-
content: { source: 'this is not valid javascript {{{' },
|
|
391
|
-
},
|
|
392
|
-
],
|
|
393
|
-
edges: [],
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
expect(() => parseJDM(jdm)).toThrow();
|
|
397
|
-
expect(() => parseJDM(jdm)).toThrow('Failed to parse function code');
|
|
398
|
-
});
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
describe('Empty or Malformed JDM Structure', () => {
|
|
402
|
-
it('should throw error for empty nodes array', () => {
|
|
403
|
-
const jdm: JDMDecision = {
|
|
404
|
-
nodes: [],
|
|
405
|
-
edges: [],
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
const graph = buildGraph(jdm);
|
|
409
|
-
expect(() => validateGraph(graph)).toThrow(CompilationError);
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
it('should throw error for invalid JSON string', () => {
|
|
413
|
-
expect(() => parseJDM('{ invalid json }')).toThrow();
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
it('should handle JDM with only input node (no output)', () => {
|
|
417
|
-
const jdm: JDMDecision = {
|
|
418
|
-
nodes: [
|
|
419
|
-
{
|
|
420
|
-
id: 'input-1',
|
|
421
|
-
type: NodeType.INPUT,
|
|
422
|
-
position: { x: 0, y: 0 },
|
|
423
|
-
name: 'Request',
|
|
424
|
-
},
|
|
425
|
-
],
|
|
426
|
-
edges: [],
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
const graph = buildGraph(jdm);
|
|
430
|
-
expect(() => validateGraph(graph)).toThrow(CompilationError);
|
|
431
|
-
expect(() => validateGraph(graph)).toThrow(/output node/i);
|
|
432
|
-
});
|
|
433
|
-
|
|
434
|
-
it('should handle JDM with only output node (no input)', () => {
|
|
435
|
-
const jdm: JDMDecision = {
|
|
436
|
-
nodes: [
|
|
437
|
-
{
|
|
438
|
-
id: 'output-1',
|
|
439
|
-
type: NodeType.OUTPUT,
|
|
440
|
-
position: { x: 0, y: 0 },
|
|
441
|
-
name: 'Response',
|
|
442
|
-
},
|
|
443
|
-
],
|
|
444
|
-
edges: [],
|
|
445
|
-
};
|
|
446
|
-
|
|
447
|
-
const graph = buildGraph(jdm);
|
|
448
|
-
expect(() => validateGraph(graph)).toThrow(CompilationError);
|
|
449
|
-
expect(() => validateGraph(graph)).toThrow(/input node/i);
|
|
450
|
-
});
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
describe('Source Location in Errors', () => {
|
|
454
|
-
it('should include node information in structural errors', () => {
|
|
455
|
-
const jdm: JDMDecision = {
|
|
456
|
-
nodes: [
|
|
457
|
-
{
|
|
458
|
-
id: 'expr-1',
|
|
459
|
-
type: NodeType.EXPRESSION,
|
|
460
|
-
position: { x: 0, y: 0 },
|
|
461
|
-
name: 'OrphanExpression',
|
|
462
|
-
content: { expressions: [] },
|
|
463
|
-
},
|
|
464
|
-
],
|
|
465
|
-
edges: [],
|
|
466
|
-
};
|
|
467
|
-
|
|
468
|
-
const graph = buildGraph(jdm);
|
|
469
|
-
try {
|
|
470
|
-
validateGraph(graph);
|
|
471
|
-
expect.fail('Should have thrown');
|
|
472
|
-
} catch (e) {
|
|
473
|
-
expect(e).toBeInstanceOf(CompilationError);
|
|
474
|
-
// Error should mention missing input/output nodes
|
|
475
|
-
expect((e as Error).message).toMatch(/node/i);
|
|
476
|
-
}
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
it('should include node name in cycle detection errors', () => {
|
|
480
|
-
const jdm: JDMDecision = {
|
|
481
|
-
nodes: [
|
|
482
|
-
{
|
|
483
|
-
id: 'input-1',
|
|
484
|
-
type: NodeType.INPUT,
|
|
485
|
-
position: { x: 0, y: 0 },
|
|
486
|
-
name: 'Request',
|
|
487
|
-
},
|
|
488
|
-
{
|
|
489
|
-
id: 'expr-1',
|
|
490
|
-
type: NodeType.EXPRESSION,
|
|
491
|
-
position: { x: 100, y: 0 },
|
|
492
|
-
name: 'CycleNodeA',
|
|
493
|
-
content: { expressions: [] },
|
|
494
|
-
},
|
|
495
|
-
{
|
|
496
|
-
id: 'expr-2',
|
|
497
|
-
type: NodeType.EXPRESSION,
|
|
498
|
-
position: { x: 200, y: 0 },
|
|
499
|
-
name: 'CycleNodeB',
|
|
500
|
-
content: { expressions: [] },
|
|
501
|
-
},
|
|
502
|
-
{
|
|
503
|
-
id: 'output-1',
|
|
504
|
-
type: NodeType.OUTPUT,
|
|
505
|
-
position: { x: 300, y: 0 },
|
|
506
|
-
name: 'Response',
|
|
507
|
-
},
|
|
508
|
-
],
|
|
509
|
-
edges: [
|
|
510
|
-
{ id: 'e1', sourceId: 'input-1', targetId: 'expr-1', type: 'edge' },
|
|
511
|
-
{ id: 'e2', sourceId: 'expr-1', targetId: 'expr-2', type: 'edge' },
|
|
512
|
-
{ id: 'e3', sourceId: 'expr-2', targetId: 'expr-1', type: 'edge' },
|
|
513
|
-
],
|
|
514
|
-
};
|
|
515
|
-
|
|
516
|
-
const graph = buildGraph(jdm);
|
|
517
|
-
try {
|
|
518
|
-
validateGraph(graph);
|
|
519
|
-
expect.fail('Should have thrown');
|
|
520
|
-
} catch (e) {
|
|
521
|
-
expect(e).toBeInstanceOf(CompilationError);
|
|
522
|
-
const message = (e as Error).message;
|
|
523
|
-
// Should include node names in cycle path
|
|
524
|
-
expect(message).toMatch(/CycleNodeA|CycleNodeB/);
|
|
525
|
-
}
|
|
526
|
-
});
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
describe('Error Code Classification', () => {
|
|
530
|
-
it('should use MULTIPLE_INPUT_NODES code for missing or wrong number of inputs', () => {
|
|
531
|
-
// Note: The graph validation uses MULTIPLE_INPUT_NODES code when input count != 1
|
|
532
|
-
// This includes both 0 inputs and 2+ inputs
|
|
533
|
-
const jdm: JDMDecision = {
|
|
534
|
-
nodes: [
|
|
535
|
-
{
|
|
536
|
-
id: 'output-1',
|
|
537
|
-
type: NodeType.OUTPUT,
|
|
538
|
-
position: { x: 0, y: 0 },
|
|
539
|
-
name: 'Response',
|
|
540
|
-
},
|
|
541
|
-
],
|
|
542
|
-
edges: [],
|
|
543
|
-
};
|
|
544
|
-
|
|
545
|
-
const graph = buildGraph(jdm);
|
|
546
|
-
try {
|
|
547
|
-
validateGraph(graph);
|
|
548
|
-
expect.fail('Should have thrown');
|
|
549
|
-
} catch (e) {
|
|
550
|
-
expect(e).toBeInstanceOf(CompilationError);
|
|
551
|
-
// When input count != 1, MULTIPLE_INPUT_NODES is used (includes 0 case)
|
|
552
|
-
expect((e as CompilationError).code).toBe(ErrorCode.MULTIPLE_INPUT_NODES);
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
|
|
556
|
-
it('should use MISSING_OUTPUT_NODE code for missing output', () => {
|
|
557
|
-
const jdm: JDMDecision = {
|
|
558
|
-
nodes: [
|
|
559
|
-
{
|
|
560
|
-
id: 'input-1',
|
|
561
|
-
type: NodeType.INPUT,
|
|
562
|
-
position: { x: 0, y: 0 },
|
|
563
|
-
name: 'Request',
|
|
564
|
-
},
|
|
565
|
-
],
|
|
566
|
-
edges: [],
|
|
567
|
-
};
|
|
568
|
-
|
|
569
|
-
const graph = buildGraph(jdm);
|
|
570
|
-
try {
|
|
571
|
-
validateGraph(graph);
|
|
572
|
-
expect.fail('Should have thrown');
|
|
573
|
-
} catch (e) {
|
|
574
|
-
expect(e).toBeInstanceOf(CompilationError);
|
|
575
|
-
expect((e as CompilationError).code).toBe(ErrorCode.MISSING_OUTPUT_NODE);
|
|
576
|
-
}
|
|
577
|
-
});
|
|
578
|
-
|
|
579
|
-
it('should use MULTIPLE_INPUT_NODES code for multiple inputs', () => {
|
|
580
|
-
const jdm: JDMDecision = {
|
|
581
|
-
nodes: [
|
|
582
|
-
{
|
|
583
|
-
id: 'input-1',
|
|
584
|
-
type: NodeType.INPUT,
|
|
585
|
-
position: { x: 0, y: 0 },
|
|
586
|
-
name: 'Request1',
|
|
587
|
-
},
|
|
588
|
-
{
|
|
589
|
-
id: 'input-2',
|
|
590
|
-
type: NodeType.INPUT,
|
|
591
|
-
position: { x: 0, y: 100 },
|
|
592
|
-
name: 'Request2',
|
|
593
|
-
},
|
|
594
|
-
{
|
|
595
|
-
id: 'output-1',
|
|
596
|
-
type: NodeType.OUTPUT,
|
|
597
|
-
position: { x: 200, y: 0 },
|
|
598
|
-
name: 'Response',
|
|
599
|
-
},
|
|
600
|
-
],
|
|
601
|
-
edges: [],
|
|
602
|
-
};
|
|
603
|
-
|
|
604
|
-
const graph = buildGraph(jdm);
|
|
605
|
-
try {
|
|
606
|
-
validateGraph(graph);
|
|
607
|
-
expect.fail('Should have thrown');
|
|
608
|
-
} catch (e) {
|
|
609
|
-
expect(e).toBeInstanceOf(CompilationError);
|
|
610
|
-
expect((e as CompilationError).code).toBe(ErrorCode.MULTIPLE_INPUT_NODES);
|
|
611
|
-
}
|
|
612
|
-
});
|
|
613
|
-
|
|
614
|
-
it('should use CYCLE_DETECTED code for cycles', () => {
|
|
615
|
-
const jdm: JDMDecision = {
|
|
616
|
-
nodes: [
|
|
617
|
-
{
|
|
618
|
-
id: 'input-1',
|
|
619
|
-
type: NodeType.INPUT,
|
|
620
|
-
position: { x: 0, y: 0 },
|
|
621
|
-
name: 'Request',
|
|
622
|
-
},
|
|
623
|
-
{
|
|
624
|
-
id: 'expr-1',
|
|
625
|
-
type: NodeType.EXPRESSION,
|
|
626
|
-
position: { x: 100, y: 0 },
|
|
627
|
-
name: 'NodeA',
|
|
628
|
-
content: { expressions: [] },
|
|
629
|
-
},
|
|
630
|
-
{
|
|
631
|
-
id: 'expr-2',
|
|
632
|
-
type: NodeType.EXPRESSION,
|
|
633
|
-
position: { x: 200, y: 0 },
|
|
634
|
-
name: 'NodeB',
|
|
635
|
-
content: { expressions: [] },
|
|
636
|
-
},
|
|
637
|
-
{
|
|
638
|
-
id: 'output-1',
|
|
639
|
-
type: NodeType.OUTPUT,
|
|
640
|
-
position: { x: 300, y: 0 },
|
|
641
|
-
name: 'Response',
|
|
642
|
-
},
|
|
643
|
-
],
|
|
644
|
-
edges: [
|
|
645
|
-
{ id: 'e1', sourceId: 'input-1', targetId: 'expr-1', type: 'edge' },
|
|
646
|
-
{ id: 'e2', sourceId: 'expr-1', targetId: 'expr-2', type: 'edge' },
|
|
647
|
-
{ id: 'e3', sourceId: 'expr-2', targetId: 'expr-1', type: 'edge' },
|
|
648
|
-
],
|
|
649
|
-
};
|
|
650
|
-
|
|
651
|
-
const graph = buildGraph(jdm);
|
|
652
|
-
try {
|
|
653
|
-
validateGraph(graph);
|
|
654
|
-
expect.fail('Should have thrown');
|
|
655
|
-
} catch (e) {
|
|
656
|
-
expect(e).toBeInstanceOf(CompilationError);
|
|
657
|
-
expect((e as CompilationError).code).toBe(ErrorCode.CYCLE_DETECTED);
|
|
658
|
-
}
|
|
659
|
-
});
|
|
660
|
-
|
|
661
|
-
it('should use INVALID_EDGE code for invalid edges', () => {
|
|
662
|
-
const jdm: JDMDecision = {
|
|
663
|
-
nodes: [
|
|
664
|
-
{
|
|
665
|
-
id: 'input-1',
|
|
666
|
-
type: NodeType.INPUT,
|
|
667
|
-
position: { x: 0, y: 0 },
|
|
668
|
-
name: 'Request',
|
|
669
|
-
},
|
|
670
|
-
],
|
|
671
|
-
edges: [
|
|
672
|
-
{
|
|
673
|
-
id: 'edge-1',
|
|
674
|
-
sourceId: 'input-1',
|
|
675
|
-
targetId: 'nonexistent',
|
|
676
|
-
type: 'edge',
|
|
677
|
-
},
|
|
678
|
-
],
|
|
679
|
-
};
|
|
680
|
-
|
|
681
|
-
try {
|
|
682
|
-
buildGraph(jdm);
|
|
683
|
-
expect.fail('Should have thrown');
|
|
684
|
-
} catch (e) {
|
|
685
|
-
expect(e).toBeInstanceOf(CompilationError);
|
|
686
|
-
expect((e as CompilationError).code).toBe(ErrorCode.INVALID_EDGE);
|
|
687
|
-
}
|
|
688
|
-
});
|
|
689
|
-
});
|
|
690
|
-
|
|
691
|
-
describe('Decision Table Validation', () => {
|
|
692
|
-
it('should handle decision table with no rules (currently a limitation)', async () => {
|
|
693
|
-
const jdm: JDMDecision = {
|
|
694
|
-
nodes: [
|
|
695
|
-
{
|
|
696
|
-
id: 'input-1',
|
|
697
|
-
type: NodeType.INPUT,
|
|
698
|
-
position: { x: 0, y: 0 },
|
|
699
|
-
name: 'Request',
|
|
700
|
-
},
|
|
701
|
-
{
|
|
702
|
-
id: 'dt-1',
|
|
703
|
-
type: NodeType.DECISION_TABLE,
|
|
704
|
-
position: { x: 200, y: 0 },
|
|
705
|
-
name: 'EmptyTable',
|
|
706
|
-
content: {
|
|
707
|
-
hitPolicy: 'first',
|
|
708
|
-
inputs: [{ id: 'in1', field: 'x', name: 'X' }],
|
|
709
|
-
outputs: [{ id: 'out1', field: 'result', name: 'Result' }],
|
|
710
|
-
rules: [],
|
|
711
|
-
},
|
|
712
|
-
},
|
|
713
|
-
{
|
|
714
|
-
id: 'output-1',
|
|
715
|
-
type: NodeType.OUTPUT,
|
|
716
|
-
position: { x: 400, y: 0 },
|
|
717
|
-
name: 'Response',
|
|
718
|
-
},
|
|
719
|
-
],
|
|
720
|
-
edges: [
|
|
721
|
-
{ id: 'e1', sourceId: 'input-1', targetId: 'dt-1', type: 'edge' },
|
|
722
|
-
{ id: 'e2', sourceId: 'dt-1', targetId: 'output-1', type: 'edge' },
|
|
723
|
-
],
|
|
724
|
-
};
|
|
725
|
-
|
|
726
|
-
// LIMITATION: Empty decision tables currently fail to compile due to code generation
|
|
727
|
-
// producing invalid AssemblyScript (dangling 'else' clause).
|
|
728
|
-
// This documents the current behavior - future improvements could handle this case.
|
|
729
|
-
await expect(
|
|
730
|
-
compile({
|
|
731
|
-
jdm,
|
|
732
|
-
inputSchema: Type.Object({ x: Type.Number() }),
|
|
733
|
-
outputSchema: Type.Object({ result: Type.Optional(Type.Number()) }),
|
|
734
|
-
}),
|
|
735
|
-
).rejects.toThrow();
|
|
736
|
-
});
|
|
737
|
-
|
|
738
|
-
it('should handle decision table with at least one rule', async () => {
|
|
739
|
-
const jdm: JDMDecision = {
|
|
740
|
-
nodes: [
|
|
741
|
-
{
|
|
742
|
-
id: 'input-1',
|
|
743
|
-
type: NodeType.INPUT,
|
|
744
|
-
position: { x: 0, y: 0 },
|
|
745
|
-
name: 'Request',
|
|
746
|
-
},
|
|
747
|
-
{
|
|
748
|
-
id: 'dt-1',
|
|
749
|
-
type: NodeType.DECISION_TABLE,
|
|
750
|
-
position: { x: 200, y: 0 },
|
|
751
|
-
name: 'SimpleTable',
|
|
752
|
-
content: {
|
|
753
|
-
hitPolicy: 'first',
|
|
754
|
-
inputs: [{ id: 'in1', field: 'x', name: 'X' }],
|
|
755
|
-
outputs: [{ id: 'out1', field: 'result', name: 'Result' }],
|
|
756
|
-
rules: [
|
|
757
|
-
{
|
|
758
|
-
_id: 'rule1',
|
|
759
|
-
in1: '', // Empty condition = always matches
|
|
760
|
-
out1: '42',
|
|
761
|
-
},
|
|
762
|
-
],
|
|
763
|
-
},
|
|
764
|
-
},
|
|
765
|
-
{
|
|
766
|
-
id: 'output-1',
|
|
767
|
-
type: NodeType.OUTPUT,
|
|
768
|
-
position: { x: 400, y: 0 },
|
|
769
|
-
name: 'Response',
|
|
770
|
-
},
|
|
771
|
-
],
|
|
772
|
-
edges: [
|
|
773
|
-
{ id: 'e1', sourceId: 'input-1', targetId: 'dt-1', type: 'edge' },
|
|
774
|
-
{ id: 'e2', sourceId: 'dt-1', targetId: 'output-1', type: 'edge' },
|
|
775
|
-
],
|
|
776
|
-
};
|
|
777
|
-
|
|
778
|
-
const result = await compile({
|
|
779
|
-
jdm,
|
|
780
|
-
inputSchema: Type.Object({ x: Type.Number() }),
|
|
781
|
-
outputSchema: Type.Object({ result: Type.Number() }),
|
|
782
|
-
});
|
|
783
|
-
|
|
784
|
-
expect(result.wasm).toBeInstanceOf(Uint8Array);
|
|
785
|
-
});
|
|
786
|
-
});
|
|
787
|
-
|
|
788
|
-
describe('Switch Node Validation', () => {
|
|
789
|
-
it('should handle switch with no conditions', async () => {
|
|
790
|
-
const jdm: JDMDecision = {
|
|
791
|
-
nodes: [
|
|
792
|
-
{
|
|
793
|
-
id: 'input-1',
|
|
794
|
-
type: NodeType.INPUT,
|
|
795
|
-
position: { x: 0, y: 0 },
|
|
796
|
-
name: 'Request',
|
|
797
|
-
},
|
|
798
|
-
{
|
|
799
|
-
id: 'switch-1',
|
|
800
|
-
type: NodeType.SWITCH,
|
|
801
|
-
position: { x: 200, y: 0 },
|
|
802
|
-
name: 'EmptySwitch',
|
|
803
|
-
content: {
|
|
804
|
-
hitPolicy: 'first',
|
|
805
|
-
statements: [],
|
|
806
|
-
},
|
|
807
|
-
},
|
|
808
|
-
{
|
|
809
|
-
id: 'output-1',
|
|
810
|
-
type: NodeType.OUTPUT,
|
|
811
|
-
position: { x: 400, y: 0 },
|
|
812
|
-
name: 'Response',
|
|
813
|
-
},
|
|
814
|
-
],
|
|
815
|
-
edges: [
|
|
816
|
-
{ id: 'e1', sourceId: 'input-1', targetId: 'switch-1', type: 'edge' },
|
|
817
|
-
{ id: 'e2', sourceId: 'switch-1', targetId: 'output-1', type: 'edge' },
|
|
818
|
-
],
|
|
819
|
-
};
|
|
820
|
-
|
|
821
|
-
// Empty switch should compile but produce no output or use default
|
|
822
|
-
const result = await compile({
|
|
823
|
-
jdm,
|
|
824
|
-
inputSchema: Type.Object({ x: Type.Number() }),
|
|
825
|
-
outputSchema: Type.Object({}),
|
|
826
|
-
});
|
|
827
|
-
|
|
828
|
-
expect(result.wasm).toBeInstanceOf(Uint8Array);
|
|
829
|
-
});
|
|
830
|
-
});
|
|
831
|
-
|
|
832
|
-
describe('Compilation Pipeline Errors', () => {
|
|
833
|
-
it('should provide useful error for complex nested expression errors', async () => {
|
|
834
|
-
const jdm = createExpressionJDM([{ key: 'result', value: '((x + y) * (z -))' }]); // Missing operand
|
|
835
|
-
|
|
836
|
-
try {
|
|
837
|
-
await compile({
|
|
838
|
-
jdm,
|
|
839
|
-
inputSchema: Type.Object({ x: Type.Number(), y: Type.Number(), z: Type.Number() }),
|
|
840
|
-
outputSchema: defaultOutputSchema,
|
|
841
|
-
});
|
|
842
|
-
expect.fail('Should have thrown');
|
|
843
|
-
} catch (e) {
|
|
844
|
-
expect(e).toBeDefined();
|
|
845
|
-
// The error should be thrown, exact message depends on parser
|
|
846
|
-
}
|
|
847
|
-
});
|
|
848
|
-
|
|
849
|
-
it('should handle invalid ternary expression', async () => {
|
|
850
|
-
const jdm = createExpressionJDM([{ key: 'result', value: 'x > 0 ? "yes"' }]); // Missing else branch
|
|
851
|
-
|
|
852
|
-
try {
|
|
853
|
-
await compile({
|
|
854
|
-
jdm,
|
|
855
|
-
inputSchema: defaultInputSchema,
|
|
856
|
-
outputSchema: Type.Object({ result: Type.String() }),
|
|
857
|
-
});
|
|
858
|
-
expect.fail('Should have thrown');
|
|
859
|
-
} catch (e) {
|
|
860
|
-
expect(e).toBeDefined();
|
|
861
|
-
}
|
|
862
|
-
});
|
|
863
|
-
});
|
|
864
|
-
});
|