@sequenceholdings/orm 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/README.md +11 -1
  2. package/dist/authoring.cjs +1066 -59
  3. package/dist/authoring.cjs.map +1 -1
  4. package/dist/authoring.d.cts +289 -24
  5. package/dist/authoring.d.ts +289 -24
  6. package/dist/authoring.js +1056 -60
  7. package/dist/authoring.js.map +1 -1
  8. package/dist/canonical.cjs +415 -9
  9. package/dist/canonical.cjs.map +1 -1
  10. package/dist/canonical.d.cts +235 -1
  11. package/dist/canonical.d.ts +235 -1
  12. package/dist/canonical.js +411 -10
  13. package/dist/canonical.js.map +1 -1
  14. package/dist/cli.cjs +1764 -225
  15. package/dist/cli.cjs.map +1 -1
  16. package/dist/cli.js +1765 -226
  17. package/dist/cli.js.map +1 -1
  18. package/dist/client.cjs.map +1 -1
  19. package/dist/client.d.cts +1 -1
  20. package/dist/client.d.ts +1 -1
  21. package/dist/client.js.map +1 -1
  22. package/dist/compiler.cjs +506 -54
  23. package/dist/compiler.cjs.map +1 -1
  24. package/dist/compiler.d.cts +39 -231
  25. package/dist/compiler.d.ts +39 -231
  26. package/dist/compiler.js +504 -55
  27. package/dist/compiler.js.map +1 -1
  28. package/dist/drizzle.cjs +14 -0
  29. package/dist/drizzle.cjs.map +1 -0
  30. package/dist/drizzle.d.cts +1 -0
  31. package/dist/drizzle.d.ts +1 -0
  32. package/dist/drizzle.js +3 -0
  33. package/dist/drizzle.js.map +1 -0
  34. package/dist/dynamic-input.cjs +391 -0
  35. package/dist/dynamic-input.cjs.map +1 -0
  36. package/dist/dynamic-input.d.cts +111 -0
  37. package/dist/dynamic-input.d.ts +111 -0
  38. package/dist/dynamic-input.js +380 -0
  39. package/dist/dynamic-input.js.map +1 -0
  40. package/dist/index.cjs +2223 -219
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.cts +125 -9
  43. package/dist/index.d.ts +125 -9
  44. package/dist/index.js +2199 -220
  45. package/dist/index.js.map +1 -1
  46. package/dist/ir.cjs +249 -14
  47. package/dist/ir.cjs.map +1 -1
  48. package/dist/ir.d.cts +20 -80
  49. package/dist/ir.d.ts +20 -80
  50. package/dist/ir.js +249 -14
  51. package/dist/ir.js.map +1 -1
  52. package/dist/predicate-v2.cjs +1093 -0
  53. package/dist/predicate-v2.cjs.map +1 -0
  54. package/dist/predicate-v2.d.cts +139 -0
  55. package/dist/predicate-v2.d.ts +139 -0
  56. package/dist/predicate-v2.js +1083 -0
  57. package/dist/predicate-v2.js.map +1 -0
  58. package/dist/sdl.cjs +344 -55
  59. package/dist/sdl.cjs.map +1 -1
  60. package/dist/sdl.d.cts +1 -3
  61. package/dist/sdl.d.ts +1 -3
  62. package/dist/sdl.js +344 -55
  63. package/dist/sdl.js.map +1 -1
  64. package/package.json +16 -1
  65. package/templates/orm-namespace/CLAUDE.md +6 -5
package/dist/index.d.cts CHANGED
@@ -1,12 +1,15 @@
1
- export { ActionInput, ActionParamInput, AuthoringContext, AuthoringRegistration, COLUMN_BRAND, COLUMN_DEFAULT_FNS, ColumnBuilder, ColumnDefaultFn, ColumnDefaultLiteral, ColumnTypeSpec, ENUM_BRAND, EnumRef, IndexInput, LINK_BRAND, LinkKind, LoadNamespaceOptions, LoadedNamespaceV2, NAMESPACE_CONFIG_BRAND, NAMESPACE_CONFIG_FILE, NamespaceCapabilitiesInput, NamespaceConfigInput, PolicyInput, PolicyVariantInput, PolicyWithVariantsInput, SCHEMA_DIR, SeqLink, SeqNamespaceConfig, SeqTable, SerializeNamespaceInput, SyncedTableConfig, TABLE_BRAND, TableConfig, TablePoliciesInput, TableRef, ToManyOptions, ToOneOptions, ToPlatformUserOptions, activeAuthoringContext, beginAuthoringContext, computeCanonicalHash, defineEnum, defineNamespace, defineSyncedTable, defineTable, deriveColumnName, endAuthoringContext, isColumnBuilder, isEnumRef, isSeqLink, isSeqNamespaceConfig, isSeqTable, loadNamespaceFromDir, serializeNamespace, t, toMany, toOne, toPlatformUser } from './authoring.cjs';
1
+ export { AuthoringContext, AuthoringRegistration, COLUMN_BRAND, COLUMN_DEFAULT_FNS, ColumnBuilder, ColumnDefaultFn, ColumnDefaultLiteral, ColumnTypeSpec, CowMutationInput, DrizzleRelation, ENUM_BRAND, EnumRef, IndexInput, LINK_BRAND, LinkKind, LoadNamespaceOptions, LoadedNamespaceV2, NAMESPACE_CONFIG_BRAND, NAMESPACE_CONFIG_FILE, NamespaceCapabilitiesInput, NamespaceConfigInput, ORM_TO_PIPELINE_TYPE, OrmContractColumnMap, OrmContractPipelineColumn, OrmSyncedTableContract, OrmToPipelineType, OverlayTableRef, OverlayWinsUnionInput, OverrideRowMutationInput, PolicyInput, PolicyVariantInput, PolicyWithVariantsInput, RelationRef, RevertOverlayMutationInput, SCHEMA_DIR, SYNCED_CONTRACT_HASH_DOMAIN, SeqLink, SeqNamespaceConfig, SeqTable, SeqView, SerializeNamespaceInput, SyncedTableConfig, SyncedTablePoliciesInput, TABLE_BRAND, TableConfig, TablePoliciesInput, TableRef, ToManyOptions, ToOneOptions, ToPlatformUserOptions, TypedSyncedTableConfig, VIEW_BRAND, ViewConfig, ViewPoliciesInput, ViewQueryContext, ViewSelectQuery, activeAuthoringContext, beginAuthoringContext, computeCanonicalHash, computeSyncedContractHash, defineEnum, defineNamespace, defineSyncedTable, defineTable, defineView, deriveColumnName, endAuthoringContext, extractOrmSyncedTableContract, isColumnBuilder, isEnumRef, isSeqLink, isSeqNamespaceConfig, isSeqTable, isSeqView, loadNamespaceFromDir, overlayWinsUnion, overrideRowMutation, revertOverlayMutation, serializeNamespace, syncedContractSurface, t, toMany, toOne, toPlatformUser } from './authoring.cjs';
2
2
  import { CanonicalDefinition } from './canonical.cjs';
