@emulators/core 0.4.0 → 0.4.1

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.
Files changed (2) hide show
  1. package/README.md +51 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # @emulators/core
2
+
3
+ HTTP server, in-memory store, plugin interface, and middleware for emulate service plugins.
4
+
5
+ Part of [emulate](https://github.com/vercel-labs/emulate) — local drop-in replacement services for CI and no-network sandboxes.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @emulators/core
11
+ ```
12
+
13
+ ## Overview
14
+
15
+ The core provides the shared infrastructure that every `@emulators/*` service plugin builds on:
16
+
17
+ - **Store** — a generic in-memory store with typed `Collection<T>` instances supporting CRUD, indexing, filtering, and pagination
18
+ - **Server** — Hono-based HTTP server with automatic port management
19
+ - **Middleware** — bearer token auth, error handling, CORS
20
+ - **UI** — shared authorization/consent page rendering with bundled fonts
21
+ - **Persistence** — pluggable save/load adapters for state durability
22
+
23
+ ## Persistence
24
+
25
+ ### File persistence
26
+
27
+ For local development, use the built-in file adapter:
28
+
29
+ ```typescript
30
+ import { filePersistence } from '@emulators/core'
31
+
32
+ persistence: filePersistence('.emulate/state.json')
33
+ ```
34
+
35
+ ### Custom adapter
36
+
37
+ Any object with `load` and `save` methods works:
38
+
39
+ ```typescript
40
+ const kvAdapter = {
41
+ async load() { return await kv.get('emulate-state') },
42
+ async save(data: string) { await kv.set('emulate-state', data) },
43
+ }
44
+ ```
45
+
46
+ The persistence adapter is called on cold start (load) and after every mutating request (save). Saves are serialized via an internal queue to prevent race conditions.
47
+
48
+ ## Links
49
+
50
+ - [Full documentation](https://emulate.dev)
51
+ - [GitHub](https://github.com/vercel-labs/emulate)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emulators/core",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",