@ontrails/drizzle 1.0.0-beta.15 → 1.0.0-beta.16

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/CHANGELOG.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # @ontrails/drizzle
2
2
 
3
+ ## 1.0.0-beta.16
4
+
5
+ ### Patch Changes
6
+
7
+ - f5c6777: Move adapter package workspaces from `connectors/*` to `adapters/*` as part of
8
+ the package-boundary taxonomy cutover. Package names and public APIs are
9
+ unchanged.
10
+ - 3395234: Move store adapter-binding helpers to `@ontrails/store/adapter-support` and topographer direct database/admin helpers to `@ontrails/topographer/backend-support`, keeping root exports focused on contract-level APIs.
11
+ - 6300f70: BREAKING: rename the shared store backend option type from `StoreConnectorOptions` to `StoreAdapterOptions`.
12
+ - 49c2e7d: Refresh published package README taxonomy to use adapter language instead of retired connector vocabulary.
13
+ - df9a7d0: Add project-aware public export-map governance for @ontrails workspace docs,
14
+ imports, root barrels, and bin-only package surfaces.
15
+ - Updated dependencies [73622ae]
16
+ - Updated dependencies [6300f70]
17
+ - Updated dependencies [d172013]
18
+ - Updated dependencies [c3fc5c3]
19
+ - Updated dependencies [20d7a5c]
20
+ - Updated dependencies [be5fb46]
21
+ - Updated dependencies [e898cc4]
22
+ - Updated dependencies [3395234]
23
+ - Updated dependencies [bcdc484]
24
+ - Updated dependencies [6300f70]
25
+ - Updated dependencies [49c2e7d]
26
+ - Updated dependencies [331e3a9]
27
+ - Updated dependencies [4399fdb]
28
+ - Updated dependencies [4b8d13b]
29
+ - Updated dependencies [112b9f2]
30
+ - Updated dependencies [893025e]
31
+ - Updated dependencies [eec5e9d]
32
+ - Updated dependencies [ebd4434]
33
+ - Updated dependencies [863d473]
34
+ - Updated dependencies [344f2f7]
35
+ - Updated dependencies [26f9ffd]
36
+ - Updated dependencies [10eae9a]
37
+ - Updated dependencies [22c6c06]
38
+ - Updated dependencies [df9a7d0]
39
+ - @ontrails/core@1.0.0-beta.16
40
+ - @ontrails/store@1.0.0-beta.16
41
+
3
42
  ## 1.0.0-beta.15
4
43
 
5
44
  ### Patch Changes
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @ontrails/drizzle
2
2
 
3
- Drizzle connector for Trails stores. Use this package to bind a connector-agnostic `store(...)` definition from `@ontrails/store` to a concrete Drizzle runtime.
3
+ Drizzle adapter for Trails stores. Use this package to bind a backend-agnostic `store(...)` definition from `@ontrails/store` to a concrete Drizzle runtime.
4
4
 
5
5
  ## Usage
6
6
 
@@ -30,7 +30,9 @@ bun add @ontrails/store @ontrails/drizzle zod
30
30
 
31
31
  ## Migration
32
32
 
33
+ <!-- warden-ignore-next-line -->
33
34
  This package replaces the old `@ontrails/store/drizzle` subpath.
34
35
 
36
+ <!-- warden-ignore-next-line -->
35
37
  - Before: `import { connectDrizzle } from '@ontrails/store/drizzle'`
36
38
  - After: `import { connectDrizzle } from '@ontrails/drizzle'`
package/package.json CHANGED
@@ -1,6 +1,14 @@
1
1
  {
2
2
  "name": "@ontrails/drizzle",
3
- "version": "1.0.0-beta.15",
3
+ "version": "1.0.0-beta.16",
4
+ "files": [
5
+ "src/**/*.ts",
6
+ "!src/**/__tests__/**",
7
+ "!src/**/*.test.ts",
8
+ "!src/**/*.test-d.ts",
9
+ "README.md",
10
+ "CHANGELOG.md"
11
+ ],
4
12
  "type": "module",
5
13
  "exports": {
6
14
  ".": "./src/index.ts",
@@ -14,11 +22,11 @@
14
22
  "clean": "rm -rf dist *.tsbuildinfo"
15
23
  },
16
24
  "dependencies": {
17
- "@ontrails/core": "^1.0.0-beta.14",
25
+ "@ontrails/core": "^1.0.0-beta.15",
18
26
  "drizzle-orm": "^0.45.2"
19
27
  },
20
28
  "peerDependencies": {
21
- "@ontrails/store": "^1.0.0-beta.14",
29
+ "@ontrails/store": "^1.0.0-beta.15",
22
30
  "zod": "^4.3.5"
23
31
  }
24
32
  }