3
- export { CANONICAL_FORMAT, CanonicalColumn, CanonicalEnum, CanonicalLink, CanonicalTable, IDENTIFIER_RE, PolicyExpression, canonicalActionSchema, canonicalColumnSchema, canonicalDefinitionSchema, canonicalEnumSchema, canonicalIndexSchema, canonicalLinkSchema, canonicalPoliciesSchema, canonicalTableSchema, normalizeCanonical, policyExpressionSchema, policyVariantSchema } from './canonical.cjs';
3
+ export { CANONICAL_FORMAT, CanonicalColumn, CanonicalEnum, CanonicalLink, CanonicalTable, CanonicalView, IDENTIFIER_RE, PolicyExpression, canonicalActionSchema, canonicalColumnSchema, canonicalDefinitionSchema, canonicalEnumSchema, canonicalIndexSchema, canonicalLinkSchema, canonicalPoliciesSchema, canonicalRelations, canonicalTableSchema, canonicalViewSchema, normalizeCanonical, policyExpressionSchema, policyVariantSchema } from './canonical.cjs';
4
4
  import { CustomRolesBlock } from '@sequenceholdings/custom-roles-manifest';
5
5
  export { CustomRolesBlock, capabilityPinsSchema, customRolesBlockSchema, customRolesDeclared, parseCapabilityPin, validateCapabilityPins } from '@sequenceholdings/custom-roles-manifest';
6
6
  import { z } from 'zod';
7
+ import { PredIr } from './ir.cjs';
8
+ export { CLAIMS_CONTRACT, CMP_OPS, ClaimKey, CmpOp, CompiledArtifact, CompiledOperation, INPUT_REF_KINDS, IR_VERSION, InputRefKind, IrVersionError, LimitIr, OrderIr, RootIr, SelectionIr, TableMetaIr, ValueIr, VariableDefaultIr, VariableIr, compiledArtifactSchema, compiledOperationSchema, indexByHash, limitIrSchema, normalizeIr, orderIrSchema, predIrSchema, rootIrSchema, selectionIrSchema, tableMetaIrSchema, valueIrSchema, variableDefaultIrSchema, variableIrSchema } from './ir.cjs';
7
9
  import { generateDrizzleJson } from 'drizzle-kit/api';
8
10
  import { PgTableWithColumns } from 'drizzle-orm/pg-core';
9
- export { CLAIMS_CONTRACT, CMP_OPS, ClaimKey, CmpOp, CompiledArtifact, CompiledOperation, INPUT_REF_KINDS, IR_VERSION, InputRefKind, IrVersionError, LimitIr, OrderIr, PredIr, RootIr, SelectionIr, TableMetaIr, ValueIr, VariableDefaultIr, VariableIr, compiledArtifactSchema, compiledOperationSchema, indexByHash, limitIrSchema, normalizeIr, orderIrSchema, predIrSchema, rootIrSchema, selectionIrSchema, tableMetaIrSchema, valueIrSchema, variableDefaultIrSchema, variableIrSchema } from './ir.cjs';
11
+ import 'drizzle-orm';
12
+ import 'drizzle-orm/query-builders/query-builder';
10
13
 
11
14
  /**
12
15
  * The reserved `namespace.yaml` — namespace-level settings beside the table
@@ -99,8 +102,8 @@ declare const actionSchema: z.ZodObject<{
99
102
  }>>>;
100
103
  audit: z.ZodOptional<z.ZodObject<{
101
104
  action: z.ZodEnum<{
102
- create: "create";
103
105
  update: "update";
106
+ create: "create";
104
107
  delete: "delete";
105
108
  }>;
106
109
  resource: z.ZodOptional<z.ZodString>;
@@ -246,6 +249,8 @@ declare const tableFileSchema: z.ZodObject<{
246
249
  policies: z.ZodOptional<z.ZodObject<{
247
250
  read: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<ParsedPredicate, string>>>;
248
251
  write: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<ParsedPredicate, string>>>;
252
+ insert: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<ParsedPredicate, string>>>;
253
+ update: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<ParsedPredicate, string>>>;
249
254
  }, z.core.$strict>>;
250
255
  actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
251
256
  description: z.ZodOptional<z.ZodString>;
@@ -282,8 +287,8 @@ declare const tableFileSchema: z.ZodObject<{
282
287
  }>>>;
283
288
  audit: z.ZodOptional<z.ZodObject<{
284
289
  action: z.ZodEnum<{
285
- create: "create";
286
290
  update: "update";
291
+ create: "create";
287
292
  delete: "delete";
288
293
  }>;
289
294
  resource: z.ZodOptional<z.ZodString>;
@@ -347,6 +352,24 @@ declare function compileActionStatements(action: ActionDefinition, renderParam?:
347
352
  /** Compiled `requires` gate — a SQL boolean over the transaction claims, or null when unguarded. */
348
353
  declare function compileActionRequires(action: ActionDefinition): string | null;
349
354
 
355
+ /** Canonical column types can be enums — v1 `PredicateColumnTypes` cannot carry them. */
356
+ type SyncedColumnType = ColumnType | {
357
+ readonly enum: string;
358
+ };
359
+ type SyncedPredicateColumnTypes = Readonly<Record<string, SyncedColumnType>>;
360
+ interface CompilePredIrToSqlOptions {
361
+ /** Column name → declared type, for claim casts in comparisons. */
362
+ readonly columnTypes?: SyncedPredicateColumnTypes;
363
+ /** Logical column name → physical column name for the synced backing. */
364
+ readonly columnNames?: Readonly<Record<string, string>>;
365
+ }
366
+ /**
367
+ * PredIr → a static SQL boolean for synced-view WHERE clauses. Capability and
368
+ * role leaves stay as runtime claim checks (mirroring table RLS), unlike the
369
+ * data-plane executor which pre-resolves them per caller.
370
+ */
371
+ declare function compilePredIrToSql(pred: PredIr, options?: CompilePredIrToSqlOptions): string;
372
+
350
373
  declare const COMPARE_OPS: readonly ["=", "!=", "<", "<=", ">", ">="];
351
374
  type CompareOp = (typeof COMPARE_OPS)[number];
