@effectstream/db-emulator 0.100.14 → 0.100.15
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 +45 -14
- package/package.json +1 -1
- package/test/examples.test.ts +8 -0
package/README.md
CHANGED
|
@@ -1,34 +1,65 @@
|
|
|
1
1
|
# @effectstream/db-emulator
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
##
|
|
8
|
+
## Install
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
```bash
|
|
11
|
+
bun add @effectstream/db-emulator
|
|
12
|
+
# or
|
|
13
|
+
npm install @effectstream/db-emulator
|
|
14
|
+
```
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
This package exists separately from `@effectstream/db` to break the
|
|
17
|
+
circular dependency between `@effectstream/db` and `@effectstream/sm` —
|
|
18
|
+
both of which `standAloneApplyMigrations` needs.
|
|
15
19
|
|
|
16
|
-
##
|
|
20
|
+
## Standalone usage
|
|
17
21
|
|
|
18
22
|
```typescript
|
|
19
23
|
import { getConnection } from "@effectstream/db";
|
|
20
24
|
import { standAloneApplyMigrations } from "@effectstream/db-emulator";
|
|
25
|
+
import { localhostConfig } from "./config.ts";
|
|
26
|
+
import { migrationTable } from "./migrations.ts";
|
|
21
27
|
|
|
22
28
|
const db = await getConnection();
|
|
23
29
|
await standAloneApplyMigrations(
|
|
24
30
|
db,
|
|
25
31
|
migrationTable,
|
|
26
32
|
localhostConfig,
|
|
27
|
-
userDefinedPrimitives
|
|
33
|
+
/* userDefinedPrimitives */ undefined,
|
|
28
34
|
);
|
|
29
35
|
```
|
|
30
36
|
|
|
31
|
-
|
|
37
|
+
You're left with a database that has every EffectStream system table
|
|
38
|
+
plus your migrations applied, ready for tests to read and write
|
|
39
|
+
directly against the client returned by `getConnection()`.
|
|
40
|
+
|
|
41
|
+
> Use only against ephemeral / in-memory databases. The function
|
|
42
|
+
> assumes it owns the schema.
|
|
43
|
+
|
|
44
|
+
## Inside EffectStream
|
|
45
|
+
|
|
46
|
+
Designed for use in tests and migration tooling. Pair with
|
|
47
|
+
[`@effectstream/db/start-pglite`](https://www.npmjs.com/package/@effectstream/db)
|
|
48
|
+
for a quick in-memory database that's ready for app code to read /
|
|
49
|
+
write.
|
|
50
|
+
|
|
51
|
+
## Key exports
|
|
52
|
+
|
|
53
|
+
- `standAloneApplyMigrations(db, migrationTable, config, userPrimitives?)` — apply the EffectStream system migrations plus your own, against the given pg client.
|
|
54
|
+
|
|
55
|
+
## Examples
|
|
56
|
+
|
|
57
|
+
Runnable: [`test/examples.test.ts`](./test/examples.test.ts).
|
|
58
|
+
|
|
59
|
+
For the broader migration pattern, see
|
|
60
|
+
`templates/*/packages/client/database/sql-to-ts.ts`.
|
|
61
|
+
|
|
62
|
+
## Links
|
|
32
63
|
|
|
33
|
-
|
|
34
|
-
|
|
64
|
+
- Docs: https://effectstream.github.io/docs/packages/node/db-emulator
|
|
65
|
+
- Source: https://github.com/PaimaStudios/paima-engine/tree/main/packages/node-sdk/db-emulator
|
package/package.json
CHANGED
|
@@ -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
|
+
});
|