qubu 0.4.2 → 0.5.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/{canonical-BXUguqfo.mjs → canonical-DMvR9yBe.mjs} +4 -4
- package/dist/codegen.d.mts +1 -1
- package/dist/codegen.mjs +7 -4
- package/dist/{column-hqKr7-1I.mjs → column-DmazTL67.mjs} +15 -2
- package/dist/{complete-WYyVozgK.mjs → complete-DP7pliuY.mjs} +6 -6
- package/dist/{complete-types-IjEn5VPN.d.mts → complete-types-CY0KbzNw.d.mts} +1 -1
- package/dist/core.d.mts +1 -1
- package/dist/core.mjs +3 -3
- package/dist/diff.d.mts +201 -1
- package/dist/diff.mjs +8 -8
- package/dist/{index-1DpA3mUh.d.mts → index-C-480HmV.d.mts} +12 -12
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +226 -44
- package/dist/introspection.d.mts +2 -2
- package/dist/introspection.mjs +24 -13
- package/dist/mysql.d.mts +2 -2
- package/dist/{on-conflict-hfPW0KmQ.mjs → on-conflict-jPsl9l0K.mjs} +6 -3
- package/dist/postgres.d.mts +2 -2
- package/dist/postgres.mjs +3 -3
- package/dist/{registry-BRMLYwDp.mjs → registry-BGqa05et.mjs} +2 -2
- package/dist/{relational-BZ3WDPzC.mjs → relational-x3BDVX9e.mjs} +2 -2
- package/dist/schema.d.mts +2 -2
- package/dist/schema.mjs +5 -5
- package/dist/{snapshot-C-W65HEd.mjs → snapshot-BSraiLtH.mjs} +2 -2
- package/dist/snapshot.d.mts +4 -4
- package/dist/snapshot.mjs +585 -5
- package/dist/{source-BcS2AsIg.mjs → source-C4Vmu5bb.mjs} +1 -1
- package/dist/{sqlite-Cg0nwYEH.mjs → sqlite-CsIUtZ2Q.mjs} +6 -6
- package/dist/sqlite.d.mts +30 -3
- package/dist/sqlite.mjs +28 -2
- package/dist/{table-Bp5irMSj.mjs → table-DLQ7YWth.mjs} +2 -2
- package/dist/{types-BK1COGZe.d.mts → types-C0VkiwpR.d.mts} +146 -41
- package/dist/{types-JSZHpUEj.d.mts → types-CTCqtFlS.d.mts} +1 -1
- package/dist/{types-JM3FcAnX.mjs → types-CTENnDh9.mjs} +2 -2
- package/dist/{value-Bi71Agyf.mjs → value-BEEj_Ayd.mjs} +1 -1
- package/dist/vite/ambient.d.ts +6 -0
- package/docs/config.json +1 -0
- package/docs/dialects-and-execution.md +47 -0
- package/docs/guides/drizzle.md +2 -1
- package/docs/index.md +6 -2
- package/docs/migrations/adapters.md +70 -0
- package/docs/migrations/artifacts-and-policy.md +123 -0
- package/docs/migrations/index.md +46 -0
- package/docs/migrations/lotta-adoption.md +50 -0
- package/docs/migrations/operations.md +133 -0
- package/docs/migrations/recovery.md +121 -0
- package/docs/reference/introspection-support.md +1 -1
- package/docs/reference/supported-surface.md +59 -44
- package/docs/schema/catalog-model.md +1 -1
- package/docs/schema/columns-and-writes.md +14 -0
- package/docs/schema/ddl-emission.md +15 -10
- package/docs/schema/introspection.md +4 -3
- package/docs/schema/migration-plans.md +6 -6
- package/docs/schema/snapshots.md +2 -2
- package/package.json +5 -14
- package/dist/ddl.d.mts +0 -118
- package/dist/ddl.mjs +0 -1119
- package/dist/index-CPvfEheG.d.mts +0 -202
- package/dist/migration.d.mts +0 -214
- package/dist/migration.mjs +0 -1160
- package/dist/mysql-B_cYzzX2.mjs +0 -585
package/dist/sqlite.mjs
CHANGED
|
@@ -1,7 +1,33 @@
|
|
|
1
1
|
import { o as createDialect, r as sqliteJson } from "./json-Db7XRD91.mjs";
|
|
2
|
+
import { g as nativeStorage, h as nativeColumn } from "./column-DmazTL67.mjs";
|
|
2
3
|
import { r as sqliteExplain } from "./explain-CkIK13L_.mjs";
|
|
3
|
-
import { i as onConflict, n as doUpdate, r as excluded, t as doNothing } from "./on-conflict-
|
|
4
|
+
import { i as onConflict, n as doUpdate, r as excluded, t as doNothing } from "./on-conflict-jPsl9l0K.mjs";
|
|
4
5
|
//#region src/dialects/sqlite.ts
|
|
6
|
+
/** Declare a SQLite `INTEGER` timestamp with a live Date codec. */
|
|
7
|
+
function sqliteTimestamp(options) {
|
|
8
|
+
const mode = options?.mode ?? "timestamp";
|
|
9
|
+
const scale = mode === "timestamp" ? 1e3 : 1;
|
|
10
|
+
return nativeColumn(nativeStorage("sqlite", "INTEGER"), {
|
|
11
|
+
nullable: options?.nullable === true,
|
|
12
|
+
sqlName: options?.sqlName,
|
|
13
|
+
defaultFn: options?.defaultFn,
|
|
14
|
+
codec: {
|
|
15
|
+
toDriver(value) {
|
|
16
|
+
if (!(value instanceof Date) || Number.isNaN(value.getTime())) throw new TypeError("SQLite timestamps require a valid Date");
|
|
17
|
+
return mode === "timestamp" ? Math.floor(value.getTime() / scale) : value.getTime();
|
|
18
|
+
},
|
|
19
|
+
fromDriver(value) {
|
|
20
|
+
if (value instanceof Date) return value;
|
|
21
|
+
if (typeof value !== "number" && typeof value !== "bigint") throw new TypeError("SQLite timestamp results require a numeric value");
|
|
22
|
+
const timestamp = Number(value);
|
|
23
|
+
if (!Number.isFinite(timestamp) || !Number.isInteger(timestamp)) throw new TypeError("SQLite timestamp results require a finite integer");
|
|
24
|
+
const decoded = new Date(timestamp * scale);
|
|
25
|
+
if (Number.isNaN(decoded.getTime())) throw new TypeError("SQLite timestamp result is outside the valid Date range");
|
|
26
|
+
return decoded;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}).$type();
|
|
30
|
+
}
|
|
5
31
|
function renderSqliteSchemaLiteral(value) {
|
|
6
32
|
if (value === null) return "NULL";
|
|
7
33
|
if (typeof value === "boolean") return value ? "1" : "0";
|
|
@@ -45,4 +71,4 @@ function sqliteDialect() {
|
|
|
45
71
|
});
|
|
46
72
|
}
|
|
47
73
|
//#endregion
|
|
48
|
-
export { doNothing, doUpdate, excluded, onConflict, sqliteDialect };
|
|
74
|
+
export { doNothing, doUpdate, excluded, onConflict, sqliteDialect, sqliteTimestamp };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as exposeColumns, t as createSource } from "./source-
|
|
1
|
+
import { L as materializeSchemaObjectRecord, R as resolveSqlNames, Y as parenthesize, at as resultValueOf, i as identifier, rt as resultShapeValue, t as createColumnReference, u as columnResultValue } from "./column-DmazTL67.mjs";
|
|
2
|
+
import { r as exposeColumns, t as createSource } from "./source-C4Vmu5bb.mjs";
|
|
3
3
|
//#region src/schema/alias.ts
|
|
4
4
|
function alias(sourceOrQuery, name) {
|
|
5
5
|
const input = sourceOrQuery;
|
|
@@ -415,15 +415,23 @@ declare function render<TQuery extends AnyFragment, TCapabilities extends Dialec
|
|
|
415
415
|
type StreamableQuery<TRow extends object = Record<string, unknown>> = QueryWithRow<TRow> & {
|
|
416
416
|
readonly queryKind: "select" | "set";
|
|
417
417
|
};
|
|
418
|
+
/** Scalar application metadata forwarded only to bound-client lifecycle hooks. */
|
|
419
|
+
type HookMetadataValue = string | number | boolean;
|
|
420
|
+
/** Application correlation metadata forwarded without affecting execution. */
|
|
421
|
+
type HookMetadata = Readonly<Record<string, HookMetadataValue>>;
|
|
418
422
|
/** Rendering policy and cancellation input accepted by query execution. */
|
|
419
423
|
interface ExecutionOptions extends RenderOptions {
|
|
420
424
|
/** Passed to the application adapter for drivers that support cancellation. */
|
|
421
425
|
readonly signal?: AbortSignal;
|
|
426
|
+
/** Inert application metadata exposed to bound-client hooks. */
|
|
427
|
+
readonly hookMetadata?: HookMetadata;
|
|
422
428
|
}
|
|
423
429
|
/** Rendering, EXPLAIN, and cancellation options for plan requests. */
|
|
424
430
|
interface ExplainOptions extends RenderOptions, ExplainRenderOptions {
|
|
425
431
|
/** Passed to the application adapter for drivers that support cancellation. */
|
|
426
432
|
readonly signal?: AbortSignal;
|
|
433
|
+
/** Inert application metadata exposed to bound-client hooks. */
|
|
434
|
+
readonly hookMetadata?: HookMetadata;
|
|
427
435
|
}
|
|
428
436
|
/** EXPLAIN options accepted for SELECT and set-operation queries. */
|
|
429
437
|
type ExplainReadOptions = ExplainOptions;
|
|
@@ -437,6 +445,66 @@ type ExplainOptionsFor<TQuery extends AnyQuery> = TQuery["queryKind"] extends "s
|
|
|
437
445
|
interface TransactionOptions {
|
|
438
446
|
/** Passed to the adapter for transaction begin, commit, and rollback. */
|
|
439
447
|
readonly signal?: AbortSignal;
|
|
448
|
+
/** Inert application metadata exposed to bound-client hooks. */
|
|
449
|
+
readonly hookMetadata?: HookMetadata;
|
|
450
|
+
}
|
|
451
|
+
/** Operations observable through one bound client's hooks. */
|
|
452
|
+
type HookOperationKind = "execute" | "stream" | "explain" | "transaction";
|
|
453
|
+
interface HookOperationBase {
|
|
454
|
+
/** Opaque identifier unique within one bound client and its transaction scopes. */
|
|
455
|
+
readonly id: number;
|
|
456
|
+
/** The enclosing transaction operation, when present. */
|
|
457
|
+
readonly parentId?: number;
|
|
458
|
+
readonly kind: HookOperationKind;
|
|
459
|
+
/** Monotonic start time in milliseconds. */
|
|
460
|
+
readonly startedAt: number;
|
|
461
|
+
readonly metadata?: HookMetadata;
|
|
462
|
+
}
|
|
463
|
+
/** Metadata for one bound-client query operation. */
|
|
464
|
+
interface HookQueryOperation extends HookOperationBase {
|
|
465
|
+
readonly kind: "execute" | "stream" | "explain";
|
|
466
|
+
readonly queryKind: QueryKind;
|
|
467
|
+
readonly dialect: string;
|
|
468
|
+
readonly sql: string;
|
|
469
|
+
readonly parameterCount: number;
|
|
470
|
+
}
|
|
471
|
+
/** Metadata for one bound-client transaction operation. */
|
|
472
|
+
interface HookTransactionOperation extends HookOperationBase {
|
|
473
|
+
readonly kind: "transaction";
|
|
474
|
+
}
|
|
475
|
+
/** Immutable metadata supplied when a bound-client operation starts. */
|
|
476
|
+
type HookOperation = HookQueryOperation | HookTransactionOperation;
|
|
477
|
+
/** How a successfully observed stream stopped producing rows. */
|
|
478
|
+
type HookStreamEnd = "complete" | "consumer-return";
|
|
479
|
+
/** Aggregate facts reported after a successful bound-client operation. */
|
|
480
|
+
interface HookSuccessOutcome {
|
|
481
|
+
readonly status: "success";
|
|
482
|
+
readonly durationMs: number;
|
|
483
|
+
readonly rowCount?: number;
|
|
484
|
+
readonly affectedRows?: number | bigint;
|
|
485
|
+
readonly changedRows?: number | bigint;
|
|
486
|
+
readonly hasInsertId?: boolean;
|
|
487
|
+
readonly streamEnd?: HookStreamEnd;
|
|
488
|
+
}
|
|
489
|
+
/** The original failure reported after a bound-client operation rejects or throws. */
|
|
490
|
+
interface HookErrorOutcome {
|
|
491
|
+
readonly status: "error";
|
|
492
|
+
readonly durationMs: number;
|
|
493
|
+
readonly error: unknown;
|
|
494
|
+
}
|
|
495
|
+
/** Terminal observation for one bound-client operation. */
|
|
496
|
+
type HookOutcome = HookSuccessOutcome | HookErrorOutcome;
|
|
497
|
+
/** Optional completion callback returned when an operation starts. */
|
|
498
|
+
type OperationEndHook = (outcome: HookOutcome) => void;
|
|
499
|
+
/** Observational callbacks for one bound client and its transaction scopes. */
|
|
500
|
+
interface QubuHooks {
|
|
501
|
+
onOperationStart?(operation: HookOperation): OperationEndHook | void;
|
|
502
|
+
/** Receives hook failures without changing the observed operation's outcome. */
|
|
503
|
+
onHookError?(error: unknown): void;
|
|
504
|
+
}
|
|
505
|
+
/** Optional lifecycle observation configured for one bound client. */
|
|
506
|
+
interface QubuOptions {
|
|
507
|
+
readonly hooks?: QubuHooks;
|
|
440
508
|
}
|
|
441
509
|
/** One rendered statement and the controls passed to an application adapter. */
|
|
442
510
|
interface ExecutionRequest {
|
|
@@ -570,16 +638,16 @@ interface QubuStreamingTransactionalClient<TAdapter extends StreamingTransaction
|
|
|
570
638
|
transaction<T>(callback: (transaction: QubuStreamingTransaction) => Promise<T>, options?: TransactionOptions): Promise<T>;
|
|
571
639
|
}
|
|
572
640
|
/** Bind an application-owned adapter once for repeated query execution. */
|
|
573
|
-
declare function qubu<TAdapter extends ExplainableQueryAdapter & StreamingTransactionalQueryAdapter>(adapter: TAdapter): QubuExplainableStreamingTransactionalClient<TAdapter>;
|
|
574
|
-
declare function qubu<TAdapter extends ExplainableQueryAdapter & TransactionalQueryAdapter & StreamingQueryAdapter>(adapter: TAdapter): QubuExplainableTransactionalClient<TAdapter> & QubuStreamingExplainableClient<TAdapter>;
|
|
575
|
-
declare function qubu<TAdapter extends ExplainableQueryAdapter & TransactionalQueryAdapter>(adapter: TAdapter): QubuExplainableTransactionalClient<TAdapter, TransactionAdapterOf<TAdapter>>;
|
|
576
|
-
declare function qubu<TAdapter extends ExplainableQueryAdapter & StreamingQueryAdapter>(adapter: TAdapter): QubuStreamingExplainableClient<TAdapter>;
|
|
577
|
-
declare function qubu<TAdapter extends ExplainableQueryAdapter>(adapter: TAdapter): QubuExplainableClient<TAdapter>;
|
|
578
|
-
declare function qubu<TAdapter extends StreamingTransactionalQueryAdapter>(adapter: TAdapter): QubuStreamingTransactionalClient<TAdapter>;
|
|
579
|
-
declare function qubu<TAdapter extends TransactionalQueryAdapter & StreamingQueryAdapter>(adapter: TAdapter): QubuTransactionalClient<TAdapter> & QubuStreamingClient<TAdapter>;
|
|
580
|
-
declare function qubu<TAdapter extends TransactionalQueryAdapter>(adapter: TAdapter): QubuTransactionalClient<TAdapter, TransactionAdapterOf<TAdapter>>;
|
|
581
|
-
declare function qubu<TAdapter extends StreamingQueryAdapter>(adapter: TAdapter): QubuStreamingClient<TAdapter>;
|
|
582
|
-
declare function qubu<TAdapter extends QueryAdapter>(adapter: TAdapter): QubuClient<TAdapter>;
|
|
641
|
+
declare function qubu<TAdapter extends ExplainableQueryAdapter & StreamingTransactionalQueryAdapter>(adapter: TAdapter, options?: QubuOptions): QubuExplainableStreamingTransactionalClient<TAdapter>;
|
|
642
|
+
declare function qubu<TAdapter extends ExplainableQueryAdapter & TransactionalQueryAdapter & StreamingQueryAdapter>(adapter: TAdapter, options?: QubuOptions): QubuExplainableTransactionalClient<TAdapter> & QubuStreamingExplainableClient<TAdapter>;
|
|
643
|
+
declare function qubu<TAdapter extends ExplainableQueryAdapter & TransactionalQueryAdapter>(adapter: TAdapter, options?: QubuOptions): QubuExplainableTransactionalClient<TAdapter, TransactionAdapterOf<TAdapter>>;
|
|
644
|
+
declare function qubu<TAdapter extends ExplainableQueryAdapter & StreamingQueryAdapter>(adapter: TAdapter, options?: QubuOptions): QubuStreamingExplainableClient<TAdapter>;
|
|
645
|
+
declare function qubu<TAdapter extends ExplainableQueryAdapter>(adapter: TAdapter, options?: QubuOptions): QubuExplainableClient<TAdapter>;
|
|
646
|
+
declare function qubu<TAdapter extends StreamingTransactionalQueryAdapter>(adapter: TAdapter, options?: QubuOptions): QubuStreamingTransactionalClient<TAdapter>;
|
|
647
|
+
declare function qubu<TAdapter extends TransactionalQueryAdapter & StreamingQueryAdapter>(adapter: TAdapter, options?: QubuOptions): QubuTransactionalClient<TAdapter> & QubuStreamingClient<TAdapter>;
|
|
648
|
+
declare function qubu<TAdapter extends TransactionalQueryAdapter>(adapter: TAdapter, options?: QubuOptions): QubuTransactionalClient<TAdapter, TransactionAdapterOf<TAdapter>>;
|
|
649
|
+
declare function qubu<TAdapter extends StreamingQueryAdapter>(adapter: TAdapter, options?: QubuOptions): QubuStreamingClient<TAdapter>;
|
|
650
|
+
declare function qubu<TAdapter extends QueryAdapter>(adapter: TAdapter, options?: QubuOptions): QubuClient<TAdapter>;
|
|
583
651
|
interface DriverValueEncoder<TDriverValue = unknown> {
|
|
584
652
|
/** Convert one Qubu parameter into the driver's bindable representation. */
|
|
585
653
|
encode(value: unknown): TDriverValue;
|
|
@@ -750,7 +818,7 @@ interface IdentityDescriptor {
|
|
|
750
818
|
readonly dialect?: IdentityDialectExtension;
|
|
751
819
|
}
|
|
752
820
|
/** Structured failures raised while resolving column behavior metadata. */
|
|
753
|
-
type ColumnBehaviorErrorCode = "invalid-default" | "invalid-generated-column" | "invalid-identity" | "invalid-on-update" | "default-flag-conflict" | "generated-flag-conflict" | "default-generated-conflict" | "identity-generated-conflict";
|
|
821
|
+
type ColumnBehaviorErrorCode = "invalid-default" | "invalid-runtime-default" | "invalid-generated-column" | "invalid-identity" | "invalid-on-update" | "default-flag-conflict" | "generated-flag-conflict" | "default-generated-conflict" | "identity-generated-conflict" | "runtime-default-generated-conflict";
|
|
754
822
|
/** A column behavior error with a stable code and optional property path. */
|
|
755
823
|
declare class ColumnBehaviorError extends TypeError {
|
|
756
824
|
readonly code: ColumnBehaviorErrorCode;
|
|
@@ -774,8 +842,10 @@ declare function identityColumn(generation?: IdentityGeneration, options?: {
|
|
|
774
842
|
/** The normalized behavior fields attached to a column definition. */
|
|
775
843
|
interface ResolvedColumnBehavior {
|
|
776
844
|
readonly hasDefault: boolean;
|
|
845
|
+
readonly hasRuntimeDefault: boolean;
|
|
777
846
|
readonly generated: boolean;
|
|
778
847
|
readonly default?: ColumnDefault;
|
|
848
|
+
readonly defaultFn?: () => unknown;
|
|
779
849
|
readonly generatedColumn?: GeneratedColumnDescriptor;
|
|
780
850
|
readonly identity?: IdentityDescriptor;
|
|
781
851
|
readonly onUpdate?: AnySchemaExpression;
|
|
@@ -783,6 +853,7 @@ interface ResolvedColumnBehavior {
|
|
|
783
853
|
/** Normalize complete and legacy column behavior into immutable metadata. */
|
|
784
854
|
declare function resolveColumnBehavior(options: {
|
|
785
855
|
readonly hasDefault?: boolean;
|
|
856
|
+
readonly defaultFn?: () => unknown;
|
|
786
857
|
readonly generated?: boolean;
|
|
787
858
|
readonly default?: ColumnDefaultInput;
|
|
788
859
|
readonly generatedColumn?: GeneratedColumnDescriptor;
|
|
@@ -859,12 +930,19 @@ type StorageTypeOf<T> = ColumnStorageTypeOf<T>;
|
|
|
859
930
|
type StorageDialectOf<T> = ColumnStorageDialectOf<T>;
|
|
860
931
|
/** Alias for the native declaration extraction. */
|
|
861
932
|
type StorageDeclarationOf<T> = ColumnStorageDeclarationOf<T>;
|
|
862
|
-
|
|
933
|
+
/** Live conversion between one column's application and physical driver values. */
|
|
934
|
+
interface ColumnCodec<TOutput = unknown, TInsert = TOutput, TDriver = unknown> {
|
|
935
|
+
readonly toDriver: (value: TInsert) => TDriver;
|
|
936
|
+
readonly fromDriver: (value: TDriver) => TOutput;
|
|
937
|
+
}
|
|
938
|
+
interface ColumnOptions<TOutput = unknown, TInsert = TOutput> {
|
|
863
939
|
readonly nullable?: boolean;
|
|
864
940
|
readonly hasDefault?: boolean;
|
|
865
941
|
readonly generated?: boolean;
|
|
866
942
|
/** A literal, deterministic expression, or externally managed default. */
|
|
867
943
|
readonly default?: ColumnDefaultInput;
|
|
944
|
+
/** Supply an application value when an insert omits this column. */
|
|
945
|
+
readonly defaultFn?: () => TInsert;
|
|
868
946
|
/** Complete generated-column metadata, independent of identity behavior. */
|
|
869
947
|
readonly generatedColumn?: GeneratedColumnDescriptor;
|
|
870
948
|
/** Database identity metadata; identity is not an ordinary expression. */
|
|
@@ -877,13 +955,15 @@ interface ColumnOptions {
|
|
|
877
955
|
readonly storage?: ColumnStorage;
|
|
878
956
|
/** Override adapter decoding for values selected from this column. */
|
|
879
957
|
readonly decode?: ResultDecoder;
|
|
958
|
+
/** Convert values at the live application-to-driver boundary without affecting schema metadata. */
|
|
959
|
+
readonly codec?: ColumnCodec<TOutput, TInsert, unknown>;
|
|
880
960
|
/**
|
|
881
961
|
* Raw SQL target that makes a custom definition reusable with cast(). The value is emitted
|
|
882
962
|
* verbatim and must come from trusted source code.
|
|
883
963
|
*/
|
|
884
964
|
readonly castType?: string;
|
|
885
965
|
}
|
|
886
|
-
type BuiltInColumnOptions = Omit<ColumnOptions, "castType" | "storage"> & {
|
|
966
|
+
type BuiltInColumnOptions<TOutput> = Omit<ColumnOptions<TOutput, TOutput>, "castType" | "storage"> & {
|
|
887
967
|
readonly castType?: never;
|
|
888
968
|
readonly storage?: never;
|
|
889
969
|
};
|
|
@@ -899,6 +979,8 @@ interface ColumnDefinitionConfig {
|
|
|
899
979
|
readonly update?: unknown;
|
|
900
980
|
/** Whether an insert may omit the column. Defaults to `false`. */
|
|
901
981
|
readonly hasDefault?: boolean;
|
|
982
|
+
/** Whether an application runtime default can supply an omitted insert. */
|
|
983
|
+
readonly hasRuntimeDefault?: boolean;
|
|
902
984
|
/** Whether the database generates the column. Defaults to `false`. */
|
|
903
985
|
readonly generated?: boolean;
|
|
904
986
|
/** SQL semantic domain. Defaults to {@link SqlUnknown}. */
|
|
@@ -921,6 +1003,7 @@ type ColumnConfigNullable<TConfig> = ConfigBoolean<TConfig, "nullable">;
|
|
|
921
1003
|
type ColumnConfigInsert<TConfig> = ConfigValue<TConfig, "insert", ColumnConfigOutput<TConfig>>;
|
|
922
1004
|
type ColumnConfigUpdate<TConfig> = ConfigValue<TConfig, "update", ColumnConfigInsert<TConfig>>;
|
|
923
1005
|
type ColumnConfigHasDefault<TConfig> = ConfigBoolean<TConfig, "hasDefault">;
|
|
1006
|
+
type ColumnConfigHasRuntimeDefault<TConfig> = ConfigBoolean<TConfig, "hasRuntimeDefault">;
|
|
924
1007
|
type ColumnConfigGenerated<TConfig> = ConfigBoolean<TConfig, "generated">;
|
|
925
1008
|
type ColumnConfigSqlType<TConfig> = Extract<ConfigValue<TConfig, "sqlType", SqlUnknown>, AnySqlType> extends (infer TValue) ? [TValue] extends [never] ? SqlUnknown : TValue : SqlUnknown;
|
|
926
1009
|
type ColumnConfigStorage<TConfig> = ConfigValue<TConfig, "storage", undefined>;
|
|
@@ -939,6 +1022,7 @@ interface ColumnDefinition<TConfig extends ColumnDefinitionConfig = {}> {
|
|
|
939
1022
|
readonly definitionKind: "column";
|
|
940
1023
|
readonly nullable: ColumnConfigNullable<TConfig>;
|
|
941
1024
|
readonly hasDefault: ColumnConfigHasDefault<TConfig>;
|
|
1025
|
+
readonly hasRuntimeDefault: ColumnConfigHasRuntimeDefault<TConfig>;
|
|
942
1026
|
readonly generated: ColumnConfigGenerated<TConfig>;
|
|
943
1027
|
/** Complete database default metadata, when known. */
|
|
944
1028
|
readonly default?: ColumnConfigDefault<TConfig>;
|
|
@@ -953,6 +1037,12 @@ interface ColumnDefinition<TConfig extends ColumnDefinitionConfig = {}> {
|
|
|
953
1037
|
readonly storage?: ColumnConfigStorage<TConfig>;
|
|
954
1038
|
/** Runtime decoder used when this definition is projected. */
|
|
955
1039
|
readonly resultDecoder?: ResultDecoder;
|
|
1040
|
+
/** Runtime default used when an application insert omits this definition. */
|
|
1041
|
+
readonly defaultFn?: () => ColumnConfigInsert<TConfig>;
|
|
1042
|
+
/** Runtime encoder applied to application values written through this definition. */
|
|
1043
|
+
readonly parameterEncoder?: (value: ColumnConfigInsert<TConfig>) => unknown;
|
|
1044
|
+
/** Live application/driver codec available to integration adapters. */
|
|
1045
|
+
readonly columnCodec?: ColumnCodec<ColumnConfigOutput<TConfig>, ColumnConfigInsert<TConfig>, unknown>;
|
|
956
1046
|
/** Runtime CAST target when this definition can describe a cast result. */
|
|
957
1047
|
readonly castTarget?: CastTarget;
|
|
958
1048
|
readonly __output?: ColumnConfigOutput<TConfig>;
|
|
@@ -974,22 +1064,25 @@ interface ColumnDefinition<TConfig extends ColumnDefinitionConfig = {}> {
|
|
|
974
1064
|
}
|
|
975
1065
|
type Flag<T extends boolean | undefined> = T extends true ? true : false;
|
|
976
1066
|
type HasExplicitOption<TOptions, TKey extends PropertyKey> = TKey extends keyof TOptions ? {} extends Pick<TOptions, TKey> ? false : true : false;
|
|
977
|
-
type ColumnHasDefaultOption<TOptions extends ColumnOptions
|
|
978
|
-
type
|
|
1067
|
+
type ColumnHasDefaultOption<TOptions extends ColumnOptions<any, any>> = HasExplicitOption<TOptions, "default"> extends true ? true : Flag<TOptions["hasDefault"]>;
|
|
1068
|
+
type ColumnHasRuntimeDefaultOption<TOptions extends ColumnOptions<any, any>> = TOptions extends {
|
|
1069
|
+
readonly defaultFn: () => unknown;
|
|
1070
|
+
} ? true : false;
|
|
1071
|
+
type ColumnIsGeneratedOption<TOptions extends ColumnOptions<any, any>> = TOptions extends {
|
|
979
1072
|
readonly generatedColumn: GeneratedColumnDescriptor;
|
|
980
1073
|
} ? true : TOptions extends {
|
|
981
1074
|
readonly identity: IdentityDescriptor;
|
|
982
1075
|
} ? true : Flag<TOptions["generated"]>;
|
|
983
|
-
type ColumnDefaultOption<TOptions extends ColumnOptions
|
|
1076
|
+
type ColumnDefaultOption<TOptions extends ColumnOptions<any, any>> = HasExplicitOption<TOptions, "default"> extends true ? TOptions extends {
|
|
984
1077
|
readonly default: infer TDefault;
|
|
985
1078
|
} ? TDefault extends AnySchemaExpression ? ExpressionDefaultDescriptor<TDefault> : TDefault extends ExternalDefaultDescriptor ? TDefault : TDefault extends SchemaLiteralValue ? LiteralDefaultDescriptor : never : never : TOptions["hasDefault"] extends true ? ExternalDefaultDescriptor : undefined;
|
|
986
|
-
type ColumnGeneratedOption<TOptions extends ColumnOptions
|
|
1079
|
+
type ColumnGeneratedOption<TOptions extends ColumnOptions<any, any>> = TOptions extends {
|
|
987
1080
|
readonly generatedColumn: infer TGenerated extends GeneratedColumnDescriptor;
|
|
988
1081
|
} ? TGenerated : TOptions["generated"] extends true ? ExternalGeneratedColumnDescriptor : undefined;
|
|
989
|
-
type ColumnIdentityOption<TOptions extends ColumnOptions
|
|
1082
|
+
type ColumnIdentityOption<TOptions extends ColumnOptions<any, any>> = TOptions extends {
|
|
990
1083
|
readonly identity: infer TIdentity extends IdentityDescriptor;
|
|
991
1084
|
} ? TIdentity : undefined;
|
|
992
|
-
type ColumnOnUpdateOption<TOptions extends ColumnOptions
|
|
1085
|
+
type ColumnOnUpdateOption<TOptions extends ColumnOptions<any, any>> = TOptions extends {
|
|
993
1086
|
readonly onUpdate: infer TOnUpdate extends AnySchemaExpression;
|
|
994
1087
|
} ? TOnUpdate : undefined;
|
|
995
1088
|
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
@@ -1004,19 +1097,19 @@ type ColumnValueConfig<TOutput, TInsert, TUpdate> = {
|
|
|
1004
1097
|
});
|
|
1005
1098
|
type TrueConfig<TKey extends PropertyKey, TValue> = TValue extends true ? { readonly [TField in TKey]: true; } : {};
|
|
1006
1099
|
type DefinedConfig<TKey extends PropertyKey, TValue> = [TValue] extends [undefined] ? {} : { readonly [TField in TKey]: TValue; };
|
|
1007
|
-
type ColumnOptionConfig<TOptions extends ColumnOptions
|
|
1100
|
+
type ColumnOptionConfig<TOptions extends ColumnOptions<any, any>> = Simplify$1<TrueConfig<"nullable", Flag<TOptions["nullable"]>> & TrueConfig<"hasDefault", ColumnHasDefaultOption<TOptions>> & TrueConfig<"hasRuntimeDefault", ColumnHasRuntimeDefaultOption<TOptions>> & TrueConfig<"generated", ColumnIsGeneratedOption<TOptions>> & DefinedConfig<"default", ColumnDefaultOption<TOptions>> & DefinedConfig<"generatedColumn", ColumnGeneratedOption<TOptions>> & DefinedConfig<"identity", ColumnIdentityOption<TOptions>> & DefinedConfig<"onUpdate", ColumnOnUpdateOption<TOptions>> & (TOptions extends {
|
|
1008
1101
|
readonly storage: infer TStorage extends ColumnStorage;
|
|
1009
1102
|
} ? {
|
|
1010
1103
|
readonly storage: TStorage;
|
|
1011
1104
|
} : {})>;
|
|
1012
|
-
type BuiltInColumnDefinition<TOutput, TSqlType extends AnySqlType, TStorageType extends PortableStorageType, TCastType extends PortableCastType, TOptions extends BuiltInColumnOptions
|
|
1105
|
+
type BuiltInColumnDefinition<TOutput, TSqlType extends AnySqlType, TStorageType extends PortableStorageType, TCastType extends PortableCastType, TOptions extends BuiltInColumnOptions<TOutput>> = ColumnDefinition<Simplify$1<{
|
|
1013
1106
|
readonly output: TOutput;
|
|
1014
1107
|
readonly sqlType: TSqlType;
|
|
1015
1108
|
readonly storage: PortableColumnStorage<TStorageType>;
|
|
1016
1109
|
} & ColumnOptionConfig<TOptions>>> & {
|
|
1017
1110
|
readonly castTarget: PortableCastTarget<TCastType>;
|
|
1018
1111
|
};
|
|
1019
|
-
type ColumnFromOptions<TOutput, TInsert, TUpdate, TOptions extends ColumnOptions, TSqlType extends AnySqlType = SqlUnknown> = ColumnDefinition<Simplify$1<ColumnValueConfig<TOutput, TInsert, TUpdate> & {
|
|
1112
|
+
type ColumnFromOptions<TOutput, TInsert, TUpdate, TOptions extends ColumnOptions<TOutput, TInsert>, TSqlType extends AnySqlType = SqlUnknown> = ColumnDefinition<Simplify$1<ColumnValueConfig<TOutput, TInsert, TUpdate> & {
|
|
1020
1113
|
readonly sqlType: TSqlType;
|
|
1021
1114
|
} & ColumnOptionConfig<TOptions>>> & (TOptions extends {
|
|
1022
1115
|
readonly castType: string;
|
|
@@ -1038,6 +1131,10 @@ type ColumnUpdateInput<T> = T extends {
|
|
|
1038
1131
|
type ColumnHasDefault<T> = T extends {
|
|
1039
1132
|
readonly hasDefault: infer THasDefault extends boolean;
|
|
1040
1133
|
} ? THasDefault : false;
|
|
1134
|
+
/** Whether an omitted application insert can be supplied at runtime. */
|
|
1135
|
+
type ColumnHasRuntimeDefault<T> = T extends {
|
|
1136
|
+
readonly hasRuntimeDefault: infer THasRuntimeDefault extends boolean;
|
|
1137
|
+
} ? THasRuntimeDefault : false;
|
|
1041
1138
|
type ColumnIsGenerated<T> = T extends {
|
|
1042
1139
|
readonly generated: infer TGenerated extends boolean;
|
|
1043
1140
|
} ? TGenerated : false;
|
|
@@ -1076,7 +1173,7 @@ type AnyColumnDefinition = ColumnDefinition<any>;
|
|
|
1076
1173
|
type NamedCastColumn<TDefinition extends AnyColumnDefinition> = TDefinition & {
|
|
1077
1174
|
readonly castTarget: NamedCastTarget;
|
|
1078
1175
|
};
|
|
1079
|
-
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, TSqlType extends AnySqlType = SqlUnknown, const TStorage extends ColumnStorage = ColumnStorage, const TOptions extends Omit<ColumnOptions, "storage"> = Omit<ColumnOptions, "storage">>(options: TOptions & {
|
|
1176
|
+
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, TSqlType extends AnySqlType = SqlUnknown, const TStorage extends ColumnStorage = ColumnStorage, const TOptions extends Omit<ColumnOptions<TOutput, TInsert>, "storage"> = Omit<ColumnOptions<TOutput, TInsert>, "storage">>(options: TOptions & {
|
|
1080
1177
|
readonly storage: TStorage;
|
|
1081
1178
|
}): ColumnFromOptions<TOutput, TInsert, TUpdate, TOptions & {
|
|
1082
1179
|
readonly storage: TStorage;
|
|
@@ -1165,17 +1262,21 @@ declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert,
|
|
|
1165
1262
|
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, TSqlType extends AnySqlType = SqlUnknown>(options?: FalseColumnOptions): ColumnDefinition<Simplify$1<ColumnValueConfig<TOutput, TInsert, TUpdate> & {
|
|
1166
1263
|
readonly sqlType: TSqlType;
|
|
1167
1264
|
}>>;
|
|
1168
|
-
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, TSqlType extends AnySqlType = SqlUnknown, const TOptions extends ColumnOptions = {}>(options?: TOptions): ColumnFromOptions<TOutput, TInsert, TUpdate, TOptions, TSqlType>;
|
|
1169
|
-
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, const TOptions extends ColumnOptions = {}, TSqlType extends AnySqlType = SqlUnknown>(options?: TOptions): ColumnFromOptions<TOutput, TInsert, TUpdate, TOptions, TSqlType>;
|
|
1265
|
+
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, TSqlType extends AnySqlType = SqlUnknown, const TOptions extends ColumnOptions<TOutput, TInsert> = {}>(options?: TOptions): ColumnFromOptions<TOutput, TInsert, TUpdate, TOptions, TSqlType>;
|
|
1266
|
+
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, const TOptions extends ColumnOptions<TOutput, TInsert> = {}, TSqlType extends AnySqlType = SqlUnknown>(options?: TOptions): ColumnFromOptions<TOutput, TInsert, TUpdate, TOptions, TSqlType>;
|
|
1170
1267
|
/** Resolve the runtime result metadata carried by a column definition. */
|
|
1171
1268
|
declare function columnResultValue(definition: {
|
|
1172
1269
|
readonly storage?: ColumnStorage;
|
|
1173
1270
|
readonly resultDecoder?: ResultDecoder;
|
|
1174
1271
|
}): ResultValueMetadata | undefined;
|
|
1175
|
-
|
|
1272
|
+
/** Apply a live column codec while preserving SQL NULL unchanged. */
|
|
1273
|
+
declare function encodeColumnParameter(definition: {
|
|
1274
|
+
readonly parameterEncoder?: (value: any) => unknown;
|
|
1275
|
+
}, value: unknown): unknown;
|
|
1276
|
+
type NativeColumnOptions<TOutput, TInsert> = Omit<ColumnOptions<TOutput, TInsert>, "storage"> & {
|
|
1176
1277
|
readonly storage?: never;
|
|
1177
1278
|
};
|
|
1178
|
-
type NativeColumnFromOptions<TOutput, TInsert, TUpdate, TOptions extends NativeColumnOptions, TSqlType extends AnySqlType, TDialect extends string, TDeclaration extends string> = ColumnDefinition<Simplify$1<ColumnValueConfig<TOutput, TInsert, TUpdate> & {
|
|
1279
|
+
type NativeColumnFromOptions<TOutput, TInsert, TUpdate, TOptions extends NativeColumnOptions<TOutput, TInsert>, TSqlType extends AnySqlType, TDialect extends string, TDeclaration extends string> = ColumnDefinition<Simplify$1<ColumnValueConfig<TOutput, TInsert, TUpdate> & {
|
|
1179
1280
|
readonly sqlType: TSqlType;
|
|
1180
1281
|
} & ColumnOptionConfig<TOptions> & {
|
|
1181
1282
|
readonly storage: NativeColumnStorage<TDialect, TDeclaration>;
|
|
@@ -1185,22 +1286,22 @@ type NativeColumnFromOptions<TOutput, TInsert, TUpdate, TOptions extends NativeC
|
|
|
1185
1286
|
readonly castTarget: NamedCastTarget;
|
|
1186
1287
|
} : unknown);
|
|
1187
1288
|
/** Create a column whose physical declaration belongs to one SQL dialect. */
|
|
1188
|
-
declare function nativeColumn<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, const TOptions extends NativeColumnOptions = {}, TSqlType extends AnySqlType = SqlUnknown, const TDialect extends string = string, const TDeclaration extends string = string>(storage: NativeColumnStorage<TDialect, TDeclaration>, options?: TOptions): NativeColumnFromOptions<TOutput, TInsert, TUpdate, TOptions, TSqlType, TDialect, TDeclaration>;
|
|
1289
|
+
declare function nativeColumn<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, const TOptions extends NativeColumnOptions<TOutput, TInsert> = {}, TSqlType extends AnySqlType = SqlUnknown, const TDialect extends string = string, const TDeclaration extends string = string>(storage: NativeColumnStorage<TDialect, TDeclaration>, options?: TOptions): NativeColumnFromOptions<TOutput, TInsert, TUpdate, TOptions, TSqlType, TDialect, TDeclaration>;
|
|
1189
1290
|
/** Create a dialect-native column from an adapter name and exact declaration. */
|
|
1190
|
-
declare function nativeColumn<const TDialect extends string, const TDeclaration extends string, TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, const TOptions extends NativeColumnOptions = {}, TSqlType extends AnySqlType = SqlUnknown>(dialect: TDialect, type: TDeclaration, options?: TOptions): NativeColumnFromOptions<TOutput, TInsert, TUpdate, TOptions, TSqlType, TDialect, TDeclaration>;
|
|
1291
|
+
declare function nativeColumn<const TDialect extends string, const TDeclaration extends string, TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, const TOptions extends NativeColumnOptions<TOutput, TInsert> = {}, TSqlType extends AnySqlType = SqlUnknown>(dialect: TDialect, type: TDeclaration, options?: TOptions): NativeColumnFromOptions<TOutput, TInsert, TUpdate, TOptions, TSqlType, TDialect, TDeclaration>;
|
|
1191
1292
|
declare function nullable<TConfig extends ColumnDefinitionConfig>(definition: ColumnDefinition<TConfig>): ColumnDefinition<Simplify$1<Omit<TConfig, "nullable"> & {
|
|
1192
1293
|
readonly nullable: true;
|
|
1193
1294
|
}>>;
|
|
1194
|
-
declare function integer<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): BuiltInColumnDefinition<number, SqlInteger, "integer", "integer", TOptions>;
|
|
1195
|
-
declare function numeric<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): BuiltInColumnDefinition<number, SqlDecimal, "numeric", "decimal", TOptions>;
|
|
1196
|
-
declare function text<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): BuiltInColumnDefinition<string, SqlText, "text", "text", TOptions>;
|
|
1197
|
-
declare function boolean<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): BuiltInColumnDefinition<boolean, SqlBoolean, "boolean", "boolean", TOptions>;
|
|
1198
|
-
declare function date<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): BuiltInColumnDefinition<Date, SqlDate, "date", "date", TOptions>;
|
|
1199
|
-
declare function timestamp<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): BuiltInColumnDefinition<Date, SqlTimestamp, "timestamp", "timestamp", TOptions>;
|
|
1200
|
-
declare function uuid<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): BuiltInColumnDefinition<string, SqlUuid, "uuid", "uuid", TOptions>;
|
|
1201
|
-
declare function json<TOutput = unknown, const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): BuiltInColumnDefinition<TOutput, SqlJson<TOutput>, "json", "json", TOptions>;
|
|
1202
|
-
declare function bigint<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): BuiltInColumnDefinition<bigint, SqlBigInt, "bigint", "bigint", TOptions>;
|
|
1203
|
-
declare function binary<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): BuiltInColumnDefinition<Uint8Array, SqlBinary, "binary", "binary", TOptions>;
|
|
1295
|
+
declare function integer<const TOptions extends BuiltInColumnOptions<number> = {}>(options?: TOptions): BuiltInColumnDefinition<number, SqlInteger, "integer", "integer", TOptions>;
|
|
1296
|
+
declare function numeric<const TOptions extends BuiltInColumnOptions<number> = {}>(options?: TOptions): BuiltInColumnDefinition<number, SqlDecimal, "numeric", "decimal", TOptions>;
|
|
1297
|
+
declare function text<const TOptions extends BuiltInColumnOptions<string> = {}>(options?: TOptions): BuiltInColumnDefinition<string, SqlText, "text", "text", TOptions>;
|
|
1298
|
+
declare function boolean<const TOptions extends BuiltInColumnOptions<boolean> = {}>(options?: TOptions): BuiltInColumnDefinition<boolean, SqlBoolean, "boolean", "boolean", TOptions>;
|
|
1299
|
+
declare function date<const TOptions extends BuiltInColumnOptions<Date> = {}>(options?: TOptions): BuiltInColumnDefinition<Date, SqlDate, "date", "date", TOptions>;
|
|
1300
|
+
declare function timestamp<const TOptions extends BuiltInColumnOptions<Date> = {}>(options?: TOptions): BuiltInColumnDefinition<Date, SqlTimestamp, "timestamp", "timestamp", TOptions>;
|
|
1301
|
+
declare function uuid<const TOptions extends BuiltInColumnOptions<string> = {}>(options?: TOptions): BuiltInColumnDefinition<string, SqlUuid, "uuid", "uuid", TOptions>;
|
|
1302
|
+
declare function json<TOutput = unknown, const TOptions extends BuiltInColumnOptions<TOutput> = {}>(options?: TOptions): BuiltInColumnDefinition<TOutput, SqlJson<TOutput>, "json", "json", TOptions>;
|
|
1303
|
+
declare function bigint<const TOptions extends BuiltInColumnOptions<bigint> = {}>(options?: TOptions): BuiltInColumnDefinition<bigint, SqlBigInt, "bigint", "bigint", TOptions>;
|
|
1304
|
+
declare function binary<const TOptions extends BuiltInColumnOptions<Uint8Array> = {}>(options?: TOptions): BuiltInColumnDefinition<Uint8Array, SqlBinary, "binary", "binary", TOptions>;
|
|
1204
1305
|
//#endregion
|
|
1205
1306
|
//#region src/expressions/cast.d.ts
|
|
1206
1307
|
type CastDefinition = ColumnDefinition<any> & {
|
|
@@ -3493,8 +3594,12 @@ type InsertRow<TTable extends AnyTable> = TableInsertInput<TTable["definitions"]
|
|
|
3493
3594
|
type InvalidInsertRow<TTable extends AnyTable, TRow> = TRow extends InsertRow<TTable> ? Exclude<keyof TRow, keyof InsertRow<TTable>> extends never ? unknown : QueryTypeValidation<"invalid-insert", "insert.values.columns", "Use only columns declared by the insert table.", Exclude<keyof TRow, keyof InsertRow<TTable>>> : QueryTypeValidation<"invalid-insert", "insert.values.row", "Provide values matching the insert table columns.", TRow>;
|
|
3494
3595
|
type ValidInsertSource<TTable extends AnyTable, TSource extends InsertSource> = TSource extends ValuesSource<infer TRows> ? TRows[number] extends (infer TRow) ? InvalidInsertRow<TTable, TRow> : never : TSource extends DefaultValuesSource ? Exclude<keyof TTable["definitions"], { [K in keyof TTable["definitions"]]-?: ColumnIsGenerated<TTable["definitions"][K]> extends true ? K : TTable["definitions"][K] extends {
|
|
3495
3596
|
hasDefault: true;
|
|
3597
|
+
} | {
|
|
3598
|
+
hasRuntimeDefault: true;
|
|
3496
3599
|
} ? K : never; }[keyof TTable["definitions"]]> extends never ? unknown : QueryTypeValidation<"invalid-insert", "insert.default-values", "Provide values for required columns or define defaults for them.", Exclude<keyof TTable["definitions"], { [K in keyof TTable["definitions"]]-?: ColumnIsGenerated<TTable["definitions"][K]> extends true ? K : TTable["definitions"][K] extends {
|
|
3497
3600
|
hasDefault: true;
|
|
3601
|
+
} | {
|
|
3602
|
+
hasRuntimeDefault: true;
|
|
3498
3603
|
} ? K : never; }[keyof TTable["definitions"]]>> : TSource extends InsertSelectSource<any, infer TColumns> ? Exclude<TColumns[number], keyof TTable["definitions"]> extends never ? Exclude<{ [K in keyof TTable["definitions"]]-?: ColumnIsGenerated<TTable["definitions"][K]> extends true ? never : ColumnHasDefault<TTable["definitions"][K]> extends true ? never : K; }[keyof TTable["definitions"]], TColumns[number]> extends never ? unknown : QueryTypeValidation<"invalid-insert", "insert.select.columns", "Include every required insert column in the target list.", Exclude<{ [K in keyof TTable["definitions"]]-?: ColumnIsGenerated<TTable["definitions"][K]> extends true ? never : ColumnHasDefault<TTable["definitions"][K]> extends true ? never : K; }[keyof TTable["definitions"]], TColumns[number]>> : QueryTypeValidation<"invalid-insert", "insert.select.columns", "Use only columns declared by the insert table.", Exclude<TColumns[number], keyof TTable["definitions"]>> : never;
|
|
3499
3604
|
declare function insertInto<const TTable extends AnyTable, const TSource extends InsertSource, const TClauses extends readonly InsertClause[]>(table: TTable, source: TSource & ValidInsertSource<TTable, TSource>, ...clauses: TClauses & MutationScopeValidation<TTable, TClauses>): MutationQuery<{
|
|
3500
3605
|
readonly row: MutationRow<TClauses>;
|
|
@@ -3556,7 +3661,7 @@ type AnyTable = Source<any> & {
|
|
|
3556
3661
|
type TableRow<TDefinitions extends TableDefinitions> = { -readonly [K in keyof TDefinitions]: ColumnOutput<TDefinitions[K]>; };
|
|
3557
3662
|
/** SQL semantic domains derived from a table's column definitions. */
|
|
3558
3663
|
type TableSqlTypes<TDefinitions extends TableDefinitions> = { readonly [K in keyof TDefinitions]: ColumnSqlType<TDefinitions[K]>; };
|
|
3559
|
-
type RequiredInsertKeys<TDefinitions extends TableDefinitions> = { [K in keyof TDefinitions]-?: ColumnHasDefault<TDefinitions[K]> extends true ? never : ColumnIsGenerated<TDefinitions[K]> extends true ? never : K; }[keyof TDefinitions];
|
|
3664
|
+
type RequiredInsertKeys<TDefinitions extends TableDefinitions> = { [K in keyof TDefinitions]-?: ColumnHasDefault<TDefinitions[K]> extends true ? never : ColumnHasRuntimeDefault<TDefinitions[K]> extends true ? never : ColumnIsGenerated<TDefinitions[K]> extends true ? never : K; }[keyof TDefinitions];
|
|
3560
3665
|
type OptionalInsertKeys<TDefinitions extends TableDefinitions> = Exclude<keyof TDefinitions, RequiredInsertKeys<TDefinitions>>;
|
|
3561
3666
|
type TableInsertInput<TDefinitions extends TableDefinitions> = { -readonly [K in RequiredInsertKeys<TDefinitions>]: ColumnInsertInput<TDefinitions[K]>; } & { -readonly [K in OptionalInsertKeys<TDefinitions>]?: ColumnInsertInput<TDefinitions[K]>; };
|
|
3562
3667
|
type TableUpdateInput<TDefinitions extends TableDefinitions> = { -readonly [K in keyof TDefinitions as ColumnIsGenerated<TDefinitions[K]> extends true ? never : K]?: ColumnUpdateInput<TDefinitions[K]>; };
|
|
@@ -4144,4 +4249,4 @@ type SchemaSnapshotInput = SchemaSnapshot | Readonly<Record<string, unknown>>;
|
|
|
4144
4249
|
/** Expose the schema generic in tooling declarations without widening APIs. */
|
|
4145
4250
|
type AnySchema = Schema<any>;
|
|
4146
4251
|
//#endregion
|
|
4147
|
-
export { PaginationKind as $, SqlTag as $a, RenderCapabilityValidation as $c, SourceIndexesRecord as $i, InheritedMetadata as $l, WithClause as $n, ColumnStorageOf as $o, generatedTableName as $r, canonicalLiteral as $s, nullsLast as $t, SnapshotStorage as A, jsonBoolean as Aa, ExplainableQueryAdapter as Ac, catalogCheck as Ai, ResultField as Al, MutationReturningClause as An, value as Ao, SchemaExpressionErrorCode as Ar, timestamp as As, SourceSqlTypeMap as At, SqlBoolean as Au, CastTarget as B, concat as Ba, QubuTransactionalClient as Bc, AliasedSource as Bi, CapabilityMetadataOf as Bl, select as Bn, ColumnIdentityOf as Bo, renderSchemaSql as Br, ExternalDefaultDescriptor as Bs, TableDefinitions as Bt, SqlSemanticType as Bu, SnapshotIndexTerm as C, SelectClause as Ca, ExplainMutationOptions as Cc, SourceConstraintsRecord as Ci, markExpressionCategory as Cl, update as Cn, isTrue as Co, SelectionSqlTypes as Cr, json as Cs, SourceColumns as Ct, fragment as Cu, SnapshotLiteral as D, multiply as Da, ExplainReadOptions as Dc, UniqueConstraint as Di, ResultDecoder as Dl, MutationQuery as Dn, SqlCapabilityValidation as Do, createSchemaDialect as Dr, numeric as Ds, SourceKind as Dt, AnySqlType as Du, SnapshotKeyConstraint as E, modulo as Ea, ExplainPlanRow as Ec, TableLike as Ei, ResultDecodeContext as El, MutationKind as En, OperandSqlType as Eo, SchemaDialectHooks as Er, nullable as Es, SourceIdentity as Et, sequence as Eu, neutralSnapshotDialect as F, denseRank as Fa, QubuStreamingClient as Fc, references as Fi, timestampResultDecoder as Fl, ReturningClause as Fn, ColumnDefinition as Fo, UnsafeSchemaSqlExpression as Fr, ColumnDefault as Fs, exposeColumns as Ft, SqlInteger as Fu, DialectJson as G, typedCall as Ga, StreamingTransactionalQueryAdapter as Gc, alias as Gi, Fragment as Gl, MissingScope as Gn, ColumnOptions as Go, SchemaNamingPolicy as Gr, IdentityDescriptor as Gs, TableRow as Gt, SqlUnknown as Gu, DialectCapability as H, upper as Ha, QueryExecutor as Hc, LateralSource as Hi, CardinalityOf as Hl, AvailableScope as Hn, ColumnIsGenerated as Ho, unsafeSchemaSql as Hr, GeneratedColumnDescriptor as Hs, TableInsertInput as Ht, SqlTextLike as Hu, schemaSnapshotDialectVersion as I, over as Ia, QubuStreamingExplainableClient as Ic, unique as Ii, AggregateDependenciesOf as Il, ReturningRow as In, ColumnDefinitionConfig as Io, defineSchemaExpression as Ir, ColumnDefaultInput as Is, sourceIdentity as It, SqlJson as Iu, DialectRowLocking as J, countDistinct as Ja, execute as Jc, IndexOptions as Ji, GroupingKeysOf as Jl, ScopeValidation as Jn, ColumnStorage as Jo, SchemaTableNames as Jr, LiteralDefaultDescriptor as Js, table as Jt, DialectOptions as K, avg as Ka, TransactionOptions as Kc, lateral as Ki, FragmentMeta as Kl, RequiredOuterScope as Kn, ColumnOutput as Ko, SchemaOptions as Kr, IdentityDialectExtension as Ks, TableSqlTypes as Kt, SqlUuid as Ku, schemaSnapshotFormat as L, rank as La, QubuStreamingTransaction as Lc, uniqueConstraint as Li, AggregateMeta as Ll, ReturningSqlTypes as Ln, ColumnFromOptions as Lo, isUnsafeSchemaSql as Lr, DefaultDescriptor as Ls, AnyTable as Lt, SqlNumericLike as Lu, SnapshotTable as M, jsonNumber as Ma, QubuExplainableClient as Mc, check as Mi, booleanResultDecoder as Ml, MutationScopeValidation as Mn, cast as Mo, SchemaExpressionMode as Mr, CanonicalLiteral as Ms, UnknownSourceSqlTypes as Mt, SqlDecimal as Mu, SnapshotUniqueConstraint as N, jsonPath as Na, QubuExplainableStreamingTransactionalClient as Nc, foreignKey as Ni, dateResultDecoder as Nl, MutationSqlTypes as Nn, typedCast as No, SchemaRenderContext as Nr, ColumnBehaviorError as Ns, createSource as Nt, SqlEqualityComparable as Nu, SnapshotNamingPolicy as O, subtract as Oa, ExplainRequest as Oc, UniqueConstraintOptions as Oi, ResultDecoders as Ol, MutationQueryConfig as On, asValue as Oo, RenderedSchemaExpression as Or, portableStorage as Os, SourceProvision as Ot, SqlBigInt as Ou, SnapshotValidationContext as P, jsonText as Pa, QubuExplainableTransactionalClient as Pc, primaryKey as Pi, jsonTextResultDecoder as Pl, allowAll as Pn, ColumnDefaultOf as Po, SchemaRenderOptions as Pr, ColumnBehaviorErrorCode as Ps, customSource as Pt, SqlEqualityCompatible as Pu, NamedCastTarget as Q, SqlFragment as Qa, stream as Qc, SourceIndex as Qi, HasWindow as Ql, RecursiveCteSource as Qn, ColumnStorageKindOf as Qo, defaultSchemaNamingPolicy as Qr, SqliteIdentityExtension as Qs, nullsFirst as Qt, schemaSnapshotNamingPolicyVersion as R, rowNumber as Ra, QubuStreamingTransactionalClient as Rc, validateConstraintDialect as Ri, AnyFragment as Rl, returning as Rn, ColumnGeneratedOf as Ro, normalizeSchemaSql as Rr, ExpressionDefaultDescriptor as Rs, Table as Rt, SqlOrderCompatible as Ru, SnapshotIndex as S, ClausePlacement as Sa, ExecutionResult as Sc, SourceConstraint as Si, makeExpression as Sl, UpdateAssignments as Sn, isNull as So, SelectionOutput as Sr, integer as Ss, Source as St, WindowMeta as Su, SnapshotJsonValue as T, divide as Ta, ExplainOptionsFor as Tc, SqliteConstraintExtension as Ti, DecodableResultType as Tl, MutationClause as Tn, OperandNullability as To, SchemaDialect as Tr, nativeStorage as Ts, SourceConstraints as Tt, parenthesize as Tu, DialectCastTypes as U, call as Ua, StreamableQuery as Uc, QueryAliasIdentity as Ui, DependenciesOf as Ul, ClauseScope as Un, ColumnIsNullable as Uo, Schema as Ur, GeneratedColumnMode as Us, TableMetadataCallback as Ut, SqlTimestamp as Uu, Dialect as V, lower as Va, QueryAdapter as Vc, LateralIdentity as Vi, CardinalityMeta as Vl, AvailableOuterScope as Vn, ColumnInsertInput as Vo, schemaExpression as Vr, ExternalGeneratedColumnDescriptor as Vs, TableIdentity as Vt, SqlText as Vu, DialectExplain as W, schemaCall as Wa, StreamingQueryAdapter as Wc, QuerySource as Wi, ExpressionMeta as Wl, GroupingValidation as Wn, ColumnOnUpdateOf as Wo, SchemaDiagnostic as Wr, GeneratedDescriptor as Ws, TableOptions as Wt, SqlTypeSatisfies as Wu, ExplainRenderOptions as X, min as Xa, explain as Xc, MysqlIndexExtension as Xi, HasAggregate as Xl, SelectQuery as Xn, ColumnStorageDescriptor as Xo, SchemaTableRegistry as Xr, ResolvedColumnBehavior as Xs, asc as Xt, ExplainFormat as Y, max as Ya, executeRows as Yc, IndexTerm as Yi, GroupingMeta as Yl, SelectCardinality as Yn, ColumnStorageDeclarationOf as Yo, SchemaTableRecord as Yr, MysqlIdentityExtension as Ys, OrderTerm as Yt, JsonScalarKind as Z, sum as Za, qubu as Zc, PostgresIndexExtension as Zi, HasSubquery as Zl, CteSource as Zn, ColumnStorageDialectOf as Zo, SchemaValidationError as Zr, SchemaLiteralValue as Zs, desc as Zt, SnapshotExpressionContext as _, fetchNext as _a, materializeSchemaObjectRecord as _c, KeyConstraint as _i, ExpressionSqlType as _l, doNothing as _n, notLike as _o, FromScope as _r, binary as _s, AnySource as _t, RequiresSourceMeta as _u, SnapshotBigInt as a, and as aa, SchemaDialectExtension as ac, CheckConstraint as ai, QueryValidationErrorCode as al, InsertSource as an, notExists as ao, except as ar, NativeStorage as as, SchemaLiteralRenderer as at, OutputOf as au, SnapshotGeneratedColumn as b, distinct as ba, ExecutionOptions as bc, PostgresConstraintExtension as bi, SchemaExpressionBrand as bl, onConflict as bn, notIn as bo, Selection as br, columnResultValue as bs, ProvidedSourceIdentity as bt, SubqueryMeta as bu, SnapshotConstraint as c, Omit$1 as ca, SchemaMetadataValidationError as cc, ConstraintOptions as ci, ColumnReference as cl, insertInto as cn, eq as co, unionAll as cr, PortableStorage as cs, resolveCastTarget as ct, ProvidesSourceMeta as cu, SnapshotDefault as d, omit as da, assertSchemaDialectSupport as dc, FieldLikeOptions as di, AnySchemaExpression as dl, ConflictAction as dn, isDistinctFrom as do, innerJoin as dr, StorageDeclarationOf as ds, QueryConfig as dt, RenderFunction as du, SqliteIndexExtension as ea, externalDefault as ec, schema as ei, RenderOptions as el, order as en, TypedSqlTag as eo, cte as er, ColumnStorageType as es, PaginationPart as et, InheritedMetadataOf as eu, SnapshotDiagnostic as f, where as fa, dialectMismatchDiagnostic as fc, ForeignKeyConstraint as fi, Expression as fl, ConflictTarget as fn, isNotDistinctFrom as fo, leftJoin as fr, StorageDescriptor as fs, QueryKind as ft, RequiresCapabilityMeta as fu, SnapshotExpression as g, fetchFirst as ga, materializeSchemaObjectIdentity as gc, ForeignKeyTargetInput as gi, ExpressionRequires as gl, OnConflictClause as gn, ne as go, FromClause as gr, bigint as gs, Row as gt, RequiresOuterSourceMeta as gu, SnapshotDialectExtension as h, rowLock as ha, isValidSchemaObjectName as hc, ForeignKeyTarget as hi, ExpressionOutput as hl, ExcludedSource as hn, lte as ho, groupBy as hr, StorageTypeOf as hs, QueryWithRow as ht, RequiresOuterOf as hu, SchemaSnapshotInput as i, DeclaredColumnNullability as ia, resolveColumnBehavior as ic, CatalogCheckSql as ii, QueryValidationError as il, InsertSelectSource as in, inQuery as io, SetQuery as ir, NativeColumnStorage as is, RowLockWaitPolicy as it, NullableSourcesOf as iu, SnapshotStorageContext as j, jsonExists as ja, QubuClient as jc, catalogForeignKey as ji, ResultShape as jl, MutationRow as jn, mapResult as jo, SchemaExpressionInput as jr, uuid as js, SourceSqlTypes as jt, SqlDate as ju, SnapshotSpecialNumber as k, JsonPath as ka, ExplainResult as kc, UniqueNullSemantics as ki, ResultDecodingError as kl, MutationReturning as kn, typedValue as ko, SchemaExpressionError as kr, text as ks, SourceRow as kt, SqlBinary as ku, SnapshotCreateResult as l, OmittableSelectClause as la, SchemaObjectIdentity as lc, ConstraintTiming as li, expressionFragment as ll, insertSelect as ln, gt as lo, crossJoin as lr, PortableStorageDescriptor as ls, AnyQuery as lt, QueryCardinality as lu, SnapshotDialect as m, RowLockOptions as ma, generatedSchemaObjectName as mc, ForeignKeyOptions as mi, ExpressionNullability as ml, DoUpdateAction as mn, lt as mo, rightJoin as mr, StorageOf as ms, QuerySqlTypeMap as mt, RequiresOuterMetadataOf as mu, SchemaSnapshot as n, index as na, generatedColumn as nc, AnyKeyColumn as ni, render as nl, deleteFrom as nn, caseWhen as no, withCte as nr, ColumnUpdateInput as ns, PortableCastType as nt, NullabilityOf as nu, SnapshotCheckConstraint as o, not as oa, SchemaDialectName as oc, CheckConstraintOptions as oi, QueryValidationIssue as ol, ValuesSource as on, scalar as oo, intersect as or, NativeStorageDescriptor as os, assertDialectCapability as ot, ProvidesOuterOf as ou, SnapshotDiagnosticCode as p, RowLockClause as pa, freezeSchemaMetadata as pc, ForeignKeyMatch as pi, ExpressionKind as pl, DoNothingAction as pn, like as po, naturalJoin as pr, StorageDialectOf as ps, QueryRow as pt, RequiresOf as pu, DialectPagination as q, count as qa, TransactionalQueryAdapter as qc, IndexDialectExtension as qi, GroupingDependenciesOf as ql, RequiredScope as qn, ColumnSqlType as qo, SchemaTableEntry as qr, IdentityGeneration as qs, TableUpdateInput as qt, SchemaSnapshotAdapter as r, validateIndexDialect as ra, identityColumn as rc, CatalogCheckExpression as ri, QueryTypeValidation as rl, DefaultValuesSource as rn, exists as ro, SetOperator as rr, DialectNativeStorage as rs, RowLockMode as rt, NullableSourceMeta as ru, SnapshotColumn as s, or as sa, SchemaMetadataDiagnostic as sc, ConstraintDialectExtension as si, ColumnDependency as sl, defaultValues as sn, ComparisonValidation as so, union as sr, PortableColumnStorage as ss, createDialect as st, ProvidesOuterSourceMeta as su, AnySchema as t, TableIndex as ta, externalGeneratedColumn as tc, schemaNamingPolicyVersion as ti, RenderedQuery as tl, orderBy as tn, sql as to, recursiveCte as tr, ColumnStorageTypeOf as ts, PortableCastTarget as tt, MetadataOf as tu, SnapshotDecodeResult as u, SelectPart as ua, SchemaObjectNameOptions as uc, FieldLike as ui, AnyExpression as ul, values as un, gte as uo, fullJoin as ur, PortableStorageType as us, Query as ut, RenderContext as uu, SnapshotExtensionContext as v, offset as va, AdapterExecutionResult as vc, KeyConstraintOptions as vi, ExpressionWithOutput as vl, doUpdate as vn, between as vo, FromSource as vr, boolean as vs, CustomSource as vt, ResultMeta as vu, SnapshotIndexTermExpression as w, add as wa, ExplainOptions as wc, SourceLike as wi, withDialectCapability as wl, AllowAllClause as wn, Operand as wo, all as wr, nativeColumn as ws, SourceConfig as wt, isFragment as wu, SnapshotIdentity as x, AnySelectClause as xa, ExecutionRequest as xc, ReferentialAction as xi, isExpression as xl, UpdateAssignmentValue as xn, isNotNull as xo, SelectionObject as xr, date as xs, ProvidedSourceRow as xt, VisibleDependenciesOf as xu, SnapshotForeignKey as y, having as ya, DriverValueEncoder as yc, MysqlConstraintExtension as yi, SchemaExpression as yl, excluded as yn, inList as yo, from as yr, column as ys, CustomSourceOptions as yt, SqlTypeOf as yu, schemaSnapshotVersion as z, coalesce as za, QubuTransaction as zc, AliasIdentity as zi, CapabilitiesOf as zl, correlate as zn, ColumnHasDefault as zo, renderSchemaExpression as zr, ExpressionGeneratedColumnDescriptor as zs, TableColumns as zt, SqlOrderable as zu };
|
|
4252
|
+
export { PaginationKind as $, SqlTag as $a, QubuStreamingTransaction as $c, SourceIndexesRecord as $i, AggregateMeta as $l, WithClause as $n, ColumnStorageDialectOf as $o, generatedTableName as $r, ResolvedColumnBehavior as $s, nullsLast as $t, SqlNumericLike as $u, SnapshotStorage as A, jsonBoolean as Aa, ExplainReadOptions as Ac, catalogCheck as Ai, ExpressionNullability as Al, MutationReturningClause as An, value as Ao, SchemaExpressionErrorCode as Ar, numeric as As, SourceSqlTypeMap as At, RequiresOuterMetadataOf as Au, CastTarget as B, concat as Ba, HookQueryOperation as Bc, AliasedSource as Bi, withDialectCapability as Bl, select as Bn, ColumnHasDefault as Bo, renderSchemaSql as Br, DefaultDescriptor as Bs, TableDefinitions as Bt, isFragment as Bu, SnapshotIndexTerm as C, SelectClause as Ca, ExecutionOptions as Cc, SourceConstraintsRecord as Ci, ColumnDependency as Cl, update as Cn, isTrue as Co, SelectionSqlTypes as Cr, date as Cs, SourceColumns as Ct, ProvidesOuterSourceMeta as Cu, SnapshotLiteral as D, multiply as Da, ExplainOptions as Dc, UniqueConstraint as Di, AnySchemaExpression as Dl, MutationQuery as Dn, SqlCapabilityValidation as Do, createSchemaDialect as Dr, nativeColumn as Ds, SourceKind as Dt, RenderFunction as Du, SnapshotKeyConstraint as E, modulo as Ea, ExplainMutationOptions as Ec, TableLike as Ei, AnyExpression as El, MutationKind as En, OperandSqlType as Eo, SchemaDialectHooks as Er, json as Es, SourceIdentity as Et, RenderContext as Eu, neutralSnapshotDialect as F, denseRank as Fa, HookMetadata as Fc, references as Fi, SchemaExpression as Fl, ReturningClause as Fn, ColumnDefaultOf as Fo, UnsafeSchemaSqlExpression as Fr, CanonicalLiteral as Fs, exposeColumns as Ft, SqlTypeOf as Fu, DialectJson as G, typedCall as Ga, QubuClient as Gc, alias as Gi, ResultDecodingError as Gl, MissingScope as Gn, ColumnIsNullable as Go, SchemaNamingPolicy as Gr, GeneratedColumnDescriptor as Gs, TableRow as Gt, SqlBinary as Gu, DialectCapability as H, upper as Ha, HookSuccessOutcome as Hc, LateralSource as Hi, ResultDecodeContext as Hl, AvailableScope as Hn, ColumnIdentityOf as Ho, unsafeSchemaSql as Hr, ExpressionGeneratedColumnDescriptor as Hs, TableInsertInput as Ht, sequence as Hu, schemaSnapshotDialectVersion as I, over as Ia, HookMetadataValue as Ic, unique as Ii, SchemaExpressionBrand as Il, ReturningRow as In, ColumnDefinition as Io, defineSchemaExpression as Ir, ColumnBehaviorError as Is, sourceIdentity as It, SubqueryMeta as Iu, DialectRowLocking as J, countDistinct as Ja, QubuExplainableTransactionalClient as Jc, IndexOptions as Ji, booleanResultDecoder as Jl, ScopeValidation as Jn, ColumnOutput as Jo, SchemaTableNames as Jr, IdentityDescriptor as Js, table as Jt, SqlDecimal as Ju, DialectOptions as K, avg as Ka, QubuExplainableClient as Kc, lateral as Ki, ResultField as Kl, RequiredOuterScope as Kn, ColumnOnUpdateOf as Ko, SchemaOptions as Kr, GeneratedColumnMode as Ks, TableSqlTypes as Kt, SqlBoolean as Ku, schemaSnapshotFormat as L, rank as La, HookOperation as Lc, uniqueConstraint as Li, isExpression as Ll, ReturningSqlTypes as Ln, ColumnDefinitionConfig as Lo, isUnsafeSchemaSql as Lr, ColumnBehaviorErrorCode as Ls, AnyTable as Lt, VisibleDependenciesOf as Lu, SnapshotTable as M, jsonNumber as Ma, ExplainResult as Mc, check as Mi, ExpressionRequires as Ml, MutationScopeValidation as Mn, cast as Mo, SchemaExpressionMode as Mr, text as Ms, UnknownSourceSqlTypes as Mt, RequiresOuterSourceMeta as Mu, SnapshotUniqueConstraint as N, jsonPath as Na, ExplainableQueryAdapter as Nc, foreignKey as Ni, ExpressionSqlType as Nl, MutationSqlTypes as Nn, typedCast as No, SchemaRenderContext as Nr, timestamp as Ns, createSource as Nt, RequiresSourceMeta as Nu, SnapshotNamingPolicy as O, subtract as Oa, ExplainOptionsFor as Oc, UniqueConstraintOptions as Oi, Expression as Ol, MutationQueryConfig as On, asValue as Oo, RenderedSchemaExpression as Or, nativeStorage as Os, SourceProvision as Ot, RequiresCapabilityMeta as Ou, SnapshotValidationContext as P, jsonText as Pa, HookErrorOutcome as Pc, primaryKey as Pi, ExpressionWithOutput as Pl, allowAll as Pn, ColumnCodec as Po, SchemaRenderOptions as Pr, uuid as Ps, customSource as Pt, ResultMeta as Pu, NamedCastTarget as Q, SqlFragment as Qa, QubuStreamingExplainableClient as Qc, SourceIndex as Qi, AggregateDependenciesOf as Ql, RecursiveCteSource as Qn, ColumnStorageDescriptor as Qo, defaultSchemaNamingPolicy as Qr, MysqlIdentityExtension as Qs, nullsFirst as Qt, SqlJson as Qu, schemaSnapshotNamingPolicyVersion as R, rowNumber as Ra, HookOperationKind as Rc, validateConstraintDialect as Ri, makeExpression as Rl, returning as Rn, ColumnFromOptions as Ro, normalizeSchemaSql as Rr, ColumnDefault as Rs, Table as Rt, WindowMeta as Ru, SnapshotIndex as S, ClausePlacement as Sa, DriverValueEncoder as Sc, SourceConstraint as Si, QueryValidationIssue as Sl, UpdateAssignments as Sn, isNull as So, SelectionOutput as Sr, columnResultValue as Ss, Source as St, ProvidesOuterOf as Su, SnapshotJsonValue as T, divide as Ta, ExecutionResult as Tc, SqliteConstraintExtension as Ti, expressionFragment as Tl, MutationClause as Tn, OperandNullability as To, SchemaDialect as Tr, integer as Ts, SourceConstraints as Tt, QueryCardinality as Tu, DialectCastTypes as U, call as Ua, HookTransactionOperation as Uc, QueryAliasIdentity as Ui, ResultDecoder as Ul, ClauseScope as Un, ColumnInsertInput as Uo, Schema as Ur, ExternalDefaultDescriptor as Us, TableMetadataCallback as Ut, AnySqlType as Uu, Dialect as V, lower as Va, HookStreamEnd as Vc, LateralIdentity as Vi, DecodableResultType as Vl, AvailableOuterScope as Vn, ColumnHasRuntimeDefault as Vo, schemaExpression as Vr, ExpressionDefaultDescriptor as Vs, TableIdentity as Vt, parenthesize as Vu, DialectExplain as W, schemaCall as Wa, OperationEndHook as Wc, QuerySource as Wi, ResultDecoders as Wl, GroupingValidation as Wn, ColumnIsGenerated as Wo, SchemaDiagnostic as Wr, ExternalGeneratedColumnDescriptor as Ws, TableOptions as Wt, SqlBigInt as Wu, ExplainRenderOptions as X, min as Xa, QubuOptions as Xc, MysqlIndexExtension as Xi, jsonTextResultDecoder as Xl, SelectQuery as Xn, ColumnStorage as Xo, SchemaTableRegistry as Xr, IdentityGeneration as Xs, asc as Xt, SqlEqualityCompatible as Xu, ExplainFormat as Y, max as Ya, QubuHooks as Yc, IndexTerm as Yi, dateResultDecoder as Yl, SelectCardinality as Yn, ColumnSqlType as Yo, SchemaTableRecord as Yr, IdentityDialectExtension as Ys, OrderTerm as Yt, SqlEqualityComparable as Yu, JsonScalarKind as Z, sum as Za, QubuStreamingClient as Zc, PostgresIndexExtension as Zi, timestampResultDecoder as Zl, CteSource as Zn, ColumnStorageDeclarationOf as Zo, SchemaValidationError as Zr, LiteralDefaultDescriptor as Zs, desc as Zt, SqlInteger as Zu, SnapshotExpressionContext as _, fetchNext as _a, generatedSchemaObjectName as _c, KeyConstraint as _i, RenderedQuery as _l, doNothing as _n, notLike as _o, FromScope as _r, StorageTypeOf as _s, AnySource as _t, MetadataOf as _u, SnapshotBigInt as a, and as aa, generatedColumn as ac, SqlTimestamp as ad, CheckConstraint as ai, StreamableQuery as al, InsertSource as an, notExists as ao, except as ar, DialectNativeStorage as as, SchemaLiteralRenderer as at, DependenciesOf as au, SnapshotGeneratedColumn as b, distinct as ba, materializeSchemaObjectRecord as bc, PostgresConstraintExtension as bi, QueryValidationError as bl, onConflict as bn, notIn as bo, Selection as br, boolean as bs, ProvidedSourceIdentity as bt, NullableSourcesOf as bu, SnapshotConstraint as c, Omit$1 as ca, SchemaDialectExtension as cc, SqlUuid as cd, ConstraintOptions as ci, TransactionOptions as cl, insertInto as cn, eq as co, unionAll as cr, NativeStorageDescriptor as cs, resolveCastTarget as ct, FragmentMeta as cu, SnapshotDefault as d, omit as da, SchemaMetadataValidationError as dc, FieldLikeOptions as di, executeRows as dl, ConflictAction as dn, isDistinctFrom as do, innerJoin as dr, PortableStorageDescriptor as ds, QueryConfig as dt, GroupingMeta as du, SqliteIndexExtension as ea, SchemaLiteralValue as ec, SqlOrderCompatible as ed, schema as ei, QubuStreamingTransactionalClient as el, order as en, TypedSqlTag as eo, cte as er, ColumnStorageKindOf as es, PaginationPart as et, AnyFragment as eu, SnapshotDiagnostic as f, where as fa, SchemaObjectIdentity as fc, ForeignKeyConstraint as fi, explain as fl, ConflictTarget as fn, isNotDistinctFrom as fo, leftJoin as fr, PortableStorageType as fs, QueryKind as ft, HasAggregate as fu, SnapshotExpression as g, fetchFirst as ga, freezeSchemaMetadata as gc, ForeignKeyTargetInput as gi, RenderOptions as gl, OnConflictClause as gn, ne as go, FromClause as gr, StorageOf as gs, Row as gt, InheritedMetadataOf as gu, SnapshotDialectExtension as h, rowLock as ha, dialectMismatchDiagnostic as hc, ForeignKeyTarget as hi, RenderCapabilityValidation as hl, ExcludedSource as hn, lte as ho, groupBy as hr, StorageDialectOf as hs, QueryWithRow as ht, InheritedMetadata as hu, SchemaSnapshotInput as i, DeclaredColumnNullability as ia, externalGeneratedColumn as ic, SqlTextLike as id, CatalogCheckSql as ii, QueryExecutor as il, InsertSelectSource as in, inQuery as io, SetQuery as ir, ColumnUpdateInput as is, RowLockWaitPolicy as it, CardinalityOf as iu, SnapshotStorageContext as j, jsonExists as ja, ExplainRequest as jc, catalogForeignKey as ji, ExpressionOutput as jl, MutationRow as jn, mapResult as jo, SchemaExpressionInput as jr, portableStorage as js, SourceSqlTypes as jt, RequiresOuterOf as ju, SnapshotSpecialNumber as k, JsonPath as ka, ExplainPlanRow as kc, UniqueNullSemantics as ki, ExpressionKind as kl, MutationReturning as kn, typedValue as ko, SchemaExpressionError as kr, nullable as ks, SourceRow as kt, RequiresOf as ku, SnapshotCreateResult as l, OmittableSelectClause as la, SchemaDialectName as lc, ConstraintTiming as li, TransactionalQueryAdapter as ll, insertSelect as ln, gt as lo, crossJoin as lr, PortableColumnStorage as ls, AnyQuery as lt, GroupingDependenciesOf as lu, SnapshotDialect as m, RowLockOptions as ma, assertSchemaDialectSupport as mc, ForeignKeyOptions as mi, stream as ml, DoUpdateAction as mn, lt as mo, rightJoin as mr, StorageDescriptor as ms, QuerySqlTypeMap as mt, HasWindow as mu, SchemaSnapshot as n, index as na, canonicalLiteral as nc, SqlSemanticType as nd, AnyKeyColumn as ni, QubuTransactionalClient as nl, deleteFrom as nn, caseWhen as no, withCte as nr, ColumnStorageType as ns, PortableCastType as nt, CapabilityMetadataOf as nu, SnapshotCheckConstraint as o, not as oa, identityColumn as oc, SqlTypeSatisfies as od, CheckConstraintOptions as oi, StreamingQueryAdapter as ol, ValuesSource as on, scalar as oo, intersect as or, NativeColumnStorage as os, assertDialectCapability as ot, ExpressionMeta as ou, SnapshotDiagnosticCode as p, RowLockClause as pa, SchemaObjectNameOptions as pc, ForeignKeyMatch as pi, qubu as pl, DoNothingAction as pn, like as po, naturalJoin as pr, StorageDeclarationOf as ps, QueryRow as pt, HasSubquery as pu, DialectPagination as q, count as qa, QubuExplainableStreamingTransactionalClient as qc, IndexDialectExtension as qi, ResultShape as ql, RequiredScope as qn, ColumnOptions as qo, SchemaTableEntry as qr, GeneratedDescriptor as qs, TableUpdateInput as qt, SqlDate as qu, SchemaSnapshotAdapter as r, validateIndexDialect as ra, externalDefault as rc, SqlText as rd, CatalogCheckExpression as ri, QueryAdapter as rl, DefaultValuesSource as rn, exists as ro, SetOperator as rr, ColumnStorageTypeOf as rs, RowLockMode as rt, CardinalityMeta as ru, SnapshotColumn as s, or as sa, resolveColumnBehavior as sc, SqlUnknown as sd, ConstraintDialectExtension as si, StreamingTransactionalQueryAdapter as sl, defaultValues as sn, ComparisonValidation as so, union as sr, NativeStorage as ss, createDialect as st, Fragment as su, AnySchema as t, TableIndex as ta, SqliteIdentityExtension as tc, SqlOrderable as td, schemaNamingPolicyVersion as ti, QubuTransaction as tl, orderBy as tn, sql as to, recursiveCte as tr, ColumnStorageOf as ts, PortableCastTarget as tt, CapabilitiesOf as tu, SnapshotDecodeResult as u, SelectPart as ua, SchemaMetadataDiagnostic as uc, FieldLike as ui, execute as ul, values as un, gte as uo, fullJoin as ur, PortableStorage as us, Query as ut, GroupingKeysOf as uu, SnapshotExtensionContext as v, offset as va, isValidSchemaObjectName as vc, KeyConstraintOptions as vi, render as vl, doUpdate as vn, between as vo, FromSource as vr, bigint as vs, CustomSource as vt, NullabilityOf as vu, SnapshotIndexTermExpression as w, add as wa, ExecutionRequest as wc, SourceLike as wi, ColumnReference as wl, AllowAllClause as wn, Operand as wo, all as wr, encodeColumnParameter as ws, SourceConfig as wt, ProvidesSourceMeta as wu, SnapshotIdentity as x, AnySelectClause as xa, AdapterExecutionResult as xc, ReferentialAction as xi, QueryValidationErrorCode as xl, UpdateAssignmentValue as xn, isNotNull as xo, SelectionObject as xr, column as xs, ProvidedSourceRow as xt, OutputOf as xu, SnapshotForeignKey as y, having as ya, materializeSchemaObjectIdentity as yc, MysqlConstraintExtension as yi, QueryTypeValidation as yl, excluded as yn, inList as yo, from as yr, binary as ys, CustomSourceOptions as yt, NullableSourceMeta as yu, schemaSnapshotVersion as z, coalesce as za, HookOutcome as zc, AliasIdentity as zi, markExpressionCategory as zl, correlate as zn, ColumnGeneratedOf as zo, renderSchemaExpression as zr, ColumnDefaultInput as zs, TableColumns as zt, fragment as zu };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { s as resolveCastTarget } from "./json-Db7XRD91.mjs";
|
|
2
2
|
import { t as standardDialect } from "./standard-DfcZEVOj.mjs";
|
|
3
|
-
import { H as
|
|
4
|
-
import { t as asValue } from "./value-
|
|
3
|
+
import { H as makeExpression, U as makeSchemaExpression, q as fragment, u as columnResultValue } from "./column-DmazTL67.mjs";
|
|
4
|
+
import { t as asValue } from "./value-BEEj_Ayd.mjs";
|
|
5
5
|
//#region src/core/render.ts
|
|
6
6
|
function render(query, options = {}) {
|
|
7
7
|
const dialect = isDialect(options) ? options : options.dialect ?? standardDialect();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { U as makeSchemaExpression, q as fragment } from "./column-DmazTL67.mjs";
|
|
2
2
|
//#region src/core/primitives/parameter.ts
|
|
3
3
|
function parameter(_value) {
|
|
4
4
|
return fragment((context) => context.parameter(_value));
|
package/dist/vite/ambient.d.ts
CHANGED
|
@@ -136,10 +136,16 @@ declare global {
|
|
|
136
136
|
type ColumnDefinitionConfig = import("qubu").ColumnDefinitionConfig
|
|
137
137
|
type ColumnDefinition<TConfig extends ColumnDefinitionConfig = {}> =
|
|
138
138
|
import("qubu").ColumnDefinition<TConfig>
|
|
139
|
+
type ColumnCodec<
|
|
140
|
+
TOutput = unknown,
|
|
141
|
+
TInsert = TOutput,
|
|
142
|
+
TDriver = unknown,
|
|
143
|
+
> = import("qubu").ColumnCodec<TOutput, TInsert, TDriver>
|
|
139
144
|
type ColumnSqlType<T> = import("qubu").ColumnSqlType<T>
|
|
140
145
|
type ColumnDefault = import("qubu").ColumnDefault
|
|
141
146
|
type ColumnDefaultInput = import("qubu").ColumnDefaultInput
|
|
142
147
|
type ColumnDefaultOf<T> = import("qubu").ColumnDefaultOf<T>
|
|
148
|
+
type ColumnHasRuntimeDefault<T> = import("qubu").ColumnHasRuntimeDefault<T>
|
|
143
149
|
type ColumnGeneratedOf<T> = import("qubu").ColumnGeneratedOf<T>
|
|
144
150
|
type ColumnIdentityOf<T> = import("qubu").ColumnIdentityOf<T>
|
|
145
151
|
type ColumnOnUpdateOf<T> = import("qubu").ColumnOnUpdateOf<T>
|
package/docs/config.json
CHANGED
|
@@ -353,6 +353,53 @@ const rows = await db.rows(readQuery)
|
|
|
353
353
|
array. Both methods infer each row from the query projection. They do not make
|
|
354
354
|
query values executable or transfer connection ownership to Qubu.
|
|
355
355
|
|
|
356
|
+
## Observe bound operations
|
|
357
|
+
|
|
358
|
+
Configure hooks on a bound client when logs, traces, or metrics need the same
|
|
359
|
+
lifecycle view across queries, streams, plans, and transactions:
|
|
360
|
+
|
|
361
|
+
```ts
|
|
362
|
+
import { qubu } from "qubu"
|
|
363
|
+
|
|
364
|
+
const db = qubu(adapter, {
|
|
365
|
+
hooks: {
|
|
366
|
+
onOperationStart(operation) {
|
|
367
|
+
console.info("Qubu operation started", operation)
|
|
368
|
+
|
|
369
|
+
return (outcome) => {
|
|
370
|
+
console.info("Qubu operation finished", operation.id, outcome)
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
onHookError(error) {
|
|
374
|
+
console.error("Qubu hook failed", error)
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
})
|
|
378
|
+
|
|
379
|
+
await db.rows(readQuery, {
|
|
380
|
+
hookMetadata: { operation: "users.list" },
|
|
381
|
+
})
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
Query operations start after rendering and immediately before the adapter is
|
|
385
|
+
called. Completion reports duration, success or the original error, and
|
|
386
|
+
available aggregate facts such as row and affected-row counts. Transaction
|
|
387
|
+
queries identify their parent transaction operation. Hooks are synchronous,
|
|
388
|
+
and their failures are sent to `onHookError` without changing the database
|
|
389
|
+
operation's result.
|
|
390
|
+
|
|
391
|
+
Hook metadata accepts only strings, numbers, and booleans. Observations include
|
|
392
|
+
rendered SQL and parameter count, but never parameter values, result rows,
|
|
393
|
+
decoded values, or insert identifiers. Rendered SQL can still contain literals
|
|
394
|
+
introduced by unsafe SQL helpers, so treat it according to the application's
|
|
395
|
+
logging policy.
|
|
396
|
+
|
|
397
|
+
Streaming adapters are still called eagerly. A consumed stream completes its
|
|
398
|
+
observation when it is exhausted, closed early, or fails. A stream created but
|
|
399
|
+
never consumed has no completion observation. Hooks are available only on
|
|
400
|
+
clients created with `qubu()`; standalone execution functions remain
|
|
401
|
+
unobserved.
|
|
402
|
+
|
|
356
403
|
## Run a transaction
|
|
357
404
|
|
|
358
405
|
Use a transactional adapter when several queries must share one commit or
|