@effectstream/db-emulator 0.100.14 → 0.100.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/README.md CHANGED
@@ -1,34 +1,70 @@
1
1
  # @effectstream/db-emulator
2
2
 
3
- Database emulation utilities for Effectstream development and testing.
3
+ A standalone migration runner for EffectStream's database. Apply the
4
+ EffectStream system schema plus your migrations to a Postgres or PgLite
5
+ instance without booting the full runtime — handy for unit tests and CI
6
+ fixtures.
4
7
 
5
- ## Purpose
8
+ - Standalone migration runner: apply Effectstream's system schema + your migrations to a fresh DB.
9
+ - For tests and CI fixtures; do not point at a production database.
10
+ - Exists separately from `@effectstream/db` to break a circular dep with `@effectstream/sm`.
11
+ - Single export: `standAloneApplyMigrations`.
6
12
 
7
- This package provides utilities for applying database migrations in test
8
- environments and during development. It was separated from `@effectstream/db` to break
9
- the circular dependency between `@effectstream/db` and `@effectstream/sm`.
13
+ ## Install
10
14
 
11
- ## Dependencies
15
+ ```bash
16
+ bun add @effectstream/db-emulator
17
+ # or
18
+ npm install @effectstream/db-emulator
19
+ ```
12
20
 
13
- - `@effectstream/db` - Core database functionality
14
- - `@effectstream/sm` - State machine primitives (for built-in primitives map)
21
+ This package exists separately from `@effectstream/db` to break the
22
+ circular dependency between `@effectstream/db` and `@effectstream/sm` —
23
+ both of which `standAloneApplyMigrations` needs.
15
24
 
16
- ## Usage
25
+ ## Standalone usage
17
26
 
18
27
  ```typescript
19
28
  import { getConnection } from "@effectstream/db";
20
29
  import { standAloneApplyMigrations } from "@effectstream/db-emulator";
30
+ import { localhostConfig } from "./config.ts";
31
+ import { migrationTable } from "./migrations.ts";
21
32
 
22
33
  const db = await getConnection();
23
34
  await standAloneApplyMigrations(
24
35
  db,
25
36
  migrationTable,
26
37
  localhostConfig,
27
- userDefinedPrimitives, // optional
38
+ /* userDefinedPrimitives */ undefined,
28
39
  );
29
40
  ```
30
41
 
31
- ## Note
42
+ You're left with a database that has every EffectStream system table
43
+ plus your migrations applied, ready for tests to read and write
44
+ directly against the client returned by `getConnection()`.
45
+
46
+ > Use only against ephemeral / in-memory databases. The function
47
+ > assumes it owns the schema.
48
+
49
+ ## Inside EffectStream
50
+
51
+ Designed for use in tests and migration tooling. Pair with
52
+ [`@effectstream/db/start-pglite`](https://www.npmjs.com/package/@effectstream/db)
53
+ for a quick in-memory database that's ready for app code to read /
54
+ write.
55
+
56
+ ## Key exports
57
+
58
+ - `standAloneApplyMigrations(db, migrationTable, config, userPrimitives?)` — apply the EffectStream system migrations plus your own, against the given pg client.
59
+
60
+ ## Examples
61
+
62
+ Runnable: [`test/examples.test.ts`](./test/examples.test.ts).
63
+
64
+ For the broader migration pattern, see
65
+ `templates/*/packages/client/database/sql-to-ts.ts`.
66
+
67
+ ## Links
32
68
 
33
- This is primarily a development/testing utility. Production applications
34
- typically use the migration system directly through `@effectstream/db`.
69
+ - Docs: https://effectstream.github.io/docs/packages/node/db-emulator
70
+ - Source: https://github.com/effectstream/effectstream/tree/main/packages/node-sdk/db-emulator
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effectstream/db-emulator",
3
- "version": "0.100.14",
3
+ "version": "0.100.16",
4
4
  "license": "MIT",
5
5
  "homepage": "https://effectstream.github.io/docs/",
6
6
  "repository": {
@@ -0,0 +1,8 @@
1
+ // Examples for the README — verify the public surface resolves.
2
+
3
+ import { test, expect } from "bun:test";
4
+ import { standAloneApplyMigrations } from "../mod.ts";
5
+
6
+ test("README: standAloneApplyMigrations is exported as a function", () => {
7
+ expect(typeof standAloneApplyMigrations).toBe("function");
8
+ });