Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/bump-unthrown-beta-5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@temporal-contract/contract": patch
"@temporal-contract/client": patch
"@temporal-contract/worker": patch
---

Bump `unthrown` to `5.0.0-beta.5`. This tracks two beta breaking changes:
`match`'s error handler key is renamed `err` → `errCases`, and the bare error
combinators gained the `*Cases` suffix (`flatMapErr` → `flatMapErrCases`,
`tapErr` → `tapErrCases`). `unthrown` also now declares `ts-pattern` as a peer
dependency, so `ts-pattern` (`^5`) is added alongside it. The peer range is
raised to `^5.0.0-beta.5`.
1 change: 1 addition & 0 deletions examples/order-processing-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@temporalio/client": "catalog:",
"pino": "catalog:",
"pino-pretty": "catalog:",
"ts-pattern": "catalog:",
"unthrown": "catalog:",
"zod": "catalog:"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/order-processing-client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async function run() {
);
}
},
err: (matcher) =>
errCases: (matcher) =>
matcher
.with(tag("@temporal-contract/WorkflowNotFoundError"), (err) =>
logger.error({ error: err, orderId: order.orderId }, "❌ Workflow not found"),
Expand Down Expand Up @@ -198,7 +198,7 @@ async function run() {
};
logger.info({ data: summary }, `📊 Order summary: ${summary.message}`);
},
err: (matcher) =>
errCases: (matcher) =>
matcher
.with(tag("@temporal-contract/WorkflowNotFoundError"), (err) =>
logger.error({ error: err }, "❌ Workflow not found"),
Expand Down
1 change: 1 addition & 0 deletions examples/order-processing-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@temporalio/workflow": "catalog:",
"pino": "catalog:",
"pino-pretty": "catalog:",
"ts-pattern": "catalog:",
"unthrown": "catalog:",
"zod": "catalog:"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"@types/node": "catalog:",
"@unthrown/vitest": "catalog:",
"@vitest/coverage-v8": "catalog:",
"ts-pattern": "catalog:",
"tsdown": "catalog:",
"typedoc": "catalog:",
"typedoc-plugin-markdown": "catalog:",
Expand All @@ -77,7 +78,7 @@
"peerDependencies": {
"@temporalio/client": "^1",
"@temporalio/common": "^1",
"unthrown": "^5.0.0-beta.3"
"unthrown": "^5.0.0-beta.5"
},
Comment thread
btravers marked this conversation as resolved.
"engines": {
"node": ">=22.19.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/__tests__/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ describe("Client Package - Integration Tests", () => {
matched = true;
expect(value).toEqual({ result: "Processed: test" });
},
err: (matcher) =>
errCases: (matcher) =>
matcher.with(P._, () => {
Comment thread
btravers marked this conversation as resolved.
Outdated
throw new Error("Should not be called");
}),
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ describe("TypedClient", () => {
matched = true;
expect(value).toEqual({ result: "success" });
},
err: (matcher) =>
errCases: (matcher) =>
matcher.with(P._, () => {
throw new Error("Should not be called");
}),
Expand Down Expand Up @@ -1513,7 +1513,7 @@ describe("TypedClient — interceptors", () => {
.mockRejectedValueOnce(new Error("transient"))
.mockResolvedValueOnce({ result: "ok" });
const retryOnce: ClientInterceptor = (_args, next) =>
next().flatMapErr((matcher) =>
next().flatMapErrCases((matcher) =>
matcher.with(
P._,
(error): ReturnType<typeof next> =>
Expand Down
10 changes: 5 additions & 5 deletions packages/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export class TypedClient<TContract extends ContractDefinition> {
*
* await result.match({
* ok: async (handle) => { await handle.pause("maintenance"); },
* err: (matcher) => matcher.with(P._, (error) => console.error("schedule create failed", error)),
* errCases: (matcher) => matcher.with(P._, (error) => console.error("schedule create failed", error)),
* defect: (cause) => console.error("unexpected failure", cause),
* });
* ```
Expand Down Expand Up @@ -546,7 +546,7 @@ export class TypedClient<TContract extends ContractDefinition> {
* const result = await handle.result();
* // ... handle result
* },
* err: (matcher) => matcher.with(P._, (error) => console.error('Failed to start:', error)),
* errCases: (matcher) => matcher.with(P._, (error) => console.error('Failed to start:', error)),
* defect: (cause) => console.error('Unexpected failure:', cause),
* });
* ```
Expand Down Expand Up @@ -637,7 +637,7 @@ export class TypedClient<TContract extends ContractDefinition> {
*
* await result.match({
* ok: (handle) => console.log('signaled run', handle.signaledRunId),
* err: (matcher) => matcher.with(P._, (error) => console.error('signalWithStart failed', error)),
* errCases: (matcher) => matcher.with(P._, (error) => console.error('signalWithStart failed', error)),
* defect: (cause) => console.error('unexpected failure', cause),
* });
* ```
Expand Down Expand Up @@ -761,7 +761,7 @@ export class TypedClient<TContract extends ContractDefinition> {
*
* await result.match({
* ok: (output) => console.log('Order processed:', output.status),
* err: (matcher) => matcher.with(P._, (error) => console.error('Processing failed:', error)),
* errCases: (matcher) => matcher.with(P._, (error) => console.error('Processing failed:', error)),
* defect: (cause) => console.error('Unexpected failure:', cause),
* });
* ```
Expand Down Expand Up @@ -894,7 +894,7 @@ export class TypedClient<TContract extends ContractDefinition> {
* const result = await handle.result();
* // ... handle result
* },
* err: (matcher) => matcher.with(P._, (error) => console.error('Failed to get handle:', error)),
* errCases: (matcher) => matcher.with(P._, (error) => console.error('Failed to get handle:', error)),
* defect: (cause) => console.error('Unexpected failure:', cause),
* });
* ```
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/interceptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export type ClientInterceptorNext = (patch?: {
* @example Retry a transient failure once
Comment thread
btravers marked this conversation as resolved.
Outdated
* ```ts
* const retryOnce: ClientInterceptor = (args, next) =>
* next().flatMapErr((matcher) =>
* next().flatMapErrCases((matcher) =>
* matcher.with(P._, (error) =>
* error instanceof RuntimeClientError ? next() : Err(error).toAsync(),
* ),
Expand Down
3 changes: 2 additions & 1 deletion packages/contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"@unthrown/vitest": "catalog:",
"@vitest/coverage-v8": "catalog:",
"arktype": "catalog:",
"ts-pattern": "catalog:",
"tsdown": "catalog:",
"typedoc": "catalog:",
"typedoc-plugin-markdown": "catalog:",
Expand All @@ -87,7 +88,7 @@
"vitest": "catalog:"
},
"peerDependencies": {
"unthrown": "^5.0.0-beta.3"
"unthrown": "^5.0.0-beta.5"
},
"peerDependenciesMeta": {
"unthrown": {
Expand Down
3 changes: 2 additions & 1 deletion packages/worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"@types/node": "catalog:",
"@unthrown/vitest": "catalog:",
"@vitest/coverage-v8": "catalog:",
"ts-pattern": "catalog:",
"tsdown": "catalog:",
"typedoc": "catalog:",
"typedoc-plugin-markdown": "catalog:",
Expand All @@ -96,7 +97,7 @@
"@temporalio/common": "^1",
"@temporalio/worker": "^1",
"@temporalio/workflow": "^1",
"unthrown": "^5.0.0-beta.3"
"unthrown": "^5.0.0-beta.5"
},
Comment thread
btravers marked this conversation as resolved.
"engines": {
"node": ">=22.19.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/worker/src/activity-contract-errors.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ describe("declareActivitiesHandler — middleware", () => {
it("observes typed errors on the err channel", async () => {
const observed: unknown[] = [];
const observing: ActivityMiddleware = (_invocation, next) =>
next().tapErr((matcher) =>
next().tapErrCases((matcher) =>
matcher.with(P._, (error) => {
observed.push(error);
}),
Expand Down
4 changes: 2 additions & 2 deletions packages/worker/src/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export type ActivityMiddlewareNext<
* @example Log every activity invocation and its outcome (read-only)
* ```ts
* const logging: ActivityMiddleware = ({ activityName, workflowName }, next) =>
* next().tapErr((matcher) =>
* next().tapErrCases((matcher) =>
* matcher.with(P._, (error) => {
* logger.warn({ activityName, workflowName, error }, "activity failed");
* }),
Expand Down Expand Up @@ -741,7 +741,7 @@ export function declareActivitiesHandler<
// retry policy (honoring `nonRetryable: true`). Contract errors are
// validated against their declared data schema and serialized as
// ApplicationFailure(type = error name, details = [data]).
err: (matcher) =>
errCases: (matcher) =>
matcher.with(P._, async (error) => {
if (error instanceof ContractError) {
throw await contractErrorToApplicationFailure(
Expand Down
2 changes: 1 addition & 1 deletion packages/worker/src/cancellation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { makeAsyncResult } from "./internal.js";
*
* result.match({
* ok: (output) => { ... },
* err: (matcher) =>
* errCases: (matcher) =>
* matcher.with(P._, (error) => {
* // error instanceof WorkflowCancelledError — graceful exit
* }),
Expand Down
2 changes: 1 addition & 1 deletion packages/worker/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export async function createWorkerOrThrow<TContract extends ContractDefinition>(
const result = await createWorker(options);
return result.match({
ok: (worker) => worker,
err: (matcher) =>
errCases: (matcher) =>
matcher.with(P._, (error) => {
throw error.cause ?? error;
}),
Expand Down
4 changes: 2 additions & 2 deletions packages/worker/src/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ type WorkflowContext<
* const result = await handle.result();
* // ... handle result
* },
* err: (matcher) => matcher.with(P._, (error) => console.error('Failed to start:', error)),
* errCases: (matcher) => matcher.with(P._, (error) => console.error('Failed to start:', error)),
* defect: (cause) => console.error('Unexpected failure:', cause),
* });
* ```
Expand Down Expand Up @@ -667,7 +667,7 @@ type WorkflowContext<
*
* await result.match({
* ok: (output) => console.log('Payment processed:', output),
* err: (matcher) => matcher.with(P._, (error) => console.error('Processing failed:', error)),
* errCases: (matcher) => matcher.with(P._, (error) => console.error('Processing failed:', error)),
* defect: (cause) => console.error('Unexpected failure:', cause),
* });
* ```
Expand Down
Loading
Loading