durable-db 0.13.2 → 0.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { t as DatabaseSource } from "../discovery-gHeLq8jk.js";
2
2
  import { C as parseRenameSpec, g as SchemaRenameRequiredError, h as SchemaAmbiguity, m as RenameAnswer, n as Snapshot, t as MigrationResolution, u as MigrationRisk } from "../snapshot-D3_SNABU.js";
3
- import { l as DatabaseInfo } from "../defineDatabase-DlgYfwhP.js";
4
- import "../index-B5W4m0Dq.js";
3
+ import { l as DatabaseInfo } from "../defineDatabase-BmjnvgJ8.js";
4
+ import "../index-Di-UGgpS.js";
5
5
  import { Command } from "commander";
6
6
  import "vite";
7
7
  import "@babel/types";
@@ -1,5 +1,5 @@
1
1
  import { l as type } from "../index-bUUlOWfP.js";
2
- import { C as RelationType, E as relationsOf, S as RelationMap, T as relationOf, _ as RelatedSpec, a as ActionInfo, b as AnySchema, c as DatabaseDefinition, d as InferArgs, f as ParsedDatabaseFile, g as RelatedOptions, h as RelatedExpression, i as ActionContext, l as DatabaseInfo, m as Related, n as Action, o as ArgsSchema, p as AnyRelated, r as ActionConfig, s as DatabaseConfig, t as defineDatabase, u as DrizzleToKysely, v as RelatedWhere, w as Relations, x as Relation, y as createRelated } from "../defineDatabase-DlgYfwhP.js";
2
+ import { C as RelationType, E as relationsOf, S as RelationMap, T as relationOf, _ as RelatedSpec, a as ActionInfo, b as AnySchema, c as DatabaseDefinition, d as InferArgs, f as ParsedDatabaseFile, g as RelatedOptions, h as RelatedExpression, i as ActionContext, l as DatabaseInfo, m as Related, n as Action, o as ArgsSchema, p as AnyRelated, r as ActionConfig, s as DatabaseConfig, t as defineDatabase, u as DrizzleToKysely, v as RelatedWhere, w as Relations, x as Relation, y as createRelated } from "../defineDatabase-BmjnvgJ8.js";
3
3
  import { a as OutboxSinkContext, c as queueOutboxSink, i as OutboxSink, l as tenantOfInstanceKey, n as OutboxEnvelope, o as OutboxSinkModule, r as OutboxMessage, s as outboxSink, t as Outbox } from "../outbox-D3Q9n7Rt.js";
4
- import { C as SqliteDurableObject, E as createKyselyFromSql, S as Migrations, T as SqlExecutor, _ as RemovedDatabaseError, a as QueryResult, b as MigrationAttemptInfo, c as DrizzleDefaultsPlugin, d as createDrizzlePlugins, f as createJsonPlugins, g as RemovedDatabaseDurableObject, h as DeleteClassMigration, i as KyselyPlugin, l as JsonPluginOptions, m as parseJsonValue, n as CompiledQuery, o as studio, p as dateSerializers, r as Kysely, s as DateSerializePlugin, t as CamelCasePlugin, u as SchemaPlugin, v as removedDatabaseMessage, w as CreateKyselyOptions, x as MigrationSchemaConflictError, y as Migration } from "../index-B5W4m0Dq.js";
4
+ import { C as SqliteDurableObject, E as createKyselyFromSql, S as Migrations, T as SqlExecutor, _ as RemovedDatabaseError, a as QueryResult, b as MigrationAttemptInfo, c as DrizzleDefaultsPlugin, d as createDrizzlePlugins, f as createJsonPlugins, g as RemovedDatabaseDurableObject, h as DeleteClassMigration, i as KyselyPlugin, l as JsonPluginOptions, m as parseJsonValue, n as CompiledQuery, o as studio, p as dateSerializers, r as Kysely, s as DateSerializePlugin, t as CamelCasePlugin, u as SchemaPlugin, v as removedDatabaseMessage, w as CreateKyselyOptions, x as MigrationSchemaConflictError, y as Migration } from "../index-Di-UGgpS.js";
5
5
  export { type Action, type ActionConfig, type ActionContext, type ActionInfo, type AnyRelated, type AnySchema, type ArgsSchema, CamelCasePlugin, type CompiledQuery, type CreateKyselyOptions, type DatabaseConfig, type DatabaseDefinition, type DatabaseInfo, DateSerializePlugin, type DeleteClassMigration, DrizzleDefaultsPlugin, type DrizzleToKysely, type InferArgs, type JsonPluginOptions, type Kysely, type KyselyPlugin, type Migration, type MigrationAttemptInfo, MigrationSchemaConflictError, type Migrations, type Outbox, type OutboxEnvelope, type OutboxMessage, type OutboxSink, type OutboxSinkContext, type OutboxSinkModule, type ParsedDatabaseFile, type QueryResult, type Related, RelatedExpression, type RelatedOptions, type RelatedSpec, type RelatedWhere, type Relation, type RelationMap, type RelationType, type Relations, RemovedDatabaseDurableObject, RemovedDatabaseError, SchemaPlugin, type SqlExecutor, SqliteDurableObject, createDrizzlePlugins, createJsonPlugins, createKyselyFromSql, createRelated, dateSerializers, defineDatabase, outboxSink, parseJsonValue, queueOutboxSink, relationOf, relationsOf, removedDatabaseMessage, studio, tenantOfInstanceKey, type };
