@coji/durably 0.1.0 → 0.1.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 +74 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # @coji/durably
2
+
3
+ Step-oriented resumable batch execution for Node.js and browsers using SQLite.
4
+
5
+ **[Documentation](https://coji.github.io/durably/)** | **[GitHub](https://github.com/coji/durably)** | **[Live Demo](https://durably-demo.vercel.app)**
6
+
7
+ ## Features
8
+
9
+ - Resumable batch processing with step-level persistence
10
+ - Works in both Node.js and browsers
11
+ - Uses SQLite for state management (better-sqlite3/libsql for Node.js, SQLite WASM for browsers)
12
+ - Minimal dependencies - just Kysely and Zod as peer dependencies
13
+ - Event system for monitoring and extensibility
14
+ - Type-safe input/output with Zod schemas
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ # Node.js with better-sqlite3
20
+ npm install @coji/durably kysely zod better-sqlite3
21
+
22
+ # Node.js with libsql
23
+ npm install @coji/durably kysely zod @libsql/client @libsql/kysely-libsql
24
+
25
+ # Browser with SQLocal
26
+ npm install @coji/durably kysely zod sqlocal
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ ```ts
32
+ import { createDurably } from '@coji/durably'
33
+ import SQLite from 'better-sqlite3'
34
+ import { SqliteDialect } from 'kysely'
35
+ import { z } from 'zod'
36
+
37
+ const dialect = new SqliteDialect({
38
+ database: new SQLite('local.db'),
39
+ })
40
+
41
+ const durably = createDurably({ dialect })
42
+
43
+ const syncUsers = durably.defineJob(
44
+ {
45
+ name: 'sync-users',
46
+ input: z.object({ orgId: z.string() }),
47
+ output: z.object({ syncedCount: z.number() }),
48
+ },
49
+ async (context, payload) => {
50
+ const users = await context.run('fetch-users', async () => {
51
+ return api.fetchUsers(payload.orgId)
52
+ })
53
+
54
+ await context.run('save-to-db', async () => {
55
+ await db.upsertUsers(users)
56
+ })
57
+
58
+ return { syncedCount: users.length }
59
+ },
60
+ )
61
+
62
+ await durably.migrate()
63
+ durably.start()
64
+
65
+ await syncUsers.trigger({ orgId: 'org_123' })
66
+ ```
67
+
68
+ ## Documentation
69
+
70
+ For full documentation, visit [coji.github.io/durably](https://coji.github.io/durably/).
71
+
72
+ ## License
73
+
74
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coji/durably",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Step-oriented resumable batch execution for Node.js and browsers using SQLite",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -16,7 +16,8 @@
16
16
  }
17
17
  },
18
18
  "files": [
19
- "dist"
19
+ "dist",
20
+ "README.md"
20
21
  ],
21
22
  "keywords": [
22
23
  "batch",