@voltro/database 0.84.0 → 0.85.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sql.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import { ConfigError } from 'effect';
2
- import { Connection } from '@effect/sql/SqlConnection';
1
+ import { Config } from 'effect';
2
+ import { Connection } from 'effect/sql/SqlConnection';
3
3
  import { Effect } from 'effect';
4
- import { Fragment } from '@effect/sql/Statement';
4
+ import { Fragment } from 'effect/sql/Statement';
5
5
  import { Layer } from 'effect';
6
6
  import { Schema } from 'effect';
7
- import { SqlClient } from '@effect/sql';
8
- import { SqlError } from '@effect/sql/SqlError';
9
- import { SqlError as SqlError_2 } from '@effect/sql';
10
- import { Statement } from '@effect/sql';
7
+ import { SqlClient } from 'effect/sql';
8
+ import { SqlError } from 'effect/sql/SqlError';
9
+ import { SqlError as SqlError_2 } from 'effect/sql';
10
+ import { Statement } from 'effect/sql';
11
11
 
12
12
  /** Every hash this source may have been recorded under: its own, and the body
13
13
  * before each framework edit in {@link FRAMEWORK_MIGRATION_EDITS}. */
@@ -810,7 +810,8 @@ declare interface ColumnDefinition<TsType, Type extends ColumnType = ColumnType,
810
810
  */
811
811
  readonly fkAutoIndex?: boolean;
812
812
  /**
813
- * This id-shaped scalar names something outside the local relational graph.
813
+ * This id-shaped scalar deliberately has no single foreign key target,
814
+ * including external-system ids and local polymorphic targets.
814
815
  * Set by `.externalId()` so schema audits do not guess a local FK from the
815
816
  * column name. Metadata only; it emits no constraint or DDL.
816
817
  */
@@ -1241,7 +1242,8 @@ declare interface ColumnDefinition_2<TsType, Type extends ColumnType_2 = ColumnT
1241
1242
  */
1242
1243
  readonly fkAutoIndex?: boolean;
1243
1244
  /**
1244
- * This id-shaped scalar names something outside the local relational graph.
1245
+ * This id-shaped scalar deliberately has no single foreign key target,
1246
+ * including external-system ids and local polymorphic targets.
1245
1247
  * Set by `.externalId()` so schema audits do not guess a local FK from the
1246
1248
  * column name. Metadata only; it emits no constraint or DDL.
1247
1249
  */
@@ -2576,7 +2578,7 @@ declare type DialectId = 'postgres' | 'mysql' | 'mariadb' | 'mssql' | 'sqlite' |
2576
2578
  * Resolve the live dialect from the `SqlClient`.
2577
2579
  *
2578
2580
  * `sql.onDialectOrElse` collapses the six voltro dialects onto four driver
2579
- * tokens: mysql+mariadb share `mysql` (one `@effect/sql-mysql2` client) and
2581
+ * tokens: mysql+mariadb share `mysql` (one `effect/sql-mysql2` client) and
2580
2582
  * sqlite+turso share `sqlite`. That collapse is fine for every consumer here —
2581
2583
  * the paired dialects behave identically for everything this module decides.
2582
2584
  *
