@effect-agent/storage-cloudflare 0.1.0-beta.37 → 0.1.0-beta.39

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.
@@ -0,0 +1,33 @@
1
+ import { d as DoStorageFailpointLocation, n as DoStorageFailpointHandler, t as DoStorageFailpoint } from "./do-storage-failpoint-9XB9tuif.mjs";
2
+ import { Context, Effect, Layer } from "effect";
3
+ //#region src/do-storage-failpoint-testing.d.ts
4
+ declare const DoStorageFailpointTestControl_base: Context.ServiceClass<DoStorageFailpointTestControl, "@effect-agent/storage-cloudflare/DoStorageFailpointTestControl", {
5
+ readonly clear: Effect.Effect<void>;
6
+ readonly setHandler: (handler: DoStorageFailpointHandler) => Effect.Effect<void>;
7
+ }>;
8
+ /** Test-only control for replacing the active Durable Object failpoint handler. */
9
+ declare class DoStorageFailpointTestControl extends DoStorageFailpointTestControl_base {
10
+ /** Reusable test Layer with a control service backed by the same handler Ref. */
11
+ static readonly layer: Layer.Layer<DoStorageFailpoint | DoStorageFailpointTestControl, never, never>;
12
+ }
13
+ /**
14
+ * The DC-specific eviction failpoint mode: instead of failing typed, an armed hit evicts the
15
+ * Durable Object through an injected `evict` thunk — in production-shaped harnesses that thunk
16
+ * is `() => ctx.abort()`, the platform's real failure mode. `ctx.abort()` never returns (it
17
+ * throws while destroying the in-memory instance and every in-flight implicit or explicit
18
+ * storage transaction rolls back), so an armed hit ends the current Attempt exactly like an
19
+ * unannounced platform eviction; DO storage — the only correctness-critical state — survives
20
+ * for the next incarnation, which the persisted alarm wakes without any incoming request.
21
+ *
22
+ * The handles stay injected: this package never imports `cloudflare:workers`, so the harness
23
+ * that owns a `DurableObjectState` supplies the thunk.
24
+ */
25
+ declare const evictionFailpointHandler: (options: {
26
+ readonly isArmed: (location: DoStorageFailpointLocation) => Effect.Effect<boolean>;
27
+ /** Kills the incarnation — e.g. `() => ctx.abort()`. Typed `void` because the platform
28
+ * declares `abort` as returning, but it throws while destroying the instance. */
29
+ readonly evict: (location: DoStorageFailpointLocation) => void;
30
+ }) => DoStorageFailpointHandler;
31
+ //#endregion
32
+ export { DoStorageFailpointTestControl, evictionFailpointHandler };
33
+ //# sourceMappingURL=testing.d.mts.map
@@ -0,0 +1,35 @@
1
+ import { t as DoStorageFailpoint } from "./do-storage-failpoint-C-Qtchs7.mjs";
2
+ import { Context, Effect, Layer, Ref } from "effect";
3
+ //#region src/do-storage-failpoint-testing.ts
4
+ const noFailpoint = () => Effect.void;
5
+ /** Test-only control for replacing the active Durable Object failpoint handler. */
6
+ var DoStorageFailpointTestControl = class DoStorageFailpointTestControl extends Context.Service()("@effect-agent/storage-cloudflare/DoStorageFailpointTestControl") {
7
+ /** Reusable test Layer with a control service backed by the same handler Ref. */
8
+ static layer = Layer.effectContext(Effect.gen(function* () {
9
+ const handler = yield* Ref.make(noFailpoint);
10
+ return Context.make(DoStorageFailpoint, DoStorageFailpoint.of({ hit: (location) => Ref.get(handler).pipe(Effect.flatMap((current) => current(location))) })).pipe(Context.add(DoStorageFailpointTestControl, DoStorageFailpointTestControl.of({
11
+ clear: Ref.set(handler, noFailpoint),
12
+ setHandler: (next) => Ref.set(handler, next)
13
+ })));
14
+ }));
15
+ };
16
+ /**
17
+ * The DC-specific eviction failpoint mode: instead of failing typed, an armed hit evicts the
18
+ * Durable Object through an injected `evict` thunk — in production-shaped harnesses that thunk
19
+ * is `() => ctx.abort()`, the platform's real failure mode. `ctx.abort()` never returns (it
20
+ * throws while destroying the in-memory instance and every in-flight implicit or explicit
21
+ * storage transaction rolls back), so an armed hit ends the current Attempt exactly like an
22
+ * unannounced platform eviction; DO storage — the only correctness-critical state — survives
23
+ * for the next incarnation, which the persisted alarm wakes without any incoming request.
24
+ *
25
+ * The handles stay injected: this package never imports `cloudflare:workers`, so the harness
26
+ * that owns a `DurableObjectState` supplies the thunk.
27
+ */
28
+ const evictionFailpointHandler = (options) => (location) => options.isArmed(location).pipe(Effect.flatMap((armed) => armed ? Effect.sync(() => {
29
+ options.evict(location);
30
+ throw new Error(`Durable Object eviction did not interrupt execution at ${location}.`);
31
+ }) : Effect.void));
32
+ //#endregion
33
+ export { DoStorageFailpointTestControl, evictionFailpointHandler };
34
+
35
+ //# sourceMappingURL=testing.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.mjs","names":[],"sources":["../src/do-storage-failpoint-testing.ts"],"sourcesContent":["import { Context, Effect, Layer, Ref } from \"effect\";\n\nimport { DoStorageFailpoint, type DoStorageFailpointHandler } from \"./do-storage-failpoint.ts\";\nimport type { DoStorageFailpointLocation } from \"./errors.ts\";\n\nconst noFailpoint: DoStorageFailpointHandler = () => Effect.void;\n\n/** Test-only control for replacing the active Durable Object failpoint handler. */\nexport class DoStorageFailpointTestControl extends Context.Service<\n DoStorageFailpointTestControl,\n {\n readonly clear: Effect.Effect<void>;\n readonly setHandler: (handler: DoStorageFailpointHandler) => Effect.Effect<void>;\n }\n>()(\"@effect-agent/storage-cloudflare/DoStorageFailpointTestControl\") {\n /** Reusable test Layer with a control service backed by the same handler Ref. */\n static readonly layer = Layer.effectContext(\n Effect.gen(function* () {\n const handler = yield* Ref.make<DoStorageFailpointHandler>(noFailpoint);\n return Context.make(\n DoStorageFailpoint,\n DoStorageFailpoint.of({\n hit: (location) => Ref.get(handler).pipe(Effect.flatMap((current) => current(location))),\n }),\n ).pipe(\n Context.add(\n DoStorageFailpointTestControl,\n DoStorageFailpointTestControl.of({\n clear: Ref.set(handler, noFailpoint),\n setHandler: (next) => Ref.set(handler, next),\n }),\n ),\n );\n }),\n );\n}\n\n/**\n * The DC-specific eviction failpoint mode: instead of failing typed, an armed hit evicts the\n * Durable Object through an injected `evict` thunk — in production-shaped harnesses that thunk\n * is `() => ctx.abort()`, the platform's real failure mode. `ctx.abort()` never returns (it\n * throws while destroying the in-memory instance and every in-flight implicit or explicit\n * storage transaction rolls back), so an armed hit ends the current Attempt exactly like an\n * unannounced platform eviction; DO storage — the only correctness-critical state — survives\n * for the next incarnation, which the persisted alarm wakes without any incoming request.\n *\n * The handles stay injected: this package never imports `cloudflare:workers`, so the harness\n * that owns a `DurableObjectState` supplies the thunk.\n */\nexport const evictionFailpointHandler =\n (options: {\n readonly isArmed: (location: DoStorageFailpointLocation) => Effect.Effect<boolean>;\n /** Kills the incarnation — e.g. `() => ctx.abort()`. Typed `void` because the platform\n * declares `abort` as returning, but it throws while destroying the instance. */\n readonly evict: (location: DoStorageFailpointLocation) => void;\n }): DoStorageFailpointHandler =>\n (location) =>\n options.isArmed(location).pipe(\n Effect.flatMap((armed) =>\n armed\n ? // `ctx.abort()` throws while destroying the instance; that throw surfaces as a\n // defect in the (already dying) incarnation. The defensive throw below keeps the\n // guarantee — nothing after an armed hit may observe in-memory state — even if a\n // harness supplies an evict thunk that returns.\n Effect.sync((): never => {\n options.evict(location);\n throw new Error(\n `Durable Object eviction did not interrupt execution at ${location}.`,\n );\n })\n : Effect.void,\n ),\n );\n"],"mappings":";;;AAKA,MAAM,oBAA+C,OAAO;;AAG5D,IAAa,gCAAb,MAAa,sCAAsC,QAAQ,QAMzD,CAAC,CAAC,gEAAgE,CAAC,CAAC;;CAEpE,OAAgB,QAAQ,MAAM,cAC5B,OAAO,IAAI,aAAa;EACtB,MAAM,UAAU,OAAO,IAAI,KAAgC,WAAW;EACtE,OAAO,QAAQ,KACb,oBACA,mBAAmB,GAAG,EACpB,MAAM,aAAa,IAAI,IAAI,OAAO,CAAC,CAAC,KAAK,OAAO,SAAS,YAAY,QAAQ,QAAQ,CAAC,CAAC,EACzF,CAAC,CACH,CAAC,CAAC,KACA,QAAQ,IACN,+BACA,8BAA8B,GAAG;GAC/B,OAAO,IAAI,IAAI,SAAS,WAAW;GACnC,aAAa,SAAS,IAAI,IAAI,SAAS,IAAI;EAC7C,CAAC,CACH,CACF;CACF,CAAC,CACH;AACF;;;;;;;;;;;;;AAcA,MAAa,4BACV,aAMA,aACC,QAAQ,QAAQ,QAAQ,CAAC,CAAC,KACxB,OAAO,SAAS,UACd,QAKI,OAAO,WAAkB;CACvB,QAAQ,MAAM,QAAQ;CACtB,MAAM,IAAI,MACR,0DAA0D,SAAS,EACrE;AACF,CAAC,IACD,OAAO,IACb,CACF"}
package/package.json CHANGED
@@ -1,17 +1,23 @@
1
1
  {
2
2
  "name": "@effect-agent/storage-cloudflare",
3
- "version": "0.1.0-beta.37",
3
+ "version": "0.1.0-beta.39",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.mts",
7
7
  "default": "./dist/index.mjs"
8
+ },
9
+ "./testing": {
10
+ "types": "./dist/testing.d.mts",
11
+ "default": "./dist/testing.mjs"
8
12
  }
