@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,786 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convex functions surfaces: `convex.queries` and `convex.mutations`.
|
|
3
|
+
*
|
|
4
|
+
* Queries are reactive reads over `ctx.db` (reads are not governed). Mutations
|
|
5
|
+
* are governed writes: each IR command becomes a Convex `mutation` that runs the
|
|
6
|
+
* command's policies → guards → constraints (rendered from IR via the
|
|
7
|
+
* fail-closed expression resolver), applies the command's mutate actions,
|
|
8
|
+
* appends an event row, and fires matched reactions.
|
|
9
|
+
*
|
|
10
|
+
* Governance is rendered FAIL CLOSED: any guard/policy/constraint the resolver
|
|
11
|
+
* cannot fully map produces a hard diagnostic AND a denying `throw`, never a
|
|
12
|
+
* silent pass.
|
|
13
|
+
*/
|
|
14
|
+
import { normalizeOptions } from './options.js';
|
|
15
|
+
import { resolveConvexTableName, collectFkTargets, collectReferenceFields, indexEntryToDef, buildValidator, isPersistentEntity, resolveEventsTableName, } from './generator.js';
|
|
16
|
+
import { resolveConvexValidator } from './type-mapping.js';
|
|
17
|
+
import { renderExpression, isNullLiteral } from './expression.js';
|
|
18
|
+
const GENERATED_HEADER = '// GENERATED by the Manifest → Convex projection. DO NOT EDIT.';
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
// Shared helpers
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
function persistentEntities(ir) {
|
|
23
|
+
return ir.entities.filter(e => isPersistentEntity(e, ir));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Render an IR default value to a TS literal that satisfies a Convex validator.
|
|
27
|
+
*
|
|
28
|
+
* Two of the projection's type mappings are *representational*: `int`/`bigint`
|
|
29
|
+
* map to `v.int64()` (a JS `bigint`) and `decimal`/`money` map to `v.string()`
|
|
30
|
+
* (lossless decimal transport — Convex has no native Decimal). A structurally
|
|
31
|
+
* faithful render of an IR `number` default (`1`) is the WRONG runtime type for
|
|
32
|
+
* those validators — Convex rejects a JS number where it expects a bigint or a
|
|
33
|
+
* string — so the create-mutation default fill would fail schema validation at
|
|
34
|
+
* insert time. Coerce numeric leaves to the validator's representation.
|
|
35
|
+
*
|
|
36
|
+
* `validator` is the field's resolved expression (possibly `v.optional`/
|
|
37
|
+
* `v.array`-wrapped); detection is structural so per-property `typeMappings`
|
|
38
|
+
* overrides are honored. Arrays share their element validator, so it propagates
|
|
39
|
+
* to elements; objects carry heterogeneous members the field validator does not
|
|
40
|
+
* describe, so their members are rendered structurally (no coercion).
|
|
41
|
+
*/
|
|
42
|
+
function defaultToTs(value, validator) {
|
|
43
|
+
switch (value.kind) {
|
|
44
|
+
case 'string': return JSON.stringify(value.value);
|
|
45
|
+
case 'number':
|
|
46
|
+
// int64 wants a bigint literal; a non-integer default on an int field is
|
|
47
|
+
// an authoring contradiction — surface it as a type error, don't truncate.
|
|
48
|
+
if (validator && /\bv\.int64\(\)/.test(validator) && Number.isInteger(value.value)) {
|
|
49
|
+
return `${value.value}n`;
|
|
50
|
+
}
|
|
51
|
+
// decimal/money (and stringId FKs) transport as strings.
|
|
52
|
+
if (validator && /\bv\.string\(\)/.test(validator)) {
|
|
53
|
+
return JSON.stringify(String(value.value));
|
|
54
|
+
}
|
|
55
|
+
return String(value.value);
|
|
56
|
+
case 'boolean': return String(value.value);
|
|
57
|
+
case 'null': return 'null';
|
|
58
|
+
case 'array': return `[${value.elements.map(el => defaultToTs(el, validator)).join(', ')}]`;
|
|
59
|
+
case 'object': return `{${Object.entries(value.properties).map(([k, v]) => `${JSON.stringify(k)}: ${defaultToTs(v)}`).join(', ')}}`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Render a mutate-action right-hand side, converting a literal-`null` assignment
|
|
64
|
+
* to a NON-nullable field into `undefined`. Convex rejects `null` for an
|
|
65
|
+
* `v.optional(T)` column but treats `undefined` as "unset" — so a DSL `= null`
|
|
66
|
+
* "clear"/"restore" must lower to field omission, not a rejected null write.
|
|
67
|
+
* Nullable fields (schema `v.union(T, v.null())`) keep `null`.
|
|
68
|
+
*/
|
|
69
|
+
function renderActionValue(entity, target, expression, scope) {
|
|
70
|
+
const res = renderExpression(expression, scope);
|
|
71
|
+
if (res.unresolved.length === 0 && target && isNullLiteral(expression)) {
|
|
72
|
+
const targetProp = entity.properties.find(p => p.name === target);
|
|
73
|
+
if (targetProp?.type.nullable !== true) {
|
|
74
|
+
return { code: 'undefined', unresolved: res.unresolved };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return res;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Validator expression for a command parameter (no optional wrap). Mirrors the
|
|
81
|
+
* entity-field `array<T>` handling so an `array`-typed param maps to
|
|
82
|
+
* `v.array(<element>)` instead of collapsing to a structureless `v.any()`.
|
|
83
|
+
* Unknown leaf types still fall back to `v.any()` (params are not schema fields,
|
|
84
|
+
* so an unmapped type is permissive rather than a hard diagnostic).
|
|
85
|
+
*/
|
|
86
|
+
function paramValidator(type) {
|
|
87
|
+
if (type.name === 'array' && type.generic) {
|
|
88
|
+
const element = resolveConvexValidator(type.generic.name, undefined, '') ?? 'v.any()';
|
|
89
|
+
return `v.array(${element})`;
|
|
90
|
+
}
|
|
91
|
+
return resolveConvexValidator(type.name, undefined, '') ?? 'v.any()';
|
|
92
|
+
}
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
94
|
+
// Queries
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
function capWord(s) {
|
|
97
|
+
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The indexes an entity exposes as reads, derived to match EXACTLY what the
|
|
101
|
+
* schema surface emits (`generator.ts#emitTable`): `indexed`-modifier properties,
|
|
102
|
+
* the tenant column, every belongsTo/ref FK (in BOTH reference modes), and every
|
|
103
|
+
* `options.indexes` entry (single-field AND composite). Single-field specs are
|
|
104
|
+
* deduped by column in schema order; composite specs by index name. The result
|
|
105
|
+
* guarantees every schema index has a corresponding `list<Entity>By<Field...>`
|
|
106
|
+
* query — the two surfaces can no longer drift (closing both the stringId-mode
|
|
107
|
+
* FK gap and the composite-index gap).
|
|
108
|
+
*/
|
|
109
|
+
function collectQueryIndexSpecs(ir, entity, options) {
|
|
110
|
+
const specs = [];
|
|
111
|
+
const seenSingle = new Set();
|
|
112
|
+
const seenName = new Set();
|
|
113
|
+
// convexId-only targets: present → arg typed `v.id(target)`; absent → `v.string()`.
|
|
114
|
+
const fkTargets = collectFkTargets(entity, ir, options);
|
|
115
|
+
const mkField = (name) => ({ name, fkTarget: fkTargets.get(name) });
|
|
116
|
+
const addSingle = (field, indexName) => {
|
|
117
|
+
if (field === 'id' || seenSingle.has(field))
|
|
118
|
+
return;
|
|
119
|
+
seenSingle.add(field);
|
|
120
|
+
seenName.add(indexName);
|
|
121
|
+
specs.push({ fields: [mkField(field)], indexName });
|
|
122
|
+
};
|
|
123
|
+
for (const p of entity.properties) {
|
|
124
|
+
if (p.modifiers.includes('indexed'))
|
|
125
|
+
addSingle(p.name, `by_${p.name}`);
|
|
126
|
+
}
|
|
127
|
+
const tenantProp = ir.tenant?.property;
|
|
128
|
+
if (tenantProp && entity.properties.some(p => p.name === tenantProp))
|
|
129
|
+
addSingle(tenantProp, `by_${tenantProp}`);
|
|
130
|
+
for (const fk of collectReferenceFields(entity, ir, options).keys())
|
|
131
|
+
addSingle(fk, `by_${fk}`);
|
|
132
|
+
for (const entry of options.indexes[entity.name] ?? []) {
|
|
133
|
+
const def = indexEntryToDef(entry);
|
|
134
|
+
if (def.fields.length === 1) {
|
|
135
|
+
addSingle(def.fields[0], def.name);
|
|
136
|
+
}
|
|
137
|
+
else if (def.fields.length > 1 && !seenName.has(def.name)) {
|
|
138
|
+
seenName.add(def.name);
|
|
139
|
+
specs.push({ fields: def.fields.map(mkField), indexName: def.name });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return specs;
|
|
143
|
+
}
|
|
144
|
+
function resolveReadFilter(ir, entity, options) {
|
|
145
|
+
const tenantProp = options.tenantIdProperty ?? ir.tenant?.property;
|
|
146
|
+
const hasTenant = options.includeTenantFilter && !!tenantProp
|
|
147
|
+
&& entity.properties.some(p => p.name === tenantProp);
|
|
148
|
+
const deletedProp = options.deletedAtProperty;
|
|
149
|
+
const hasSoftDelete = options.includeSoftDeleteFilter
|
|
150
|
+
&& entity.properties.some(p => p.name === deletedProp);
|
|
151
|
+
return {
|
|
152
|
+
hasTenant,
|
|
153
|
+
tenantProp: hasTenant ? tenantProp : undefined,
|
|
154
|
+
tenantIndexed: hasTenant && tenantProp === ir.tenant?.property,
|
|
155
|
+
hasSoftDelete,
|
|
156
|
+
deletedProp,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
export function generateQueries(ir, rawOptions) {
|
|
160
|
+
const options = normalizeOptions(rawOptions);
|
|
161
|
+
const diagnostics = [];
|
|
162
|
+
const blocks = [];
|
|
163
|
+
for (const entity of persistentEntities(ir)) {
|
|
164
|
+
const table = resolveConvexTableName(entity.name, options);
|
|
165
|
+
const rf = resolveReadFilter(ir, entity, options);
|
|
166
|
+
// list<Entity> — tenant-scoped + soft-delete-filtered by default. The tenant
|
|
167
|
+
// id comes from the authenticated identity (never a client arg), so an
|
|
168
|
+
// un-scoped list cannot leak rows across tenants.
|
|
169
|
+
if (!rf.hasTenant && !rf.hasSoftDelete) {
|
|
170
|
+
blocks.push(`export const list${entity.name} = query({\n` +
|
|
171
|
+
` args: {},\n` +
|
|
172
|
+
` handler: async (ctx) => {\n` +
|
|
173
|
+
` return await ctx.db.query("${table}").collect();\n` +
|
|
174
|
+
` },\n});`);
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
const lines = [];
|
|
178
|
+
if (rf.hasTenant)
|
|
179
|
+
lines.push(` const __tenant = (ctx as any).auth?.${rf.tenantProp} ?? null;`);
|
|
180
|
+
if (rf.hasTenant && rf.tenantIndexed) {
|
|
181
|
+
lines.push(` let rows = await ctx.db.query("${table}").withIndex("by_${rf.tenantProp}", (q) => q.eq("${rf.tenantProp}", __tenant)).collect();`);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
lines.push(` let rows = await ctx.db.query("${table}").collect();`);
|
|
185
|
+
if (rf.hasTenant)
|
|
186
|
+
lines.push(` rows = rows.filter((d) => (d as any).${rf.tenantProp} === __tenant);`);
|
|
187
|
+
}
|
|
188
|
+
if (rf.hasSoftDelete)
|
|
189
|
+
lines.push(` rows = rows.filter((d) => (d as any).${rf.deletedProp} == null);`);
|
|
190
|
+
lines.push(` return rows;`);
|
|
191
|
+
blocks.push(`export const list${entity.name} = query({\n` +
|
|
192
|
+
` args: {},\n` +
|
|
193
|
+
` handler: async (ctx) => {\n${lines.join('\n')}\n },\n});`);
|
|
194
|
+
}
|
|
195
|
+
// get<Entity> by Convex _id — returns null on tenant mismatch / soft-deleted.
|
|
196
|
+
if (!rf.hasTenant && !rf.hasSoftDelete) {
|
|
197
|
+
blocks.push(`export const get${entity.name} = query({\n` +
|
|
198
|
+
` args: { id: v.id("${table}") },\n` +
|
|
199
|
+
` handler: async (ctx, { id }) => {\n` +
|
|
200
|
+
` return await ctx.db.get(id);\n` +
|
|
201
|
+
` },\n});`);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
const lines = [` const doc = await ctx.db.get(id);`];
|
|
205
|
+
if (rf.hasTenant) {
|
|
206
|
+
lines.push(` const __tenant = (ctx as any).auth?.${rf.tenantProp} ?? null;`);
|
|
207
|
+
lines.push(` if (doc && (doc as any).${rf.tenantProp} !== __tenant) return null;`);
|
|
208
|
+
}
|
|
209
|
+
if (rf.hasSoftDelete)
|
|
210
|
+
lines.push(` if (doc && (doc as any).${rf.deletedProp} != null) return null;`);
|
|
211
|
+
lines.push(` return doc;`);
|
|
212
|
+
blocks.push(`export const get${entity.name} = query({\n` +
|
|
213
|
+
` args: { id: v.id("${table}") },\n` +
|
|
214
|
+
` handler: async (ctx, { id }) => {\n${lines.join('\n')}\n },\n});`);
|
|
215
|
+
}
|
|
216
|
+
// list<Entity>By<Field...> — one per schema index (indexed, tenant, every
|
|
217
|
+
// reference FK in both modes, single-field AND composite option indexes).
|
|
218
|
+
// Soft-delete + (auth-derived) tenant filters apply unless the index itself
|
|
219
|
+
// already constrains the tenant column.
|
|
220
|
+
for (const spec of collectQueryIndexSpecs(ir, entity, options)) {
|
|
221
|
+
const names = spec.fields.map(f => f.name);
|
|
222
|
+
const suffix = spec.fields.map(f => capWord(f.name)).join('And');
|
|
223
|
+
const argList = spec.fields.map(f => `${f.name}: ${f.fkTarget ? `v.id("${f.fkTarget}")` : 'v.string()'}`).join(', ');
|
|
224
|
+
const destructure = `{ ${names.join(', ')} }`;
|
|
225
|
+
const eqChain = spec.fields.map(f => `.eq("${f.name}", ${f.name})`).join('');
|
|
226
|
+
const applyTenant = rf.hasTenant && !!rf.tenantProp && !names.includes(rf.tenantProp);
|
|
227
|
+
if (!applyTenant && !rf.hasSoftDelete) {
|
|
228
|
+
blocks.push(`export const list${entity.name}By${suffix} = query({\n` +
|
|
229
|
+
` args: { ${argList} },\n` +
|
|
230
|
+
` handler: async (ctx, ${destructure}) => {\n` +
|
|
231
|
+
` return await ctx.db.query("${table}").withIndex("${spec.indexName}", (q) => q${eqChain}).collect();\n` +
|
|
232
|
+
` },\n});`);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
const lines = [];
|
|
236
|
+
if (applyTenant)
|
|
237
|
+
lines.push(` const __tenant = (ctx as any).auth?.${rf.tenantProp} ?? null;`);
|
|
238
|
+
lines.push(` let rows = await ctx.db.query("${table}").withIndex("${spec.indexName}", (q) => q${eqChain}).collect();`);
|
|
239
|
+
if (applyTenant)
|
|
240
|
+
lines.push(` rows = rows.filter((d) => (d as any).${rf.tenantProp} === __tenant);`);
|
|
241
|
+
if (rf.hasSoftDelete)
|
|
242
|
+
lines.push(` rows = rows.filter((d) => (d as any).${rf.deletedProp} == null);`);
|
|
243
|
+
lines.push(` return rows;`);
|
|
244
|
+
blocks.push(`export const list${entity.name}By${suffix} = query({\n` +
|
|
245
|
+
` args: { ${argList} },\n` +
|
|
246
|
+
` handler: async (ctx, ${destructure}) => {\n${lines.join('\n')}\n },\n});`);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// System events table reads (when emitted): recent feed + the three indexed
|
|
251
|
+
// lookups (by_type / by_entity / by_entityId) the schema declares on it.
|
|
252
|
+
if (options.emitEventsTable) {
|
|
253
|
+
const ev = resolveEventsTableName(ir, options);
|
|
254
|
+
blocks.push(`export const listRecentEvents = query({\n` +
|
|
255
|
+
` args: {},\n` +
|
|
256
|
+
` handler: async (ctx) => {\n` +
|
|
257
|
+
` return await ctx.db.query("${ev}").order("desc").take(50);\n` +
|
|
258
|
+
` },\n});`);
|
|
259
|
+
for (const field of ['type', 'entity', 'entityId']) {
|
|
260
|
+
blocks.push(`export const listEventsBy${capWord(field)} = query({\n` +
|
|
261
|
+
` args: { ${field}: v.string() },\n` +
|
|
262
|
+
` handler: async (ctx, { ${field} }) => {\n` +
|
|
263
|
+
` return await ctx.db.query("${ev}").withIndex("by_${field}", (q) => q.eq("${field}", ${field})).collect();\n` +
|
|
264
|
+
` },\n});`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
const code = `${GENERATED_HEADER}\n// ${blocks.length} query function(s).\n\n` +
|
|
268
|
+
`import { query } from "./_generated/server";\n` +
|
|
269
|
+
`import { v } from "convex/values";\n\n` +
|
|
270
|
+
`${blocks.join('\n\n')}\n`;
|
|
271
|
+
return { code, diagnostics };
|
|
272
|
+
}
|
|
273
|
+
// ---------------------------------------------------------------------------
|
|
274
|
+
// Mutations
|
|
275
|
+
// ---------------------------------------------------------------------------
|
|
276
|
+
/** Build the ROLE_PERMISSIONS map literal from IR roles' effective permissions. */
|
|
277
|
+
function roleMapLiteral(ir) {
|
|
278
|
+
const map = {};
|
|
279
|
+
for (const role of ir.roles ?? []) {
|
|
280
|
+
const actions = new Set();
|
|
281
|
+
for (const perm of role.effectivePermissions ?? [])
|
|
282
|
+
actions.add(perm.action);
|
|
283
|
+
map[role.name] = [...actions].sort();
|
|
284
|
+
}
|
|
285
|
+
return JSON.stringify(map, null, 2);
|
|
286
|
+
}
|
|
287
|
+
/** Render governance checks fail-closed. Returns TS lines + diagnostics. */
|
|
288
|
+
function renderChecks(entityName, checks, scope) {
|
|
289
|
+
const lines = [];
|
|
290
|
+
const diagnostics = [];
|
|
291
|
+
for (const c of checks) {
|
|
292
|
+
const { code, unresolved } = renderExpression(c.expr, scope);
|
|
293
|
+
if (unresolved.length > 0) {
|
|
294
|
+
diagnostics.push({
|
|
295
|
+
severity: 'error',
|
|
296
|
+
code: c.code,
|
|
297
|
+
entity: entityName,
|
|
298
|
+
message: `${c.label}: could not resolve expression (${unresolved.join('; ')}). Emitted a denying throw (fail-closed).`,
|
|
299
|
+
});
|
|
300
|
+
lines.push(` throw new Error(${JSON.stringify(`${c.label} unresolved — denied`)});`);
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
lines.push(` if (!(${code})) throw new Error(${JSON.stringify(c.message)});`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
return { lines, diagnostics };
|
|
307
|
+
}
|
|
308
|
+
/** Collect the policy/guard/constraint checks for a command, in runtime order. */
|
|
309
|
+
function commandChecks(ir, cmd, policyMode) {
|
|
310
|
+
const checks = [];
|
|
311
|
+
if (policyMode !== 'skip') {
|
|
312
|
+
for (const pName of cmd.policies ?? []) {
|
|
313
|
+
const policy = ir.policies.find(p => p.name === pName);
|
|
314
|
+
if (!policy)
|
|
315
|
+
continue;
|
|
316
|
+
checks.push({ expr: policy.expression, message: policy.message ?? `Policy ${pName} denied`, code: 'CONVEX_UNRESOLVED_POLICY', label: `policy '${pName}'` });
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
for (let i = 0; i < cmd.guards.length; i++) {
|
|
320
|
+
checks.push({ expr: cmd.guards[i], message: `Guard ${i} failed`, code: 'CONVEX_UNRESOLVED_GUARD', label: `guard[${i}]` });
|
|
321
|
+
}
|
|
322
|
+
for (const c of (cmd.constraints ?? [])) {
|
|
323
|
+
if (c.severity && c.severity !== 'block')
|
|
324
|
+
continue;
|
|
325
|
+
checks.push({ expr: c.expression, message: c.message ?? c.messageTemplate ?? `Constraint ${c.code} failed`, code: 'CONVEX_UNRESOLVED_CONSTRAINT', label: `constraint '${c.code}'` });
|
|
326
|
+
}
|
|
327
|
+
return checks;
|
|
328
|
+
}
|
|
329
|
+
/** Render reaction fan-out for the events a command emits. */
|
|
330
|
+
function renderReactions(ir, options, emits) {
|
|
331
|
+
const lines = [];
|
|
332
|
+
const diagnostics = [];
|
|
333
|
+
const matched = (ir.reactions ?? []).filter((r) => emits.includes(r.event));
|
|
334
|
+
if (matched.length === 0)
|
|
335
|
+
return { lines, diagnostics };
|
|
336
|
+
lines.push(' // Reactions');
|
|
337
|
+
const tenantProp = ir.tenant?.property;
|
|
338
|
+
// Count vars + the shared tenant binding are handler-scoped (one handler per
|
|
339
|
+
// command, so all matched reactions share a scope); dedupe across reactions.
|
|
340
|
+
let countCounter = 0;
|
|
341
|
+
let tenantEmitted = false;
|
|
342
|
+
/**
|
|
343
|
+
* Render ONE reaction param. An aggregate-count param lowers to a read block
|
|
344
|
+
* (preLines) that counts rows of the param's entity matching its ANDed equality
|
|
345
|
+
* predicates, then binds the param to that count variable. The foreign-key (or
|
|
346
|
+
* any indexed) predicate drives a `withIndex` read; remaining predicates,
|
|
347
|
+
* soft-delete, and tenant scope are applied as JS `.filter`s — mirroring the
|
|
348
|
+
* hardened read surface. Any other param renders as a single expression.
|
|
349
|
+
* Returns `entry: null` when the value cannot be resolved (caller omits it).
|
|
350
|
+
*/
|
|
351
|
+
const buildParam = (p, scope, label) => {
|
|
352
|
+
const e = p.expression;
|
|
353
|
+
if (e.kind === 'aggregate' && e.op === 'count') {
|
|
354
|
+
const childEntity = ir.entities.find(en => en.name === e.entity);
|
|
355
|
+
if (!childEntity) {
|
|
356
|
+
diagnostics.push({ severity: 'error', code: 'CONVEX_AGGREGATE_UNKNOWN_ENTITY', message: `${label} param '${p.name}' counts unknown entity '${e.entity}'; omitted.` });
|
|
357
|
+
return { preLines: [], entry: null };
|
|
358
|
+
}
|
|
359
|
+
const childTable = resolveConvexTableName(e.entity, options);
|
|
360
|
+
const rf = resolveReadFilter(ir, childEntity, options);
|
|
361
|
+
const refFields = collectReferenceFields(childEntity, ir, options);
|
|
362
|
+
const isIndexedField = (field) => {
|
|
363
|
+
const prop = childEntity.properties.find(pp => pp.name === field);
|
|
364
|
+
return !!prop && (prop.modifiers.includes('indexed') || refFields.has(field));
|
|
365
|
+
};
|
|
366
|
+
const renderVal = (val) => {
|
|
367
|
+
const r = renderExpression(val, scope);
|
|
368
|
+
if (r.unresolved.length) {
|
|
369
|
+
diagnostics.push({ severity: 'warning', code: 'CONVEX_UNRESOLVED_AGGREGATE_PREDICATE', message: `${label} param '${p.name}' count predicate value unresolved (${r.unresolved.join('; ')}).` });
|
|
370
|
+
}
|
|
371
|
+
return r;
|
|
372
|
+
};
|
|
373
|
+
const indexedPred = e.predicates.find(pr => isIndexedField(pr.field));
|
|
374
|
+
const remaining = indexedPred ? e.predicates.filter(pr => pr !== indexedPred) : e.predicates;
|
|
375
|
+
const rowsVar = `__count${countCounter}_rows`;
|
|
376
|
+
const countVar = `__count${countCounter}`;
|
|
377
|
+
countCounter++;
|
|
378
|
+
const preLines = [];
|
|
379
|
+
let queryHead;
|
|
380
|
+
if (indexedPred) {
|
|
381
|
+
const v = renderVal(indexedPred.value);
|
|
382
|
+
queryHead = `ctx.db.query("${childTable}").withIndex("by_${indexedPred.field}", (q) => q.eq("${indexedPred.field}", ${v.code}))`;
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
queryHead = `ctx.db.query("${childTable}")`;
|
|
386
|
+
diagnostics.push({ severity: 'info', code: 'CONVEX_AGGREGATE_UNINDEXED', message: `${label} param '${p.name}' counts '${e.entity}' with no indexed/foreign-key predicate; rendered a table scan (mark an equality field indexed for speed).` });
|
|
387
|
+
}
|
|
388
|
+
preLines.push(` const ${rowsVar} = await ${queryHead}.collect();`);
|
|
389
|
+
const filters = [];
|
|
390
|
+
for (const pr of remaining) {
|
|
391
|
+
const v = renderVal(pr.value);
|
|
392
|
+
filters.push(`(d as any).${pr.field} === ${v.code}`);
|
|
393
|
+
}
|
|
394
|
+
if (rf.hasSoftDelete)
|
|
395
|
+
filters.push(`(d as any).${rf.deletedProp} == null`);
|
|
396
|
+
if (rf.hasTenant && rf.tenantProp) {
|
|
397
|
+
if (!tenantEmitted) {
|
|
398
|
+
preLines.push(` const __tenant = (ctx as any).auth?.${rf.tenantProp} ?? null;`);
|
|
399
|
+
tenantEmitted = true;
|
|
400
|
+
}
|
|
401
|
+
filters.push(`(d as any).${rf.tenantProp} === __tenant`);
|
|
402
|
+
}
|
|
403
|
+
const chain = filters.length ? filters.map(f => `.filter((d) => ${f})`).join('') : '';
|
|
404
|
+
preLines.push(` const ${countVar} = ${rowsVar}${chain}.length;`);
|
|
405
|
+
return { preLines, entry: `${p.name}: ${countVar}` };
|
|
406
|
+
}
|
|
407
|
+
const { code, unresolved } = renderExpression(e, scope);
|
|
408
|
+
if (unresolved.length) {
|
|
409
|
+
diagnostics.push({ severity: 'warning', code: 'CONVEX_UNRESOLVED_REACTION_PARAM', message: `${label} param '${p.name}' unresolved (${unresolved.join('; ')}); omitted.` });
|
|
410
|
+
return { preLines: [], entry: null };
|
|
411
|
+
}
|
|
412
|
+
return { preLines: [], entry: `${p.name}: ${code}` };
|
|
413
|
+
};
|
|
414
|
+
matched.forEach((reaction, idx) => {
|
|
415
|
+
const targetTable = resolveConvexTableName(reaction.targetEntity, options);
|
|
416
|
+
const targetEntity = ir.entities.find(e => e.name === reaction.targetEntity);
|
|
417
|
+
const label = `reaction ${reaction.event}→${reaction.targetEntity}.${reaction.targetCommand}`;
|
|
418
|
+
// Fan-out reaction: dispatch the command on every target row where
|
|
419
|
+
// row.<matchField> == matchSource. matchSource + params resolve against the
|
|
420
|
+
// event payload (self === payload, matching the reference runtime). Each
|
|
421
|
+
// match runs the GENERATED target mutation via ctx.runMutation, so the
|
|
422
|
+
// target command's own governance/actions run — exactly what hand-written
|
|
423
|
+
// after-emit middleware does. Prefer the schema index (FK/indexed fields
|
|
424
|
+
// carry by_<field>); fall back to a table-scan filter otherwise.
|
|
425
|
+
if (reaction.fanOut) {
|
|
426
|
+
const fanScope = { selfVar: 'payload', globals: ['user', 'context', 'args'] };
|
|
427
|
+
const src = renderExpression(reaction.fanOut.matchSource, fanScope);
|
|
428
|
+
if (src.unresolved.length) {
|
|
429
|
+
diagnostics.push({ severity: 'warning', code: 'CONVEX_UNRESOLVED_REACTION_FANOUT', message: `fan-out ${label} match source unresolved (${src.unresolved.join('; ')}); skipped.` });
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
const fanParams = [];
|
|
433
|
+
const fanPreLines = [];
|
|
434
|
+
for (const p of reaction.params ?? []) {
|
|
435
|
+
const r = buildParam(p, fanScope, label);
|
|
436
|
+
fanPreLines.push(...r.preLines);
|
|
437
|
+
if (r.entry)
|
|
438
|
+
fanParams.push(r.entry);
|
|
439
|
+
}
|
|
440
|
+
const field = reaction.fanOut.matchField;
|
|
441
|
+
const isFk = !!targetEntity && collectReferenceFields(targetEntity, ir, options).has(field);
|
|
442
|
+
const targetProp = targetEntity?.properties.find(p => p.name === field);
|
|
443
|
+
const indexed = !!targetProp && (targetProp.modifiers.includes('indexed') || isFk);
|
|
444
|
+
if (!indexed) {
|
|
445
|
+
diagnostics.push({ severity: 'info', code: 'CONVEX_FANOUT_UNINDEXED', message: `fan-out ${label} matches on non-indexed '${field}'; rendered an unindexed filter (mark '${reaction.targetEntity}.${field}' indexed for speed).` });
|
|
446
|
+
}
|
|
447
|
+
const queryExpr = indexed
|
|
448
|
+
? `ctx.db.query("${targetTable}").withIndex("by_${field}", (q) => q.eq("${field}", ${src.code}))`
|
|
449
|
+
: `ctx.db.query("${targetTable}").filter((q) => q.eq(q.field("${field}"), ${src.code}))`;
|
|
450
|
+
const rowsVar = `fanRows${idx}`;
|
|
451
|
+
for (const pl of fanPreLines)
|
|
452
|
+
lines.push(pl);
|
|
453
|
+
lines.push(` const ${rowsVar} = await ${queryExpr}.collect();`);
|
|
454
|
+
lines.push(` for (const __row of ${rowsVar}) {`);
|
|
455
|
+
lines.push(` await ctx.runMutation(api.mutations.${reaction.targetEntity}_${reaction.targetCommand}, { docId: (__row as any)._id${fanParams.length ? ', ' + fanParams.join(', ') : ''} } as any);`);
|
|
456
|
+
lines.push(` }`);
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
const scope = { selfVar: 'doc', globals: ['payload', 'user', 'context', 'args'] };
|
|
460
|
+
const paramEntries = [];
|
|
461
|
+
const paramPreLines = [];
|
|
462
|
+
const paramNamesSeen = new Set();
|
|
463
|
+
for (const p of reaction.params ?? []) {
|
|
464
|
+
const r = buildParam(p, scope, label);
|
|
465
|
+
paramPreLines.push(...r.preLines);
|
|
466
|
+
if (r.entry) {
|
|
467
|
+
paramEntries.push(r.entry);
|
|
468
|
+
paramNamesSeen.add(p.name);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
// Tenant propagation: a reaction fires within the source entity's tenant, so
|
|
472
|
+
// when it creates a tenant-scoped target, thread the source tenantId
|
|
473
|
+
// (available as payload.<tenantProp>) unless an explicit param already set it.
|
|
474
|
+
const targetIsTenantScoped = !!tenantProp && !!targetEntity?.properties.some(p => p.name === tenantProp);
|
|
475
|
+
if (reaction.targetCommand === 'create' && targetIsTenantScoped && !paramNamesSeen.has(tenantProp)) {
|
|
476
|
+
paramEntries.unshift(`${tenantProp}: payload.${tenantProp}`);
|
|
477
|
+
}
|
|
478
|
+
for (const pl of paramPreLines)
|
|
479
|
+
lines.push(pl);
|
|
480
|
+
if (reaction.targetCommand === 'create') {
|
|
481
|
+
lines.push(` await ctx.db.insert("${targetTable}", { ${paramEntries.join(', ')} } as any);`);
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
const resolve = renderExpression(reaction.resolve, { selfVar: 'doc', globals: ['payload', 'user', 'context', 'args'] });
|
|
485
|
+
const varName = `reactionTarget${idx}`;
|
|
486
|
+
if (reaction.resolve?.kind === 'literal' && reaction.resolve.value.kind === 'null') {
|
|
487
|
+
lines.push(` // reaction ${reaction.event} → ${reaction.targetEntity}.${reaction.targetCommand} (resolve: null — no target id)`);
|
|
488
|
+
}
|
|
489
|
+
else if (resolve.unresolved.length) {
|
|
490
|
+
diagnostics.push({ severity: 'warning', code: 'CONVEX_UNRESOLVED_REACTION_TARGET', message: `${label} target unresolved; skipped.` });
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
lines.push(` const ${varName} = ${resolve.code};`);
|
|
494
|
+
lines.push(` if (${varName}) await ctx.db.patch(${varName} as any, { ${paramEntries.join(', ')} } as any);`);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
});
|
|
498
|
+
return { lines, diagnostics };
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Render the G7 `emit Event { field: expr }` payload fields declared for ONE
|
|
502
|
+
* event, evaluated against the post-action instance scope (selfVar = the
|
|
503
|
+
* affected instance). Mirrors runtime-engine.ts G7 (eventPayload construction
|
|
504
|
+
* at emit time): declared fields are populated from `self.*` so the emitted
|
|
505
|
+
* event row — and the reactions/readers that consume it — see real values
|
|
506
|
+
* instead of `undefined`. Without this, a reaction on a MUTATE command reading
|
|
507
|
+
* an entity-owned field (e.g. `payload.invoiceId`) is a silent no-op, which is
|
|
508
|
+
* the gap capsule-pro papers over with hand-written after-emit middleware.
|
|
509
|
+
*
|
|
510
|
+
* Non-governance expressions: unresolved fields are omitted with a warning
|
|
511
|
+
* diagnostic (never a denying throw — that is reserved for guards/policies).
|
|
512
|
+
*/
|
|
513
|
+
function renderEmitPayloadFields(cmd, eventName, scope) {
|
|
514
|
+
const spec = cmd.emitPayloads?.find(ep => ep.eventName === eventName);
|
|
515
|
+
if (!spec)
|
|
516
|
+
return { fields: [], diagnostics: [] };
|
|
517
|
+
const fields = [];
|
|
518
|
+
const diagnostics = [];
|
|
519
|
+
for (const f of spec.fields) {
|
|
520
|
+
const { code, unresolved } = renderExpression(f.expression, scope);
|
|
521
|
+
if (unresolved.length) {
|
|
522
|
+
diagnostics.push({
|
|
523
|
+
severity: 'warning',
|
|
524
|
+
code: 'CONVEX_UNRESOLVED_EMIT_PAYLOAD',
|
|
525
|
+
message: `emit payload field '${cmd.entity}.${eventName}.${f.name}' unresolved (${unresolved.join('; ')}); omitted.`,
|
|
526
|
+
});
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
fields.push({ name: f.name, code });
|
|
530
|
+
}
|
|
531
|
+
return { fields, diagnostics };
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Union of G7 payload fields across ALL of a command's emits (deduped by field
|
|
535
|
+
* name), for the shared reaction-payload binding. Per-event rows carry their
|
|
536
|
+
* own precise fields (see {@link renderEvents}); the shared reaction payload is
|
|
537
|
+
* a benign superset — a reaction only reads the fields it references, so extra
|
|
538
|
+
* sibling-event fields are harmless. Correct for the common single-event case.
|
|
539
|
+
*/
|
|
540
|
+
function unionEmitPayloadFields(cmd, scope) {
|
|
541
|
+
const seen = new Set();
|
|
542
|
+
const fields = [];
|
|
543
|
+
const diagnostics = [];
|
|
544
|
+
for (const ev of cmd.emits ?? []) {
|
|
545
|
+
const r = renderEmitPayloadFields(cmd, ev, scope);
|
|
546
|
+
diagnostics.push(...r.diagnostics);
|
|
547
|
+
for (const f of r.fields) {
|
|
548
|
+
if (seen.has(f.name))
|
|
549
|
+
continue;
|
|
550
|
+
seen.add(f.name);
|
|
551
|
+
fields.push(f);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return { fields, diagnostics };
|
|
555
|
+
}
|
|
556
|
+
function payloadObjectLiteral(fields) {
|
|
557
|
+
return fields.length ? `{ ${fields.map(f => `${f.name}: ${f.code}`).join(', ')} }` : '{}';
|
|
558
|
+
}
|
|
559
|
+
/** Render the event-row inserts for a command's emits, populating G7 payload fields. */
|
|
560
|
+
function renderEvents(eventsTable, cmd, idVar, scope) {
|
|
561
|
+
const lines = [];
|
|
562
|
+
const diagnostics = [];
|
|
563
|
+
for (const ev of cmd.emits ?? []) {
|
|
564
|
+
const { fields, diagnostics: d } = renderEmitPayloadFields(cmd, ev, scope);
|
|
565
|
+
diagnostics.push(...d);
|
|
566
|
+
lines.push(` await ctx.db.insert("${eventsTable}", { type: ${JSON.stringify(ev)}, entity: ${JSON.stringify(cmd.entity)}, entityId: ${idVar}, payload: ${payloadObjectLiteral(fields)}, createdAt: Date.now() });`);
|
|
567
|
+
}
|
|
568
|
+
return { lines, diagnostics };
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Auth/context/payload bindings a handler needs, derived by scanning the body
|
|
572
|
+
* for the identifiers it actually references (avoids both undefined-name and
|
|
573
|
+
* unused-var errors). `payloadValue` is the expression `payload` binds to.
|
|
574
|
+
*/
|
|
575
|
+
function authBindings(bodyText) {
|
|
576
|
+
const lines = [];
|
|
577
|
+
const refs = (token) => new RegExp(`\\b${token}\\b`).test(bodyText);
|
|
578
|
+
if (refs('userRole'))
|
|
579
|
+
lines.push(` const userRole = (ctx as any).auth?.role ?? "anonymous";`);
|
|
580
|
+
if (refs('user'))
|
|
581
|
+
lines.push(` const user = (ctx as any).auth ?? {};`);
|
|
582
|
+
if (refs('context'))
|
|
583
|
+
lines.push(` const context = (ctx as any);`);
|
|
584
|
+
return lines;
|
|
585
|
+
}
|
|
586
|
+
function generateMutation(ir, options, cmd) {
|
|
587
|
+
if (!cmd.entity)
|
|
588
|
+
return null;
|
|
589
|
+
const entity = ir.entities.find(e => e.name === cmd.entity);
|
|
590
|
+
if (!entity || !isPersistentEntity(entity, ir))
|
|
591
|
+
return null;
|
|
592
|
+
const diagnostics = [];
|
|
593
|
+
const table = resolveConvexTableName(entity.name, options);
|
|
594
|
+
const name = `${entity.name}_${cmd.name}`;
|
|
595
|
+
const fkTargets = collectFkTargets(entity, ir, options);
|
|
596
|
+
const isCreate = cmd.name === 'create';
|
|
597
|
+
const paramNames = (cmd.parameters ?? []).map(p => p.name);
|
|
598
|
+
if (isCreate) {
|
|
599
|
+
// Unified create model. Every stored field must be reachable so the insert
|
|
600
|
+
// satisfies the schema: it is either (a) set by a `mutate` action, (b) filled
|
|
601
|
+
// from its default, or (c) exposed as a mutation argument the caller provides.
|
|
602
|
+
// Command parameters that feed actions (and are not themselves fields) are
|
|
603
|
+
// also exposed as args. All expressions resolve against `args`.
|
|
604
|
+
const params = cmd.parameters ?? [];
|
|
605
|
+
const scope = { selfVar: 'args' };
|
|
606
|
+
const argLines = [];
|
|
607
|
+
const argNames = new Set();
|
|
608
|
+
const docLines = [];
|
|
609
|
+
// Fields set by mutate actions (mapped from params); not exposed as args.
|
|
610
|
+
const mutates = (cmd.actions ?? []).filter(a => a.kind === 'mutate' && a.target);
|
|
611
|
+
const targetSet = new Set(mutates.map(a => a.target));
|
|
612
|
+
// Entity properties → args (unless action-set) + doc lines (with defaults).
|
|
613
|
+
for (const p of entity.properties) {
|
|
614
|
+
if (p.name === 'id' || targetSet.has(p.name))
|
|
615
|
+
continue;
|
|
616
|
+
const { validator, diagnostics: vd } = buildValidator(entity, p, ir, options, fkTargets.get(p.name));
|
|
617
|
+
diagnostics.push(...vd);
|
|
618
|
+
if (!validator)
|
|
619
|
+
continue;
|
|
620
|
+
// Required AND no default → required arg; otherwise optional (caller may
|
|
621
|
+
// omit; default fills in).
|
|
622
|
+
const required = p.modifiers.includes('required') && !p.defaultValue;
|
|
623
|
+
if (!argNames.has(p.name)) {
|
|
624
|
+
argLines.push(` ${p.name}: ${required ? validator : `v.optional(${validator})`}`);
|
|
625
|
+
argNames.add(p.name);
|
|
626
|
+
}
|
|
627
|
+
docLines.push(` ${p.name}: args.${p.name}${p.defaultValue ? ` ?? ${defaultToTs(p.defaultValue, validator)}` : ''}`);
|
|
628
|
+
}
|
|
629
|
+
// Command params that are not entity fields (they feed actions) → args.
|
|
630
|
+
for (const p of params) {
|
|
631
|
+
if (argNames.has(p.name))
|
|
632
|
+
continue;
|
|
633
|
+
const validator = paramValidator(p.type);
|
|
634
|
+
argLines.push(` ${p.name}: ${p.required ? validator : `v.optional(${validator})`}`);
|
|
635
|
+
argNames.add(p.name);
|
|
636
|
+
}
|
|
637
|
+
// mutate actions → doc fields (param → field mapping).
|
|
638
|
+
for (const a of mutates) {
|
|
639
|
+
const { code, unresolved } = renderActionValue(entity, a.target, a.expression, scope);
|
|
640
|
+
if (unresolved.length) {
|
|
641
|
+
diagnostics.push({ severity: 'warning', code: 'CONVEX_UNRESOLVED_ACTION', entity: entity.name, message: `create action '${a.target}' unresolved (${unresolved.join('; ')}); omitted.` });
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
docLines.push(` ${a.target}: ${code}`);
|
|
645
|
+
}
|
|
646
|
+
const checks = renderChecks(entity.name, commandChecks(ir, cmd, options.policyMode), scope);
|
|
647
|
+
diagnostics.push(...checks.diagnostics);
|
|
648
|
+
// G7 `emit Event { field: expr }`: populate each event-row payload (and the
|
|
649
|
+
// shared reaction payload below) with declared fields evaluated against the
|
|
650
|
+
// post-action instance. `doc` is the created instance, so `self.X` → doc.X.
|
|
651
|
+
const g7Scope = { selfVar: 'doc' };
|
|
652
|
+
const g7 = unionEmitPayloadFields(cmd, g7Scope);
|
|
653
|
+
diagnostics.push(...g7.diagnostics);
|
|
654
|
+
const events = renderEvents(resolveEventsTableName(ir, options), cmd, '_id', g7Scope);
|
|
655
|
+
diagnostics.push(...events.diagnostics);
|
|
656
|
+
const reactions = renderReactions(ir, options, cmd.emits ?? []);
|
|
657
|
+
diagnostics.push(...reactions.diagnostics);
|
|
658
|
+
const tail = [...events.lines, ...reactions.lines].join('\n');
|
|
659
|
+
// Reaction expressions resolve `payload` against the reference-runtime
|
|
660
|
+
// contract (runtime-engine.ts): the emitted event payload is `{ ...input,
|
|
661
|
+
// result }` and reactions additionally see `_subject` (the canonical
|
|
662
|
+
// entity/command/id metadata). `result` is the affected entity, with its
|
|
663
|
+
// app-level `id` aliased to the Convex `_id` (convexId mode stores no `id`
|
|
664
|
+
// scalar). Without these keys, IR expressions like `payload.result.id` /
|
|
665
|
+
// `payload._subject.id` read through `undefined` and crash at runtime.
|
|
666
|
+
const g7Entries = g7.fields.map(f => `${f.name}: ${f.code}`).join(', ');
|
|
667
|
+
const subjectLiteral = `_subject: { entity: ${JSON.stringify(entity.name)}, command: ${JSON.stringify(cmd.name)}, id: _id }`;
|
|
668
|
+
const payloadBinding = /\bpayload\b/.test(tail)
|
|
669
|
+
? ` const payload: Record<string, any> = { _id, id: _id, ...doc, result: { _id, id: _id, ...doc }${g7Entries ? `, ${g7Entries}` : ''}, ${subjectLiteral} };\n`
|
|
670
|
+
: '';
|
|
671
|
+
const bodyText = [...checks.lines, tail].join('\n');
|
|
672
|
+
const body = `export const ${name} = mutation({\n` +
|
|
673
|
+
` args: {\n${argLines.join(',\n')}\n },\n` +
|
|
674
|
+
` handler: async (ctx, args: any) => {\n` +
|
|
675
|
+
(authBindings(bodyText).join('\n') ? authBindings(bodyText).join('\n') + '\n' : '') +
|
|
676
|
+
` const doc: Record<string, any> = {\n${docLines.join(',\n')}\n };\n` +
|
|
677
|
+
(checks.lines.length ? checks.lines.join('\n') + '\n' : '') +
|
|
678
|
+
` const _id = await ctx.db.insert("${table}", doc as any);\n` +
|
|
679
|
+
payloadBinding +
|
|
680
|
+
(tail ? tail + '\n' : '') +
|
|
681
|
+
` return { _id, ...doc };\n` +
|
|
682
|
+
` },\n});`;
|
|
683
|
+
return { code: body, diagnostics };
|
|
684
|
+
}
|
|
685
|
+
// Non-create mutation
|
|
686
|
+
const argLines = [` docId: v.id("${table}")`];
|
|
687
|
+
for (const p of cmd.parameters ?? []) {
|
|
688
|
+
argLines.push(` ${p.name}: ${p.required ? paramValidator(p.type) : `v.optional(${paramValidator(p.type)})`}`);
|
|
689
|
+
}
|
|
690
|
+
// Non-create: command params are destructured locals; self.x → doc.x.
|
|
691
|
+
const checks = renderChecks(entity.name, commandChecks(ir, cmd, options.policyMode), { selfVar: 'doc', locals: paramNames });
|
|
692
|
+
diagnostics.push(...checks.diagnostics);
|
|
693
|
+
const updateLines = [];
|
|
694
|
+
for (const a of cmd.actions ?? []) {
|
|
695
|
+
if (a.kind !== 'mutate' || !a.target)
|
|
696
|
+
continue;
|
|
697
|
+
const { code, unresolved } = renderActionValue(entity, a.target, a.expression, { selfVar: 'doc', locals: paramNames });
|
|
698
|
+
if (unresolved.length) {
|
|
699
|
+
diagnostics.push({ severity: 'warning', code: 'CONVEX_UNRESOLVED_ACTION', entity: entity.name, message: `action mutate '${a.target}' unresolved (${unresolved.join('; ')}); omitted.` });
|
|
700
|
+
continue;
|
|
701
|
+
}
|
|
702
|
+
updateLines.push(` ${a.target}: ${code}`);
|
|
703
|
+
}
|
|
704
|
+
// G7 `emit Event { field: expr }`: declared payload fields are evaluated
|
|
705
|
+
// against the POST-action instance (fetched doc + applied updates). Introduce
|
|
706
|
+
// `__after` ONLY when the command actually declares emit fields, so commands
|
|
707
|
+
// without G7 emit byte-identical output to before (no unused-var, no churn).
|
|
708
|
+
const hasG7 = !!(cmd.emitPayloads && cmd.emitPayloads.length > 0);
|
|
709
|
+
const g7Scope = { selfVar: hasG7 ? '__after' : 'doc', locals: paramNames };
|
|
710
|
+
const g7 = unionEmitPayloadFields(cmd, g7Scope);
|
|
711
|
+
diagnostics.push(...g7.diagnostics);
|
|
712
|
+
const useAfter = hasG7 && g7.fields.length > 0;
|
|
713
|
+
const afterLine = useAfter ? ` const __after: Record<string, any> = { ...doc, ...updates };\n` : '';
|
|
714
|
+
const events = renderEvents(resolveEventsTableName(ir, options), cmd, 'docId', g7Scope);
|
|
715
|
+
diagnostics.push(...events.diagnostics);
|
|
716
|
+
const reactions = renderReactions(ir, options, cmd.emits ?? []);
|
|
717
|
+
diagnostics.push(...reactions.diagnostics);
|
|
718
|
+
const tail = [...events.lines, ...reactions.lines].join('\n');
|
|
719
|
+
// Same reference-runtime payload contract as the create branch: `result` is
|
|
720
|
+
// the affected entity (post-patch) with `id` aliased to the Convex `_id`, and
|
|
721
|
+
// `_subject` carries the canonical entity/command/id metadata reactions read.
|
|
722
|
+
const g7Entries = g7.fields.map(f => `${f.name}: ${f.code}`).join(', ');
|
|
723
|
+
const subjectLiteral = `_subject: { entity: ${JSON.stringify(entity.name)}, command: ${JSON.stringify(cmd.name)}, id: docId }`;
|
|
724
|
+
const payloadBinding = /\bpayload\b/.test(tail)
|
|
725
|
+
? (useAfter
|
|
726
|
+
? ` const payload: Record<string, any> = { id: docId, ...__after, result: { id: docId, ...__after }${g7Entries ? `, ${g7Entries}` : ''}, ${subjectLiteral} };\n`
|
|
727
|
+
: ` const payload: Record<string, any> = { id: docId, ...doc, ...updates, result: { id: docId, ...doc, ...updates }, ${subjectLiteral} };\n`)
|
|
728
|
+
: '';
|
|
729
|
+
const argDestructure = paramNames.length ? `, ${paramNames.join(', ')}` : '';
|
|
730
|
+
const bodyText = [...checks.lines, ...updateLines, tail].join('\n');
|
|
731
|
+
const body = `export const ${name} = mutation({\n` +
|
|
732
|
+
` args: {\n${argLines.join(',\n')}\n },\n` +
|
|
733
|
+
` handler: async (ctx, { docId${argDestructure} }) => {\n` +
|
|
734
|
+
(authBindings(bodyText).join('\n') ? authBindings(bodyText).join('\n') + '\n' : '') +
|
|
735
|
+
` const doc = await ctx.db.get(docId) as Record<string, any> | null;\n` +
|
|
736
|
+
` if (!doc) throw new Error(${JSON.stringify(`${entity.name} not found`)});\n` +
|
|
737
|
+
(checks.lines.length ? checks.lines.join('\n') + '\n' : '') +
|
|
738
|
+
` const updates = {\n${updateLines.join(',\n')}${updateLines.length ? '\n' : ''} };\n` +
|
|
739
|
+
` await ctx.db.patch(docId, updates as any);\n` +
|
|
740
|
+
afterLine +
|
|
741
|
+
payloadBinding +
|
|
742
|
+
(tail ? tail + '\n' : '') +
|
|
743
|
+
` return { ...doc, ...updates };\n` +
|
|
744
|
+
` },\n});`;
|
|
745
|
+
return { code: body, diagnostics };
|
|
746
|
+
}
|
|
747
|
+
export function generateMutations(ir, rawOptions) {
|
|
748
|
+
const options = normalizeOptions(rawOptions);
|
|
749
|
+
const diagnostics = [];
|
|
750
|
+
const blocks = [];
|
|
751
|
+
for (const cmd of ir.commands) {
|
|
752
|
+
const m = generateMutation(ir, options, cmd);
|
|
753
|
+
if (!m)
|
|
754
|
+
continue;
|
|
755
|
+
blocks.push(m.code);
|
|
756
|
+
diagnostics.push(...m.diagnostics);
|
|
757
|
+
}
|
|
758
|
+
// Emit helpers only when the generated mutations actually reference them
|
|
759
|
+
// (a policyMode:'skip' build may use neither), so there is no dead code.
|
|
760
|
+
const body = blocks.join('\n\n');
|
|
761
|
+
const helpers = [];
|
|
762
|
+
if (/\bcheckRole\(/.test(body)) {
|
|
763
|
+
helpers.push(`// Role hierarchy from IR (effective permissions after inheritance).\n` +
|
|
764
|
+
`const ROLE_PERMISSIONS: Record<string, string[]> = ${roleMapLiteral(ir)};\n\n` +
|
|
765
|
+
`function checkRole(userRole: string, action: string): boolean {\n` +
|
|
766
|
+
` const perms = ROLE_PERMISSIONS[userRole];\n` +
|
|
767
|
+
` return perms ? (perms.includes(action) || perms.includes("all")) : false;\n` +
|
|
768
|
+
`}`);
|
|
769
|
+
}
|
|
770
|
+
if (/\bflag\(/.test(body)) {
|
|
771
|
+
helpers.push(`// Feature toggle (configurable). Not an authorization gate.\nfunction flag(_name?: string): boolean { return true; }`);
|
|
772
|
+
}
|
|
773
|
+
const policyNote = options.policyMode === 'skip' ? ' (policyMode: skip — authorization policies omitted)' : '';
|
|
774
|
+
// Fan-out reactions dispatch sibling mutations via ctx.runMutation, which
|
|
775
|
+
// needs the generated `api`. Only import it when actually used (no dead import).
|
|
776
|
+
const needsApi = /\bctx\.runMutation\b/.test(body);
|
|
777
|
+
const code = `${GENERATED_HEADER}\n// ${blocks.length} mutation(s); roles: ${(ir.roles ?? []).length}; policies: ${ir.policies.length}.${policyNote}\n\n` +
|
|
778
|
+
`import { mutation } from "./_generated/server";\n` +
|
|
779
|
+
`import { v } from "convex/values";\n` +
|
|
780
|
+
(needsApi ? `import { api } from "./_generated/api";\n` : '') +
|
|
781
|
+
`\n` +
|
|
782
|
+
(helpers.length ? helpers.join('\n\n') + '\n\n' : '') +
|
|
783
|
+
`${body}\n`;
|
|
784
|
+
return { code, diagnostics };
|
|
785
|
+
}
|
|
786
|
+
//# sourceMappingURL=functions.js.map
|