@coji/durably 0.0.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.
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # durably
2
+
3
+ Step-oriented resumable batch execution for Node.js and browsers using SQLite.
4
+
5
+ > **Note**: This package is under development. The API is not yet implemented.
6
+
7
+ ## Features (Planned)
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, or WASM)
12
+ - Minimal dependencies - just Kysely as a peer dependency
13
+ - Event system for monitoring and extensibility
14
+ - Plugin architecture for optional features
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install durably kysely better-sqlite3
20
+ ```
21
+
22
+ ## Usage (Preview)
23
+
24
+ ```ts
25
+ import { createClient, defineJob } from 'durably'
26
+ import Database from 'better-sqlite3'
27
+ import { BetterSqlite3Dialect } from 'kysely'
28
+
29
+ const dialect = new BetterSqlite3Dialect({
30
+ database: new Database('app.db'),
31
+ })
32
+
33
+ const client = createClient({ dialect })
34
+
35
+ const syncUsers = defineJob('sync-users', async (ctx, payload: { orgId: string }) => {
36
+ const users = await ctx.run('fetch-users', async () => {
37
+ return api.fetchUsers(payload.orgId)
38
+ })
39
+
40
+ await ctx.run('save-to-db', async () => {
41
+ await db.upsertUsers(users)
42
+ })
43
+ })
44
+
45
+ client.register(syncUsers)
46
+ await client.migrate()
47
+ client.start()
48
+
49
+ await syncUsers.trigger({ orgId: 'org_123' })
50
+ ```
51
+
52
+ ## License
53
+
54
+ MIT
@@ -0,0 +1,55 @@
1
+ /**
2
+ * durably - Step-oriented resumable batch execution for Node.js and browsers
3
+ *
4
+ * This package is under development. See https://github.com/coji/durably for updates.
5
+ */
6
+ interface ClientOptions {
7
+ dialect: unknown;
8
+ pollingInterval?: number;
9
+ heartbeatInterval?: number;
10
+ staleThreshold?: number;
11
+ }
12
+ interface JobContext<TPayload> {
13
+ run<T>(name: string, fn: () => Promise<T>): Promise<T>;
14
+ log: {
15
+ info(message: string, data?: Record<string, unknown>): void;
16
+ warn(message: string, data?: Record<string, unknown>): void;
17
+ error(message: string, data?: Record<string, unknown>): void;
18
+ };
19
+ }
20
+ interface Job<TPayload> {
21
+ name: string;
22
+ trigger(payload: TPayload, options?: {
23
+ idempotencyKey?: string;
24
+ concurrencyKey?: string;
25
+ }): Promise<{
26
+ runId: string;
27
+ }>;
28
+ batchTrigger(items: Array<{
29
+ payload: TPayload;
30
+ options?: {
31
+ idempotencyKey?: string;
32
+ concurrencyKey?: string;
33
+ };
34
+ }>): Promise<Array<{
35
+ runId: string;
36
+ }>>;
37
+ }
38
+ interface Client {
39
+ register<TPayload>(job: Job<TPayload>): void;
40
+ migrate(): Promise<void>;
41
+ start(): void;
42
+ stop(): Promise<void>;
43
+ retry(runId: string): Promise<void>;
44
+ getRuns(filter?: {
45
+ status?: string;
46
+ }): Promise<Array<{
47
+ id: string;
48
+ }>>;
49
+ on(event: string, handler: (event: unknown) => void): void;
50
+ use(plugin: unknown): void;
51
+ }
52
+ declare function createClient(_options: ClientOptions): Client;
53
+ declare function defineJob<TPayload>(_name: string, _handler: (ctx: JobContext<TPayload>, payload: TPayload) => Promise<void>): Job<TPayload>;
54
+
55
+ export { type Client, type ClientOptions, type Job, type JobContext, createClient, defineJob };
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ // src/index.ts
2
+ function createClient(_options) {
3
+ throw new Error(
4
+ "durably is not yet implemented. This is a placeholder package. See https://github.com/coji/durably for updates."
5
+ );
6
+ }
7
+ function defineJob(_name, _handler) {
8
+ throw new Error(
9
+ "durably is not yet implemented. This is a placeholder package. See https://github.com/coji/durably for updates."
10
+ );
11
+ }
12
+ export {
13
+ createClient,
14
+ defineJob
15
+ };
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * durably - Step-oriented resumable batch execution for Node.js and browsers\n *\n * This package is under development. See https://github.com/coji/durably for updates.\n */\n\nexport interface ClientOptions {\n dialect: unknown\n pollingInterval?: number\n heartbeatInterval?: number\n staleThreshold?: number\n}\n\nexport interface JobContext<TPayload> {\n run<T>(name: string, fn: () => Promise<T>): Promise<T>\n log: {\n info(message: string, data?: Record<string, unknown>): void\n warn(message: string, data?: Record<string, unknown>): void\n error(message: string, data?: Record<string, unknown>): void\n }\n}\n\nexport interface Job<TPayload> {\n name: string\n trigger(\n payload: TPayload,\n options?: { idempotencyKey?: string; concurrencyKey?: string }\n ): Promise<{ runId: string }>\n batchTrigger(\n items: Array<{\n payload: TPayload\n options?: { idempotencyKey?: string; concurrencyKey?: string }\n }>\n ): Promise<Array<{ runId: string }>>\n}\n\nexport interface Client {\n register<TPayload>(job: Job<TPayload>): void\n migrate(): Promise<void>\n start(): void\n stop(): Promise<void>\n retry(runId: string): Promise<void>\n getRuns(filter?: { status?: string }): Promise<Array<{ id: string }>>\n on(event: string, handler: (event: unknown) => void): void\n use(plugin: unknown): void\n}\n\nexport function createClient(_options: ClientOptions): Client {\n throw new Error(\n 'durably is not yet implemented. This is a placeholder package. See https://github.com/coji/durably for updates.'\n )\n}\n\nexport function defineJob<TPayload>(\n _name: string,\n _handler: (ctx: JobContext<TPayload>, payload: TPayload) => Promise<void>\n): Job<TPayload> {\n throw new Error(\n 'durably is not yet implemented. This is a placeholder package. See https://github.com/coji/durably for updates.'\n )\n}\n"],"mappings":";AA+CO,SAAS,aAAa,UAAiC;AAC5D,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AAEO,SAAS,UACd,OACA,UACe;AACf,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * durably plugins
3
+ *
4
+ * This package is under development. See https://github.com/coji/durably for updates.
5
+ */
6
+ declare function withLogPersistence(): unknown;
7
+
8
+ export { withLogPersistence };
@@ -0,0 +1,10 @@
1
+ // src/plugins/index.ts
2
+ function withLogPersistence() {
3
+ throw new Error(
4
+ "durably is not yet implemented. This is a placeholder package. See https://github.com/coji/durably for updates."
5
+ );
6
+ }
7
+ export {
8
+ withLogPersistence
9
+ };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/plugins/index.ts"],"sourcesContent":["/**\n * durably plugins\n *\n * This package is under development. See https://github.com/coji/durably for updates.\n */\n\nexport function withLogPersistence(): unknown {\n throw new Error(\n 'durably is not yet implemented. This is a placeholder package. See https://github.com/coji/durably for updates.'\n )\n}\n"],"mappings":";AAMO,SAAS,qBAA8B;AAC5C,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@coji/durably",
3
+ "version": "0.0.1",
4
+ "description": "Step-oriented resumable batch execution for Node.js and browsers using SQLite",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./plugins": {
15
+ "types": "./dist/plugins/index.d.ts",
16
+ "import": "./dist/plugins/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "keywords": [
23
+ "batch",
24
+ "job",
25
+ "queue",
26
+ "workflow",
27
+ "durable",
28
+ "resumable",
29
+ "sqlite",
30
+ "kysely"
31
+ ],
32
+ "author": "",
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/coji/durably.git"
37
+ },
38
+ "bugs": {
39
+ "url": "https://github.com/coji/durably/issues"
40
+ },
41
+ "homepage": "https://github.com/coji/durably#readme",
42
+ "peerDependencies": {
43
+ "kysely": ">=0.27.0"
44
+ },
45
+ "peerDependenciesMeta": {
46
+ "kysely": {
47
+ "optional": true
48
+ }
49
+ },
50
+ "devDependencies": {
51
+ "kysely": "^0.27.0",
52
+ "tsup": "8.5.1",
53
+ "typescript": "^5.7.2"
54
+ },
55
+ "scripts": {
56
+ "build": "tsup"
57
+ }
58
+ }