@@ -2,8 +2,7 @@ import "./index-bUUlOWfP.js";
2
2
  import { t as Outbox } from "./outbox-D3Q9n7Rt.js";
3
3
  import { type } from "arktype";
4
4
  import { SQLiteTableWithColumns } from "drizzle-orm/sqlite-core";
5
- import { AliasNode, AliasedExpression, Expression, ExpressionBuilder, Kysely, KyselyPlugin, OperationNode, Selectable, SqlBool } from "kysely";
6
- import { Kyselify } from "drizzle-orm/kysely";
5
+ import { AliasNode, AliasedExpression, ColumnType, Expression, ExpressionBuilder, Kysely, KyselyPlugin, OperationNode, Selectable, SqlBool } from "kysely";
7
6
  //#region src/db/relations.d.ts
8
7
  type AnySchema = Record<string, SQLiteTableWithColumns<any>>;
9
8
  type RefOf<Col> = Col extends {
@@ -16,7 +15,7 @@ type TableNameOf<Col> = Col extends {
16
15
  tableName: infer N;
17
16
  };
18
17
  } ? N : never;
19
- type ColumnsOf<T> = T extends {
18
+ type ColumnsOf$1<T> = T extends {
20
19
  _: {
21
20
  columns: infer C;
22
21
  };
@@ -29,16 +28,16 @@ type NameOf<T> = T extends {
29
28
  type KeyOf<S, Name> = { [K in keyof S & string]: NameOf<S[K]> extends Name ? K : never; }[keyof S & string];
30
29
  type TargetOf$1<S, Col> = [RefOf<Col>] extends [never] ? never : string extends TableNameOf<RefOf<Col>> ? never : KeyOf<S, TableNameOf<RefOf<Col>>>;
31
30
  /** Every foreign key of a schema the types know: the table and column that hold it, the table it points at. */
32
- type Edge<S> = { [TK in keyof S & string]: { [CK in keyof ColumnsOf<S[TK]> & string]: [TargetOf$1<S, ColumnsOf<S[TK]>[CK]>] extends [never] ? never : {
31
+ type Edge<S> = { [TK in keyof S & string]: { [CK in keyof ColumnsOf$1<S[TK]> & string]: [TargetOf$1<S, ColumnsOf$1<S[TK]>[CK]>] extends [never] ? never : {
33
32
  table: TK;
34
33
  column: CK;
35
- target: TargetOf$1<S, ColumnsOf<S[TK]>[CK]>;
36
- nullable: ColumnsOf<S[TK]>[CK] extends {
34
+ target: TargetOf$1<S, ColumnsOf$1<S[TK]>[CK]>;
35
+ nullable: ColumnsOf$1<S[TK]>[CK] extends {
37
36
  _: {
38
37
  notNull: true;
39
38
  };
40
39
  } ? false : true;
41
- }; }[keyof ColumnsOf<S[TK]> & string]; }[keyof S & string];
40
+ }; }[keyof ColumnsOf$1<S[TK]> & string]; }[keyof S & string];
42
41
  type AnyEdge = {
43
42
  table: string;
44
43
  column: string;
@@ -239,7 +238,44 @@ interface DatabaseConfig<TSchema extends Record<string, SQLiteTableWithColumns<a
239
238
  /**
240
239
  * Convert a Drizzle schema to Kysely database types using drizzle-kysely
241
240
  */
242
- type DrizzleToKysely<TSchema extends Record<string, SQLiteTableWithColumns<any>>> = { [K in keyof TSchema]: TSchema[K] extends SQLiteTableWithColumns<any> ? Kyselify<TSchema[K]> : never; };
241
+ type DrizzleToKysely<TSchema extends Record<string, SQLiteTableWithColumns<any>>> = { [K in keyof TSchema]: KyselyTable<TSchema[K]>; };
242
+ type ColumnsOf<T> = T extends {
243
+ _: {
244
+ columns: infer C;
245
+ };
246
+ } ? C : never;
247
+ type KyselyTable<T> = { [C in keyof ColumnsOf<T> & string as DbNameOf<C, ColumnsOf<T>[C]>]: KyselyColumn<ColumnsOf<T>[C]>; };
248
+ type DbNameOf<Key, Col> = Col extends {
249
+ _: {
250
+ name: infer N extends string;
251
+ };
252
+ } ? N : Key;
253
+ /** A column's value as a row holds it: null where it may be. */
254
+ type ColumnValue<Col> = Col extends {
255
+ _: {
256
+ notNull: true;
257
+ data: infer D;
258
+ };
259
+ } ? D : Col extends {
260
+ _: {
261
+ data: infer D;
262
+ };
263
+ } ? D | null : never;
264
+ type KyselyColumn<Col> = Col extends {
265
+ _: {
266
+ notNull: true;
267
+ hasDefault: false;
268
+ };
269
+ } ? ColumnValue<Col> : Col extends {
270
+ _: {
271
+ generated: undefined;
272
+ identity: undefined;
273
+ };
274
+ } ? Col extends {
275
+ _: {
276
+ notNull: true;
277
+ };
278
+ } ? ColumnType<ColumnValue<Col>, ColumnValue<Col> | undefined, ColumnValue<Col> | undefined> : ColumnValue<Col> : ColumnType<ColumnValue<Col>, never, never>;
243
279
  /**
244
280
  * ArkType helpers – mirror Ark's own API:
245
281
  * - arkType.validate<Def> → definition shape with DSL validation/autocomplete
@@ -1,4 +1,4 @@
1
- import "./defineDatabase-DlgYfwhP.js";
1
+ import "./defineDatabase-BmjnvgJ8.js";
2
2
  import { i as OutboxSink, t as Outbox } from "./outbox-D3Q9n7Rt.js";
3
3
  import { SQLiteTableWithColumns } from "drizzle-orm/sqlite-core";
4
4
  import { CamelCasePlugin, CamelCasePlugin as CamelCasePlugin$1, CompiledQuery, Kysely, Kysely as Kysely$1, KyselyPlugin, KyselyPlugin as KyselyPlugin$1, PluginTransformQueryArgs, PluginTransformResultArgs, QueryResult, QueryResult as QueryResult$1, RootOperationNode, UnknownRow } from "kysely";
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { i as Type, l as type } from "./index-bUUlOWfP.js";
2
- import { C as RelationType, E as relationsOf, S as RelationMap, T as relationOf, _ as RelatedSpec, b as AnySchema, c as DatabaseDefinition, d as InferArgs, g as RelatedOptions, h as RelatedExpression, i as ActionContext, m as Related, n as Action, p as AnyRelated, r as ActionConfig, s as DatabaseConfig, t as defineDatabase, u as DrizzleToKysely, v as RelatedWhere, w as Relations, x as Relation, y as createRelated } from "./defineDatabase-DlgYfwhP.js";
2
+ import { C as RelationType, E as relationsOf, S as RelationMap, T as relationOf, _ as RelatedSpec, b as AnySchema, c as DatabaseDefinition, d as InferArgs, g as RelatedOptions, h as RelatedExpression, i as ActionContext, m as Related, n as Action, p as AnyRelated, r as ActionConfig, s as DatabaseConfig, t as defineDatabase, u as DrizzleToKysely, v as RelatedWhere, w as Relations, x as Relation, y as createRelated } from "./defineDatabase-BmjnvgJ8.js";
3
3
  import { a as OutboxSinkContext, i as OutboxSink, n as OutboxEnvelope, o as OutboxSinkModule, r as OutboxMessage, t as Outbox } from "./outbox-D3Q9n7Rt.js";
4
4
  import { getTenantId, hasTenantId, setTenantIdResolver } from "./context/index.js";
5
5
  import { AnySQLiteColumn, blob, foreignKey, index, integer, numeric, primaryKey, real, table, text, uniqueIndex } from "./schema.js";
@@ -1,5 +1,5 @@
1
1
  import { t as DatabaseSource } from "../discovery-gHeLq8jk.js";
2
- import "../index-B5W4m0Dq.js";
2
+ import "../index-Di-UGgpS.js";
3
3
  import { Plugin } from "vite";
4
4
  import "@babel/types";
5
5
  //#region src/vite/modules/wrangler.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "durable-db",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/eagerpatch/durable-db.git"