Skip to content

Commit fe7bda3

Browse files
Benoit Traversclaude
authored andcommitted
chore(deps): bump unthrown to 5.0.0 and migrate tag to P.tag
unthrown 5.0.0 is out. The only API change since 5.0.0-beta.7 is that the standalone `tag` export moved onto the pattern namespace as `P.tag(t)`, so every call site, TSDoc example, README and doc page is updated and the peer range is raised to `^5.0.0`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 9ec2a82 commit fe7bda3

30 files changed

Lines changed: 206 additions & 156 deletions
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
"@temporal-contract/contract": patch
3+
"@temporal-contract/client": patch
4+
"@temporal-contract/worker": patch
5+
---
6+
7+
Bump `unthrown` to the stable `5.0.0` and raise the peer range to `^5.0.0`.
8+
9+
The only API change since `5.0.0-beta.7` is that the standalone `tag` export is
10+
gone — it now lives on the pattern namespace as `P.tag(t)`, alongside every
11+
other pattern constructor (`P._` / `P.any` / `P.instanceOf` / `P.when` /
12+
`P.union`). The type and runtime behaviour are unchanged: it still produces the
13+
`{ _tag: t }` pattern, still narrows to the matching variant with its payload,
14+
and still works in grouped patterns.
15+
16+
Migration is mechanical — drop `tag` from the import (keeping or adding `P`) and
17+
prefix the call sites:
18+
19+
```diff
20+
- import { tag } from "unthrown";
21+
+ import { P } from "unthrown";
22+
23+
result.mapErrCases((matcher) =>
24+
- matcher.with(tag("@temporal-contract/WorkflowFailedError"), (error) => handle(error)),
25+
+ matcher.with(P.tag("@temporal-contract/WorkflowFailedError"), (error) => handle(error)),
26+
);
27+
```
28+
29+
Every example in the docs, READMEs and TSDoc has been updated to the `P.tag`
30+
spelling, and the upgrade guide gained a note for anyone already tracking an
31+
8.0 beta.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ result.match({
9393
ok: (output) => console.log(output.transactionId),
9494
errCases: (matcher) =>
9595
matcher.with(
96-
tag("@temporal-contract/WorkflowValidationError"),
97-
tag("@temporal-contract/WorkflowFailedError"),
96+
P.tag("@temporal-contract/WorkflowValidationError"),
97+
P.tag("@temporal-contract/WorkflowFailedError"),
9898
// ...exhaustive — a missing tag is a compile error
9999
(error) => console.error(error.message),
100100
),

docs/explanation/the-result-model.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,16 @@ The `errCases` handler and the `*ErrCases` combinators receive a matcher rather
121121
than the bare error:
122122

123123
```typescript
124-
import { tag } from "unthrown";
124+
import { P } from "unthrown";
125125

126126
result.match({
127127
ok: (output) => output.transactionId,
128128
errCases: (matcher) =>
129129
matcher
130-
.with(tag("@temporal-contract/ContractError"), (e) => handleDomain(e))
130+
.with(P.tag("@temporal-contract/ContractError"), (e) => handleDomain(e))
131131
.with(
132-
tag("@temporal-contract/WorkflowFailedError"),
133-
tag("@temporal-contract/WorkflowExecutionNotFoundError"),
132+
P.tag("@temporal-contract/WorkflowFailedError"),
133+
P.tag("@temporal-contract/WorkflowExecutionNotFoundError"),
134134
(e) => handleInfra(e),
135135
),
136136
defect: (cause) => report(cause),

docs/how-to/add-activity-middleware.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ import {
3838
declareActivitiesHandler,
3939
type ActivityMiddleware,
4040
} from "@temporal-contract/worker/activity";
41-
import { P, tag } from "unthrown";
41+
import { P } from "unthrown";
4242

4343
const logging: ActivityMiddleware = ({ activityName, workflowName }, next) =>
4444
next().tapErrCases((matcher) =>
4545
matcher.with(
4646
P.instanceOf(ApplicationFailure),
47-
tag("@temporal-contract/ContractError"),
47+
P.tag("@temporal-contract/ContractError"),
4848
(error) => {
4949
logger.warn({ activityName, workflowName, error }, "activity failed");
5050
},

docs/how-to/install.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ describes a compatible set. Do not mix versions.
5454
These are peers, not dependencies, because they appear in the packages' public
5555
types. Your code and the library must resolve to the _same_ copy.
5656

57-
| Peer | Required by | Range |
58-
| ---------------------- | ------------------------ | --------------- |
59-
| `unthrown` | contract, worker, client | `^5.0.0-beta.7` |
60-
| `@temporalio/common` | worker, client | `^1` |
61-
| `@temporalio/worker` | worker, testing | `^1` |
62-
| `@temporalio/workflow` | worker | `^1` |
63-
| `@temporalio/client` | client, testing | `^1` |
64-
| `@temporalio/testing` | testing | `^1` |
65-
| `vitest` | testing | `^4` |
57+
| Peer | Required by | Range |
58+
| ---------------------- | ------------------------ | -------- |
59+
| `unthrown` | contract, worker, client | `^5.0.0` |
60+
| `@temporalio/common` | worker, client | `^1` |
61+
| `@temporalio/worker` | worker, testing | `^1` |
62+
| `@temporalio/workflow` | worker | `^1` |
63+
| `@temporalio/client` | client, testing | `^1` |
64+
| `@temporalio/testing` | testing | `^1` |
65+
| `vitest` | testing | `^4` |
6666

6767
Plus a [Standard Schema](https://standardschema.dev/) library to write your
6868
schemas with — Zod, Valibot, or ArkType.

docs/how-to/intercept-client-calls.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ Modeled domain errors (`WorkflowNotFoundError`, a `ContractError`, a validation
9595
failure) stay on the `err` channel. Branch on those with `flatMapErrCases`:
9696

9797
```typescript
98-
import { Err, Ok, P, tag } from "unthrown";
98+
import { Err, Ok, P } from "unthrown";
9999

100100
const fallback: ClientInterceptor = (args, next) =>
101101
next().flatMapErrCases((matcher) =>
102102
matcher
103103
// Idempotent start: treat "already running" as success.
104-
.with(tag("@temporal-contract/WorkflowAlreadyStartedError"), () => Ok(undefined).toAsync())
104+
.with(P.tag("@temporal-contract/WorkflowAlreadyStartedError"), () => Ok(undefined).toAsync())
105105
// The matcher must cover the whole union — `P._` passes the rest through.
106106
.with(P._, (error) => Err(error).toAsync()),
107107
);
@@ -110,7 +110,7 @@ const fallback: ClientInterceptor = (args, next) =>
110110
::: warning The matcher is exhaustive
111111
`flatMapErrCases`, `mapErrCases`, `tapErrCases`, and `recoverErrCases` all
112112
require a match that covers every member of the error union — here the nine
113-
members of `ClientCallError`. A single `.with(tag(...))` arm will not compile.
113+
members of `ClientCallError`. A single `.with(P.tag(...))` arm will not compile.
114114
Handle the cases you care about, then close with `P._`.
115115
:::
116116

docs/how-to/migrate-from-neverthrow.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ exhaustive matcher instead of the bare error:
104104
result.mapErr((error) => new WrappedError(error));
105105

106106
// after — one arm per tag in the union (abbreviated here; see the note below)
107-
import { tag } from "unthrown";
107+
import { P } from "unthrown";
108108

109109
result.mapErrCases((matcher) =>
110-
matcher.with(tag("@temporal-contract/WorkflowFailedError"), (error) => new WrappedError(error)),
110+
matcher.with(P.tag("@temporal-contract/WorkflowFailedError"), (error) => new WrappedError(error)),
111111
);
112112
```
113113

@@ -125,9 +125,9 @@ into one branch is compact:
125125

126126
```typescript
127127
matcher.with(
128-
tag("@temporal-contract/WorkflowNotFoundError"),
129-
tag("@temporal-contract/WorkflowValidationError"),
130-
tag("@temporal-contract/WorkflowFailedError"),
128+
P.tag("@temporal-contract/WorkflowNotFoundError"),
129+
P.tag("@temporal-contract/WorkflowValidationError"),
130+
P.tag("@temporal-contract/WorkflowFailedError"),
131131
(error) => report(error),
132132
);
133133
```
@@ -146,8 +146,8 @@ const message = result.match({
146146
ok: (value) => `charged ${value.transactionId}`,
147147
errCases: (matcher) =>
148148
matcher.with(
149-
tag("@temporal-contract/WorkflowFailedError"),
150-
tag("@temporal-contract/WorkflowValidationError"),
149+
P.tag("@temporal-contract/WorkflowFailedError"),
150+
P.tag("@temporal-contract/WorkflowValidationError"),
151151
(error) => `failed: ${error.message}`,
152152
),
153153
defect: (cause) => `unexpected: ${String(cause)}`,

docs/how-to/model-domain-errors.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Declaring errors on an activity **changes its workflow-side call signature.**
129129
So an errors-declaring activity is awaited as a result, not a plain value:
130130

131131
```typescript
132-
import { tag } from "unthrown";
132+
import { P } from "unthrown";
133133

134134
implementation: async (context, order) => {
135135
const charged = await context.activities.chargeCard({
@@ -141,16 +141,16 @@ implementation: async (context, order) => {
141141
ok: (payment) => ({ status: "completed" as const, transactionId: payment.transactionId }),
142142
errCases: (matcher) =>
143143
matcher
144-
.with(tag("@temporal-contract/ContractError"), (error) => {
144+
.with(P.tag("@temporal-contract/ContractError"), (error) => {
145145
// error.errorName narrows; error.data is typed from the schema
146146
if (error.errorName === "CardDeclined") {
147147
return { status: "failed" as const, reason: error.data.reason };
148148
}
149149
return { status: "failed" as const, reason: error.errorName };
150150
})
151151
.with(
152-
tag("@temporal-contract/ActivityError"),
153-
tag("@temporal-contract/ActivityCancelledError"),
152+
P.tag("@temporal-contract/ActivityError"),
153+
P.tag("@temporal-contract/ActivityCancelledError"),
154154
(error) => ({ status: "failed" as const, reason: error.message }),
155155
),
156156
defect: (cause) => ({
@@ -179,7 +179,7 @@ A workflow whose declared error caused the failure surfaces it as a
179179
`WorkflowFailedError`:
180180

181181
```typescript
182-
import { tag } from "unthrown";
182+
import { P } from "unthrown";
183183

184184
const result = await client.executeWorkflow("processOrder", {
185185
workflowId: "order-1",
@@ -190,7 +190,7 @@ result.match({
190190
ok: (output) => console.log("done:", output),
191191
errCases: (matcher) =>
192192
matcher
193-
.with(tag("@temporal-contract/ContractError"), (error) => {
193+
.with(P.tag("@temporal-contract/ContractError"), (error) => {
194194
switch (error.errorName) {
195195
case "EmptyOrder":
196196
return console.error("no items on order", error.data.orderId);
@@ -199,11 +199,11 @@ result.match({
199199
}
200200
})
201201
.with(
202-
tag("@temporal-contract/WorkflowNotFoundError"),
203-
tag("@temporal-contract/WorkflowValidationError"),
204-
tag("@temporal-contract/WorkflowAlreadyStartedError"),
205-
tag("@temporal-contract/WorkflowFailedError"),
206-
tag("@temporal-contract/WorkflowExecutionNotFoundError"),
202+
P.tag("@temporal-contract/WorkflowNotFoundError"),
203+
P.tag("@temporal-contract/WorkflowValidationError"),
204+
P.tag("@temporal-contract/WorkflowAlreadyStartedError"),
205+
P.tag("@temporal-contract/WorkflowFailedError"),
206+
P.tag("@temporal-contract/WorkflowExecutionNotFoundError"),
207207
(error) => console.error("failed:", error.message),
208208
),
209209
defect: (cause) => console.error("unexpected:", cause),

docs/how-to/run-child-workflows.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ same-contract and cross-contract calls look identical.
1313

1414
```typescript
1515
import { declareWorkflow } from "@temporal-contract/worker/workflow";
16-
import { tag } from "unthrown";
16+
import { P } from "unthrown";
1717

1818
import { orderContract } from "./contract.js";
1919

@@ -31,9 +31,9 @@ export const processOrder = declareWorkflow({
3131
ok: (output) => ({ status: "completed" as const, transactionId: output.transactionId }),
3232
errCases: (matcher) =>
3333
matcher.with(
34-
tag("@temporal-contract/ChildWorkflowError"),
35-
tag("@temporal-contract/ChildWorkflowCancelledError"),
36-
tag("@temporal-contract/ChildWorkflowNotFoundError"),
34+
P.tag("@temporal-contract/ChildWorkflowError"),
35+
P.tag("@temporal-contract/ChildWorkflowCancelledError"),
36+
P.tag("@temporal-contract/ChildWorkflowNotFoundError"),
3737
(error) => ({ status: "failed" as const, reason: error.message }),
3838
),
3939
defect: (cause) => ({

docs/how-to/troubleshoot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Handle them in `defect`, `recoverDefect`, or `tapDefect`:
252252
```typescript
253253
result.match({
254254
ok: (v) => v,
255-
errCases: (m) => m.with(tag("@temporal-contract/WorkflowFailedError"), handle),
255+
errCases: (m) => m.with(P.tag("@temporal-contract/WorkflowFailedError"), handle),
256256
defect: (cause) => {
257257
if (cause instanceof RuntimeClientError) return report(cause);
258258
throw cause;

0 commit comments

Comments
 (0)