Skip to content

Commit 647eaab

Browse files
Benoit Traversclaude
authored andcommitted
docs: show where P comes from in P.tag snippets
Review feedback: several snippets call P.tag(...) without establishing that P is unthrown's pattern namespace. Standalone and random-access contexts now import it explicitly — the eight TSDoc @example blocks (each renders as an isolated card in the API docs), the root README client example, and the troubleshoot.md entry readers reach by symptom rather than by reading top to bottom. The linear how-to guides already import P at their first use, so their later blocks are left alone. reference/errors.md keeps its one-line shape fragments free of imports — no snippet on that page has ever carried one — and states P's origin in prose instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent fe7bda3 commit 647eaab

7 files changed

Lines changed: 26 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ export const activities = declareActivitiesHandler({
8484
Call it — names, arguments, and results all typed, and validated at runtime:
8585

8686
```typescript
87+
import { P } from "unthrown";
88+
8789
const result = await client.executeWorkflow("processOrder", {
8890
workflowId: "order-123",
8991
args: { orderId: "ORD-1", customerId: "CUST-1", amount: 99.99 },

docs/how-to/troubleshoot.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ Since 8.0, `TechnicalError` and `RuntimeClientError` ride the defect channel.
250250
Handle them in `defect`, `recoverDefect`, or `tapDefect`:
251251

252252
```typescript
253+
import { P } from "unthrown";
254+
253255
result.match({
254256
ok: (v) => v,
255257
errCases: (m) => m.with(P.tag("@temporal-contract/WorkflowFailedError"), handle),

docs/reference/errors.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ exhaustive matcher. Tags are namespaced with the package scope
1111
(`"@temporal-contract/…"`) so they never collide with your own or another
1212
library's. `.name` stays the bare class name for readable logs.
1313

14+
The snippets on this page are shape fragments, not runnable programs. `P` is
15+
unthrown's pattern namespace throughout — `import { P } from "unthrown"`.
16+
1417
```typescript
1518
matcher.with(P.tag("@temporal-contract/WorkflowFailedError"), (error) => ...);
1619
```

packages/client/src/client.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ export class TypedClient<TContract extends ContractDefinition> {
383383
*
384384
* @example
385385
* ```ts
386+
* import { P } from "unthrown";
387+
*
386388
* const result = await client.schedule.create("processOrder", {
387389
* scheduleId: "daily-sweep",
388390
* spec: { cronExpressions: ["0 2 * * *"] },
@@ -516,6 +518,8 @@ export class TypedClient<TContract extends ContractDefinition> {
516518
*
517519
* @example
518520
* ```ts
521+
* import { P } from "unthrown";
522+
*
519523
* const handleResult = await client.startWorkflow('processOrder', {
520524
* workflowId: 'order-123',
521525
* args: { orderId: 'ORD-123' },
@@ -612,6 +616,8 @@ export class TypedClient<TContract extends ContractDefinition> {
612616
*
613617
* @example
614618
* ```ts
619+
* import { P } from "unthrown";
620+
*
615621
* const result = await client.signalWithStart('processOrder', {
616622
* workflowId: 'order-123',
617623
* args: { orderId: 'ORD-123', customerId: 'CUST-1' },
@@ -744,6 +750,8 @@ export class TypedClient<TContract extends ContractDefinition> {
744750
*
745751
* @example
746752
* ```ts
753+
* import { P } from "unthrown";
754+
*
747755
* const result = await client.executeWorkflow('processOrder', {
748756
* workflowId: 'order-123',
749757
* args: { orderId: 'ORD-123' },
@@ -888,6 +896,8 @@ export class TypedClient<TContract extends ContractDefinition> {
888896
*
889897
* @example
890898
* ```ts
899+
* import { P } from "unthrown";
900+
*
891901
* const handleResult = await client.getHandle('processOrder', 'order-123');
892902
* await handleResult.match({
893903
* ok: async (handle) => {

packages/worker/src/activity.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ export type ActivityMiddlewareNext<
293293
*
294294
* @example Log every activity invocation and its outcome (read-only)
295295
* ```ts
296+
* import { ApplicationFailure } from '@temporal-contract/worker/activity';
297+
* import { P } from "unthrown";
298+
*
296299
* const logging: ActivityMiddleware = ({ activityName, workflowName }, next) =>
297300
* next().tapErrCases((matcher) =>
298301
* matcher.with(

packages/worker/src/cancellation.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import { makeAsyncResult } from "./internal.js";
3131
*
3232
* @example
3333
* ```ts
34+
* import { P } from "unthrown";
35+
*
3436
* const result = await context.cancellableScope(async () => {
3537
* return await context.activities.processStep(...);
3638
* });

packages/worker/src/workflow.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,8 @@ type WorkflowContext<
610610
*
611611
* @example
612612
* ```ts
613+
* import { P } from "unthrown";
614+
*
613615
* // Same contract child workflow
614616
* const childResult = await context.startChildWorkflow(myContract, 'processPayment', {
615617
* workflowId: 'payment-123',
@@ -659,6 +661,8 @@ type WorkflowContext<
659661
*
660662
* @example
661663
* ```ts
664+
* import { P } from "unthrown";
665+
*
662666
* // Same contract child workflow
663667
* const result = await context.executeChildWorkflow(myContract, 'processPayment', {
664668
* workflowId: 'payment-123',

0 commit comments

Comments
 (0)