reqon-dsl 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +45 -3
- package/dist/ast/nodes.d.ts +91 -4
- package/dist/ast/nodes.js +14 -0
- package/dist/auth/circuit-breaker.d.ts +11 -0
- package/dist/auth/circuit-breaker.js +90 -18
- package/dist/auth/credentials.d.ts +6 -1
- package/dist/auth/credentials.js +12 -4
- package/dist/auth/oauth2-provider.js +13 -3
- package/dist/auth/rate-limiter.d.ts +12 -1
- package/dist/auth/rate-limiter.js +39 -26
- package/dist/auth/token-store.js +8 -1
- package/dist/cli.d.ts +24 -1
- package/dist/cli.js +149 -10
- package/dist/config/constants.d.ts +152 -0
- package/dist/config/constants.js +139 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/index.js +4 -0
- package/dist/control/index.d.ts +2 -0
- package/dist/control/index.js +1 -0
- package/dist/control/server.d.ts +105 -0
- package/dist/control/server.js +315 -0
- package/dist/control/types.d.ts +61 -0
- package/dist/control/types.js +7 -0
- package/dist/debug/cli-debugger.d.ts +17 -0
- package/dist/debug/cli-debugger.js +185 -0
- package/dist/debug/controller.d.ts +94 -0
- package/dist/debug/controller.js +45 -0
- package/dist/debug/index.d.ts +6 -0
- package/dist/debug/index.js +5 -0
- package/dist/errors/index.d.ts +67 -0
- package/dist/errors/index.js +89 -1
- package/dist/execution/index.d.ts +1 -1
- package/dist/execution/state.d.ts +24 -0
- package/dist/execution/store.js +2 -2
- package/dist/execution-log/events.d.ts +125 -0
- package/dist/execution-log/events.js +17 -0
- package/dist/execution-log/fold.d.ts +38 -0
- package/dist/execution-log/fold.js +54 -0
- package/dist/execution-log/index.d.ts +18 -0
- package/dist/execution-log/index.js +6 -0
- package/dist/execution-log/postgres-store.d.ts +36 -0
- package/dist/execution-log/postgres-store.js +108 -0
- package/dist/execution-log/resume.d.ts +11 -0
- package/dist/execution-log/resume.js +5 -0
- package/dist/execution-log/sqlite-store.d.ts +16 -0
- package/dist/execution-log/sqlite-store.js +101 -0
- package/dist/execution-log/store.d.ts +72 -0
- package/dist/execution-log/store.js +182 -0
- package/dist/index.d.ts +23 -2
- package/dist/index.js +35 -3
- package/dist/interpreter/context.d.ts +29 -0
- package/dist/interpreter/context.js +18 -0
- package/dist/interpreter/evaluator.d.ts +63 -1
- package/dist/interpreter/evaluator.js +219 -42
- package/dist/interpreter/executor.d.ts +132 -14
- package/dist/interpreter/executor.js +883 -178
- package/dist/interpreter/fetch-handler.d.ts +48 -1
- package/dist/interpreter/fetch-handler.js +216 -38
- package/dist/interpreter/http.d.ts +34 -0
- package/dist/interpreter/http.js +203 -28
- package/dist/interpreter/index.d.ts +5 -3
- package/dist/interpreter/index.js +4 -2
- package/dist/interpreter/pagination.d.ts +12 -3
- package/dist/interpreter/pagination.js +102 -32
- package/dist/interpreter/signals.d.ts +8 -0
- package/dist/interpreter/signals.js +12 -0
- package/dist/interpreter/source-manager.d.ts +75 -0
- package/dist/interpreter/source-manager.js +157 -0
- package/dist/interpreter/step-handlers/apply-handler.d.ts +29 -0
- package/dist/interpreter/step-handlers/apply-handler.js +79 -0
- package/dist/interpreter/step-handlers/for-handler.d.ts +16 -0
- package/dist/interpreter/step-handlers/for-handler.js +89 -7
- package/dist/interpreter/step-handlers/index.d.ts +4 -2
- package/dist/interpreter/step-handlers/index.js +4 -2
- package/dist/interpreter/step-handlers/match-handler.d.ts +9 -0
- package/dist/interpreter/step-handlers/match-handler.js +47 -17
- package/dist/interpreter/step-handlers/pause-handler.d.ts +52 -0
- package/dist/interpreter/step-handlers/pause-handler.js +87 -0
- package/dist/interpreter/step-handlers/store-handler.d.ts +17 -1
- package/dist/interpreter/step-handlers/store-handler.js +61 -20
- package/dist/interpreter/step-handlers/types.d.ts +3 -0
- package/dist/interpreter/step-handlers/validate-handler.d.ts +2 -1
- package/dist/interpreter/step-handlers/validate-handler.js +7 -2
- package/dist/interpreter/step-handlers/webhook-handler.d.ts +4 -0
- package/dist/interpreter/step-handlers/webhook-handler.js +31 -5
- package/dist/interpreter/store-manager.d.ts +46 -0
- package/dist/interpreter/store-manager.js +70 -0
- package/dist/lexer/index.d.ts +11 -4
- package/dist/lexer/index.js +11 -4
- package/dist/lexer/tokens.d.ts +17 -1
- package/dist/lexer/tokens.js +36 -0
- package/dist/loader/index.js +5 -8
- package/dist/mcp/index.d.ts +11 -0
- package/dist/mcp/index.js +11 -0
- package/dist/mcp/sandbox.d.ts +41 -0
- package/dist/mcp/sandbox.js +76 -0
- package/dist/mcp/server.d.ts +17 -0
- package/dist/mcp/server.js +504 -0
- package/dist/oas/index.d.ts +2 -0
- package/dist/oas/index.js +1 -0
- package/dist/oas/loader.d.ts +13 -1
- package/dist/oas/loader.js +25 -3
- package/dist/oas/mock-generator.d.ts +12 -0
- package/dist/oas/mock-generator.js +196 -0
- package/dist/oas/validator.js +45 -5
- package/dist/observability/events.d.ts +248 -0
- package/dist/observability/events.js +85 -0
- package/dist/observability/index.d.ts +15 -0
- package/dist/observability/index.js +12 -0
- package/dist/observability/logger.d.ts +106 -0
- package/dist/observability/logger.js +266 -0
- package/dist/observability/otel.d.ts +143 -0
- package/dist/observability/otel.js +421 -0
- package/dist/parser/action-parser.d.ts +105 -0
- package/dist/parser/action-parser.js +645 -0
- package/dist/parser/base.d.ts +7 -0
- package/dist/parser/base.js +11 -0
- package/dist/parser/expressions.d.ts +14 -0
- package/dist/parser/expressions.js +89 -6
- package/dist/parser/fetch-parser.d.ts +27 -0
- package/dist/parser/fetch-parser.js +280 -0
- package/dist/parser/index.d.ts +17 -0
- package/dist/parser/index.js +17 -0
- package/dist/parser/parser.d.ts +44 -46
- package/dist/parser/parser.js +122 -1070
- package/dist/parser/pipeline-parser.d.ts +12 -0
- package/dist/parser/pipeline-parser.js +52 -0
- package/dist/parser/schedule-parser.d.ts +7 -0
- package/dist/parser/schedule-parser.js +137 -0
- package/dist/parser/source-parser.d.ts +9 -0
- package/dist/parser/source-parser.js +151 -0
- package/dist/pause/index.d.ts +15 -0
- package/dist/pause/index.js +12 -0
- package/dist/pause/log-store.d.ts +33 -0
- package/dist/pause/log-store.js +98 -0
- package/dist/pause/manager.d.ts +130 -0
- package/dist/pause/manager.js +294 -0
- package/dist/pause/state.d.ts +93 -0
- package/dist/pause/state.js +103 -0
- package/dist/pause/store.d.ts +61 -0
- package/dist/pause/store.js +158 -0
- package/dist/plugin.d.ts +9 -12
- package/dist/plugin.js +10 -13
- package/dist/scheduler/cron-parser.d.ts +10 -3
- package/dist/scheduler/cron-parser.js +227 -48
- package/dist/scheduler/scheduler.js +56 -22
- package/dist/stores/factory.d.ts +7 -1
- package/dist/stores/factory.js +14 -3
- package/dist/stores/file.d.ts +26 -0
- package/dist/stores/file.js +67 -21
- package/dist/stores/index.d.ts +16 -1
- package/dist/stores/index.js +16 -1
- package/dist/stores/memory.d.ts +4 -0
- package/dist/stores/memory.js +8 -6
- package/dist/stores/postgrest.d.ts +28 -0
- package/dist/stores/postgrest.js +84 -37
- package/dist/stores/types.d.ts +17 -0
- package/dist/stores/types.js +12 -0
- package/dist/sync/index.d.ts +3 -2
- package/dist/sync/index.js +2 -1
- package/dist/sync/log-store.d.ts +30 -0
- package/dist/sync/log-store.js +45 -0
- package/dist/sync/store.js +1 -1
- package/dist/trace/index.d.ts +18 -0
- package/dist/trace/index.js +13 -0
- package/dist/trace/log-view.d.ts +57 -0
- package/dist/trace/log-view.js +76 -0
- package/dist/trace/recorder.d.ts +75 -0
- package/dist/trace/recorder.js +157 -0
- package/dist/trace/replay.d.ts +132 -0
- package/dist/trace/replay.js +264 -0
- package/dist/trace/state.d.ts +102 -0
- package/dist/trace/state.js +86 -0
- package/dist/trace/store.d.ts +75 -0
- package/dist/trace/store.js +250 -0
- package/dist/utils/deep-merge.d.ts +10 -0
- package/dist/utils/deep-merge.js +23 -0
- package/dist/utils/file.d.ts +13 -4
- package/dist/utils/file.js +70 -12
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/long-timeout.d.ts +19 -0
- package/dist/utils/long-timeout.js +33 -0
- package/dist/utils/path.d.ts +22 -1
- package/dist/utils/path.js +46 -1
- package/dist/utils/redact.d.ts +22 -0
- package/dist/utils/redact.js +42 -0
- package/dist/utils/type-guards.d.ts +58 -0
- package/dist/utils/type-guards.js +92 -0
- package/dist/webhook/server.d.ts +9 -0
- package/dist/webhook/server.js +122 -36
- package/dist/webhook/types.d.ts +9 -1
- package/package.json +76 -9
- package/.claude/settings.local.json +0 -31
- package/.claude/skills/api-integration.md +0 -125
- package/.claude/skills/database-schema.md +0 -51
- package/.claude/skills/dsl-design.md +0 -80
- package/.claude/skills/property-testing.md +0 -143
- package/.claude/skills/reqon/SKILL.md +0 -44
- package/.claude/skills/reqon/references/examples.md +0 -206
- package/.claude/skills/reqon/references/syntax.md +0 -263
- package/.claude/skills/vscode-extension.md +0 -113
- package/.github/dependabot.yml +0 -32
- package/.github/pull_request_template.md +0 -21
- package/.github/workflows/ci.yml +0 -174
- package/.github/workflows/release.yml +0 -73
- package/CLAUDE.md +0 -72
- package/CONTRIBUTING.md +0 -161
- package/TODO.md +0 -51
- package/dist/auth/auth.test.d.ts +0 -1
- package/dist/auth/auth.test.js +0 -255
- package/dist/errors/errors.test.d.ts +0 -1
- package/dist/errors/errors.test.js +0 -165
- package/dist/execution/execution.test.d.ts +0 -1
- package/dist/execution/execution.test.js +0 -246
- package/dist/integration.test.d.ts +0 -1
- package/dist/integration.test.js +0 -168
- package/dist/interpreter/evaluator.test.d.ts +0 -1
- package/dist/interpreter/evaluator.test.js +0 -512
- package/dist/interpreter/http.test.d.ts +0 -1
- package/dist/interpreter/http.test.js +0 -299
- package/dist/interpreter/progress.test.d.ts +0 -1
- package/dist/interpreter/progress.test.js +0 -216
- package/dist/interpreter/schema-matcher.test.d.ts +0 -1
- package/dist/interpreter/schema-matcher.test.js +0 -122
- package/dist/lexer/lexer.d.ts +0 -24
- package/dist/lexer/lexer.js +0 -264
- package/dist/lexer/lexer.test.d.ts +0 -1
- package/dist/lexer/lexer.test.js +0 -259
- package/dist/loader/loader.test.d.ts +0 -1
- package/dist/loader/loader.test.js +0 -287
- package/dist/oas/oas.test.d.ts +0 -1
- package/dist/oas/oas.test.js +0 -218
- package/dist/parser/expressions.test.d.ts +0 -1
- package/dist/parser/expressions.test.js +0 -378
- package/dist/parser/match.test.d.ts +0 -1
- package/dist/parser/match.test.js +0 -254
- package/dist/parser/parser.test.d.ts +0 -1
- package/dist/parser/parser.test.js +0 -333
- package/dist/parser/schedule.test.d.ts +0 -1
- package/dist/parser/schedule.test.js +0 -241
- package/dist/scheduler/cron-parser.test.d.ts +0 -1
- package/dist/scheduler/cron-parser.test.js +0 -188
- package/dist/stores/file.test.d.ts +0 -1
- package/dist/stores/file.test.js +0 -165
- package/dist/stores/memory.test.d.ts +0 -1
- package/dist/stores/memory.test.js +0 -157
- package/dist/stores/stores.test.d.ts +0 -1
- package/dist/stores/stores.test.js +0 -158
- package/dist/sync/sync.test.d.ts +0 -1
- package/dist/sync/sync.test.js +0 -221
- package/docusaurus/README.md +0 -41
- package/docusaurus/docs/advanced/execution-state.md +0 -283
- package/docusaurus/docs/advanced/extending-reqon.md +0 -388
- package/docusaurus/docs/advanced/multi-file-missions.md +0 -250
- package/docusaurus/docs/advanced/parallel-execution.md +0 -353
- package/docusaurus/docs/api-reference.md +0 -443
- package/docusaurus/docs/authentication/api-key.md +0 -339
- package/docusaurus/docs/authentication/basic.md +0 -276
- package/docusaurus/docs/authentication/bearer.md +0 -282
- package/docusaurus/docs/authentication/oauth2.md +0 -317
- package/docusaurus/docs/authentication/overview.md +0 -251
- package/docusaurus/docs/cli.md +0 -229
- package/docusaurus/docs/core-concepts/actions.md +0 -286
- package/docusaurus/docs/core-concepts/missions.md +0 -264
- package/docusaurus/docs/core-concepts/schemas.md +0 -353
- package/docusaurus/docs/core-concepts/sources.md +0 -339
- package/docusaurus/docs/core-concepts/stores.md +0 -332
- package/docusaurus/docs/dsl-syntax/expressions.md +0 -361
- package/docusaurus/docs/dsl-syntax/fetch.md +0 -293
- package/docusaurus/docs/dsl-syntax/for-loops.md +0 -324
- package/docusaurus/docs/dsl-syntax/map.md +0 -345
- package/docusaurus/docs/dsl-syntax/match.md +0 -387
- package/docusaurus/docs/dsl-syntax/pipelines.md +0 -397
- package/docusaurus/docs/dsl-syntax/validate.md +0 -401
- package/docusaurus/docs/error-handling/dead-letter-queues.md +0 -399
- package/docusaurus/docs/error-handling/flow-control.md +0 -337
- package/docusaurus/docs/error-handling/retry-strategies.md +0 -368
- package/docusaurus/docs/examples.md +0 -488
- package/docusaurus/docs/getting-started.md +0 -256
- package/docusaurus/docs/http/circuit-breaker.md +0 -401
- package/docusaurus/docs/http/incremental-sync.md +0 -394
- package/docusaurus/docs/http/pagination.md +0 -361
- package/docusaurus/docs/http/rate-limiting.md +0 -383
- package/docusaurus/docs/http/requests.md +0 -328
- package/docusaurus/docs/http/retry.md +0 -402
- package/docusaurus/docs/intro.md +0 -90
- package/docusaurus/docs/openapi/loading-specs.md +0 -305
- package/docusaurus/docs/openapi/operation-calls.md +0 -314
- package/docusaurus/docs/openapi/overview.md +0 -212
- package/docusaurus/docs/openapi/response-validation.md +0 -344
- package/docusaurus/docs/scheduling/cron.md +0 -305
- package/docusaurus/docs/scheduling/daemon-mode.md +0 -317
- package/docusaurus/docs/scheduling/intervals.md +0 -289
- package/docusaurus/docs/scheduling/overview.md +0 -231
- package/docusaurus/docs/stores/custom-adapters.md +0 -376
- package/docusaurus/docs/stores/file.md +0 -236
- package/docusaurus/docs/stores/memory.md +0 -193
- package/docusaurus/docs/stores/overview.md +0 -274
- package/docusaurus/docs/stores/postgrest.md +0 -316
- package/docusaurus/docusaurus.config.ts +0 -148
- package/docusaurus/package-lock.json +0 -18029
- package/docusaurus/package.json +0 -47
- package/docusaurus/sidebars.ts +0 -155
- package/docusaurus/src/components/HomepageFeatures/index.tsx +0 -105
- package/docusaurus/src/components/HomepageFeatures/styles.module.css +0 -12
- package/docusaurus/src/css/custom.css +0 -169
- package/docusaurus/src/pages/index.module.css +0 -48
- package/docusaurus/src/pages/index.tsx +0 -110
- package/docusaurus/src/pages/markdown-page.md +0 -7
- package/docusaurus/static/.nojekyll +0 -0
- package/docusaurus/static/img/docusaurus-social-card.jpg +0 -0
- package/docusaurus/static/img/docusaurus.png +0 -0
- package/docusaurus/static/img/favicon.ico +0 -0
- package/docusaurus/static/img/logo.svg +0 -10
- package/docusaurus/static/img/undraw_docusaurus_mountain.svg +0 -171
- package/docusaurus/static/img/undraw_docusaurus_react.svg +0 -170
- package/docusaurus/static/img/undraw_docusaurus_tree.svg +0 -40
- package/docusaurus/tsconfig.json +0 -8
- package/examples/README.md +0 -112
- package/examples/error-handling/README.md +0 -150
- package/examples/error-handling/payment-processor.vague +0 -287
- package/examples/github-sync/README.md +0 -74
- package/examples/github-sync/fetch-issues.vague +0 -47
- package/examples/github-sync/fetch-prs.vague +0 -40
- package/examples/github-sync/mission.vague +0 -101
- package/examples/github-sync/normalize.vague +0 -70
- package/examples/jsonplaceholder/README.md +0 -28
- package/examples/jsonplaceholder/posts.vague +0 -48
- package/examples/petstore/README.md +0 -35
- package/examples/petstore/openapi.yaml +0 -97
- package/examples/petstore/sync.vague +0 -52
- package/examples/temporal-comparison/README.md +0 -297
- package/examples/temporal-comparison/reconciliation.vague +0 -355
- package/examples/temporal-comparison/temporal/activities/index.ts +0 -8
- package/examples/temporal-comparison/temporal/activities/shipstation.ts +0 -225
- package/examples/temporal-comparison/temporal/activities/shopify.ts +0 -257
- package/examples/temporal-comparison/temporal/activities/storage.ts +0 -198
- package/examples/temporal-comparison/temporal/activities/stripe.ts +0 -169
- package/examples/temporal-comparison/temporal/activities/validation.ts +0 -205
- package/examples/temporal-comparison/temporal/client/schedule.ts +0 -218
- package/examples/temporal-comparison/temporal/config/retry.ts +0 -63
- package/examples/temporal-comparison/temporal/types/index.ts +0 -129
- package/examples/temporal-comparison/temporal/workers/main.ts +0 -130
- package/examples/temporal-comparison/temporal/workflows/orderReconciliation.ts +0 -262
- package/examples/xero/README.md +0 -88
- package/examples/xero/invoices.vague +0 -189
- package/src/api-integration.test.ts +0 -954
- package/src/ast/index.ts +0 -1
- package/src/ast/nodes.ts +0 -310
- package/src/auth/auth.test.ts +0 -326
- package/src/auth/circuit-breaker.test.ts +0 -390
- package/src/auth/circuit-breaker.ts +0 -379
- package/src/auth/credentials.test.ts +0 -273
- package/src/auth/credentials.ts +0 -246
- package/src/auth/index.ts +0 -40
- package/src/auth/oauth2-provider.ts +0 -177
- package/src/auth/rate-limiter.ts +0 -459
- package/src/auth/token-store.ts +0 -177
- package/src/auth/types.ts +0 -159
- package/src/benchmark/e2e.bench.ts +0 -288
- package/src/benchmark/evaluator.bench.ts +0 -331
- package/src/benchmark/fixtures.ts +0 -295
- package/src/benchmark/index.ts +0 -108
- package/src/benchmark/lexer.bench.ts +0 -69
- package/src/benchmark/parser.bench.ts +0 -103
- package/src/benchmark/resilience.bench.ts +0 -193
- package/src/benchmark/store.bench.ts +0 -147
- package/src/benchmark/utils.ts +0 -230
- package/src/cli.ts +0 -313
- package/src/errors/errors.test.ts +0 -234
- package/src/errors/index.ts +0 -223
- package/src/execution/execution.test.ts +0 -307
- package/src/execution/index.ts +0 -21
- package/src/execution/state.ts +0 -207
- package/src/execution/store.ts +0 -188
- package/src/index.ts +0 -169
- package/src/integration.test.ts +0 -192
- package/src/interpreter/context.ts +0 -57
- package/src/interpreter/evaluator.test.ts +0 -796
- package/src/interpreter/evaluator.ts +0 -245
- package/src/interpreter/executor.ts +0 -946
- package/src/interpreter/fetch-handler.ts +0 -302
- package/src/interpreter/http.test.ts +0 -423
- package/src/interpreter/http.ts +0 -308
- package/src/interpreter/index.ts +0 -32
- package/src/interpreter/pagination.ts +0 -207
- package/src/interpreter/progress.test.ts +0 -276
- package/src/interpreter/schema-matcher.test.ts +0 -160
- package/src/interpreter/schema-matcher.ts +0 -168
- package/src/interpreter/signals.ts +0 -73
- package/src/interpreter/step-handlers/for-handler.ts +0 -65
- package/src/interpreter/step-handlers/index.ts +0 -17
- package/src/interpreter/step-handlers/map-handler.ts +0 -24
- package/src/interpreter/step-handlers/match-handler.ts +0 -101
- package/src/interpreter/step-handlers/store-handler.ts +0 -78
- package/src/interpreter/step-handlers/types.ts +0 -17
- package/src/interpreter/step-handlers/validate-handler.ts +0 -30
- package/src/interpreter/step-handlers/webhook-handler.ts +0 -142
- package/src/lexer/index.ts +0 -18
- package/src/lexer/lexer.test.ts +0 -316
- package/src/lexer/tokens.ts +0 -179
- package/src/loader/index.ts +0 -288
- package/src/loader/loader.test.ts +0 -360
- package/src/oas/index.ts +0 -4
- package/src/oas/loader.ts +0 -126
- package/src/oas/oas.test.ts +0 -254
- package/src/oas/validator.ts +0 -299
- package/src/parser/base.ts +0 -124
- package/src/parser/expressions.test.ts +0 -525
- package/src/parser/expressions.ts +0 -314
- package/src/parser/index.ts +0 -3
- package/src/parser/match.test.ts +0 -296
- package/src/parser/parser.test.ts +0 -739
- package/src/parser/parser.ts +0 -1469
- package/src/parser/schedule.test.ts +0 -287
- package/src/parser/webhook.test.ts +0 -248
- package/src/plugin.ts +0 -83
- package/src/scheduler/cron-parser.test.ts +0 -236
- package/src/scheduler/cron-parser.ts +0 -236
- package/src/scheduler/index.ts +0 -10
- package/src/scheduler/scheduler.ts +0 -443
- package/src/scheduler/types.ts +0 -71
- package/src/stores/factory.ts +0 -104
- package/src/stores/file.test.ts +0 -276
- package/src/stores/file.ts +0 -211
- package/src/stores/index.ts +0 -6
- package/src/stores/memory.test.ts +0 -238
- package/src/stores/memory.ts +0 -63
- package/src/stores/postgrest.test.ts +0 -488
- package/src/stores/postgrest.ts +0 -263
- package/src/stores/stores.test.ts +0 -197
- package/src/stores/types.ts +0 -58
- package/src/sync/index.ts +0 -16
- package/src/sync/state.ts +0 -126
- package/src/sync/store.ts +0 -139
- package/src/sync/sync.test.ts +0 -271
- package/src/utils/async.ts +0 -10
- package/src/utils/file.ts +0 -106
- package/src/utils/index.ts +0 -14
- package/src/utils/logger.ts +0 -53
- package/src/utils/path.ts +0 -47
- package/src/webhook/index.ts +0 -15
- package/src/webhook/server.test.ts +0 -253
- package/src/webhook/server.ts +0 -389
- package/src/webhook/store.ts +0 -239
- package/src/webhook/types.ts +0 -93
- package/tsconfig.json +0 -17
- package/vitest.config.ts +0 -39
package/dist/integration.test.js
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { parse, execute } from './index.js';
|
|
3
|
-
import { MemoryStore } from './stores/index.js';
|
|
4
|
-
describe('Reqon Integration', () => {
|
|
5
|
-
it('parses and executes a simple mission with dry run', async () => {
|
|
6
|
-
const source = `
|
|
7
|
-
mission TestMission {
|
|
8
|
-
source API {
|
|
9
|
-
auth: bearer,
|
|
10
|
-
base: "https://api.example.com"
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
store items: memory("items")
|
|
14
|
-
|
|
15
|
-
action FetchItems {
|
|
16
|
-
fetch GET "/items"
|
|
17
|
-
|
|
18
|
-
store response -> items {
|
|
19
|
-
key: .id
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
run FetchItems
|
|
24
|
-
}
|
|
25
|
-
`;
|
|
26
|
-
const program = parse(source);
|
|
27
|
-
expect(program.type).toBe('ReqonProgram');
|
|
28
|
-
const result = await execute(source, { dryRun: true, verbose: false });
|
|
29
|
-
expect(result.success).toBe(true);
|
|
30
|
-
expect(result.actionsRun).toContain('FetchItems');
|
|
31
|
-
});
|
|
32
|
-
it('executes a mission with mock data flow', async () => {
|
|
33
|
-
const source = `
|
|
34
|
-
mission MockDataFlow {
|
|
35
|
-
source API {
|
|
36
|
-
auth: bearer,
|
|
37
|
-
base: "https://api.example.com"
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
store raw: memory("raw")
|
|
41
|
-
store processed: memory("processed")
|
|
42
|
-
|
|
43
|
-
action Process {
|
|
44
|
-
for item in raw {
|
|
45
|
-
map item -> Processed {
|
|
46
|
-
id: .id,
|
|
47
|
-
name: .title,
|
|
48
|
-
value: .amount
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
store response -> processed {
|
|
52
|
-
key: .id
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
run Process
|
|
58
|
-
}
|
|
59
|
-
`;
|
|
60
|
-
// Pre-populate the raw store
|
|
61
|
-
const rawStore = new MemoryStore('raw');
|
|
62
|
-
await rawStore.set('1', { id: '1', title: 'Item 1', amount: 100 });
|
|
63
|
-
await rawStore.set('2', { id: '2', title: 'Item 2', amount: 200 });
|
|
64
|
-
const result = await execute(source, {
|
|
65
|
-
dryRun: false,
|
|
66
|
-
verbose: false,
|
|
67
|
-
stores: { raw: rawStore },
|
|
68
|
-
});
|
|
69
|
-
expect(result.success).toBe(true);
|
|
70
|
-
expect(result.actionsRun).toContain('Process');
|
|
71
|
-
// Check processed store
|
|
72
|
-
const processedStore = result.stores.get('processed');
|
|
73
|
-
expect(processedStore).toBeDefined();
|
|
74
|
-
const items = await processedStore.list();
|
|
75
|
-
expect(items).toHaveLength(2);
|
|
76
|
-
expect(items[0]).toMatchObject({ id: '1', name: 'Item 1', value: 100 });
|
|
77
|
-
});
|
|
78
|
-
it('parses the Xero example file', async () => {
|
|
79
|
-
const fs = await import('node:fs/promises');
|
|
80
|
-
const source = await fs.readFile('./examples/xero/invoices.reqon', 'utf-8');
|
|
81
|
-
const program = parse(source);
|
|
82
|
-
expect(program.type).toBe('ReqonProgram');
|
|
83
|
-
expect(program.statements).toHaveLength(1);
|
|
84
|
-
const mission = program.statements[0];
|
|
85
|
-
if (mission.type === 'MissionDefinition') {
|
|
86
|
-
expect(mission.name).toBe('SyncXeroInvoices');
|
|
87
|
-
expect(mission.sources).toHaveLength(1);
|
|
88
|
-
expect(mission.stores).toHaveLength(2);
|
|
89
|
-
expect(mission.actions).toHaveLength(3);
|
|
90
|
-
expect(mission.pipeline.stages).toHaveLength(3);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
it('handles validation failures gracefully', async () => {
|
|
94
|
-
const source = `
|
|
95
|
-
mission ValidationTest {
|
|
96
|
-
source API {
|
|
97
|
-
auth: bearer,
|
|
98
|
-
base: "https://api.example.com"
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
store items: memory("items")
|
|
102
|
-
|
|
103
|
-
action Validate {
|
|
104
|
-
for item in items {
|
|
105
|
-
validate item {
|
|
106
|
-
assume .value > 0
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
run Validate
|
|
112
|
-
}
|
|
113
|
-
`;
|
|
114
|
-
const itemsStore = new MemoryStore('items');
|
|
115
|
-
await itemsStore.set('1', { id: '1', value: -5 }); // Invalid: negative value
|
|
116
|
-
const result = await execute(source, {
|
|
117
|
-
stores: { items: itemsStore },
|
|
118
|
-
});
|
|
119
|
-
// Validation should fail
|
|
120
|
-
expect(result.success).toBe(false);
|
|
121
|
-
expect(result.errors.length).toBeGreaterThan(0);
|
|
122
|
-
});
|
|
123
|
-
it('processes match expressions in map steps', async () => {
|
|
124
|
-
const source = `
|
|
125
|
-
mission MatchTest {
|
|
126
|
-
source API {
|
|
127
|
-
auth: bearer,
|
|
128
|
-
base: "https://api.example.com"
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
store input: memory("input")
|
|
132
|
-
store output: memory("output")
|
|
133
|
-
|
|
134
|
-
action Transform {
|
|
135
|
-
for item in input {
|
|
136
|
-
map item -> Output {
|
|
137
|
-
id: .id,
|
|
138
|
-
status: match .state {
|
|
139
|
-
"A" => "active",
|
|
140
|
-
"I" => "inactive",
|
|
141
|
-
_ => "unknown"
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
store response -> output {
|
|
146
|
-
key: .id
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
run Transform
|
|
152
|
-
}
|
|
153
|
-
`;
|
|
154
|
-
const inputStore = new MemoryStore('input');
|
|
155
|
-
await inputStore.set('1', { id: '1', state: 'A' });
|
|
156
|
-
await inputStore.set('2', { id: '2', state: 'I' });
|
|
157
|
-
await inputStore.set('3', { id: '3', state: 'X' });
|
|
158
|
-
const result = await execute(source, {
|
|
159
|
-
stores: { input: inputStore },
|
|
160
|
-
});
|
|
161
|
-
expect(result.success).toBe(true);
|
|
162
|
-
const outputStore = result.stores.get('output');
|
|
163
|
-
const items = await outputStore.list();
|
|
164
|
-
expect(items).toContainEqual(expect.objectContaining({ id: '1', status: 'active' }));
|
|
165
|
-
expect(items).toContainEqual(expect.objectContaining({ id: '2', status: 'inactive' }));
|
|
166
|
-
expect(items).toContainEqual(expect.objectContaining({ id: '3', status: 'unknown' }));
|
|
167
|
-
});
|
|
168
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,512 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { evaluate, evaluateToString, interpolatePath } from './evaluator.js';
|
|
3
|
-
import { createContext, childContext, setVariable } from './context.js';
|
|
4
|
-
describe('evaluate', () => {
|
|
5
|
-
describe('literals', () => {
|
|
6
|
-
it('evaluates number literal', () => {
|
|
7
|
-
const ctx = createContext();
|
|
8
|
-
const expr = { type: 'Literal', value: 42, dataType: 'number' };
|
|
9
|
-
expect(evaluate(expr, ctx)).toBe(42);
|
|
10
|
-
});
|
|
11
|
-
it('evaluates string literal', () => {
|
|
12
|
-
const ctx = createContext();
|
|
13
|
-
const expr = { type: 'Literal', value: 'hello', dataType: 'string' };
|
|
14
|
-
expect(evaluate(expr, ctx)).toBe('hello');
|
|
15
|
-
});
|
|
16
|
-
it('evaluates boolean literal', () => {
|
|
17
|
-
const ctx = createContext();
|
|
18
|
-
const trueExpr = { type: 'Literal', value: true, dataType: 'boolean' };
|
|
19
|
-
const falseExpr = { type: 'Literal', value: false, dataType: 'boolean' };
|
|
20
|
-
expect(evaluate(trueExpr, ctx)).toBe(true);
|
|
21
|
-
expect(evaluate(falseExpr, ctx)).toBe(false);
|
|
22
|
-
});
|
|
23
|
-
it('evaluates null literal', () => {
|
|
24
|
-
const ctx = createContext();
|
|
25
|
-
const expr = { type: 'Literal', value: null, dataType: 'null' };
|
|
26
|
-
expect(evaluate(expr, ctx)).toBe(null);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
describe('identifiers', () => {
|
|
30
|
-
it('resolves variable from context', () => {
|
|
31
|
-
const ctx = createContext();
|
|
32
|
-
setVariable(ctx, 'myVar', 'hello');
|
|
33
|
-
const expr = { type: 'Identifier', name: 'myVar' };
|
|
34
|
-
expect(evaluate(expr, ctx)).toBe('hello');
|
|
35
|
-
});
|
|
36
|
-
it('resolves response special identifier', () => {
|
|
37
|
-
const ctx = createContext();
|
|
38
|
-
ctx.response = { data: 'test' };
|
|
39
|
-
const expr = { type: 'Identifier', name: 'response' };
|
|
40
|
-
expect(evaluate(expr, ctx)).toEqual({ data: 'test' });
|
|
41
|
-
});
|
|
42
|
-
it('resolves field from current object', () => {
|
|
43
|
-
const ctx = createContext();
|
|
44
|
-
const current = { name: 'Alice', age: 30 };
|
|
45
|
-
const expr = { type: 'Identifier', name: 'name' };
|
|
46
|
-
expect(evaluate(expr, ctx, current)).toBe('Alice');
|
|
47
|
-
});
|
|
48
|
-
it('resolves field from response when no current object', () => {
|
|
49
|
-
const ctx = createContext();
|
|
50
|
-
ctx.response = { name: 'Response Name' };
|
|
51
|
-
const expr = { type: 'Identifier', name: 'name' };
|
|
52
|
-
expect(evaluate(expr, ctx)).toBe('Response Name');
|
|
53
|
-
});
|
|
54
|
-
it('returns undefined for non-existent variable', () => {
|
|
55
|
-
const ctx = createContext();
|
|
56
|
-
const expr = { type: 'Identifier', name: 'nonExistent' };
|
|
57
|
-
expect(evaluate(expr, ctx)).toBeUndefined();
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
describe('qualified names (property access)', () => {
|
|
61
|
-
it('resolves nested properties from current', () => {
|
|
62
|
-
const ctx = createContext();
|
|
63
|
-
const current = { user: { profile: { name: 'Alice' } } };
|
|
64
|
-
const expr = {
|
|
65
|
-
type: 'QualifiedName',
|
|
66
|
-
parts: ['user', 'profile', 'name'],
|
|
67
|
-
};
|
|
68
|
-
expect(evaluate(expr, ctx, current)).toBe('Alice');
|
|
69
|
-
});
|
|
70
|
-
it('resolves from response when no current', () => {
|
|
71
|
-
const ctx = createContext();
|
|
72
|
-
ctx.response = { data: { items: [1, 2, 3] } };
|
|
73
|
-
const expr = {
|
|
74
|
-
type: 'QualifiedName',
|
|
75
|
-
parts: ['data', 'items'],
|
|
76
|
-
};
|
|
77
|
-
expect(evaluate(expr, ctx)).toEqual([1, 2, 3]);
|
|
78
|
-
});
|
|
79
|
-
it('resolves from variables', () => {
|
|
80
|
-
const ctx = createContext();
|
|
81
|
-
setVariable(ctx, 'config', { settings: { theme: 'dark' } });
|
|
82
|
-
const expr = {
|
|
83
|
-
type: 'QualifiedName',
|
|
84
|
-
parts: ['config', 'settings', 'theme'],
|
|
85
|
-
};
|
|
86
|
-
expect(evaluate(expr, ctx)).toBe('dark');
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
describe('binary expressions', () => {
|
|
90
|
-
it('evaluates addition', () => {
|
|
91
|
-
const ctx = createContext();
|
|
92
|
-
const expr = {
|
|
93
|
-
type: 'BinaryExpression',
|
|
94
|
-
operator: '+',
|
|
95
|
-
left: { type: 'Literal', value: 5, dataType: 'number' },
|
|
96
|
-
right: { type: 'Literal', value: 3, dataType: 'number' },
|
|
97
|
-
};
|
|
98
|
-
expect(evaluate(expr, ctx)).toBe(8);
|
|
99
|
-
});
|
|
100
|
-
it('evaluates subtraction', () => {
|
|
101
|
-
const ctx = createContext();
|
|
102
|
-
const expr = {
|
|
103
|
-
type: 'BinaryExpression',
|
|
104
|
-
operator: '-',
|
|
105
|
-
left: { type: 'Literal', value: 10, dataType: 'number' },
|
|
106
|
-
right: { type: 'Literal', value: 4, dataType: 'number' },
|
|
107
|
-
};
|
|
108
|
-
expect(evaluate(expr, ctx)).toBe(6);
|
|
109
|
-
});
|
|
110
|
-
it('evaluates multiplication', () => {
|
|
111
|
-
const ctx = createContext();
|
|
112
|
-
const expr = {
|
|
113
|
-
type: 'BinaryExpression',
|
|
114
|
-
operator: '*',
|
|
115
|
-
left: { type: 'Literal', value: 6, dataType: 'number' },
|
|
116
|
-
right: { type: 'Literal', value: 7, dataType: 'number' },
|
|
117
|
-
};
|
|
118
|
-
expect(evaluate(expr, ctx)).toBe(42);
|
|
119
|
-
});
|
|
120
|
-
it('evaluates division', () => {
|
|
121
|
-
const ctx = createContext();
|
|
122
|
-
const expr = {
|
|
123
|
-
type: 'BinaryExpression',
|
|
124
|
-
operator: '/',
|
|
125
|
-
left: { type: 'Literal', value: 20, dataType: 'number' },
|
|
126
|
-
right: { type: 'Literal', value: 4, dataType: 'number' },
|
|
127
|
-
};
|
|
128
|
-
expect(evaluate(expr, ctx)).toBe(5);
|
|
129
|
-
});
|
|
130
|
-
it('evaluates equality', () => {
|
|
131
|
-
const ctx = createContext();
|
|
132
|
-
const expr = {
|
|
133
|
-
type: 'BinaryExpression',
|
|
134
|
-
operator: '==',
|
|
135
|
-
left: { type: 'Literal', value: 5, dataType: 'number' },
|
|
136
|
-
right: { type: 'Literal', value: 5, dataType: 'number' },
|
|
137
|
-
};
|
|
138
|
-
expect(evaluate(expr, ctx)).toBe(true);
|
|
139
|
-
});
|
|
140
|
-
it('evaluates inequality', () => {
|
|
141
|
-
const ctx = createContext();
|
|
142
|
-
const expr = {
|
|
143
|
-
type: 'BinaryExpression',
|
|
144
|
-
operator: '!=',
|
|
145
|
-
left: { type: 'Literal', value: 5, dataType: 'number' },
|
|
146
|
-
right: { type: 'Literal', value: 3, dataType: 'number' },
|
|
147
|
-
};
|
|
148
|
-
expect(evaluate(expr, ctx)).toBe(true);
|
|
149
|
-
});
|
|
150
|
-
it('evaluates less than', () => {
|
|
151
|
-
const ctx = createContext();
|
|
152
|
-
const expr = {
|
|
153
|
-
type: 'BinaryExpression',
|
|
154
|
-
operator: '<',
|
|
155
|
-
left: { type: 'Literal', value: 3, dataType: 'number' },
|
|
156
|
-
right: { type: 'Literal', value: 5, dataType: 'number' },
|
|
157
|
-
};
|
|
158
|
-
expect(evaluate(expr, ctx)).toBe(true);
|
|
159
|
-
});
|
|
160
|
-
it('evaluates greater than or equal', () => {
|
|
161
|
-
const ctx = createContext();
|
|
162
|
-
const expr = {
|
|
163
|
-
type: 'BinaryExpression',
|
|
164
|
-
operator: '>=',
|
|
165
|
-
left: { type: 'Literal', value: 5, dataType: 'number' },
|
|
166
|
-
right: { type: 'Literal', value: 5, dataType: 'number' },
|
|
167
|
-
};
|
|
168
|
-
expect(evaluate(expr, ctx)).toBe(true);
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
describe('logical expressions', () => {
|
|
172
|
-
it('evaluates and (true && true)', () => {
|
|
173
|
-
const ctx = createContext();
|
|
174
|
-
const expr = {
|
|
175
|
-
type: 'LogicalExpression',
|
|
176
|
-
operator: 'and',
|
|
177
|
-
left: { type: 'Literal', value: true, dataType: 'boolean' },
|
|
178
|
-
right: { type: 'Literal', value: true, dataType: 'boolean' },
|
|
179
|
-
};
|
|
180
|
-
expect(evaluate(expr, ctx)).toBe(true);
|
|
181
|
-
});
|
|
182
|
-
it('evaluates and (true && false)', () => {
|
|
183
|
-
const ctx = createContext();
|
|
184
|
-
const expr = {
|
|
185
|
-
type: 'LogicalExpression',
|
|
186
|
-
operator: 'and',
|
|
187
|
-
left: { type: 'Literal', value: true, dataType: 'boolean' },
|
|
188
|
-
right: { type: 'Literal', value: false, dataType: 'boolean' },
|
|
189
|
-
};
|
|
190
|
-
expect(evaluate(expr, ctx)).toBe(false);
|
|
191
|
-
});
|
|
192
|
-
it('short-circuits and on falsy left', () => {
|
|
193
|
-
const ctx = createContext();
|
|
194
|
-
// If short-circuiting works, the right side should not be evaluated
|
|
195
|
-
const expr = {
|
|
196
|
-
type: 'LogicalExpression',
|
|
197
|
-
operator: 'and',
|
|
198
|
-
left: { type: 'Literal', value: false, dataType: 'boolean' },
|
|
199
|
-
right: { type: 'Literal', value: true, dataType: 'boolean' },
|
|
200
|
-
};
|
|
201
|
-
expect(evaluate(expr, ctx)).toBe(false);
|
|
202
|
-
});
|
|
203
|
-
it('evaluates or (false || true)', () => {
|
|
204
|
-
const ctx = createContext();
|
|
205
|
-
const expr = {
|
|
206
|
-
type: 'LogicalExpression',
|
|
207
|
-
operator: 'or',
|
|
208
|
-
left: { type: 'Literal', value: false, dataType: 'boolean' },
|
|
209
|
-
right: { type: 'Literal', value: true, dataType: 'boolean' },
|
|
210
|
-
};
|
|
211
|
-
expect(evaluate(expr, ctx)).toBe(true);
|
|
212
|
-
});
|
|
213
|
-
it('short-circuits or on truthy left', () => {
|
|
214
|
-
const ctx = createContext();
|
|
215
|
-
const expr = {
|
|
216
|
-
type: 'LogicalExpression',
|
|
217
|
-
operator: 'or',
|
|
218
|
-
left: { type: 'Literal', value: true, dataType: 'boolean' },
|
|
219
|
-
right: { type: 'Literal', value: false, dataType: 'boolean' },
|
|
220
|
-
};
|
|
221
|
-
expect(evaluate(expr, ctx)).toBe(true);
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
describe('not expression', () => {
|
|
225
|
-
it('negates true to false', () => {
|
|
226
|
-
const ctx = createContext();
|
|
227
|
-
const expr = {
|
|
228
|
-
type: 'NotExpression',
|
|
229
|
-
operand: { type: 'Literal', value: true, dataType: 'boolean' },
|
|
230
|
-
};
|
|
231
|
-
expect(evaluate(expr, ctx)).toBe(false);
|
|
232
|
-
});
|
|
233
|
-
it('negates false to true', () => {
|
|
234
|
-
const ctx = createContext();
|
|
235
|
-
const expr = {
|
|
236
|
-
type: 'NotExpression',
|
|
237
|
-
operand: { type: 'Literal', value: false, dataType: 'boolean' },
|
|
238
|
-
};
|
|
239
|
-
expect(evaluate(expr, ctx)).toBe(true);
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
describe('unary expressions', () => {
|
|
243
|
-
it('negates a number', () => {
|
|
244
|
-
const ctx = createContext();
|
|
245
|
-
const expr = {
|
|
246
|
-
type: 'UnaryExpression',
|
|
247
|
-
operator: '-',
|
|
248
|
-
operand: { type: 'Literal', value: 5, dataType: 'number' },
|
|
249
|
-
};
|
|
250
|
-
expect(evaluate(expr, ctx)).toBe(-5);
|
|
251
|
-
});
|
|
252
|
-
it('positive unary has no effect', () => {
|
|
253
|
-
const ctx = createContext();
|
|
254
|
-
const expr = {
|
|
255
|
-
type: 'UnaryExpression',
|
|
256
|
-
operator: '+',
|
|
257
|
-
operand: { type: 'Literal', value: 5, dataType: 'number' },
|
|
258
|
-
};
|
|
259
|
-
expect(evaluate(expr, ctx)).toBe(5);
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
describe('ternary expressions', () => {
|
|
263
|
-
it('returns consequent when condition is true', () => {
|
|
264
|
-
const ctx = createContext();
|
|
265
|
-
const expr = {
|
|
266
|
-
type: 'TernaryExpression',
|
|
267
|
-
condition: { type: 'Literal', value: true, dataType: 'boolean' },
|
|
268
|
-
consequent: { type: 'Literal', value: 'yes', dataType: 'string' },
|
|
269
|
-
alternate: { type: 'Literal', value: 'no', dataType: 'string' },
|
|
270
|
-
};
|
|
271
|
-
expect(evaluate(expr, ctx)).toBe('yes');
|
|
272
|
-
});
|
|
273
|
-
it('returns alternate when condition is false', () => {
|
|
274
|
-
const ctx = createContext();
|
|
275
|
-
const expr = {
|
|
276
|
-
type: 'TernaryExpression',
|
|
277
|
-
condition: { type: 'Literal', value: false, dataType: 'boolean' },
|
|
278
|
-
consequent: { type: 'Literal', value: 'yes', dataType: 'string' },
|
|
279
|
-
alternate: { type: 'Literal', value: 'no', dataType: 'string' },
|
|
280
|
-
};
|
|
281
|
-
expect(evaluate(expr, ctx)).toBe('no');
|
|
282
|
-
});
|
|
283
|
-
});
|
|
284
|
-
describe('match expressions', () => {
|
|
285
|
-
it('matches value and returns result', () => {
|
|
286
|
-
const ctx = createContext();
|
|
287
|
-
const expr = {
|
|
288
|
-
type: 'MatchExpression',
|
|
289
|
-
value: { type: 'Literal', value: 'A', dataType: 'string' },
|
|
290
|
-
arms: [
|
|
291
|
-
{
|
|
292
|
-
pattern: { type: 'Literal', value: 'A', dataType: 'string' },
|
|
293
|
-
result: { type: 'Literal', value: 'active', dataType: 'string' },
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
pattern: { type: 'Literal', value: 'I', dataType: 'string' },
|
|
297
|
-
result: { type: 'Literal', value: 'inactive', dataType: 'string' },
|
|
298
|
-
},
|
|
299
|
-
],
|
|
300
|
-
};
|
|
301
|
-
expect(evaluate(expr, ctx)).toBe('active');
|
|
302
|
-
});
|
|
303
|
-
it('matches wildcard pattern', () => {
|
|
304
|
-
const ctx = createContext();
|
|
305
|
-
const expr = {
|
|
306
|
-
type: 'MatchExpression',
|
|
307
|
-
value: { type: 'Literal', value: 'X', dataType: 'string' },
|
|
308
|
-
arms: [
|
|
309
|
-
{
|
|
310
|
-
pattern: { type: 'Literal', value: 'A', dataType: 'string' },
|
|
311
|
-
result: { type: 'Literal', value: 'active', dataType: 'string' },
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
pattern: { type: 'Identifier', name: '_' },
|
|
315
|
-
result: { type: 'Literal', value: 'unknown', dataType: 'string' },
|
|
316
|
-
},
|
|
317
|
-
],
|
|
318
|
-
};
|
|
319
|
-
expect(evaluate(expr, ctx)).toBe('unknown');
|
|
320
|
-
});
|
|
321
|
-
it('returns undefined when no match', () => {
|
|
322
|
-
const ctx = createContext();
|
|
323
|
-
const expr = {
|
|
324
|
-
type: 'MatchExpression',
|
|
325
|
-
value: { type: 'Literal', value: 'X', dataType: 'string' },
|
|
326
|
-
arms: [
|
|
327
|
-
{
|
|
328
|
-
pattern: { type: 'Literal', value: 'A', dataType: 'string' },
|
|
329
|
-
result: { type: 'Literal', value: 'active', dataType: 'string' },
|
|
330
|
-
},
|
|
331
|
-
],
|
|
332
|
-
};
|
|
333
|
-
expect(evaluate(expr, ctx)).toBeUndefined();
|
|
334
|
-
});
|
|
335
|
-
});
|
|
336
|
-
describe('call expressions (built-in functions)', () => {
|
|
337
|
-
it('evaluates length function', () => {
|
|
338
|
-
const ctx = createContext();
|
|
339
|
-
const expr = {
|
|
340
|
-
type: 'CallExpression',
|
|
341
|
-
callee: 'length',
|
|
342
|
-
arguments: [{
|
|
343
|
-
type: 'OrderedSequenceType',
|
|
344
|
-
elements: [
|
|
345
|
-
{ type: 'Literal', value: 1, dataType: 'number' },
|
|
346
|
-
{ type: 'Literal', value: 2, dataType: 'number' },
|
|
347
|
-
{ type: 'Literal', value: 3, dataType: 'number' },
|
|
348
|
-
{ type: 'Literal', value: 4, dataType: 'number' },
|
|
349
|
-
{ type: 'Literal', value: 5, dataType: 'number' },
|
|
350
|
-
],
|
|
351
|
-
}],
|
|
352
|
-
};
|
|
353
|
-
expect(evaluate(expr, ctx)).toBe(5);
|
|
354
|
-
});
|
|
355
|
-
it('evaluates sum function', () => {
|
|
356
|
-
const ctx = createContext();
|
|
357
|
-
const expr = {
|
|
358
|
-
type: 'CallExpression',
|
|
359
|
-
callee: 'sum',
|
|
360
|
-
arguments: [{
|
|
361
|
-
type: 'OrderedSequenceType',
|
|
362
|
-
elements: [
|
|
363
|
-
{ type: 'Literal', value: 10, dataType: 'number' },
|
|
364
|
-
{ type: 'Literal', value: 20, dataType: 'number' },
|
|
365
|
-
{ type: 'Literal', value: 30, dataType: 'number' },
|
|
366
|
-
],
|
|
367
|
-
}],
|
|
368
|
-
};
|
|
369
|
-
expect(evaluate(expr, ctx)).toBe(60);
|
|
370
|
-
});
|
|
371
|
-
it('evaluates first function', () => {
|
|
372
|
-
const ctx = createContext();
|
|
373
|
-
const expr = {
|
|
374
|
-
type: 'CallExpression',
|
|
375
|
-
callee: 'first',
|
|
376
|
-
arguments: [{
|
|
377
|
-
type: 'OrderedSequenceType',
|
|
378
|
-
elements: [
|
|
379
|
-
{ type: 'Literal', value: 'a', dataType: 'string' },
|
|
380
|
-
{ type: 'Literal', value: 'b', dataType: 'string' },
|
|
381
|
-
{ type: 'Literal', value: 'c', dataType: 'string' },
|
|
382
|
-
],
|
|
383
|
-
}],
|
|
384
|
-
};
|
|
385
|
-
expect(evaluate(expr, ctx)).toBe('a');
|
|
386
|
-
});
|
|
387
|
-
it('evaluates last function', () => {
|
|
388
|
-
const ctx = createContext();
|
|
389
|
-
const expr = {
|
|
390
|
-
type: 'CallExpression',
|
|
391
|
-
callee: 'last',
|
|
392
|
-
arguments: [{
|
|
393
|
-
type: 'OrderedSequenceType',
|
|
394
|
-
elements: [
|
|
395
|
-
{ type: 'Literal', value: 'a', dataType: 'string' },
|
|
396
|
-
{ type: 'Literal', value: 'b', dataType: 'string' },
|
|
397
|
-
{ type: 'Literal', value: 'c', dataType: 'string' },
|
|
398
|
-
],
|
|
399
|
-
}],
|
|
400
|
-
};
|
|
401
|
-
expect(evaluate(expr, ctx)).toBe('c');
|
|
402
|
-
});
|
|
403
|
-
it('evaluates round function', () => {
|
|
404
|
-
const ctx = createContext();
|
|
405
|
-
const expr = {
|
|
406
|
-
type: 'CallExpression',
|
|
407
|
-
callee: 'round',
|
|
408
|
-
arguments: [{ type: 'Literal', value: 3.7, dataType: 'number' }],
|
|
409
|
-
};
|
|
410
|
-
expect(evaluate(expr, ctx)).toBe(4);
|
|
411
|
-
});
|
|
412
|
-
it('evaluates floor function', () => {
|
|
413
|
-
const ctx = createContext();
|
|
414
|
-
const expr = {
|
|
415
|
-
type: 'CallExpression',
|
|
416
|
-
callee: 'floor',
|
|
417
|
-
arguments: [{ type: 'Literal', value: 3.9, dataType: 'number' }],
|
|
418
|
-
};
|
|
419
|
-
expect(evaluate(expr, ctx)).toBe(3);
|
|
420
|
-
});
|
|
421
|
-
it('evaluates ceil function', () => {
|
|
422
|
-
const ctx = createContext();
|
|
423
|
-
const expr = {
|
|
424
|
-
type: 'CallExpression',
|
|
425
|
-
callee: 'ceil',
|
|
426
|
-
arguments: [{ type: 'Literal', value: 3.1, dataType: 'number' }],
|
|
427
|
-
};
|
|
428
|
-
expect(evaluate(expr, ctx)).toBe(4);
|
|
429
|
-
});
|
|
430
|
-
it('throws on unknown function', () => {
|
|
431
|
-
const ctx = createContext();
|
|
432
|
-
const expr = {
|
|
433
|
-
type: 'CallExpression',
|
|
434
|
-
callee: 'unknownFn',
|
|
435
|
-
arguments: [],
|
|
436
|
-
};
|
|
437
|
-
expect(() => evaluate(expr, ctx)).toThrow('Unknown function: unknownFn');
|
|
438
|
-
});
|
|
439
|
-
});
|
|
440
|
-
});
|
|
441
|
-
describe('evaluateToString', () => {
|
|
442
|
-
it('converts number to string', () => {
|
|
443
|
-
const ctx = createContext();
|
|
444
|
-
const expr = { type: 'Literal', value: 42, dataType: 'number' };
|
|
445
|
-
expect(evaluateToString(expr, ctx)).toBe('42');
|
|
446
|
-
});
|
|
447
|
-
it('converts null to empty string', () => {
|
|
448
|
-
const ctx = createContext();
|
|
449
|
-
const expr = { type: 'Literal', value: null, dataType: 'null' };
|
|
450
|
-
expect(evaluateToString(expr, ctx)).toBe('');
|
|
451
|
-
});
|
|
452
|
-
it('converts undefined to empty string', () => {
|
|
453
|
-
const ctx = createContext();
|
|
454
|
-
const expr = { type: 'Identifier', name: 'nonExistent' };
|
|
455
|
-
expect(evaluateToString(expr, ctx)).toBe('');
|
|
456
|
-
});
|
|
457
|
-
});
|
|
458
|
-
describe('interpolatePath', () => {
|
|
459
|
-
it('interpolates simple variables', () => {
|
|
460
|
-
const ctx = createContext();
|
|
461
|
-
const current = { id: '123' };
|
|
462
|
-
const result = interpolatePath('/users/{id}', ctx, current);
|
|
463
|
-
expect(result).toBe('/users/123');
|
|
464
|
-
});
|
|
465
|
-
it('interpolates nested properties', () => {
|
|
466
|
-
const ctx = createContext();
|
|
467
|
-
const current = { user: { profile: { id: 'abc' } } };
|
|
468
|
-
const result = interpolatePath('/profiles/{user.profile.id}', ctx, current);
|
|
469
|
-
expect(result).toBe('/profiles/abc');
|
|
470
|
-
});
|
|
471
|
-
it('interpolates from context variables', () => {
|
|
472
|
-
const ctx = createContext();
|
|
473
|
-
setVariable(ctx, 'userId', '456');
|
|
474
|
-
const result = interpolatePath('/users/{userId}', ctx);
|
|
475
|
-
expect(result).toBe('/users/456');
|
|
476
|
-
});
|
|
477
|
-
it('handles multiple interpolations', () => {
|
|
478
|
-
const ctx = createContext();
|
|
479
|
-
const current = { org: 'acme', project: 'widget' };
|
|
480
|
-
const result = interpolatePath('/orgs/{org}/projects/{project}', ctx, current);
|
|
481
|
-
expect(result).toBe('/orgs/acme/projects/widget');
|
|
482
|
-
});
|
|
483
|
-
it('handles missing values as empty string', () => {
|
|
484
|
-
const ctx = createContext();
|
|
485
|
-
const result = interpolatePath('/users/{nonExistent}', ctx, {});
|
|
486
|
-
expect(result).toBe('/users/');
|
|
487
|
-
});
|
|
488
|
-
});
|
|
489
|
-
describe('context variable resolution', () => {
|
|
490
|
-
it('resolves variables from parent context', () => {
|
|
491
|
-
const parent = createContext();
|
|
492
|
-
setVariable(parent, 'parentVar', 'from parent');
|
|
493
|
-
const child = childContext(parent);
|
|
494
|
-
const expr = { type: 'Identifier', name: 'parentVar' };
|
|
495
|
-
expect(evaluate(expr, child)).toBe('from parent');
|
|
496
|
-
});
|
|
497
|
-
it('child variables shadow parent variables', () => {
|
|
498
|
-
const parent = createContext();
|
|
499
|
-
setVariable(parent, 'sharedVar', 'parent value');
|
|
500
|
-
const child = childContext(parent);
|
|
501
|
-
setVariable(child, 'sharedVar', 'child value');
|
|
502
|
-
const expr = { type: 'Identifier', name: 'sharedVar' };
|
|
503
|
-
expect(evaluate(expr, child)).toBe('child value');
|
|
504
|
-
expect(evaluate(expr, parent)).toBe('parent value');
|
|
505
|
-
});
|
|
506
|
-
it('shares stores between parent and child', () => {
|
|
507
|
-
const parent = createContext();
|
|
508
|
-
const child = childContext(parent);
|
|
509
|
-
expect(child.stores).toBe(parent.stores);
|
|
510
|
-
expect(child.sources).toBe(parent.sources);
|
|
511
|
-
});
|
|
512
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|