@sequenceholdings/orm 2.5.0 → 2.6.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.
package/dist/index.d.cts CHANGED
@@ -366,6 +366,8 @@ interface CompilePredIrToSqlOptions {
366
366
  kind: 'exists';
367
367
  }>) => string;
368
368
  readonly namespace?: string;
369
+ /** Synced-view claim leaves are row-independent: evaluate them once per statement. */
370
+ readonly statementClaimChecks?: boolean;
369
371
  /** Column name → declared type, for claim casts in comparisons. */
370
372
  readonly columnTypes?: SyncedPredicateColumnTypes;
371
373
  /** Logical column name → physical column name for the synced backing. */
@@ -419,8 +421,12 @@ declare function referencedCapabilities(predicate: Predicate): string[];
419
421
 
420
422
  /** Column name → declared type, so claim comparisons can cast to the column's side. */
421
423
  type PredicateColumnTypes = Readonly<Record<string, ColumnType>>;
424
+ interface CompilePredicateOptions {
425
+ /** Synced-view capability leaves have no row dependency. */
426
+ readonly statementClaimChecks?: boolean;
427
+ }
422
428
  /** Predicate AST → a parenthesized SQL boolean expression. Never interpolates raw policy text. */
423
- declare function compilePredicate(predicate: Predicate, columnTypes?: PredicateColumnTypes): string;
429
+ declare function compilePredicate(predicate: Predicate, columnTypes?: PredicateColumnTypes, options?: CompilePredicateOptions): string;
424
430
 
425
431
  /** Claims are stamped per transaction by the Data API (`set_config('request.jwt.claims', …, true)`). */
426
432
  declare const CLAIMS_SETTING = "request.jwt.claims";