352
375
  type Operand = {
@@ -395,11 +418,15 @@ declare function compilePredicate(predicate: Predicate, columnTypes?: PredicateC
395
418
  declare const CLAIMS_SETTING = "request.jwt.claims";
396
419
  /** Claims JSON key holding the caller's granted capability pins (a string array). */
397
420
  declare const CAPABILITIES_CLAIM_KEY = "capabilities";
421
+ /** Claims JSON key holding the caller's granted custom roles (a string array). */
422
+ declare const ROLES_CLAIM_KEY = "roles";
398
423
  declare const quoteIdentifier: (name: string) => string;
399
424
  declare const quoteLiteral: (value: string) => string;
400
425
  declare const claimExpression: (key: string) => string;
401
426
  /** NULL claims (or a missing capabilities array) coalesce to false — capability checks fail closed. */
402
427
  declare const capabilityExpression: (key: string) => string;
428
+ /** NULL claims (or a missing roles array) coalesce to false — role checks fail closed. */
429
+ declare const roleExpression: (key: string) => string;
403
430
 
404
431
  /** Namespace names become Postgres identifiers (`orm_<ns>` schema, `orm_<ns>_consumer` role) — the tight grammar is a security control, not cosmetics. */
405
432
  declare const NAMESPACE_PATTERN: RegExp;
@@ -494,6 +521,7 @@ declare function applyMigrationHints(previous: NamespaceSnapshot, definition: Na
494
521
  * pending statement and lets a non-converged schema pass.
495
522
  */
496
523
  declare function isOwnedStatement(statement: string): boolean;
524
+ declare function isOwnedStatementV2(statement: string): boolean;
497
525
  /**
498
526
  * The kit-owned statements a live database would still need to match the
499
527
  * definition — drizzle-kit's `pushSchema` introspection diffed against the
@@ -506,6 +534,12 @@ declare function pendingKitStatements({ definition, db, }: {
506
534
  /** A drizzle PgDatabase over the target — typed loose because pushSchema's own parameter is `PgDatabase<any>`. */
507
535
  db: unknown;
508
536
  }): Promise<string[]>;
537
+ /** V2 convergence includes managed regular views in drizzle-kit's verdict. */
538
+ declare function pendingKitStatementsV2({ canonical, db, }: {
539
+ canonical: CanonicalDefinition;
540
+ /** A drizzle PgDatabase over the target — typed loose because pushSchema's own parameter is `PgDatabase<any>`. */
541
+ db: unknown;
542
+ }): Promise<string[]>;
509
543
 
510
544
  interface DrizzleEntities {
511
545
  /** The in-memory schema bag drizzle-kit snapshots (`generateDrizzleJson(imports)`). */
@@ -569,10 +603,68 @@ declare function actionPrepareChecks(definition: NamespaceDefinition): string[];
569
603
  * write-capable callers SELECT rows the read policy hides.
570
604
  */
571
605
  declare function securityStatements(definition: NamespaceDefinition): string[];
606
+ declare const syncedTables: (definition: NamespaceDefinition) => TableFile[];
607
+ /**
608
+ * A resolved synced-table backing: the physical Lakebase relation name
609
+ * (captured at provision, never derived) plus optional projection column
610
+ * types for claim-cast compilation.
611
+ */
612
+ interface SyncedBacking {
613
+ readonly table: string;
614
+ /** Physical Lakebase relation (e.g. `synced_loans` or `df_retail_customers`). */
615
+ readonly physicalRelation: string;
616
+ /** Column name → ORM column type, for claim casts in the view's WHERE. */
617
+ readonly columnTypes?: PredicateColumnTypes;
618
+ }
619
+ /**
620
+ * Emit CREATE OR REPLACE VIEW + SELECT-only grants for synced tables that have
621
+ * a registered backing. Synced tables cannot use table-level RLS (they may be
622
+ * foreign tables), so claims filtering compiles into the view's WHERE clause.
623
+ *
624
+ * Each view lives in `orm_<ns>` alongside regular tables, named identically to
625
+ * the synced table definition so read routing is transparent.
626
+ */
627
+ /**
628
+ * Atlas reassigns every relation in `orm_<ns>` to this role after apply.
629
+ * Synced views resolve backing access as their owner, so the emitter must
630
+ * grant this role narrow SELECT on each physical relation before CREATE VIEW.
631
+ */
632
+ declare const SYNCED_VIEW_EXECUTION_OWNER_ROLE = "orm_exec";
633
+ declare function syncedViewStatements({ definition, backings, readPolicyIrByTable, columnNamesByTable, columnTypesByTable, executionOwnerRole, }: {
634
+ definition: NamespaceDefinition;
635
+ backings: readonly SyncedBacking[];
636
+ /** v2 compiled read policies (preserves capability/role variants). */
637
+ readPolicyIrByTable?: ReadonlyMap<string, PredIr>;
638
+ /** Logical column name → physical backing column name per synced table. */
639
+ columnNamesByTable?: ReadonlyMap<string, Readonly<Record<string, string>>>;
640
+ /**
641
+ * Canonical declared types per synced table (keyed by logical AND physical
642
+ * name). Carries what the TableFile adapter cannot — enum types — so IN/NIN
643
+ * policies never silently downgrade an enum comparison to text[]-vs-enum.
644
+ */
645
+ columnTypesByTable?: ReadonlyMap<string, SyncedPredicateColumnTypes>;
646
+ /** Role that will own the view after ensureExecutionOwner (default orm_exec). */
647
+ executionOwnerRole?: string;
648
+ }): string[];
649
+ /**
650
+ * Drop synced views — idempotent cleanup for apply retries and removal.
651
+ */
652
+ declare function syncedViewDropStatements({ schemaName, tables, }: {
653
+ schemaName: string;
654
+ tables: readonly string[];
655
+ }): string[];
656
+ /**
657
+ * Revoke orm_exec backing privileges for physical relations that are no longer
658
+ * active for this namespace (removed / renamed / rebound away).
659
+ */
660
+ declare function syncedBackingRevokeStatements({ backings, executionOwnerRole, }: {
661
+ backings: readonly SyncedBacking[];
662
+ executionOwnerRole?: string;
663
+ }): string[];
572
664
 
573
665
  declare const sqlTypeName: (type: ColumnType) => string;
574
666
 
575
- declare const STATEMENT_KINDS: readonly ["hint", "ddl", "security", "function"];
667
+ declare const STATEMENT_KINDS: readonly ["hint", "ddl", "security", "function", "synced_view"];
576
668
  type StatementKind = (typeof STATEMENT_KINDS)[number];
577
669
  interface CompiledStatement {
578
670
  readonly kind: StatementKind;
@@ -605,6 +697,13 @@ declare const compileNamespace: (definition: NamespaceDefinition) => Promise<Pla
605
697
  * table handles — the same `DrizzleEntities` shape engine/snapshot.ts consumes.
606
698
  */
607
699
  declare function buildDrizzleEntitiesV2(definition: CanonicalDefinition): DrizzleEntities;
700
+ declare function rewriteSyncedSourceRelationsInViewQuery({ query, canonical, schemaName, dependencies, }: {
701
+ query: string;
702
+ canonical: CanonicalDefinition;
703
+ schemaName: string;
704
+ /** The view's declared logical dependencies — disambiguates shared sources. */
705
+ dependencies?: readonly string[];
706
+ }): string;
608
707
  /** drizzle-kit snapshot for a canonical definition — the v2 twin of engine/snapshot.ts generateSnapshot. */
609
708
  declare function generateSnapshotV2(definition: CanonicalDefinition, previousId?: string): NamespaceSnapshot;
610
709
  /**
@@ -635,6 +734,21 @@ declare function planMigrationV2({ canonical, previousSnapshot, }: {
635
734
  canonical: CanonicalDefinition;
636
735
  previousSnapshot?: NamespaceSnapshot;
637
736
  }): Promise<PlannedMigration>;
737
+ /**
738
+ * Drizzle's manual-view snapshot stores declared columns, but PostgreSQL names
739
+ * and types the live view from the SELECT itself. Assert the live catalog in
740
+ * the same transaction so a stale alias/type or an incomplete dependency
741
+ * declaration can never be persisted as a successful schema version.
742
+ */
743
+ /**
744
+ * Assert live view columns/types/dependencies match the canonical contract.
745
+ * Used by planMigrationV2 and by CASCADE recovery recreates (same transaction).
746
+ */
747
+ declare function validateViewCatalogStatement({ canonical, view, schema, }: {
748
+ canonical: CanonicalDefinition;
749
+ view: NonNullable<CanonicalDefinition['views']>[number];
750
+ schema: string;
751
+ }): string;
638
752
 
639
753
  declare class OrmDefinitionError extends Error {
640
754
  readonly file?: string | undefined;
@@ -815,8 +929,10 @@ declare function writeMigration({ dir, workspace, plan, contentHash, destructive
815
929
  * - the single v1 `primary_key: true` column becomes `primaryKey: [name]`;
816
930
  * - policy expressions carry over as their verbatim DSL source strings
817
931
  * (re-parsed by the v2 predicate compiler, never the parsed v1 AST);
818
- * - actions carry over verbatim (multi-statement `executes` lists join on
819
- * ';\n' — the boundaries stay recoverable for the compiled-op executor);
932
+ * - v1 actions are DROPPED, loudly: v2 has no action surface — writes are
933
+ * persisted mutations — and the v1→v2 apply sweep removes the `action_*`
934
+ * functions anyway. The emitter leaves a TODO listing each dropped action
935
+ * so it gets re-authored as a mutation (or a CoW `overrideRowMutation`);
820
936
  * - the capabilities block passes through untouched (verbatim custom-roles
821
937
  * grammar in both formats);
822
938
  * - qualified (cross-namespace) link targets have no v2 representation —
@@ -897,4 +1013,4 @@ declare function parseCanonicalDefinition(value: unknown): NamespaceDefinition;
897
1013
 
898
1014
  declare const parsedPredicateSchema: z.ZodPipe<z.ZodString, z.ZodTransform<ParsedPredicate, string>>;
899
1015
 
900
- export { ACTION_REQUIRES_DENIED_SQLSTATE, ACTION_VALIDATES_FAILED_SQLSTATE, AUDIT_ACTIONS, type ActionDefinition, CAPABILITIES_CLAIM_KEY, CAPABILITY_KEY_PATTERN, CLAIMS_SETTING, CLAIM_KEY_PATTERN, COLUMN_TYPES, COMPARE_OPS, CONSUMER_ROLE_SUFFIX, CanonicalDefinition, type ColumnDefault, type ColumnDefinition, type ColumnType, type CommittedChainEntry, type CommittedMigration, type CompareOp, type CompiledStatement, DEFINITION_FILE_EXTENSIONS, type DefinitionFile, type DefinitionSource, type DestructiveStatement, type DiffOptions, type DrizzleEntities, HASH_DOMAIN, IDENTIFIER_PATTERN, type IndexDefinition, type JournalEntry, type LinkDefinition, type LoadedNamespace, MAX_DEFINITION_FILE_BYTES, MAX_IDENTIFIER_LENGTH, MIGRATIONS_DIRNAME, type MigrationJournal, type MigrationWorkspace, NAMESPACE_CONFIG_FILENAMES, NAMESPACE_PATTERN, type NamespaceCapabilities, type NamespaceConfig, type NamespaceDefinition, type NamespaceSnapshot, ORM_DATA_TOKEN_HEADER, ORM_SCHEMA_PREFIX, ORM_SERVICE_DATA_TOKEN_HEADER, type Operand, OrmDefinitionError, type ParsedPredicate, type PlannedMigration, type Predicate, PredicateParseError, QUALIFIED_TABLE_PATTERN, RESERVED_COLUMN_NAMES, RESERVED_TABLE_NAMES, type RebaseEntry, type RebaseEntryInput, type RebaseNoopOptions, STATEMENT_KINDS, SYNCED_SOURCE_PATTERN, type StatementKind, type TableFile, type ValidatesEntry, type WrittenMigration, actionFunctionName, actionFunctionStatements, actionParamArg, actionParamOrder, actionParamSchema, actionPrepareChecks, actionSchema, actionWriteTargets, actionsInterfaceName, applyMigrationHints, applyMigrationHintsV2, buildActionParamsSchema, buildDrizzleEntities, buildDrizzleEntitiesV2, buildNamespaceDefinition, buildRebaseJournalEntry, canonicalizeDefinition, capabilityExpression, castParts, checksumOf, claimExpression, classifyDestructive, columnSchema, columnTypeSchema, compileActionRequires, compileActionStatements, compileNamespace, compilePredicate, computeDefinitionHash, consumerRoleName, convertV1DefinitionToCanonical, declaredCapabilityKeys, diffCommand, diffStatements, emptyJournal, emptySnapshot, extractNamedParams, generateNamespaceTypes, generateSnapshot, generateSnapshotV2, identifierSchema, isFunctionDefault, isOwnedStatement, isQualifiedReference, loadCommittedMigrations, loadCommittedTipMigration, loadNamespaceDefinition, migrationName, namespaceConfigSchema, namespaceSchema, normalizeSnapshot, ormSchemaName, parseCanonicalDefinition, parseDefinitionSources, parsePredicate, parseTableFile, parsedPredicateSchema, pendingKitStatements, planMigration, planMigrationV2, predicateOperands, quoteIdentifier, quoteLiteral, readMigrationSql, readMigrationWorkspace, readSnapshot, rebaseViolations, referencedCapabilities, referencedColumns, renderMigrationSql, securityStatements, sqlTypeName, stableJson, tableFileSchema, tableReferenceSchema, typesInterfaceName, verifyRebaseIsNoop, walkPredicate, writeMigration };
1016
+ export { ACTION_REQUIRES_DENIED_SQLSTATE, ACTION_VALIDATES_FAILED_SQLSTATE, AUDIT_ACTIONS, type ActionDefinition, CAPABILITIES_CLAIM_KEY, CAPABILITY_KEY_PATTERN, CLAIMS_SETTING, CLAIM_KEY_PATTERN, COLUMN_TYPES, COMPARE_OPS, CONSUMER_ROLE_SUFFIX, CanonicalDefinition, type ColumnDefault, type ColumnDefinition, type ColumnType, type CommittedChainEntry, type CommittedMigration, type CompareOp, type CompilePredIrToSqlOptions, type CompiledStatement, DEFINITION_FILE_EXTENSIONS, type DefinitionFile, type DefinitionSource, type DestructiveStatement, type DiffOptions, type DrizzleEntities, HASH_DOMAIN, IDENTIFIER_PATTERN, type IndexDefinition, type JournalEntry, type LinkDefinition, type LoadedNamespace, MAX_DEFINITION_FILE_BYTES, MAX_IDENTIFIER_LENGTH, MIGRATIONS_DIRNAME, type MigrationJournal, type MigrationWorkspace, NAMESPACE_CONFIG_FILENAMES, NAMESPACE_PATTERN, type NamespaceCapabilities, type NamespaceConfig, type NamespaceDefinition, type NamespaceSnapshot, ORM_DATA_TOKEN_HEADER, ORM_SCHEMA_PREFIX, ORM_SERVICE_DATA_TOKEN_HEADER, type Operand, OrmDefinitionError, type ParsedPredicate, type PlannedMigration, PredIr, type Predicate, type PredicateColumnTypes, PredicateParseError, QUALIFIED_TABLE_PATTERN, RESERVED_COLUMN_NAMES, RESERVED_TABLE_NAMES, ROLES_CLAIM_KEY, type RebaseEntry, type RebaseEntryInput, type RebaseNoopOptions, STATEMENT_KINDS, SYNCED_SOURCE_PATTERN, SYNCED_VIEW_EXECUTION_OWNER_ROLE, type StatementKind, type SyncedBacking, type SyncedColumnType, type SyncedPredicateColumnTypes, type TableFile, type ValidatesEntry, type WrittenMigration, actionFunctionName, actionFunctionStatements, actionParamArg, actionParamOrder, actionParamSchema, actionPrepareChecks, actionSchema, actionWriteTargets, actionsInterfaceName, applyMigrationHints, applyMigrationHintsV2, buildActionParamsSchema, buildDrizzleEntities, buildDrizzleEntitiesV2, buildNamespaceDefinition, buildRebaseJournalEntry, canonicalizeDefinition, capabilityExpression, castParts, checksumOf, claimExpression, classifyDestructive, columnSchema, columnTypeSchema, compileActionRequires, compileActionStatements, compileNamespace, compilePredIrToSql, compilePredicate, computeDefinitionHash, consumerRoleName, convertV1DefinitionToCanonical, declaredCapabilityKeys, diffCommand, diffStatements, emptyJournal, emptySnapshot, extractNamedParams, generateNamespaceTypes, generateSnapshot, generateSnapshotV2, identifierSchema, isFunctionDefault, isOwnedStatement, isOwnedStatementV2, isQualifiedReference, loadCommittedMigrations, loadCommittedTipMigration, loadNamespaceDefinition, migrationName, namespaceConfigSchema, namespaceSchema, normalizeSnapshot, ormSchemaName, parseCanonicalDefinition, parseDefinitionSources, parsePredicate, parseTableFile, parsedPredicateSchema, pendingKitStatements, pendingKitStatementsV2, planMigration, planMigrationV2, predicateOperands, quoteIdentifier, quoteLiteral, readMigrationSql, readMigrationWorkspace, readSnapshot, rebaseViolations, referencedCapabilities, referencedColumns, renderMigrationSql, rewriteSyncedSourceRelationsInViewQuery, roleExpression, securityStatements, sqlTypeName, stableJson, syncedBackingRevokeStatements, syncedTables, syncedViewDropStatements, syncedViewStatements, tableFileSchema, tableReferenceSchema, typesInterfaceName, validateViewCatalogStatement, verifyRebaseIsNoop, walkPredicate, writeMigration };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,15 @@
1
- export { ActionInput, ActionParamInput, AuthoringContext, AuthoringRegistration, COLUMN_BRAND, COLUMN_DEFAULT_FNS, ColumnBuilder, ColumnDefaultFn, ColumnDefaultLiteral, ColumnTypeSpec, ENUM_BRAND, EnumRef, IndexInput, LINK_BRAND, LinkKind, LoadNamespaceOptions, LoadedNamespaceV2, NAMESPACE_CONFIG_BRAND, NAMESPACE_CONFIG_FILE, NamespaceCapabilitiesInput, NamespaceConfigInput, PolicyInput, PolicyVariantInput, PolicyWithVariantsInput, SCHEMA_DIR, SeqLink, SeqNamespaceConfig, SeqTable, SerializeNamespaceInput, SyncedTableConfig, TABLE_BRAND, TableConfig, TablePoliciesInput, TableRef, ToManyOptions, ToOneOptions, ToPlatformUserOptions, activeAuthoringContext, beginAuthoringContext, computeCanonicalHash, defineEnum, defineNamespace, defineSyncedTable, defineTable, deriveColumnName, endAuthoringContext, isColumnBuilder, isEnumRef, isSeqLink, isSeqNamespaceConfig, isSeqTable, loadNamespaceFromDir, serializeNamespace, t, toMany, toOne, toPlatformUser } from './authoring.js';
1
+ export { AuthoringContext, AuthoringRegistration, COLUMN_BRAND, COLUMN_DEFAULT_FNS, ColumnBuilder, ColumnDefaultFn, ColumnDefaultLiteral, ColumnTypeSpec, CowMutationInput, DrizzleRelation, ENUM_BRAND, EnumRef, IndexInput, LINK_BRAND, LinkKind, LoadNamespaceOptions, LoadedNamespaceV2, NAMESPACE_CONFIG_BRAND, NAMESPACE_CONFIG_FILE, NamespaceCapabilitiesInput, NamespaceConfigInput, ORM_TO_PIPELINE_TYPE, OrmContractColumnMap, OrmContractPipelineColumn, OrmSyncedTableContract, OrmToPipelineType, OverlayTableRef, OverlayWinsUnionInput, OverrideRowMutationInput, PolicyInput, PolicyVariantInput, PolicyWithVariantsInput, RelationRef, RevertOverlayMutationInput, SCHEMA_DIR, SYNCED_CONTRACT_HASH_DOMAIN, SeqLink, SeqNamespaceConfig, SeqTable, SeqView, SerializeNamespaceInput, SyncedTableConfig, SyncedTablePoliciesInput, TABLE_BRAND, TableConfig, TablePoliciesInput, TableRef, ToManyOptions, ToOneOptions, ToPlatformUserOptions, TypedSyncedTableConfig, VIEW_BRAND, ViewConfig, ViewPoliciesInput, ViewQueryContext, ViewSelectQuery, activeAuthoringContext, beginAuthoringContext, computeCanonicalHash, computeSyncedContractHash, defineEnum, defineNamespace, defineSyncedTable, defineTable, defineView, deriveColumnName, endAuthoringContext, extractOrmSyncedTableContract, isColumnBuilder, isEnumRef, isSeqLink, isSeqNamespaceConfig, isSeqTable, isSeqView, loadNamespaceFromDir, overlayWinsUnion, overrideRowMutation, revertOverlayMutation, serializeNamespace, syncedContractSurface, t, toMany, toOne, toPlatformUser } from './authoring.js';
2
2
  import { CanonicalDefinition } from './canonical.js';
3
- export { CANONICAL_FORMAT, CanonicalColumn, CanonicalEnum, CanonicalLink, CanonicalTable, IDENTIFIER_RE, PolicyExpression, canonicalActionSchema, canonicalColumnSchema, canonicalDefinitionSchema, canonicalEnumSchema, canonicalIndexSchema, canonicalLinkSchema, canonicalPoliciesSchema, canonicalTableSchema, normalizeCanonical, policyExpressionSchema, policyVariantSchema } from './canonical.js';
3
+ export { CANONICAL_FORMAT, CanonicalColumn, CanonicalEnum, CanonicalLink, CanonicalTable, CanonicalView, IDENTIFIER_RE, PolicyExpression, canonicalActionSchema, canonicalColumnSchema, canonicalDefinitionSchema, canonicalEnumSchema, canonicalIndexSchema, canonicalLinkSchema, canonicalPoliciesSchema, canonicalRelations, canonicalTableSchema, canonicalViewSchema, normalizeCanonical, policyExpressionSchema, policyVariantSchema } from './canonical.js';
4
4
  import { CustomRolesBlock } from '@sequenceholdings/custom-roles-manifest';
5
5
  export { CustomRolesBlock, capabilityPinsSchema, customRolesBlockSchema, customRolesDeclared, parseCapabilityPin, validateCapabilityPins } from '@sequenceholdings/custom-roles-manifest';
6
6
  import { z } from 'zod';
7
+ import { PredIr } from './ir.js';
8
+ export { CLAIMS_CONTRACT, CMP_OPS, ClaimKey, CmpOp, CompiledArtifact, CompiledOperation, INPUT_REF_KINDS, IR_VERSION, InputRefKind, IrVersionError, LimitIr, OrderIr, RootIr, SelectionIr, TableMetaIr, ValueIr, VariableDefaultIr, VariableIr, compiledArtifactSchema, compiledOperationSchema, indexByHash, limitIrSchema, normalizeIr, orderIrSchema, predIrSchema, rootIrSchema, selectionIrSchema, tableMetaIrSchema, valueIrSchema, variableDefaultIrSchema, variableIrSchema } from './ir.js';
7
9
  import { generateDrizzleJson } from 'drizzle-kit/api';
8
10
  import { PgTableWithColumns } from 'drizzle-orm/pg-core';
9
- export { CLAIMS_CONTRACT, CMP_OPS, ClaimKey, CmpOp, CompiledArtifact, CompiledOperation, INPUT_REF_KINDS, IR_VERSION, InputRefKind, IrVersionError, LimitIr, OrderIr, PredIr, RootIr, SelectionIr, TableMetaIr, ValueIr, VariableDefaultIr, VariableIr, compiledArtifactSchema, compiledOperationSchema, indexByHash, limitIrSchema, normalizeIr, orderIrSchema, predIrSchema, rootIrSchema, selectionIrSchema, tableMetaIrSchema, valueIrSchema, variableDefaultIrSchema, variableIrSchema } from './ir.js';
11
+ import 'drizzle-orm';
12
+ import 'drizzle-orm/query-builders/query-builder';
10
13
 
11
14
  /**
12
15
  * The reserved `namespace.yaml` — namespace-level settings beside the table
@@ -99,8 +102,8 @@ declare const actionSchema: z.ZodObject<{
99
102
  }>>>;
100
103
  audit: z.ZodOptional<z.ZodObject<{
101
104
  action: z.ZodEnum<{
102
- create: "create";
103
105
  update: "update";
106
+ create: "create";
104
107
  delete: "delete";
105
108
  }>;
106
109
  resource: z.ZodOptional<z.ZodString>;
@@ -246,6 +249,8 @@ declare const tableFileSchema: z.ZodObject<{
246
249
  policies: z.ZodOptional<z.ZodObject<{
247
250
  read: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<ParsedPredicate, string>>>;
248
251
  write: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<ParsedPredicate, string>>>;
252
+ insert: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<ParsedPredicate, string>>>;
253
+ update: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<ParsedPredicate, string>>>;
249
254
  }, z.core.$strict>>;
250
255
  actions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
251
256
  description: z.ZodOptional<z.ZodString>;
@@ -282,8 +287,8 @@ declare const tableFileSchema: z.ZodObject<{
282
287
  }>>>;
283
288
  audit: z.ZodOptional<z.ZodObject<{
284
289
  action: z.ZodEnum<{
285
- create: "create";
286
290
  update: "update";
291
+ create: "create";
287
292
  delete: "delete";
288
293
  }>;
289
294
  resource: z.ZodOptional<z.ZodString>;
@@ -347,6 +352,24 @@ declare function compileActionStatements(action: ActionDefinition, renderParam?:
347
352
  /** Compiled `requires` gate — a SQL boolean over the transaction claims, or null when unguarded. */
348
353
  declare function compileActionRequires(action: ActionDefinition): string | null;
349
354
 
355
+ /** Canonical column types can be enums — v1 `PredicateColumnTypes` cannot carry them. */
356
+ type SyncedColumnType = ColumnType | {
357
+ readonly enum: string;
358
+ };
359
+ type SyncedPredicateColumnTypes = Readonly<Record<string, SyncedColumnType>>;
360
+ interface CompilePredIrToSqlOptions {
361
+ /** Column name → declared type, for claim casts in comparisons. */
362
+ readonly columnTypes?: SyncedPredicateColumnTypes;
363
+ /** Logical column name → physical column name for the synced backing. */
364
+ readonly columnNames?: Readonly<Record<string, string>>;
365
+ }
366
+ /**
367
+ * PredIr → a static SQL boolean for synced-view WHERE clauses. Capability and
368
+ * role leaves stay as runtime claim checks (mirroring table RLS), unlike the
369
+ * data-plane executor which pre-resolves them per caller.
370
+ */
371
+ declare function compilePredIrToSql(pred: PredIr, options?: CompilePredIrToSqlOptions): string;
372
+
350
373
  declare const COMPARE_OPS: readonly ["=", "!=", "<", "<=", ">", ">="];
351
374
  type CompareOp = (typeof COMPARE_OPS)[number];
352
375
  type Operand = {
@@ -395,11 +418,15 @@ declare function compilePredicate(predicate: Predicate, columnTypes?: PredicateC
395
418
  declare const CLAIMS_SETTING = "request.jwt.claims";
396
419
  /** Claims JSON key holding the caller's granted capability pins (a string array). */
397
420
  declare const CAPABILITIES_CLAIM_KEY = "capabilities";
421
+ /** Claims JSON key holding the caller's granted custom roles (a string array). */
422
+ declare const ROLES_CLAIM_KEY = "roles";
398
423
  declare const quoteIdentifier: (name: string) => string;
399
424
  declare const quoteLiteral: (value: string) => string;
400
425
  declare const claimExpression: (key: string) => string;
401
426
  /** NULL claims (or a missing capabilities array) coalesce to false — capability checks fail closed. */
402
427
  declare const capabilityExpression: (key: string) => string;
428
+ /** NULL claims (or a missing roles array) coalesce to false — role checks fail closed. */
429
+ declare const roleExpression: (key: string) => string;
403
430
 
404
431
  /** Namespace names become Postgres identifiers (`orm_<ns>` schema, `orm_<ns>_consumer` role) — the tight grammar is a security control, not cosmetics. */
405
432
  declare const NAMESPACE_PATTERN: RegExp;
@@ -494,6 +521,7 @@ declare function applyMigrationHints(previous: NamespaceSnapshot, definition: Na
494
521
  * pending statement and lets a non-converged schema pass.
495
522
  */
496
523
  declare function isOwnedStatement(statement: string): boolean;
524
+ declare function isOwnedStatementV2(statement: string): boolean;
497
525
  /**
498
526
  * The kit-owned statements a live database would still need to match the
499
527
  * definition — drizzle-kit's `pushSchema` introspection diffed against the
@@ -506,6 +534,12 @@ declare function pendingKitStatements({ definition, db, }: {
506
534
  /** A drizzle PgDatabase over the target — typed loose because pushSchema's own parameter is `PgDatabase<any>`. */
507
535
  db: unknown;
508
536
  }): Promise<string[]>;
537
+ /** V2 convergence includes managed regular views in drizzle-kit's verdict. */
538
+ declare function pendingKitStatementsV2({ canonical, db, }: {
539
+ canonical: CanonicalDefinition;
540
+ /** A drizzle PgDatabase over the target — typed loose because pushSchema's own parameter is `PgDatabase<any>`. */
541
+ db: unknown;
542
+ }): Promise<string[]>;
509
543
 
510
544
  interface DrizzleEntities {
511
545
  /** The in-memory schema bag drizzle-kit snapshots (`generateDrizzleJson(imports)`). */
@@ -569,10 +603,68 @@ declare function actionPrepareChecks(definition: NamespaceDefinition): string[];
569
603
  * write-capable callers SELECT rows the read policy hides.
570
604
  */
571
605
  declare function securityStatements(definition: NamespaceDefinition): string[];
606
+ declare const syncedTables: (definition: NamespaceDefinition) => TableFile[];
607
+ /**
608
+ * A resolved synced-table backing: the physical Lakebase relation name
609
+ * (captured at provision, never derived) plus optional projection column
610
+ * types for claim-cast compilation.
611
+ */
612
+ interface SyncedBacking {
613
+ readonly table: string;
614
+ /** Physical Lakebase relation (e.g. `synced_loans` or `df_retail_customers`). */
615
+ readonly physicalRelation: string;
616
+ /** Column name → ORM column type, for claim casts in the view's WHERE. */
617
+ readonly columnTypes?: PredicateColumnTypes;
618
+ }
619
+ /**
620
+ * Emit CREATE OR REPLACE VIEW + SELECT-only grants for synced tables that have
621
+ * a registered backing. Synced tables cannot use table-level RLS (they may be
622
+ * foreign tables), so claims filtering compiles into the view's WHERE clause.
623
+ *
624
+ * Each view lives in `orm_<ns>` alongside regular tables, named identically to
625
+ * the synced table definition so read routing is transparent.
626
+ */
627
+ /**
628
+ * Atlas reassigns every relation in `orm_<ns>` to this role after apply.
629
+ * Synced views resolve backing access as their owner, so the emitter must
630
+ * grant this role narrow SELECT on each physical relation before CREATE VIEW.
631
+ */
632
+ declare const SYNCED_VIEW_EXECUTION_OWNER_ROLE = "orm_exec";
633
+ declare function syncedViewStatements({ definition, backings, readPolicyIrByTable, columnNamesByTable, columnTypesByTable, executionOwnerRole, }: {
634
+ definition: NamespaceDefinition;
635
+ backings: readonly SyncedBacking[];
636
+ /** v2 compiled read policies (preserves capability/role variants). */
637
+ readPolicyIrByTable?: ReadonlyMap<string, PredIr>;
638
+ /** Logical column name → physical backing column name per synced table. */
639
+ columnNamesByTable?: ReadonlyMap<string, Readonly<Record<string, string>>>;
640
+ /**
641
+ * Canonical declared types per synced table (keyed by logical AND physical
642
+ * name). Carries what the TableFile adapter cannot — enum types — so IN/NIN
643
+ * policies never silently downgrade an enum comparison to text[]-vs-enum.
644
+ */
645
+ columnTypesByTable?: ReadonlyMap<string, SyncedPredicateColumnTypes>;
646
+ /** Role that will own the view after ensureExecutionOwner (default orm_exec). */
647
+ executionOwnerRole?: string;
648
+ }): string[];
649
+ /**
650
+ * Drop synced views — idempotent cleanup for apply retries and removal.
651
+ */
652
+ declare function syncedViewDropStatements({ schemaName, tables, }: {
653
+ schemaName: string;
654
+ tables: readonly string[];
655
+ }): string[];
656
+ /**
657
+ * Revoke orm_exec backing privileges for physical relations that are no longer
658
+ * active for this namespace (removed / renamed / rebound away).
659
+ */
660
+ declare function syncedBackingRevokeStatements({ backings, executionOwnerRole, }: {
661
+ backings: readonly SyncedBacking[];
662
+ executionOwnerRole?: string;
663
+ }): string[];
572
664
 
573
665
  declare const sqlTypeName: (type: ColumnType) => string;
574
666
 
575
- declare const STATEMENT_KINDS: readonly ["hint", "ddl", "security", "function"];
667
+ declare const STATEMENT_KINDS: readonly ["hint", "ddl", "security", "function", "synced_view"];
576
668
  type StatementKind = (typeof STATEMENT_KINDS)[number];
577
669
  interface CompiledStatement {
578
670
  readonly kind: StatementKind;
@@ -605,6 +697,13 @@ declare const compileNamespace: (definition: NamespaceDefinition) => Promise<Pla
605
697
  * table handles — the same `DrizzleEntities` shape engine/snapshot.ts consumes.
606
698
  */
607
699
  declare function buildDrizzleEntitiesV2(definition: CanonicalDefinition): DrizzleEntities;
700
+ declare function rewriteSyncedSourceRelationsInViewQuery({ query, canonical, schemaName, dependencies, }: {
701
+ query: string;
702
+ canonical: CanonicalDefinition;
703
+ schemaName: string;
704
+ /** The view's declared logical dependencies — disambiguates shared sources. */
705
+ dependencies?: readonly string[];
706
+ }): string;
608
707
  /** drizzle-kit snapshot for a canonical definition — the v2 twin of engine/snapshot.ts generateSnapshot. */
609
708
  declare function generateSnapshotV2(definition: CanonicalDefinition, previousId?: string): NamespaceSnapshot;
610
709
  /**
@@ -635,6 +734,21 @@ declare function planMigrationV2({ canonical, previousSnapshot, }: {
635
734
  canonical: CanonicalDefinition;
636
735
  previousSnapshot?: NamespaceSnapshot;
637
736
  }): Promise<PlannedMigration>;
737
+ /**
738
+ * Drizzle's manual-view snapshot stores declared columns, but PostgreSQL names
739
+ * and types the live view from the SELECT itself. Assert the live catalog in
740
+ * the same transaction so a stale alias/type or an incomplete dependency
741
+ * declaration can never be persisted as a successful schema version.
742
+ */
743
+ /**
744
+ * Assert live view columns/types/dependencies match the canonical contract.
745
+ * Used by planMigrationV2 and by CASCADE recovery recreates (same transaction).
746
+ */
747
+ declare function validateViewCatalogStatement({ canonical, view, schema, }: {
748
+ canonical: CanonicalDefinition;
749
+ view: NonNullable<CanonicalDefinition['views']>[number];
750
+ schema: string;
751
+ }): string;
638
752
 
639
753
  declare class OrmDefinitionError extends Error {
640
754
  readonly file?: string | undefined;
@@ -815,8 +929,10 @@ declare function writeMigration({ dir, workspace, plan, contentHash, destructive
815
929
  * - the single v1 `primary_key: true` column becomes `primaryKey: [name]`;
816
930
  * - policy expressions carry over as their verbatim DSL source strings
817
931
  * (re-parsed by the v2 predicate compiler, never the parsed v1 AST);
818
- * - actions carry over verbatim (multi-statement `executes` lists join on
819
- * ';\n' — the boundaries stay recoverable for the compiled-op executor);
932
+ * - v1 actions are DROPPED, loudly: v2 has no action surface — writes are
933
+ * persisted mutations — and the v1→v2 apply sweep removes the `action_*`
934
+ * functions anyway. The emitter leaves a TODO listing each dropped action
935
+ * so it gets re-authored as a mutation (or a CoW `overrideRowMutation`);
820
936
  * - the capabilities block passes through untouched (verbatim custom-roles
821
937
  * grammar in both formats);
822
938
  * - qualified (cross-namespace) link targets have no v2 representation —
@@ -897,4 +1013,4 @@ declare function parseCanonicalDefinition(value: unknown): NamespaceDefinition;
897
1013
 
898
1014
  declare const parsedPredicateSchema: z.ZodPipe<z.ZodString, z.ZodTransform<ParsedPredicate, string>>;
899
1015
 
900
- export { ACTION_REQUIRES_DENIED_SQLSTATE, ACTION_VALIDATES_FAILED_SQLSTATE, AUDIT_ACTIONS, type ActionDefinition, CAPABILITIES_CLAIM_KEY, CAPABILITY_KEY_PATTERN, CLAIMS_SETTING, CLAIM_KEY_PATTERN, COLUMN_TYPES, COMPARE_OPS, CONSUMER_ROLE_SUFFIX, CanonicalDefinition, type ColumnDefault, type ColumnDefinition, type ColumnType, type CommittedChainEntry, type CommittedMigration, type CompareOp, type CompiledStatement, DEFINITION_FILE_EXTENSIONS, type DefinitionFile, type DefinitionSource, type DestructiveStatement, type DiffOptions, type DrizzleEntities, HASH_DOMAIN, IDENTIFIER_PATTERN, type IndexDefinition, type JournalEntry, type LinkDefinition, type LoadedNamespace, MAX_DEFINITION_FILE_BYTES, MAX_IDENTIFIER_LENGTH, MIGRATIONS_DIRNAME, type MigrationJournal, type MigrationWorkspace, NAMESPACE_CONFIG_FILENAMES, NAMESPACE_PATTERN, type NamespaceCapabilities, type NamespaceConfig, type NamespaceDefinition, type NamespaceSnapshot, ORM_DATA_TOKEN_HEADER, ORM_SCHEMA_PREFIX, ORM_SERVICE_DATA_TOKEN_HEADER, type Operand, OrmDefinitionError, type ParsedPredicate, type PlannedMigration, type Predicate, PredicateParseError, QUALIFIED_TABLE_PATTERN, RESERVED_COLUMN_NAMES, RESERVED_TABLE_NAMES, type RebaseEntry, type RebaseEntryInput, type RebaseNoopOptions, STATEMENT_KINDS, SYNCED_SOURCE_PATTERN, type StatementKind, type TableFile, type ValidatesEntry, type WrittenMigration, actionFunctionName, actionFunctionStatements, actionParamArg, actionParamOrder, actionParamSchema, actionPrepareChecks, actionSchema, actionWriteTargets, actionsInterfaceName, applyMigrationHints, applyMigrationHintsV2, buildActionParamsSchema, buildDrizzleEntities, buildDrizzleEntitiesV2, buildNamespaceDefinition, buildRebaseJournalEntry, canonicalizeDefinition, capabilityExpression, castParts, checksumOf, claimExpression, classifyDestructive, columnSchema, columnTypeSchema, compileActionRequires, compileActionStatements, compileNamespace, compilePredicate, computeDefinitionHash, consumerRoleName, convertV1DefinitionToCanonical, declaredCapabilityKeys, diffCommand, diffStatements, emptyJournal, emptySnapshot, extractNamedParams, generateNamespaceTypes, generateSnapshot, generateSnapshotV2, identifierSchema, isFunctionDefault, isOwnedStatement, isQualifiedReference, loadCommittedMigrations, loadCommittedTipMigration, loadNamespaceDefinition, migrationName, namespaceConfigSchema, namespaceSchema, normalizeSnapshot, ormSchemaName, parseCanonicalDefinition, parseDefinitionSources, parsePredicate, parseTableFile, parsedPredicateSchema, pendingKitStatements, planMigration, planMigrationV2, predicateOperands, quoteIdentifier, quoteLiteral, readMigrationSql, readMigrationWorkspace, readSnapshot, rebaseViolations, referencedCapabilities, referencedColumns, renderMigrationSql, securityStatements, sqlTypeName, stableJson, tableFileSchema, tableReferenceSchema, typesInterfaceName, verifyRebaseIsNoop, walkPredicate, writeMigration };
1016
+ export { ACTION_REQUIRES_DENIED_SQLSTATE, ACTION_VALIDATES_FAILED_SQLSTATE, AUDIT_ACTIONS, type ActionDefinition, CAPABILITIES_CLAIM_KEY, CAPABILITY_KEY_PATTERN, CLAIMS_SETTING, CLAIM_KEY_PATTERN, COLUMN_TYPES, COMPARE_OPS, CONSUMER_ROLE_SUFFIX, CanonicalDefinition, type ColumnDefault, type ColumnDefinition, type ColumnType, type CommittedChainEntry, type CommittedMigration, type CompareOp, type CompilePredIrToSqlOptions, type CompiledStatement, DEFINITION_FILE_EXTENSIONS, type DefinitionFile, type DefinitionSource, type DestructiveStatement, type DiffOptions, type DrizzleEntities, HASH_DOMAIN, IDENTIFIER_PATTERN, type IndexDefinition, type JournalEntry, type LinkDefinition, type LoadedNamespace, MAX_DEFINITION_FILE_BYTES, MAX_IDENTIFIER_LENGTH, MIGRATIONS_DIRNAME, type MigrationJournal, type MigrationWorkspace, NAMESPACE_CONFIG_FILENAMES, NAMESPACE_PATTERN, type NamespaceCapabilities, type NamespaceConfig, type NamespaceDefinition, type NamespaceSnapshot, ORM_DATA_TOKEN_HEADER, ORM_SCHEMA_PREFIX, ORM_SERVICE_DATA_TOKEN_HEADER, type Operand, OrmDefinitionError, type ParsedPredicate, type PlannedMigration, PredIr, type Predicate, type PredicateColumnTypes, PredicateParseError, QUALIFIED_TABLE_PATTERN, RESERVED_COLUMN_NAMES, RESERVED_TABLE_NAMES, ROLES_CLAIM_KEY, type RebaseEntry, type RebaseEntryInput, type RebaseNoopOptions, STATEMENT_KINDS, SYNCED_SOURCE_PATTERN, SYNCED_VIEW_EXECUTION_OWNER_ROLE, type StatementKind, type SyncedBacking, type SyncedColumnType, type SyncedPredicateColumnTypes, type TableFile, type ValidatesEntry, type WrittenMigration, actionFunctionName, actionFunctionStatements, actionParamArg, actionParamOrder, actionParamSchema, actionPrepareChecks, actionSchema, actionWriteTargets, actionsInterfaceName, applyMigrationHints, applyMigrationHintsV2, buildActionParamsSchema, buildDrizzleEntities, buildDrizzleEntitiesV2, buildNamespaceDefinition, buildRebaseJournalEntry, canonicalizeDefinition, capabilityExpression, castParts, checksumOf, claimExpression, classifyDestructive, columnSchema, columnTypeSchema, compileActionRequires, compileActionStatements, compileNamespace, compilePredIrToSql, compilePredicate, computeDefinitionHash, consumerRoleName, convertV1DefinitionToCanonical, declaredCapabilityKeys, diffCommand, diffStatements, emptyJournal, emptySnapshot, extractNamedParams, generateNamespaceTypes, generateSnapshot, generateSnapshotV2, identifierSchema, isFunctionDefault, isOwnedStatement, isOwnedStatementV2, isQualifiedReference, loadCommittedMigrations, loadCommittedTipMigration, loadNamespaceDefinition, migrationName, namespaceConfigSchema, namespaceSchema, normalizeSnapshot, ormSchemaName, parseCanonicalDefinition, parseDefinitionSources, parsePredicate, parseTableFile, parsedPredicateSchema, pendingKitStatements, pendingKitStatementsV2, planMigration, planMigrationV2, predicateOperands, quoteIdentifier, quoteLiteral, readMigrationSql, readMigrationWorkspace, readSnapshot, rebaseViolations, referencedCapabilities, referencedColumns, renderMigrationSql, rewriteSyncedSourceRelationsInViewQuery, roleExpression, securityStatements, sqlTypeName, stableJson, syncedBackingRevokeStatements, syncedTables, syncedViewDropStatements, syncedViewStatements, tableFileSchema, tableReferenceSchema, typesInterfaceName, validateViewCatalogStatement, verifyRebaseIsNoop, walkPredicate, writeMigration };