9
13
  },
10
14
  "dependencies": {
11
- "@effect-agent/session": "0.1.0-beta.37",
15
+ "@effect-agent/thread": "0.1.0-beta.39",
12
16
  "@effect/platform-browser": "4.0.0-rc.111",
13
- "@effect/sql-sqlite-do": "4.0.0-rc.111",
14
- "effect": "4.0.0-rc.111"
17
+ "@effect/sql-sqlite-do": "4.0.0-rc.111"
18
+ },
19
+ "peerDependencies": {
20
+ "effect": "^4.0.0-rc.111"
15
21
  },
16
22
  "description": "Durable Object SQLite storage adapters and the routed port protocol for Effect Agent on Cloudflare.",
17
23
  "license": "MIT",
@@ -35,8 +41,9 @@
35
41
  "devDependencies": {
36
42
  "@cloudflare/vitest-pool-workers": "0.21.3",
37
43
  "@cloudflare/workers-types": "5.20260825.1",
38
- "@effect-agent/testing": "0.1.0-beta.35",
44
+ "@effect-agent/testing": "0.1.0-beta.38",
39
45
  "@effect/vitest": "4.0.0-rc.111",
46
+ "effect": "4.0.0-rc.111",
40
47
  "typescript": "7.0.2",
41
48
  "vite-plus": "0.2.6",
42
49
  "vitest": "4.1.10"