@sequenceholdings/orm 2.1.0 → 2.1.1

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 (69) hide show
  1. package/README.md +38 -1
  2. package/dist/authoring.cjs +1358 -45
  3. package/dist/authoring.cjs.map +1 -1
  4. package/dist/authoring.d.cts +223 -2
  5. package/dist/authoring.d.ts +223 -2
  6. package/dist/authoring.js +1349 -47
  7. package/dist/authoring.js.map +1 -1
  8. package/dist/canonical.cjs +662 -38
  9. package/dist/canonical.cjs.map +1 -1
  10. package/dist/canonical.d.cts +696 -53
  11. package/dist/canonical.d.ts +696 -53
  12. package/dist/canonical.js +647 -39
  13. package/dist/canonical.js.map +1 -1
  14. package/dist/cli.cjs +1808 -247
  15. package/dist/cli.cjs.map +1 -1
  16. package/dist/cli.js +1809 -248
  17. package/dist/cli.js.map +1 -1
  18. package/dist/client.cjs +90 -25
  19. package/dist/client.cjs.map +1 -1
  20. package/dist/client.d.cts +39 -22
  21. package/dist/client.d.ts +39 -22
  22. package/dist/client.js +87 -26
  23. package/dist/client.js.map +1 -1
  24. package/dist/compiler.cjs +1325 -285
  25. package/dist/compiler.cjs.map +1 -1
  26. package/dist/compiler.d.cts +23 -2
  27. package/dist/compiler.d.ts +23 -2
  28. package/dist/compiler.js +1325 -285
  29. package/dist/compiler.js.map +1 -1
  30. package/dist/constants-YoFGjIBM.d.cts +99 -0
  31. package/dist/constants-YoFGjIBM.d.ts +99 -0
  32. package/dist/dynamic-input.d.cts +1 -0
  33. package/dist/dynamic-input.d.ts +1 -0
  34. package/dist/index.cjs +1605 -140
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +230 -113
  37. package/dist/index.d.ts +230 -113
  38. package/dist/index.js +1583 -142
  39. package/dist/index.js.map +1 -1
  40. package/dist/ir.cjs +727 -38
  41. package/dist/ir.cjs.map +1 -1
  42. package/dist/ir.d.cts +539 -21
  43. package/dist/ir.d.ts +539 -21
  44. package/dist/ir.js +722 -39
  45. package/dist/ir.js.map +1 -1
  46. package/dist/{naming-DCn94LJ4.d.ts → naming-CPfx7EfF.d.ts} +14 -1
  47. package/dist/{naming-DPglwzkB.d.cts → naming-CU9ThP_E.d.cts} +14 -1
  48. package/dist/policy-1iZbGnZZ.d.cts +24 -0
  49. package/dist/policy-1iZbGnZZ.d.ts +24 -0
  50. package/dist/predicate-v2.cjs +726 -42
  51. package/dist/predicate-v2.cjs.map +1 -1
  52. package/dist/predicate-v2.d.cts +2 -1
  53. package/dist/predicate-v2.d.ts +2 -1
  54. package/dist/predicate-v2.js +726 -42
  55. package/dist/predicate-v2.js.map +1 -1
  56. package/dist/sdl.cjs +858 -54
  57. package/dist/sdl.cjs.map +1 -1
  58. package/dist/sdl.d.cts +7 -3
  59. package/dist/sdl.d.ts +7 -3
  60. package/dist/sdl.js +856 -55
  61. package/dist/sdl.js.map +1 -1
  62. package/package.json +9 -4
  63. package/templates/orm-namespace/CLAUDE.md +6 -4
  64. package/templates/orm-namespace/codegen.preset.d.cts +7 -0
  65. package/templates/orm-namespace/codegen.ts +2 -1
  66. package/templates/orm-namespace/graphql/example/queries.ts +4 -3
  67. package/templates/orm-namespace/package.json +2 -1
  68. package/templates/orm-namespace/schema/tables.ts +3 -2
  69. package/templates/orm-namespace/sequence.config.ts +7 -11
