reqon-dsl 0.2.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.
Files changed (388) hide show
  1. package/.claude/settings.local.json +31 -0
  2. package/.claude/skills/api-integration.md +125 -0
  3. package/.claude/skills/database-schema.md +51 -0
  4. package/.claude/skills/dsl-design.md +80 -0
  5. package/.claude/skills/property-testing.md +143 -0
  6. package/.claude/skills/reqon/SKILL.md +44 -0
  7. package/.claude/skills/reqon/references/examples.md +206 -0
  8. package/.claude/skills/reqon/references/syntax.md +263 -0
  9. package/.claude/skills/vscode-extension.md +113 -0
  10. package/.github/dependabot.yml +32 -0
  11. package/.github/pull_request_template.md +21 -0
  12. package/.github/workflows/ci.yml +174 -0
  13. package/.github/workflows/release.yml +73 -0
  14. package/CLAUDE.md +72 -0
  15. package/CONTRIBUTING.md +161 -0
  16. package/README.md +235 -0
  17. package/TODO.md +51 -0
  18. package/dist/ast/index.d.ts +1 -0
  19. package/dist/ast/index.js +1 -0
  20. package/dist/ast/nodes.d.ts +237 -0
  21. package/dist/ast/nodes.js +12 -0
  22. package/dist/auth/auth.test.d.ts +1 -0
  23. package/dist/auth/auth.test.js +255 -0
  24. package/dist/auth/circuit-breaker.d.ts +115 -0
  25. package/dist/auth/circuit-breaker.js +267 -0
  26. package/dist/auth/credentials.d.ts +91 -0
  27. package/dist/auth/credentials.js +169 -0
  28. package/dist/auth/index.d.ts +5 -0
  29. package/dist/auth/index.js +8 -0
  30. package/dist/auth/oauth2-provider.d.ts +41 -0
  31. package/dist/auth/oauth2-provider.js +131 -0
  32. package/dist/auth/rate-limiter.d.ts +61 -0
  33. package/dist/auth/rate-limiter.js +380 -0
  34. package/dist/auth/token-store.d.ts +30 -0
  35. package/dist/auth/token-store.js +148 -0
  36. package/dist/auth/types.d.ts +142 -0
  37. package/dist/auth/types.js +1 -0
  38. package/dist/cli.d.ts +2 -0
  39. package/dist/cli.js +270 -0
  40. package/dist/errors/errors.test.d.ts +1 -0
  41. package/dist/errors/errors.test.js +165 -0
  42. package/dist/errors/index.d.ts +83 -0
  43. package/dist/errors/index.js +159 -0
  44. package/dist/execution/execution.test.d.ts +1 -0
  45. package/dist/execution/execution.test.js +246 -0
  46. package/dist/execution/index.d.ts +4 -0
  47. package/dist/execution/index.js +2 -0
  48. package/dist/execution/state.d.ts +136 -0
  49. package/dist/execution/state.js +82 -0
  50. package/dist/execution/store.d.ts +52 -0
  51. package/dist/execution/store.js +120 -0
  52. package/dist/index.d.ts +27 -0
  53. package/dist/index.js +57 -0
  54. package/dist/integration.test.d.ts +1 -0
  55. package/dist/integration.test.js +168 -0
  56. package/dist/interpreter/context.d.ts +15 -0
  57. package/dist/interpreter/context.js +29 -0
  58. package/dist/interpreter/evaluator.d.ts +5 -0
  59. package/dist/interpreter/evaluator.js +223 -0
  60. package/dist/interpreter/evaluator.test.d.ts +1 -0
  61. package/dist/interpreter/evaluator.test.js +512 -0
  62. package/dist/interpreter/executor.d.ts +131 -0
  63. package/dist/interpreter/executor.js +663 -0
  64. package/dist/interpreter/fetch-handler.d.ts +43 -0
  65. package/dist/interpreter/fetch-handler.js +203 -0
  66. package/dist/interpreter/http.d.ts +57 -0
  67. package/dist/interpreter/http.js +210 -0
  68. package/dist/interpreter/http.test.d.ts +1 -0
  69. package/dist/interpreter/http.test.js +299 -0
  70. package/dist/interpreter/index.d.ts +7 -0
  71. package/dist/interpreter/index.js +7 -0
  72. package/dist/interpreter/pagination.d.ts +63 -0
  73. package/dist/interpreter/pagination.js +155 -0
  74. package/dist/interpreter/progress.test.d.ts +1 -0
  75. package/dist/interpreter/progress.test.js +216 -0
  76. package/dist/interpreter/schema-matcher.d.ts +16 -0
  77. package/dist/interpreter/schema-matcher.js +136 -0
  78. package/dist/interpreter/schema-matcher.test.d.ts +1 -0
  79. package/dist/interpreter/schema-matcher.test.js +122 -0
  80. package/dist/interpreter/signals.d.ts +57 -0
  81. package/dist/interpreter/signals.js +73 -0
  82. package/dist/interpreter/step-handlers/for-handler.d.ts +17 -0
  83. package/dist/interpreter/step-handlers/for-handler.js +51 -0
  84. package/dist/interpreter/step-handlers/index.d.ts +8 -0
  85. package/dist/interpreter/step-handlers/index.js +8 -0
  86. package/dist/interpreter/step-handlers/map-handler.d.ts +10 -0
  87. package/dist/interpreter/step-handlers/map-handler.js +20 -0
  88. package/dist/interpreter/step-handlers/match-handler.d.ts +27 -0
  89. package/dist/interpreter/step-handlers/match-handler.js +61 -0
  90. package/dist/interpreter/step-handlers/store-handler.d.ts +13 -0
  91. package/dist/interpreter/step-handlers/store-handler.js +66 -0
  92. package/dist/interpreter/step-handlers/types.d.ts +15 -0
  93. package/dist/interpreter/step-handlers/types.js +1 -0
  94. package/dist/interpreter/step-handlers/validate-handler.d.ts +10 -0
  95. package/dist/interpreter/step-handlers/validate-handler.js +26 -0
  96. package/dist/interpreter/step-handlers/webhook-handler.d.ts +36 -0
  97. package/dist/interpreter/step-handlers/webhook-handler.js +104 -0
  98. package/dist/lexer/index.d.ts +10 -0
  99. package/dist/lexer/index.js +12 -0
  100. package/dist/lexer/lexer.d.ts +24 -0
  101. package/dist/lexer/lexer.js +264 -0
  102. package/dist/lexer/lexer.test.d.ts +1 -0
  103. package/dist/lexer/lexer.test.js +259 -0
  104. package/dist/lexer/tokens.d.ts +69 -0
  105. package/dist/lexer/tokens.js +146 -0
  106. package/dist/loader/index.d.ts +36 -0
  107. package/dist/loader/index.js +220 -0
  108. package/dist/loader/loader.test.d.ts +1 -0
  109. package/dist/loader/loader.test.js +287 -0
  110. package/dist/oas/index.d.ts +4 -0
  111. package/dist/oas/index.js +2 -0
  112. package/dist/oas/loader.d.ts +21 -0
  113. package/dist/oas/loader.js +82 -0
  114. package/dist/oas/oas.test.d.ts +1 -0
  115. package/dist/oas/oas.test.js +218 -0
  116. package/dist/oas/validator.d.ts +12 -0
  117. package/dist/oas/validator.js +227 -0
  118. package/dist/parser/base.d.ts +33 -0
  119. package/dist/parser/base.js +97 -0
  120. package/dist/parser/expressions.d.ts +27 -0
  121. package/dist/parser/expressions.js +248 -0
  122. package/dist/parser/expressions.test.d.ts +1 -0
  123. package/dist/parser/expressions.test.js +378 -0
  124. package/dist/parser/index.d.ts +3 -0
  125. package/dist/parser/index.js +3 -0
  126. package/dist/parser/match.test.d.ts +1 -0
  127. package/dist/parser/match.test.js +254 -0
  128. package/dist/parser/parser.d.ts +68 -0
  129. package/dist/parser/parser.js +1229 -0
  130. package/dist/parser/parser.test.d.ts +1 -0
  131. package/dist/parser/parser.test.js +333 -0
  132. package/dist/parser/schedule.test.d.ts +1 -0
  133. package/dist/parser/schedule.test.js +241 -0
  134. package/dist/plugin.d.ts +35 -0
  135. package/dist/plugin.js +68 -0
  136. package/dist/scheduler/cron-parser.d.ts +32 -0
  137. package/dist/scheduler/cron-parser.js +198 -0
  138. package/dist/scheduler/cron-parser.test.d.ts +1 -0
  139. package/dist/scheduler/cron-parser.test.js +188 -0
  140. package/dist/scheduler/index.d.ts +3 -0
  141. package/dist/scheduler/index.js +2 -0
  142. package/dist/scheduler/scheduler.d.ts +81 -0
  143. package/dist/scheduler/scheduler.js +376 -0
  144. package/dist/scheduler/types.d.ts +65 -0
  145. package/dist/scheduler/types.js +1 -0
  146. package/dist/stores/factory.d.ts +36 -0
  147. package/dist/stores/factory.js +73 -0
  148. package/dist/stores/file.d.ts +60 -0
  149. package/dist/stores/file.js +173 -0
  150. package/dist/stores/file.test.d.ts +1 -0
  151. package/dist/stores/file.test.js +165 -0
  152. package/dist/stores/index.d.ts +6 -0
  153. package/dist/stores/index.js +5 -0
  154. package/dist/stores/memory.d.ts +19 -0
  155. package/dist/stores/memory.js +51 -0
  156. package/dist/stores/memory.test.d.ts +1 -0
  157. package/dist/stores/memory.test.js +157 -0
  158. package/dist/stores/postgrest.d.ts +55 -0
  159. package/dist/stores/postgrest.js +217 -0
  160. package/dist/stores/stores.test.d.ts +1 -0
  161. package/dist/stores/stores.test.js +158 -0
  162. package/dist/stores/types.d.ts +31 -0
  163. package/dist/stores/types.js +26 -0
  164. package/dist/sync/index.d.ts +4 -0
  165. package/dist/sync/index.js +2 -0
  166. package/dist/sync/state.d.ts +69 -0
  167. package/dist/sync/state.js +66 -0
  168. package/dist/sync/store.d.ts +49 -0
  169. package/dist/sync/store.js +93 -0
  170. package/dist/sync/sync.test.d.ts +1 -0
  171. package/dist/sync/sync.test.js +221 -0
  172. package/dist/utils/async.d.ts +7 -0
  173. package/dist/utils/async.js +9 -0
  174. package/dist/utils/file.d.ts +38 -0
  175. package/dist/utils/file.js +92 -0
  176. package/dist/utils/index.d.ts +4 -0
  177. package/dist/utils/index.js +4 -0
  178. package/dist/utils/logger.d.ts +34 -0
  179. package/dist/utils/logger.js +39 -0
  180. package/dist/utils/path.d.ts +12 -0
  181. package/dist/utils/path.js +41 -0
  182. package/dist/webhook/index.d.ts +8 -0
  183. package/dist/webhook/index.js +7 -0
  184. package/dist/webhook/server.d.ts +84 -0
  185. package/dist/webhook/server.js +319 -0
  186. package/dist/webhook/store.d.ts +67 -0
  187. package/dist/webhook/store.js +193 -0
  188. package/dist/webhook/types.d.ts +88 -0
  189. package/dist/webhook/types.js +6 -0
  190. package/docusaurus/README.md +41 -0
  191. package/docusaurus/docs/advanced/execution-state.md +283 -0
  192. package/docusaurus/docs/advanced/extending-reqon.md +388 -0
  193. package/docusaurus/docs/advanced/multi-file-missions.md +250 -0
  194. package/docusaurus/docs/advanced/parallel-execution.md +353 -0
  195. package/docusaurus/docs/api-reference.md +443 -0
  196. package/docusaurus/docs/authentication/api-key.md +339 -0
  197. package/docusaurus/docs/authentication/basic.md +276 -0
  198. package/docusaurus/docs/authentication/bearer.md +282 -0
  199. package/docusaurus/docs/authentication/oauth2.md +317 -0
  200. package/docusaurus/docs/authentication/overview.md +251 -0
  201. package/docusaurus/docs/cli.md +229 -0
  202. package/docusaurus/docs/core-concepts/actions.md +286 -0
  203. package/docusaurus/docs/core-concepts/missions.md +264 -0
  204. package/docusaurus/docs/core-concepts/schemas.md +353 -0
  205. package/docusaurus/docs/core-concepts/sources.md +339 -0
  206. package/docusaurus/docs/core-concepts/stores.md +332 -0
  207. package/docusaurus/docs/dsl-syntax/expressions.md +361 -0
  208. package/docusaurus/docs/dsl-syntax/fetch.md +293 -0
  209. package/docusaurus/docs/dsl-syntax/for-loops.md +324 -0
  210. package/docusaurus/docs/dsl-syntax/map.md +345 -0
  211. package/docusaurus/docs/dsl-syntax/match.md +387 -0
  212. package/docusaurus/docs/dsl-syntax/pipelines.md +397 -0
  213. package/docusaurus/docs/dsl-syntax/validate.md +401 -0
  214. package/docusaurus/docs/error-handling/dead-letter-queues.md +399 -0
  215. package/docusaurus/docs/error-handling/flow-control.md +337 -0
  216. package/docusaurus/docs/error-handling/retry-strategies.md +368 -0
  217. package/docusaurus/docs/examples.md +488 -0
  218. package/docusaurus/docs/getting-started.md +256 -0
  219. package/docusaurus/docs/http/circuit-breaker.md +401 -0
  220. package/docusaurus/docs/http/incremental-sync.md +394 -0
  221. package/docusaurus/docs/http/pagination.md +361 -0
  222. package/docusaurus/docs/http/rate-limiting.md +383 -0
  223. package/docusaurus/docs/http/requests.md +328 -0
  224. package/docusaurus/docs/http/retry.md +402 -0
  225. package/docusaurus/docs/intro.md +90 -0
  226. package/docusaurus/docs/openapi/loading-specs.md +305 -0
  227. package/docusaurus/docs/openapi/operation-calls.md +314 -0
  228. package/docusaurus/docs/openapi/overview.md +212 -0
  229. package/docusaurus/docs/openapi/response-validation.md +344 -0
  230. package/docusaurus/docs/scheduling/cron.md +305 -0
  231. package/docusaurus/docs/scheduling/daemon-mode.md +317 -0
  232. package/docusaurus/docs/scheduling/intervals.md +289 -0
  233. package/docusaurus/docs/scheduling/overview.md +231 -0
  234. package/docusaurus/docs/stores/custom-adapters.md +376 -0
  235. package/docusaurus/docs/stores/file.md +236 -0
  236. package/docusaurus/docs/stores/memory.md +193 -0
  237. package/docusaurus/docs/stores/overview.md +274 -0
  238. package/docusaurus/docs/stores/postgrest.md +316 -0
  239. package/docusaurus/docusaurus.config.ts +148 -0
  240. package/docusaurus/package-lock.json +18029 -0
  241. package/docusaurus/package.json +47 -0
  242. package/docusaurus/sidebars.ts +155 -0
  243. package/docusaurus/src/components/HomepageFeatures/index.tsx +105 -0
  244. package/docusaurus/src/components/HomepageFeatures/styles.module.css +12 -0
  245. package/docusaurus/src/css/custom.css +169 -0
  246. package/docusaurus/src/pages/index.module.css +48 -0
  247. package/docusaurus/src/pages/index.tsx +110 -0
  248. package/docusaurus/src/pages/markdown-page.md +7 -0
  249. package/docusaurus/static/.nojekyll +0 -0
  250. package/docusaurus/static/img/docusaurus-social-card.jpg +0 -0
  251. package/docusaurus/static/img/docusaurus.png +0 -0
  252. package/docusaurus/static/img/favicon.ico +0 -0
  253. package/docusaurus/static/img/logo.svg +10 -0
  254. package/docusaurus/static/img/undraw_docusaurus_mountain.svg +171 -0
  255. package/docusaurus/static/img/undraw_docusaurus_react.svg +170 -0
  256. package/docusaurus/static/img/undraw_docusaurus_tree.svg +40 -0
  257. package/docusaurus/tsconfig.json +8 -0
  258. package/examples/README.md +112 -0
  259. package/examples/error-handling/README.md +150 -0
  260. package/examples/error-handling/payment-processor.vague +287 -0
  261. package/examples/github-sync/README.md +74 -0
  262. package/examples/github-sync/fetch-issues.vague +47 -0
  263. package/examples/github-sync/fetch-prs.vague +40 -0
  264. package/examples/github-sync/mission.vague +101 -0
  265. package/examples/github-sync/normalize.vague +70 -0
  266. package/examples/jsonplaceholder/README.md +28 -0
  267. package/examples/jsonplaceholder/posts.vague +48 -0
  268. package/examples/petstore/README.md +35 -0
  269. package/examples/petstore/openapi.yaml +97 -0
  270. package/examples/petstore/sync.vague +52 -0
  271. package/examples/temporal-comparison/README.md +297 -0
  272. package/examples/temporal-comparison/reconciliation.vague +355 -0
  273. package/examples/temporal-comparison/temporal/activities/index.ts +8 -0
  274. package/examples/temporal-comparison/temporal/activities/shipstation.ts +225 -0
  275. package/examples/temporal-comparison/temporal/activities/shopify.ts +257 -0
  276. package/examples/temporal-comparison/temporal/activities/storage.ts +198 -0
  277. package/examples/temporal-comparison/temporal/activities/stripe.ts +169 -0
  278. package/examples/temporal-comparison/temporal/activities/validation.ts +205 -0
  279. package/examples/temporal-comparison/temporal/client/schedule.ts +218 -0
  280. package/examples/temporal-comparison/temporal/config/retry.ts +63 -0
  281. package/examples/temporal-comparison/temporal/types/index.ts +129 -0
  282. package/examples/temporal-comparison/temporal/workers/main.ts +130 -0
  283. package/examples/temporal-comparison/temporal/workflows/orderReconciliation.ts +262 -0
  284. package/examples/xero/README.md +88 -0
  285. package/examples/xero/invoices.vague +189 -0
  286. package/package.json +40 -0
  287. package/src/api-integration.test.ts +954 -0
  288. package/src/ast/index.ts +1 -0
  289. package/src/ast/nodes.ts +310 -0
  290. package/src/auth/auth.test.ts +326 -0
  291. package/src/auth/circuit-breaker.test.ts +390 -0
  292. package/src/auth/circuit-breaker.ts +379 -0
  293. package/src/auth/credentials.test.ts +273 -0
  294. package/src/auth/credentials.ts +246 -0
  295. package/src/auth/index.ts +40 -0
  296. package/src/auth/oauth2-provider.ts +177 -0
  297. package/src/auth/rate-limiter.ts +459 -0
  298. package/src/auth/token-store.ts +177 -0
  299. package/src/auth/types.ts +159 -0
  300. package/src/benchmark/e2e.bench.ts +288 -0
  301. package/src/benchmark/evaluator.bench.ts +331 -0
  302. package/src/benchmark/fixtures.ts +295 -0
  303. package/src/benchmark/index.ts +108 -0
  304. package/src/benchmark/lexer.bench.ts +69 -0
  305. package/src/benchmark/parser.bench.ts +103 -0
  306. package/src/benchmark/resilience.bench.ts +193 -0
  307. package/src/benchmark/store.bench.ts +147 -0
  308. package/src/benchmark/utils.ts +230 -0
  309. package/src/cli.ts +313 -0
  310. package/src/errors/errors.test.ts +234 -0
  311. package/src/errors/index.ts +223 -0
  312. package/src/execution/execution.test.ts +307 -0
  313. package/src/execution/index.ts +21 -0
  314. package/src/execution/state.ts +207 -0
  315. package/src/execution/store.ts +188 -0
  316. package/src/index.ts +169 -0
  317. package/src/integration.test.ts +192 -0
  318. package/src/interpreter/context.ts +57 -0
  319. package/src/interpreter/evaluator.test.ts +796 -0
  320. package/src/interpreter/evaluator.ts +245 -0
  321. package/src/interpreter/executor.ts +946 -0
  322. package/src/interpreter/fetch-handler.ts +302 -0
  323. package/src/interpreter/http.test.ts +423 -0
  324. package/src/interpreter/http.ts +308 -0
  325. package/src/interpreter/index.ts +32 -0
  326. package/src/interpreter/pagination.ts +207 -0
  327. package/src/interpreter/progress.test.ts +276 -0
  328. package/src/interpreter/schema-matcher.test.ts +160 -0
  329. package/src/interpreter/schema-matcher.ts +168 -0
  330. package/src/interpreter/signals.ts +73 -0
  331. package/src/interpreter/step-handlers/for-handler.ts +65 -0
  332. package/src/interpreter/step-handlers/index.ts +17 -0
  333. package/src/interpreter/step-handlers/map-handler.ts +24 -0
  334. package/src/interpreter/step-handlers/match-handler.ts +101 -0
  335. package/src/interpreter/step-handlers/store-handler.ts +78 -0
  336. package/src/interpreter/step-handlers/types.ts +17 -0
  337. package/src/interpreter/step-handlers/validate-handler.ts +30 -0
  338. package/src/interpreter/step-handlers/webhook-handler.ts +142 -0
  339. package/src/lexer/index.ts +18 -0
  340. package/src/lexer/lexer.test.ts +316 -0
  341. package/src/lexer/tokens.ts +179 -0
  342. package/src/loader/index.ts +288 -0
  343. package/src/loader/loader.test.ts +360 -0
  344. package/src/oas/index.ts +4 -0
  345. package/src/oas/loader.ts +126 -0
  346. package/src/oas/oas.test.ts +254 -0
  347. package/src/oas/validator.ts +299 -0
  348. package/src/parser/base.ts +124 -0
  349. package/src/parser/expressions.test.ts +525 -0
  350. package/src/parser/expressions.ts +314 -0
  351. package/src/parser/index.ts +3 -0
  352. package/src/parser/match.test.ts +296 -0
  353. package/src/parser/parser.test.ts +739 -0
  354. package/src/parser/parser.ts +1469 -0
  355. package/src/parser/schedule.test.ts +287 -0
  356. package/src/parser/webhook.test.ts +248 -0
  357. package/src/plugin.ts +83 -0
  358. package/src/scheduler/cron-parser.test.ts +236 -0
  359. package/src/scheduler/cron-parser.ts +236 -0
  360. package/src/scheduler/index.ts +10 -0
  361. package/src/scheduler/scheduler.ts +443 -0
  362. package/src/scheduler/types.ts +71 -0
  363. package/src/stores/factory.ts +104 -0
  364. package/src/stores/file.test.ts +276 -0
  365. package/src/stores/file.ts +211 -0
  366. package/src/stores/index.ts +6 -0
  367. package/src/stores/memory.test.ts +238 -0
  368. package/src/stores/memory.ts +63 -0
  369. package/src/stores/postgrest.test.ts +488 -0
  370. package/src/stores/postgrest.ts +263 -0
  371. package/src/stores/stores.test.ts +197 -0
  372. package/src/stores/types.ts +58 -0
  373. package/src/sync/index.ts +16 -0
  374. package/src/sync/state.ts +126 -0
  375. package/src/sync/store.ts +139 -0
  376. package/src/sync/sync.test.ts +271 -0
  377. package/src/utils/async.ts +10 -0
  378. package/src/utils/file.ts +106 -0
  379. package/src/utils/index.ts +14 -0
  380. package/src/utils/logger.ts +53 -0
  381. package/src/utils/path.ts +47 -0
  382. package/src/webhook/index.ts +15 -0
  383. package/src/webhook/server.test.ts +253 -0
  384. package/src/webhook/server.ts +389 -0
  385. package/src/webhook/store.ts +239 -0
  386. package/src/webhook/types.ts +93 -0
  387. package/tsconfig.json +17 -0
  388. package/vitest.config.ts +39 -0
