@temporal-contract/contract 2.3.1 → 3.0.0

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 CHANGED
@@ -32,11 +32,11 @@ export const myContract = defineContract({
32
32
 
33
33
  ## Documentation
34
34
 
35
- 📖 **[Read the full documentation →](https://btravers.github.io/temporal-contract)**
35
+ 📖 **[Read the full documentation →](https://btravstack.github.io/temporal-contract)**
36
36
 
37
- - [API Reference](https://btravers.github.io/temporal-contract/api/contract)
38
- - [Getting Started](https://btravers.github.io/temporal-contract/guide/getting-started)
39
- - [Core Concepts](https://btravers.github.io/temporal-contract/guide/core-concepts)
37
+ - [API Reference](https://btravstack.github.io/temporal-contract/api/contract)
38
+ - [Getting Started](https://btravstack.github.io/temporal-contract/guide/getting-started)
39
+ - [Core Concepts](https://btravstack.github.io/temporal-contract/guide/core-concepts)
40
40
 
41
41
  ## License
42
42
 
@@ -1,41 +1,57 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- let neverthrow = require("neverthrow");
2
+ let unthrown = require("unthrown");
3
3
  //#region src/result-async.ts
4
4
  /**
5
5
  * Internal helper shared across `@temporal-contract/client` and
6
6
  * `@temporal-contract/worker` for wrapping a result-producing async function
7
- * in a `ResultAsync` while routing any unhandled rejection through a typed
8
- * mapper.
7
+ * in an `AsyncResult`, routing any unanticipated rejection through unthrown's
8
+ * `defect` channel.
9
9
  *
10
10
  * Lives in `@temporal-contract/contract` so the two consuming packages don't
11
11
  * each carry their own copy. Exported from the package's public surface
12
- * under a deliberately-internal-looking name (`_internal_makeResultAsync`)
12
+ * under a deliberately-internal-looking name (`_internal_makeAsyncResult`)
13
13
  * so users don't import it by accident — there is no semver guarantee on
14
14
  * this entry point.
15
15
  */
16
16
  /**
17
- * Wrap an async function returning `Promise<Result<T, E>>` in a
18
- * `ResultAsync<T, E>`, catching synchronous throws and rejected promises
19
- * and routing them through `mapRejection` so they surface as typed
20
- * `err(...)` instead of unhandled rejections.
17
+ * Wrap an async function returning `Promise<Result<T, E>>` in an
18
+ * `AsyncResult<T, E>`, catching synchronous throws and rejected promises and
19
+ * routing them through unthrown's `defect` channel so an *unanticipated*
20
+ * failure surfaces as a defect (a bug, re-thrown at the edge) rather than an
21
+ * unhandled rejection, while the work function's own domain `err(...)` flows
22
+ * through untouched.
21
23
  *
22
- * `new ResultAsync(promise)` does **not** catch rejections the resulting
23
- * `ResultAsync` rejects, escaping neverthrow's railway. This helper closes
24
- * that gap. The work function is expected to handle its own domain errors
25
- * and return `err(...)` for them; `mapRejection` is a safety net for
26
- * thrown exceptions the work didn't anticipate.
24
+ * `fromSafePromise(thunk)` invokes the thunk, capturing both a synchronous
25
+ * throw before the promise is produced and an eventual rejection as a `defect`
26
+ * (its error channel is `never`) — the work function is expected to model its
27
+ * own domain errors as `err(...)`, so any *thrown* failure is by definition
28
+ * unmodeled. The `.flatMap((inner) => inner)` flattens the nested
29
+ * `Result<T, E>` the thunk resolves with, surfacing its modeled error channel.
27
30
  *
28
- * @internal — exported under `_internal_makeResultAsync` for use by the
31
+ * @internal — exported under `_internal_makeAsyncResult` for use by the
29
32
  * sibling client and worker packages. Not part of the public API.
30
33
  */
31
- function _internal_makeResultAsync(work, mapRejection) {
32
- let promise;
33
- try {
34
- promise = work();
35
- } catch (error) {
36
- promise = Promise.resolve((0, neverthrow.err)(mapRejection(error)));
37
- }
38
- return new neverthrow.ResultAsync(promise.catch((e) => (0, neverthrow.err)(mapRejection(e))));
34
+ function _internal_makeAsyncResult(work) {
35
+ return (0, unthrown.fromSafePromise)(work).flatMap((inner) => inner);
36
+ }
37
+ /**
38
+ * Assert that a `Result` is not a `Defect`, narrowing it to `Ok | Err`.
39
+ *
40
+ * unthrown's `Result<T, E>` type always includes the out-of-band `Defect`
41
+ * variant, so `if (r.isErr()) else r.value` does not type-check — the `else`
42
+ * branch is still `Ok | Defect`. For an internally-produced result that is
43
+ * *known* to be built only from `ok(...)` / `err(...)`, this collapses the
44
+ * "impossible defect" case in one call: it re-throws a present defect's cause
45
+ * (so a genuine bug still rides the defect channel at the boundary) and
46
+ * narrows the result to `Ok | Err` for the caller, which can then branch on
47
+ * `isErr` / `isOk` and reach `.value` / `.error` cleanly.
48
+ *
49
+ * @internal — exported under `_internal_assertNoDefect` for the sibling client
50
+ * and worker packages. Not part of the public API.
51
+ */
52
+ function _internal_assertNoDefect(result) {
53
+ if (result.isDefect()) throw result.cause;
39
54
  }
40
55
  //#endregion
41
- exports._internal_makeResultAsync = _internal_makeResultAsync;
56
+ exports._internal_assertNoDefect = _internal_assertNoDefect;
57
+ exports._internal_makeAsyncResult = _internal_makeAsyncResult;
@@ -1,22 +1,41 @@
1
- import { Result, ResultAsync } from "neverthrow";
1
+ import { AsyncResult, ErrView, OkView, Result } from "unthrown";
2
2
 
3
3
  //#region src/result-async.d.ts
4
4
  /**
5
- * Wrap an async function returning `Promise<Result<T, E>>` in a
6
- * `ResultAsync<T, E>`, catching synchronous throws and rejected promises
7
- * and routing them through `mapRejection` so they surface as typed
8
- * `err(...)` instead of unhandled rejections.
5
+ * Wrap an async function returning `Promise<Result<T, E>>` in an
6
+ * `AsyncResult<T, E>`, catching synchronous throws and rejected promises and
7
+ * routing them through unthrown's `defect` channel so an *unanticipated*
8
+ * failure surfaces as a defect (a bug, re-thrown at the edge) rather than an
9
+ * unhandled rejection, while the work function's own domain `err(...)` flows
10
+ * through untouched.
9
11
  *
10
- * `new ResultAsync(promise)` does **not** catch rejections the resulting
11
- * `ResultAsync` rejects, escaping neverthrow's railway. This helper closes
12
- * that gap. The work function is expected to handle its own domain errors
13
- * and return `err(...)` for them; `mapRejection` is a safety net for
14
- * thrown exceptions the work didn't anticipate.
12
+ * `fromSafePromise(thunk)` invokes the thunk, capturing both a synchronous
13
+ * throw before the promise is produced and an eventual rejection as a `defect`
14
+ * (its error channel is `never`) — the work function is expected to model its
15
+ * own domain errors as `err(...)`, so any *thrown* failure is by definition
16
+ * unmodeled. The `.flatMap((inner) => inner)` flattens the nested
17
+ * `Result<T, E>` the thunk resolves with, surfacing its modeled error channel.
15
18
  *
16
- * @internal — exported under `_internal_makeResultAsync` for use by the
19
+ * @internal — exported under `_internal_makeAsyncResult` for use by the
17
20
  * sibling client and worker packages. Not part of the public API.
18
21
  */
19
- declare function _internal_makeResultAsync<T, E>(work: () => Promise<Result<T, E>>, mapRejection: (error: unknown) => E): ResultAsync<T, E>;
22
+ declare function _internal_makeAsyncResult<T, E>(work: () => Promise<Result<T, E>>): AsyncResult<T, E>;
23
+ /**
24
+ * Assert that a `Result` is not a `Defect`, narrowing it to `Ok | Err`.
25
+ *
26
+ * unthrown's `Result<T, E>` type always includes the out-of-band `Defect`
27
+ * variant, so `if (r.isErr()) … else r.value` does not type-check — the `else`
28
+ * branch is still `Ok | Defect`. For an internally-produced result that is
29
+ * *known* to be built only from `ok(...)` / `err(...)`, this collapses the
30
+ * "impossible defect" case in one call: it re-throws a present defect's cause
31
+ * (so a genuine bug still rides the defect channel at the boundary) and
32
+ * narrows the result to `Ok | Err` for the caller, which can then branch on
33
+ * `isErr` / `isOk` and reach `.value` / `.error` cleanly.
34
+ *
35
+ * @internal — exported under `_internal_assertNoDefect` for the sibling client
36
+ * and worker packages. Not part of the public API.
37
+ */
38
+ declare function _internal_assertNoDefect<T, E>(result: Result<T, E>): asserts result is OkView<T, E> | ErrView<E, T>;
20
39
  //#endregion
21
- export { _internal_makeResultAsync };
40
+ export { _internal_assertNoDefect, _internal_makeAsyncResult };
22
41
  //# sourceMappingURL=result-async.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"result-async.d.cts","names":[],"sources":["../src/result-async.ts"],"mappings":";;;;;;;;;;;;;;;;;;iBA6BgB,yBAAA,OACd,IAAA,QAAY,OAAA,CAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,IAC9B,YAAA,GAAe,KAAA,cAAmB,CAAA,GACjC,WAAA,CAAY,CAAA,EAAG,CAAA"}
1
+ {"version":3,"file":"result-async.d.cts","names":[],"sources":["../src/result-async.ts"],"mappings":";;;;;;;;;;;;;;;;AAwCmB;AAmBnB;;;;iBArBgB,yBAAA,OACd,IAAA,QAAY,OAAA,CAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,KAC7B,WAAA,CAAY,CAAA,EAAG,CAAA;;;;;;;;;;;;;;;;iBAmBF,wBAAA,OACd,MAAA,EAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,YACT,MAAA,IAAU,MAAA,CAAO,CAAA,EAAG,CAAA,IAAK,OAAA,CAAQ,CAAA,EAAG,CAAA"}
@@ -1,22 +1,41 @@
1
- import { Result, ResultAsync } from "neverthrow";
1
+ import { AsyncResult, ErrView, OkView, Result } from "unthrown";
2
2
 
3
3
  //#region src/result-async.d.ts
4
4
  /**
5
- * Wrap an async function returning `Promise<Result<T, E>>` in a
6
- * `ResultAsync<T, E>`, catching synchronous throws and rejected promises
7
- * and routing them through `mapRejection` so they surface as typed
8
- * `err(...)` instead of unhandled rejections.
5
+ * Wrap an async function returning `Promise<Result<T, E>>` in an
6
+ * `AsyncResult<T, E>`, catching synchronous throws and rejected promises and
7
+ * routing them through unthrown's `defect` channel so an *unanticipated*
8
+ * failure surfaces as a defect (a bug, re-thrown at the edge) rather than an
9
+ * unhandled rejection, while the work function's own domain `err(...)` flows
10
+ * through untouched.
9
11
  *
10
- * `new ResultAsync(promise)` does **not** catch rejections the resulting
11
- * `ResultAsync` rejects, escaping neverthrow's railway. This helper closes
12
- * that gap. The work function is expected to handle its own domain errors
13
- * and return `err(...)` for them; `mapRejection` is a safety net for
14
- * thrown exceptions the work didn't anticipate.
12
+ * `fromSafePromise(thunk)` invokes the thunk, capturing both a synchronous
13
+ * throw before the promise is produced and an eventual rejection as a `defect`
14
+ * (its error channel is `never`) — the work function is expected to model its
15
+ * own domain errors as `err(...)`, so any *thrown* failure is by definition
16
+ * unmodeled. The `.flatMap((inner) => inner)` flattens the nested
17
+ * `Result<T, E>` the thunk resolves with, surfacing its modeled error channel.
15
18
  *
16
- * @internal — exported under `_internal_makeResultAsync` for use by the
19
+ * @internal — exported under `_internal_makeAsyncResult` for use by the
17
20
  * sibling client and worker packages. Not part of the public API.
18
21
  */
19
- declare function _internal_makeResultAsync<T, E>(work: () => Promise<Result<T, E>>, mapRejection: (error: unknown) => E): ResultAsync<T, E>;
22
+ declare function _internal_makeAsyncResult<T, E>(work: () => Promise<Result<T, E>>): AsyncResult<T, E>;
23
+ /**
24
+ * Assert that a `Result` is not a `Defect`, narrowing it to `Ok | Err`.
25
+ *
26
+ * unthrown's `Result<T, E>` type always includes the out-of-band `Defect`
27
+ * variant, so `if (r.isErr()) … else r.value` does not type-check — the `else`
28
+ * branch is still `Ok | Defect`. For an internally-produced result that is
29
+ * *known* to be built only from `ok(...)` / `err(...)`, this collapses the
30
+ * "impossible defect" case in one call: it re-throws a present defect's cause
31
+ * (so a genuine bug still rides the defect channel at the boundary) and
32
+ * narrows the result to `Ok | Err` for the caller, which can then branch on
33
+ * `isErr` / `isOk` and reach `.value` / `.error` cleanly.
34
+ *
35
+ * @internal — exported under `_internal_assertNoDefect` for the sibling client
36
+ * and worker packages. Not part of the public API.
37
+ */
38
+ declare function _internal_assertNoDefect<T, E>(result: Result<T, E>): asserts result is OkView<T, E> | ErrView<E, T>;
20
39
  //#endregion
21
- export { _internal_makeResultAsync };
40
+ export { _internal_assertNoDefect, _internal_makeAsyncResult };
22
41
  //# sourceMappingURL=result-async.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"result-async.d.mts","names":[],"sources":["../src/result-async.ts"],"mappings":";;;;;;;;;;;;;;;;;;iBA6BgB,yBAAA,OACd,IAAA,QAAY,OAAA,CAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,IAC9B,YAAA,GAAe,KAAA,cAAmB,CAAA,GACjC,WAAA,CAAY,CAAA,EAAG,CAAA"}
1
+ {"version":3,"file":"result-async.d.mts","names":[],"sources":["../src/result-async.ts"],"mappings":";;;;;;;;;;;;;;;;AAwCmB;AAmBnB;;;;iBArBgB,yBAAA,OACd,IAAA,QAAY,OAAA,CAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,KAC7B,WAAA,CAAY,CAAA,EAAG,CAAA;;;;;;;;;;;;;;;;iBAmBF,wBAAA,OACd,MAAA,EAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,YACT,MAAA,IAAU,MAAA,CAAO,CAAA,EAAG,CAAA,IAAK,OAAA,CAAQ,CAAA,EAAG,CAAA"}
@@ -1,42 +1,57 @@
1
- import { ResultAsync, err } from "neverthrow";
1
+ import { fromSafePromise } from "unthrown";
2
2
  //#region src/result-async.ts
3
3
  /**
4
4
  * Internal helper shared across `@temporal-contract/client` and
5
5
  * `@temporal-contract/worker` for wrapping a result-producing async function
6
- * in a `ResultAsync` while routing any unhandled rejection through a typed
7
- * mapper.
6
+ * in an `AsyncResult`, routing any unanticipated rejection through unthrown's
7
+ * `defect` channel.
8
8
  *
9
9
  * Lives in `@temporal-contract/contract` so the two consuming packages don't
10
10
  * each carry their own copy. Exported from the package's public surface
11
- * under a deliberately-internal-looking name (`_internal_makeResultAsync`)
11
+ * under a deliberately-internal-looking name (`_internal_makeAsyncResult`)
12
12
  * so users don't import it by accident — there is no semver guarantee on
13
13
  * this entry point.
14
14
  */
15
15
  /**
16
- * Wrap an async function returning `Promise<Result<T, E>>` in a
17
- * `ResultAsync<T, E>`, catching synchronous throws and rejected promises
18
- * and routing them through `mapRejection` so they surface as typed
19
- * `err(...)` instead of unhandled rejections.
16
+ * Wrap an async function returning `Promise<Result<T, E>>` in an
17
+ * `AsyncResult<T, E>`, catching synchronous throws and rejected promises and
18
+ * routing them through unthrown's `defect` channel so an *unanticipated*
19
+ * failure surfaces as a defect (a bug, re-thrown at the edge) rather than an
20
+ * unhandled rejection, while the work function's own domain `err(...)` flows
21
+ * through untouched.
20
22
  *
21
- * `new ResultAsync(promise)` does **not** catch rejections the resulting
22
- * `ResultAsync` rejects, escaping neverthrow's railway. This helper closes
23
- * that gap. The work function is expected to handle its own domain errors
24
- * and return `err(...)` for them; `mapRejection` is a safety net for
25
- * thrown exceptions the work didn't anticipate.
23
+ * `fromSafePromise(thunk)` invokes the thunk, capturing both a synchronous
24
+ * throw before the promise is produced and an eventual rejection as a `defect`
25
+ * (its error channel is `never`) — the work function is expected to model its
26
+ * own domain errors as `err(...)`, so any *thrown* failure is by definition
27
+ * unmodeled. The `.flatMap((inner) => inner)` flattens the nested
28
+ * `Result<T, E>` the thunk resolves with, surfacing its modeled error channel.
26
29
  *
27
- * @internal — exported under `_internal_makeResultAsync` for use by the
30
+ * @internal — exported under `_internal_makeAsyncResult` for use by the
28
31
  * sibling client and worker packages. Not part of the public API.
29
32
  */
30
- function _internal_makeResultAsync(work, mapRejection) {
31
- let promise;
32
- try {
33
- promise = work();
34
- } catch (error) {
35
- promise = Promise.resolve(err(mapRejection(error)));
36
- }
37
- return new ResultAsync(promise.catch((e) => err(mapRejection(e))));
33
+ function _internal_makeAsyncResult(work) {
34
+ return fromSafePromise(work).flatMap((inner) => inner);
35
+ }
36
+ /**
37
+ * Assert that a `Result` is not a `Defect`, narrowing it to `Ok | Err`.
38
+ *
39
+ * unthrown's `Result<T, E>` type always includes the out-of-band `Defect`
40
+ * variant, so `if (r.isErr()) else r.value` does not type-check — the `else`
41
+ * branch is still `Ok | Defect`. For an internally-produced result that is
42
+ * *known* to be built only from `ok(...)` / `err(...)`, this collapses the
43
+ * "impossible defect" case in one call: it re-throws a present defect's cause
44
+ * (so a genuine bug still rides the defect channel at the boundary) and
45
+ * narrows the result to `Ok | Err` for the caller, which can then branch on
46
+ * `isErr` / `isOk` and reach `.value` / `.error` cleanly.
47
+ *
48
+ * @internal — exported under `_internal_assertNoDefect` for the sibling client
49
+ * and worker packages. Not part of the public API.
50
+ */
51
+ function _internal_assertNoDefect(result) {
52
+ if (result.isDefect()) throw result.cause;
38
53
  }
39
54
  //#endregion
40
- export { _internal_makeResultAsync };
55
+ export { _internal_assertNoDefect, _internal_makeAsyncResult };
41
56
 
42
57
  //# sourceMappingURL=result-async.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"result-async.mjs","names":[],"sources":["../src/result-async.ts"],"sourcesContent":["/**\n * Internal helper shared across `@temporal-contract/client` and\n * `@temporal-contract/worker` for wrapping a result-producing async function\n * in a `ResultAsync` while routing any unhandled rejection through a typed\n * mapper.\n *\n * Lives in `@temporal-contract/contract` so the two consuming packages don't\n * each carry their own copy. Exported from the package's public surface\n * under a deliberately-internal-looking name (`_internal_makeResultAsync`)\n * so users don't import it by accident — there is no semver guarantee on\n * this entry point.\n */\nimport { ResultAsync, type Result, err } from \"neverthrow\";\n\n/**\n * Wrap an async function returning `Promise<Result<T, E>>` in a\n * `ResultAsync<T, E>`, catching synchronous throws and rejected promises\n * and routing them through `mapRejection` so they surface as typed\n * `err(...)` instead of unhandled rejections.\n *\n * `new ResultAsync(promise)` does **not** catch rejections the resulting\n * `ResultAsync` rejects, escaping neverthrow's railway. This helper closes\n * that gap. The work function is expected to handle its own domain errors\n * and return `err(...)` for them; `mapRejection` is a safety net for\n * thrown exceptions the work didn't anticipate.\n *\n * @internal — exported under `_internal_makeResultAsync` for use by the\n * sibling client and worker packages. Not part of the public API.\n */\nexport function _internal_makeResultAsync<T, E>(\n work: () => Promise<Result<T, E>>,\n mapRejection: (error: unknown) => E,\n): ResultAsync<T, E> {\n let promise: Promise<Result<T, E>>;\n try {\n promise = work();\n } catch (error) {\n // Synchronous throw before the function returned its promise. Without\n // this branch, `work()` blowing up synchronously would surface as a\n // thrown error from the constructor call rather than an `err(...)`.\n promise = Promise.resolve(err(mapRejection(error)));\n }\n return new ResultAsync<T, E>(promise.catch((e: unknown) => err(mapRejection(e))));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,0BACd,MACA,cACmB;CACnB,IAAI;CACJ,IAAI;EACF,UAAU,KAAK;CACjB,SAAS,OAAO;EAId,UAAU,QAAQ,QAAQ,IAAI,aAAa,KAAK,CAAC,CAAC;CACpD;CACA,OAAO,IAAI,YAAkB,QAAQ,OAAO,MAAe,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;AAClF"}
1
+ {"version":3,"file":"result-async.mjs","names":[],"sources":["../src/result-async.ts"],"sourcesContent":["/**\n * Internal helper shared across `@temporal-contract/client` and\n * `@temporal-contract/worker` for wrapping a result-producing async function\n * in an `AsyncResult`, routing any unanticipated rejection through unthrown's\n * `defect` channel.\n *\n * Lives in `@temporal-contract/contract` so the two consuming packages don't\n * each carry their own copy. Exported from the package's public surface\n * under a deliberately-internal-looking name (`_internal_makeAsyncResult`)\n * so users don't import it by accident — there is no semver guarantee on\n * this entry point.\n */\nimport {\n fromSafePromise,\n type AsyncResult,\n type ErrView,\n type OkView,\n type Result,\n} from \"unthrown\";\n\n/**\n * Wrap an async function returning `Promise<Result<T, E>>` in an\n * `AsyncResult<T, E>`, catching synchronous throws and rejected promises and\n * routing them through unthrown's `defect` channel — so an *unanticipated*\n * failure surfaces as a defect (a bug, re-thrown at the edge) rather than an\n * unhandled rejection, while the work function's own domain `err(...)` flows\n * through untouched.\n *\n * `fromSafePromise(thunk)` invokes the thunk, capturing both a synchronous\n * throw before the promise is produced and an eventual rejection as a `defect`\n * (its error channel is `never`) — the work function is expected to model its\n * own domain errors as `err(...)`, so any *thrown* failure is by definition\n * unmodeled. The `.flatMap((inner) => inner)` flattens the nested\n * `Result<T, E>` the thunk resolves with, surfacing its modeled error channel.\n *\n * @internal — exported under `_internal_makeAsyncResult` for use by the\n * sibling client and worker packages. Not part of the public API.\n */\nexport function _internal_makeAsyncResult<T, E>(\n work: () => Promise<Result<T, E>>,\n): AsyncResult<T, E> {\n return fromSafePromise(work).flatMap((inner) => inner);\n}\n\n/**\n * Assert that a `Result` is not a `Defect`, narrowing it to `Ok | Err`.\n *\n * unthrown's `Result<T, E>` type always includes the out-of-band `Defect`\n * variant, so `if (r.isErr()) … else r.value` does not type-check — the `else`\n * branch is still `Ok | Defect`. For an internally-produced result that is\n * *known* to be built only from `ok(...)` / `err(...)`, this collapses the\n * \"impossible defect\" case in one call: it re-throws a present defect's cause\n * (so a genuine bug still rides the defect channel at the boundary) and\n * narrows the result to `Ok | Err` for the caller, which can then branch on\n * `isErr` / `isOk` and reach `.value` / `.error` cleanly.\n *\n * @internal exported under `_internal_assertNoDefect` for the sibling client\n * and worker packages. Not part of the public API.\n */\nexport function _internal_assertNoDefect<T, E>(\n result: Result<T, E>,\n): asserts result is OkView<T, E> | ErrView<E, T> {\n if (result.isDefect()) {\n throw result.cause;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,0BACd,MACmB;CACnB,OAAO,gBAAgB,IAAI,CAAC,CAAC,SAAS,UAAU,KAAK;AACvD;;;;;;;;;;;;;;;;AAiBA,SAAgB,yBACd,QACgD;CAChD,IAAI,OAAO,SAAS,GAClB,MAAM,OAAO;AAEjB"}
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "@temporal-contract/contract",
3
- "version": "2.3.1",
3
+ "version": "3.0.0",
4
4
  "description": "Contract builder for temporal-contract",
5
5
  "keywords": [
6
6
  "contract",
7
7
  "temporal",
8
8
  "typescript"
9
9
  ],
10
- "homepage": "https://github.com/btravers/temporal-contract#readme",
10
+ "homepage": "https://github.com/btravstack/temporal-contract#readme",
11
11
  "bugs": {
12
- "url": "https://github.com/btravers/temporal-contract/issues"
12
+ "url": "https://github.com/btravstack/temporal-contract/issues"
13
13
  },
14
14
  "license": "MIT",
15
15
  "author": "Benoit TRAVERS <benoit.travers.fr@gmail.com>",
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "https://github.com/btravers/temporal-contract.git",
18
+ "url": "https://github.com/btravstack/temporal-contract.git",
19
19
  "directory": "packages/contract"
20
20
  },
21
21
  "files": [
@@ -53,26 +53,30 @@
53
53
  "zod": "4.4.3"
54
54
  },
55
55
  "devDependencies": {
56
+ "@unthrown/vitest": "0.2.0",
56
57
  "@vitest/coverage-v8": "4.1.8",
57
- "arktype": "2.2.0",
58
- "neverthrow": "8.2.0",
59
- "tsdown": "0.22.2",
58
+ "arktype": "2.2.1",
59
+ "tsdown": "0.22.3",
60
60
  "typedoc": "0.28.19",
61
61
  "typedoc-plugin-markdown": "4.12.0",
62
62
  "typescript": "6.0.3",
63
+ "unthrown": "0.2.0",
63
64
  "valibot": "1.4.1",
64
65
  "vitest": "4.1.8",
65
66
  "@temporal-contract/tsconfig": "1.0.0",
66
67
  "@temporal-contract/typedoc": "0.1.0"
67
68
  },
68
69
  "peerDependencies": {
69
- "neverthrow": "^8"
70
+ "unthrown": "^0.2"
70
71
  },
71
72
  "peerDependenciesMeta": {
72
- "neverthrow": {
73
+ "unthrown": {
73
74
  "optional": true
74
75
  }
75
76
  },
77
+ "engines": {
78
+ "node": ">=22.19.0"
79
+ },
76
80
  "scripts": {
77
81
  "build": "tsdown src/index.ts src/result-async.ts --format cjs,esm --dts --clean",
78
82
  "build:docs": "typedoc",