@@ -586,7 +592,7 @@ interface SyncedBacking {
586
592
  * SELECT before CREATE VIEW, or preserve a separately verified publisher grant.
587
593
  */
588
594
  declare const SYNCED_VIEW_EXECUTION_OWNER_ROLE = "orm_exec";
589
- declare function syncedViewStatements({ definition, backings, readPolicyIrByTable, columnNamesByTable, columnTypesByTable, executionOwnerRole, backingPrivileges, }: {
595
+ declare function syncedViewStatements({ definition, backings, readPolicyIrByTable, columnNamesByTable, columnTypesByTable, executionOwnerRole, backingPrivileges, viewPrivileges, statementClaimChecks, }: {
590
596
  definition: NamespaceDefinition;
591
597
  backings: readonly SyncedBacking[];
592
598
  /** v2 compiled read policies (preserves capability/role variants). */
@@ -606,6 +612,10 @@ declare function syncedViewStatements({ definition, backings, readPolicyIrByTabl
606
612
  * the views as that owner. This option does not grant backing access.
607
613
  */
608
614
  backingPrivileges?: 'grant' | 'preserve';
615
+ /** Maintenance of an existing view must retain its consumer ACL unchanged. */
616
+ viewPrivileges?: 'grant' | 'preserve';
617
+ /** False reproduces the previous compiler solely to verify existing view definitions. */
618
+ statementClaimChecks?: boolean;
609
619
  }): string[];
610
620
  /**
611
621
  * Drop synced views — idempotent cleanup for apply retries and removal.
@@ -623,6 +633,18 @@ declare function syncedBackingRevokeStatements({ backings, executionOwnerRole, }
623
633
  executionOwnerRole?: string;
624
634
  }): string[];
625
635
 
636
+ /**
637
+ * Prove a stored synced view still has an exact compiler definition before
638
+ * replacing its policy. This is deliberately narrower than SQL equivalence.
639
+ * Callers must separately verify catalog metadata (owner, ACL, reloptions,
640
+ * dependencies and column types); pg_get_viewdef contains only the SELECT.
641
+ * Capture it with search_path = pg_catalog so backing names stay qualified.
642
+ */
643
+ declare function assertSyncedViewDefinitionMatches({ viewDefinition, expectedCreateStatements, }: {
644
+ viewDefinition: string;
645
+ expectedCreateStatements: readonly string[];
646
+ }): Promise<void>;
647
+
626
648
  declare const sqlTypeName: (type: ColumnType) => string;
627
649
 
628
650
  declare const STATEMENT_KINDS: readonly ["hint", "ddl", "security", "function", "synced_view"];
@@ -1855,4 +1877,4 @@ declare function planTableImport({ definition, spec, after, }: {
1855
1877
  after?: string;
1856
1878
  }): ImportPlanResult;
1857
1879
 
1858
- 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, IMPORT_CONFLICT_MODES, type ImportConflictMode, type ImportPlan, type ImportPlanResult, type ImportSpec, 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, importSpecSchema, isFunctionDefault, isOwnedStatement, isOwnedStatementV2, isQualifiedReference, loadCommittedMigrations, loadCommittedTipMigration, loadNamespaceDefinition, migrationName, namespaceConfigSchema, namespaceSchema, normalizeSnapshot, ormMigrationExportSchema, parseCanonicalDefinition, parseDefinitionSources, parseOrmMigrationExport, parsePredicate, parseTableFile, parsedPredicateSchema, pendingKitStatements, pendingKitStatementsV2, planCommittedMigrationV2, planMigration, planMigrationV2, planTableImport, 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 };
1880
+ 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, IMPORT_CONFLICT_MODES, type ImportConflictMode, type ImportPlan, type ImportPlanResult, type ImportSpec, 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, assertSyncedViewDefinitionMatches, 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, importSpecSchema, isFunctionDefault, isOwnedStatement, isOwnedStatementV2, isQualifiedReference, loadCommittedMigrations, loadCommittedTipMigration, loadNamespaceDefinition, migrationName, namespaceConfigSchema, namespaceSchema, normalizeSnapshot, ormMigrationExportSchema, parseCanonicalDefinition, parseDefinitionSources, parseOrmMigrationExport, parsePredicate, parseTableFile, parsedPredicateSchema, pendingKitStatements, pendingKitStatementsV2, planCommittedMigrationV2, planMigration, planMigrationV2, planTableImport, 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 };
package/dist/index.d.ts CHANGED
@@ -366,6 +366,8 @@ interface CompilePredIrToSqlOptions {
366
366
  kind: 'exists';
367
367
  }>) => string;
368
368
  readonly namespace?: string;
369
+ /** Synced-view claim leaves are row-independent: evaluate them once per statement. */
370
+ readonly statementClaimChecks?: boolean;
369
371
  /** Column name → declared type, for claim casts in comparisons. */
370
372
  readonly columnTypes?: SyncedPredicateColumnTypes;
371
373
  /** Logical column name → physical column name for the synced backing. */
@@ -419,8 +421,12 @@ declare function referencedCapabilities(predicate: Predicate): string[];
419
421
 
420
422
  /** Column name → declared type, so claim comparisons can cast to the column's side. */
421
423
  type PredicateColumnTypes = Readonly<Record<string, ColumnType>>;
424
+ interface CompilePredicateOptions {
425
+ /** Synced-view capability leaves have no row dependency. */
426
+ readonly statementClaimChecks?: boolean;
427
+ }
422
428
  /** Predicate AST → a parenthesized SQL boolean expression. Never interpolates raw policy text. */
423
- declare function compilePredicate(predicate: Predicate, columnTypes?: PredicateColumnTypes): string;
429
+ declare function compilePredicate(predicate: Predicate, columnTypes?: PredicateColumnTypes, options?: CompilePredicateOptions): string;
424
430
 
425
431
  /** Claims are stamped per transaction by the Data API (`set_config('request.jwt.claims', …, true)`). */
426
432
  declare const CLAIMS_SETTING = "request.jwt.claims";
@@ -586,7 +592,7 @@ interface SyncedBacking {
586
592
  * SELECT before CREATE VIEW, or preserve a separately verified publisher grant.
587
593
  */
588
594
  declare const SYNCED_VIEW_EXECUTION_OWNER_ROLE = "orm_exec";
589
- declare function syncedViewStatements({ definition, backings, readPolicyIrByTable, columnNamesByTable, columnTypesByTable, executionOwnerRole, backingPrivileges, }: {
595
+ declare function syncedViewStatements({ definition, backings, readPolicyIrByTable, columnNamesByTable, columnTypesByTable, executionOwnerRole, backingPrivileges, viewPrivileges, statementClaimChecks, }: {
590
596
  definition: NamespaceDefinition;
591
597
  backings: readonly SyncedBacking[];
592
598
  /** v2 compiled read policies (preserves capability/role variants). */
@@ -606,6 +612,10 @@ declare function syncedViewStatements({ definition, backings, readPolicyIrByTabl
606
612
  * the views as that owner. This option does not grant backing access.
607
613
  */
608
614
  backingPrivileges?: 'grant' | 'preserve';
615
+ /** Maintenance of an existing view must retain its consumer ACL unchanged. */
616
+ viewPrivileges?: 'grant' | 'preserve';
617
+ /** False reproduces the previous compiler solely to verify existing view definitions. */
618
+ statementClaimChecks?: boolean;
609
619
  }): string[];
610
620
  /**
611
621
  * Drop synced views — idempotent cleanup for apply retries and removal.
@@ -623,6 +633,18 @@ declare function syncedBackingRevokeStatements({ backings, executionOwnerRole, }
623
633
  executionOwnerRole?: string;
624
634
  }): string[];
625
635
 
636
+ /**
637
+ * Prove a stored synced view still has an exact compiler definition before
638
+ * replacing its policy. This is deliberately narrower than SQL equivalence.
639
+ * Callers must separately verify catalog metadata (owner, ACL, reloptions,
640
+ * dependencies and column types); pg_get_viewdef contains only the SELECT.
641
+ * Capture it with search_path = pg_catalog so backing names stay qualified.
642
+ */
643
+ declare function assertSyncedViewDefinitionMatches({ viewDefinition, expectedCreateStatements, }: {
644
+ viewDefinition: string;
645
+ expectedCreateStatements: readonly string[];
646
+ }): Promise<void>;
647
+
626
648
  declare const sqlTypeName: (type: ColumnType) => string;
627
649
 
628
650
  declare const STATEMENT_KINDS: readonly ["hint", "ddl", "security", "function", "synced_view"];
@@ -1855,4 +1877,4 @@ declare function planTableImport({ definition, spec, after, }: {
1855
1877
  after?: string;
1856
1878
  }): ImportPlanResult;
1857
1879
 
1858
- 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, IMPORT_CONFLICT_MODES, type ImportConflictMode, type ImportPlan, type ImportPlanResult, type ImportSpec, 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, importSpecSchema, isFunctionDefault, isOwnedStatement, isOwnedStatementV2, isQualifiedReference, loadCommittedMigrations, loadCommittedTipMigration, loadNamespaceDefinition, migrationName, namespaceConfigSchema, namespaceSchema, normalizeSnapshot, ormMigrationExportSchema, parseCanonicalDefinition, parseDefinitionSources, parseOrmMigrationExport, parsePredicate, parseTableFile, parsedPredicateSchema, pendingKitStatements, pendingKitStatementsV2, planCommittedMigrationV2, planMigration, planMigrationV2, planTableImport, 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 };
1880
+ 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, IMPORT_CONFLICT_MODES, type ImportConflictMode, type ImportPlan, type ImportPlanResult, type ImportSpec, 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, assertSyncedViewDefinitionMatches, 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, importSpecSchema, isFunctionDefault, isOwnedStatement, isOwnedStatementV2, isQualifiedReference, loadCommittedMigrations, loadCommittedTipMigration, loadNamespaceDefinition, migrationName, namespaceConfigSchema, namespaceSchema, normalizeSnapshot, ormMigrationExportSchema, parseCanonicalDefinition, parseDefinitionSources, parseOrmMigrationExport, parsePredicate, parseTableFile, parsedPredicateSchema, pendingKitStatements, pendingKitStatementsV2, planCommittedMigrationV2, planMigration, planMigrationV2, planTableImport, 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 };