@angriff36/manifest 2.18.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/LICENSE +21 -0
- package/README.md +476 -0
- package/dist/manifest/agent-sdk/agent-runtime.d.ts +30 -0
- package/dist/manifest/agent-sdk/agent-runtime.d.ts.map +1 -0
- package/dist/manifest/agent-sdk/agent-runtime.js +232 -0
- package/dist/manifest/agent-sdk/agent-runtime.js.map +1 -0
- package/dist/manifest/agent-sdk/index.d.ts +17 -0
- package/dist/manifest/agent-sdk/index.d.ts.map +1 -0
- package/dist/manifest/agent-sdk/index.js +21 -0
- package/dist/manifest/agent-sdk/index.js.map +1 -0
- package/dist/manifest/agent-sdk/intent-mapper.d.ts +17 -0
- package/dist/manifest/agent-sdk/intent-mapper.d.ts.map +1 -0
- package/dist/manifest/agent-sdk/intent-mapper.js +115 -0
- package/dist/manifest/agent-sdk/intent-mapper.js.map +1 -0
- package/dist/manifest/agent-sdk/introspect.d.ts +42 -0
- package/dist/manifest/agent-sdk/introspect.d.ts.map +1 -0
- package/dist/manifest/agent-sdk/introspect.js +284 -0
- package/dist/manifest/agent-sdk/introspect.js.map +1 -0
- package/dist/manifest/agent-sdk/json-schema.d.ts +29 -0
- package/dist/manifest/agent-sdk/json-schema.d.ts.map +1 -0
- package/dist/manifest/agent-sdk/json-schema.js +132 -0
- package/dist/manifest/agent-sdk/json-schema.js.map +1 -0
- package/dist/manifest/agent-sdk/tool-definitions.d.ts +41 -0
- package/dist/manifest/agent-sdk/tool-definitions.d.ts.map +1 -0
- package/dist/manifest/agent-sdk/tool-definitions.js +288 -0
- package/dist/manifest/agent-sdk/tool-definitions.js.map +1 -0
- package/dist/manifest/agent-sdk/types.d.ts +293 -0
- package/dist/manifest/agent-sdk/types.d.ts.map +1 -0
- package/dist/manifest/agent-sdk/types.js +6 -0
- package/dist/manifest/agent-sdk/types.js.map +1 -0
- package/dist/manifest/api-diagnostics.d.ts +41 -0
- package/dist/manifest/api-diagnostics.d.ts.map +1 -0
- package/dist/manifest/api-diagnostics.js +105 -0
- package/dist/manifest/api-diagnostics.js.map +1 -0
- package/dist/manifest/approval/approval-store.d.ts +52 -0
- package/dist/manifest/approval/approval-store.d.ts.map +1 -0
- package/dist/manifest/approval/approval-store.js +25 -0
- package/dist/manifest/approval/approval-store.js.map +1 -0
- package/dist/manifest/approval/stores/memory.d.ts +33 -0
- package/dist/manifest/approval/stores/memory.d.ts.map +1 -0
- package/dist/manifest/approval/stores/memory.js +56 -0
- package/dist/manifest/approval/stores/memory.js.map +1 -0
- package/dist/manifest/approval/stores/postgres.d.ts +41 -0
- package/dist/manifest/approval/stores/postgres.d.ts.map +1 -0
- package/dist/manifest/approval/stores/postgres.js +124 -0
- package/dist/manifest/approval/stores/postgres.js.map +1 -0
- package/dist/manifest/audit/audit-sink.d.ts +53 -0
- package/dist/manifest/audit/audit-sink.d.ts.map +1 -0
- package/dist/manifest/audit/audit-sink.js +15 -0
- package/dist/manifest/audit/audit-sink.js.map +1 -0
- package/dist/manifest/audit/sinks/memory.d.ts +50 -0
- package/dist/manifest/audit/sinks/memory.d.ts.map +1 -0
- package/dist/manifest/audit/sinks/memory.js +66 -0
- package/dist/manifest/audit/sinks/memory.js.map +1 -0
- package/dist/manifest/audit/sinks/postgres.d.ts +31 -0
- package/dist/manifest/audit/sinks/postgres.d.ts.map +1 -0
- package/dist/manifest/audit/sinks/postgres.js +67 -0
- package/dist/manifest/audit/sinks/postgres.js.map +1 -0
- package/dist/manifest/binary-ir.d.ts +76 -0
- package/dist/manifest/binary-ir.d.ts.map +1 -0
- package/dist/manifest/binary-ir.js +124 -0
- package/dist/manifest/binary-ir.js.map +1 -0
- package/dist/manifest/breaking-change.d.ts +75 -0
- package/dist/manifest/breaking-change.d.ts.map +1 -0
- package/dist/manifest/breaking-change.js +704 -0
- package/dist/manifest/breaking-change.js.map +1 -0
- package/dist/manifest/compiler.d.ts +12 -0
- package/dist/manifest/compiler.d.ts.map +1 -0
- package/dist/manifest/compiler.js +23 -0
- package/dist/manifest/compiler.js.map +1 -0
- package/dist/manifest/config.d.ts +171 -0
- package/dist/manifest/config.d.ts.map +1 -0
- package/dist/manifest/config.js +65 -0
- package/dist/manifest/config.js.map +1 -0
- package/dist/manifest/constraint-analysis.d.ts +122 -0
- package/dist/manifest/constraint-analysis.d.ts.map +1 -0
- package/dist/manifest/constraint-analysis.js +340 -0
- package/dist/manifest/constraint-analysis.js.map +1 -0
- package/dist/manifest/date-time.d.ts +13 -0
- package/dist/manifest/date-time.d.ts.map +1 -0
- package/dist/manifest/date-time.js +60 -0
- package/dist/manifest/date-time.js.map +1 -0
- package/dist/manifest/debug/command-trace.d.ts +37 -0
- package/dist/manifest/debug/command-trace.d.ts.map +1 -0
- package/dist/manifest/debug/command-trace.js +51 -0
- package/dist/manifest/debug/command-trace.js.map +1 -0
- package/dist/manifest/debug/index.d.ts +3 -0
- package/dist/manifest/debug/index.d.ts.map +1 -0
- package/dist/manifest/debug/index.js +2 -0
- package/dist/manifest/debug/index.js.map +1 -0
- package/dist/manifest/domain-completeness.d.ts +13 -0
- package/dist/manifest/domain-completeness.d.ts.map +1 -0
- package/dist/manifest/domain-completeness.js +245 -0
- package/dist/manifest/domain-completeness.js.map +1 -0
- package/dist/manifest/entity-composition.d.ts +24 -0
- package/dist/manifest/entity-composition.d.ts.map +1 -0
- package/dist/manifest/entity-composition.js +157 -0
- package/dist/manifest/entity-composition.js.map +1 -0
- package/dist/manifest/examples.d.ts +6 -0
- package/dist/manifest/examples.d.ts.map +1 -0
- package/dist/manifest/examples.js +443 -0
- package/dist/manifest/examples.js.map +1 -0
- package/dist/manifest/federation/client.d.ts +52 -0
- package/dist/manifest/federation/client.d.ts.map +1 -0
- package/dist/manifest/federation/client.js +152 -0
- package/dist/manifest/federation/client.js.map +1 -0
- package/dist/manifest/federation/descriptor.d.ts +25 -0
- package/dist/manifest/federation/descriptor.d.ts.map +1 -0
- package/dist/manifest/federation/descriptor.js +97 -0
- package/dist/manifest/federation/descriptor.js.map +1 -0
- package/dist/manifest/federation/http-adapter.d.ts +26 -0
- package/dist/manifest/federation/http-adapter.d.ts.map +1 -0
- package/dist/manifest/federation/http-adapter.js +209 -0
- package/dist/manifest/federation/http-adapter.js.map +1 -0
- package/dist/manifest/federation/index.d.ts +51 -0
- package/dist/manifest/federation/index.d.ts.map +1 -0
- package/dist/manifest/federation/index.js +49 -0
- package/dist/manifest/federation/index.js.map +1 -0
- package/dist/manifest/federation/policy-bridge.d.ts +51 -0
- package/dist/manifest/federation/policy-bridge.d.ts.map +1 -0
- package/dist/manifest/federation/policy-bridge.js +122 -0
- package/dist/manifest/federation/policy-bridge.js.map +1 -0
- package/dist/manifest/federation/registry.d.ts +88 -0
- package/dist/manifest/federation/registry.d.ts.map +1 -0
- package/dist/manifest/federation/registry.js +165 -0
- package/dist/manifest/federation/registry.js.map +1 -0
- package/dist/manifest/federation/types.d.ts +209 -0
- package/dist/manifest/federation/types.d.ts.map +1 -0
- package/dist/manifest/federation/types.js +13 -0
- package/dist/manifest/federation/types.js.map +1 -0
- package/dist/manifest/generator.d.ts +44 -0
- package/dist/manifest/generator.d.ts.map +1 -0
- package/dist/manifest/generator.js +899 -0
- package/dist/manifest/generator.js.map +1 -0
- package/dist/manifest/ir-cache.d.ts +48 -0
- package/dist/manifest/ir-cache.d.ts.map +1 -0
- package/dist/manifest/ir-cache.js +91 -0
- package/dist/manifest/ir-cache.js.map +1 -0
- package/dist/manifest/ir-compiler.d.ts +135 -0
- package/dist/manifest/ir-compiler.d.ts.map +1 -0
- package/dist/manifest/ir-compiler.js +1477 -0
- package/dist/manifest/ir-compiler.js.map +1 -0
- package/dist/manifest/ir-diff.d.ts +266 -0
- package/dist/manifest/ir-diff.d.ts.map +1 -0
- package/dist/manifest/ir-diff.js +731 -0
- package/dist/manifest/ir-diff.js.map +1 -0
- package/dist/manifest/ir-version-store.d.ts +109 -0
- package/dist/manifest/ir-version-store.d.ts.map +1 -0
- package/dist/manifest/ir-version-store.js +162 -0
- package/dist/manifest/ir-version-store.js.map +1 -0
- package/dist/manifest/ir.d.ts +616 -0
- package/dist/manifest/ir.d.ts.map +1 -0
- package/dist/manifest/ir.js +2 -0
- package/dist/manifest/ir.js.map +1 -0
- package/dist/manifest/lexer.d.ts +37 -0
- package/dist/manifest/lexer.d.ts.map +1 -0
- package/dist/manifest/lexer.js +224 -0
- package/dist/manifest/lexer.js.map +1 -0
- package/dist/manifest/masking.d.ts +11 -0
- package/dist/manifest/masking.d.ts.map +1 -0
- package/dist/manifest/masking.js +34 -0
- package/dist/manifest/masking.js.map +1 -0
- package/dist/manifest/module-resolver.d.ts +42 -0
- package/dist/manifest/module-resolver.d.ts.map +1 -0
- package/dist/manifest/module-resolver.js +162 -0
- package/dist/manifest/module-resolver.js.map +1 -0
- package/dist/manifest/multi-compiler.d.ts +40 -0
- package/dist/manifest/multi-compiler.d.ts.map +1 -0
- package/dist/manifest/multi-compiler.js +324 -0
- package/dist/manifest/multi-compiler.js.map +1 -0
- package/dist/manifest/outbox/outbox-store.d.ts +56 -0
- package/dist/manifest/outbox/outbox-store.d.ts.map +1 -0
- package/dist/manifest/outbox/outbox-store.js +13 -0
- package/dist/manifest/outbox/outbox-store.js.map +1 -0
- package/dist/manifest/outbox/stores/dynamodb.d.ts +100 -0
- package/dist/manifest/outbox/stores/dynamodb.d.ts.map +1 -0
- package/dist/manifest/outbox/stores/dynamodb.js +239 -0
- package/dist/manifest/outbox/stores/dynamodb.js.map +1 -0
- package/dist/manifest/outbox/stores/memory.d.ts +54 -0
- package/dist/manifest/outbox/stores/memory.d.ts.map +1 -0
- package/dist/manifest/outbox/stores/memory.js +131 -0
- package/dist/manifest/outbox/stores/memory.js.map +1 -0
- package/dist/manifest/outbox/stores/mongodb.d.ts +58 -0
- package/dist/manifest/outbox/stores/mongodb.d.ts.map +1 -0
- package/dist/manifest/outbox/stores/mongodb.js +151 -0
- package/dist/manifest/outbox/stores/mongodb.js.map +1 -0
- package/dist/manifest/outbox/stores/postgres.d.ts +81 -0
- package/dist/manifest/outbox/stores/postgres.d.ts.map +1 -0
- package/dist/manifest/outbox/stores/postgres.js +182 -0
- package/dist/manifest/outbox/stores/postgres.js.map +1 -0
- package/dist/manifest/outbox/stores/redis.d.ts +95 -0
- package/dist/manifest/outbox/stores/redis.d.ts.map +1 -0
- package/dist/manifest/outbox/stores/redis.js +248 -0
- package/dist/manifest/outbox/stores/redis.js.map +1 -0
- package/dist/manifest/parser.d.ts +148 -0
- package/dist/manifest/parser.d.ts.map +1 -0
- package/dist/manifest/parser.js +2243 -0
- package/dist/manifest/parser.js.map +1 -0
- package/dist/manifest/plugin-api.d.ts +202 -0
- package/dist/manifest/plugin-api.d.ts.map +1 -0
- package/dist/manifest/plugin-api.js +101 -0
- package/dist/manifest/plugin-api.js.map +1 -0
- package/dist/manifest/plugin-loader.d.ts +101 -0
- package/dist/manifest/plugin-loader.d.ts.map +1 -0
- package/dist/manifest/plugin-loader.js +332 -0
- package/dist/manifest/plugin-loader.js.map +1 -0
- package/dist/manifest/profiling.d.ts +183 -0
- package/dist/manifest/profiling.d.ts.map +1 -0
- package/dist/manifest/profiling.js +186 -0
- package/dist/manifest/profiling.js.map +1 -0
- package/dist/manifest/projections/analytics/generator.d.ts +27 -0
- package/dist/manifest/projections/analytics/generator.d.ts.map +1 -0
- package/dist/manifest/projections/analytics/generator.js +686 -0
- package/dist/manifest/projections/analytics/generator.js.map +1 -0
- package/dist/manifest/projections/analytics/types.d.ts +46 -0
- package/dist/manifest/projections/analytics/types.d.ts.map +1 -0
- package/dist/manifest/projections/analytics/types.js +8 -0
- package/dist/manifest/projections/analytics/types.js.map +1 -0
- package/dist/manifest/projections/builtins.d.ts +29 -0
- package/dist/manifest/projections/builtins.d.ts.map +1 -0
- package/dist/manifest/projections/builtins.js +143 -0
- package/dist/manifest/projections/builtins.js.map +1 -0
- package/dist/manifest/projections/convex/expression.d.ts +52 -0
- package/dist/manifest/projections/convex/expression.d.ts.map +1 -0
- package/dist/manifest/projections/convex/expression.js +166 -0
- package/dist/manifest/projections/convex/expression.js.map +1 -0
- package/dist/manifest/projections/convex/functions.d.ts +22 -0
- package/dist/manifest/projections/convex/functions.d.ts.map +1 -0
- package/dist/manifest/projections/convex/functions.js +786 -0
- package/dist/manifest/projections/convex/functions.js.map +1 -0
- package/dist/manifest/projections/convex/generator.d.ts +79 -0
- package/dist/manifest/projections/convex/generator.d.ts.map +1 -0
- package/dist/manifest/projections/convex/generator.js +406 -0
- package/dist/manifest/projections/convex/generator.js.map +1 -0
- package/dist/manifest/projections/convex/index.d.ts +10 -0
- package/dist/manifest/projections/convex/index.d.ts.map +1 -0
- package/dist/manifest/projections/convex/index.js +10 -0
- package/dist/manifest/projections/convex/index.js.map +1 -0
- package/dist/manifest/projections/convex/options.d.ts +153 -0
- package/dist/manifest/projections/convex/options.d.ts.map +1 -0
- package/dist/manifest/projections/convex/options.js +60 -0
- package/dist/manifest/projections/convex/options.js.map +1 -0
- package/dist/manifest/projections/convex/orchestration.d.ts +23 -0
- package/dist/manifest/projections/convex/orchestration.d.ts.map +1 -0
- package/dist/manifest/projections/convex/orchestration.js +150 -0
- package/dist/manifest/projections/convex/orchestration.js.map +1 -0
- package/dist/manifest/projections/convex/type-mapping.d.ts +40 -0
- package/dist/manifest/projections/convex/type-mapping.d.ts.map +1 -0
- package/dist/manifest/projections/convex/type-mapping.js +71 -0
- package/dist/manifest/projections/convex/type-mapping.js.map +1 -0
- package/dist/manifest/projections/dart/generator.d.ts +33 -0
- package/dist/manifest/projections/dart/generator.d.ts.map +1 -0
- package/dist/manifest/projections/dart/generator.js +981 -0
- package/dist/manifest/projections/dart/generator.js.map +1 -0
- package/dist/manifest/projections/dart/types.d.ts +29 -0
- package/dist/manifest/projections/dart/types.d.ts.map +1 -0
- package/dist/manifest/projections/dart/types.js +5 -0
- package/dist/manifest/projections/dart/types.js.map +1 -0
- package/dist/manifest/projections/drizzle/generator.d.ts +27 -0
- package/dist/manifest/projections/drizzle/generator.d.ts.map +1 -0
- package/dist/manifest/projections/drizzle/generator.js +654 -0
- package/dist/manifest/projections/drizzle/generator.js.map +1 -0
- package/dist/manifest/projections/drizzle/index.d.ts +12 -0
- package/dist/manifest/projections/drizzle/index.d.ts.map +1 -0
- package/dist/manifest/projections/drizzle/index.js +12 -0
- package/dist/manifest/projections/drizzle/index.js.map +1 -0
- package/dist/manifest/projections/drizzle/options.d.ts +94 -0
- package/dist/manifest/projections/drizzle/options.d.ts.map +1 -0
- package/dist/manifest/projections/drizzle/options.js +31 -0
- package/dist/manifest/projections/drizzle/options.js.map +1 -0
- package/dist/manifest/projections/drizzle/type-mapping.d.ts +74 -0
- package/dist/manifest/projections/drizzle/type-mapping.d.ts.map +1 -0
- package/dist/manifest/projections/drizzle/type-mapping.js +101 -0
- package/dist/manifest/projections/drizzle/type-mapping.js.map +1 -0
- package/dist/manifest/projections/dynamodb/generator.d.ts +48 -0
- package/dist/manifest/projections/dynamodb/generator.d.ts.map +1 -0
- package/dist/manifest/projections/dynamodb/generator.js +341 -0
- package/dist/manifest/projections/dynamodb/generator.js.map +1 -0
- package/dist/manifest/projections/elasticsearch/generator.d.ts +44 -0
- package/dist/manifest/projections/elasticsearch/generator.d.ts.map +1 -0
- package/dist/manifest/projections/elasticsearch/generator.js +613 -0
- package/dist/manifest/projections/elasticsearch/generator.js.map +1 -0
- package/dist/manifest/projections/elasticsearch/options.d.ts +56 -0
- package/dist/manifest/projections/elasticsearch/options.d.ts.map +1 -0
- package/dist/manifest/projections/elasticsearch/options.js +37 -0
- package/dist/manifest/projections/elasticsearch/options.js.map +1 -0
- package/dist/manifest/projections/elasticsearch/type-mapping.d.ts +30 -0
- package/dist/manifest/projections/elasticsearch/type-mapping.d.ts.map +1 -0
- package/dist/manifest/projections/elasticsearch/type-mapping.js +34 -0
- package/dist/manifest/projections/elasticsearch/type-mapping.js.map +1 -0
- package/dist/manifest/projections/elasticsearch/types.d.ts +81 -0
- package/dist/manifest/projections/elasticsearch/types.d.ts.map +1 -0
- package/dist/manifest/projections/elasticsearch/types.js +10 -0
- package/dist/manifest/projections/elasticsearch/types.js.map +1 -0
- package/dist/manifest/projections/express/generator.d.ts +38 -0
- package/dist/manifest/projections/express/generator.d.ts.map +1 -0
- package/dist/manifest/projections/express/generator.js +620 -0
- package/dist/manifest/projections/express/generator.js.map +1 -0
- package/dist/manifest/projections/express/index.d.ts +8 -0
- package/dist/manifest/projections/express/index.d.ts.map +1 -0
- package/dist/manifest/projections/express/index.js +7 -0
- package/dist/manifest/projections/express/index.js.map +1 -0
- package/dist/manifest/projections/express/types.d.ts +92 -0
- package/dist/manifest/projections/express/types.d.ts.map +1 -0
- package/dist/manifest/projections/express/types.js +9 -0
- package/dist/manifest/projections/express/types.js.map +1 -0
- package/dist/manifest/projections/graphql/generator.d.ts +43 -0
- package/dist/manifest/projections/graphql/generator.d.ts.map +1 -0
- package/dist/manifest/projections/graphql/generator.js +662 -0
- package/dist/manifest/projections/graphql/generator.js.map +1 -0
- package/dist/manifest/projections/graphql/index.d.ts +11 -0
- package/dist/manifest/projections/graphql/index.d.ts.map +1 -0
- package/dist/manifest/projections/graphql/index.js +10 -0
- package/dist/manifest/projections/graphql/index.js.map +1 -0
- package/dist/manifest/projections/graphql/types.d.ts +69 -0
- package/dist/manifest/projections/graphql/types.d.ts.map +1 -0
- package/dist/manifest/projections/graphql/types.js +9 -0
- package/dist/manifest/projections/graphql/types.js.map +1 -0
- package/dist/manifest/projections/health/generator.d.ts +36 -0
- package/dist/manifest/projections/health/generator.d.ts.map +1 -0
- package/dist/manifest/projections/health/generator.js +355 -0
- package/dist/manifest/projections/health/generator.js.map +1 -0
- package/dist/manifest/projections/health/types.d.ts +67 -0
- package/dist/manifest/projections/health/types.d.ts.map +1 -0
- package/dist/manifest/projections/health/types.js +28 -0
- package/dist/manifest/projections/health/types.js.map +1 -0
- package/dist/manifest/projections/hono/generator.d.ts +36 -0
- package/dist/manifest/projections/hono/generator.d.ts.map +1 -0
- package/dist/manifest/projections/hono/generator.js +578 -0
- package/dist/manifest/projections/hono/generator.js.map +1 -0
- package/dist/manifest/projections/hono/types.d.ts +86 -0
- package/dist/manifest/projections/hono/types.d.ts.map +1 -0
- package/dist/manifest/projections/hono/types.js +10 -0
- package/dist/manifest/projections/hono/types.js.map +1 -0
- package/dist/manifest/projections/index.d.ts +58 -0
- package/dist/manifest/projections/index.d.ts.map +1 -0
- package/dist/manifest/projections/index.js +41 -0
- package/dist/manifest/projections/index.js.map +1 -0
- package/dist/manifest/projections/interface.d.ts +285 -0
- package/dist/manifest/projections/interface.d.ts.map +1 -0
- package/dist/manifest/projections/interface.js +8 -0
- package/dist/manifest/projections/interface.js.map +1 -0
- package/dist/manifest/projections/jsonschema/generator.d.ts +35 -0
- package/dist/manifest/projections/jsonschema/generator.d.ts.map +1 -0
- package/dist/manifest/projections/jsonschema/generator.js +347 -0
- package/dist/manifest/projections/jsonschema/generator.js.map +1 -0
- package/dist/manifest/projections/jsonschema/index.d.ts +3 -0
- package/dist/manifest/projections/jsonschema/index.d.ts.map +1 -0
- package/dist/manifest/projections/jsonschema/index.js +2 -0
- package/dist/manifest/projections/jsonschema/index.js.map +1 -0
- package/dist/manifest/projections/jsonschema/types.d.ts +31 -0
- package/dist/manifest/projections/jsonschema/types.d.ts.map +1 -0
- package/dist/manifest/projections/jsonschema/types.js +2 -0
- package/dist/manifest/projections/jsonschema/types.js.map +1 -0
- package/dist/manifest/projections/kysely/generator.d.ts +36 -0
- package/dist/manifest/projections/kysely/generator.d.ts.map +1 -0
- package/dist/manifest/projections/kysely/generator.js +325 -0
- package/dist/manifest/projections/kysely/generator.js.map +1 -0
- package/dist/manifest/projections/kysely/index.d.ts +4 -0
- package/dist/manifest/projections/kysely/index.d.ts.map +1 -0
- package/dist/manifest/projections/kysely/index.js +2 -0
- package/dist/manifest/projections/kysely/index.js.map +1 -0
- package/dist/manifest/projections/kysely/options.d.ts +61 -0
- package/dist/manifest/projections/kysely/options.d.ts.map +1 -0
- package/dist/manifest/projections/kysely/options.js +31 -0
- package/dist/manifest/projections/kysely/options.js.map +1 -0
- package/dist/manifest/projections/kysely/type-mapping.d.ts +61 -0
- package/dist/manifest/projections/kysely/type-mapping.d.ts.map +1 -0
- package/dist/manifest/projections/kysely/type-mapping.js +84 -0
- package/dist/manifest/projections/kysely/type-mapping.js.map +1 -0
- package/dist/manifest/projections/llm-context/generator.d.ts +24 -0
- package/dist/manifest/projections/llm-context/generator.d.ts.map +1 -0
- package/dist/manifest/projections/llm-context/generator.js +371 -0
- package/dist/manifest/projections/llm-context/generator.js.map +1 -0
- package/dist/manifest/projections/llm-context/types.d.ts +205 -0
- package/dist/manifest/projections/llm-context/types.d.ts.map +1 -0
- package/dist/manifest/projections/llm-context/types.js +9 -0
- package/dist/manifest/projections/llm-context/types.js.map +1 -0
- package/dist/manifest/projections/materialized-views/expression-to-sql.d.ts +29 -0
- package/dist/manifest/projections/materialized-views/expression-to-sql.d.ts.map +1 -0
- package/dist/manifest/projections/materialized-views/expression-to-sql.js +211 -0
- package/dist/manifest/projections/materialized-views/expression-to-sql.js.map +1 -0
- package/dist/manifest/projections/materialized-views/generator.d.ts +29 -0
- package/dist/manifest/projections/materialized-views/generator.d.ts.map +1 -0
- package/dist/manifest/projections/materialized-views/generator.js +263 -0
- package/dist/manifest/projections/materialized-views/generator.js.map +1 -0
- package/dist/manifest/projections/materialized-views/options.d.ts +59 -0
- package/dist/manifest/projections/materialized-views/options.d.ts.map +1 -0
- package/dist/manifest/projections/materialized-views/options.js +34 -0
- package/dist/manifest/projections/materialized-views/options.js.map +1 -0
- package/dist/manifest/projections/materialized-views/types.d.ts +100 -0
- package/dist/manifest/projections/materialized-views/types.d.ts.map +1 -0
- package/dist/manifest/projections/materialized-views/types.js +11 -0
- package/dist/manifest/projections/materialized-views/types.js.map +1 -0
- package/dist/manifest/projections/mermaid/generator.d.ts +46 -0
- package/dist/manifest/projections/mermaid/generator.d.ts.map +1 -0
- package/dist/manifest/projections/mermaid/generator.js +436 -0
- package/dist/manifest/projections/mermaid/generator.js.map +1 -0
- package/dist/manifest/projections/mongoose/options.d.ts +30 -0
- package/dist/manifest/projections/mongoose/options.d.ts.map +1 -0
- package/dist/manifest/projections/mongoose/options.js +18 -0
- package/dist/manifest/projections/mongoose/options.js.map +1 -0
- package/dist/manifest/projections/mongoose/type-mapping.d.ts +42 -0
- package/dist/manifest/projections/mongoose/type-mapping.d.ts.map +1 -0
- package/dist/manifest/projections/mongoose/type-mapping.js +64 -0
- package/dist/manifest/projections/mongoose/type-mapping.js.map +1 -0
- package/dist/manifest/projections/nextjs/defaults.d.ts +161 -0
- package/dist/manifest/projections/nextjs/defaults.d.ts.map +1 -0
- package/dist/manifest/projections/nextjs/defaults.js +157 -0
- package/dist/manifest/projections/nextjs/defaults.js.map +1 -0
- package/dist/manifest/projections/nextjs/generator.d.ts +78 -0
- package/dist/manifest/projections/nextjs/generator.d.ts.map +1 -0
- package/dist/manifest/projections/nextjs/generator.js +1339 -0
- package/dist/manifest/projections/nextjs/generator.js.map +1 -0
- package/dist/manifest/projections/nextjs/schedule-generator.d.ts +10 -0
- package/dist/manifest/projections/nextjs/schedule-generator.d.ts.map +1 -0
- package/dist/manifest/projections/nextjs/schedule-generator.js +54 -0
- package/dist/manifest/projections/nextjs/schedule-generator.js.map +1 -0
- package/dist/manifest/projections/openapi/generator.d.ts +37 -0
- package/dist/manifest/projections/openapi/generator.d.ts.map +1 -0
- package/dist/manifest/projections/openapi/generator.js +690 -0
- package/dist/manifest/projections/openapi/generator.js.map +1 -0
- package/dist/manifest/projections/openapi/index.d.ts +11 -0
- package/dist/manifest/projections/openapi/index.d.ts.map +1 -0
- package/dist/manifest/projections/openapi/index.js +10 -0
- package/dist/manifest/projections/openapi/index.js.map +1 -0
- package/dist/manifest/projections/openapi/types.d.ts +75 -0
- package/dist/manifest/projections/openapi/types.d.ts.map +1 -0
- package/dist/manifest/projections/openapi/types.js +9 -0
- package/dist/manifest/projections/openapi/types.js.map +1 -0
- package/dist/manifest/projections/prisma/generator.d.ts +32 -0
- package/dist/manifest/projections/prisma/generator.d.ts.map +1 -0
- package/dist/manifest/projections/prisma/generator.js +861 -0
- package/dist/manifest/projections/prisma/generator.js.map +1 -0
- package/dist/manifest/projections/prisma/index.d.ts +12 -0
- package/dist/manifest/projections/prisma/index.d.ts.map +1 -0
- package/dist/manifest/projections/prisma/index.js +12 -0
- package/dist/manifest/projections/prisma/index.js.map +1 -0
- package/dist/manifest/projections/prisma/options.d.ts +243 -0
- package/dist/manifest/projections/prisma/options.d.ts.map +1 -0
- package/dist/manifest/projections/prisma/options.js +59 -0
- package/dist/manifest/projections/prisma/options.js.map +1 -0
- package/dist/manifest/projections/prisma/type-mapping.d.ts +60 -0
- package/dist/manifest/projections/prisma/type-mapping.d.ts.map +1 -0
- package/dist/manifest/projections/prisma/type-mapping.js +95 -0
- package/dist/manifest/projections/prisma/type-mapping.js.map +1 -0
- package/dist/manifest/projections/prisma-store/generator.d.ts +12 -0
- package/dist/manifest/projections/prisma-store/generator.d.ts.map +1 -0
- package/dist/manifest/projections/prisma-store/generator.js +52 -0
- package/dist/manifest/projections/prisma-store/generator.js.map +1 -0
- package/dist/manifest/projections/prisma-store/metadata-builder.d.ts +11 -0
- package/dist/manifest/projections/prisma-store/metadata-builder.d.ts.map +1 -0
- package/dist/manifest/projections/prisma-store/metadata-builder.js +183 -0
- package/dist/manifest/projections/prisma-store/metadata-builder.js.map +1 -0
- package/dist/manifest/projections/prisma-store/options.d.ts +31 -0
- package/dist/manifest/projections/prisma-store/options.d.ts.map +1 -0
- package/dist/manifest/projections/prisma-store/options.js +21 -0
- package/dist/manifest/projections/prisma-store/options.js.map +1 -0
- package/dist/manifest/projections/prisma-store/persistence.d.ts +4 -0
- package/dist/manifest/projections/prisma-store/persistence.d.ts.map +1 -0
- package/dist/manifest/projections/prisma-store/persistence.js +24 -0
- package/dist/manifest/projections/prisma-store/persistence.js.map +1 -0
- package/dist/manifest/projections/pydantic/generator.d.ts +27 -0
- package/dist/manifest/projections/pydantic/generator.d.ts.map +1 -0
- package/dist/manifest/projections/pydantic/generator.js +798 -0
- package/dist/manifest/projections/pydantic/generator.js.map +1 -0
- package/dist/manifest/projections/pydantic/types.d.ts +32 -0
- package/dist/manifest/projections/pydantic/types.d.ts.map +1 -0
- package/dist/manifest/projections/pydantic/types.js +5 -0
- package/dist/manifest/projections/pydantic/types.js.map +1 -0
- package/dist/manifest/projections/react-query/generator.d.ts +87 -0
- package/dist/manifest/projections/react-query/generator.d.ts.map +1 -0
- package/dist/manifest/projections/react-query/generator.js +413 -0
- package/dist/manifest/projections/react-query/generator.js.map +1 -0
- package/dist/manifest/projections/registry.d.ts +59 -0
- package/dist/manifest/projections/registry.d.ts.map +1 -0
- package/dist/manifest/projections/registry.js +110 -0
- package/dist/manifest/projections/registry.js.map +1 -0
- package/dist/manifest/projections/remix/generator.d.ts +58 -0
- package/dist/manifest/projections/remix/generator.d.ts.map +1 -0
- package/dist/manifest/projections/remix/generator.js +788 -0
- package/dist/manifest/projections/remix/generator.js.map +1 -0
- package/dist/manifest/projections/routes/generator.d.ts +32 -0
- package/dist/manifest/projections/routes/generator.d.ts.map +1 -0
- package/dist/manifest/projections/routes/generator.js +401 -0
- package/dist/manifest/projections/routes/generator.js.map +1 -0
- package/dist/manifest/projections/routes/types.d.ts +104 -0
- package/dist/manifest/projections/routes/types.d.ts.map +1 -0
- package/dist/manifest/projections/routes/types.js +11 -0
- package/dist/manifest/projections/routes/types.js.map +1 -0
- package/dist/manifest/projections/shared/naming.d.ts +64 -0
- package/dist/manifest/projections/shared/naming.d.ts.map +1 -0
- package/dist/manifest/projections/shared/naming.js +138 -0
- package/dist/manifest/projections/shared/naming.js.map +1 -0
- package/dist/manifest/projections/storybook/generator.d.ts +38 -0
- package/dist/manifest/projections/storybook/generator.d.ts.map +1 -0
- package/dist/manifest/projections/storybook/generator.js +462 -0
- package/dist/manifest/projections/storybook/generator.js.map +1 -0
- package/dist/manifest/projections/sveltekit/generator.d.ts +64 -0
- package/dist/manifest/projections/sveltekit/generator.d.ts.map +1 -0
- package/dist/manifest/projections/sveltekit/generator.js +1043 -0
- package/dist/manifest/projections/sveltekit/generator.js.map +1 -0
- package/dist/manifest/projections/sveltekit/index.d.ts +11 -0
- package/dist/manifest/projections/sveltekit/index.d.ts.map +1 -0
- package/dist/manifest/projections/sveltekit/index.js +10 -0
- package/dist/manifest/projections/sveltekit/index.js.map +1 -0
- package/dist/manifest/projections/sveltekit/types.d.ts +122 -0
- package/dist/manifest/projections/sveltekit/types.d.ts.map +1 -0
- package/dist/manifest/projections/sveltekit/types.js +10 -0
- package/dist/manifest/projections/sveltekit/types.js.map +1 -0
- package/dist/manifest/projections/terraform/generator.d.ts +29 -0
- package/dist/manifest/projections/terraform/generator.d.ts.map +1 -0
- package/dist/manifest/projections/terraform/generator.js +722 -0
- package/dist/manifest/projections/terraform/generator.js.map +1 -0
- package/dist/manifest/projections/terraform/index.d.ts +7 -0
- package/dist/manifest/projections/terraform/index.d.ts.map +1 -0
- package/dist/manifest/projections/terraform/index.js +7 -0
- package/dist/manifest/projections/terraform/index.js.map +1 -0
- package/dist/manifest/projections/terraform/options.d.ts +92 -0
- package/dist/manifest/projections/terraform/options.d.ts.map +1 -0
- package/dist/manifest/projections/terraform/options.js +37 -0
- package/dist/manifest/projections/terraform/options.js.map +1 -0
- package/dist/manifest/projections/terraform/types.d.ts +55 -0
- package/dist/manifest/projections/terraform/types.d.ts.map +1 -0
- package/dist/manifest/projections/terraform/types.js +38 -0
- package/dist/manifest/projections/terraform/types.js.map +1 -0
- package/dist/manifest/projections/zod/generator.d.ts +27 -0
- package/dist/manifest/projections/zod/generator.d.ts.map +1 -0
- package/dist/manifest/projections/zod/generator.js +367 -0
- package/dist/manifest/projections/zod/generator.js.map +1 -0
- package/dist/manifest/projections/zod/index.d.ts +8 -0
- package/dist/manifest/projections/zod/index.d.ts.map +1 -0
- package/dist/manifest/projections/zod/index.js +7 -0
- package/dist/manifest/projections/zod/index.js.map +1 -0
- package/dist/manifest/projections/zod/types.d.ts +14 -0
- package/dist/manifest/projections/zod/types.d.ts.map +1 -0
- package/dist/manifest/projections/zod/types.js +5 -0
- package/dist/manifest/projections/zod/types.js.map +1 -0
- package/dist/manifest/reaction-completeness-checks.d.ts +11 -0
- package/dist/manifest/reaction-completeness-checks.d.ts.map +1 -0
- package/dist/manifest/reaction-completeness-checks.js +106 -0
- package/dist/manifest/reaction-completeness-checks.js.map +1 -0
- package/dist/manifest/reaction-completeness.d.ts +9 -0
- package/dist/manifest/reaction-completeness.d.ts.map +1 -0
- package/dist/manifest/reaction-completeness.js +35 -0
- package/dist/manifest/reaction-completeness.js.map +1 -0
- package/dist/manifest/registry/emit.d.ts +53 -0
- package/dist/manifest/registry/emit.d.ts.map +1 -0
- package/dist/manifest/registry/emit.js +96 -0
- package/dist/manifest/registry/emit.js.map +1 -0
- package/dist/manifest/runtime-command-extensions.d.ts +21 -0
- package/dist/manifest/runtime-command-extensions.d.ts.map +1 -0
- package/dist/manifest/runtime-command-extensions.js +136 -0
- package/dist/manifest/runtime-command-extensions.js.map +1 -0
- package/dist/manifest/runtime-engine.d.ts +1019 -0
- package/dist/manifest/runtime-engine.d.ts.map +1 -0
- package/dist/manifest/runtime-engine.js +3872 -0
- package/dist/manifest/runtime-engine.js.map +1 -0
- package/dist/manifest/runtime-profiling-bridge.d.ts +22 -0
- package/dist/manifest/runtime-profiling-bridge.d.ts.map +1 -0
- package/dist/manifest/runtime-profiling-bridge.js +69 -0
- package/dist/manifest/runtime-profiling-bridge.js.map +1 -0
- package/dist/manifest/runtime-rate-limit.d.ts +52 -0
- package/dist/manifest/runtime-rate-limit.d.ts.map +1 -0
- package/dist/manifest/runtime-rate-limit.js +70 -0
- package/dist/manifest/runtime-rate-limit.js.map +1 -0
- package/dist/manifest/runtime-retry.d.ts +68 -0
- package/dist/manifest/runtime-retry.d.ts.map +1 -0
- package/dist/manifest/runtime-retry.js +93 -0
- package/dist/manifest/runtime-retry.js.map +1 -0
- package/dist/manifest/runtime-schedule.d.ts +47 -0
- package/dist/manifest/runtime-schedule.d.ts.map +1 -0
- package/dist/manifest/runtime-schedule.js +95 -0
- package/dist/manifest/runtime-schedule.js.map +1 -0
- package/dist/manifest/schedule-utils.d.ts +15 -0
- package/dist/manifest/schedule-utils.d.ts.map +1 -0
- package/dist/manifest/schedule-utils.js +82 -0
- package/dist/manifest/schedule-utils.js.map +1 -0
- package/dist/manifest/standalone-generator.d.ts +32 -0
- package/dist/manifest/standalone-generator.d.ts.map +1 -0
- package/dist/manifest/standalone-generator.js +596 -0
- package/dist/manifest/standalone-generator.js.map +1 -0
- package/dist/manifest/stores/prisma-generic/coercion.d.ts +17 -0
- package/dist/manifest/stores/prisma-generic/coercion.d.ts.map +1 -0
- package/dist/manifest/stores/prisma-generic/coercion.js +83 -0
- package/dist/manifest/stores/prisma-generic/coercion.js.map +1 -0
- package/dist/manifest/stores/prisma-generic/index.d.ts +3 -0
- package/dist/manifest/stores/prisma-generic/index.d.ts.map +1 -0
- package/dist/manifest/stores/prisma-generic/index.js +2 -0
- package/dist/manifest/stores/prisma-generic/index.js.map +1 -0
- package/dist/manifest/stores/prisma-generic/store.d.ts +35 -0
- package/dist/manifest/stores/prisma-generic/store.d.ts.map +1 -0
- package/dist/manifest/stores/prisma-generic/store.js +216 -0
- package/dist/manifest/stores/prisma-generic/store.js.map +1 -0
- package/dist/manifest/stores/prisma-generic/types.d.ts +46 -0
- package/dist/manifest/stores/prisma-generic/types.d.ts.map +1 -0
- package/dist/manifest/stores/prisma-generic/types.js +6 -0
- package/dist/manifest/stores/prisma-generic/types.js.map +1 -0
- package/dist/manifest/stores.node.d.ts +248 -0
- package/dist/manifest/stores.node.d.ts.map +1 -0
- package/dist/manifest/stores.node.js +718 -0
- package/dist/manifest/stores.node.js.map +1 -0
- package/dist/manifest/test/postgres-live-env.d.ts +9 -0
- package/dist/manifest/test/postgres-live-env.d.ts.map +1 -0
- package/dist/manifest/test/postgres-live-env.js +14 -0
- package/dist/manifest/test/postgres-live-env.js.map +1 -0
- package/dist/manifest/types.d.ts +570 -0
- package/dist/manifest/types.d.ts.map +1 -0
- package/dist/manifest/types.js +2 -0
- package/dist/manifest/types.js.map +1 -0
- package/dist/manifest/version.d.ts +15 -0
- package/dist/manifest/version.d.ts.map +1 -0
- package/dist/manifest/version.js +15 -0
- package/dist/manifest/version.js.map +1 -0
- package/dist/manifest/wasm/index.d.ts +15 -0
- package/dist/manifest/wasm/index.d.ts.map +1 -0
- package/dist/manifest/wasm/index.js +15 -0
- package/dist/manifest/wasm/index.js.map +1 -0
- package/dist/manifest/wasm/wasm-evaluator.d.ts +93 -0
- package/dist/manifest/wasm/wasm-evaluator.d.ts.map +1 -0
- package/dist/manifest/wasm/wasm-evaluator.js +242 -0
- package/dist/manifest/wasm/wasm-evaluator.js.map +1 -0
- package/dist/manifest/wasm/wasm-loader.d.ts +56 -0
- package/dist/manifest/wasm/wasm-loader.d.ts.map +1 -0
- package/dist/manifest/wasm/wasm-loader.js +132 -0
- package/dist/manifest/wasm/wasm-loader.js.map +1 -0
- package/docs/spec/config/manifest.config.schema.json +737 -0
- package/docs/spec/config/prisma-projection.schema.json +173 -0
- package/docs/spec/ir/ir-v1.schema.json +2033 -0
- package/docs/spec/plugins/plugin.schema.json +104 -0
- package/docs/spec/registry/bypasses.schema.json +87 -0
- package/docs/spec/registry/commands.schema.json +61 -0
- package/docs/spec/registry/entities.schema.json +52 -0
- package/docs/spec/semantics.md +630 -0
- package/package.json +356 -0
- package/packages/cli/dist/audit/bypass-violations.d.ts +16 -0
- package/packages/cli/dist/audit/bypass-violations.d.ts.map +1 -0
- package/packages/cli/dist/audit/bypass-violations.js +98 -0
- package/packages/cli/dist/audit/bypass-violations.js.map +1 -0
- package/packages/cli/dist/audit/direct-writes.d.ts +15 -0
- package/packages/cli/dist/audit/direct-writes.d.ts.map +1 -0
- package/packages/cli/dist/audit/direct-writes.js +86 -0
- package/packages/cli/dist/audit/direct-writes.js.map +1 -0
- package/packages/cli/dist/audit/event-fabrication.d.ts +17 -0
- package/packages/cli/dist/audit/event-fabrication.d.ts.map +1 -0
- package/packages/cli/dist/audit/event-fabrication.js +101 -0
- package/packages/cli/dist/audit/event-fabrication.js.map +1 -0
- package/packages/cli/dist/audit/existing-command-available.d.ts +20 -0
- package/packages/cli/dist/audit/existing-command-available.d.ts.map +1 -0
- package/packages/cli/dist/audit/existing-command-available.js +158 -0
- package/packages/cli/dist/audit/existing-command-available.js.map +1 -0
- package/packages/cli/dist/audit/missing-tests.d.ts +17 -0
- package/packages/cli/dist/audit/missing-tests.d.ts.map +1 -0
- package/packages/cli/dist/audit/missing-tests.js +108 -0
- package/packages/cli/dist/audit/missing-tests.js.map +1 -0
- package/packages/cli/dist/audit/route-drift.d.ts +16 -0
- package/packages/cli/dist/audit/route-drift.d.ts.map +1 -0
- package/packages/cli/dist/audit/route-drift.js +86 -0
- package/packages/cli/dist/audit/route-drift.js.map +1 -0
- package/packages/cli/dist/audit/types.d.ts +63 -0
- package/packages/cli/dist/audit/types.d.ts.map +1 -0
- package/packages/cli/dist/audit/types.js +10 -0
- package/packages/cli/dist/audit/types.js.map +1 -0
- package/packages/cli/dist/audit/unregistered-command-call.d.ts +25 -0
- package/packages/cli/dist/audit/unregistered-command-call.d.ts.map +1 -0
- package/packages/cli/dist/audit/unregistered-command-call.js +196 -0
- package/packages/cli/dist/audit/unregistered-command-call.js.map +1 -0
- package/packages/cli/dist/audit/unregistered-entity-write.d.ts +16 -0
- package/packages/cli/dist/audit/unregistered-entity-write.d.ts.map +1 -0
- package/packages/cli/dist/audit/unregistered-entity-write.js +96 -0
- package/packages/cli/dist/audit/unregistered-entity-write.js.map +1 -0
- package/packages/cli/dist/audit/write-receiver.d.ts +23 -0
- package/packages/cli/dist/audit/write-receiver.d.ts.map +1 -0
- package/packages/cli/dist/audit/write-receiver.js +32 -0
- package/packages/cli/dist/audit/write-receiver.js.map +1 -0
- package/packages/cli/dist/checks/dispatcher-presence.d.ts +37 -0
- package/packages/cli/dist/checks/dispatcher-presence.d.ts.map +1 -0
- package/packages/cli/dist/checks/dispatcher-presence.js +57 -0
- package/packages/cli/dist/checks/dispatcher-presence.js.map +1 -0
- package/packages/cli/dist/checks/package-shape.d.ts +81 -0
- package/packages/cli/dist/checks/package-shape.d.ts.map +1 -0
- package/packages/cli/dist/checks/package-shape.js +359 -0
- package/packages/cli/dist/checks/package-shape.js.map +1 -0
- package/packages/cli/dist/checks/runtime-smoke.d.ts +42 -0
- package/packages/cli/dist/checks/runtime-smoke.d.ts.map +1 -0
- package/packages/cli/dist/checks/runtime-smoke.js +167 -0
- package/packages/cli/dist/checks/runtime-smoke.js.map +1 -0
- package/packages/cli/dist/commands/analyze.d.ts +97 -0
- package/packages/cli/dist/commands/analyze.d.ts.map +1 -0
- package/packages/cli/dist/commands/analyze.js +411 -0
- package/packages/cli/dist/commands/analyze.js.map +1 -0
- package/packages/cli/dist/commands/audit-bypasses.d.ts +31 -0
- package/packages/cli/dist/commands/audit-bypasses.d.ts.map +1 -0
- package/packages/cli/dist/commands/audit-bypasses.js +152 -0
- package/packages/cli/dist/commands/audit-bypasses.js.map +1 -0
- package/packages/cli/dist/commands/audit-constitution.d.ts +20 -0
- package/packages/cli/dist/commands/audit-constitution.d.ts.map +1 -0
- package/packages/cli/dist/commands/audit-constitution.js +18 -0
- package/packages/cli/dist/commands/audit-constitution.js.map +1 -0
- package/packages/cli/dist/commands/audit-governance.d.ts +37 -0
- package/packages/cli/dist/commands/audit-governance.d.ts.map +1 -0
- package/packages/cli/dist/commands/audit-governance.js +78 -0
- package/packages/cli/dist/commands/audit-governance.js.map +1 -0
- package/packages/cli/dist/commands/audit-routes.d.ts +135 -0
- package/packages/cli/dist/commands/audit-routes.d.ts.map +1 -0
- package/packages/cli/dist/commands/audit-routes.js +514 -0
- package/packages/cli/dist/commands/audit-routes.js.map +1 -0
- package/packages/cli/dist/commands/breaking-change.d.ts +15 -0
- package/packages/cli/dist/commands/breaking-change.d.ts.map +1 -0
- package/packages/cli/dist/commands/breaking-change.js +150 -0
- package/packages/cli/dist/commands/breaking-change.js.map +1 -0
- package/packages/cli/dist/commands/build.d.ts +26 -0
- package/packages/cli/dist/commands/build.d.ts.map +1 -0
- package/packages/cli/dist/commands/build.js +58 -0
- package/packages/cli/dist/commands/build.js.map +1 -0
- package/packages/cli/dist/commands/changelog.d.ts +26 -0
- package/packages/cli/dist/commands/changelog.d.ts.map +1 -0
- package/packages/cli/dist/commands/changelog.js +365 -0
- package/packages/cli/dist/commands/changelog.js.map +1 -0
- package/packages/cli/dist/commands/check.d.ts +21 -0
- package/packages/cli/dist/commands/check.d.ts.map +1 -0
- package/packages/cli/dist/commands/check.js +31 -0
- package/packages/cli/dist/commands/check.js.map +1 -0
- package/packages/cli/dist/commands/compile.d.ts +19 -0
- package/packages/cli/dist/commands/compile.d.ts.map +1 -0
- package/packages/cli/dist/commands/compile.js +325 -0
- package/packages/cli/dist/commands/compile.js.map +1 -0
- package/packages/cli/dist/commands/config.d.ts +23 -0
- package/packages/cli/dist/commands/config.d.ts.map +1 -0
- package/packages/cli/dist/commands/config.js +172 -0
- package/packages/cli/dist/commands/config.js.map +1 -0
- package/packages/cli/dist/commands/coverage.d.ts +55 -0
- package/packages/cli/dist/commands/coverage.d.ts.map +1 -0
- package/packages/cli/dist/commands/coverage.js +343 -0
- package/packages/cli/dist/commands/coverage.js.map +1 -0
- package/packages/cli/dist/commands/diagram.d.ts +22 -0
- package/packages/cli/dist/commands/diagram.d.ts.map +1 -0
- package/packages/cli/dist/commands/diagram.js +176 -0
- package/packages/cli/dist/commands/diagram.js.map +1 -0
- package/packages/cli/dist/commands/docs.d.ts +18 -0
- package/packages/cli/dist/commands/docs.d.ts.map +1 -0
- package/packages/cli/dist/commands/docs.js +722 -0
- package/packages/cli/dist/commands/docs.js.map +1 -0
- package/packages/cli/dist/commands/doctor-lib.d.ts +147 -0
- package/packages/cli/dist/commands/doctor-lib.d.ts.map +1 -0
- package/packages/cli/dist/commands/doctor-lib.js +491 -0
- package/packages/cli/dist/commands/doctor-lib.js.map +1 -0
- package/packages/cli/dist/commands/doctor.d.ts +31 -0
- package/packages/cli/dist/commands/doctor.d.ts.map +1 -0
- package/packages/cli/dist/commands/doctor.js +628 -0
- package/packages/cli/dist/commands/doctor.js.map +1 -0
- package/packages/cli/dist/commands/emit-registries.d.ts +33 -0
- package/packages/cli/dist/commands/emit-registries.d.ts.map +1 -0
- package/packages/cli/dist/commands/emit-registries.js +109 -0
- package/packages/cli/dist/commands/emit-registries.js.map +1 -0
- package/packages/cli/dist/commands/enforce-surface.d.ts +62 -0
- package/packages/cli/dist/commands/enforce-surface.d.ts.map +1 -0
- package/packages/cli/dist/commands/enforce-surface.js +172 -0
- package/packages/cli/dist/commands/enforce-surface.js.map +1 -0
- package/packages/cli/dist/commands/fmt.d.ts +17 -0
- package/packages/cli/dist/commands/fmt.d.ts.map +1 -0
- package/packages/cli/dist/commands/fmt.js +129 -0
- package/packages/cli/dist/commands/fmt.js.map +1 -0
- package/packages/cli/dist/commands/gen-tests.d.ts +41 -0
- package/packages/cli/dist/commands/gen-tests.d.ts.map +1 -0
- package/packages/cli/dist/commands/gen-tests.js +370 -0
- package/packages/cli/dist/commands/gen-tests.js.map +1 -0
- package/packages/cli/dist/commands/generate-from-prompt.d.ts +34 -0
- package/packages/cli/dist/commands/generate-from-prompt.d.ts.map +1 -0
- package/packages/cli/dist/commands/generate-from-prompt.js +990 -0
- package/packages/cli/dist/commands/generate-from-prompt.js.map +1 -0
- package/packages/cli/dist/commands/generate.d.ts +36 -0
- package/packages/cli/dist/commands/generate.d.ts.map +1 -0
- package/packages/cli/dist/commands/generate.js +371 -0
- package/packages/cli/dist/commands/generate.js.map +1 -0
- package/packages/cli/dist/commands/harness.d.ts +13 -0
- package/packages/cli/dist/commands/harness.d.ts.map +1 -0
- package/packages/cli/dist/commands/harness.js +276 -0
- package/packages/cli/dist/commands/harness.js.map +1 -0
- package/packages/cli/dist/commands/init-ci.d.ts +19 -0
- package/packages/cli/dist/commands/init-ci.d.ts.map +1 -0
- package/packages/cli/dist/commands/init-ci.js +148 -0
- package/packages/cli/dist/commands/init-ci.js.map +1 -0
- package/packages/cli/dist/commands/init.d.ts +33 -0
- package/packages/cli/dist/commands/init.d.ts.map +1 -0
- package/packages/cli/dist/commands/init.js +157 -0
- package/packages/cli/dist/commands/init.js.map +1 -0
- package/packages/cli/dist/commands/install-hooks.d.ts +29 -0
- package/packages/cli/dist/commands/install-hooks.d.ts.map +1 -0
- package/packages/cli/dist/commands/install-hooks.js +139 -0
- package/packages/cli/dist/commands/install-hooks.js.map +1 -0
- package/packages/cli/dist/commands/integration-check.d.ts +62 -0
- package/packages/cli/dist/commands/integration-check.d.ts.map +1 -0
- package/packages/cli/dist/commands/integration-check.js +298 -0
- package/packages/cli/dist/commands/integration-check.js.map +1 -0
- package/packages/cli/dist/commands/ir-diff.d.ts +8 -0
- package/packages/cli/dist/commands/ir-diff.d.ts.map +1 -0
- package/packages/cli/dist/commands/ir-diff.js +199 -0
- package/packages/cli/dist/commands/ir-diff.js.map +1 -0
- package/packages/cli/dist/commands/lint-routes.d.ts +56 -0
- package/packages/cli/dist/commands/lint-routes.d.ts.map +1 -0
- package/packages/cli/dist/commands/lint-routes.js +228 -0
- package/packages/cli/dist/commands/lint-routes.js.map +1 -0
- package/packages/cli/dist/commands/load-test.d.ts +61 -0
- package/packages/cli/dist/commands/load-test.d.ts.map +1 -0
- package/packages/cli/dist/commands/load-test.js +675 -0
- package/packages/cli/dist/commands/load-test.js.map +1 -0
- package/packages/cli/dist/commands/migrate.d.ts +21 -0
- package/packages/cli/dist/commands/migrate.d.ts.map +1 -0
- package/packages/cli/dist/commands/migrate.js +264 -0
- package/packages/cli/dist/commands/migrate.js.map +1 -0
- package/packages/cli/dist/commands/mock.d.ts +79 -0
- package/packages/cli/dist/commands/mock.d.ts.map +1 -0
- package/packages/cli/dist/commands/mock.js +324 -0
- package/packages/cli/dist/commands/mock.js.map +1 -0
- package/packages/cli/dist/commands/pack-unpack.d.ts +30 -0
- package/packages/cli/dist/commands/pack-unpack.d.ts.map +1 -0
- package/packages/cli/dist/commands/pack-unpack.js +108 -0
- package/packages/cli/dist/commands/pack-unpack.js.map +1 -0
- package/packages/cli/dist/commands/preflight.d.ts +31 -0
- package/packages/cli/dist/commands/preflight.d.ts.map +1 -0
- package/packages/cli/dist/commands/preflight.js +246 -0
- package/packages/cli/dist/commands/preflight.js.map +1 -0
- package/packages/cli/dist/commands/profile.d.ts +30 -0
- package/packages/cli/dist/commands/profile.d.ts.map +1 -0
- package/packages/cli/dist/commands/profile.js +201 -0
- package/packages/cli/dist/commands/profile.js.map +1 -0
- package/packages/cli/dist/commands/repl.d.ts +16 -0
- package/packages/cli/dist/commands/repl.d.ts.map +1 -0
- package/packages/cli/dist/commands/repl.js +772 -0
- package/packages/cli/dist/commands/repl.js.map +1 -0
- package/packages/cli/dist/commands/routes.d.ts +24 -0
- package/packages/cli/dist/commands/routes.d.ts.map +1 -0
- package/packages/cli/dist/commands/routes.js +144 -0
- package/packages/cli/dist/commands/routes.js.map +1 -0
- package/packages/cli/dist/commands/scan.d.ts +23 -0
- package/packages/cli/dist/commands/scan.d.ts.map +1 -0
- package/packages/cli/dist/commands/scan.js +722 -0
- package/packages/cli/dist/commands/scan.js.map +1 -0
- package/packages/cli/dist/commands/seed.d.ts +35 -0
- package/packages/cli/dist/commands/seed.d.ts.map +1 -0
- package/packages/cli/dist/commands/seed.js +503 -0
- package/packages/cli/dist/commands/seed.js.map +1 -0
- package/packages/cli/dist/commands/validate-ai-ajv.d.ts +4 -0
- package/packages/cli/dist/commands/validate-ai-ajv.d.ts.map +1 -0
- package/packages/cli/dist/commands/validate-ai-ajv.js +78 -0
- package/packages/cli/dist/commands/validate-ai-ajv.js.map +1 -0
- package/packages/cli/dist/commands/validate-ai-compiler.d.ts +5 -0
- package/packages/cli/dist/commands/validate-ai-compiler.d.ts.map +1 -0
- package/packages/cli/dist/commands/validate-ai-compiler.js +8 -0
- package/packages/cli/dist/commands/validate-ai-compiler.js.map +1 -0
- package/packages/cli/dist/commands/validate-ai-report.d.ts +5 -0
- package/packages/cli/dist/commands/validate-ai-report.d.ts.map +1 -0
- package/packages/cli/dist/commands/validate-ai-report.js +80 -0
- package/packages/cli/dist/commands/validate-ai-report.js.map +1 -0
- package/packages/cli/dist/commands/validate-ai-resolve-inputs.d.ts +6 -0
- package/packages/cli/dist/commands/validate-ai-resolve-inputs.d.ts.map +1 -0
- package/packages/cli/dist/commands/validate-ai-resolve-inputs.js +54 -0
- package/packages/cli/dist/commands/validate-ai-resolve-inputs.js.map +1 -0
- package/packages/cli/dist/commands/validate-ai-semantic-checks.d.ts +4 -0
- package/packages/cli/dist/commands/validate-ai-semantic-checks.d.ts.map +1 -0
- package/packages/cli/dist/commands/validate-ai-semantic-checks.js +218 -0
- package/packages/cli/dist/commands/validate-ai-semantic-checks.js.map +1 -0
- package/packages/cli/dist/commands/validate-ai-types.d.ts +41 -0
- package/packages/cli/dist/commands/validate-ai-types.d.ts.map +1 -0
- package/packages/cli/dist/commands/validate-ai-types.js +2 -0
- package/packages/cli/dist/commands/validate-ai-types.js.map +1 -0
- package/packages/cli/dist/commands/validate-ai-validate-file.d.ts +5 -0
- package/packages/cli/dist/commands/validate-ai-validate-file.d.ts.map +1 -0
- package/packages/cli/dist/commands/validate-ai-validate-file.js +126 -0
- package/packages/cli/dist/commands/validate-ai-validate-file.js.map +1 -0
- package/packages/cli/dist/commands/validate-ai.d.ts +15 -0
- package/packages/cli/dist/commands/validate-ai.d.ts.map +1 -0
- package/packages/cli/dist/commands/validate-ai.js +124 -0
- package/packages/cli/dist/commands/validate-ai.js.map +1 -0
- package/packages/cli/dist/commands/validate.d.ts +15 -0
- package/packages/cli/dist/commands/validate.d.ts.map +1 -0
- package/packages/cli/dist/commands/validate.js +205 -0
- package/packages/cli/dist/commands/validate.js.map +1 -0
- package/packages/cli/dist/commands/versions.d.ts +56 -0
- package/packages/cli/dist/commands/versions.d.ts.map +1 -0
- package/packages/cli/dist/commands/versions.js +427 -0
- package/packages/cli/dist/commands/versions.js.map +1 -0
- package/packages/cli/dist/commands/watch.d.ts +34 -0
- package/packages/cli/dist/commands/watch.d.ts.map +1 -0
- package/packages/cli/dist/commands/watch.js +253 -0
- package/packages/cli/dist/commands/watch.js.map +1 -0
- package/packages/cli/dist/index.d.ts +14 -0
- package/packages/cli/dist/index.d.ts.map +1 -0
- package/packages/cli/dist/index.js +1159 -0
- package/packages/cli/dist/index.js.map +1 -0
- package/packages/cli/dist/utils/config-validate.d.ts +48 -0
- package/packages/cli/dist/utils/config-validate.d.ts.map +1 -0
- package/packages/cli/dist/utils/config-validate.js +116 -0
- package/packages/cli/dist/utils/config-validate.js.map +1 -0
- package/packages/cli/dist/utils/config.d.ts +360 -0
- package/packages/cli/dist/utils/config.d.ts.map +1 -0
- package/packages/cli/dist/utils/config.js +567 -0
- package/packages/cli/dist/utils/config.js.map +1 -0
- package/packages/cli/dist/utils/schema.d.ts +8 -0
- package/packages/cli/dist/utils/schema.d.ts.map +1 -0
- package/packages/cli/dist/utils/schema.js +13 -0
- package/packages/cli/dist/utils/schema.js.map +1 -0
- package/packages/lsp-server/bin/manifest-lsp.js +3 -0
- package/packages/lsp-server/dist/compiler-bridge.d.ts +24 -0
- package/packages/lsp-server/dist/compiler-bridge.d.ts.map +1 -0
- package/packages/lsp-server/dist/compiler-bridge.js +32 -0
- package/packages/lsp-server/dist/compiler-bridge.js.map +1 -0
- package/packages/lsp-server/dist/document-store.d.ts +23 -0
- package/packages/lsp-server/dist/document-store.d.ts.map +1 -0
- package/packages/lsp-server/dist/document-store.js +40 -0
- package/packages/lsp-server/dist/document-store.js.map +1 -0
- package/packages/lsp-server/dist/features/completion.d.ts +23 -0
- package/packages/lsp-server/dist/features/completion.d.ts.map +1 -0
- package/packages/lsp-server/dist/features/completion.js +293 -0
- package/packages/lsp-server/dist/features/completion.js.map +1 -0
- package/packages/lsp-server/dist/features/definition.d.ts +9 -0
- package/packages/lsp-server/dist/features/definition.d.ts.map +1 -0
- package/packages/lsp-server/dist/features/definition.js +24 -0
- package/packages/lsp-server/dist/features/definition.js.map +1 -0
- package/packages/lsp-server/dist/features/diagnostics.d.ts +8 -0
- package/packages/lsp-server/dist/features/diagnostics.d.ts.map +1 -0
- package/packages/lsp-server/dist/features/diagnostics.js +40 -0
- package/packages/lsp-server/dist/features/diagnostics.js.map +1 -0
- package/packages/lsp-server/dist/features/document-symbols.d.ts +8 -0
- package/packages/lsp-server/dist/features/document-symbols.d.ts.map +1 -0
- package/packages/lsp-server/dist/features/document-symbols.js +164 -0
- package/packages/lsp-server/dist/features/document-symbols.js.map +1 -0
- package/packages/lsp-server/dist/features/hover.d.ts +9 -0
- package/packages/lsp-server/dist/features/hover.d.ts.map +1 -0
- package/packages/lsp-server/dist/features/hover.js +100 -0
- package/packages/lsp-server/dist/features/hover.js.map +1 -0
- package/packages/lsp-server/dist/index.d.ts +6 -0
- package/packages/lsp-server/dist/index.d.ts.map +1 -0
- package/packages/lsp-server/dist/index.js +11 -0
- package/packages/lsp-server/dist/index.js.map +1 -0
- package/packages/lsp-server/dist/position-utils.d.ts +25 -0
- package/packages/lsp-server/dist/position-utils.d.ts.map +1 -0
- package/packages/lsp-server/dist/position-utils.js +39 -0
- package/packages/lsp-server/dist/position-utils.js.map +1 -0
- package/packages/lsp-server/dist/server.d.ts +14 -0
- package/packages/lsp-server/dist/server.d.ts.map +1 -0
- package/packages/lsp-server/dist/server.js +96 -0
- package/packages/lsp-server/dist/server.js.map +1 -0
- package/packages/lsp-server/dist/symbols/builtin-docs.d.ts +34 -0
- package/packages/lsp-server/dist/symbols/builtin-docs.d.ts.map +1 -0
- package/packages/lsp-server/dist/symbols/builtin-docs.js +193 -0
- package/packages/lsp-server/dist/symbols/builtin-docs.js.map +1 -0
- package/packages/lsp-server/dist/symbols/symbol-index.d.ts +18 -0
- package/packages/lsp-server/dist/symbols/symbol-index.d.ts.map +1 -0
- package/packages/lsp-server/dist/symbols/symbol-index.js +107 -0
- package/packages/lsp-server/dist/symbols/symbol-index.js.map +1 -0
- package/packages/mcp-server/bin/manifest-mcp.js +27 -0
- package/packages/mcp-server/dist/index.d.ts +24 -0
- package/packages/mcp-server/dist/index.d.ts.map +1 -0
- package/packages/mcp-server/dist/index.js +36 -0
- package/packages/mcp-server/dist/index.js.map +1 -0
- package/packages/mcp-server/dist/resources/ir-cache.d.ts +9 -0
- package/packages/mcp-server/dist/resources/ir-cache.d.ts.map +1 -0
- package/packages/mcp-server/dist/resources/ir-cache.js +47 -0
- package/packages/mcp-server/dist/resources/ir-cache.js.map +1 -0
- package/packages/mcp-server/dist/resources/ir-schema.d.ts +8 -0
- package/packages/mcp-server/dist/resources/ir-schema.d.ts.map +1 -0
- package/packages/mcp-server/dist/resources/ir-schema.js +39 -0
- package/packages/mcp-server/dist/resources/ir-schema.js.map +1 -0
- package/packages/mcp-server/dist/resources/semantics.d.ts +8 -0
- package/packages/mcp-server/dist/resources/semantics.d.ts.map +1 -0
- package/packages/mcp-server/dist/resources/semantics.js +38 -0
- package/packages/mcp-server/dist/resources/semantics.js.map +1 -0
- package/packages/mcp-server/dist/server.d.ts +7 -0
- package/packages/mcp-server/dist/server.d.ts.map +1 -0
- package/packages/mcp-server/dist/server.js +22 -0
- package/packages/mcp-server/dist/server.js.map +1 -0
- package/packages/mcp-server/dist/state/session-store.d.ts +39 -0
- package/packages/mcp-server/dist/state/session-store.d.ts.map +1 -0
- package/packages/mcp-server/dist/state/session-store.js +58 -0
- package/packages/mcp-server/dist/state/session-store.js.map +1 -0
- package/packages/mcp-server/dist/tools/compile.d.ts +30 -0
- package/packages/mcp-server/dist/tools/compile.d.ts.map +1 -0
- package/packages/mcp-server/dist/tools/compile.js +54 -0
- package/packages/mcp-server/dist/tools/compile.js.map +1 -0
- package/packages/mcp-server/dist/tools/execute.d.ts +112 -0
- package/packages/mcp-server/dist/tools/execute.d.ts.map +1 -0
- package/packages/mcp-server/dist/tools/execute.js +103 -0
- package/packages/mcp-server/dist/tools/execute.js.map +1 -0
- package/packages/mcp-server/dist/tools/explain.d.ts +25 -0
- package/packages/mcp-server/dist/tools/explain.d.ts.map +1 -0
- package/packages/mcp-server/dist/tools/explain.js +254 -0
- package/packages/mcp-server/dist/tools/explain.js.map +1 -0
- package/packages/mcp-server/dist/tools/validate.d.ts +23 -0
- package/packages/mcp-server/dist/tools/validate.d.ts.map +1 -0
- package/packages/mcp-server/dist/tools/validate.js +38 -0
- package/packages/mcp-server/dist/tools/validate.js.map +1 -0
- package/src/manifest/audit/sinks/postgres.sql +51 -0
- package/src/manifest/outbox/stores/postgres.sql +61 -0
|
@@ -0,0 +1,2243 @@
|
|
|
1
|
+
import { Lexer } from './lexer.js';
|
|
2
|
+
export class Parser {
|
|
3
|
+
tokens = [];
|
|
4
|
+
pos = 0;
|
|
5
|
+
errors = [];
|
|
6
|
+
parse(source) {
|
|
7
|
+
this.tokens = new Lexer(source).tokenize();
|
|
8
|
+
this.pos = 0;
|
|
9
|
+
this.errors = [];
|
|
10
|
+
const program = {
|
|
11
|
+
uses: [], modules: [], entities: [], enums: [], values: [], commands: [], flows: [], effects: [],
|
|
12
|
+
exposures: [], compositions: [], policies: [], stores: [], events: [], reactions: [], sagas: [], roles: [],
|
|
13
|
+
webhooks: [], schedules: []
|
|
14
|
+
};
|
|
15
|
+
// Parse use declarations (must appear before any other declarations)
|
|
16
|
+
let pastUseDeclarations = false;
|
|
17
|
+
while (!this.isEnd()) {
|
|
18
|
+
this.skipNL();
|
|
19
|
+
if (this.isEnd())
|
|
20
|
+
break;
|
|
21
|
+
if (this.check('KEYWORD', 'use') && !pastUseDeclarations) {
|
|
22
|
+
program.uses.push(this.parseUse());
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
pastUseDeclarations = true;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
while (!this.isEnd()) {
|
|
29
|
+
this.skipNL();
|
|
30
|
+
if (this.isEnd())
|
|
31
|
+
break;
|
|
32
|
+
try {
|
|
33
|
+
if (this.check('KEYWORD', 'use')) {
|
|
34
|
+
this.errors.push({ message: "'use' declarations must appear before all other declarations", position: this.current()?.position, severity: 'error' });
|
|
35
|
+
this.advance(); // consume 'use'
|
|
36
|
+
if (this.check('STRING'))
|
|
37
|
+
this.advance(); // consume path
|
|
38
|
+
}
|
|
39
|
+
else if (this.check('KEYWORD', 'module'))
|
|
40
|
+
program.modules.push(this.parseModule());
|
|
41
|
+
else if (this.check('KEYWORD', 'entity'))
|
|
42
|
+
program.entities.push(this.parseEntity());
|
|
43
|
+
else if (this.check('IDENTIFIER', 'external') && this.peekIsKeyword(1, 'entity'))
|
|
44
|
+
program.entities.push(this.parseEntity());
|
|
45
|
+
else if (this.check('KEYWORD', 'enum'))
|
|
46
|
+
program.enums.push(this.parseEnum());
|
|
47
|
+
else if (this.check('IDENTIFIER', 'value') || this.check('KEYWORD', 'value')) {
|
|
48
|
+
program.values.push(this.parseValueObject());
|
|
49
|
+
}
|
|
50
|
+
else if (this.check('KEYWORD', 'tenant')) {
|
|
51
|
+
if (program.tenant) {
|
|
52
|
+
this.errors.push({ message: 'Duplicate tenant declaration; only one tenant declaration is allowed per program', position: this.current()?.position, severity: 'error' });
|
|
53
|
+
}
|
|
54
|
+
program.tenant = this.parseTenant();
|
|
55
|
+
}
|
|
56
|
+
else if (this.check('KEYWORD', 'async')) {
|
|
57
|
+
this.advance(); // consume 'async'
|
|
58
|
+
if (!this.check('KEYWORD', 'command')) {
|
|
59
|
+
throw new Error("Expected 'command' after 'async'");
|
|
60
|
+
}
|
|
61
|
+
const cmd = this.parseCommand();
|
|
62
|
+
cmd.async = true;
|
|
63
|
+
program.commands.push(cmd);
|
|
64
|
+
}
|
|
65
|
+
else if (this.check('KEYWORD', 'command'))
|
|
66
|
+
program.commands.push(this.parseCommand());
|
|
67
|
+
else if (this.check('KEYWORD', 'flow'))
|
|
68
|
+
program.flows.push(this.parseFlow());
|
|
69
|
+
else if (this.check('KEYWORD', 'effect'))
|
|
70
|
+
program.effects.push(this.parseEffect());
|
|
71
|
+
else if (this.check('KEYWORD', 'expose'))
|
|
72
|
+
program.exposures.push(this.parseExpose());
|
|
73
|
+
else if (this.check('KEYWORD', 'compose'))
|
|
74
|
+
program.compositions.push(this.parseComposition());
|
|
75
|
+
else if (this.check('KEYWORD', 'policy'))
|
|
76
|
+
program.policies.push(this.parsePolicy(false));
|
|
77
|
+
else if (this.check('KEYWORD', 'store'))
|
|
78
|
+
program.stores.push(this.parseStore());
|
|
79
|
+
else if (this.check('KEYWORD', 'event'))
|
|
80
|
+
program.events.push(this.parseOutboxEvent());
|
|
81
|
+
else if (this.check('KEYWORD', 'on'))
|
|
82
|
+
program.reactions.push(this.parseReaction());
|
|
83
|
+
else if (this.check('KEYWORD', 'saga'))
|
|
84
|
+
program.sagas.push(this.parseSaga());
|
|
85
|
+
else if (this.check('IDENTIFIER', 'role'))
|
|
86
|
+
program.roles.push(this.parseRole());
|
|
87
|
+
else if (this.check('KEYWORD', 'webhook'))
|
|
88
|
+
program.webhooks.push(this.parseWebhook());
|
|
89
|
+
else if (this.check('IDENTIFIER', 'schedule'))
|
|
90
|
+
program.schedules.push(this.parseSchedule());
|
|
91
|
+
else
|
|
92
|
+
this.advance();
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
this.errors.push({ message: e instanceof Error ? e.message : 'Parse error', position: this.current()?.position, severity: 'error' });
|
|
96
|
+
this.sync();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return { program, errors: this.errors };
|
|
100
|
+
}
|
|
101
|
+
parseUse() {
|
|
102
|
+
const position = this.current()?.position;
|
|
103
|
+
this.consume('KEYWORD', 'use');
|
|
104
|
+
if (!this.check('STRING')) {
|
|
105
|
+
throw new Error("Expected string path after 'use'");
|
|
106
|
+
}
|
|
107
|
+
const path = this.advance().value;
|
|
108
|
+
if (!path.startsWith('./') && !path.startsWith('../')) {
|
|
109
|
+
this.errors.push({ message: `use path must be relative (start with './' or '../'), got '${path}'`, position, severity: 'error' });
|
|
110
|
+
}
|
|
111
|
+
if (!path.endsWith('.manifest')) {
|
|
112
|
+
this.errors.push({ message: `use path must end with '.manifest', got '${path}'`, position, severity: 'error' });
|
|
113
|
+
}
|
|
114
|
+
return { type: 'Use', path, position };
|
|
115
|
+
}
|
|
116
|
+
parseModule() {
|
|
117
|
+
this.consume('KEYWORD', 'module');
|
|
118
|
+
const name = this.consumeIdentifier().value;
|
|
119
|
+
this.consume('PUNCTUATION', '{');
|
|
120
|
+
this.skipNL();
|
|
121
|
+
const entities = [], enums = [], commands = [], policies = [], stores = [], events = [], reactions = [], sagas = [], roles = [], webhooks = [], schedules = [];
|
|
122
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
123
|
+
this.skipNL();
|
|
124
|
+
if (this.check('PUNCTUATION', '}'))
|
|
125
|
+
break;
|
|
126
|
+
if (this.check('KEYWORD', 'entity'))
|
|
127
|
+
entities.push(this.parseEntity());
|
|
128
|
+
else if (this.check('IDENTIFIER', 'external') && this.peekIsKeyword(1, 'entity'))
|
|
129
|
+
entities.push(this.parseEntity());
|
|
130
|
+
else if (this.check('KEYWORD', 'enum'))
|
|
131
|
+
enums.push(this.parseEnum());
|
|
132
|
+
else if (this.check('KEYWORD', 'async')) {
|
|
133
|
+
this.advance(); // consume 'async'
|
|
134
|
+
if (!this.check('KEYWORD', 'command')) {
|
|
135
|
+
throw new Error("Expected 'command' after 'async'");
|
|
136
|
+
}
|
|
137
|
+
const cmd = this.parseCommand();
|
|
138
|
+
cmd.async = true;
|
|
139
|
+
commands.push(cmd);
|
|
140
|
+
}
|
|
141
|
+
else if (this.check('KEYWORD', 'command'))
|
|
142
|
+
commands.push(this.parseCommand());
|
|
143
|
+
else if (this.check('KEYWORD', 'policy'))
|
|
144
|
+
policies.push(this.parsePolicy(false));
|
|
145
|
+
else if (this.check('KEYWORD', 'store'))
|
|
146
|
+
stores.push(this.parseStore());
|
|
147
|
+
else if (this.check('KEYWORD', 'event'))
|
|
148
|
+
events.push(this.parseOutboxEvent());
|
|
149
|
+
else if (this.check('KEYWORD', 'on'))
|
|
150
|
+
reactions.push(this.parseReaction());
|
|
151
|
+
else if (this.check('KEYWORD', 'saga'))
|
|
152
|
+
sagas.push(this.parseSaga());
|
|
153
|
+
else if (this.check('IDENTIFIER', 'role'))
|
|
154
|
+
roles.push(this.parseRole());
|
|
155
|
+
else if (this.check('KEYWORD', 'webhook'))
|
|
156
|
+
webhooks.push(this.parseWebhook());
|
|
157
|
+
else if (this.check('IDENTIFIER', 'schedule'))
|
|
158
|
+
schedules.push(this.parseSchedule());
|
|
159
|
+
else
|
|
160
|
+
this.advance();
|
|
161
|
+
this.skipNL();
|
|
162
|
+
}
|
|
163
|
+
this.consume('PUNCTUATION', '}');
|
|
164
|
+
return { type: 'Module', name, entities, enums, commands, policies, stores, events, reactions, sagas, roles, webhooks, ...(schedules.length > 0 ? { schedules } : {}) };
|
|
165
|
+
}
|
|
166
|
+
parseEntity() {
|
|
167
|
+
// Optional contextual `external` modifier: `external entity X { ... }`.
|
|
168
|
+
// Kept as a contextual identifier (not a reserved word) so that property
|
|
169
|
+
// names like `property external: string` continue to parse.
|
|
170
|
+
let external = false;
|
|
171
|
+
if (this.check('IDENTIFIER', 'external')) {
|
|
172
|
+
this.advance(); // consume 'external'
|
|
173
|
+
external = true;
|
|
174
|
+
}
|
|
175
|
+
this.consume('KEYWORD', 'entity');
|
|
176
|
+
const name = this.consumeIdentifier().value;
|
|
177
|
+
// Parse optional `extends Parent`
|
|
178
|
+
let parent;
|
|
179
|
+
if (this.check('KEYWORD', 'extends')) {
|
|
180
|
+
this.advance(); // consume 'extends'
|
|
181
|
+
parent = this.consumeIdentifier().value;
|
|
182
|
+
}
|
|
183
|
+
// Parse optional `mixin A, B`
|
|
184
|
+
let mixins;
|
|
185
|
+
if (this.check('IDENTIFIER', 'mixin')) {
|
|
186
|
+
this.advance(); // consume 'mixin'
|
|
187
|
+
mixins = [];
|
|
188
|
+
mixins.push(this.consumeIdentifier().value);
|
|
189
|
+
while (this.check('PUNCTUATION', ',')) {
|
|
190
|
+
this.advance(); // consume ','
|
|
191
|
+
mixins.push(this.consumeIdentifier().value);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
this.consume('PUNCTUATION', '{');
|
|
195
|
+
this.skipNL();
|
|
196
|
+
const properties = [], computedProperties = [], relationships = [];
|
|
197
|
+
const behaviors = [], commands = [], constraints = [], policies = [];
|
|
198
|
+
const transitions = [], approvals = [], reactions = [];
|
|
199
|
+
let store;
|
|
200
|
+
let key;
|
|
201
|
+
const alternateKeys = [];
|
|
202
|
+
let versionProperty;
|
|
203
|
+
let versionAtProperty;
|
|
204
|
+
let timestamps;
|
|
205
|
+
let realtime;
|
|
206
|
+
let policyRefs;
|
|
207
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
208
|
+
this.skipNL();
|
|
209
|
+
if (this.check('PUNCTUATION', '}'))
|
|
210
|
+
break;
|
|
211
|
+
if (this.check('KEYWORD', 'property'))
|
|
212
|
+
properties.push(this.parseProperty());
|
|
213
|
+
else if (this.check('KEYWORD', 'computed') || this.check('KEYWORD', 'derived'))
|
|
214
|
+
computedProperties.push(this.parseComputedProperty());
|
|
215
|
+
else if (this.check('KEYWORD', 'hasMany') || this.check('KEYWORD', 'hasOne') || this.check('KEYWORD', 'belongsTo') || this.check('KEYWORD', 'ref'))
|
|
216
|
+
relationships.push(this.parseRelationship());
|
|
217
|
+
else if (this.check('KEYWORD', 'behavior'))
|
|
218
|
+
behaviors.push(this.parseBehavior());
|
|
219
|
+
else if (this.check('KEYWORD', 'on')) {
|
|
220
|
+
// Lookahead: "on <EventName> run" = reaction; otherwise = behavior
|
|
221
|
+
if (this.isReactionLookahead())
|
|
222
|
+
reactions.push(this.parseReaction());
|
|
223
|
+
else
|
|
224
|
+
behaviors.push(this.parseBehavior());
|
|
225
|
+
}
|
|
226
|
+
else if (this.check('KEYWORD', 'async')) {
|
|
227
|
+
this.advance(); // consume 'async'
|
|
228
|
+
if (!this.check('KEYWORD', 'command')) {
|
|
229
|
+
throw new Error("Expected 'command' after 'async'");
|
|
230
|
+
}
|
|
231
|
+
const cmd = this.parseCommand();
|
|
232
|
+
cmd.async = true;
|
|
233
|
+
commands.push(cmd);
|
|
234
|
+
}
|
|
235
|
+
else if (this.check('KEYWORD', 'command'))
|
|
236
|
+
commands.push(this.parseCommand());
|
|
237
|
+
else if (this.check('KEYWORD', 'constraint'))
|
|
238
|
+
constraints.push(this.parseConstraint());
|
|
239
|
+
else if (this.check('KEYWORD', 'policy'))
|
|
240
|
+
policies.push(this.parsePolicy(false));
|
|
241
|
+
// Parse contextual `policies { Name, ... }` block for policy references
|
|
242
|
+
else if (this.check('IDENTIFIER', 'policies') && this.tokens[this.pos + 1]?.value === '{') {
|
|
243
|
+
this.advance(); // consume 'policies'
|
|
244
|
+
this.consume('PUNCTUATION', '{');
|
|
245
|
+
this.skipNL();
|
|
246
|
+
policyRefs = [];
|
|
247
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
248
|
+
this.skipNL();
|
|
249
|
+
if (this.check('PUNCTUATION', '}'))
|
|
250
|
+
break;
|
|
251
|
+
policyRefs.push(this.consumeIdentifier().value);
|
|
252
|
+
if (this.check('PUNCTUATION', ',')) {
|
|
253
|
+
this.advance();
|
|
254
|
+
}
|
|
255
|
+
this.skipNL();
|
|
256
|
+
}
|
|
257
|
+
this.consume('PUNCTUATION', '}');
|
|
258
|
+
this.skipNL();
|
|
259
|
+
}
|
|
260
|
+
else if (this.check('KEYWORD', 'default')) {
|
|
261
|
+
// Default policy syntax: "default policy execute: ..."
|
|
262
|
+
this.advance(); // consume 'default'
|
|
263
|
+
if (this.check('KEYWORD', 'policy')) {
|
|
264
|
+
policies.push(this.parsePolicy(true));
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
throw new Error("Expected 'policy' after 'default'");
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
else if (this.check('KEYWORD', 'store')) {
|
|
271
|
+
// Check the syntax variant
|
|
272
|
+
const nextToken = this.tokens[this.pos + 1];
|
|
273
|
+
const afterNextToken = this.tokens[this.pos + 2];
|
|
274
|
+
if (nextToken?.value === 'in') {
|
|
275
|
+
// Entity-scoped syntax: "store in <target>"
|
|
276
|
+
this.advance(); // consume 'store'
|
|
277
|
+
this.advance(); // consume 'in'
|
|
278
|
+
store = this.advance().value; // get target
|
|
279
|
+
}
|
|
280
|
+
else if (afterNextToken?.value === 'in') {
|
|
281
|
+
// Full syntax inside entity: "store <Entity> in <target>"
|
|
282
|
+
// Parse as store node and extract target
|
|
283
|
+
const storeNode = this.parseStore();
|
|
284
|
+
store = storeNode.target;
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
// Short syntax: "store <target>" (without "in")
|
|
288
|
+
this.advance(); // consume 'store'
|
|
289
|
+
store = this.advance().value; // get target directly
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
else if (this.check('KEYWORD', 'versionProperty')) {
|
|
293
|
+
// Syntax: versionProperty <name>: <type>
|
|
294
|
+
this.advance(); // consume 'versionProperty'
|
|
295
|
+
versionProperty = this.consumeIdentifier().value;
|
|
296
|
+
// Skip type annotation (': number')
|
|
297
|
+
if (this.check('OPERATOR', ':')) {
|
|
298
|
+
this.advance(); // consume ':'
|
|
299
|
+
this.advance(); // consume type name
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
else if (this.check('KEYWORD', 'versionAtProperty')) {
|
|
303
|
+
// Syntax: versionAtProperty <name>: <type>
|
|
304
|
+
this.advance(); // consume 'versionAtProperty'
|
|
305
|
+
versionAtProperty = this.consumeIdentifier().value;
|
|
306
|
+
// Skip type annotation (': number')
|
|
307
|
+
if (this.check('OPERATOR', ':')) {
|
|
308
|
+
this.advance(); // consume ':'
|
|
309
|
+
this.advance(); // consume type name
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
else if (this.check('KEYWORD', 'key')) {
|
|
313
|
+
this.advance();
|
|
314
|
+
key = this.parseIdentifierArray();
|
|
315
|
+
}
|
|
316
|
+
else if (this.check('KEYWORD', 'unique') && this.tokens[this.pos + 1]?.value === '[') {
|
|
317
|
+
this.advance();
|
|
318
|
+
alternateKeys.push(this.parseIdentifierArray());
|
|
319
|
+
}
|
|
320
|
+
else if (this.check('KEYWORD', 'transition'))
|
|
321
|
+
transitions.push(this.parseTransition());
|
|
322
|
+
else if (this.check('KEYWORD', 'approval'))
|
|
323
|
+
approvals.push(this.parseApproval());
|
|
324
|
+
else if (this.check('KEYWORD', 'timestamps')) {
|
|
325
|
+
this.advance();
|
|
326
|
+
timestamps = true;
|
|
327
|
+
}
|
|
328
|
+
// Contextual `realtime` flag (not a reserved word, same approach as the
|
|
329
|
+
// `masked` modifier): a bare `realtime` line inside an entity block marks
|
|
330
|
+
// the entity as realtime. `property realtime: boolean` is unaffected —
|
|
331
|
+
// property declarations are consumed by the `property` branch above.
|
|
332
|
+
else if (this.check('IDENTIFIER', 'realtime')) {
|
|
333
|
+
this.advance();
|
|
334
|
+
realtime = true;
|
|
335
|
+
}
|
|
336
|
+
else if (this.check('KEYWORD', 'event')) {
|
|
337
|
+
// Entity-scoped events are not supported - emit warning to prevent silent data loss
|
|
338
|
+
const pos = this.current()?.position;
|
|
339
|
+
this.errors.push({
|
|
340
|
+
message: "Events cannot be declared inside entity blocks. Declare events at module or root level instead.",
|
|
341
|
+
position: pos,
|
|
342
|
+
severity: 'warning'
|
|
343
|
+
});
|
|
344
|
+
this.advance(); // consume the 'event' keyword to prevent infinite loop
|
|
345
|
+
// Also skip the event name if present
|
|
346
|
+
if (this.current()?.type === 'IDENTIFIER')
|
|
347
|
+
this.advance();
|
|
348
|
+
}
|
|
349
|
+
else
|
|
350
|
+
this.advance();
|
|
351
|
+
this.skipNL();
|
|
352
|
+
}
|
|
353
|
+
this.consume('PUNCTUATION', '}');
|
|
354
|
+
return {
|
|
355
|
+
type: 'Entity', name, properties, computedProperties, relationships, behaviors,
|
|
356
|
+
commands, constraints, policies, transitions, approvals, reactions, store,
|
|
357
|
+
...(parent ? { parent } : {}),
|
|
358
|
+
...(mixins ? { mixins } : {}),
|
|
359
|
+
...(policyRefs ? { policyRefs } : {}),
|
|
360
|
+
...(key ? { key } : {}),
|
|
361
|
+
...(alternateKeys.length > 0 ? { alternateKeys } : {}),
|
|
362
|
+
versionProperty, versionAtProperty,
|
|
363
|
+
...(timestamps ? { timestamps } : {}),
|
|
364
|
+
...(realtime ? { realtime } : {}),
|
|
365
|
+
...(external ? { external } : {}),
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
parseEnum() {
|
|
369
|
+
this.consume('KEYWORD', 'enum');
|
|
370
|
+
const name = this.consumeIdentifier().value;
|
|
371
|
+
this.consume('PUNCTUATION', '{');
|
|
372
|
+
this.skipNL();
|
|
373
|
+
const values = [];
|
|
374
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
375
|
+
this.skipNL();
|
|
376
|
+
if (this.check('PUNCTUATION', '}'))
|
|
377
|
+
break;
|
|
378
|
+
const valueName = this.consumeIdentifier().value;
|
|
379
|
+
const enumValue = { type: 'EnumValue', name: valueName };
|
|
380
|
+
// Check for optional label: "valueName = \"Display Label\""
|
|
381
|
+
if (this.check('OPERATOR', '=')) {
|
|
382
|
+
this.advance();
|
|
383
|
+
if (this.check('STRING')) {
|
|
384
|
+
enumValue.label = this.advance().value;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
// Check for optional ordinal: "valueName(123)" or "valueName = \"Label\" (123)"
|
|
388
|
+
if (this.check('PUNCTUATION', '(')) {
|
|
389
|
+
this.advance();
|
|
390
|
+
if (this.check('NUMBER')) {
|
|
391
|
+
enumValue.ordinal = parseFloat(this.advance().value);
|
|
392
|
+
}
|
|
393
|
+
this.consume('PUNCTUATION', ')');
|
|
394
|
+
}
|
|
395
|
+
values.push(enumValue);
|
|
396
|
+
// Skip comma if present
|
|
397
|
+
if (this.check('PUNCTUATION', ',')) {
|
|
398
|
+
this.advance();
|
|
399
|
+
}
|
|
400
|
+
this.skipNL();
|
|
401
|
+
}
|
|
402
|
+
this.consume('PUNCTUATION', '}');
|
|
403
|
+
return { type: 'Enum', name, values };
|
|
404
|
+
}
|
|
405
|
+
parseValueObject() {
|
|
406
|
+
const token = this.current();
|
|
407
|
+
if (token && ((token.type === 'IDENTIFIER' || token.type === 'KEYWORD') && token.value === 'value')) {
|
|
408
|
+
this.advance();
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
throw new Error(`Expected 'value' keyword, got ${token?.value || 'EOF'}`);
|
|
412
|
+
}
|
|
413
|
+
const name = this.consumeIdentifier().value;
|
|
414
|
+
this.consume('PUNCTUATION', '{');
|
|
415
|
+
this.skipNL();
|
|
416
|
+
const properties = [];
|
|
417
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
418
|
+
this.skipNL();
|
|
419
|
+
if (this.check('PUNCTUATION', '}'))
|
|
420
|
+
break;
|
|
421
|
+
if (this.check('KEYWORD', 'property')) {
|
|
422
|
+
properties.push(this.parseProperty());
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
this.errors.push({
|
|
426
|
+
message: `Unexpected token '${this.current()?.value}' in value object '${name}'. Value objects may only contain property declarations.`,
|
|
427
|
+
position: this.current()?.position,
|
|
428
|
+
severity: 'error'
|
|
429
|
+
});
|
|
430
|
+
this.advance();
|
|
431
|
+
}
|
|
432
|
+
this.skipNL();
|
|
433
|
+
}
|
|
434
|
+
this.consume('PUNCTUATION', '}');
|
|
435
|
+
return { type: 'ValueObject', name, properties };
|
|
436
|
+
}
|
|
437
|
+
parseTenant() {
|
|
438
|
+
const pos = this.current()?.position;
|
|
439
|
+
this.consume('KEYWORD', 'tenant');
|
|
440
|
+
const property = this.consumeIdentifierOrKeyword().value;
|
|
441
|
+
this.consume('OPERATOR', ':');
|
|
442
|
+
const dataType = this.parseType();
|
|
443
|
+
this.consume('KEYWORD', 'from');
|
|
444
|
+
let contextPath = '';
|
|
445
|
+
contextPath += this.advance().value;
|
|
446
|
+
while (this.check('OPERATOR', '.')) {
|
|
447
|
+
contextPath += this.advance().value;
|
|
448
|
+
contextPath += this.consumeIdentifierOrKeyword().value;
|
|
449
|
+
}
|
|
450
|
+
return { type: 'Tenant', property, dataType, contextPath, position: pos };
|
|
451
|
+
}
|
|
452
|
+
parseProperty() {
|
|
453
|
+
this.consume('KEYWORD', 'property');
|
|
454
|
+
const modifiers = [];
|
|
455
|
+
let maskStrategy;
|
|
456
|
+
for (;;) {
|
|
457
|
+
const cur = this.current();
|
|
458
|
+
if (cur && ['required', 'unique', 'indexed', 'private', 'readonly', 'optional', 'searchable', 'encrypted'].includes(cur.value || '')) {
|
|
459
|
+
modifiers.push(this.advance().value);
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
// Contextual `masked` modifier (not a reserved word). One-token lookahead:
|
|
463
|
+
// if the next token is ':', `masked` is the property NAME (`property masked: string`).
|
|
464
|
+
if (cur && cur.type === 'IDENTIFIER' && cur.value === 'masked') {
|
|
465
|
+
const next = this.tokens[this.pos + 1];
|
|
466
|
+
if (next && next.type === 'OPERATOR' && next.value === ':')
|
|
467
|
+
break;
|
|
468
|
+
this.advance(); // consume 'masked'
|
|
469
|
+
modifiers.push('masked');
|
|
470
|
+
if (this.check('PUNCTUATION', '('))
|
|
471
|
+
maskStrategy = this.parseMaskStrategyArgs();
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
476
|
+
const name = this.consumeIdentifier().value;
|
|
477
|
+
this.consume('OPERATOR', ':');
|
|
478
|
+
const dataType = this.parseType();
|
|
479
|
+
let defaultValue;
|
|
480
|
+
if (this.check('OPERATOR', '=')) {
|
|
481
|
+
this.advance();
|
|
482
|
+
defaultValue = this.parseExpr();
|
|
483
|
+
}
|
|
484
|
+
// Optional `unmask when <expr>` clause; compile error without the masked modifier.
|
|
485
|
+
let unmaskWhen;
|
|
486
|
+
if (this.check('IDENTIFIER', 'unmask')) {
|
|
487
|
+
const unmaskPos = this.current()?.position;
|
|
488
|
+
this.advance(); // consume 'unmask'
|
|
489
|
+
this.consume('KEYWORD', 'when');
|
|
490
|
+
unmaskWhen = this.parseExpr();
|
|
491
|
+
if (!modifiers.includes('masked')) {
|
|
492
|
+
this.errors.push({
|
|
493
|
+
message: `'unmask when' requires the 'masked' modifier on property '${name}'`,
|
|
494
|
+
position: unmaskPos,
|
|
495
|
+
severity: 'error'
|
|
496
|
+
});
|
|
497
|
+
unmaskWhen = undefined;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
return {
|
|
501
|
+
type: 'Property', name, dataType, defaultValue, modifiers,
|
|
502
|
+
...(maskStrategy ? { maskStrategy } : {}),
|
|
503
|
+
...(unmaskWhen ? { unmaskWhen } : {}),
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
/** Parses the parenthesized arg list of `masked(strategy, ...numericParams)`. */
|
|
507
|
+
parseMaskStrategyArgs() {
|
|
508
|
+
this.consume('PUNCTUATION', '(');
|
|
509
|
+
let type = 'redact';
|
|
510
|
+
const strategyTok = this.current();
|
|
511
|
+
if (strategyTok && (strategyTok.type === 'IDENTIFIER' || strategyTok.type === 'KEYWORD')) {
|
|
512
|
+
type = this.advance().value;
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
this.errors.push({
|
|
516
|
+
message: "Expected a masking strategy name after 'masked('",
|
|
517
|
+
position: strategyTok?.position,
|
|
518
|
+
severity: 'error'
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
const params = [];
|
|
522
|
+
while (this.check('PUNCTUATION', ',')) {
|
|
523
|
+
this.advance(); // consume ','
|
|
524
|
+
this.skipNL();
|
|
525
|
+
const tok = this.current();
|
|
526
|
+
if (tok && tok.type === 'NUMBER') {
|
|
527
|
+
params.push(parseFloat(this.advance().value));
|
|
528
|
+
}
|
|
529
|
+
else {
|
|
530
|
+
this.errors.push({
|
|
531
|
+
message: `Masking strategy parameters must be numeric literals, got '${tok?.value ?? 'EOF'}'`,
|
|
532
|
+
position: tok?.position,
|
|
533
|
+
severity: 'error'
|
|
534
|
+
});
|
|
535
|
+
if (tok && tok.type !== 'PUNCTUATION')
|
|
536
|
+
this.advance();
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
this.consume('PUNCTUATION', ')');
|
|
540
|
+
return params.length > 0 ? { type, params } : { type };
|
|
541
|
+
}
|
|
542
|
+
parseTransition() {
|
|
543
|
+
// Syntax: transition <property> from "<value>" to ["<value>", "<value>"]
|
|
544
|
+
this.consume('KEYWORD', 'transition');
|
|
545
|
+
const property = this.consumeIdentifier().value;
|
|
546
|
+
this.consume('KEYWORD', 'from');
|
|
547
|
+
const fromToken = this.advance(); // consume the "from" value (string literal)
|
|
548
|
+
const from = fromToken.type === 'STRING' ? fromToken.value : fromToken.value;
|
|
549
|
+
this.consume('KEYWORD', 'to');
|
|
550
|
+
const to = [];
|
|
551
|
+
if (this.check('PUNCTUATION', '[')) {
|
|
552
|
+
this.advance(); // consume '['
|
|
553
|
+
while (!this.check('PUNCTUATION', ']') && !this.isEnd()) {
|
|
554
|
+
const valToken = this.advance();
|
|
555
|
+
to.push(valToken.type === 'STRING' ? valToken.value : valToken.value);
|
|
556
|
+
if (this.check('PUNCTUATION', ','))
|
|
557
|
+
this.advance(); // consume ','
|
|
558
|
+
}
|
|
559
|
+
this.consume('PUNCTUATION', ']');
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
// Single value: transition status from "draft" to "review"
|
|
563
|
+
const valToken = this.advance();
|
|
564
|
+
to.push(valToken.type === 'STRING' ? valToken.value : valToken.value);
|
|
565
|
+
}
|
|
566
|
+
return { type: 'Transition', property, from, to };
|
|
567
|
+
}
|
|
568
|
+
parseApproval() {
|
|
569
|
+
const position = this.current()?.position;
|
|
570
|
+
this.consume('KEYWORD', 'approval');
|
|
571
|
+
const name = this.consumeIdentifier().value;
|
|
572
|
+
this.consume('PUNCTUATION', '{');
|
|
573
|
+
this.skipNL();
|
|
574
|
+
let command = '';
|
|
575
|
+
const stages = [];
|
|
576
|
+
let timeout;
|
|
577
|
+
let onTimeout;
|
|
578
|
+
const emits = [];
|
|
579
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
580
|
+
this.skipNL();
|
|
581
|
+
if (this.check('PUNCTUATION', '}'))
|
|
582
|
+
break;
|
|
583
|
+
if (this.check('KEYWORD', 'command')) {
|
|
584
|
+
this.advance(); // consume 'command'
|
|
585
|
+
this.consume('OPERATOR', ':');
|
|
586
|
+
command = this.consumeIdentifier().value;
|
|
587
|
+
}
|
|
588
|
+
else if (this.check('KEYWORD', 'stages')) {
|
|
589
|
+
this.advance(); // consume 'stages'
|
|
590
|
+
this.consume('PUNCTUATION', '{');
|
|
591
|
+
this.skipNL();
|
|
592
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
593
|
+
this.skipNL();
|
|
594
|
+
if (this.check('PUNCTUATION', '}'))
|
|
595
|
+
break;
|
|
596
|
+
if (this.check('IDENTIFIER') || this.check('KEYWORD', 'stage')) {
|
|
597
|
+
// Support both "stage <name> { ... }" and bare "<name> { ... }"
|
|
598
|
+
if (this.current()?.value === 'stage')
|
|
599
|
+
this.advance();
|
|
600
|
+
stages.push(this.parseApprovalStage());
|
|
601
|
+
}
|
|
602
|
+
else {
|
|
603
|
+
this.advance();
|
|
604
|
+
}
|
|
605
|
+
this.skipNL();
|
|
606
|
+
}
|
|
607
|
+
this.consume('PUNCTUATION', '}');
|
|
608
|
+
}
|
|
609
|
+
else if (this.check('KEYWORD', 'timeout')) {
|
|
610
|
+
this.advance(); // consume 'timeout'
|
|
611
|
+
this.consume('OPERATOR', ':');
|
|
612
|
+
const t = this.advance();
|
|
613
|
+
timeout = t.type === 'NUMBER' ? parseFloat(t.value) : undefined;
|
|
614
|
+
}
|
|
615
|
+
else if (this.check('IDENTIFIER') && this.current()?.value === 'on_timeout') {
|
|
616
|
+
this.advance(); // consume 'on_timeout'
|
|
617
|
+
this.consume('OPERATOR', ':');
|
|
618
|
+
const v = this.check('STRING') ? this.advance().value : this.advance().value;
|
|
619
|
+
if (v === 'cancel' || v === 'escalate')
|
|
620
|
+
onTimeout = v;
|
|
621
|
+
}
|
|
622
|
+
else if (this.check('KEYWORD', 'emit')) {
|
|
623
|
+
this.advance(); // consume 'emit'
|
|
624
|
+
emits.push(this.consumeIdentifier().value);
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
this.advance();
|
|
628
|
+
}
|
|
629
|
+
this.skipNL();
|
|
630
|
+
}
|
|
631
|
+
this.consume('PUNCTUATION', '}');
|
|
632
|
+
if (!command) {
|
|
633
|
+
throw new Error(`Approval '${name}' must specify a command`);
|
|
634
|
+
}
|
|
635
|
+
const node = { type: 'Approval', name, command, stages, emits, position };
|
|
636
|
+
if (timeout !== undefined)
|
|
637
|
+
node.timeout = timeout;
|
|
638
|
+
if (onTimeout !== undefined)
|
|
639
|
+
node.onTimeout = onTimeout;
|
|
640
|
+
return node;
|
|
641
|
+
}
|
|
642
|
+
parseApprovalStage() {
|
|
643
|
+
const name = this.consumeIdentifier().value;
|
|
644
|
+
this.consume('PUNCTUATION', '{');
|
|
645
|
+
this.skipNL();
|
|
646
|
+
let policy;
|
|
647
|
+
let when;
|
|
648
|
+
let required = 1;
|
|
649
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
650
|
+
this.skipNL();
|
|
651
|
+
if (this.check('PUNCTUATION', '}'))
|
|
652
|
+
break;
|
|
653
|
+
if (this.check('KEYWORD', 'policy')) {
|
|
654
|
+
this.advance(); // consume 'policy'
|
|
655
|
+
this.consume('OPERATOR', ':');
|
|
656
|
+
policy = this.parseExpr();
|
|
657
|
+
}
|
|
658
|
+
else if (this.check('KEYWORD', 'when')) {
|
|
659
|
+
this.advance(); // consume 'when'
|
|
660
|
+
this.consume('OPERATOR', ':');
|
|
661
|
+
when = this.parseExpr();
|
|
662
|
+
}
|
|
663
|
+
else if (this.check('KEYWORD', 'required')) {
|
|
664
|
+
this.advance(); // consume 'required'
|
|
665
|
+
this.consume('OPERATOR', ':');
|
|
666
|
+
const r = this.advance();
|
|
667
|
+
required = r.type === 'NUMBER' ? parseFloat(r.value) : 1;
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
this.advance();
|
|
671
|
+
}
|
|
672
|
+
this.skipNL();
|
|
673
|
+
}
|
|
674
|
+
this.consume('PUNCTUATION', '}');
|
|
675
|
+
if (!policy) {
|
|
676
|
+
throw new Error(`Approval stage '${name}' requires a policy expression`);
|
|
677
|
+
}
|
|
678
|
+
const node = { type: 'ApprovalStage', name, policy, required };
|
|
679
|
+
if (when)
|
|
680
|
+
node.when = when;
|
|
681
|
+
return node;
|
|
682
|
+
}
|
|
683
|
+
parseComputedProperty() {
|
|
684
|
+
this.advance();
|
|
685
|
+
const name = this.consumeIdentifier().value;
|
|
686
|
+
this.consume('OPERATOR', ':');
|
|
687
|
+
const dataType = this.parseType();
|
|
688
|
+
this.consume('OPERATOR', '=');
|
|
689
|
+
const expression = this.parseExpr();
|
|
690
|
+
const dependencies = this.extractDependencies(expression);
|
|
691
|
+
const cache = this.parseComputedCache();
|
|
692
|
+
const node = { type: 'ComputedProperty', name, dataType, expression, dependencies };
|
|
693
|
+
if (cache)
|
|
694
|
+
node.cache = cache;
|
|
695
|
+
return node;
|
|
696
|
+
}
|
|
697
|
+
parseComputedCache() {
|
|
698
|
+
if (!this.check('KEYWORD', 'cache'))
|
|
699
|
+
return undefined;
|
|
700
|
+
this.advance(); // consume 'cache'
|
|
701
|
+
if (this.check('KEYWORD', 'request')) {
|
|
702
|
+
this.advance();
|
|
703
|
+
return { strategy: 'request' };
|
|
704
|
+
}
|
|
705
|
+
if (this.check('KEYWORD', 'session')) {
|
|
706
|
+
this.advance();
|
|
707
|
+
return { strategy: 'session' };
|
|
708
|
+
}
|
|
709
|
+
if (this.check('KEYWORD', 'ttl')) {
|
|
710
|
+
this.advance();
|
|
711
|
+
const ttlToken = this.advance();
|
|
712
|
+
if (ttlToken.type !== 'NUMBER') {
|
|
713
|
+
throw new Error(`Expected TTL value in seconds after 'ttl', got '${ttlToken.value}'`);
|
|
714
|
+
}
|
|
715
|
+
return { strategy: 'ttl', ttlSeconds: Number(ttlToken.value) };
|
|
716
|
+
}
|
|
717
|
+
throw new Error(`Expected cache strategy: 'request', 'session', or 'ttl', got '${this.current()?.value}'`);
|
|
718
|
+
}
|
|
719
|
+
extractDependencies(expr) {
|
|
720
|
+
const deps = new Set();
|
|
721
|
+
const RESERVED = ['self', 'this', 'user', 'context'];
|
|
722
|
+
const walk = (e) => {
|
|
723
|
+
switch (e.type) {
|
|
724
|
+
case 'Identifier':
|
|
725
|
+
if (!RESERVED.includes(e.name)) {
|
|
726
|
+
deps.add(e.name);
|
|
727
|
+
}
|
|
728
|
+
break;
|
|
729
|
+
case 'MemberAccess':
|
|
730
|
+
// self.X / this.X → X is an instance property the computed reads, so
|
|
731
|
+
// it is a real dependency (the runtime's stale-marking keys on the
|
|
732
|
+
// names of mutated properties). Previously the property was dropped,
|
|
733
|
+
// so `self.totalTax` never listed `totalTax` and caches went stale.
|
|
734
|
+
// Other bases (user.X, context.X, event.X, payload.X) recurse into
|
|
735
|
+
// the object so their non-instance property names aren't captured;
|
|
736
|
+
// a nested self.a.b recurses to capture `a`. Mirrors the self/this
|
|
737
|
+
// member check in checkComputedRefsInGuardsAndConstraints (ir-compiler).
|
|
738
|
+
if (e.object.type === 'Identifier' &&
|
|
739
|
+
(e.object.name === 'self' || e.object.name === 'this') &&
|
|
740
|
+
typeof e.property === 'string') {
|
|
741
|
+
deps.add(e.property);
|
|
742
|
+
}
|
|
743
|
+
else {
|
|
744
|
+
walk(e.object);
|
|
745
|
+
}
|
|
746
|
+
break;
|
|
747
|
+
case 'BinaryOp':
|
|
748
|
+
walk(e.left);
|
|
749
|
+
walk(e.right);
|
|
750
|
+
break;
|
|
751
|
+
case 'UnaryOp':
|
|
752
|
+
walk(e.operand);
|
|
753
|
+
break;
|
|
754
|
+
case 'Call':
|
|
755
|
+
walk(e.callee);
|
|
756
|
+
e.arguments.forEach(walk);
|
|
757
|
+
break;
|
|
758
|
+
case 'Conditional':
|
|
759
|
+
walk(e.condition);
|
|
760
|
+
walk(e.consequent);
|
|
761
|
+
walk(e.alternate);
|
|
762
|
+
break;
|
|
763
|
+
case 'Array':
|
|
764
|
+
e.elements.forEach(walk);
|
|
765
|
+
break;
|
|
766
|
+
case 'Object':
|
|
767
|
+
e.properties.forEach((p) => walk(p.value));
|
|
768
|
+
break;
|
|
769
|
+
case 'Lambda':
|
|
770
|
+
walk(e.body);
|
|
771
|
+
break;
|
|
772
|
+
case 'Literal':
|
|
773
|
+
// No dependencies in literals
|
|
774
|
+
break;
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
walk(expr);
|
|
778
|
+
return Array.from(deps);
|
|
779
|
+
}
|
|
780
|
+
parseIdentifierArray() {
|
|
781
|
+
this.consume('PUNCTUATION', '[');
|
|
782
|
+
const items = [];
|
|
783
|
+
while (!this.check('PUNCTUATION', ']') && !this.isEnd()) {
|
|
784
|
+
items.push(this.consumeIdentifierOrKeyword().value);
|
|
785
|
+
if (this.check('PUNCTUATION', ','))
|
|
786
|
+
this.advance();
|
|
787
|
+
}
|
|
788
|
+
this.consume('PUNCTUATION', ']');
|
|
789
|
+
return items;
|
|
790
|
+
}
|
|
791
|
+
parseRelationship() {
|
|
792
|
+
const kind = this.advance().value;
|
|
793
|
+
const name = this.consumeIdentifierOrKeyword().value;
|
|
794
|
+
this.consume('OPERATOR', ':');
|
|
795
|
+
const target = this.consumeIdentifierOrKeyword().value;
|
|
796
|
+
let fields;
|
|
797
|
+
let references;
|
|
798
|
+
let through;
|
|
799
|
+
let onDelete;
|
|
800
|
+
let onUpdate;
|
|
801
|
+
if (this.check('KEYWORD', 'through')) {
|
|
802
|
+
this.advance();
|
|
803
|
+
through = this.consumeIdentifier().value;
|
|
804
|
+
}
|
|
805
|
+
if (this.check('KEYWORD', 'fields')) {
|
|
806
|
+
this.advance();
|
|
807
|
+
fields = this.parseIdentifierArray();
|
|
808
|
+
}
|
|
809
|
+
if (this.check('KEYWORD', 'references')) {
|
|
810
|
+
this.advance();
|
|
811
|
+
references = this.parseIdentifierArray();
|
|
812
|
+
}
|
|
813
|
+
// `with <single>` backward-compat: parsed as fields: [name], references absent
|
|
814
|
+
if (this.check('KEYWORD', 'with')) {
|
|
815
|
+
this.advance();
|
|
816
|
+
fields = [this.consumeIdentifier().value];
|
|
817
|
+
}
|
|
818
|
+
// Case 3: references only, no fields — infer local from relName + "Id" (single only)
|
|
819
|
+
if (references && !fields) {
|
|
820
|
+
if (references.length > 1) {
|
|
821
|
+
this.errors.push({
|
|
822
|
+
message: `Composite references [...] requires explicit fields [...]`,
|
|
823
|
+
position: this.current()?.position,
|
|
824
|
+
severity: 'error',
|
|
825
|
+
});
|
|
826
|
+
}
|
|
827
|
+
fields = [`${name}Id`];
|
|
828
|
+
}
|
|
829
|
+
if (this.check('KEYWORD', 'onDelete')) {
|
|
830
|
+
this.advance();
|
|
831
|
+
onDelete = this.advance().value;
|
|
832
|
+
}
|
|
833
|
+
if (this.check('KEYWORD', 'onUpdate')) {
|
|
834
|
+
this.advance();
|
|
835
|
+
onUpdate = this.advance().value;
|
|
836
|
+
}
|
|
837
|
+
return { type: 'Relationship', kind, name, target, fields, references, through, onDelete, onUpdate };
|
|
838
|
+
}
|
|
839
|
+
parseCommand() {
|
|
840
|
+
this.consume('KEYWORD', 'command');
|
|
841
|
+
const name = this.consumeIdentifier().value;
|
|
842
|
+
this.consume('PUNCTUATION', '(');
|
|
843
|
+
const parameters = [];
|
|
844
|
+
while (!this.check('PUNCTUATION', ')') && !this.isEnd()) {
|
|
845
|
+
const required = !this.check('KEYWORD', 'optional');
|
|
846
|
+
if (!required)
|
|
847
|
+
this.advance();
|
|
848
|
+
const pname = this.consumeIdentifier().value;
|
|
849
|
+
this.consume('OPERATOR', ':');
|
|
850
|
+
const dataType = this.parseType();
|
|
851
|
+
let defaultValue;
|
|
852
|
+
if (this.check('OPERATOR', '=')) {
|
|
853
|
+
this.advance();
|
|
854
|
+
defaultValue = this.parseExpr();
|
|
855
|
+
}
|
|
856
|
+
parameters.push({ type: 'Parameter', name: pname, dataType, required, defaultValue });
|
|
857
|
+
if (this.check('PUNCTUATION', ','))
|
|
858
|
+
this.advance();
|
|
859
|
+
}
|
|
860
|
+
this.consume('PUNCTUATION', ')');
|
|
861
|
+
let returns;
|
|
862
|
+
if (this.check('KEYWORD', 'returns')) {
|
|
863
|
+
this.advance();
|
|
864
|
+
returns = this.parseType();
|
|
865
|
+
}
|
|
866
|
+
let retry;
|
|
867
|
+
let rateLimit;
|
|
868
|
+
const guards = [], constraints = [], actions = [], emits = [];
|
|
869
|
+
const emitPayloads = [];
|
|
870
|
+
if (this.check('PUNCTUATION', '{')) {
|
|
871
|
+
this.advance();
|
|
872
|
+
this.skipNL();
|
|
873
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
874
|
+
this.skipNL();
|
|
875
|
+
if (this.check('PUNCTUATION', '}'))
|
|
876
|
+
break;
|
|
877
|
+
// Parse retry block
|
|
878
|
+
if (this.check('IDENTIFIER', 'retry') && this.tokens[this.pos + 1]?.value === '{') {
|
|
879
|
+
retry = this.parseRetryBlock();
|
|
880
|
+
}
|
|
881
|
+
// Parse rateLimit block
|
|
882
|
+
else if (this.check('IDENTIFIER', 'rateLimit') && this.tokens[this.pos + 1]?.value === '{') {
|
|
883
|
+
rateLimit = this.parseRateLimitBlock();
|
|
884
|
+
}
|
|
885
|
+
else if (this.check('KEYWORD', 'guard') || this.check('KEYWORD', 'when')) {
|
|
886
|
+
this.advance();
|
|
887
|
+
guards.push(this.parseExpr());
|
|
888
|
+
}
|
|
889
|
+
else if (this.check('KEYWORD', 'constraint')) {
|
|
890
|
+
constraints.push(this.parseConstraint());
|
|
891
|
+
}
|
|
892
|
+
else if (this.check('KEYWORD', 'emit')) {
|
|
893
|
+
this.advance();
|
|
894
|
+
const eventName = this.consumeIdentifier().value;
|
|
895
|
+
emits.push(eventName);
|
|
896
|
+
// Optional explicit payload: emit EventName { field: expr, ... }
|
|
897
|
+
if (this.check('PUNCTUATION', '{')) {
|
|
898
|
+
const payload = this.parsePrimary();
|
|
899
|
+
if (payload.type === 'Object')
|
|
900
|
+
emitPayloads.push({ eventName, payload });
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
else
|
|
904
|
+
actions.push(this.parseAction());
|
|
905
|
+
this.skipNL();
|
|
906
|
+
}
|
|
907
|
+
this.consume('PUNCTUATION', '}');
|
|
908
|
+
}
|
|
909
|
+
else if (this.check('OPERATOR', '=>')) {
|
|
910
|
+
this.advance();
|
|
911
|
+
actions.push(this.parseAction());
|
|
912
|
+
}
|
|
913
|
+
return {
|
|
914
|
+
type: 'Command',
|
|
915
|
+
name,
|
|
916
|
+
parameters,
|
|
917
|
+
...(retry ? { retry } : {}),
|
|
918
|
+
...(rateLimit ? { rateLimit } : {}),
|
|
919
|
+
guards: guards.length ? guards : undefined,
|
|
920
|
+
constraints: constraints.length ? constraints : undefined,
|
|
921
|
+
actions,
|
|
922
|
+
emits: emits.length ? emits : undefined,
|
|
923
|
+
emitPayloads: emitPayloads.length ? emitPayloads : undefined,
|
|
924
|
+
returns
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
parsePolicy(isDefault = false) {
|
|
928
|
+
this.consume('KEYWORD', 'policy');
|
|
929
|
+
const name = this.consumeIdentifier().value;
|
|
930
|
+
let action = 'all';
|
|
931
|
+
if (this.check('KEYWORD', 'read') || this.check('KEYWORD', 'write') || this.check('KEYWORD', 'delete') || this.check('KEYWORD', 'execute') || this.check('KEYWORD', 'all') || this.check('KEYWORD', 'override')) {
|
|
932
|
+
action = this.advance().value;
|
|
933
|
+
}
|
|
934
|
+
this.consume('OPERATOR', ':');
|
|
935
|
+
this.skipNL();
|
|
936
|
+
const expression = this.parseExpr();
|
|
937
|
+
// Parse optional rateLimit block after expression
|
|
938
|
+
let rateLimit;
|
|
939
|
+
if (this.check('IDENTIFIER', 'rateLimit') && this.tokens[this.pos + 1]?.value === '{') {
|
|
940
|
+
rateLimit = this.parseRateLimitBlock();
|
|
941
|
+
}
|
|
942
|
+
const message = this.check('STRING') ? this.advance().value : undefined;
|
|
943
|
+
return { type: 'Policy', name, action, expression, ...(rateLimit ? { rateLimit } : {}), message, isDefault };
|
|
944
|
+
}
|
|
945
|
+
parseRole() {
|
|
946
|
+
const position = this.current()?.position;
|
|
947
|
+
this.consume('IDENTIFIER', 'role');
|
|
948
|
+
const name = this.consumeIdentifier().value;
|
|
949
|
+
let parent;
|
|
950
|
+
if (this.check('KEYWORD', 'extends')) {
|
|
951
|
+
this.advance();
|
|
952
|
+
parent = this.consumeIdentifier().value;
|
|
953
|
+
}
|
|
954
|
+
this.consume('PUNCTUATION', '{');
|
|
955
|
+
this.skipNL();
|
|
956
|
+
const permissions = [];
|
|
957
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
958
|
+
this.skipNL();
|
|
959
|
+
if (this.check('PUNCTUATION', '}'))
|
|
960
|
+
break;
|
|
961
|
+
if (this.check('KEYWORD', 'allow') || this.check('KEYWORD', 'deny')) {
|
|
962
|
+
const kind = this.advance().value;
|
|
963
|
+
const action = this.advance().value;
|
|
964
|
+
let target;
|
|
965
|
+
if (this.check('IDENTIFIER'))
|
|
966
|
+
target = this.advance().value;
|
|
967
|
+
permissions.push({ kind, action, target });
|
|
968
|
+
}
|
|
969
|
+
else {
|
|
970
|
+
this.advance();
|
|
971
|
+
}
|
|
972
|
+
this.skipNL();
|
|
973
|
+
}
|
|
974
|
+
this.consume('PUNCTUATION', '}');
|
|
975
|
+
return { type: 'Role', name, parent, permissions, position };
|
|
976
|
+
}
|
|
977
|
+
parseStore() {
|
|
978
|
+
this.consume('KEYWORD', 'store');
|
|
979
|
+
const entity = this.consumeIdentifier().value;
|
|
980
|
+
this.consume('KEYWORD', 'in');
|
|
981
|
+
const target = this.advance().value;
|
|
982
|
+
const config = {};
|
|
983
|
+
if (this.check('PUNCTUATION', '{')) {
|
|
984
|
+
this.advance();
|
|
985
|
+
this.skipNL();
|
|
986
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
987
|
+
this.skipNL();
|
|
988
|
+
if (this.check('PUNCTUATION', '}'))
|
|
989
|
+
break;
|
|
990
|
+
// Config keys are like object literal keys - allow keywords
|
|
991
|
+
const key = this.consumeIdentifierOrKeyword().value;
|
|
992
|
+
this.consume('OPERATOR', ':');
|
|
993
|
+
config[key] = this.parseExpr();
|
|
994
|
+
this.skipNL();
|
|
995
|
+
}
|
|
996
|
+
this.consume('PUNCTUATION', '}');
|
|
997
|
+
}
|
|
998
|
+
return { type: 'Store', entity, target, config: Object.keys(config).length ? config : undefined };
|
|
999
|
+
}
|
|
1000
|
+
parseOutboxEvent() {
|
|
1001
|
+
this.consume('KEYWORD', 'event');
|
|
1002
|
+
const name = this.consumeIdentifier().value;
|
|
1003
|
+
this.consume('OPERATOR', ':');
|
|
1004
|
+
const channel = this.check('STRING') ? this.advance().value : name;
|
|
1005
|
+
let payload = { type: 'Type', name: 'unknown', nullable: false };
|
|
1006
|
+
if (this.check('PUNCTUATION', '{')) {
|
|
1007
|
+
this.advance();
|
|
1008
|
+
this.skipNL();
|
|
1009
|
+
const fields = [];
|
|
1010
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
1011
|
+
this.skipNL();
|
|
1012
|
+
if (this.check('PUNCTUATION', '}'))
|
|
1013
|
+
break;
|
|
1014
|
+
const fname = this.consumeIdentifier().value;
|
|
1015
|
+
this.consume('OPERATOR', ':');
|
|
1016
|
+
const ftype = this.parseType();
|
|
1017
|
+
fields.push({ type: 'Parameter', name: fname, dataType: ftype, required: true });
|
|
1018
|
+
this.skipNL();
|
|
1019
|
+
}
|
|
1020
|
+
this.consume('PUNCTUATION', '}');
|
|
1021
|
+
payload = { fields };
|
|
1022
|
+
}
|
|
1023
|
+
else if (this.check('IDENTIFIER') || this.check('KEYWORD')) {
|
|
1024
|
+
payload = this.parseType();
|
|
1025
|
+
}
|
|
1026
|
+
return { type: 'OutboxEvent', name, channel, payload };
|
|
1027
|
+
}
|
|
1028
|
+
parseType() {
|
|
1029
|
+
const name = this.advance().value;
|
|
1030
|
+
let generic;
|
|
1031
|
+
// Type parameters for decimal/decimal(money) types: decimal(10, 2)
|
|
1032
|
+
let params;
|
|
1033
|
+
if (this.check('PUNCTUATION', '(') && (name === 'decimal' || name === 'money')) {
|
|
1034
|
+
this.advance(); // consume (
|
|
1035
|
+
const precisionToken = this.advance();
|
|
1036
|
+
const precision = typeof precisionToken.value === 'number' ? precisionToken.value : parseInt(precisionToken.value, 10);
|
|
1037
|
+
this.consume('PUNCTUATION', ',');
|
|
1038
|
+
this.skipNL();
|
|
1039
|
+
const scaleToken = this.advance();
|
|
1040
|
+
const scale = typeof scaleToken.value === 'number' ? scaleToken.value : parseInt(scaleToken.value, 10);
|
|
1041
|
+
this.consume('PUNCTUATION', ')');
|
|
1042
|
+
params = { precision, scale };
|
|
1043
|
+
}
|
|
1044
|
+
if (this.check('OPERATOR', '<')) {
|
|
1045
|
+
this.advance();
|
|
1046
|
+
generic = this.parseType();
|
|
1047
|
+
this.consume('OPERATOR', '>');
|
|
1048
|
+
}
|
|
1049
|
+
const nullable = this.check('OPERATOR', '?') ? (this.advance(), true) : false;
|
|
1050
|
+
// Postfix [] array syntax: string[] is sugar for array<string>
|
|
1051
|
+
const isArray = this.check('PUNCTUATION', '[')
|
|
1052
|
+
&& this.tokens[this.pos + 1]?.type === 'PUNCTUATION'
|
|
1053
|
+
&& this.tokens[this.pos + 1]?.value === ']';
|
|
1054
|
+
if (isArray) {
|
|
1055
|
+
this.advance(); // consume [
|
|
1056
|
+
this.advance(); // consume ]
|
|
1057
|
+
return { type: 'Type', name: 'array', generic: { type: 'Type', name, nullable: false, params }, nullable };
|
|
1058
|
+
}
|
|
1059
|
+
return { type: 'Type', name, generic, nullable, params };
|
|
1060
|
+
}
|
|
1061
|
+
parseBehavior() {
|
|
1062
|
+
if (this.check('KEYWORD', 'behavior'))
|
|
1063
|
+
this.advance();
|
|
1064
|
+
this.consume('KEYWORD', 'on');
|
|
1065
|
+
const trigger = this.parseTrigger();
|
|
1066
|
+
const guards = [];
|
|
1067
|
+
while (this.check('KEYWORD', 'guard') || this.check('KEYWORD', 'when')) {
|
|
1068
|
+
this.advance();
|
|
1069
|
+
guards.push(this.parseExpr());
|
|
1070
|
+
}
|
|
1071
|
+
const actions = [];
|
|
1072
|
+
if (this.check('PUNCTUATION', '{')) {
|
|
1073
|
+
this.advance();
|
|
1074
|
+
this.skipNL();
|
|
1075
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
1076
|
+
this.skipNL();
|
|
1077
|
+
if (this.check('PUNCTUATION', '}'))
|
|
1078
|
+
break;
|
|
1079
|
+
actions.push(this.parseAction());
|
|
1080
|
+
this.skipNL();
|
|
1081
|
+
}
|
|
1082
|
+
this.consume('PUNCTUATION', '}');
|
|
1083
|
+
}
|
|
1084
|
+
else if (this.check('KEYWORD', 'then') || this.check('OPERATOR', '=>')) {
|
|
1085
|
+
this.advance();
|
|
1086
|
+
actions.push(this.parseAction());
|
|
1087
|
+
}
|
|
1088
|
+
return { type: 'Behavior', name: trigger.event, trigger, actions, guards: guards.length ? guards : undefined };
|
|
1089
|
+
}
|
|
1090
|
+
parseTrigger() {
|
|
1091
|
+
const event = this.consumeIdentifier().value;
|
|
1092
|
+
let parameters;
|
|
1093
|
+
if (this.check('PUNCTUATION', '(')) {
|
|
1094
|
+
this.advance();
|
|
1095
|
+
parameters = [];
|
|
1096
|
+
while (!this.check('PUNCTUATION', ')') && !this.isEnd()) {
|
|
1097
|
+
parameters.push(this.consumeIdentifier().value);
|
|
1098
|
+
if (this.check('PUNCTUATION', ','))
|
|
1099
|
+
this.advance();
|
|
1100
|
+
}
|
|
1101
|
+
this.consume('PUNCTUATION', ')');
|
|
1102
|
+
}
|
|
1103
|
+
return { type: 'Trigger', event, parameters };
|
|
1104
|
+
}
|
|
1105
|
+
/**
|
|
1106
|
+
* Lookahead to check if the current `on` keyword starts a reaction
|
|
1107
|
+
* (`on Event run ...` or `on Event fanOut ...`) or a behavior
|
|
1108
|
+
* (`on Event { ... }` / `on Event then ...`).
|
|
1109
|
+
*/
|
|
1110
|
+
isReactionLookahead() {
|
|
1111
|
+
// Current token is 'on'. A reaction is `on <Event> run|fanOut ...`.
|
|
1112
|
+
const eventToken = this.tokens[this.pos + 1];
|
|
1113
|
+
const actionToken = this.tokens[this.pos + 2];
|
|
1114
|
+
return eventToken?.type === 'IDENTIFIER'
|
|
1115
|
+
&& actionToken?.type === 'KEYWORD'
|
|
1116
|
+
&& (actionToken?.value === 'run' || actionToken?.value === 'fanOut');
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Parses an optional `params { name: <expr>, ... }` clause shared by all
|
|
1120
|
+
* reaction forms.
|
|
1121
|
+
*/
|
|
1122
|
+
parseReactionParams() {
|
|
1123
|
+
if (!this.check('KEYWORD', 'params'))
|
|
1124
|
+
return undefined;
|
|
1125
|
+
this.advance(); // consume 'params'
|
|
1126
|
+
const params = [];
|
|
1127
|
+
this.consume('PUNCTUATION', '{');
|
|
1128
|
+
this.skipNL();
|
|
1129
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
1130
|
+
this.skipNL();
|
|
1131
|
+
if (this.check('PUNCTUATION', '}'))
|
|
1132
|
+
break;
|
|
1133
|
+
const name = this.consumeIdentifier().value;
|
|
1134
|
+
this.consume('OPERATOR', ':');
|
|
1135
|
+
const expression = this.parseExpr();
|
|
1136
|
+
params.push({ name, expression });
|
|
1137
|
+
if (this.check('PUNCTUATION', ','))
|
|
1138
|
+
this.advance();
|
|
1139
|
+
this.skipNL();
|
|
1140
|
+
}
|
|
1141
|
+
this.consume('PUNCTUATION', '}');
|
|
1142
|
+
return params;
|
|
1143
|
+
}
|
|
1144
|
+
/**
|
|
1145
|
+
* Parses a reaction. Two forms:
|
|
1146
|
+
*
|
|
1147
|
+
* on <Event> run <EntityType>.<commandName>
|
|
1148
|
+
* resolve <expression>
|
|
1149
|
+
* params { <name>: <expression>, ... }
|
|
1150
|
+
*
|
|
1151
|
+
* on <Event> fanOut <EntityType> where <matchField> = <sourceExpr>
|
|
1152
|
+
* run <commandName>
|
|
1153
|
+
* params { <name>: <expression>, ... }
|
|
1154
|
+
*
|
|
1155
|
+
* The fan-out form dispatches the command on EVERY target row where
|
|
1156
|
+
* `row.<matchField> == <sourceExpr>` (evaluated against the event payload);
|
|
1157
|
+
* the collection match replaces `resolve`.
|
|
1158
|
+
*/
|
|
1159
|
+
parseReaction() {
|
|
1160
|
+
const position = this.current()?.position;
|
|
1161
|
+
this.consume('KEYWORD', 'on');
|
|
1162
|
+
const event = this.consumeIdentifier().value;
|
|
1163
|
+
// Fan-out form: on <Event> fanOut <Target> where <field> = <source> run <cmd>
|
|
1164
|
+
if (this.check('KEYWORD', 'fanOut')) {
|
|
1165
|
+
this.advance(); // consume 'fanOut'
|
|
1166
|
+
const targetEntity = this.consumeIdentifier().value;
|
|
1167
|
+
this.consume('KEYWORD', 'where');
|
|
1168
|
+
const matchField = this.consumeIdentifier().value;
|
|
1169
|
+
this.consume('OPERATOR', '=');
|
|
1170
|
+
const matchSource = this.parseExpr();
|
|
1171
|
+
this.skipNL();
|
|
1172
|
+
this.consume('KEYWORD', 'run');
|
|
1173
|
+
const targetCommand = this.consumeIdentifier().value;
|
|
1174
|
+
this.skipNL();
|
|
1175
|
+
const params = this.parseReactionParams();
|
|
1176
|
+
return {
|
|
1177
|
+
type: 'Reaction', event, targetEntity, targetCommand,
|
|
1178
|
+
fanOut: { matchField, matchSource },
|
|
1179
|
+
...(params ? { params } : {}), position,
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
// Single-target form: on <Event> run <EntityType>.<command> resolve <expr>
|
|
1183
|
+
this.consume('KEYWORD', 'run');
|
|
1184
|
+
const targetEntity = this.consumeIdentifier().value;
|
|
1185
|
+
this.consume('OPERATOR', '.');
|
|
1186
|
+
const targetCommand = this.consumeIdentifier().value;
|
|
1187
|
+
this.skipNL();
|
|
1188
|
+
// Parse 'resolve' clause
|
|
1189
|
+
this.consume('KEYWORD', 'resolve');
|
|
1190
|
+
const resolve = this.parseExpr();
|
|
1191
|
+
this.skipNL();
|
|
1192
|
+
const params = this.parseReactionParams();
|
|
1193
|
+
return { type: 'Reaction', event, targetEntity, targetCommand, resolve, ...(params ? { params } : {}), position };
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Parses: webhook <name> "<path>" run [Entity.]<command>
|
|
1197
|
+
* [method: "POST"]
|
|
1198
|
+
* [signature { algorithm: "hmac-sha256", header: "X-Sig", secret: "context.secret" }]
|
|
1199
|
+
* [idempotencyHeader: "X-Idempotency-Key"]
|
|
1200
|
+
* [transform: { <param>: <expr>, ... }]
|
|
1201
|
+
*/
|
|
1202
|
+
parseWebhook() {
|
|
1203
|
+
const position = this.current()?.position;
|
|
1204
|
+
this.consume('KEYWORD', 'webhook');
|
|
1205
|
+
const name = this.consumeIdentifier().value;
|
|
1206
|
+
this.skipNL();
|
|
1207
|
+
// Parse path string
|
|
1208
|
+
if (!this.check('STRING')) {
|
|
1209
|
+
throw new Error(`Expected path string after webhook '${name}'`);
|
|
1210
|
+
}
|
|
1211
|
+
const path = this.advance().value;
|
|
1212
|
+
this.skipNL();
|
|
1213
|
+
// 'run' keyword
|
|
1214
|
+
this.consume('KEYWORD', 'run');
|
|
1215
|
+
// Parse optional Entity.commandName
|
|
1216
|
+
let entity;
|
|
1217
|
+
let command;
|
|
1218
|
+
const firstIdent = this.consumeIdentifier().value;
|
|
1219
|
+
if (this.check('OPERATOR', '.')) {
|
|
1220
|
+
this.advance(); // consume '.'
|
|
1221
|
+
entity = firstIdent;
|
|
1222
|
+
command = this.consumeIdentifier().value;
|
|
1223
|
+
}
|
|
1224
|
+
else {
|
|
1225
|
+
command = firstIdent;
|
|
1226
|
+
}
|
|
1227
|
+
this.skipNL();
|
|
1228
|
+
// Parse optional block clauses
|
|
1229
|
+
let method;
|
|
1230
|
+
let signature;
|
|
1231
|
+
let idempotencyHeader;
|
|
1232
|
+
let transform;
|
|
1233
|
+
// Lookahead: continue parsing clauses while we see webhook-specific keywords
|
|
1234
|
+
while (!this.isEnd() && (this.check('IDENTIFIER', 'method') ||
|
|
1235
|
+
this.check('KEYWORD', 'signature') ||
|
|
1236
|
+
this.check('KEYWORD', 'idempotencyHeader') ||
|
|
1237
|
+
this.check('KEYWORD', 'transform'))) {
|
|
1238
|
+
if (this.check('IDENTIFIER', 'method')) {
|
|
1239
|
+
this.advance();
|
|
1240
|
+
this.consume('OPERATOR', ':');
|
|
1241
|
+
if (!this.check('STRING')) {
|
|
1242
|
+
throw new Error(`Expected string method after 'method:'`);
|
|
1243
|
+
}
|
|
1244
|
+
method = this.advance().value;
|
|
1245
|
+
}
|
|
1246
|
+
else if (this.check('KEYWORD', 'signature')) {
|
|
1247
|
+
this.advance();
|
|
1248
|
+
signature = this.parseWebhookSignature();
|
|
1249
|
+
}
|
|
1250
|
+
else if (this.check('KEYWORD', 'idempotencyHeader')) {
|
|
1251
|
+
this.advance();
|
|
1252
|
+
this.consume('OPERATOR', ':');
|
|
1253
|
+
if (!this.check('STRING')) {
|
|
1254
|
+
throw new Error(`Expected string header name after 'idempotencyHeader:'`);
|
|
1255
|
+
}
|
|
1256
|
+
idempotencyHeader = this.advance().value;
|
|
1257
|
+
}
|
|
1258
|
+
else if (this.check('KEYWORD', 'transform')) {
|
|
1259
|
+
this.advance();
|
|
1260
|
+
this.consume('OPERATOR', ':');
|
|
1261
|
+
this.consume('PUNCTUATION', '{');
|
|
1262
|
+
this.skipNL();
|
|
1263
|
+
transform = [];
|
|
1264
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
1265
|
+
this.skipNL();
|
|
1266
|
+
if (this.check('PUNCTUATION', '}'))
|
|
1267
|
+
break;
|
|
1268
|
+
const pname = this.consumeIdentifier().value;
|
|
1269
|
+
this.consume('OPERATOR', ':');
|
|
1270
|
+
const pexpr = this.parseExpr();
|
|
1271
|
+
transform.push({ name: pname, expression: pexpr });
|
|
1272
|
+
if (this.check('PUNCTUATION', ','))
|
|
1273
|
+
this.advance();
|
|
1274
|
+
this.skipNL();
|
|
1275
|
+
}
|
|
1276
|
+
this.consume('PUNCTUATION', '}');
|
|
1277
|
+
}
|
|
1278
|
+
this.skipNL();
|
|
1279
|
+
}
|
|
1280
|
+
const node = {
|
|
1281
|
+
type: 'Webhook',
|
|
1282
|
+
name,
|
|
1283
|
+
path,
|
|
1284
|
+
command,
|
|
1285
|
+
position,
|
|
1286
|
+
};
|
|
1287
|
+
if (method)
|
|
1288
|
+
node.method = method;
|
|
1289
|
+
if (entity)
|
|
1290
|
+
node.entity = entity;
|
|
1291
|
+
if (signature)
|
|
1292
|
+
node.signature = signature;
|
|
1293
|
+
if (idempotencyHeader)
|
|
1294
|
+
node.idempotencyHeader = idempotencyHeader;
|
|
1295
|
+
if (transform && transform.length > 0)
|
|
1296
|
+
node.transform = transform;
|
|
1297
|
+
return node;
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* Parses: { algorithm: "hmac-sha256", header: "X-Hub-Signature-256", secret: "context.secret" }
|
|
1301
|
+
*/
|
|
1302
|
+
parseWebhookSignature() {
|
|
1303
|
+
this.consume('PUNCTUATION', '{');
|
|
1304
|
+
this.skipNL();
|
|
1305
|
+
let algorithm;
|
|
1306
|
+
let header;
|
|
1307
|
+
let secret;
|
|
1308
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
1309
|
+
this.skipNL();
|
|
1310
|
+
if (this.check('PUNCTUATION', '}'))
|
|
1311
|
+
break;
|
|
1312
|
+
const field = this.consumeIdentifierOrKeyword().value;
|
|
1313
|
+
this.consume('OPERATOR', ':');
|
|
1314
|
+
if (field === 'algorithm') {
|
|
1315
|
+
if (!this.check('STRING')) {
|
|
1316
|
+
throw new Error(`Expected string algorithm in signature block`);
|
|
1317
|
+
}
|
|
1318
|
+
const alg = this.advance().value;
|
|
1319
|
+
if (alg === 'hmac-sha256' || alg === 'hmac-sha512') {
|
|
1320
|
+
algorithm = alg;
|
|
1321
|
+
}
|
|
1322
|
+
else {
|
|
1323
|
+
throw new Error(`Unsupported signature algorithm '${alg}'. Supported: hmac-sha256, hmac-sha512`);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
else if (field === 'header') {
|
|
1327
|
+
if (!this.check('STRING')) {
|
|
1328
|
+
throw new Error(`Expected string header name in signature block`);
|
|
1329
|
+
}
|
|
1330
|
+
header = this.advance().value;
|
|
1331
|
+
}
|
|
1332
|
+
else if (field === 'secret') {
|
|
1333
|
+
if (!this.check('STRING')) {
|
|
1334
|
+
throw new Error(`Expected string secret path in signature block`);
|
|
1335
|
+
}
|
|
1336
|
+
secret = this.advance().value;
|
|
1337
|
+
}
|
|
1338
|
+
else {
|
|
1339
|
+
// Skip unknown field
|
|
1340
|
+
this.parseExpr();
|
|
1341
|
+
}
|
|
1342
|
+
this.skipNL();
|
|
1343
|
+
if (this.check('PUNCTUATION', ','))
|
|
1344
|
+
this.advance();
|
|
1345
|
+
}
|
|
1346
|
+
this.consume('PUNCTUATION', '}');
|
|
1347
|
+
if (!algorithm || !header || !secret) {
|
|
1348
|
+
throw new Error(`Signature block requires algorithm, header, and secret fields`);
|
|
1349
|
+
}
|
|
1350
|
+
return { type: 'WebhookSignature', algorithm, header, secret };
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Parses: saga <Name> {
|
|
1354
|
+
* step <name> { command: Entity.cmd [compensate: Entity.cmd] }
|
|
1355
|
+
* ...
|
|
1356
|
+
* [on_failure: "compensate"|"abort"]
|
|
1357
|
+
* [emit EventName]
|
|
1358
|
+
* }
|
|
1359
|
+
*
|
|
1360
|
+
* Note: 'step' and 'compensate' are NOT keywords — matched as IDENTIFIERs
|
|
1361
|
+
* to avoid breaking existing code that uses 'step' as a property name.
|
|
1362
|
+
*/
|
|
1363
|
+
parseSaga() {
|
|
1364
|
+
const position = this.current()?.position;
|
|
1365
|
+
this.consume('KEYWORD', 'saga');
|
|
1366
|
+
const name = this.consumeIdentifier().value;
|
|
1367
|
+
this.consume('PUNCTUATION', '{');
|
|
1368
|
+
this.skipNL();
|
|
1369
|
+
const steps = [];
|
|
1370
|
+
let onFailure = 'compensate';
|
|
1371
|
+
const emits = [];
|
|
1372
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
1373
|
+
this.skipNL();
|
|
1374
|
+
if (this.check('PUNCTUATION', '}'))
|
|
1375
|
+
break;
|
|
1376
|
+
if (this.check('IDENTIFIER') && this.current()?.value === 'step') {
|
|
1377
|
+
steps.push(this.parseSagaStep());
|
|
1378
|
+
}
|
|
1379
|
+
else if (this.check('IDENTIFIER') && this.current()?.value === 'on_failure') {
|
|
1380
|
+
this.advance(); // consume 'on_failure'
|
|
1381
|
+
this.consume('OPERATOR', ':');
|
|
1382
|
+
const v = this.check('STRING') ? this.advance().value : this.advance().value;
|
|
1383
|
+
if (v === 'compensate' || v === 'abort')
|
|
1384
|
+
onFailure = v;
|
|
1385
|
+
}
|
|
1386
|
+
else if (this.check('KEYWORD', 'emit')) {
|
|
1387
|
+
this.advance(); // consume 'emit'
|
|
1388
|
+
emits.push(this.consumeIdentifier().value);
|
|
1389
|
+
}
|
|
1390
|
+
else {
|
|
1391
|
+
this.advance();
|
|
1392
|
+
}
|
|
1393
|
+
this.skipNL();
|
|
1394
|
+
}
|
|
1395
|
+
this.consume('PUNCTUATION', '}');
|
|
1396
|
+
if (steps.length === 0) {
|
|
1397
|
+
throw new Error(`Saga '${name}' must declare at least one step`);
|
|
1398
|
+
}
|
|
1399
|
+
return { type: 'Saga', name, steps, onFailure, emits, position };
|
|
1400
|
+
}
|
|
1401
|
+
parseSagaStep() {
|
|
1402
|
+
this.advance(); // consume 'step' (IDENTIFIER, not keyword)
|
|
1403
|
+
const name = this.consumeIdentifier().value;
|
|
1404
|
+
this.consume('PUNCTUATION', '{');
|
|
1405
|
+
this.skipNL();
|
|
1406
|
+
let commandEntity = '', command = '';
|
|
1407
|
+
let compensateEntity, compensate;
|
|
1408
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
1409
|
+
this.skipNL();
|
|
1410
|
+
if (this.check('PUNCTUATION', '}'))
|
|
1411
|
+
break;
|
|
1412
|
+
if (this.check('KEYWORD', 'command')) {
|
|
1413
|
+
this.advance(); // consume 'command'
|
|
1414
|
+
this.consume('OPERATOR', ':');
|
|
1415
|
+
commandEntity = this.consumeIdentifier().value;
|
|
1416
|
+
this.consume('OPERATOR', '.');
|
|
1417
|
+
command = this.consumeIdentifier().value;
|
|
1418
|
+
}
|
|
1419
|
+
else if (this.check('IDENTIFIER') && this.current()?.value === 'compensate') {
|
|
1420
|
+
this.advance(); // consume 'compensate'
|
|
1421
|
+
this.consume('OPERATOR', ':');
|
|
1422
|
+
compensateEntity = this.consumeIdentifier().value;
|
|
1423
|
+
this.consume('OPERATOR', '.');
|
|
1424
|
+
compensate = this.consumeIdentifier().value;
|
|
1425
|
+
}
|
|
1426
|
+
else {
|
|
1427
|
+
this.advance();
|
|
1428
|
+
}
|
|
1429
|
+
this.skipNL();
|
|
1430
|
+
}
|
|
1431
|
+
this.consume('PUNCTUATION', '}');
|
|
1432
|
+
if (!command) {
|
|
1433
|
+
throw new Error(`Saga step '${name}' must specify a command`);
|
|
1434
|
+
}
|
|
1435
|
+
const node = { type: 'SagaStep', name, commandEntity, command };
|
|
1436
|
+
if (compensate) {
|
|
1437
|
+
node.compensateEntity = compensateEntity;
|
|
1438
|
+
node.compensate = compensate;
|
|
1439
|
+
}
|
|
1440
|
+
return node;
|
|
1441
|
+
}
|
|
1442
|
+
parseAction() {
|
|
1443
|
+
let kind = 'compute', target;
|
|
1444
|
+
if (this.check('KEYWORD', 'mutate')) {
|
|
1445
|
+
this.advance();
|
|
1446
|
+
kind = 'mutate';
|
|
1447
|
+
target = this.consumeIdentifier().value;
|
|
1448
|
+
this.consume('OPERATOR', '=');
|
|
1449
|
+
}
|
|
1450
|
+
else if (this.check('KEYWORD', 'emit')) {
|
|
1451
|
+
this.advance();
|
|
1452
|
+
kind = 'emit';
|
|
1453
|
+
}
|
|
1454
|
+
else if (this.check('KEYWORD', 'effect')) {
|
|
1455
|
+
this.advance();
|
|
1456
|
+
kind = 'effect';
|
|
1457
|
+
}
|
|
1458
|
+
else if (this.check('KEYWORD', 'publish')) {
|
|
1459
|
+
this.advance();
|
|
1460
|
+
kind = 'publish';
|
|
1461
|
+
}
|
|
1462
|
+
else if (this.check('KEYWORD', 'persist')) {
|
|
1463
|
+
this.advance();
|
|
1464
|
+
kind = 'persist';
|
|
1465
|
+
}
|
|
1466
|
+
else if (this.check('KEYWORD', 'compute')) {
|
|
1467
|
+
this.advance();
|
|
1468
|
+
kind = 'compute';
|
|
1469
|
+
// Check for assignment form: compute <identifier> = <expr>
|
|
1470
|
+
const nextToken = this.tokens[this.pos + 1];
|
|
1471
|
+
if (this.check('IDENTIFIER') && nextToken?.type === 'OPERATOR' && nextToken?.value === '=') {
|
|
1472
|
+
target = this.consumeIdentifier().value;
|
|
1473
|
+
this.consume('OPERATOR', '=');
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
return { type: 'Action', kind, target, expression: this.parseExpr() };
|
|
1477
|
+
}
|
|
1478
|
+
parseConstraint() {
|
|
1479
|
+
this.consume('KEYWORD', 'constraint');
|
|
1480
|
+
// Check for overrideable modifier
|
|
1481
|
+
let overrideable = false;
|
|
1482
|
+
if (this.check('KEYWORD', 'overrideable')) {
|
|
1483
|
+
this.advance();
|
|
1484
|
+
overrideable = true;
|
|
1485
|
+
}
|
|
1486
|
+
const name = this.consumeIdentifier().value;
|
|
1487
|
+
// Declare variables that may be used in both paths
|
|
1488
|
+
let code;
|
|
1489
|
+
let severity;
|
|
1490
|
+
let message;
|
|
1491
|
+
let messageTemplate;
|
|
1492
|
+
let detailsMapping;
|
|
1493
|
+
let overridePolicyRef;
|
|
1494
|
+
// Check for block syntax: constraint <name> { ... }
|
|
1495
|
+
if (this.check('PUNCTUATION', '{')) {
|
|
1496
|
+
this.advance();
|
|
1497
|
+
this.skipNL();
|
|
1498
|
+
let expression;
|
|
1499
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
1500
|
+
this.skipNL();
|
|
1501
|
+
if (this.check('PUNCTUATION', '}'))
|
|
1502
|
+
break;
|
|
1503
|
+
const field = this.consumeIdentifierOrKeyword().value;
|
|
1504
|
+
this.consume('OPERATOR', ':');
|
|
1505
|
+
switch (field) {
|
|
1506
|
+
case 'code':
|
|
1507
|
+
code = this.consumeIdentifier().value;
|
|
1508
|
+
break;
|
|
1509
|
+
case 'severity': {
|
|
1510
|
+
const sev = this.consumeIdentifierOrKeyword().value;
|
|
1511
|
+
if (sev === 'ok' || sev === 'warn' || sev === 'block') {
|
|
1512
|
+
severity = sev;
|
|
1513
|
+
}
|
|
1514
|
+
break;
|
|
1515
|
+
}
|
|
1516
|
+
case 'expression':
|
|
1517
|
+
expression = this.parseExpr();
|
|
1518
|
+
break;
|
|
1519
|
+
case 'message':
|
|
1520
|
+
message = this.check('STRING') ? this.advance().value : undefined;
|
|
1521
|
+
break;
|
|
1522
|
+
case 'messageTemplate':
|
|
1523
|
+
messageTemplate = this.check('STRING') ? this.advance().value : undefined;
|
|
1524
|
+
break;
|
|
1525
|
+
case 'overridePolicy':
|
|
1526
|
+
overridePolicyRef = this.consumeIdentifier().value;
|
|
1527
|
+
break;
|
|
1528
|
+
case 'details':
|
|
1529
|
+
detailsMapping = {};
|
|
1530
|
+
if (this.check('PUNCTUATION', '{')) {
|
|
1531
|
+
this.advance();
|
|
1532
|
+
this.skipNL();
|
|
1533
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
1534
|
+
this.skipNL();
|
|
1535
|
+
if (this.check('PUNCTUATION', '}'))
|
|
1536
|
+
break;
|
|
1537
|
+
const key = this.consumeIdentifierOrKeyword().value;
|
|
1538
|
+
this.consume('OPERATOR', ':');
|
|
1539
|
+
detailsMapping[key] = this.parseExpr();
|
|
1540
|
+
this.skipNL();
|
|
1541
|
+
if (this.check('PUNCTUATION', ','))
|
|
1542
|
+
this.advance();
|
|
1543
|
+
}
|
|
1544
|
+
this.consume('PUNCTUATION', '}');
|
|
1545
|
+
}
|
|
1546
|
+
break;
|
|
1547
|
+
default:
|
|
1548
|
+
// Unknown field, skip the expression
|
|
1549
|
+
this.parseExpr();
|
|
1550
|
+
}
|
|
1551
|
+
this.skipNL();
|
|
1552
|
+
if (this.check('PUNCTUATION', ','))
|
|
1553
|
+
this.advance();
|
|
1554
|
+
}
|
|
1555
|
+
this.consume('PUNCTUATION', '}');
|
|
1556
|
+
if (!expression) {
|
|
1557
|
+
throw new Error('Constraint block must include an expression');
|
|
1558
|
+
}
|
|
1559
|
+
return {
|
|
1560
|
+
type: 'Constraint',
|
|
1561
|
+
name,
|
|
1562
|
+
code,
|
|
1563
|
+
expression,
|
|
1564
|
+
severity: severity || 'block',
|
|
1565
|
+
message,
|
|
1566
|
+
messageTemplate,
|
|
1567
|
+
detailsMapping,
|
|
1568
|
+
overrideable,
|
|
1569
|
+
overridePolicyRef,
|
|
1570
|
+
};
|
|
1571
|
+
}
|
|
1572
|
+
// Inline syntax: constraint <name>[:severity] <expression> ["<message>"]
|
|
1573
|
+
this.consume('OPERATOR', ':');
|
|
1574
|
+
// Check for severity suffix (name:ok, name:warn, name:block)
|
|
1575
|
+
if (this.check('KEYWORD', 'ok') || this.check('KEYWORD', 'warn') || this.check('KEYWORD', 'block')) {
|
|
1576
|
+
const sev = this.advance().value;
|
|
1577
|
+
severity = sev;
|
|
1578
|
+
}
|
|
1579
|
+
const expression = this.parseExpr();
|
|
1580
|
+
message = this.check('STRING') ? this.advance().value : undefined;
|
|
1581
|
+
// Check for optional block after inline expression:
|
|
1582
|
+
// constraint name:severity <expr> { messageTemplate: "...", details: { ... } }
|
|
1583
|
+
// This is the hybrid inline+block syntax used in production manifests.
|
|
1584
|
+
if (this.check('PUNCTUATION', '{')) {
|
|
1585
|
+
this.advance();
|
|
1586
|
+
this.skipNL();
|
|
1587
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
1588
|
+
this.skipNL();
|
|
1589
|
+
if (this.check('PUNCTUATION', '}'))
|
|
1590
|
+
break;
|
|
1591
|
+
const field = this.consumeIdentifierOrKeyword().value;
|
|
1592
|
+
this.consume('OPERATOR', ':');
|
|
1593
|
+
switch (field) {
|
|
1594
|
+
case 'code':
|
|
1595
|
+
code = this.consumeIdentifier().value;
|
|
1596
|
+
break;
|
|
1597
|
+
case 'message':
|
|
1598
|
+
message = this.check('STRING') ? this.advance().value : undefined;
|
|
1599
|
+
break;
|
|
1600
|
+
case 'messageTemplate':
|
|
1601
|
+
messageTemplate = this.check('STRING') ? this.advance().value : undefined;
|
|
1602
|
+
break;
|
|
1603
|
+
case 'overridePolicy':
|
|
1604
|
+
overridePolicyRef = this.consumeIdentifier().value;
|
|
1605
|
+
break;
|
|
1606
|
+
case 'details':
|
|
1607
|
+
detailsMapping = {};
|
|
1608
|
+
if (this.check('PUNCTUATION', '{')) {
|
|
1609
|
+
this.advance();
|
|
1610
|
+
this.skipNL();
|
|
1611
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
1612
|
+
this.skipNL();
|
|
1613
|
+
if (this.check('PUNCTUATION', '}'))
|
|
1614
|
+
break;
|
|
1615
|
+
const key = this.consumeIdentifierOrKeyword().value;
|
|
1616
|
+
this.consume('OPERATOR', ':');
|
|
1617
|
+
detailsMapping[key] = this.parseExpr();
|
|
1618
|
+
this.skipNL();
|
|
1619
|
+
if (this.check('PUNCTUATION', ','))
|
|
1620
|
+
this.advance();
|
|
1621
|
+
}
|
|
1622
|
+
this.consume('PUNCTUATION', '}');
|
|
1623
|
+
}
|
|
1624
|
+
break;
|
|
1625
|
+
default:
|
|
1626
|
+
// Unknown field, skip the expression
|
|
1627
|
+
this.parseExpr();
|
|
1628
|
+
}
|
|
1629
|
+
this.skipNL();
|
|
1630
|
+
if (this.check('PUNCTUATION', ','))
|
|
1631
|
+
this.advance();
|
|
1632
|
+
}
|
|
1633
|
+
this.consume('PUNCTUATION', '}');
|
|
1634
|
+
}
|
|
1635
|
+
return {
|
|
1636
|
+
type: 'Constraint',
|
|
1637
|
+
name,
|
|
1638
|
+
code,
|
|
1639
|
+
expression,
|
|
1640
|
+
severity: severity || 'block',
|
|
1641
|
+
message,
|
|
1642
|
+
messageTemplate,
|
|
1643
|
+
detailsMapping,
|
|
1644
|
+
overrideable,
|
|
1645
|
+
overridePolicyRef,
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
parseFlow() {
|
|
1649
|
+
this.consume('KEYWORD', 'flow');
|
|
1650
|
+
const name = this.consumeIdentifier().value;
|
|
1651
|
+
this.consume('PUNCTUATION', '(');
|
|
1652
|
+
const input = this.parseType();
|
|
1653
|
+
this.consume('PUNCTUATION', ')');
|
|
1654
|
+
this.consume('OPERATOR', '->');
|
|
1655
|
+
const output = this.parseType();
|
|
1656
|
+
this.consume('PUNCTUATION', '{');
|
|
1657
|
+
this.skipNL();
|
|
1658
|
+
const steps = [];
|
|
1659
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
1660
|
+
this.skipNL();
|
|
1661
|
+
if (this.check('PUNCTUATION', '}'))
|
|
1662
|
+
break;
|
|
1663
|
+
steps.push(this.parseFlowStep());
|
|
1664
|
+
this.skipNL();
|
|
1665
|
+
}
|
|
1666
|
+
this.consume('PUNCTUATION', '}');
|
|
1667
|
+
return { type: 'Flow', name, input, output, steps };
|
|
1668
|
+
}
|
|
1669
|
+
parseFlowStep() {
|
|
1670
|
+
const operation = this.advance().value;
|
|
1671
|
+
let condition;
|
|
1672
|
+
if (this.check('KEYWORD', 'when')) {
|
|
1673
|
+
this.advance();
|
|
1674
|
+
condition = this.parseExpr();
|
|
1675
|
+
}
|
|
1676
|
+
this.consume('OPERATOR', ':');
|
|
1677
|
+
return { type: 'FlowStep', operation, expression: this.parseExpr(), condition };
|
|
1678
|
+
}
|
|
1679
|
+
parseEffect() {
|
|
1680
|
+
this.consume('KEYWORD', 'effect');
|
|
1681
|
+
const name = this.consumeIdentifier().value;
|
|
1682
|
+
this.consume('OPERATOR', ':');
|
|
1683
|
+
const kind = this.advance().value;
|
|
1684
|
+
const config = {};
|
|
1685
|
+
if (this.check('PUNCTUATION', '{')) {
|
|
1686
|
+
this.advance();
|
|
1687
|
+
this.skipNL();
|
|
1688
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
1689
|
+
this.skipNL();
|
|
1690
|
+
if (this.check('PUNCTUATION', '}'))
|
|
1691
|
+
break;
|
|
1692
|
+
// Config keys are like object literal keys - allow keywords
|
|
1693
|
+
const key = this.consumeIdentifierOrKeyword().value;
|
|
1694
|
+
this.consume('OPERATOR', ':');
|
|
1695
|
+
config[key] = this.parseExpr();
|
|
1696
|
+
this.skipNL();
|
|
1697
|
+
}
|
|
1698
|
+
this.consume('PUNCTUATION', '}');
|
|
1699
|
+
}
|
|
1700
|
+
return { type: 'Effect', name, kind, config };
|
|
1701
|
+
}
|
|
1702
|
+
parseExpose() {
|
|
1703
|
+
this.consume('KEYWORD', 'expose');
|
|
1704
|
+
const entity = this.consumeIdentifier().value;
|
|
1705
|
+
this.consume('KEYWORD', 'as');
|
|
1706
|
+
const protocol = this.advance().value;
|
|
1707
|
+
let name = entity.toLowerCase();
|
|
1708
|
+
let generateServer = false;
|
|
1709
|
+
if (this.check('KEYWORD', 'server')) {
|
|
1710
|
+
this.advance();
|
|
1711
|
+
generateServer = true;
|
|
1712
|
+
}
|
|
1713
|
+
if (this.check('STRING'))
|
|
1714
|
+
name = this.advance().value;
|
|
1715
|
+
const operations = [], middleware = [];
|
|
1716
|
+
if (this.check('PUNCTUATION', '{')) {
|
|
1717
|
+
this.advance();
|
|
1718
|
+
this.skipNL();
|
|
1719
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
1720
|
+
this.skipNL();
|
|
1721
|
+
if (this.check('PUNCTUATION', '}'))
|
|
1722
|
+
break;
|
|
1723
|
+
const val = this.advance().value;
|
|
1724
|
+
if (val === 'middleware') {
|
|
1725
|
+
this.consume('OPERATOR', ':');
|
|
1726
|
+
middleware.push(this.consumeIdentifier().value);
|
|
1727
|
+
}
|
|
1728
|
+
else
|
|
1729
|
+
operations.push(val);
|
|
1730
|
+
if (this.check('PUNCTUATION', ','))
|
|
1731
|
+
this.advance();
|
|
1732
|
+
this.skipNL();
|
|
1733
|
+
}
|
|
1734
|
+
this.consume('PUNCTUATION', '}');
|
|
1735
|
+
}
|
|
1736
|
+
return { type: 'Expose', name, protocol, entity, operations, generateServer, middleware: middleware.length ? middleware : undefined };
|
|
1737
|
+
}
|
|
1738
|
+
parseComposition() {
|
|
1739
|
+
this.consume('KEYWORD', 'compose');
|
|
1740
|
+
const name = this.consumeIdentifier().value;
|
|
1741
|
+
this.consume('PUNCTUATION', '{');
|
|
1742
|
+
this.skipNL();
|
|
1743
|
+
const components = [], connections = [];
|
|
1744
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
1745
|
+
this.skipNL();
|
|
1746
|
+
if (this.check('PUNCTUATION', '}'))
|
|
1747
|
+
break;
|
|
1748
|
+
if (this.check('KEYWORD', 'connect'))
|
|
1749
|
+
connections.push(this.parseConnection());
|
|
1750
|
+
else
|
|
1751
|
+
components.push(this.parseComponentRef());
|
|
1752
|
+
this.skipNL();
|
|
1753
|
+
}
|
|
1754
|
+
this.consume('PUNCTUATION', '}');
|
|
1755
|
+
return { type: 'Composition', name, components, connections };
|
|
1756
|
+
}
|
|
1757
|
+
parseComponentRef() {
|
|
1758
|
+
const entity = this.consumeIdentifier().value;
|
|
1759
|
+
let alias;
|
|
1760
|
+
if (this.check('KEYWORD', 'as')) {
|
|
1761
|
+
this.advance();
|
|
1762
|
+
alias = this.consumeIdentifier().value;
|
|
1763
|
+
}
|
|
1764
|
+
return { type: 'ComponentRef', entity, alias };
|
|
1765
|
+
}
|
|
1766
|
+
parseConnection() {
|
|
1767
|
+
this.consume('KEYWORD', 'connect');
|
|
1768
|
+
// Component names are references to declared components (use consumeIdentifier for declaration-like reference)
|
|
1769
|
+
// Port names after '.' are member-access-like (use consumeIdentifierOrKeyword to allow keywords)
|
|
1770
|
+
const fromComponent = this.consumeIdentifier().value;
|
|
1771
|
+
this.consume('OPERATOR', '.');
|
|
1772
|
+
const fromOutput = this.consumeIdentifierOrKeyword().value;
|
|
1773
|
+
this.consume('OPERATOR', '->');
|
|
1774
|
+
const toComponent = this.consumeIdentifier().value;
|
|
1775
|
+
this.consume('OPERATOR', '.');
|
|
1776
|
+
const toInput = this.consumeIdentifierOrKeyword().value;
|
|
1777
|
+
let transform;
|
|
1778
|
+
if (this.check('KEYWORD', 'with')) {
|
|
1779
|
+
this.advance();
|
|
1780
|
+
transform = this.parseExpr();
|
|
1781
|
+
}
|
|
1782
|
+
return { type: 'Connection', from: { component: fromComponent, output: fromOutput }, to: { component: toComponent, input: toInput }, transform };
|
|
1783
|
+
}
|
|
1784
|
+
parseExpr() { return this.parseTernary(); }
|
|
1785
|
+
parseTernary() {
|
|
1786
|
+
const expr = this.parseOr();
|
|
1787
|
+
if (this.check('OPERATOR', '?')) {
|
|
1788
|
+
this.advance();
|
|
1789
|
+
const cons = this.parseExpr();
|
|
1790
|
+
this.consume('OPERATOR', ':');
|
|
1791
|
+
const alt = this.parseExpr();
|
|
1792
|
+
return { type: 'Conditional', condition: expr, consequent: cons, alternate: alt };
|
|
1793
|
+
}
|
|
1794
|
+
return expr;
|
|
1795
|
+
}
|
|
1796
|
+
parseOr() {
|
|
1797
|
+
let left = this.parseAnd();
|
|
1798
|
+
while (this.check('OPERATOR', '||') || this.check('KEYWORD', 'or')) {
|
|
1799
|
+
const op = this.advance().value;
|
|
1800
|
+
left = { type: 'BinaryOp', operator: op, left, right: this.parseAnd() };
|
|
1801
|
+
}
|
|
1802
|
+
return left;
|
|
1803
|
+
}
|
|
1804
|
+
parseAnd() {
|
|
1805
|
+
let left = this.parseEquality();
|
|
1806
|
+
while (this.check('OPERATOR', '&&') || this.check('KEYWORD', 'and')) {
|
|
1807
|
+
const op = this.advance().value;
|
|
1808
|
+
left = { type: 'BinaryOp', operator: op, left, right: this.parseEquality() };
|
|
1809
|
+
}
|
|
1810
|
+
return left;
|
|
1811
|
+
}
|
|
1812
|
+
parseEquality() {
|
|
1813
|
+
let left = this.parseComparison();
|
|
1814
|
+
while (['==', '!='].includes(this.current()?.value || '') || ['is', 'in', 'contains'].includes(this.current()?.value || '')) {
|
|
1815
|
+
const op = this.advance().value;
|
|
1816
|
+
left = { type: 'BinaryOp', operator: op, left, right: this.parseComparison() };
|
|
1817
|
+
}
|
|
1818
|
+
return left;
|
|
1819
|
+
}
|
|
1820
|
+
parseComparison() {
|
|
1821
|
+
let left = this.parseAdditive();
|
|
1822
|
+
while (['<', '>', '<=', '>='].includes(this.current()?.value || '')) {
|
|
1823
|
+
const op = this.advance().value;
|
|
1824
|
+
left = { type: 'BinaryOp', operator: op, left, right: this.parseAdditive() };
|
|
1825
|
+
}
|
|
1826
|
+
return left;
|
|
1827
|
+
}
|
|
1828
|
+
parseAdditive() {
|
|
1829
|
+
let left = this.parseMultiplicative();
|
|
1830
|
+
while (['+', '-'].includes(this.current()?.value || '')) {
|
|
1831
|
+
const op = this.advance().value;
|
|
1832
|
+
left = { type: 'BinaryOp', operator: op, left, right: this.parseMultiplicative() };
|
|
1833
|
+
}
|
|
1834
|
+
return left;
|
|
1835
|
+
}
|
|
1836
|
+
parseMultiplicative() {
|
|
1837
|
+
let left = this.parseUnary();
|
|
1838
|
+
while (['*', '/', '%'].includes(this.current()?.value || '')) {
|
|
1839
|
+
const op = this.advance().value;
|
|
1840
|
+
left = { type: 'BinaryOp', operator: op, left, right: this.parseUnary() };
|
|
1841
|
+
}
|
|
1842
|
+
return left;
|
|
1843
|
+
}
|
|
1844
|
+
parseUnary() {
|
|
1845
|
+
if (['!', '-'].includes(this.current()?.value || '') || this.check('KEYWORD', 'not')) {
|
|
1846
|
+
const op = this.advance().value;
|
|
1847
|
+
return { type: 'UnaryOp', operator: op, operand: this.parseUnary() };
|
|
1848
|
+
}
|
|
1849
|
+
return this.parsePostfix();
|
|
1850
|
+
}
|
|
1851
|
+
parsePostfix() {
|
|
1852
|
+
let expr = this.parsePrimary();
|
|
1853
|
+
while (true) {
|
|
1854
|
+
// Member access: allow both identifiers AND keywords as property names (e.g., obj.entity, obj.command)
|
|
1855
|
+
if (this.check('OPERATOR', '.') || this.check('OPERATOR', '?.')) {
|
|
1856
|
+
this.advance();
|
|
1857
|
+
expr = { type: 'MemberAccess', object: expr, property: this.consumeIdentifierOrKeyword().value };
|
|
1858
|
+
}
|
|
1859
|
+
else if (this.check('PUNCTUATION', '(')) {
|
|
1860
|
+
this.advance();
|
|
1861
|
+
const args = [];
|
|
1862
|
+
while (!this.check('PUNCTUATION', ')') && !this.isEnd()) {
|
|
1863
|
+
args.push(this.parseExpr());
|
|
1864
|
+
if (this.check('PUNCTUATION', ','))
|
|
1865
|
+
this.advance();
|
|
1866
|
+
}
|
|
1867
|
+
this.consume('PUNCTUATION', ')');
|
|
1868
|
+
expr = { type: 'Call', callee: expr, arguments: args };
|
|
1869
|
+
}
|
|
1870
|
+
else if (this.check('PUNCTUATION', '[')) {
|
|
1871
|
+
this.advance();
|
|
1872
|
+
const idx = this.parseExpr();
|
|
1873
|
+
this.consume('PUNCTUATION', ']');
|
|
1874
|
+
expr = { type: 'MemberAccess', object: expr, property: `[${'value' in idx ? idx.value : ''}]` };
|
|
1875
|
+
}
|
|
1876
|
+
else
|
|
1877
|
+
break;
|
|
1878
|
+
}
|
|
1879
|
+
return expr;
|
|
1880
|
+
}
|
|
1881
|
+
parsePrimary() {
|
|
1882
|
+
if (this.check('NUMBER'))
|
|
1883
|
+
return { type: 'Literal', value: parseFloat(this.advance().value), dataType: 'number' };
|
|
1884
|
+
if (this.check('STRING'))
|
|
1885
|
+
return { type: 'Literal', value: this.advance().value, dataType: 'string' };
|
|
1886
|
+
if (this.check('KEYWORD', 'true') || this.check('KEYWORD', 'false'))
|
|
1887
|
+
return { type: 'Literal', value: this.advance().value === 'true', dataType: 'boolean' };
|
|
1888
|
+
if (this.check('KEYWORD', 'null')) {
|
|
1889
|
+
this.advance();
|
|
1890
|
+
return { type: 'Literal', value: null, dataType: 'null' };
|
|
1891
|
+
}
|
|
1892
|
+
// Aggregate count expression — `count(Entity where field == value, ...)`.
|
|
1893
|
+
// `count` is a contextual keyword (NOT reserved): recognized only when it
|
|
1894
|
+
// starts the unambiguous aggregate shape `count ( <Entity> where`. Any other
|
|
1895
|
+
// `count(...)` parses as an ordinary function call below / in parsePostfix.
|
|
1896
|
+
if (this.isAggregateCountLookahead())
|
|
1897
|
+
return this.parseAggregateCount();
|
|
1898
|
+
if (this.check('PUNCTUATION', '[')) {
|
|
1899
|
+
this.advance();
|
|
1900
|
+
const els = [];
|
|
1901
|
+
while (!this.check('PUNCTUATION', ']') && !this.isEnd()) {
|
|
1902
|
+
els.push(this.parseExpr());
|
|
1903
|
+
if (this.check('PUNCTUATION', ','))
|
|
1904
|
+
this.advance();
|
|
1905
|
+
}
|
|
1906
|
+
this.consume('PUNCTUATION', ']');
|
|
1907
|
+
return { type: 'Array', elements: els };
|
|
1908
|
+
}
|
|
1909
|
+
// Object literal: allow both identifiers AND keywords as unquoted keys (e.g., { entity: 1, command: 2 })
|
|
1910
|
+
if (this.check('PUNCTUATION', '{')) {
|
|
1911
|
+
this.advance();
|
|
1912
|
+
this.skipNL();
|
|
1913
|
+
const props = [];
|
|
1914
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
1915
|
+
this.skipNL();
|
|
1916
|
+
if (this.check('PUNCTUATION', '}'))
|
|
1917
|
+
break;
|
|
1918
|
+
const key = this.check('STRING') ? this.advance().value : this.consumeIdentifierOrKeyword().value;
|
|
1919
|
+
this.consume('OPERATOR', ':');
|
|
1920
|
+
props.push({ key, value: this.parseExpr() });
|
|
1921
|
+
if (this.check('PUNCTUATION', ','))
|
|
1922
|
+
this.advance();
|
|
1923
|
+
this.skipNL();
|
|
1924
|
+
}
|
|
1925
|
+
this.consume('PUNCTUATION', '}');
|
|
1926
|
+
return { type: 'Object', properties: props };
|
|
1927
|
+
}
|
|
1928
|
+
// Lambda or parenthesized expression
|
|
1929
|
+
if (this.check('PUNCTUATION', '(')) {
|
|
1930
|
+
this.advance();
|
|
1931
|
+
const startPos = this.pos;
|
|
1932
|
+
const params = [];
|
|
1933
|
+
// Try to parse lambda parameters (identifiers only - reserved words not allowed as parameter declarations)
|
|
1934
|
+
while (this.check('IDENTIFIER') && !this.isEnd()) {
|
|
1935
|
+
params.push(this.advance().value);
|
|
1936
|
+
if (this.check('PUNCTUATION', ','))
|
|
1937
|
+
this.advance();
|
|
1938
|
+
else
|
|
1939
|
+
break;
|
|
1940
|
+
}
|
|
1941
|
+
// Check if this looks like a lambda: (params) =>
|
|
1942
|
+
if (this.check('PUNCTUATION', ')')) {
|
|
1943
|
+
this.advance();
|
|
1944
|
+
if (this.check('OPERATOR', '=>')) {
|
|
1945
|
+
this.advance();
|
|
1946
|
+
return { type: 'Lambda', parameters: params, body: this.parseExpr() };
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
// Not a lambda, backtrack and parse as parenthesized expression
|
|
1950
|
+
this.pos = startPos;
|
|
1951
|
+
const expr = this.parseExpr();
|
|
1952
|
+
this.consume('PUNCTUATION', ')');
|
|
1953
|
+
return expr;
|
|
1954
|
+
}
|
|
1955
|
+
if (this.check('IDENTIFIER') || this.check('KEYWORD', 'user') || this.check('KEYWORD', 'self') || this.check('KEYWORD', 'context'))
|
|
1956
|
+
return { type: 'Identifier', name: this.advance().value };
|
|
1957
|
+
throw new Error(`Unexpected: ${this.current()?.value || 'EOF'}`);
|
|
1958
|
+
}
|
|
1959
|
+
/**
|
|
1960
|
+
* True when the upcoming tokens form the aggregate-count shape
|
|
1961
|
+
* `count ( <Entity> where ...` — the only form in which the otherwise-free
|
|
1962
|
+
* identifier `count` is treated as the aggregate operator.
|
|
1963
|
+
*/
|
|
1964
|
+
isAggregateCountLookahead() {
|
|
1965
|
+
if (!this.check('IDENTIFIER', 'count'))
|
|
1966
|
+
return false;
|
|
1967
|
+
const t1 = this.tokens[this.pos + 1];
|
|
1968
|
+
const t2 = this.tokens[this.pos + 2];
|
|
1969
|
+
const t3 = this.tokens[this.pos + 3];
|
|
1970
|
+
return !!t1 && t1.type === 'PUNCTUATION' && t1.value === '('
|
|
1971
|
+
&& !!t2 && t2.type === 'IDENTIFIER'
|
|
1972
|
+
&& !!t3 && t3.type === 'KEYWORD' && t3.value === 'where';
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Parses `count(Entity where field == value, field2 == value2, ...)`.
|
|
1976
|
+
* Every predicate is a pure equality (`==`); predicates are ANDed. At least
|
|
1977
|
+
* one predicate (the foreign-key match) is required — a zero-predicate count
|
|
1978
|
+
* would be an unbounded table scan, the analytics/reporting smell this
|
|
1979
|
+
* primitive deliberately avoids.
|
|
1980
|
+
*/
|
|
1981
|
+
parseAggregateCount() {
|
|
1982
|
+
const position = this.current()?.position;
|
|
1983
|
+
this.advance(); // consume 'count'
|
|
1984
|
+
this.consume('PUNCTUATION', '(');
|
|
1985
|
+
const entity = this.consumeIdentifier().value;
|
|
1986
|
+
this.consume('KEYWORD', 'where');
|
|
1987
|
+
const predicates = [];
|
|
1988
|
+
this.skipNL();
|
|
1989
|
+
while (!this.check('PUNCTUATION', ')') && !this.isEnd()) {
|
|
1990
|
+
this.skipNL();
|
|
1991
|
+
if (this.check('PUNCTUATION', ')'))
|
|
1992
|
+
break;
|
|
1993
|
+
const field = this.consumeIdentifier().value;
|
|
1994
|
+
this.consume('OPERATOR', '==');
|
|
1995
|
+
const value = this.parseExpr();
|
|
1996
|
+
predicates.push({ field, value });
|
|
1997
|
+
if (this.check('PUNCTUATION', ','))
|
|
1998
|
+
this.advance();
|
|
1999
|
+
this.skipNL();
|
|
2000
|
+
}
|
|
2001
|
+
this.consume('PUNCTUATION', ')');
|
|
2002
|
+
if (predicates.length === 0) {
|
|
2003
|
+
this.errors.push({
|
|
2004
|
+
message: `count(${entity} where ...) requires at least one equality predicate (the foreign-key match)`,
|
|
2005
|
+
position,
|
|
2006
|
+
severity: 'error',
|
|
2007
|
+
});
|
|
2008
|
+
}
|
|
2009
|
+
return { type: 'AggregateCount', entity, predicates, position };
|
|
2010
|
+
}
|
|
2011
|
+
check(type, value) { const t = this.current(); return t && t.type === type && (value === undefined || t.value === value); }
|
|
2012
|
+
/** Lookahead: true if the token `offset` positions ahead is a keyword with the given value. */
|
|
2013
|
+
peekIsKeyword(offset, value) { const t = this.tokens[this.pos + offset]; return !!t && t.type === 'KEYWORD' && t.value === value; }
|
|
2014
|
+
consume(type, value) { if (this.check(type, value))
|
|
2015
|
+
return this.advance(); throw new Error(`Expected ${value || type}, got ${this.current()?.value || 'EOF'}`); }
|
|
2016
|
+
/**
|
|
2017
|
+
* Consumes a declaration identifier token, enforcing the reserved word rule.
|
|
2018
|
+
* Use this ONLY at declaration sites (entity/module/command/property/parameter names, etc.).
|
|
2019
|
+
* Do NOT use for expression member access or object literal keys.
|
|
2020
|
+
*
|
|
2021
|
+
* If the current token is a KEYWORD (reserved word), emits a structured diagnostic
|
|
2022
|
+
* and returns a placeholder token to allow continued parsing (for better error recovery).
|
|
2023
|
+
*/
|
|
2024
|
+
consumeIdentifier() {
|
|
2025
|
+
const token = this.current();
|
|
2026
|
+
if (token && token.type === 'KEYWORD') {
|
|
2027
|
+
// Emit structured diagnostic with position from the reserved word token
|
|
2028
|
+
this.errors.push({
|
|
2029
|
+
message: `Reserved word '${token.value}' cannot be used as an identifier`,
|
|
2030
|
+
position: token.position,
|
|
2031
|
+
severity: 'error'
|
|
2032
|
+
});
|
|
2033
|
+
// Advance past the keyword and return it as a placeholder to continue parsing
|
|
2034
|
+
return this.advance();
|
|
2035
|
+
}
|
|
2036
|
+
return this.consume('IDENTIFIER');
|
|
2037
|
+
}
|
|
2038
|
+
/**
|
|
2039
|
+
* Consumes any identifier-like token (IDENTIFIER or KEYWORD) for use in expressions.
|
|
2040
|
+
* This is used for member access properties and object literal keys where keywords are allowed.
|
|
2041
|
+
*/
|
|
2042
|
+
consumeIdentifierOrKeyword() {
|
|
2043
|
+
const token = this.current();
|
|
2044
|
+
if (token && (token.type === 'IDENTIFIER' || token.type === 'KEYWORD')) {
|
|
2045
|
+
return this.advance();
|
|
2046
|
+
}
|
|
2047
|
+
throw new Error(`Expected identifier, got ${token?.value || 'EOF'}`);
|
|
2048
|
+
}
|
|
2049
|
+
parseRetryBlock() {
|
|
2050
|
+
this.advance(); // consume 'retry'
|
|
2051
|
+
this.consume('PUNCTUATION', '{');
|
|
2052
|
+
this.skipNL();
|
|
2053
|
+
let maxAttempts;
|
|
2054
|
+
let backoff;
|
|
2055
|
+
let delay;
|
|
2056
|
+
let delayMs;
|
|
2057
|
+
let jitter;
|
|
2058
|
+
const retryOn = [];
|
|
2059
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
2060
|
+
this.skipNL();
|
|
2061
|
+
if (this.check('PUNCTUATION', '}'))
|
|
2062
|
+
break;
|
|
2063
|
+
const field = this.consumeIdentifier().value;
|
|
2064
|
+
this.consume('OPERATOR', ':');
|
|
2065
|
+
if (field === 'maxAttempts') {
|
|
2066
|
+
maxAttempts = Number(this.advance().value);
|
|
2067
|
+
}
|
|
2068
|
+
else if (field === 'backoff') {
|
|
2069
|
+
backoff = this.consumeIdentifierOrKeyword().value;
|
|
2070
|
+
}
|
|
2071
|
+
else if (field === 'delay') {
|
|
2072
|
+
delay = Number(this.advance().value);
|
|
2073
|
+
}
|
|
2074
|
+
else if (field === 'delayMs') {
|
|
2075
|
+
delayMs = Number(this.advance().value);
|
|
2076
|
+
}
|
|
2077
|
+
else if (field === 'jitter') {
|
|
2078
|
+
if (this.check('KEYWORD', 'true') || this.check('KEYWORD', 'false')) {
|
|
2079
|
+
jitter = this.advance().value === 'true';
|
|
2080
|
+
}
|
|
2081
|
+
else {
|
|
2082
|
+
jitter = Number(this.advance().value);
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
else if (field === 'retryOn') {
|
|
2086
|
+
retryOn.push(this.check('STRING') ? this.advance().value : this.consumeIdentifierOrKeyword().value);
|
|
2087
|
+
}
|
|
2088
|
+
if (this.check('PUNCTUATION', ',')) {
|
|
2089
|
+
this.advance();
|
|
2090
|
+
}
|
|
2091
|
+
this.skipNL();
|
|
2092
|
+
}
|
|
2093
|
+
this.consume('PUNCTUATION', '}');
|
|
2094
|
+
this.skipNL();
|
|
2095
|
+
return {
|
|
2096
|
+
type: 'RetryPolicy',
|
|
2097
|
+
...(maxAttempts !== undefined ? { maxAttempts } : {}),
|
|
2098
|
+
...(backoff ? { backoff } : {}),
|
|
2099
|
+
...(delay !== undefined ? { delay } : {}),
|
|
2100
|
+
...(delayMs !== undefined ? { delayMs } : {}),
|
|
2101
|
+
...(jitter !== undefined ? { jitter } : {}),
|
|
2102
|
+
...(retryOn.length > 0 ? { retryOn } : {})
|
|
2103
|
+
};
|
|
2104
|
+
}
|
|
2105
|
+
parseSchedule() {
|
|
2106
|
+
this.advance(); // consume 'schedule'
|
|
2107
|
+
const name = this.consumeIdentifier().value;
|
|
2108
|
+
let scheduleType = 'cron';
|
|
2109
|
+
let cronExpression;
|
|
2110
|
+
let value;
|
|
2111
|
+
let unit;
|
|
2112
|
+
// Parse schedule type: cron <expr> | interval <num> <unit> | every <num> <unit>
|
|
2113
|
+
let intervalDuration;
|
|
2114
|
+
if (this.check('IDENTIFIER', 'cron')) {
|
|
2115
|
+
this.advance(); // consume 'cron'
|
|
2116
|
+
scheduleType = 'cron';
|
|
2117
|
+
cronExpression = this.consume('STRING').value;
|
|
2118
|
+
}
|
|
2119
|
+
else if (this.check('IDENTIFIER', 'interval')) {
|
|
2120
|
+
this.advance(); // consume 'interval'
|
|
2121
|
+
scheduleType = 'interval';
|
|
2122
|
+
if (this.check('STRING')) {
|
|
2123
|
+
intervalDuration = this.advance().value;
|
|
2124
|
+
}
|
|
2125
|
+
else {
|
|
2126
|
+
value = Number(this.advance().value);
|
|
2127
|
+
unit = this.consumeIdentifierOrKeyword().value;
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
else if (this.check('IDENTIFIER', 'every')) {
|
|
2131
|
+
this.advance(); // consume 'every'
|
|
2132
|
+
scheduleType = 'every';
|
|
2133
|
+
value = Number(this.advance().value);
|
|
2134
|
+
unit = this.consumeIdentifierOrKeyword().value;
|
|
2135
|
+
}
|
|
2136
|
+
else {
|
|
2137
|
+
throw new Error('Expected cron, interval, or every in schedule declaration');
|
|
2138
|
+
}
|
|
2139
|
+
this.skipNL();
|
|
2140
|
+
if (this.check('KEYWORD', 'run') || this.check('IDENTIFIER', 'run')) {
|
|
2141
|
+
this.advance();
|
|
2142
|
+
}
|
|
2143
|
+
else {
|
|
2144
|
+
throw new Error("Expected 'run' in schedule declaration");
|
|
2145
|
+
}
|
|
2146
|
+
this.skipNL();
|
|
2147
|
+
// Parse optional Entity.commandName
|
|
2148
|
+
let targetEntity;
|
|
2149
|
+
let targetCommand;
|
|
2150
|
+
const firstIdent = this.consumeIdentifier().value;
|
|
2151
|
+
if (this.check('OPERATOR', '.')) {
|
|
2152
|
+
this.advance(); // consume '.'
|
|
2153
|
+
targetEntity = firstIdent;
|
|
2154
|
+
targetCommand = this.consumeIdentifier().value;
|
|
2155
|
+
}
|
|
2156
|
+
else {
|
|
2157
|
+
targetCommand = firstIdent;
|
|
2158
|
+
}
|
|
2159
|
+
// Parse optional parameters: (paramName: value, ...)
|
|
2160
|
+
let parameters;
|
|
2161
|
+
if (this.check('PUNCTUATION', '(')) {
|
|
2162
|
+
this.advance(); // consume '('
|
|
2163
|
+
this.skipNL();
|
|
2164
|
+
parameters = {};
|
|
2165
|
+
while (!this.check('PUNCTUATION', ')') && !this.isEnd()) {
|
|
2166
|
+
this.skipNL();
|
|
2167
|
+
if (this.check('PUNCTUATION', ')'))
|
|
2168
|
+
break;
|
|
2169
|
+
const paramName = this.consumeIdentifier().value;
|
|
2170
|
+
this.consume('OPERATOR', ':');
|
|
2171
|
+
const paramValue = this.parseExpr();
|
|
2172
|
+
parameters[paramName] = paramValue;
|
|
2173
|
+
if (this.check('PUNCTUATION', ',')) {
|
|
2174
|
+
this.advance();
|
|
2175
|
+
}
|
|
2176
|
+
this.skipNL();
|
|
2177
|
+
}
|
|
2178
|
+
this.consume('PUNCTUATION', ')');
|
|
2179
|
+
}
|
|
2180
|
+
return {
|
|
2181
|
+
type: 'Schedule',
|
|
2182
|
+
name,
|
|
2183
|
+
scheduleType,
|
|
2184
|
+
...(cronExpression ? { cronExpression } : {}),
|
|
2185
|
+
...(intervalDuration ? { intervalDuration } : {}),
|
|
2186
|
+
...(value !== undefined ? { value } : {}),
|
|
2187
|
+
...(unit ? { unit } : {}),
|
|
2188
|
+
...(targetEntity ? { targetEntity } : {}),
|
|
2189
|
+
targetCommand,
|
|
2190
|
+
...(parameters ? { parameters } : {})
|
|
2191
|
+
};
|
|
2192
|
+
}
|
|
2193
|
+
parseRateLimitBlock() {
|
|
2194
|
+
this.advance(); // consume 'rateLimit'
|
|
2195
|
+
this.consume('PUNCTUATION', '{');
|
|
2196
|
+
this.skipNL();
|
|
2197
|
+
let maxRequests;
|
|
2198
|
+
let windowMs;
|
|
2199
|
+
let scope;
|
|
2200
|
+
let burstAllowance;
|
|
2201
|
+
while (!this.check('PUNCTUATION', '}') && !this.isEnd()) {
|
|
2202
|
+
this.skipNL();
|
|
2203
|
+
if (this.check('PUNCTUATION', '}'))
|
|
2204
|
+
break;
|
|
2205
|
+
const field = this.consumeIdentifier().value;
|
|
2206
|
+
this.consume('OPERATOR', ':');
|
|
2207
|
+
if (field === 'maxRequests') {
|
|
2208
|
+
maxRequests = Number(this.advance().value);
|
|
2209
|
+
}
|
|
2210
|
+
else if (field === 'windowMs') {
|
|
2211
|
+
windowMs = Number(this.advance().value);
|
|
2212
|
+
}
|
|
2213
|
+
else if (field === 'scope') {
|
|
2214
|
+
scope = this.consumeIdentifierOrKeyword().value;
|
|
2215
|
+
}
|
|
2216
|
+
else if (field === 'burstAllowance') {
|
|
2217
|
+
burstAllowance = Number(this.advance().value);
|
|
2218
|
+
}
|
|
2219
|
+
if (this.check('PUNCTUATION', ',')) {
|
|
2220
|
+
this.advance();
|
|
2221
|
+
}
|
|
2222
|
+
this.skipNL();
|
|
2223
|
+
}
|
|
2224
|
+
this.consume('PUNCTUATION', '}');
|
|
2225
|
+
this.skipNL();
|
|
2226
|
+
return {
|
|
2227
|
+
type: 'RateLimit',
|
|
2228
|
+
...(maxRequests !== undefined ? { maxRequests } : {}),
|
|
2229
|
+
...(windowMs !== undefined ? { windowMs } : {}),
|
|
2230
|
+
...(scope ? { scope } : {}),
|
|
2231
|
+
...(burstAllowance !== undefined ? { burstAllowance } : {})
|
|
2232
|
+
};
|
|
2233
|
+
}
|
|
2234
|
+
advance() { if (!this.isEnd())
|
|
2235
|
+
this.pos++; return this.tokens[this.pos - 1]; }
|
|
2236
|
+
current() { return this.tokens[this.pos]; }
|
|
2237
|
+
isEnd() { return this.pos >= this.tokens.length || this.tokens[this.pos]?.type === 'EOF'; }
|
|
2238
|
+
skipNL() { while (this.check('NEWLINE', '\n'))
|
|
2239
|
+
this.advance(); }
|
|
2240
|
+
sync() { this.advance(); while (!this.isEnd() && !['entity', 'enum', 'flow', 'effect', 'expose', 'compose', 'module', 'command', 'policy', 'store', 'event', 'tenant', 'async', 'saga', 'role', 'webhook'].includes(this.current()?.value || ''))
|
|
2241
|
+
this.advance(); }
|
|
2242
|
+
}
|
|
2243
|
+
//# sourceMappingURL=parser.js.map
|