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