@@ -3143,7 +3145,7 @@ export declare interface FileMigration {
3143
3145
  export declare interface FileMigrationContext {
3144
3146
  /**
3145
3147
  * The escape hatch, and it asks for a reason. `raw('why')` returns the
3146
- * `@effect/sql` client — `sql.unsafe(...)`, `sql\`...\``,
3148
+ * `effect/sql` client — `sql.unsafe(...)`, `sql\`...\``,
3147
3149
  * `sql.onDialectOrElse({...})` — for the one thing neither `store` nor
3148
3150
  * `schema` expresses. The reason is required (an empty one throws), it is
3149
3151
  * what `voltro doctor` lists beside every migration that reaches for raw
@@ -3415,6 +3417,11 @@ export declare interface HeldMigrationLock {
3415
3417
  /** Release the lock and return its connection to the pool. Idempotent only
3416
3418
  * in the sense that the dialect statements are; call it once. */
3417
3419
  readonly release: Effect.Effect<void, SqlError>;
3420
+ /** The reserved connection holding the lock (none on sqlite). Idle between
3421
+ * its keep-alive touches, so work that needs a connection OTHER than its
3422
+ * transaction's — a visibility probe — reads through this one instead of
3423
+ * reserving a third: the migration's contract is two connections. */
3424
+ readonly connection: Connection | undefined;
3418
3425
  }
3419
3426
 
3420
3427
  /**
@@ -3889,7 +3896,7 @@ export declare type MigrationModuleImporter = (file: string) => Promise<Record<s
3889
3896
  * `log` and the two probes the store can answer about its own shape
3890
3897
  * (`tableExists`, `columnExists`) work without one; each refusal names what to
3891
3898
  * do instead. Also raised at construction when what was handed in as `sql` is not
3892
- * an `@effect/sql` client, or when a SQL-backed store arrives without the
3899
+ * an `effect/sql` client, or when a SQL-backed store arrives without the
3893
3900
  * client it executes on — both are refused before a body can run rather
3894
3901
  * than surfacing as a TypeError from inside the first helper that touches
3895
3902
  * the client.
@@ -4741,7 +4748,7 @@ export declare const previewMigrationSquash: (options: Pick<SquashOptions, "befo
4741
4748
  * Eager provisioning is the APP's move (call this from a seed/startup over its
4742
4749
  * own tenant table); the framework has no tenant registry to enumerate.
4743
4750
  */
4744
- export declare const provisionTenantNamespace: (tables: ReadonlyArray<AnyTable>, namespace: string, sqlLayer: Layer.Layer<SqlClient.SqlClient, ConfigError.ConfigError | SqlError_2.SqlError, never>, dialect?: DialectId, options?: SchemaApplyOptions) => Promise<void>;
4751
+ export declare const provisionTenantNamespace: (tables: ReadonlyArray<AnyTable>, namespace: string, sqlLayer: Layer.Layer<SqlClient.SqlClient, Config.ConfigError | SqlError_2.SqlError, never>, dialect?: DialectId, options?: SchemaApplyOptions) => Promise<void>;
4745
4752
 
4746
4753
  /** Internal offline publication. Receipt and published image share the same
4747
4754
  * commit as table replacement. Retry verifies receipt/schema/retained artifacts
@@ -5776,7 +5783,7 @@ export declare interface RunFileBasedMigrationsCtx {
5776
5783
  * `voltro_isr_cache` so framework releases that grow new columns
5777
5784
  * don't crash old DBs at boot.
5778
5785
  */
5779
- export declare const runFrameworkBootstrap: (tables: ReadonlyArray<AnyTable>, sqlLayer: Layer.Layer<SqlClient.SqlClient, ConfigError.ConfigError | SqlError_2.SqlError, never>, dialect?: DialectId, options?: SchemaApplyOptions) => Promise<void>;
5786
+ export declare const runFrameworkBootstrap: (tables: ReadonlyArray<AnyTable>, sqlLayer: Layer.Layer<SqlClient.SqlClient, Config.ConfigError | SqlError_2.SqlError, never>, dialect?: DialectId, options?: SchemaApplyOptions) => Promise<void>;
5780
5787
 
5781
5788
  /**
5782
5789
  * Run `applySchema` against a fresh SqlClient from the provided sqlLayer.
@@ -5786,7 +5793,7 @@ export declare const runFrameworkBootstrap: (tables: ReadonlyArray<AnyTable>, sq
5786
5793
  * `dialect` is passed through to the DDL emitter so SQL types + reactive
5787
5794
  * trigger emission match the underlying engine.
5788
5795
  */
5789
- export declare const runMigrate: (tables: ReadonlyArray<AnyTable>, sqlLayer: Layer.Layer<SqlClient.SqlClient, ConfigError.ConfigError | SqlError_2.SqlError, never>, dialect?: DialectId, options?: SchemaApplyOptions) => Promise<void>;
5796
+ export declare const runMigrate: (tables: ReadonlyArray<AnyTable>, sqlLayer: Layer.Layer<SqlClient.SqlClient, Config.ConfigError | SqlError_2.SqlError, never>, dialect?: DialectId, options?: SchemaApplyOptions) => Promise<void>;
5790
5797
 
5791
5798
  /**
5792
5799
  * Execute ONE planned operation with the applier's own per-dialect
@@ -6053,6 +6060,8 @@ declare interface SpatialClause_2 {
6053
6060
  readonly order?: 'asc' | 'desc';
6054
6061
  }
6055
6062
 
6063
+ export declare const splitStatements: (sql: string) => ReadonlyArray<string>;
6064
+
6056
6065
  /**
6057
6066
  * The `sql` template tag — captures a tagged-template literal into a
6058
6067
  * {@link RawSqlFragment} descriptor without binding it to any client.
@@ -6360,10 +6369,9 @@ declare interface Table<Name extends string, Fields extends Record<string, Colum
6360
6369
  /**
6361
6370
  * The plugin references DECLARED on this table, surviving `table()`.
6362
6371
  *
6363
- * `pluginRefSpecOf` reads a column BUILDER, and materialisation replaces it
6364
- * with a plain field descriptor — so without this the declaration is
6365
- * unreadable the moment the table exists, and any tool deriving structure
6366
- * from the schema sees an ordinary `text()` column.
6372
+ * Derived from column metadata on every table rebuild, including columns
6373
+ * contributed by mixins. Consumers can inspect these rules without knowing
6374
+ * the private metadata on each materialized scalar definition.
6367
6375
  */
6368
6376
  readonly appliedPluginRefs?: ReadonlyArray<{
6369
6377
  readonly column: string;
@@ -6410,7 +6418,7 @@ declare interface Table<Name extends string, Fields extends Record<string, Colum
6410
6418
  * BEFORE every INSERT. Populated by `.validate(schema)`. Set
6411
6419
  * per-table at table-construction time; immutable thereafter.
6412
6420
  */
6413
- readonly insertSchema?: Schema.Schema.Any;
6421
+ readonly insertSchema?: Schema.Top;
6414
6422
  /**
6415
6423
  * Optional `effect/Schema` the framework decodes a patch against
6416
6424
  * BEFORE every UPDATE. Populated by `.validatePatch(schema)`. The
@@ -6419,7 +6427,7 @@ declare interface Table<Name extends string, Fields extends Record<string, Colum
6419
6427
  * are checked. Set per-table at table-construction time; immutable
6420
6428
  * thereafter.
6421
6429
  */
6422
- readonly validatePatchSchema?: Schema.Schema.Any;
6430
+ readonly validatePatchSchema?: Schema.Top;
6423
6431
  with: <const Mixins extends ReadonlyArray<AnyMixin>>(...mixins: Mixins) => Table<Name, Fields & MergeMixinFields<Mixins>, Reactive, IxNames>;
6424
6432
  /**
6425
6433
  * Attach an effect/Schema that validates EVERY insert against the
@@ -6447,7 +6455,7 @@ declare interface Table<Name extends string, Fields extends Record<string, Colum
6447
6455
  * `id` and `createdAt` are already filled in by the time the
6448
6456
  * decoder sees the row.
6449
6457
  */
6450
- validate: <S extends Schema.Schema.Any>(schema: S) => Table<Name, Fields, Reactive, IxNames>;
6458
+ validate: <S extends Schema.Top>(schema: S) => Table<Name, Fields, Reactive, IxNames>;
6451
6459
  /**
6452
6460
  * Attach an effect/Schema that validates UPDATE patches against the
6453
6461
  * table. The framework wraps the schema in `Schema.partial`, so a
@@ -6478,7 +6486,7 @@ declare interface Table<Name extends string, Fields extends Record<string, Colum
6478
6486
  * wrapping is applied for you, so don't pre-wrap fields in
6479
6487
  * `Schema.optional`.
6480
6488
  */
6481
- validatePatch: <S extends Schema.Schema.Any>(schema: S) => Table<Name, Fields, Reactive, IxNames>;
6489
+ validatePatch: <S extends Schema.Struct<Schema.Struct.Fields>>(schema: S) => Table<Name, Fields, Reactive, IxNames>;
6482
6490
  /**
6483
6491
  * Declare a (possibly composite) secondary index on the table.
6484
6492
  *