@@ -0,0 +1,1229 @@
1
+ import { TokenType } from 'vague-lang';
2
+ import { ReqonTokenType } from '../lexer/tokens.js';
3
+ import { ReqonExpressionParser } from './expressions.js';
4
+ export class ReqonParser extends ReqonExpressionParser {
5
+ constructor(tokens, source, filePath) {
6
+ super(tokens, source, filePath);
7
+ }
8
+ parse() {
9
+ const statements = [];
10
+ while (!this.isAtEnd()) {
11
+ const stmt = this.parseStatement();
12
+ if (stmt)
13
+ statements.push(stmt);
14
+ }
15
+ return { type: 'ReqonProgram', statements };
16
+ }
17
+ parseStatement() {
18
+ // Reqon-specific statements
19
+ if (this.check(ReqonTokenType.MISSION))
20
+ return this.parseMission();
21
+ if (this.check(ReqonTokenType.SOURCE))
22
+ return this.parseSource();
23
+ if (this.check(ReqonTokenType.STORE))
24
+ return this.parseStoreDefinition();
25
+ if (this.check(ReqonTokenType.ACTION))
26
+ return this.parseAction();
27
+ // Vague statements (schema, import, let, etc.)
28
+ if (this.check(TokenType.SCHEMA))
29
+ return this.parseSchema();
30
+ if (this.check(TokenType.IMPORT))
31
+ return this.parseImport();
32
+ if (this.check(TokenType.LET))
33
+ return this.parseLet();
34
+ throw this.error(`Unexpected token: ${this.peek().value}`);
35
+ }
36
+ // ============================================
37
+ // Mission definition
38
+ // ============================================
39
+ parseMission() {
40
+ this.consume(ReqonTokenType.MISSION, "Expected 'mission'");
41
+ const name = this.consume(TokenType.IDENTIFIER, 'Expected mission name').value;
42
+ this.consume(TokenType.LBRACE, "Expected '{'");
43
+ const sources = [];
44
+ const stores = [];
45
+ const schemas = [];
46
+ const actions = [];
47
+ let pipeline;
48
+ let schedule;
49
+ while (!this.check(TokenType.RBRACE) && !this.isAtEnd()) {
50
+ if (this.check(ReqonTokenType.SOURCE)) {
51
+ sources.push(this.parseSource());
52
+ }
53
+ else if (this.check(ReqonTokenType.STORE)) {
54
+ stores.push(this.parseStoreDefinition());
55
+ }
56
+ else if (this.check(TokenType.SCHEMA)) {
57
+ schemas.push(this.parseSchema());
58
+ }
59
+ else if (this.check(ReqonTokenType.ACTION)) {
60
+ actions.push(this.parseAction());
61
+ }
62
+ else if (this.check(ReqonTokenType.RUN)) {
63
+ pipeline = this.parsePipeline();
64
+ }
65
+ else if (this.check(ReqonTokenType.SCHEDULE)) {
66
+ schedule = this.parseSchedule();
67
+ }
68
+ else {
69
+ throw this.error(`Unexpected token in mission: ${this.peek().value}`);
70
+ }
71
+ this.match(TokenType.COMMA);
72
+ }
73
+ this.consume(TokenType.RBRACE, "Expected '}'");
74
+ if (!pipeline) {
75
+ throw this.error('Mission must have a run pipeline');
76
+ }
77
+ // Build sets of defined names for validation
78
+ const definedStores = new Set(stores.map((s) => s.name));
79
+ const definedActions = new Set(actions.map((a) => a.name));
80
+ const definedSources = new Set(sources.map((s) => s.name));
81
+ // Validate all references
82
+ this.validateActionReferences(actions, definedStores, definedSources, definedActions);
83
+ this.validatePipelineReferences(pipeline, definedActions);
84
+ return {
85
+ type: 'MissionDefinition',
86
+ name,
87
+ schedule,
88
+ sources,
89
+ stores,
90
+ schemas,
91
+ actions,
92
+ pipeline,
93
+ };
94
+ }
95
+ /**
96
+ * Validate that all store, source, and action references in actions exist
97
+ */
98
+ validateActionReferences(actions, definedStores, definedSources, definedActions) {
99
+ for (const action of actions) {
100
+ this.validateStepsReferences(action.steps, definedStores, definedSources, definedActions, action.name);
101
+ }
102
+ }
103
+ /**
104
+ * Recursively validate store, source, and action references in action steps
105
+ */
106
+ validateStepsReferences(steps, definedStores, definedSources, definedActions, actionName) {
107
+ for (const step of steps) {
108
+ if (step.type === 'StoreStep') {
109
+ if (!definedStores.has(step.target)) {
110
+ throw this.error(`Store '${step.target}' is not defined. ` +
111
+ `Available stores: ${[...definedStores].join(', ') || 'none'}`);
112
+ }
113
+ }
114
+ else if (step.type === 'FetchStep') {
115
+ // Validate source reference if specified
116
+ if (step.source && !definedSources.has(step.source)) {
117
+ throw this.error(`Source '${step.source}' is not defined. ` +
118
+ `Available sources: ${[...definedSources].join(', ') || 'none'}`);
119
+ }
120
+ // Validate operationRef source if present
121
+ if (step.operationRef && !definedSources.has(step.operationRef.source)) {
122
+ throw this.error(`Source '${step.operationRef.source}' is not defined. ` +
123
+ `Available sources: ${[...definedSources].join(', ') || 'none'}`);
124
+ }
125
+ }
126
+ else if (step.type === 'ForStep') {
127
+ // Recursively validate nested steps
128
+ this.validateStepsReferences(step.steps, definedStores, definedSources, definedActions, actionName);
129
+ }
130
+ else if (step.type === 'MatchStep') {
131
+ // Validate steps in match arms
132
+ for (const arm of step.arms) {
133
+ if (arm.steps) {
134
+ this.validateStepsReferences(arm.steps, definedStores, definedSources, definedActions, actionName);
135
+ }
136
+ // Validate jump target in flow directive
137
+ if (arm.flow?.type === 'jump' && !definedActions.has(arm.flow.action)) {
138
+ throw this.error(`Action '${arm.flow.action}' referenced in jump is not defined. ` +
139
+ `Available actions: ${[...definedActions].join(', ') || 'none'}`);
140
+ }
141
+ }
142
+ }
143
+ }
144
+ }
145
+ /**
146
+ * Validate that all action references in the pipeline exist
147
+ */
148
+ validatePipelineReferences(pipeline, definedActions) {
149
+ for (const stage of pipeline.stages) {
150
+ if (stage.action) {
151
+ if (!definedActions.has(stage.action)) {
152
+ throw this.error(`Action '${stage.action}' is not defined. ` +
153
+ `Available actions: ${[...definedActions].join(', ') || 'none'}`);
154
+ }
155
+ }
156
+ if (stage.actions) {
157
+ for (const actionName of stage.actions) {
158
+ if (!definedActions.has(actionName)) {
159
+ throw this.error(`Action '${actionName}' is not defined. ` +
160
+ `Available actions: ${[...definedActions].join(', ') || 'none'}`);
161
+ }
162
+ }
163
+ }
164
+ }
165
+ }
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
+ /**
1108
+ * Parse webhook storage config: { target: store_name, key: .id }
1109
+ */
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
+ parseImport() {
1216
+ this.consume(TokenType.IMPORT, "Expected 'import'");
1217
+ const name = this.consume(TokenType.IDENTIFIER, 'Expected import name').value;
1218
+ this.consume(TokenType.FROM, "Expected 'from'");
1219
+ const path = this.consume(TokenType.STRING, 'Expected import path').value;
1220
+ return { type: 'ImportStatement', name, path };
1221
+ }
1222
+ parseLet() {
1223
+ this.consume(TokenType.LET, "Expected 'let'");
1224
+ const name = this.consumeIdentifier('Expected variable name').value;
1225
+ this.consume(TokenType.EQUALS, "Expected '='");
1226
+ const value = this.parseExpression();
1227
+ return { type: 'LetStatement', name, value };
1228
+ }
1229
+ }