package/dist/index.d.ts CHANGED
@@ -1,13 +1,15 @@
1
- export { AuthoringContext, AuthoringRegistration, COLUMN_BRAND, COLUMN_DEFAULT_FNS, ColumnBuilder, ColumnDefaultFn, ColumnDefaultLiteral, ColumnTypeSpec, CowMutationInput, DrizzleRelation, ENUM_BRAND, EnumRef, ForeignKeyInput, 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';
1
+ export { AuthoringContext, AuthoringRegistration, COLUMN_BRAND, COLUMN_DEFAULT_FNS, CheckInput, ColumnBuilder, ColumnDefaultFn, ColumnDefaultLiteral, ColumnTypeSpec, Comparator, CowMutationInput, DrizzleRelation, DurationInput, ENUM_BRAND, EnumRef, EtlSourceInput, ForeignKeyInput, FunctionRef, IndexInput, LINK_BRAND, LinkKind, LoadNamespaceOptions, LoadedNamespaceV2, ManualSourceInput, NAMESPACE_CONFIG_BRAND, NAMESPACE_CONFIG_FILE, NamespaceCapabilitiesInput, NamespaceConfigInput, ORM_TO_PIPELINE_TYPE, OrmContractColumnMap, OrmContractPipelineColumn, OrmSyncedTableContract, OrmToPipelineType, OverlayTableRef, OverlayWinsUnionInput, OverrideRowMutationInput, PolicyInput, PolicyVariantInput, PolicyWithVariantsInput, PrefetchSourceInput, ReferentialAction, RelationRef, ResolvedSourceInput, ResolvedTableConfig, ResolvedTablePoliciesInput, 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, custom, defineEnum, defineNamespace, defineResolvedTable, defineSyncedTable, defineTable, defineView, deriveColumnName, endAuthoringContext, etlSource, extractOrmSyncedTableContract, highest, isColumnBuilder, isEnumRef, isSeqLink, isSeqNamespaceConfig, isSeqTable, isSeqView, latest, loadNamespaceFromDir, lowest, managedFn, manualSource, nonNullFirst, overlayWinsUnion, overrideRowMutation, prefetchSource, priority, 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, CanonicalView, IDENTIFIER_RE, PolicyExpression, canonicalActionSchema, canonicalColumnSchema, canonicalDefinitionSchema, canonicalEnumSchema, canonicalIndexSchema, canonicalLinkSchema, canonicalPoliciesSchema, canonicalRelations, canonicalTableSchema, canonicalViewSchema, normalizeCanonical, policyExpressionSchema, policyVariantSchema } from './canonical.js';
3
+ export { CANONICAL_FORMAT, CanonicalColumn, CanonicalEnum, CanonicalLink, CanonicalTable, CanonicalView, IDENTIFIER_RE, canonicalActionSchema, canonicalColumnSchema, canonicalDefinitionSchema, canonicalEnumSchema, canonicalIndexSchema, canonicalLinkSchema, canonicalPoliciesSchema, canonicalRelations, canonicalTableSchema, canonicalViewSchema, normalizeCanonical } 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
7
  import { PredIr } from './ir.js';
8
- export { CLAIMS_CONTRACT, CMP_OPS, ClaimKey, CmpOp, CompiledArtifact, CompiledOperation, DATE_BUCKETS, DateBucket, GroupByKeyIr, INPUT_REF_KINDS, IR_VERSION, InputRefKind, IrVersionError, LEGACY_IR_VERSION, LimitIr, OrderIr, RootIr, SelectionIr, TableMetaIr, ValueIr, VariableDefaultIr, VariableIr, compiledArtifactSchema, compiledOperationSchema, indexByHash, limitIrSchema, normalizeIr, orderIrSchema, predIrSchema, requiredArtifactIrVersion, rootIrSchema, selectionIrSchema, tableMetaIrSchema, valueIrSchema, variableDefaultIrSchema, variableIrSchema } from './ir.js';
8
+ export { CLAIMS_CONTRACT, CMP_OPS, CellSelectionIr, ClaimKey, CmpOp, CompiledArtifact, CompiledOperation, DATE_BUCKETS, DateBucket, GroupByKeyIr, INPUT_REF_KINDS, IR_VERSION, InputRefKind, IrVersionError, LEGACY_IR_VERSION, LimitIr, OrderIr, PrefetchPlanIr, ResolvedMetaIr, ResolvedSourceIr, RootIr, SelectionIr, TableMetaIr, ValueIr, VariableDefaultIr, VariableIr, compiledArtifactSchema, compiledOperationSchema, indexByHash, limitIrSchema, normalizeIr, orderIrSchema, predIrSchema, prefetchPlanIrSchema, requiredArtifactIrVersion, resolvedMetaIrSchema, resolvedSourceIrSchema, rootIrSchema, selectionIrSchema, tableMetaIrSchema, valueIrSchema, variableDefaultIrSchema, variableIrSchema } from './ir.js';
9
+ export { e as CAPABILITY_KEY_PATTERN, C as CELLS_FIELD, a as CELL_PARTS, f as CELL_PART_SUFFIX, g as CLAIM_KEY_PATTERN, h as COLUMN_IDENTIFIER_PATTERN, i as CONSUMER_ROLE_SUFFIX, b as CellPart, D as DEFINITION_FILE_EXTENSIONS, H as HASH_DOMAIN, I as IDENTIFIER_PATTERN, M as MATERIALIZE_ACTOR, j as MATERIALIZE_CLAIMS_JSON, k as MAX_DEFINITION_FILE_BYTES, l as MAX_GENERATED_SDL_BYTES, m as MAX_IDENTIFIER_LENGTH, n as MAX_TRACKED_COLUMN_NAME, o as NAMESPACE_CONFIG_FILENAMES, N as NAMESPACE_PATTERN, O as ORM_DATA_TOKEN_HEADER, p as ORM_REGISTRATION_MAX_BYTES, q as ORM_SCHEMA_PREFIX, d as ORM_SERVICE_DATA_TOKEN_HEADER, Q as QUALIFIED_TABLE_PATTERN, R as RESERVED_COLUMN_NAMES, r as RESERVED_TABLE_NAMES, S as SYNCED_SOURCE_PATTERN, c as cellColumnName, s as consumerRoleName, t as materializeLockKey, u as materializedRefreshFunctionName, v as ormSchemaName } from './constants-YoFGjIBM.js';
9
10
  import { generateDrizzleJson } from 'drizzle-kit/api';
10
11
  import { PgTableWithColumns } from 'drizzle-orm/pg-core';
12
+ export { P as PolicyExpression, p as policyExpressionSchema, a as policyVariantSchema } from './policy-1iZbGnZZ.js';
11
13
  import 'drizzle-orm';
12
14
  import 'drizzle-orm/query-builders/query-builder';
13
15
 
@@ -49,14 +51,14 @@ declare const actionParamSchema: z.ZodObject<{
49
51
  type: z.ZodEnum<{
50
52
  bigint: "bigint";
51
53
  boolean: "boolean";
52
- uuid: "uuid";
53
54
  text: "text";
55
+ date: "date";
56
+ timestamptz: "timestamptz";
57
+ jsonb: "jsonb";
58
+ uuid: "uuid";
54
59
  integer: "integer";
55
60
  numeric: "numeric";
56
61
  double: "double";
57
- timestamptz: "timestamptz";
58
- date: "date";
59
- jsonb: "jsonb";
60
62
  }>;
61
63
  optional: z.ZodOptional<z.ZodBoolean>;
62
64
  description: z.ZodOptional<z.ZodString>;
@@ -74,14 +76,14 @@ declare const actionSchema: z.ZodObject<{
74
76
  type: z.ZodEnum<{
75
77
  bigint: "bigint";
76
78
  boolean: "boolean";
77
- uuid: "uuid";
78
79
  text: "text";
80
+ date: "date";
81
+ timestamptz: "timestamptz";
82
+ jsonb: "jsonb";
83
+ uuid: "uuid";
79
84
  integer: "integer";
80
85
  numeric: "numeric";
81
86
  double: "double";
82
- timestamptz: "timestamptz";
83
- date: "date";
84
- jsonb: "jsonb";
85
87
  }>;
86
88
  optional: z.ZodOptional<z.ZodBoolean>;
87
89
  description: z.ZodOptional<z.ZodString>;
@@ -91,14 +93,14 @@ declare const actionSchema: z.ZodObject<{
91
93
  returns: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
92
94
  bigint: "bigint";
93
95
  boolean: "boolean";
94
- uuid: "uuid";
95
96
  text: "text";
97
+ date: "date";
98
+ timestamptz: "timestamptz";
99
+ jsonb: "jsonb";
100
+ uuid: "uuid";
96
101
  integer: "integer";
97
102
  numeric: "numeric";
98
103
  double: "double";
99
- timestamptz: "timestamptz";
100
- date: "date";
101
- jsonb: "jsonb";
102
104
  }>>>;
103
105
  audit: z.ZodOptional<z.ZodObject<{
104
106
  action: z.ZodEnum<{
@@ -126,14 +128,14 @@ type ColumnType = (typeof COLUMN_TYPES)[number];
126
128
  declare const columnTypeSchema: z.ZodEnum<{
127
129
  bigint: "bigint";
128
130
  boolean: "boolean";
129
- uuid: "uuid";
130
131
  text: "text";
132
+ date: "date";
133
+ timestamptz: "timestamptz";
134
+ jsonb: "jsonb";
135
+ uuid: "uuid";
131
136
  integer: "integer";
132
137
  numeric: "numeric";
133
138
  double: "double";
134
- timestamptz: "timestamptz";
135
- date: "date";
136
- jsonb: "jsonb";
137
139
  }>;
138
140
  /**
139
141
  * True when the default is one of the allowlisted SQL function calls for its
@@ -158,14 +160,14 @@ declare const columnSchema: z.ZodObject<{
158
160
  type: z.ZodEnum<{
159
161
  bigint: "bigint";
160
162
  boolean: "boolean";
161
- uuid: "uuid";
162
163
  text: "text";
164
+ date: "date";
165
+ timestamptz: "timestamptz";
166
+ jsonb: "jsonb";
167
+ uuid: "uuid";
163
168
  integer: "integer";
164
169
  numeric: "numeric";
165
170
  double: "double";
166
- timestamptz: "timestamptz";
167
- date: "date";
168
- jsonb: "jsonb";
169
171
  }>;
170
172
  primary_key: z.ZodOptional<z.ZodBoolean>;
171
173
  nullable: z.ZodOptional<z.ZodBoolean>;
@@ -208,14 +210,14 @@ declare const tableFileSchema: z.ZodObject<{
208
210
  type: z.ZodEnum<{
209
211
  bigint: "bigint";
210
212
  boolean: "boolean";
211
- uuid: "uuid";
212
213
  text: "text";
214
+ date: "date";
215
+ timestamptz: "timestamptz";
216
+ jsonb: "jsonb";
217
+ uuid: "uuid";
213
218
  integer: "integer";
214
219
  numeric: "numeric";
215
220
  double: "double";
216
- timestamptz: "timestamptz";
217
- date: "date";
218
- jsonb: "jsonb";
219
221
  }>;
220
222
  primary_key: z.ZodOptional<z.ZodBoolean>;
221
223
  nullable: z.ZodOptional<z.ZodBoolean>;
@@ -259,14 +261,14 @@ declare const tableFileSchema: z.ZodObject<{
259
261
  type: z.ZodEnum<{
260
262
  bigint: "bigint";
261
263
  boolean: "boolean";
262
- uuid: "uuid";
263
264
  text: "text";
265
+ date: "date";
266
+ timestamptz: "timestamptz";
267
+ jsonb: "jsonb";
268
+ uuid: "uuid";
264
269
  integer: "integer";
265
270
  numeric: "numeric";
266
271
  double: "double";
267
- timestamptz: "timestamptz";
268
- date: "date";
269
- jsonb: "jsonb";
270
272
  }>;
271
273
  optional: z.ZodOptional<z.ZodBoolean>;
272
274
  description: z.ZodOptional<z.ZodString>;
@@ -276,14 +278,14 @@ declare const tableFileSchema: z.ZodObject<{
276
278
  returns: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
277
279
  bigint: "bigint";
278
280
  boolean: "boolean";
279
- uuid: "uuid";
280
281
  text: "text";
282
+ date: "date";
283
+ timestamptz: "timestamptz";
284
+ jsonb: "jsonb";
285
+ uuid: "uuid";
281
286
  integer: "integer";
282
287
  numeric: "numeric";
283
288
  double: "double";
284
- timestamptz: "timestamptz";
285
- date: "date";
286
- jsonb: "jsonb";
287
289
  }>>>;
288
290
  audit: z.ZodOptional<z.ZodObject<{
289
291
  action: z.ZodEnum<{
@@ -428,70 +430,6 @@ declare const capabilityExpression: (key: string) => string;
428
430
  /** NULL claims (or a missing roles array) coalesce to false — role checks fail closed. */
429
431
  declare const roleExpression: (key: string) => string;
430
432
 
431
- /** Namespace names become Postgres identifiers (`orm_<ns>` schema, `orm_<ns>_consumer` role) — the tight grammar is a security control, not cosmetics. */
432
- declare const NAMESPACE_PATTERN: RegExp;
433
- declare const IDENTIFIER_PATTERN: RegExp;
434
- /** Native source columns may have one leading underscore; relation names may not. */
435
- declare const COLUMN_IDENTIFIER_PATTERN: RegExp;
436
- declare const MAX_IDENTIFIER_LENGTH = 63;
437
- /**
438
- * The Data API carries a delegated, attenuated data token on this header (not
439
- * `Authorization`, which stays the app-user/session bearer). One definition
440
- * shared by the client transport, the server's caller resolver, and the
441
- * function-invoke minter, so all three agree.
442
- */
443
- declare const ORM_DATA_TOKEN_HEADER = "x-sequence-data-token";
444
- /**
445
- * The SEPARATE header the invoke proxy uses to hand a managed function its
446
- * *service* data token — the escalation path. A function receives BOTH this and
447
- * `ORM_DATA_TOKEN_HEADER`; the default `createOrmClient` reads the user token,
448
- * the deliberately-named `createServiceOrmClient` reads THIS one. Two distinct
449
- * headers so reaching for the service identity is always an explicit act, never
450
- * an accidental default. Both are sent to the Data API on `ORM_DATA_TOKEN_HEADER`
451
- * — the server stays mode-agnostic and resolves whatever sub the token carries.
452
- */
453
- declare const ORM_SERVICE_DATA_TOKEN_HEADER = "x-sequence-data-token-service";
454
- /**
455
- * Custom Roles & Capabilities claim keys as policies reference them: a
456
- * host-scoped registry key, or an org pin's `org/<key>`. Matches the registry
457
- * key grammar EXACTLY (`[a-z0-9-]`, 1–64 chars, no `_` — the FGA object-id
458
- * delimiter) so any capability that's declarable/attachable in namespace.yaml
459
- * can also be referenced here — a stricter pattern would let a valid key
460
- * register yet fail at apply (e.g. `org/2fa`, a one-char or digit-led key).
461
- */
462
- declare const CAPABILITY_KEY_PATTERN: RegExp;
463
- declare const CLAIM_KEY_PATTERN: RegExp;
464
- /** Qualified reference to a table outside the defining file: `<schema>.<table>`. */
465
- declare const QUALIFIED_TABLE_PATTERN: RegExp;
466
- /** Synced reflected sources are restricted to the gold layer. */
467
- declare const SYNCED_SOURCE_PATTERN: RegExp;
468
- declare const ORM_SCHEMA_PREFIX = "orm_";
469
- declare const CONSUMER_ROLE_SUFFIX = "_consumer";
470
- declare const ormSchemaName: (namespace: string) => string;
471
- declare const consumerRoleName: (namespace: string) => string;
472
- declare const DEFINITION_FILE_EXTENSIONS: readonly [".yml", ".yaml"];
473
- /** Reserved basenames for the namespace-level config file (description, org capability pins). */
474
- declare const NAMESPACE_CONFIG_FILENAMES: Set<string>;
475
- declare const HASH_DOMAIN = "sequence-orm-definitions\0";
476
- /**
477
- * A per-file byte cap where the loader reads untrusted YAML into memory — a real failure mode, not a product
478
- * limit. Counts of tables/indexes/params and policy/SQL lengths are
479
- * deliberately uncapped; Postgres enforces its own limits loudly at apply.
480
- */
481
- declare const MAX_DEFINITION_FILE_BYTES: number;
482
- /** Generated SDL aggregates every table/view; it is not an individual source file. */
483
- declare const MAX_GENERATED_SDL_BYTES: number;
484
- /** Registration and reviewed exports carry SDL, canonical metadata, snapshots and migrations. */
485
- declare const ORM_REGISTRATION_MAX_BYTES: number;
486
- /** `/api/data/<ns>/actions/…` and `/api/data/<ns>/query` share the table path segment. */
487
- declare const RESERVED_TABLE_NAMES: Set<string>;
488
- /**
489
- * The Data API's query-string grammar owns these parameter names — a column
490
- * with one of them could never be filtered over the wire, so definitions
491
- * refuse it up front ("validate rejects only what can never work").
492
- */
493
- declare const RESERVED_COLUMN_NAMES: Set<string>;
494
-
495
433
  /** drizzle-kit's serialized schema — the diff/replay artifact the registry stores. */
496
434
  type NamespaceSnapshot = ReturnType<typeof generateDrizzleJson>;
497
435
  declare function generateSnapshot(definition: NamespaceDefinition, previousId?: string): NamespaceSnapshot;
@@ -741,11 +679,32 @@ declare function applyMigrationHintsV2(previous: NamespaceSnapshot, definition:
741
679
  * action function statements. v2 enforces row policies inside compiled
742
680
  * operations (no PG RLS policies) and executes actions on the data plane
743
681
  * (no plpgsql functions), so a v2 plan is hints + kit DDL only.
682
+ *
683
+ * Managed views are dropped and recreated only when the migration reaches
684
+ * them: their own definition changed, they read a relation whose change is not
685
+ * provably view-safe, or they depend on a view that is recreated. Every other
686
+ * view stays in place, keeping its grants, owner, and outside dependents.
744
687
  */
745
- declare function planMigrationV2({ canonical, previousSnapshot, }: {
688
+ declare function planMigrationV2(input: {
746
689
  canonical: CanonicalDefinition;
747
690
  previousSnapshot?: NamespaceSnapshot;
748
691
  }): Promise<PlannedMigration>;
692
+ /**
693
+ * The plan a committed (reviewed) migration was authored as: the current
694
+ * planner when it reproduces the migration, otherwise the legacy one for a
695
+ * migration written before view recreation was narrowed. `reproduces` decides
696
+ * a match — rendered SQL for the CLI's tip gate, statement lists for Atlas's
697
+ * replay gate. When neither reproduces it, the current plan comes back with
698
+ * `reproduced: false`, so callers report the mismatch exactly as before.
699
+ */
700
+ declare function planCommittedMigrationV2({ canonical, previousSnapshot, reproduces, }: {
701
+ canonical: CanonicalDefinition;
702
+ previousSnapshot?: NamespaceSnapshot;
703
+ reproduces: (plan: PlannedMigration) => boolean;
704
+ }): Promise<{
705
+ plan: PlannedMigration;
706
+ reproduced: boolean;
707
+ }>;
749
708
  /**
750
709
  * Drizzle's manual-view snapshot stores declared columns, but PostgreSQL names
751
710
  * and types the live view from the SELECT itself. Assert the live catalog in
@@ -806,14 +765,14 @@ declare const ormMigrationExportSchema: z.ZodObject<{
806
765
  type: z.ZodUnion<readonly [z.ZodEnum<{
807
766
  bigint: "bigint";
808
767
  boolean: "boolean";
809
- uuid: "uuid";
810
768
  text: "text";
769
+ date: "date";
770
+ timestamptz: "timestamptz";
771
+ jsonb: "jsonb";
772
+ uuid: "uuid";
811
773
  integer: "integer";
812
774
  numeric: "numeric";
813
775
  double: "double";
814
- timestamptz: "timestamptz";
815
- date: "date";
816
- jsonb: "jsonb";
817
776
  }>, z.ZodObject<{
818
777
  enum: z.ZodString;
819
778
  }, z.core.$strip>]>;
@@ -831,6 +790,16 @@ declare const ormMigrationExportSchema: z.ZodObject<{
831
790
  renamedFrom: z.ZodOptional<z.ZodString>;
832
791
  cast: z.ZodOptional<z.ZodString>;
833
792
  deprecated: z.ZodDefault<z.ZodBoolean>;
793
+ cell: z.ZodOptional<z.ZodObject<{
794
+ of: z.ZodString;
795
+ part: z.ZodEnum<{
796
+ at: "at";
797
+ by: "by";
798
+ rev: "rev";
799
+ source: "source";
800
+ conflicts: "conflicts";
801
+ }>;
802
+ }, z.core.$strict>>;
834
803
  }, z.core.$strip>>>;
835
804
  primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
836
805
  links: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -844,6 +813,20 @@ declare const ormMigrationExportSchema: z.ZodObject<{
844
813
  on: z.ZodString;
845
814
  references: z.ZodOptional<z.ZodString>;
846
815
  enforce: z.ZodDefault<z.ZodBoolean>;
816
+ onDelete: z.ZodOptional<z.ZodEnum<{
817
+ cascade: "cascade";
818
+ restrict: "restrict";
819
+ "no action": "no action";
820
+ "set null": "set null";
821
+ "set default": "set default";
822
+ }>>;
823
+ onUpdate: z.ZodOptional<z.ZodEnum<{
824
+ cascade: "cascade";
825
+ restrict: "restrict";
826
+ "no action": "no action";
827
+ "set null": "set null";
828
+ "set default": "set default";
829
+ }>>;
847
830
  description: z.ZodOptional<z.ZodString>;
848
831
  }, z.core.$strip>>>;
849
832
  indexes: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -851,6 +834,10 @@ declare const ormMigrationExportSchema: z.ZodObject<{
851
834
  unique: z.ZodDefault<z.ZodBoolean>;
852
835
  name: z.ZodOptional<z.ZodString>;
853
836
  }, z.core.$strip>>>;
837
+ checks: z.ZodOptional<z.ZodArray<z.ZodObject<{
838
+ name: z.ZodString;
839
+ expression: z.ZodString;
840
+ }, z.core.$strict>>>;
854
841
  policies: z.ZodDefault<z.ZodObject<{
855
842
  read: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
856
843
  default: z.ZodString;
@@ -892,14 +879,14 @@ declare const ormMigrationExportSchema: z.ZodObject<{
892
879
  type: z.ZodEnum<{
893
880
  bigint: "bigint";
894
881
  boolean: "boolean";
895
- uuid: "uuid";
896
882
  text: "text";
883
+ date: "date";
884
+ timestamptz: "timestamptz";
885
+ jsonb: "jsonb";
886
+ uuid: "uuid";
897
887
  integer: "integer";
898
888
  numeric: "numeric";
899
889
  double: "double";
900
- timestamptz: "timestamptz";
901
- date: "date";
902
- jsonb: "jsonb";
903
890
  }>;
904
891
  nullable: z.ZodDefault<z.ZodBoolean>;
905
892
  }, z.core.$strip>>>;
@@ -934,7 +921,24 @@ declare const ormMigrationExportSchema: z.ZodObject<{
934
921
  "initially-immediate": "initially-immediate";
935
922
  "initially-deferred": "initially-deferred";
936
923
  }>>;
924
+ onDelete: z.ZodOptional<z.ZodEnum<{
925
+ cascade: "cascade";
926
+ restrict: "restrict";
927
+ "no action": "no action";
928
+ "set null": "set null";
929
+ "set default": "set default";
930
+ }>>;
931
+ onUpdate: z.ZodOptional<z.ZodEnum<{
932
+ cascade: "cascade";
933
+ restrict: "restrict";
934
+ "no action": "no action";
935
+ "set null": "set null";
936
+ "set default": "set default";
937
+ }>>;
937
938
  }, z.core.$strict>>>;
939
+ cellMetadata: z.ZodOptional<z.ZodLiteral<true>>;
940
+ internal: z.ZodOptional<z.ZodLiteral<true>>;
941
+ materializes: z.ZodOptional<z.ZodString>;
938
942
  }, z.core.$strip>>;
939
943
  views: z.ZodOptional<z.ZodArray<z.ZodObject<{
940
944
  view: z.ZodString;
@@ -945,14 +949,14 @@ declare const ormMigrationExportSchema: z.ZodObject<{
945
949
  type: z.ZodUnion<readonly [z.ZodEnum<{
946
950
  bigint: "bigint";
947
951
  boolean: "boolean";
948
- uuid: "uuid";
949
952
  text: "text";
953
+ date: "date";
954
+ timestamptz: "timestamptz";
955
+ jsonb: "jsonb";
956
+ uuid: "uuid";
950
957
  integer: "integer";
951
958
  numeric: "numeric";
952
959
  double: "double";
953
- timestamptz: "timestamptz";
954
- date: "date";
955
- jsonb: "jsonb";
956
960
  }>, z.ZodObject<{
957
961
  enum: z.ZodString;
958
962
  }, z.core.$strip>]>;
@@ -970,6 +974,16 @@ declare const ormMigrationExportSchema: z.ZodObject<{
970
974
  renamedFrom: z.ZodOptional<z.ZodString>;
971
975
  cast: z.ZodOptional<z.ZodString>;
972
976
  deprecated: z.ZodDefault<z.ZodBoolean>;
977
+ cell: z.ZodOptional<z.ZodObject<{
978
+ of: z.ZodString;
979
+ part: z.ZodEnum<{
980
+ at: "at";
981
+ by: "by";
982
+ rev: "rev";
983
+ source: "source";
984
+ conflicts: "conflicts";
985
+ }>;
986
+ }, z.core.$strict>>;
973
987
  }, z.core.$strip>>;
974
988
  primaryKey: z.ZodOptional<z.ZodArray<z.ZodString>>;
975
989
  links: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -983,6 +997,20 @@ declare const ormMigrationExportSchema: z.ZodObject<{
983
997
  on: z.ZodString;
984
998
  references: z.ZodOptional<z.ZodString>;
985
999
  enforce: z.ZodDefault<z.ZodBoolean>;
1000
+ onDelete: z.ZodOptional<z.ZodEnum<{
1001
+ cascade: "cascade";
1002
+ restrict: "restrict";
1003
+ "no action": "no action";
1004
+ "set null": "set null";
1005
+ "set default": "set default";
1006
+ }>>;
1007
+ onUpdate: z.ZodOptional<z.ZodEnum<{
1008
+ cascade: "cascade";
1009
+ restrict: "restrict";
1010
+ "no action": "no action";
1011
+ "set null": "set null";
1012
+ "set default": "set default";
1013
+ }>>;
986
1014
  description: z.ZodOptional<z.ZodString>;
987
1015
  }, z.core.$strip>>>;
988
1016
  policies: z.ZodObject<{
@@ -997,6 +1025,95 @@ declare const ormMigrationExportSchema: z.ZodObject<{
997
1025
  }, z.core.$strict>;
998
1026
  query: z.ZodString;
999
1027
  dependencies: z.ZodArray<z.ZodString>;
1028
+ resolved: z.ZodOptional<z.ZodObject<{
1029
+ sources: z.ZodArray<z.ZodObject<{
1030
+ name: z.ZodString;
1031
+ kind: z.ZodEnum<{
1032
+ manual: "manual";
1033
+ prefetch: "prefetch";
1034
+ etl: "etl";
1035
+ }>;
1036
+ table: z.ZodString;
1037
+ columns: z.ZodArray<z.ZodString>;
1038
+ updatedAt: z.ZodOptional<z.ZodString>;
1039
+ key: z.ZodOptional<z.ZodString>;
1040
+ fetch: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
1041
+ shape: z.ZodLiteral<"single">;
1042
+ }, z.core.$strict>, z.ZodObject<{
1043
+ shape: z.ZodLiteral<"batch">;
1044
+ maxKeys: z.ZodNumber;
1045
+ }, z.core.$strict>]>>;
1046
+ function: z.ZodOptional<z.ZodObject<{
1047
+ kind: z.ZodEnum<{
1048
+ managed: "managed";
1049
+ native: "native";
1050
+ }>;
1051
+ id: z.ZodString;
1052
+ }, z.core.$strict>>;
1053
+ prefetchDefaults: z.ZodOptional<z.ZodObject<{
1054
+ maxStalenessMs: z.ZodNumber;
1055
+ timeoutMs: z.ZodNumber;
1056
+ onError: z.ZodEnum<{
1057
+ fallback: "fallback";
1058
+ fail: "fail";
1059
+ }>;
1060
+ }, z.core.$strict>>;
1061
+ writeback: z.ZodOptional<z.ZodObject<{
1062
+ columns: z.ZodArray<z.ZodString>;
1063
+ defaultMode: z.ZodEnum<{
1064
+ sync: "sync";
1065
+ async: "async";
1066
+ }>;
1067
+ timeoutMs: z.ZodNumber;
1068
+ clearManualOnConfirm: z.ZodBoolean;
1069
+ }, z.core.$strict>>;
1070
+ }, z.core.$strict>>;
1071
+ resolve: z.ZodArray<z.ZodObject<{
1072
+ column: z.ZodString;
1073
+ comparator: z.ZodEnum<{
1074
+ custom: "custom";
1075
+ latest: "latest";
1076
+ highest: "highest";
1077
+ lowest: "lowest";
1078
+ priority: "priority";
1079
+ nonNullFirst: "nonNullFirst";
1080
+ }>;
1081
+ candidates: z.ZodArray<z.ZodString>;
1082
+ orderBy: z.ZodOptional<z.ZodString>;
1083
+ }, z.core.$strict>>;
1084
+ deletedBy: z.ZodDefault<z.ZodArray<z.ZodString>>;
1085
+ materialized: z.ZodOptional<z.ZodObject<{
1086
+ table: z.ZodString;
1087
+ compute: z.ZodString;
1088
+ }, z.core.$strict>>;
1089
+ policies: z.ZodDefault<z.ZodObject<{
1090
+ write: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1091
+ default: z.ZodString;
1092
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1093
+ when: z.ZodString;
1094
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1095
+ policy: z.ZodOptional<z.ZodString>;
1096
+ }, z.core.$strip>>>;
1097
+ }, z.core.$strip>]>>;
1098
+ insert: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1099
+ default: z.ZodString;
1100
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1101
+ when: z.ZodString;
1102
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1103
+ policy: z.ZodOptional<z.ZodString>;
1104
+ }, z.core.$strip>>>;
1105
+ }, z.core.$strip>]>>;
1106
+ update: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1107
+ default: z.ZodString;
1108
+ variants: z.ZodDefault<z.ZodArray<z.ZodObject<{
1109
+ when: z.ZodString;
1110
+ allow: z.ZodOptional<z.ZodLiteral<true>>;
1111
+ policy: z.ZodOptional<z.ZodString>;
1112
+ }, z.core.$strip>>>;
1113
+ }, z.core.$strip>]>>;
1114
+ }, z.core.$strict>>;
1115
+ }, z.core.$strict>>;
1116
+ internal: z.ZodOptional<z.ZodLiteral<true>>;
1000
1117
  }, z.core.$strip>>>;
1001
1118
  capabilities: z.ZodDefault<z.ZodObject<{
1002
1119
  roles: z.ZodOptional<z.ZodUnknown>;
@@ -1270,4 +1387,4 @@ declare function parseCanonicalDefinition(value: unknown): NamespaceDefinition;
1270
1387
 
1271
1388
  declare const parsedPredicateSchema: z.ZodPipe<z.ZodString, z.ZodTransform<ParsedPredicate, string>>;
1272
1389
 
1273
- 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_IDENTIFIER_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_GENERATED_SDL_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_MIGRATION_EXPORT_FILE, ORM_MIGRATION_EXPORT_MAX_BYTES, ORM_REGISTRATION_MAX_BYTES, ORM_SCHEMA_PREFIX, ORM_SERVICE_DATA_TOKEN_HEADER, type Operand, OrmDefinitionError, type OrmMigrationExport, 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, createOrmMigrationExport, declaredCapabilityKeys, diffCommand, diffStatements, emptyJournal, emptySnapshot, extractNamedParams, generateNamespaceTypes, generateSnapshot, generateSnapshotV2, identifierSchema, isFunctionDefault, isOwnedStatement, isOwnedStatementV2, isQualifiedReference, loadCommittedMigrations, loadCommittedTipMigration, loadNamespaceDefinition, migrationName, namespaceConfigSchema, namespaceSchema, normalizeSnapshot, ormMigrationExportSchema, ormSchemaName, parseCanonicalDefinition, parseDefinitionSources, parseOrmMigrationExport, parsePredicate, parseTableFile, parsedPredicateSchema, pendingKitStatements, pendingKitStatementsV2, planMigration, planMigrationV2, predicateOperands, quoteIdentifier, quoteLiteral, readMigrationSql, readMigrationWorkspace, readSnapshot, rebaseViolations, referencedCapabilities, referencedColumns, renderMigrationSql, renderOrmMigrationExport, rewriteSyncedSourceRelationsInViewQuery, roleExpression, securityStatements, sqlTypeName, stableJson, syncedBackingRevokeStatements, syncedTables, syncedViewDropStatements, syncedViewStatements, tableFileSchema, tableReferenceSchema, typesInterfaceName, validateViewCatalogStatement, verifyRebaseIsNoop, walkPredicate, writeMigration };
1390
+ export { ACTION_REQUIRES_DENIED_SQLSTATE, ACTION_VALIDATES_FAILED_SQLSTATE, AUDIT_ACTIONS, type ActionDefinition, CAPABILITIES_CLAIM_KEY, CLAIMS_SETTING, COLUMN_TYPES, COMPARE_OPS, CanonicalDefinition, type ColumnDefault, type ColumnDefinition, type ColumnType, type CommittedChainEntry, type CommittedMigration, type CompareOp, type CompilePredIrToSqlOptions, type CompiledStatement, type DefinitionFile, type DefinitionSource, type DestructiveStatement, type DiffOptions, type DrizzleEntities, type IndexDefinition, type JournalEntry, type LinkDefinition, type LoadedNamespace, MIGRATIONS_DIRNAME, type MigrationJournal, type MigrationWorkspace, type NamespaceCapabilities, type NamespaceConfig, type NamespaceDefinition, type NamespaceSnapshot, ORM_MIGRATION_EXPORT_FILE, ORM_MIGRATION_EXPORT_MAX_BYTES, type Operand, OrmDefinitionError, type OrmMigrationExport, type ParsedPredicate, type PlannedMigration, PredIr, type Predicate, type PredicateColumnTypes, PredicateParseError, ROLES_CLAIM_KEY, type RebaseEntry, type RebaseEntryInput, type RebaseNoopOptions, STATEMENT_KINDS, 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, convertV1DefinitionToCanonical, createOrmMigrationExport, declaredCapabilityKeys, diffCommand, diffStatements, emptyJournal, emptySnapshot, extractNamedParams, generateNamespaceTypes, generateSnapshot, generateSnapshotV2, identifierSchema, isFunctionDefault, isOwnedStatement, isOwnedStatementV2, isQualifiedReference, loadCommittedMigrations, loadCommittedTipMigration, loadNamespaceDefinition, migrationName, namespaceConfigSchema, namespaceSchema, normalizeSnapshot, ormMigrationExportSchema, parseCanonicalDefinition, parseDefinitionSources, parseOrmMigrationExport, parsePredicate, parseTableFile, parsedPredicateSchema, pendingKitStatements, pendingKitStatementsV2, planCommittedMigrationV2, planMigration, planMigrationV2, predicateOperands, quoteIdentifier, quoteLiteral, readMigrationSql, readMigrationWorkspace, readSnapshot, rebaseViolations, referencedCapabilities, referencedColumns, renderMigrationSql, renderOrmMigrationExport, rewriteSyncedSourceRelationsInViewQuery, roleExpression, securityStatements, sqlTypeName, stableJson, syncedBackingRevokeStatements, syncedTables, syncedViewDropStatements, syncedViewStatements, tableFileSchema, tableReferenceSchema, typesInterfaceName, validateViewCatalogStatement, verifyRebaseIsNoop, walkPredicate, writeMigration };