Skip to content

Commit 2cf5a02

Browse files
author
Taras Mankovski
committed
refactor(durable-effects): switch to workspace dep, re-export runtime from durable-streams
Replace preview URL dependency with workspace:* for durable-streams. Replace runtime.ts implementation with re-exports from durable-streams. Add durable-streams to tsconfig references for type resolution.
1 parent c4b380b commit 2cf5a02

4 files changed

Lines changed: 59 additions & 106 deletions

File tree

durable-effects/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"effection": "^3 || ^4"
1818
},
1919
"dependencies": {
20-
"@effectionx/durable-streams": "https://pkg.pr.new/thefrontside/effectionx/@effectionx/durable-streams@179",
20+
"@effectionx/durable-streams": "workspace:*",
2121
"@effectionx/fetch": "workspace:*",
2222
"@effectionx/fs": "workspace:*",
2323
"@effectionx/process": "workspace:*"

durable-effects/runtime.ts

Lines changed: 10 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,14 @@
11
/**
2-
* DurableRuntime — platform-agnostic runtime abstraction for durable effects.
2+
* Re-exports DurableRuntime types from @effectionx/durable-streams.
33
*
4-
* Effects must not depend on Node-specific or Deno-specific APIs directly.
5-
* This interface provides all platform operations. Every I/O method returns
6-
* `Operation<T>`, not `Promise<T>`. Cancellation flows through Effection's
7-
* structured concurrency — when a scope tears down, the operation is
8-
* cancelled. No `AbortSignal` in the interface.
9-
*
10-
* Install via `scope.set(DurableRuntimeCtx, nodeRuntime())` before calling
11-
* `durableRun`. Effects access the runtime inside `createDurableOperation`
12-
* callbacks via `scope.expect<DurableRuntime>(DurableRuntimeCtx)`.
13-
*/
14-
15-
import { createContext } from "effection";
16-
import type { Context, Operation } from "effection";
17-
18-
/**
19-
* Minimal response headers interface.
20-
*
21-
* Uses a minimal interface instead of the global `Headers` type to avoid
22-
* requiring DOM lib types in tsconfig.
23-
*/
24-
export interface ResponseHeaders {
25-
get(key: string): string | null;
26-
}
27-
28-
/**
29-
* Response shape returned by `DurableRuntime.fetch()`.
30-
*
31-
* Both the response object and `text()` are Operation-native — no Promises
32-
* cross the interface boundary.
33-
*/
34-
export interface RuntimeFetchResponse {
35-
status: number;
36-
headers: ResponseHeaders;
37-
/** Read the response body as text. */
38-
text(): Operation<string>;
39-
}
40-
41-
/**
42-
* Platform-agnostic runtime for durable effects.
43-
*
44-
* Implementations exist for Node.js (`nodeRuntime()`) and testing
45-
* (`stubRuntime()`). Future implementations may cover Deno or browsers.
4+
* The canonical definitions live in durable-streams. This re-export
5+
* keeps existing imports within durable-effects working without
6+
* mass import-path changes.
467
*/
47-
export interface DurableRuntime {
48-
/** Execute a subprocess. Cancellation kills the process. */
49-
exec(options: {
50-
command: string[];
51-
cwd?: string;
52-
env?: Record<string, string>;
53-
timeout?: number;
54-
}): Operation<{ exitCode: number; stdout: string; stderr: string }>;
55-
56-
/** Read a text file. */
57-
readTextFile(path: string): Operation<string>;
58-
59-
/** Expand glob patterns. Returns relative paths with isFile flag. */
60-
glob(options: {
61-
patterns: string[];
62-
root: string;
63-
exclude?: string[];
64-
}): Operation<Array<{ path: string; isFile: boolean }>>;
65-
66-
/** Make an HTTP request. Cancellation aborts the request. */
67-
fetch(
68-
input: string,
69-
init?: {
70-
method?: string;
71-
headers?: Record<string, string>;
72-
body?: string;
73-
timeout?: number;
74-
},
75-
): Operation<RuntimeFetchResponse>;
768

77-
/** Read an environment variable. Returns undefined if not set. */
78-
env(name: string): string | undefined;
79-
80-
/** Return platform information. */
81-
platform(): { os: string; arch: string };
82-
}
83-
84-
/**
85-
* Effection Context for the DurableRuntime.
86-
*
87-
* Set on the scope before calling `durableRun()`. Effects access the
88-
* runtime via `scope.expect<DurableRuntime>(DurableRuntimeCtx)`.
89-
*/
90-
export const DurableRuntimeCtx: Context<DurableRuntime> =
91-
createContext<DurableRuntime>("@effectionx/durable-effects/runtime");
9+
export { DurableRuntimeCtx } from "@effectionx/durable-streams";
10+
export type {
11+
DurableRuntime,
12+
ResponseHeaders,
13+
RuntimeFetchResponse,
14+
} from "@effectionx/durable-streams";

durable-effects/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
{
1111
"path": "../bdd"
1212
},
13+
{
14+
"path": "../durable-streams"
15+
},
1316
{
1417
"path": "../fetch"
1518
},

pnpm-lock.yaml

Lines changed: 45 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)