package/src/runtime.ts CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  resource,
12
12
  } from '@ontrails/core';
13
13
  import { versionFieldName } from '@ontrails/store';
14
- import { bindStoreDefinition } from '@ontrails/store/internal/signal-identity';
14
+ import { bindStoreDefinition } from '@ontrails/store/adapter-support';
15
15
  import type {
16
16
  AnyStoreDefinition,
17
17
  AnyStoreTable,
@@ -32,7 +32,7 @@ import { and, eq, sql } from 'drizzle-orm';
32
32
  import { drizzle } from 'drizzle-orm/bun-sqlite';
33
33
  import type { AnySQLiteColumn, AnySQLiteTable } from 'drizzle-orm/sqlite-core';
34
34
  import type { z } from 'zod';
35
- import type { TrailContext } from '@ontrails/core';
35
+ import type { Signal, TrailContext } from '@ontrails/core';
36
36
 
37
37
  import {
38
38
  deriveDrizzleTables,
@@ -196,7 +196,7 @@ const isVersionManagedField = <TTable extends AnyStoreTable>(
196
196
  /**
197
197
  * Synthesize a value for a generated field during insert.
198
198
  *
199
- * The connector recognizes these conventions for generated fields:
199
+ * The adapter recognizes these conventions for generated fields:
200
200
  *
201
201
  * - **Primary key** (`integer` type): auto-increment, left to SQLite.
202
202
  * - **Timestamp fields** (`createdAt`, `updatedAt`, `created_at`,
@@ -474,7 +474,7 @@ const ensureNotCyclic = (
474
474
  }
475
475
 
476
476
  throw new ValidationError(
477
- `Store definition contains a reference cycle involving "${tableName}", which the SQLite connector cannot seed automatically`
477
+ `Store definition contains a reference cycle involving "${tableName}", which the SQLite adapter cannot seed automatically`
478
478
  );
479
479
  };
480
480
 
@@ -1045,19 +1045,16 @@ type BoundFireFn = NonNullable<TrailContext['fire']>;
1045
1045
  */
1046
1046
  const fireDerivedSignal = async <TTable extends AnyStoreTable>(
1047
1047
  fire: BoundFireFn,
1048
- signalId: string,
1048
+ derivedSignal: Signal<unknown>,
1049
1049
  entity: EntityOf<TTable>
1050
1050
  ): Promise<void> => {
1051
1051
  try {
1052
- const fired = await fire(signalId, entity);
1053
- if (fired.isErr()) {
1054
- console.warn(
1055
- `[drizzle] signal "${signalId}" emission failed:`,
1056
- fired.error
1057
- );
1058
- }
1052
+ await fire(derivedSignal, entity);
1059
1053
  } catch (error) {
1060
- console.warn(`[drizzle] signal "${signalId}" emission threw:`, error);
1054
+ console.warn(
1055
+ `[drizzle] signal "${derivedSignal.id}" emission threw:`,
1056
+ error
1057
+ );
1061
1058
  }
1062
1059
  };
1063
1060
 
@@ -1084,7 +1081,7 @@ const bindWritableAccessorSignals = <TTable extends AnyStoreTable>(
1084
1081
  ...accessor,
1085
1082
  async insert(input: InsertOf<TTable>) {
1086
1083
  const created = await accessor.insert(input);
1087
- await fireDerivedSignal(fire, table.signals.created.id, created);
1084
+ await fireDerivedSignal(fire, table.signals.created, created);
1088
1085
  return created;
1089
1086
  },
1090
1087
  async remove(id: StoreIdentifierOf<TTable>) {
@@ -1095,7 +1092,7 @@ const bindWritableAccessorSignals = <TTable extends AnyStoreTable>(
1095
1092
  const existing = await accessor.get(id);
1096
1093
  const removed = await accessor.remove(id);
1097
1094
  if (removed.deleted && existing !== null) {
1098
- await fireDerivedSignal(fire, table.signals.removed.id, existing);
1095
+ await fireDerivedSignal(fire, table.signals.removed, existing);
1099
1096
  }
1100
1097
  return removed;
1101
1098
  },
@@ -1106,14 +1103,14 @@ const bindWritableAccessorSignals = <TTable extends AnyStoreTable>(
1106
1103
  // and fire unconditionally on successful update.
1107
1104
  const updated = await accessor.update(id, input);
1108
1105
  if (updated !== null) {
1109
- await fireDerivedSignal(fire, table.signals.updated.id, updated);
1106
+ await fireDerivedSignal(fire, table.signals.updated, updated);
1110
1107
  }
1111
1108
  return updated;
1112
1109
  }
1113
1110
  const existing = await accessor.get(id);
1114
1111
  const updated = await accessor.update(id, input);
1115
1112
  if (changedEntity(existing, updated)) {
1116
- await fireDerivedSignal(fire, table.signals.updated.id, updated);
1113
+ await fireDerivedSignal(fire, table.signals.updated, updated);
1117
1114
  }
1118
1115
  return updated;
1119
1116
  },
@@ -1128,12 +1125,12 @@ const bindWritableAccessorSignals = <TTable extends AnyStoreTable>(
1128
1125
  const written = await accessor.upsert(input);
1129
1126
 
1130
1127
  if (existing === null) {
1131
- await fireDerivedSignal(fire, table.signals.created.id, written);
1128
+ await fireDerivedSignal(fire, table.signals.created, written);
1132
1129
  return written;
1133
1130
  }
1134
1131
 
1135
1132
  if (changedEntity(existing, written)) {
1136
- await fireDerivedSignal(fire, table.signals.updated.id, written);
1133
+ await fireDerivedSignal(fire, table.signals.updated, written);
1137
1134
  }
1138
1135
  return written;
1139
1136
  },
@@ -1238,7 +1235,7 @@ const connectionHealth = (
1238
1235
  * `Database` client is tracked via `WeakMap`).
1239
1236
  *
1240
1237
  * Note: the `search` field on `StoreTableInput` is not yet interpreted by
1241
- * this connector — it is reserved for future full-text search support.
1238
+ * this adapter — it is reserved for future full-text search support.
1242
1239
  */
1243
1240
  export const connectDrizzle = <const TStore extends AnyStoreDefinition>(
1244
1241
  definition: TStore,
@@ -1264,6 +1261,14 @@ export const connectDrizzle = <const TStore extends AnyStoreDefinition>(
1264
1261
  throw error;
1265
1262
  }
1266
1263
  const db = drizzle({ client, schema: tables });
1264
+ if (options.seed !== undefined) {
1265
+ try {
1266
+ seedFixtures(store, tables, db, options.seed);
1267
+ } catch (error) {
1268
+ client.close();
1269
+ throw error;
1270
+ }
1271
+ }
1267
1272
  return Result.ok(createWritableConnection(store, tables, db, client));
1268
1273
  } catch (error) {
1269
1274
  return Result.err(
package/src/schema.ts CHANGED
@@ -200,7 +200,7 @@ const inferFieldKind = (
200
200
  }
201
201
  default: {
202
202
  throw new ValidationError(
203
- `Store field "${field}" uses unsupported schema type "${schema.def.type}" for the Drizzle SQLite connector`
203
+ `Store field "${field}" uses unsupported schema type "${schema.def.type}" for the Drizzle SQLite adapter`
204
204
  );
205
205
  }
206
206
  }
package/src/types.ts CHANGED
@@ -3,7 +3,8 @@ import type {
3
3
  AnyStoreDefinition,
4
4
  ReadOnlyStoreConnection,
5
5
  StoreAccessMode,
6
- StoreConnectorOptions,
6
+ StoreAdapterOptions,
7
+ StoreMockSeed,
7
8
  StoreTableConnection,
8
9
  } from '@ontrails/store';
9
10
  import type { BunSQLiteDatabase } from 'drizzle-orm/bun-sqlite';
@@ -21,17 +22,32 @@ export interface DrizzleQueryContext<TStore extends AnyStoreDefinition> {
21
22
  }
22
23
 
23
24
  /**
24
- * Options accepted by the Drizzle store connector.
25
+ * Options accepted by the Drizzle store adapter.
25
26
  *
26
- * Extends {@link StoreConnectorOptions} with drizzle-specific fields. The
27
+ * Extends {@link StoreAdapterOptions} with drizzle-specific fields. The
27
28
  * read-only vs writable distinction is enforced by the factory that consumes
28
29
  * these options, not by the options type itself.
29
30
  */
30
31
  export interface DrizzleStoreOptions<
31
32
  TDef extends AnyStoreDefinition = AnyStoreDefinition,
32
- > extends StoreConnectorOptions<TDef> {
33
+ > extends StoreAdapterOptions<TDef> {
33
34
  /** Path to the SQLite database file. Use `":memory:"` for ephemeral runs. */
34
35
  readonly url: string;
36
+ /**
37
+ * Optional fixture overrides applied when the writable runtime database is
38
+ * first created.
39
+ *
40
+ * Mirrors {@link StoreAdapterOptions.mockSeed} but for the `create`
41
+ * (runtime) path: when supplied, the adapter seeds these rows into the
42
+ * writable database immediately after schema initialization. Use this for
43
+ * demo/dogfood apps that want commands and examples to find pre-loaded
44
+ * entities on a fresh `:memory:` boot. Defaults to `undefined` — runtime
45
+ * databases are not auto-seeded from `table.fixtures`.
46
+ *
47
+ * Has no effect on the read-only adapter, which receives runtime data
48
+ * from disk rather than from fixtures.
49
+ */
50
+ readonly seed?: StoreMockSeed<TDef>;
35
51
  }
36
52
 
37
53
  export type ReadOnlyDrizzleStoreConnection<TStore extends AnyStoreDefinition> =
@@ -1 +0,0 @@
1
- $ tsc -b
@@ -1,3 +0,0 @@
1
- $ oxlint ./src
2
- Found 0 warnings and 0 errors.
3
- Finished in 62ms on 5 files with 93 rules using 24 threads.
@@ -1 +0,0 @@
1
- $ tsc --noEmit
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export { connectDrizzle, connectReadOnlyDrizzle } from './runtime.js';
2
- export type { DrizzleQueryContext, DrizzleStoreConnection, DrizzleStoreOptions, DrizzleStoreResource, DrizzleStoreSchema, ReadOnlyDrizzleStoreConnection, } from './types.js';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtE,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,8BAA8B,GAC/B,MAAM,YAAY,CAAC"}
package/dist/index.js DELETED
@@ -1,2 +0,0 @@
1
- export { connectDrizzle, connectReadOnlyDrizzle } from './runtime.js';
2
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC"}
package/dist/runtime.d.ts DELETED
@@ -1,17 +0,0 @@
1
- import type { AnyStoreDefinition } from '@ontrails/store';
2
- import type { DrizzleStoreConnection, DrizzleStoreOptions, DrizzleStoreResource, ReadOnlyDrizzleStoreConnection } from './types.js';
3
- /**
4
- * Bind a store definition to a Drizzle-backed SQLite resource.
5
- *
6
- * The returned resource manages its own connection lifecycle. The `mock()`
7
- * factory creates an in-memory SQLite database seeded with fixtures — callers
8
- * who obtain a mock connection are responsible for calling `closeConnection()`
9
- * when done, or letting the connection be garbage-collected (the underlying
10
- * `Database` client is tracked via `WeakMap`).
11
- *
12
- * Note: the `search` field on `StoreTableInput` is not yet interpreted by
13
- * this connector — it is reserved for future full-text search support.
14
- */
15
- export declare const connectDrizzle: <const TStore extends AnyStoreDefinition>(definition: TStore, options: DrizzleStoreOptions<TStore>) => DrizzleStoreResource<TStore, DrizzleStoreConnection<TStore>, "readwrite">;
16
- export declare const connectReadOnlyDrizzle: <const TStore extends AnyStoreDefinition>(definition: TStore, options: DrizzleStoreOptions<TStore>) => DrizzleStoreResource<TStore, ReadOnlyDrizzleStoreConnection<TStore>, "readonly">;
17
- //# sourceMappingURL=runtime.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,kBAAkB,EAcnB,MAAM,iBAAiB,CAAC;AAYzB,OAAO,KAAK,EACV,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EAEpB,8BAA8B,EAC/B,MAAM,YAAY,CAAC;AA+pCpB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,CAAC,MAAM,SAAS,kBAAkB,EACpE,YAAY,MAAM,EAClB,SAAS,mBAAmB,CAAC,MAAM,CAAC,KACnC,oBAAoB,CACrB,MAAM,EACN,sBAAsB,CAAC,MAAM,CAAC,EAC9B,WAAW,CAqDZ,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,KAAK,CAAC,MAAM,SAAS,kBAAkB,EAC5E,YAAY,MAAM,EAClB,SAAS,mBAAmB,CAAC,MAAM,CAAC,KACnC,oBAAoB,CACrB,MAAM,EACN,8BAA8B,CAAC,MAAM,CAAC,EACtC,UAAU,CAoCX,CAAC"}