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/parser/parser.js
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ---
|
|
3
|
+
* purpose: Top-level parser - combines all domain-specific parser modules
|
|
4
|
+
* inputs:
|
|
5
|
+
* - Token[] from lexer
|
|
6
|
+
* - source string for error messages
|
|
7
|
+
* outputs:
|
|
8
|
+
* - ReqonProgram AST
|
|
9
|
+
* related:
|
|
10
|
+
* - ./pipeline-parser.ts - parent class (pipeline stage parsing)
|
|
11
|
+
* - ./action-parser.ts - action/step parsing
|
|
12
|
+
* - ./fetch-parser.ts - HTTP fetch parsing
|
|
13
|
+
* - ../ast/nodes.ts - AST node types
|
|
14
|
+
* ---
|
|
15
|
+
*/
|
|
1
16
|
import { TokenType } from 'vague-lang';
|
|
2
17
|
import { ReqonTokenType } from '../lexer/tokens.js';
|
|
3
|
-
import {
|
|
4
|
-
export class ReqonParser extends
|
|
18
|
+
import { PipelineParser } from './pipeline-parser.js';
|
|
19
|
+
export class ReqonParser extends PipelineParser {
|
|
5
20
|
constructor(tokens, source, filePath) {
|
|
6
21
|
super(tokens, source, filePath);
|
|
7
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Parse a complete Reqon program
|
|
25
|
+
*/
|
|
8
26
|
parse() {
|
|
9
27
|
const statements = [];
|
|
10
28
|
while (!this.isAtEnd()) {
|
|
@@ -14,6 +32,9 @@ export class ReqonParser extends ReqonExpressionParser {
|
|
|
14
32
|
}
|
|
15
33
|
return { type: 'ReqonProgram', statements };
|
|
16
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Parse a top-level statement
|
|
37
|
+
*/
|
|
17
38
|
parseStatement() {
|
|
18
39
|
// Reqon-specific statements
|
|
19
40
|
if (this.check(ReqonTokenType.MISSION))
|
|
@@ -24,6 +45,8 @@ export class ReqonParser extends ReqonExpressionParser {
|
|
|
24
45
|
return this.parseStoreDefinition();
|
|
25
46
|
if (this.check(ReqonTokenType.ACTION))
|
|
26
47
|
return this.parseAction();
|
|
48
|
+
if (this.check(ReqonTokenType.TRANSFORM))
|
|
49
|
+
return this.parseTransform();
|
|
27
50
|
// Vague statements (schema, import, let, etc.)
|
|
28
51
|
if (this.check(TokenType.SCHEMA))
|
|
29
52
|
return this.parseSchema();
|
|
@@ -33,9 +56,9 @@ export class ReqonParser extends ReqonExpressionParser {
|
|
|
33
56
|
return this.parseLet();
|
|
34
57
|
throw this.error(`Unexpected token: ${this.peek().value}`);
|
|
35
58
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Parse a mission definition
|
|
61
|
+
*/
|
|
39
62
|
parseMission() {
|
|
40
63
|
this.consume(ReqonTokenType.MISSION, "Expected 'mission'");
|
|
41
64
|
const name = this.consume(TokenType.IDENTIFIER, 'Expected mission name').value;
|
|
@@ -43,9 +66,12 @@ export class ReqonParser extends ReqonExpressionParser {
|
|
|
43
66
|
const sources = [];
|
|
44
67
|
const stores = [];
|
|
45
68
|
const schemas = [];
|
|
69
|
+
const transforms = [];
|
|
46
70
|
const actions = [];
|
|
47
71
|
let pipeline;
|
|
48
72
|
let schedule;
|
|
73
|
+
let checkpoint;
|
|
74
|
+
let trace;
|
|
49
75
|
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
50
76
|
if (this.check(ReqonTokenType.SOURCE)) {
|
|
51
77
|
sources.push(this.parseSource());
|
|
@@ -56,6 +82,9 @@ export class ReqonParser extends ReqonExpressionParser {
|
|
|
56
82
|
else if (this.check(TokenType.SCHEMA)) {
|
|
57
83
|
schemas.push(this.parseSchema());
|
|
58
84
|
}
|
|
85
|
+
else if (this.check(ReqonTokenType.TRANSFORM)) {
|
|
86
|
+
transforms.push(this.parseTransform());
|
|
87
|
+
}
|
|
59
88
|
else if (this.check(ReqonTokenType.ACTION)) {
|
|
60
89
|
actions.push(this.parseAction());
|
|
61
90
|
}
|
|
@@ -65,6 +94,12 @@ export class ReqonParser extends ReqonExpressionParser {
|
|
|
65
94
|
else if (this.check(ReqonTokenType.SCHEDULE)) {
|
|
66
95
|
schedule = this.parseSchedule();
|
|
67
96
|
}
|
|
97
|
+
else if (this.check(ReqonTokenType.CHECKPOINT)) {
|
|
98
|
+
checkpoint = this.parseCheckpointConfig();
|
|
99
|
+
}
|
|
100
|
+
else if (this.check(ReqonTokenType.TRACE)) {
|
|
101
|
+
trace = this.parseTraceConfig();
|
|
102
|
+
}
|
|
68
103
|
else {
|
|
69
104
|
throw this.error(`Unexpected token in mission: ${this.peek().value}`);
|
|
70
105
|
}
|
|
@@ -78,40 +113,92 @@ export class ReqonParser extends ReqonExpressionParser {
|
|
|
78
113
|
const definedStores = new Set(stores.map((s) => s.name));
|
|
79
114
|
const definedActions = new Set(actions.map((a) => a.name));
|
|
80
115
|
const definedSources = new Set(sources.map((s) => s.name));
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
this.
|
|
116
|
+
const definedTransforms = new Set(transforms.map((t) => t.name));
|
|
117
|
+
// Validate all references within actions (stores, sources)
|
|
118
|
+
this.validateActionReferences(actions, definedStores, definedSources, definedActions, definedTransforms);
|
|
84
119
|
return {
|
|
85
120
|
type: 'MissionDefinition',
|
|
86
121
|
name,
|
|
87
122
|
schedule,
|
|
123
|
+
checkpoint,
|
|
124
|
+
trace,
|
|
88
125
|
sources,
|
|
89
126
|
stores,
|
|
90
127
|
schemas,
|
|
128
|
+
transforms,
|
|
91
129
|
actions,
|
|
92
130
|
pipeline,
|
|
93
131
|
};
|
|
94
132
|
}
|
|
95
133
|
/**
|
|
96
|
-
*
|
|
134
|
+
* Parse checkpoint configuration: checkpoint: afterStep | onFailure
|
|
135
|
+
*/
|
|
136
|
+
parseCheckpointConfig() {
|
|
137
|
+
this.consume(ReqonTokenType.CHECKPOINT, "Expected 'checkpoint'");
|
|
138
|
+
this.consume(TokenType.COLON, "Expected ':'");
|
|
139
|
+
let mode;
|
|
140
|
+
// Check for keyword token (afterStep, onFailure)
|
|
141
|
+
if (this.check(ReqonTokenType.AFTER_STEP)) {
|
|
142
|
+
this.advance();
|
|
143
|
+
mode = 'after-step';
|
|
144
|
+
}
|
|
145
|
+
else if (this.check(ReqonTokenType.ON_FAILURE)) {
|
|
146
|
+
this.advance();
|
|
147
|
+
mode = 'on-failure';
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
throw this.error("Expected 'afterStep' or 'onFailure'");
|
|
151
|
+
}
|
|
152
|
+
return { type: 'CheckpointConfig', mode };
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Parse trace configuration: trace: full | minimal
|
|
97
156
|
*/
|
|
98
|
-
|
|
157
|
+
parseTraceConfig() {
|
|
158
|
+
this.consume(ReqonTokenType.TRACE, "Expected 'trace'");
|
|
159
|
+
this.consume(TokenType.COLON, "Expected ':'");
|
|
160
|
+
let mode;
|
|
161
|
+
if (this.check(ReqonTokenType.FULL)) {
|
|
162
|
+
this.advance();
|
|
163
|
+
mode = 'full';
|
|
164
|
+
}
|
|
165
|
+
else if (this.peek().value === 'minimal') {
|
|
166
|
+
this.advance();
|
|
167
|
+
mode = 'minimal';
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
throw this.error("Expected 'full' or 'minimal'");
|
|
171
|
+
}
|
|
172
|
+
return { type: 'TraceConfig', mode };
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Validate that all store, source, action, and transform references in actions exist
|
|
176
|
+
*/
|
|
177
|
+
validateActionReferences(actions, definedStores, definedSources, definedActions, definedTransforms) {
|
|
99
178
|
for (const action of actions) {
|
|
100
|
-
this.validateStepsReferences(action.steps, definedStores, definedSources, definedActions, action.name);
|
|
179
|
+
this.validateStepsReferences(action.steps, definedStores, definedSources, definedActions, definedTransforms, action.name);
|
|
101
180
|
}
|
|
102
181
|
}
|
|
103
182
|
/**
|
|
104
|
-
* Recursively validate store, source, and
|
|
183
|
+
* Recursively validate store, source, action, and transform references in action steps
|
|
105
184
|
*/
|
|
106
|
-
validateStepsReferences(steps, definedStores, definedSources, definedActions, actionName) {
|
|
185
|
+
validateStepsReferences(steps, definedStores, definedSources, definedActions, definedTransforms, actionName) {
|
|
107
186
|
for (const step of steps) {
|
|
108
|
-
|
|
187
|
+
this.validateStepReferences(step, definedStores, definedSources, definedActions, definedTransforms, actionName);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Validate references in a single step
|
|
192
|
+
*/
|
|
193
|
+
validateStepReferences(step, definedStores, definedSources, definedActions, definedTransforms, actionName) {
|
|
194
|
+
switch (step.type) {
|
|
195
|
+
case 'StoreStep':
|
|
109
196
|
if (!definedStores.has(step.target)) {
|
|
110
197
|
throw this.error(`Store '${step.target}' is not defined. ` +
|
|
111
198
|
`Available stores: ${[...definedStores].join(', ') || 'none'}`);
|
|
112
199
|
}
|
|
113
|
-
|
|
114
|
-
|
|
200
|
+
break;
|
|
201
|
+
case 'FetchStep':
|
|
115
202
|
// Validate source reference if specified
|
|
116
203
|
if (step.source && !definedSources.has(step.source)) {
|
|
117
204
|
throw this.error(`Source '${step.source}' is not defined. ` +
|
|
@@ -122,16 +209,23 @@ export class ReqonParser extends ReqonExpressionParser {
|
|
|
122
209
|
throw this.error(`Source '${step.operationRef.source}' is not defined. ` +
|
|
123
210
|
`Available sources: ${[...definedSources].join(', ') || 'none'}`);
|
|
124
211
|
}
|
|
125
|
-
|
|
126
|
-
|
|
212
|
+
break;
|
|
213
|
+
case 'ApplyStep':
|
|
214
|
+
// Validate transform reference
|
|
215
|
+
if (!definedTransforms.has(step.transform)) {
|
|
216
|
+
throw this.error(`Transform '${step.transform}' is not defined. ` +
|
|
217
|
+
`Available transforms: ${[...definedTransforms].join(', ') || 'none'}`);
|
|
218
|
+
}
|
|
219
|
+
break;
|
|
220
|
+
case 'ForStep':
|
|
127
221
|
// Recursively validate nested steps
|
|
128
|
-
this.validateStepsReferences(step.steps, definedStores, definedSources, definedActions, actionName);
|
|
129
|
-
|
|
130
|
-
|
|
222
|
+
this.validateStepsReferences(step.steps, definedStores, definedSources, definedActions, definedTransforms, actionName);
|
|
223
|
+
break;
|
|
224
|
+
case 'MatchStep':
|
|
131
225
|
// Validate steps in match arms
|
|
132
226
|
for (const arm of step.arms) {
|
|
133
227
|
if (arm.steps) {
|
|
134
|
-
this.validateStepsReferences(arm.steps, definedStores, definedSources, definedActions, actionName);
|
|
228
|
+
this.validateStepsReferences(arm.steps, definedStores, definedSources, definedActions, definedTransforms, actionName);
|
|
135
229
|
}
|
|
136
230
|
// Validate jump target in flow directive
|
|
137
231
|
if (arm.flow?.type === 'jump' && !definedActions.has(arm.flow.action)) {
|
|
@@ -139,11 +233,12 @@ export class ReqonParser extends ReqonExpressionParser {
|
|
|
139
233
|
`Available actions: ${[...definedActions].join(', ') || 'none'}`);
|
|
140
234
|
}
|
|
141
235
|
}
|
|
142
|
-
|
|
236
|
+
break;
|
|
143
237
|
}
|
|
144
238
|
}
|
|
145
239
|
/**
|
|
146
240
|
* Validate that all action references in the pipeline exist
|
|
241
|
+
* Note: This is called by the loader after action merging
|
|
147
242
|
*/
|
|
148
243
|
validatePipelineReferences(pipeline, definedActions) {
|
|
149
244
|
for (const stage of pipeline.stages) {
|
|
@@ -163,1055 +258,9 @@ export class ReqonParser extends ReqonExpressionParser {
|
|
|
163
258
|
}
|
|
164
259
|
}
|
|
165
260
|
}
|
|
166
|
-
// ============================================
|
|
167
|
-
// Schedule definition
|
|
168
|
-
// ============================================
|
|
169
|
-
parseSchedule() {
|
|
170
|
-
this.consume(ReqonTokenType.SCHEDULE, "Expected 'schedule'");
|
|
171
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
172
|
-
let scheduleType;
|
|
173
|
-
let interval;
|
|
174
|
-
let cronExpression;
|
|
175
|
-
let runAt;
|
|
176
|
-
let timezone;
|
|
177
|
-
let maxConcurrency;
|
|
178
|
-
let skipIfRunning;
|
|
179
|
-
let retryOnFailure;
|
|
180
|
-
// Determine schedule type
|
|
181
|
-
if (this.check(ReqonTokenType.EVERY)) {
|
|
182
|
-
// Interval-based: schedule: every 6 hours
|
|
183
|
-
scheduleType = 'interval';
|
|
184
|
-
interval = this.parseIntervalSchedule();
|
|
185
|
-
}
|
|
186
|
-
else if (this.check(ReqonTokenType.CRON)) {
|
|
187
|
-
// Cron-based: schedule: cron "0 */6 * * *"
|
|
188
|
-
scheduleType = 'cron';
|
|
189
|
-
this.advance(); // consume 'cron'
|
|
190
|
-
cronExpression = this.consume(TokenType.STRING, 'Expected cron expression string').value;
|
|
191
|
-
}
|
|
192
|
-
else if (this.check(ReqonTokenType.AT)) {
|
|
193
|
-
// One-time: schedule: at "2025-01-20 09:00 UTC"
|
|
194
|
-
scheduleType = 'once';
|
|
195
|
-
this.advance(); // consume 'at'
|
|
196
|
-
runAt = this.consume(TokenType.STRING, 'Expected datetime string').value;
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
throw this.error(`Expected 'every', 'cron', or 'at' for schedule type`);
|
|
200
|
-
}
|
|
201
|
-
// Optional configuration block
|
|
202
|
-
if (this.match(TokenType.LBRACE)) {
|
|
203
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
204
|
-
// Handle keyword tokens that can appear as option keys
|
|
205
|
-
let key;
|
|
206
|
-
if (this.check(ReqonTokenType.RETRY)) {
|
|
207
|
-
this.advance();
|
|
208
|
-
key = 'retry';
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
key = this.consume(TokenType.IDENTIFIER, 'Expected schedule option key').value;
|
|
212
|
-
}
|
|
213
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
214
|
-
switch (key) {
|
|
215
|
-
case 'timezone':
|
|
216
|
-
timezone = this.consume(TokenType.STRING, 'Expected timezone string').value;
|
|
217
|
-
break;
|
|
218
|
-
case 'maxConcurrency':
|
|
219
|
-
maxConcurrency = parseInt(this.consume(TokenType.NUMBER, 'Expected number').value, 10);
|
|
220
|
-
break;
|
|
221
|
-
case 'skipIfRunning':
|
|
222
|
-
skipIfRunning = this.match(TokenType.TRUE);
|
|
223
|
-
if (!skipIfRunning) {
|
|
224
|
-
this.consume(TokenType.FALSE, "Expected 'true' or 'false'");
|
|
225
|
-
}
|
|
226
|
-
break;
|
|
227
|
-
case 'retry':
|
|
228
|
-
retryOnFailure = this.parseScheduleRetryConfig();
|
|
229
|
-
break;
|
|
230
|
-
default:
|
|
231
|
-
throw this.error(`Unknown schedule option: ${key}`);
|
|
232
|
-
}
|
|
233
|
-
this.match(TokenType.COMMA);
|
|
234
|
-
}
|
|
235
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
236
|
-
}
|
|
237
|
-
return {
|
|
238
|
-
type: 'ScheduleDefinition',
|
|
239
|
-
scheduleType,
|
|
240
|
-
interval,
|
|
241
|
-
cronExpression,
|
|
242
|
-
runAt,
|
|
243
|
-
timezone,
|
|
244
|
-
maxConcurrency,
|
|
245
|
-
skipIfRunning,
|
|
246
|
-
retryOnFailure,
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
parseIntervalSchedule() {
|
|
250
|
-
this.consume(ReqonTokenType.EVERY, "Expected 'every'");
|
|
251
|
-
const value = parseInt(this.consume(TokenType.NUMBER, 'Expected interval value').value, 10);
|
|
252
|
-
let unit;
|
|
253
|
-
const unitToken = this.advance();
|
|
254
|
-
switch (unitToken.type) {
|
|
255
|
-
case ReqonTokenType.SECONDS:
|
|
256
|
-
unit = 'seconds';
|
|
257
|
-
break;
|
|
258
|
-
case ReqonTokenType.MINUTES:
|
|
259
|
-
unit = 'minutes';
|
|
260
|
-
break;
|
|
261
|
-
case ReqonTokenType.HOURS:
|
|
262
|
-
unit = 'hours';
|
|
263
|
-
break;
|
|
264
|
-
case ReqonTokenType.DAYS:
|
|
265
|
-
unit = 'days';
|
|
266
|
-
break;
|
|
267
|
-
case ReqonTokenType.WEEKS:
|
|
268
|
-
unit = 'weeks';
|
|
269
|
-
break;
|
|
270
|
-
default:
|
|
271
|
-
throw this.error(`Expected time unit (seconds, minutes, hours, days, weeks), got: ${unitToken.value}`);
|
|
272
|
-
}
|
|
273
|
-
return { value, unit };
|
|
274
|
-
}
|
|
275
|
-
parseScheduleRetryConfig() {
|
|
276
|
-
this.consume(TokenType.LBRACE, "Expected '{'");
|
|
277
|
-
let maxRetries = 3;
|
|
278
|
-
let delaySeconds = 60;
|
|
279
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
280
|
-
const key = this.consume(TokenType.IDENTIFIER, 'Expected retry option').value;
|
|
281
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
282
|
-
switch (key) {
|
|
283
|
-
case 'maxRetries':
|
|
284
|
-
maxRetries = parseInt(this.consume(TokenType.NUMBER, 'Expected number').value, 10);
|
|
285
|
-
break;
|
|
286
|
-
case 'delaySeconds':
|
|
287
|
-
delaySeconds = parseInt(this.consume(TokenType.NUMBER, 'Expected number').value, 10);
|
|
288
|
-
break;
|
|
289
|
-
default:
|
|
290
|
-
throw this.error(`Unknown retry option: ${key}`);
|
|
291
|
-
}
|
|
292
|
-
this.match(TokenType.COMMA);
|
|
293
|
-
}
|
|
294
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
295
|
-
return { maxRetries, delaySeconds };
|
|
296
|
-
}
|
|
297
|
-
// ============================================
|
|
298
|
-
// Source definition
|
|
299
|
-
// ============================================
|
|
300
|
-
parseSource() {
|
|
301
|
-
this.consume(ReqonTokenType.SOURCE, "Expected 'source'");
|
|
302
|
-
const name = this.consume(TokenType.IDENTIFIER, 'Expected source name').value;
|
|
303
|
-
// Check for 'from' clause (OAS spec path)
|
|
304
|
-
let specPath;
|
|
305
|
-
if (this.match(ReqonTokenType.FROM)) {
|
|
306
|
-
specPath = this.consume(TokenType.STRING, 'Expected OAS spec path').value;
|
|
307
|
-
}
|
|
308
|
-
this.consume(TokenType.LBRACE, "Expected '{'");
|
|
309
|
-
const config = this.parseSourceConfig(specPath !== undefined);
|
|
310
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
311
|
-
return { type: 'SourceDefinition', name, specPath, config };
|
|
312
|
-
}
|
|
313
|
-
parseSourceConfig(hasOAS = false) {
|
|
314
|
-
let auth;
|
|
315
|
-
let base;
|
|
316
|
-
let validateResponses;
|
|
317
|
-
let rateLimit;
|
|
318
|
-
let circuitBreaker;
|
|
319
|
-
const headers = {};
|
|
320
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
321
|
-
const key = this.consume(TokenType.IDENTIFIER, 'Expected config key').value;
|
|
322
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
323
|
-
if (key === 'auth') {
|
|
324
|
-
auth = this.parseAuthConfig();
|
|
325
|
-
}
|
|
326
|
-
else if (key === 'base') {
|
|
327
|
-
base = this.consume(TokenType.STRING, 'Expected base URL string').value;
|
|
328
|
-
}
|
|
329
|
-
else if (key === 'validateResponses') {
|
|
330
|
-
validateResponses = this.match(TokenType.TRUE);
|
|
331
|
-
if (!validateResponses) {
|
|
332
|
-
this.consume(TokenType.FALSE, "Expected 'true' or 'false'");
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
else if (key === 'headers') {
|
|
336
|
-
this.consume(TokenType.LBRACE, "Expected '{'");
|
|
337
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
338
|
-
const headerName = this.consume(TokenType.STRING, 'Expected header name').value;
|
|
339
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
340
|
-
headers[headerName] = this.parseExpression();
|
|
341
|
-
this.match(TokenType.COMMA);
|
|
342
|
-
}
|
|
343
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
344
|
-
}
|
|
345
|
-
else if (key === 'rateLimit') {
|
|
346
|
-
rateLimit = this.parseRateLimitConfig();
|
|
347
|
-
}
|
|
348
|
-
else if (key === 'circuitBreaker') {
|
|
349
|
-
circuitBreaker = this.parseCircuitBreakerConfig();
|
|
350
|
-
}
|
|
351
|
-
this.match(TokenType.COMMA);
|
|
352
|
-
}
|
|
353
|
-
if (!auth)
|
|
354
|
-
throw this.error('Source must have auth config');
|
|
355
|
-
// Base URL is only required if not using OAS
|
|
356
|
-
if (!base && !hasOAS)
|
|
357
|
-
throw this.error('Source must have base URL (or use OAS spec)');
|
|
358
|
-
return {
|
|
359
|
-
auth,
|
|
360
|
-
base,
|
|
361
|
-
validateResponses,
|
|
362
|
-
headers: Object.keys(headers).length > 0 ? headers : undefined,
|
|
363
|
-
rateLimit,
|
|
364
|
-
circuitBreaker,
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
|
-
parseRateLimitConfig() {
|
|
368
|
-
this.consume(TokenType.LBRACE, "Expected '{'");
|
|
369
|
-
const config = {};
|
|
370
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
371
|
-
const key = this.consume(TokenType.IDENTIFIER, 'Expected rate limit option').value;
|
|
372
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
373
|
-
switch (key) {
|
|
374
|
-
case 'strategy':
|
|
375
|
-
config.strategy = this.consume(TokenType.IDENTIFIER, 'Expected strategy').value;
|
|
376
|
-
break;
|
|
377
|
-
case 'maxWait':
|
|
378
|
-
config.maxWait = parseInt(this.consume(TokenType.NUMBER, 'Expected number').value, 10);
|
|
379
|
-
break;
|
|
380
|
-
case 'fallbackRpm':
|
|
381
|
-
config.fallbackRpm = parseInt(this.consume(TokenType.NUMBER, 'Expected number').value, 10);
|
|
382
|
-
break;
|
|
383
|
-
default:
|
|
384
|
-
throw this.error(`Unknown rate limit option: ${key}`);
|
|
385
|
-
}
|
|
386
|
-
this.match(TokenType.COMMA);
|
|
387
|
-
}
|
|
388
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
389
|
-
return config;
|
|
390
|
-
}
|
|
391
|
-
parseCircuitBreakerConfig() {
|
|
392
|
-
this.consume(TokenType.LBRACE, "Expected '{'");
|
|
393
|
-
const config = {};
|
|
394
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
395
|
-
const key = this.consume(TokenType.IDENTIFIER, 'Expected circuit breaker option').value;
|
|
396
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
397
|
-
switch (key) {
|
|
398
|
-
case 'failureThreshold':
|
|
399
|
-
config.failureThreshold = parseInt(this.consume(TokenType.NUMBER, 'Expected number').value, 10);
|
|
400
|
-
break;
|
|
401
|
-
case 'resetTimeout':
|
|
402
|
-
config.resetTimeout = parseInt(this.consume(TokenType.NUMBER, 'Expected number').value, 10);
|
|
403
|
-
break;
|
|
404
|
-
case 'successThreshold':
|
|
405
|
-
config.successThreshold = parseInt(this.consume(TokenType.NUMBER, 'Expected number').value, 10);
|
|
406
|
-
break;
|
|
407
|
-
case 'failureWindow':
|
|
408
|
-
config.failureWindow = parseInt(this.consume(TokenType.NUMBER, 'Expected number').value, 10);
|
|
409
|
-
break;
|
|
410
|
-
default:
|
|
411
|
-
throw this.error(`Unknown circuit breaker option: ${key}`);
|
|
412
|
-
}
|
|
413
|
-
this.match(TokenType.COMMA);
|
|
414
|
-
}
|
|
415
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
416
|
-
return config;
|
|
417
|
-
}
|
|
418
|
-
parseAuthConfig() {
|
|
419
|
-
const typeToken = this.advance();
|
|
420
|
-
let type;
|
|
421
|
-
switch (typeToken.type) {
|
|
422
|
-
case ReqonTokenType.OAUTH2:
|
|
423
|
-
type = 'oauth2';
|
|
424
|
-
break;
|
|
425
|
-
case ReqonTokenType.BEARER:
|
|
426
|
-
type = 'bearer';
|
|
427
|
-
break;
|
|
428
|
-
case ReqonTokenType.BASIC:
|
|
429
|
-
type = 'basic';
|
|
430
|
-
break;
|
|
431
|
-
case ReqonTokenType.API_KEY:
|
|
432
|
-
type = 'api_key';
|
|
433
|
-
break;
|
|
434
|
-
case ReqonTokenType.NONE:
|
|
435
|
-
type = 'none';
|
|
436
|
-
break;
|
|
437
|
-
default:
|
|
438
|
-
throw this.error(`Unknown auth type: ${typeToken.value}`);
|
|
439
|
-
}
|
|
440
|
-
return { type };
|
|
441
|
-
}
|
|
442
|
-
// ============================================
|
|
443
|
-
// Store definition
|
|
444
|
-
// ============================================
|
|
445
|
-
parseStoreDefinition() {
|
|
446
|
-
this.consume(ReqonTokenType.STORE, "Expected 'store'");
|
|
447
|
-
const name = this.consumeIdentifier('Expected store name').value;
|
|
448
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
449
|
-
let storeType;
|
|
450
|
-
const typeToken = this.advance();
|
|
451
|
-
switch (typeToken.type) {
|
|
452
|
-
case ReqonTokenType.NOSQL:
|
|
453
|
-
storeType = 'nosql';
|
|
454
|
-
break;
|
|
455
|
-
case ReqonTokenType.SQL:
|
|
456
|
-
storeType = 'sql';
|
|
457
|
-
break;
|
|
458
|
-
case ReqonTokenType.MEMORY:
|
|
459
|
-
storeType = 'memory';
|
|
460
|
-
break;
|
|
461
|
-
default:
|
|
462
|
-
throw this.error(`Unknown store type: ${typeToken.value}`);
|
|
463
|
-
}
|
|
464
|
-
this.consume(TokenType.LPAREN, "Expected '('");
|
|
465
|
-
const target = this.consume(TokenType.STRING, 'Expected target name').value;
|
|
466
|
-
this.consume(TokenType.RPAREN, "Expected ')'");
|
|
467
|
-
return { type: 'StoreDefinition', name, storeType, target };
|
|
468
|
-
}
|
|
469
|
-
// ============================================
|
|
470
|
-
// Action definition
|
|
471
|
-
// ============================================
|
|
472
|
-
parseAction() {
|
|
473
|
-
this.consume(ReqonTokenType.ACTION, "Expected 'action'");
|
|
474
|
-
const name = this.consume(TokenType.IDENTIFIER, 'Expected action name').value;
|
|
475
|
-
this.consume(TokenType.LBRACE, "Expected '{'");
|
|
476
|
-
const steps = [];
|
|
477
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
478
|
-
steps.push(this.parseActionStep());
|
|
479
|
-
this.match(TokenType.COMMA);
|
|
480
|
-
}
|
|
481
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
482
|
-
return { type: 'ActionDefinition', name, steps };
|
|
483
|
-
}
|
|
484
|
-
parseActionStep() {
|
|
485
|
-
if (this.check(ReqonTokenType.CALL))
|
|
486
|
-
return this.parseCallStep();
|
|
487
|
-
// Shorthand: get "/path", post "/path", etc.
|
|
488
|
-
if (this.checkHttpMethod())
|
|
489
|
-
return this.parseHttpMethodStep();
|
|
490
|
-
if (this.check(ReqonTokenType.FOR))
|
|
491
|
-
return this.parseForStep();
|
|
492
|
-
if (this.check(ReqonTokenType.MAP))
|
|
493
|
-
return this.parseMapStep();
|
|
494
|
-
if (this.check(TokenType.VALIDATE))
|
|
495
|
-
return this.parseValidateStep();
|
|
496
|
-
if (this.check(ReqonTokenType.STORE))
|
|
497
|
-
return this.parseStoreStep();
|
|
498
|
-
if (this.check(TokenType.MATCH))
|
|
499
|
-
return this.parseMatchStep();
|
|
500
|
-
if (this.check(TokenType.LET))
|
|
501
|
-
return this.parseLetStep();
|
|
502
|
-
if (this.check(ReqonTokenType.WAIT))
|
|
503
|
-
return this.parseWaitStep();
|
|
504
|
-
throw this.error(`Expected action step, got: ${this.peek().value}`);
|
|
505
|
-
}
|
|
506
|
-
checkHttpMethod() {
|
|
507
|
-
const t = this.peek().type;
|
|
508
|
-
return (t === ReqonTokenType.GET ||
|
|
509
|
-
t === ReqonTokenType.POST ||
|
|
510
|
-
t === ReqonTokenType.PUT ||
|
|
511
|
-
t === ReqonTokenType.PATCH ||
|
|
512
|
-
t === ReqonTokenType.DELETE);
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Parse HTTP method syntax: get "/path" { options }
|
|
516
|
-
*/
|
|
517
|
-
parseHttpMethodStep() {
|
|
518
|
-
const methodToken = this.advance();
|
|
519
|
-
let method;
|
|
520
|
-
switch (methodToken.type) {
|
|
521
|
-
case ReqonTokenType.GET:
|
|
522
|
-
method = 'GET';
|
|
523
|
-
break;
|
|
524
|
-
case ReqonTokenType.POST:
|
|
525
|
-
method = 'POST';
|
|
526
|
-
break;
|
|
527
|
-
case ReqonTokenType.PUT:
|
|
528
|
-
method = 'PUT';
|
|
529
|
-
break;
|
|
530
|
-
case ReqonTokenType.PATCH:
|
|
531
|
-
method = 'PATCH';
|
|
532
|
-
break;
|
|
533
|
-
case ReqonTokenType.DELETE:
|
|
534
|
-
method = 'DELETE';
|
|
535
|
-
break;
|
|
536
|
-
default:
|
|
537
|
-
throw this.error(`Unexpected HTTP method token: ${methodToken.value}`);
|
|
538
|
-
}
|
|
539
|
-
const path = this.parseExpression();
|
|
540
|
-
// Parse optional config block (same as parseFetchStep)
|
|
541
|
-
let source;
|
|
542
|
-
let body;
|
|
543
|
-
let headers;
|
|
544
|
-
let paginate;
|
|
545
|
-
let until;
|
|
546
|
-
let retry;
|
|
547
|
-
let since;
|
|
548
|
-
if (this.match(TokenType.LBRACE)) {
|
|
549
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
550
|
-
let key;
|
|
551
|
-
if (this.check(ReqonTokenType.SOURCE)) {
|
|
552
|
-
this.advance();
|
|
553
|
-
key = 'source';
|
|
554
|
-
}
|
|
555
|
-
else if (this.check(ReqonTokenType.PAGINATE)) {
|
|
556
|
-
this.advance();
|
|
557
|
-
key = 'paginate';
|
|
558
|
-
}
|
|
559
|
-
else if (this.check(ReqonTokenType.UNTIL)) {
|
|
560
|
-
this.advance();
|
|
561
|
-
key = 'until';
|
|
562
|
-
}
|
|
563
|
-
else if (this.check(ReqonTokenType.RETRY)) {
|
|
564
|
-
this.advance();
|
|
565
|
-
key = 'retry';
|
|
566
|
-
}
|
|
567
|
-
else if (this.check(ReqonTokenType.SINCE)) {
|
|
568
|
-
this.advance();
|
|
569
|
-
key = 'since';
|
|
570
|
-
}
|
|
571
|
-
else {
|
|
572
|
-
key = this.consume(TokenType.IDENTIFIER, 'Expected option key').value;
|
|
573
|
-
}
|
|
574
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
575
|
-
switch (key) {
|
|
576
|
-
case 'source':
|
|
577
|
-
source = this.consume(TokenType.IDENTIFIER, 'Expected source name').value;
|
|
578
|
-
break;
|
|
579
|
-
case 'body':
|
|
580
|
-
body = this.parseExpression();
|
|
581
|
-
break;
|
|
582
|
-
case 'paginate':
|
|
583
|
-
paginate = this.parsePaginationConfig();
|
|
584
|
-
break;
|
|
585
|
-
case 'until':
|
|
586
|
-
until = this.parseExpression();
|
|
587
|
-
break;
|
|
588
|
-
case 'retry':
|
|
589
|
-
retry = this.parseRetryConfig();
|
|
590
|
-
break;
|
|
591
|
-
case 'since':
|
|
592
|
-
since = this.parseSinceConfig();
|
|
593
|
-
break;
|
|
594
|
-
default:
|
|
595
|
-
throw this.error(`Unknown fetch option: ${key}`);
|
|
596
|
-
}
|
|
597
|
-
this.match(TokenType.COMMA);
|
|
598
|
-
}
|
|
599
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
600
|
-
}
|
|
601
|
-
return {
|
|
602
|
-
type: 'FetchStep',
|
|
603
|
-
method,
|
|
604
|
-
path,
|
|
605
|
-
source,
|
|
606
|
-
body,
|
|
607
|
-
headers,
|
|
608
|
-
paginate,
|
|
609
|
-
until,
|
|
610
|
-
retry,
|
|
611
|
-
since,
|
|
612
|
-
};
|
|
613
|
-
}
|
|
614
|
-
// ============================================
|
|
615
|
-
// Call step (OAS operationId)
|
|
616
|
-
// ============================================
|
|
617
|
-
/**
|
|
618
|
-
* Parse OAS-style call: call Source.operationId { options }
|
|
619
|
-
* For direct HTTP requests, use: get "/path", post "/path", etc.
|
|
620
|
-
*/
|
|
621
|
-
parseCallStep() {
|
|
622
|
-
this.consume(ReqonTokenType.CALL, "Expected 'call'");
|
|
623
|
-
// OAS-style: call Source.operationId
|
|
624
|
-
const sourceName = this.consume(TokenType.IDENTIFIER, 'Expected source name').value;
|
|
625
|
-
this.consume(TokenType.DOT, "Expected '.'");
|
|
626
|
-
const opId = this.consume(TokenType.IDENTIFIER, 'Expected operationId').value;
|
|
627
|
-
const operationRef = { source: sourceName, operationId: opId };
|
|
628
|
-
let source;
|
|
629
|
-
let body;
|
|
630
|
-
let headers;
|
|
631
|
-
let paginate;
|
|
632
|
-
let until;
|
|
633
|
-
let retry;
|
|
634
|
-
let since;
|
|
635
|
-
if (this.match(TokenType.LBRACE)) {
|
|
636
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
637
|
-
// Accept keyword tokens as option keys
|
|
638
|
-
let key;
|
|
639
|
-
if (this.check(ReqonTokenType.SOURCE)) {
|
|
640
|
-
this.advance();
|
|
641
|
-
key = 'source';
|
|
642
|
-
}
|
|
643
|
-
else if (this.check(ReqonTokenType.PAGINATE)) {
|
|
644
|
-
this.advance();
|
|
645
|
-
key = 'paginate';
|
|
646
|
-
}
|
|
647
|
-
else if (this.check(ReqonTokenType.UNTIL)) {
|
|
648
|
-
this.advance();
|
|
649
|
-
key = 'until';
|
|
650
|
-
}
|
|
651
|
-
else if (this.check(ReqonTokenType.RETRY)) {
|
|
652
|
-
this.advance();
|
|
653
|
-
key = 'retry';
|
|
654
|
-
}
|
|
655
|
-
else if (this.check(ReqonTokenType.SINCE)) {
|
|
656
|
-
this.advance();
|
|
657
|
-
key = 'since';
|
|
658
|
-
}
|
|
659
|
-
else {
|
|
660
|
-
key = this.consume(TokenType.IDENTIFIER, 'Expected option key').value;
|
|
661
|
-
}
|
|
662
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
663
|
-
switch (key) {
|
|
664
|
-
case 'source':
|
|
665
|
-
source = this.consume(TokenType.IDENTIFIER, 'Expected source name').value;
|
|
666
|
-
break;
|
|
667
|
-
case 'body':
|
|
668
|
-
body = this.parseExpression();
|
|
669
|
-
break;
|
|
670
|
-
case 'paginate':
|
|
671
|
-
paginate = this.parsePaginationConfig();
|
|
672
|
-
break;
|
|
673
|
-
case 'until':
|
|
674
|
-
until = this.parseExpression();
|
|
675
|
-
break;
|
|
676
|
-
case 'retry':
|
|
677
|
-
retry = this.parseRetryConfig();
|
|
678
|
-
break;
|
|
679
|
-
case 'since':
|
|
680
|
-
since = this.parseSinceConfig();
|
|
681
|
-
break;
|
|
682
|
-
default:
|
|
683
|
-
throw this.error(`Unknown fetch option: ${key}`);
|
|
684
|
-
}
|
|
685
|
-
this.match(TokenType.COMMA);
|
|
686
|
-
}
|
|
687
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
688
|
-
}
|
|
689
|
-
return {
|
|
690
|
-
type: 'FetchStep',
|
|
691
|
-
operationRef,
|
|
692
|
-
source,
|
|
693
|
-
body,
|
|
694
|
-
headers,
|
|
695
|
-
paginate,
|
|
696
|
-
until,
|
|
697
|
-
retry,
|
|
698
|
-
since,
|
|
699
|
-
};
|
|
700
|
-
}
|
|
701
|
-
parseSinceConfig() {
|
|
702
|
-
// since: lastSync
|
|
703
|
-
// since: lastSync("custom-key")
|
|
704
|
-
// since: lastSync { param: "modified_since", format: "unix" }
|
|
705
|
-
if (this.check(ReqonTokenType.LAST_SYNC)) {
|
|
706
|
-
this.advance();
|
|
707
|
-
let key;
|
|
708
|
-
let param;
|
|
709
|
-
let format;
|
|
710
|
-
let updateFrom;
|
|
711
|
-
// Check for optional key: lastSync("key")
|
|
712
|
-
if (this.match(TokenType.LPAREN)) {
|
|
713
|
-
key = this.consume(TokenType.STRING, 'Expected checkpoint key').value;
|
|
714
|
-
this.consume(TokenType.RPAREN, "Expected ')'");
|
|
715
|
-
}
|
|
716
|
-
// Check for optional config block
|
|
717
|
-
if (this.match(TokenType.LBRACE)) {
|
|
718
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
719
|
-
const optionKey = this.consume(TokenType.IDENTIFIER, 'Expected option key').value;
|
|
720
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
721
|
-
switch (optionKey) {
|
|
722
|
-
case 'param':
|
|
723
|
-
param = this.consume(TokenType.STRING, 'Expected param name').value;
|
|
724
|
-
break;
|
|
725
|
-
case 'format':
|
|
726
|
-
format = this.consume(TokenType.IDENTIFIER, 'Expected format').value;
|
|
727
|
-
break;
|
|
728
|
-
case 'updateFrom':
|
|
729
|
-
updateFrom = this.consume(TokenType.STRING, 'Expected field path').value;
|
|
730
|
-
break;
|
|
731
|
-
default:
|
|
732
|
-
throw this.error(`Unknown since option: ${optionKey}`);
|
|
733
|
-
}
|
|
734
|
-
this.match(TokenType.COMMA);
|
|
735
|
-
}
|
|
736
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
737
|
-
}
|
|
738
|
-
return {
|
|
739
|
-
type: 'lastSync',
|
|
740
|
-
key,
|
|
741
|
-
param,
|
|
742
|
-
format,
|
|
743
|
-
updateFrom,
|
|
744
|
-
};
|
|
745
|
-
}
|
|
746
|
-
// since: <expression> - custom expression for the timestamp
|
|
747
|
-
const expression = this.parseExpression();
|
|
748
|
-
return {
|
|
749
|
-
type: 'expression',
|
|
750
|
-
expression,
|
|
751
|
-
};
|
|
752
|
-
}
|
|
753
|
-
parsePaginationConfig() {
|
|
754
|
-
const typeToken = this.advance();
|
|
755
|
-
let type;
|
|
756
|
-
switch (typeToken.type) {
|
|
757
|
-
case ReqonTokenType.OFFSET:
|
|
758
|
-
type = 'offset';
|
|
759
|
-
break;
|
|
760
|
-
case ReqonTokenType.CURSOR:
|
|
761
|
-
type = 'cursor';
|
|
762
|
-
break;
|
|
763
|
-
case ReqonTokenType.PAGE:
|
|
764
|
-
type = 'page';
|
|
765
|
-
break;
|
|
766
|
-
default:
|
|
767
|
-
throw this.error(`Unknown pagination type: ${typeToken.value}`);
|
|
768
|
-
}
|
|
769
|
-
this.consume(TokenType.LPAREN, "Expected '('");
|
|
770
|
-
// Accept keyword tokens as param names (e.g., 'page', 'offset', 'cursor')
|
|
771
|
-
let param;
|
|
772
|
-
if (this.check(ReqonTokenType.PAGE)) {
|
|
773
|
-
param = this.advance().value;
|
|
774
|
-
}
|
|
775
|
-
else if (this.check(ReqonTokenType.OFFSET)) {
|
|
776
|
-
param = this.advance().value;
|
|
777
|
-
}
|
|
778
|
-
else if (this.check(ReqonTokenType.CURSOR)) {
|
|
779
|
-
param = this.advance().value;
|
|
780
|
-
}
|
|
781
|
-
else {
|
|
782
|
-
param = this.consume(TokenType.IDENTIFIER, 'Expected param name').value;
|
|
783
|
-
}
|
|
784
|
-
this.consume(TokenType.COMMA, "Expected ','");
|
|
785
|
-
const pageSize = parseInt(this.consume(TokenType.NUMBER, 'Expected page size').value, 10);
|
|
786
|
-
let cursorPath;
|
|
787
|
-
if (type === 'cursor' && this.match(TokenType.COMMA)) {
|
|
788
|
-
cursorPath = this.consume(TokenType.STRING, 'Expected cursor path').value;
|
|
789
|
-
}
|
|
790
|
-
this.consume(TokenType.RPAREN, "Expected ')'");
|
|
791
|
-
return { type, param, pageSize, cursorPath };
|
|
792
|
-
}
|
|
793
|
-
parseRetryConfig() {
|
|
794
|
-
this.consume(TokenType.LBRACE, "Expected '{'");
|
|
795
|
-
let maxAttempts = 3;
|
|
796
|
-
let backoff = 'exponential';
|
|
797
|
-
let initialDelay = 1000;
|
|
798
|
-
let maxDelay;
|
|
799
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
800
|
-
const key = this.consume(TokenType.IDENTIFIER, 'Expected retry option').value;
|
|
801
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
802
|
-
switch (key) {
|
|
803
|
-
case 'maxAttempts':
|
|
804
|
-
maxAttempts = parseInt(this.consume(TokenType.NUMBER, 'Expected number').value, 10);
|
|
805
|
-
break;
|
|
806
|
-
case 'backoff':
|
|
807
|
-
backoff = this.consume(TokenType.IDENTIFIER, 'Expected backoff type').value;
|
|
808
|
-
break;
|
|
809
|
-
case 'initialDelay':
|
|
810
|
-
initialDelay = parseInt(this.consume(TokenType.NUMBER, 'Expected number').value, 10);
|
|
811
|
-
break;
|
|
812
|
-
case 'maxDelay':
|
|
813
|
-
maxDelay = parseInt(this.consume(TokenType.NUMBER, 'Expected number').value, 10);
|
|
814
|
-
break;
|
|
815
|
-
}
|
|
816
|
-
this.match(TokenType.COMMA);
|
|
817
|
-
}
|
|
818
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
819
|
-
return { maxAttempts, backoff, initialDelay, maxDelay };
|
|
820
|
-
}
|
|
821
|
-
// ============================================
|
|
822
|
-
// For step
|
|
823
|
-
// ============================================
|
|
824
|
-
parseForStep() {
|
|
825
|
-
this.consume(ReqonTokenType.FOR, "Expected 'for'");
|
|
826
|
-
const variable = this.consumeIdentifier('Expected variable name').value;
|
|
827
|
-
this.consume(TokenType.IN, "Expected 'in'");
|
|
828
|
-
const collection = this.parseExpression();
|
|
829
|
-
let condition;
|
|
830
|
-
if (this.match(TokenType.WHERE)) {
|
|
831
|
-
condition = this.parseExpression();
|
|
832
|
-
}
|
|
833
|
-
this.consume(TokenType.LBRACE, "Expected '{'");
|
|
834
|
-
const steps = [];
|
|
835
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
836
|
-
steps.push(this.parseActionStep());
|
|
837
|
-
this.match(TokenType.COMMA);
|
|
838
|
-
}
|
|
839
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
840
|
-
return { type: 'ForStep', variable, collection, condition, steps };
|
|
841
|
-
}
|
|
842
|
-
// ============================================
|
|
843
|
-
// Map step
|
|
844
|
-
// ============================================
|
|
845
|
-
parseMapStep() {
|
|
846
|
-
this.consume(ReqonTokenType.MAP, "Expected 'map'");
|
|
847
|
-
const source = this.parseExpression();
|
|
848
|
-
this.consume(TokenType.RIGHT_ARROW, "Expected '->'");
|
|
849
|
-
const targetSchema = this.consume(TokenType.IDENTIFIER, 'Expected target schema').value;
|
|
850
|
-
this.consume(TokenType.LBRACE, "Expected '{'");
|
|
851
|
-
const mappings = [];
|
|
852
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
853
|
-
const field = this.consumeIdentifier('Expected field name').value;
|
|
854
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
855
|
-
const expression = this.parseExpression();
|
|
856
|
-
mappings.push({ field, expression });
|
|
857
|
-
this.match(TokenType.COMMA);
|
|
858
|
-
}
|
|
859
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
860
|
-
return { type: 'MapStep', source, targetSchema, mappings };
|
|
861
|
-
}
|
|
862
|
-
// ============================================
|
|
863
|
-
// Validate step
|
|
864
|
-
// ============================================
|
|
865
|
-
parseValidateStep() {
|
|
866
|
-
this.consume(TokenType.VALIDATE, "Expected 'validate'");
|
|
867
|
-
const target = this.parseExpression();
|
|
868
|
-
this.consume(TokenType.LBRACE, "Expected '{'");
|
|
869
|
-
const constraints = [];
|
|
870
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
871
|
-
this.consume(TokenType.ASSUME, "Expected 'assume'");
|
|
872
|
-
const condition = this.parseExpression();
|
|
873
|
-
let message;
|
|
874
|
-
let severity = 'error';
|
|
875
|
-
// Optional message and severity could be added here
|
|
876
|
-
constraints.push({ type: 'ValidationConstraint', condition, message, severity });
|
|
877
|
-
this.match(TokenType.COMMA);
|
|
878
|
-
}
|
|
879
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
880
|
-
return { type: 'ValidateStep', target, constraints };
|
|
881
|
-
}
|
|
882
|
-
// ============================================
|
|
883
|
-
// Store step
|
|
884
|
-
// ============================================
|
|
885
|
-
parseStoreStep() {
|
|
886
|
-
this.consume(ReqonTokenType.STORE, "Expected 'store'");
|
|
887
|
-
// Check for 'each' keyword
|
|
888
|
-
let isEach = false;
|
|
889
|
-
if (this.match(ReqonTokenType.EACH)) {
|
|
890
|
-
isEach = true;
|
|
891
|
-
}
|
|
892
|
-
const source = this.parseExpression();
|
|
893
|
-
this.consume(TokenType.RIGHT_ARROW, "Expected '->'");
|
|
894
|
-
const target = this.consumeIdentifier('Expected store name').value;
|
|
895
|
-
const options = {};
|
|
896
|
-
if (this.match(TokenType.LBRACE)) {
|
|
897
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
898
|
-
// Accept keyword tokens as option keys
|
|
899
|
-
let key;
|
|
900
|
-
if (this.check(ReqonTokenType.KEY)) {
|
|
901
|
-
this.advance();
|
|
902
|
-
key = 'key';
|
|
903
|
-
}
|
|
904
|
-
else if (this.check(ReqonTokenType.PARTIAL)) {
|
|
905
|
-
this.advance();
|
|
906
|
-
key = 'partial';
|
|
907
|
-
}
|
|
908
|
-
else if (this.check(ReqonTokenType.UPSERT)) {
|
|
909
|
-
this.advance();
|
|
910
|
-
key = 'upsert';
|
|
911
|
-
}
|
|
912
|
-
else {
|
|
913
|
-
key = this.consume(TokenType.IDENTIFIER, 'Expected option key').value;
|
|
914
|
-
}
|
|
915
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
916
|
-
switch (key) {
|
|
917
|
-
case 'key':
|
|
918
|
-
options.key = this.parseExpression();
|
|
919
|
-
break;
|
|
920
|
-
case 'partial':
|
|
921
|
-
options.partial = this.match(TokenType.TRUE);
|
|
922
|
-
if (!options.partial) {
|
|
923
|
-
this.consume(TokenType.FALSE, "Expected 'true' or 'false'");
|
|
924
|
-
}
|
|
925
|
-
break;
|
|
926
|
-
case 'upsert':
|
|
927
|
-
options.upsert = this.match(TokenType.TRUE);
|
|
928
|
-
if (!options.upsert) {
|
|
929
|
-
this.consume(TokenType.FALSE, "Expected 'true' or 'false'");
|
|
930
|
-
}
|
|
931
|
-
break;
|
|
932
|
-
}
|
|
933
|
-
this.match(TokenType.COMMA);
|
|
934
|
-
}
|
|
935
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
936
|
-
}
|
|
937
|
-
return { type: 'StoreStep', source, target, options };
|
|
938
|
-
}
|
|
939
|
-
// ============================================
|
|
940
|
-
// Match step (schema overloading)
|
|
941
|
-
// ============================================
|
|
942
|
-
parseMatchStep() {
|
|
943
|
-
this.consume(TokenType.MATCH, "Expected 'match'");
|
|
944
|
-
const target = this.parseExpression();
|
|
945
|
-
this.consume(TokenType.LBRACE, "Expected '{'");
|
|
946
|
-
const arms = [];
|
|
947
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
948
|
-
arms.push(this.parseMatchArm());
|
|
949
|
-
this.match(TokenType.COMMA);
|
|
950
|
-
}
|
|
951
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
952
|
-
return { type: 'MatchStep', target, arms };
|
|
953
|
-
}
|
|
954
|
-
parseMatchArm() {
|
|
955
|
-
// Schema name or '_' for wildcard
|
|
956
|
-
const schema = this.consume(TokenType.IDENTIFIER, 'Expected schema name or _').value;
|
|
957
|
-
this.consume(TokenType.RIGHT_ARROW, "Expected '->'");
|
|
958
|
-
// After -> we have either:
|
|
959
|
-
// 1. A flow directive (continue, skip, abort, retry, queue, jump)
|
|
960
|
-
// 2. Steps in braces { ... }
|
|
961
|
-
// 3. A single step (store, fetch, etc.)
|
|
962
|
-
// Check for flow directives
|
|
963
|
-
const flow = this.tryParseFlowDirective();
|
|
964
|
-
if (flow) {
|
|
965
|
-
return { schema, flow };
|
|
966
|
-
}
|
|
967
|
-
// Check for step block
|
|
968
|
-
if (this.check(TokenType.LBRACE)) {
|
|
969
|
-
this.advance();
|
|
970
|
-
const steps = [];
|
|
971
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
972
|
-
steps.push(this.parseActionStep());
|
|
973
|
-
this.match(TokenType.COMMA);
|
|
974
|
-
}
|
|
975
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
976
|
-
return { schema, steps };
|
|
977
|
-
}
|
|
978
|
-
// Single step
|
|
979
|
-
const step = this.parseActionStep();
|
|
980
|
-
return { schema, steps: [step] };
|
|
981
|
-
}
|
|
982
|
-
tryParseFlowDirective() {
|
|
983
|
-
if (this.match(ReqonTokenType.CONTINUE)) {
|
|
984
|
-
return { type: 'continue' };
|
|
985
|
-
}
|
|
986
|
-
if (this.match(ReqonTokenType.SKIP)) {
|
|
987
|
-
return { type: 'skip' };
|
|
988
|
-
}
|
|
989
|
-
if (this.match(ReqonTokenType.ABORT)) {
|
|
990
|
-
let message;
|
|
991
|
-
if (this.check(TokenType.STRING)) {
|
|
992
|
-
message = this.advance().value;
|
|
993
|
-
}
|
|
994
|
-
return { type: 'abort', message };
|
|
995
|
-
}
|
|
996
|
-
if (this.match(ReqonTokenType.RETRY)) {
|
|
997
|
-
let backoff;
|
|
998
|
-
if (this.check(TokenType.LBRACE)) {
|
|
999
|
-
backoff = this.parseRetryConfig();
|
|
1000
|
-
}
|
|
1001
|
-
return { type: 'retry', backoff };
|
|
1002
|
-
}
|
|
1003
|
-
if (this.match(ReqonTokenType.QUEUE)) {
|
|
1004
|
-
let target;
|
|
1005
|
-
if (this.check(TokenType.IDENTIFIER)) {
|
|
1006
|
-
target = this.advance().value;
|
|
1007
|
-
}
|
|
1008
|
-
return { type: 'queue', target };
|
|
1009
|
-
}
|
|
1010
|
-
if (this.match(ReqonTokenType.JUMP)) {
|
|
1011
|
-
const action = this.consume(TokenType.IDENTIFIER, 'Expected action name').value;
|
|
1012
|
-
let then;
|
|
1013
|
-
if (this.match(TokenType.THEN)) {
|
|
1014
|
-
if (this.match(ReqonTokenType.RETRY)) {
|
|
1015
|
-
then = 'retry';
|
|
1016
|
-
}
|
|
1017
|
-
else if (this.match(ReqonTokenType.CONTINUE)) {
|
|
1018
|
-
then = 'continue';
|
|
1019
|
-
}
|
|
1020
|
-
else {
|
|
1021
|
-
throw this.error("Expected 'retry' or 'continue' after 'then'");
|
|
1022
|
-
}
|
|
1023
|
-
}
|
|
1024
|
-
return { type: 'jump', action, then };
|
|
1025
|
-
}
|
|
1026
|
-
return undefined;
|
|
1027
|
-
}
|
|
1028
|
-
// ============================================
|
|
1029
|
-
// Let step (variable binding)
|
|
1030
|
-
// ============================================
|
|
1031
|
-
parseLetStep() {
|
|
1032
|
-
this.consume(TokenType.LET, "Expected 'let'");
|
|
1033
|
-
const name = this.consumeIdentifier('Expected variable name').value;
|
|
1034
|
-
this.consume(TokenType.EQUALS, "Expected '='");
|
|
1035
|
-
const value = this.parseExpression();
|
|
1036
|
-
return { type: 'LetStep', name, value };
|
|
1037
|
-
}
|
|
1038
|
-
// ============================================
|
|
1039
|
-
// Wait step (webhook support)
|
|
1040
|
-
// ============================================
|
|
1041
|
-
/**
|
|
1042
|
-
* Parse wait step: wait { timeout: 60000, path: "/webhooks/callback", ... }
|
|
1043
|
-
* Waits for an external webhook callback before continuing execution
|
|
1044
|
-
*/
|
|
1045
|
-
parseWaitStep() {
|
|
1046
|
-
this.consume(ReqonTokenType.WAIT, "Expected 'wait'");
|
|
1047
|
-
this.consume(TokenType.LBRACE, "Expected '{'");
|
|
1048
|
-
const step = { type: 'WebhookStep' };
|
|
1049
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
1050
|
-
// Accept keyword tokens as option keys
|
|
1051
|
-
let key;
|
|
1052
|
-
if (this.check(ReqonTokenType.TIMEOUT)) {
|
|
1053
|
-
this.advance();
|
|
1054
|
-
key = 'timeout';
|
|
1055
|
-
}
|
|
1056
|
-
else if (this.check(ReqonTokenType.PATH)) {
|
|
1057
|
-
this.advance();
|
|
1058
|
-
key = 'path';
|
|
1059
|
-
}
|
|
1060
|
-
else if (this.check(ReqonTokenType.EXPECTED_EVENTS)) {
|
|
1061
|
-
this.advance();
|
|
1062
|
-
key = 'expectedEvents';
|
|
1063
|
-
}
|
|
1064
|
-
else if (this.check(ReqonTokenType.EVENT_FILTER)) {
|
|
1065
|
-
this.advance();
|
|
1066
|
-
key = 'eventFilter';
|
|
1067
|
-
}
|
|
1068
|
-
else if (this.check(ReqonTokenType.RETRY)) {
|
|
1069
|
-
this.advance();
|
|
1070
|
-
key = 'retry';
|
|
1071
|
-
}
|
|
1072
|
-
else if (this.check(ReqonTokenType.STORAGE)) {
|
|
1073
|
-
this.advance();
|
|
1074
|
-
key = 'storage';
|
|
1075
|
-
}
|
|
1076
|
-
else {
|
|
1077
|
-
key = this.consume(TokenType.IDENTIFIER, 'Expected option key').value;
|
|
1078
|
-
}
|
|
1079
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
1080
|
-
switch (key) {
|
|
1081
|
-
case 'timeout':
|
|
1082
|
-
step.timeout = parseInt(this.consume(TokenType.NUMBER, 'Expected timeout value').value, 10);
|
|
1083
|
-
break;
|
|
1084
|
-
case 'path':
|
|
1085
|
-
step.path = this.consume(TokenType.STRING, 'Expected path string').value;
|
|
1086
|
-
break;
|
|
1087
|
-
case 'expectedEvents':
|
|
1088
|
-
step.expectedEvents = parseInt(this.consume(TokenType.NUMBER, 'Expected number').value, 10);
|
|
1089
|
-
break;
|
|
1090
|
-
case 'eventFilter':
|
|
1091
|
-
step.eventFilter = this.parseExpression();
|
|
1092
|
-
break;
|
|
1093
|
-
case 'retry':
|
|
1094
|
-
step.retryOnTimeout = this.parseRetryConfig();
|
|
1095
|
-
break;
|
|
1096
|
-
case 'storage':
|
|
1097
|
-
step.storage = this.parseWebhookStorageConfig();
|
|
1098
|
-
break;
|
|
1099
|
-
default:
|
|
1100
|
-
throw this.error(`Unknown wait option: ${key}`);
|
|
1101
|
-
}
|
|
1102
|
-
this.match(TokenType.COMMA);
|
|
1103
|
-
}
|
|
1104
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
1105
|
-
return step;
|
|
1106
|
-
}
|
|
1107
261
|
/**
|
|
1108
|
-
* Parse
|
|
262
|
+
* Parse an import statement
|
|
1109
263
|
*/
|
|
1110
|
-
parseWebhookStorageConfig() {
|
|
1111
|
-
this.consume(TokenType.LBRACE, "Expected '{'");
|
|
1112
|
-
let target;
|
|
1113
|
-
let key;
|
|
1114
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
1115
|
-
let optionKey;
|
|
1116
|
-
if (this.check(ReqonTokenType.KEY)) {
|
|
1117
|
-
this.advance();
|
|
1118
|
-
optionKey = 'key';
|
|
1119
|
-
}
|
|
1120
|
-
else {
|
|
1121
|
-
optionKey = this.consume(TokenType.IDENTIFIER, 'Expected option key').value;
|
|
1122
|
-
}
|
|
1123
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
1124
|
-
switch (optionKey) {
|
|
1125
|
-
case 'target':
|
|
1126
|
-
target = this.consume(TokenType.IDENTIFIER, 'Expected store name').value;
|
|
1127
|
-
break;
|
|
1128
|
-
case 'key':
|
|
1129
|
-
key = this.parseExpression();
|
|
1130
|
-
break;
|
|
1131
|
-
default:
|
|
1132
|
-
throw this.error(`Unknown storage option: ${optionKey}`);
|
|
1133
|
-
}
|
|
1134
|
-
this.match(TokenType.COMMA);
|
|
1135
|
-
}
|
|
1136
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
1137
|
-
if (!target) {
|
|
1138
|
-
throw this.error('Webhook storage must have a target store');
|
|
1139
|
-
}
|
|
1140
|
-
return { target, key };
|
|
1141
|
-
}
|
|
1142
|
-
// ============================================
|
|
1143
|
-
// Pipeline definition
|
|
1144
|
-
// ============================================
|
|
1145
|
-
parsePipeline() {
|
|
1146
|
-
this.consume(ReqonTokenType.RUN, "Expected 'run'");
|
|
1147
|
-
const stages = [];
|
|
1148
|
-
// First stage
|
|
1149
|
-
stages.push(this.parsePipelineStage());
|
|
1150
|
-
// Subsequent stages with 'then'
|
|
1151
|
-
while (this.match(TokenType.THEN)) {
|
|
1152
|
-
stages.push(this.parsePipelineStage());
|
|
1153
|
-
}
|
|
1154
|
-
return { type: 'PipelineDefinition', stages };
|
|
1155
|
-
}
|
|
1156
|
-
parsePipelineStage() {
|
|
1157
|
-
let condition;
|
|
1158
|
-
// Check for parallel stage: [Action1, Action2, ...]
|
|
1159
|
-
if (this.match(TokenType.LBRACKET)) {
|
|
1160
|
-
const actions = [];
|
|
1161
|
-
// First action
|
|
1162
|
-
actions.push(this.consume(TokenType.IDENTIFIER, 'Expected action name').value);
|
|
1163
|
-
// Additional actions separated by commas
|
|
1164
|
-
while (this.match(TokenType.COMMA)) {
|
|
1165
|
-
actions.push(this.consume(TokenType.IDENTIFIER, 'Expected action name').value);
|
|
1166
|
-
}
|
|
1167
|
-
this.consume(TokenType.RBRACKET, "Expected ']'");
|
|
1168
|
-
// Optional 'if' condition
|
|
1169
|
-
if (this.match(TokenType.IF)) {
|
|
1170
|
-
condition = this.parseExpression();
|
|
1171
|
-
}
|
|
1172
|
-
return { actions, condition };
|
|
1173
|
-
}
|
|
1174
|
-
// Single action (sequential)
|
|
1175
|
-
const action = this.consume(TokenType.IDENTIFIER, 'Expected action name').value;
|
|
1176
|
-
// Optional 'if' condition
|
|
1177
|
-
if (this.match(TokenType.IF)) {
|
|
1178
|
-
condition = this.parseExpression();
|
|
1179
|
-
}
|
|
1180
|
-
return { action, condition };
|
|
1181
|
-
}
|
|
1182
|
-
// ============================================
|
|
1183
|
-
// Vague statement parsing (simplified)
|
|
1184
|
-
// ============================================
|
|
1185
|
-
parseSchema() {
|
|
1186
|
-
this.consume(TokenType.SCHEMA, "Expected 'schema'");
|
|
1187
|
-
const name = this.consume(TokenType.IDENTIFIER, 'Expected schema name').value;
|
|
1188
|
-
this.consume(TokenType.LBRACE, "Expected '{'");
|
|
1189
|
-
const fields = [];
|
|
1190
|
-
while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
|
|
1191
|
-
fields.push(this.parseFieldDefinition());
|
|
1192
|
-
this.match(TokenType.COMMA);
|
|
1193
|
-
}
|
|
1194
|
-
this.consume(TokenType.RBRACE, "Expected '}'");
|
|
1195
|
-
return {
|
|
1196
|
-
type: 'SchemaDefinition',
|
|
1197
|
-
name,
|
|
1198
|
-
fields,
|
|
1199
|
-
};
|
|
1200
|
-
}
|
|
1201
|
-
parseFieldDefinition() {
|
|
1202
|
-
const name = this.consumeIdentifier('Expected field name').value;
|
|
1203
|
-
this.consume(TokenType.COLON, "Expected ':'");
|
|
1204
|
-
// Simplified field type parsing - just grab the type name for now
|
|
1205
|
-
// Type names are standard types (string, int, etc.) not HTTP methods
|
|
1206
|
-
const typeName = this.consume(TokenType.IDENTIFIER, 'Expected type').value;
|
|
1207
|
-
// Handle optional/nullable type marker (?)
|
|
1208
|
-
this.match(TokenType.QUESTION);
|
|
1209
|
-
return {
|
|
1210
|
-
type: 'FieldDefinition',
|
|
1211
|
-
name,
|
|
1212
|
-
fieldType: { type: 'PrimitiveType', name: typeName },
|
|
1213
|
-
};
|
|
1214
|
-
}
|
|
1215
264
|
parseImport() {
|
|
1216
265
|
this.consume(TokenType.IMPORT, "Expected 'import'");
|
|
1217
266
|
const name = this.consume(TokenType.IDENTIFIER, 'Expected import name').value;
|
|
@@ -1219,6 +268,9 @@ export class ReqonParser extends ReqonExpressionParser {
|
|
|
1219
268
|
const path = this.consume(TokenType.STRING, 'Expected import path').value;
|
|
1220
269
|
return { type: 'ImportStatement', name, path };
|
|
1221
270
|
}
|
|
271
|
+
/**
|
|
272
|
+
* Parse a let statement
|
|
273
|
+
*/
|
|
1222
274
|
parseLet() {
|
|
1223
275
|
this.consume(TokenType.LET, "Expected 'let'");
|
|
1224
276
|
const name = this.consumeIdentifier('Expected variable name').value;
|