Skip to content

refactor: rename context to step in job handler API#7

Merged
coji merged 5 commits into
mainfrom
refactor/context-to-step
Dec 22, 2025
Merged

refactor: rename context to step in job handler API#7
coji merged 5 commits into
mainfrom
refactor/context-to-step

Conversation

@coji
Copy link
Copy Markdown
Owner

@coji coji commented Dec 22, 2025

Summary

  • Renamed job handler first argument from context to step (Inngest-style API)
  • JobContextStepContext
  • createJobContextcreateStepContext
  • Bumped version to 0.2.0 (breaking change)
  • Added CHANGELOG.md

Migration

- durably.defineJob({ name: 'my-job', input }, async (context, payload) => {
-   await context.run('step1', () => doSomething())
+ durably.defineJob({ name: 'my-job', input }, async (step, payload) => {
+   await step.run('step1', () => doSomething())
  })

Test plan

  • All 230 tests passing (pnpm validate)
  • Documentation updated (EN/JA)
  • Examples updated

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Breaking Changes

    • The job handler now receives a step object instead of context (handler signature updated).
    • Progress API renamed to progress(current, total, message?).
  • New Features

    • Step-level streaming with checkpoint support.
    • Subscribe to job events via a new subscribe(runId, options) capability.
  • Documentation

    • Docs, guides, and examples updated to the new step-centric API and CHANGELOG added.
  • Chore

    • Package version bumped to 0.2.0.

✏️ Tip: You can customize this high-level summary in your review settings.

coji and others added 4 commits December 22, 2025 20:22
BREAKING CHANGE: Job handler's first parameter renamed from `context` to `step`

This change aligns with Inngest's API design where `step.run()` reads more
naturally as "run a step" compared to the previous `context.run()`.

Changes:
- Rename `JobContext` type to `StepContext`
- Rename `createJobContext` to `createStepContext`
- Update all job handlers: `(context, payload)` → `(step, payload)`
- Update all step calls: `context.run()` → `step.run()`
- Update logging: `context.log` → `step.log`
- Update progress: `context.progress()` → `step.progress()`
- Rename website docs: api/context.md → api/step.md

Migration:
```ts
// Before
durably.defineJob("myJob", async (context, payload) => {
  await context.run("step1", () => fetchData())
})

// After
durably.defineJob("myJob", async (step, payload) => {
  await step.run("step1", () => fetchData())
})
```

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Breaking change: Job handler API renamed from `context` to `step`
- JobContext → StepContext
- createJobContext → createStepContext
- Handler signature: (context, payload) → (step, payload)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Dec 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
durably-demo Ready Ready Preview Dec 22, 2025 11:48am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 22, 2025

Walkthrough

A large API rename: the job handler context and related APIs were renamed from "context"/JobContext to "step"/StepContext across code, tests, docs (English & Japanese), examples, and package metadata; streaming spec additions include StepContext stream APIs and JobHandle.subscribe in docs.

Changes

Cohort / File(s) Summary
Core types & exports
packages/durably/src/job.ts, packages/durably/src/index.ts, packages/durably/src/context.ts
Renamed JobContextStepContext; updated JobFunction/handler signatures to use step: StepContext; createJobContextcreateStepContext; exports changed to include StepContext.
Runtime usage
packages/durably/src/worker.ts
Replaced createJobContext calls with createStepContext; pass step into job.fn and renamed local variables/comments accordingly.
Package metadata
packages/durably/package.json
Version bumped 0.1.1 → 0.2.0.
Specification & streaming docs
docs/spec.md, docs/spec-streaming.md, CHANGELOG.md, CLAUDE.md
Documentation/spec updated from context→step; docs/spec-streaming.md adds StepContext APIs (stream, progress rename) and JobHandle.subscribe / SubscribeOptions; CHANGELOG documents breaking change and migration example.
API docs (English)
website/api/*.md, deleted website/api/context.md, added website/api/step.md
Handler examples/signatures changed from (context, payload)(step, payload); context.run/log/progressstep.run/log/progress; context.md removed and step.md introduced; log:write event text updated.
API docs (Japanese)
website/ja/api/*.md, deleted website/ja/api/context.md, added website/ja/api/step.md
Japanese equivalents updated to Step/StepContext and step.* usages; context page removed, step page added.
Guides (English)
website/guide/*.md (getting-started, resumability, events, jobs-and-steps, react, index)
All example handlers renamed to (step, payload) and internal calls updated to step.run, step.log, step.progress.
Guides (Japanese)
website/ja/guide/*.md
Japanese guide examples updated to use step and step.* APIs throughout.
Examples
examples/browser/src/main.ts, examples/node/basic.ts, examples/react/src/App.tsx, packages/durably/README.md
Example job handlers renamed to (step, payload); calls changed from context.run(...)step.run(...).
Tests
packages/durably/tests/shared/*.ts (concurrency.shared.ts, job.shared.ts, log.shared.ts, plugin.shared.ts, recovery.shared.ts, run-api.shared.ts, step.shared.ts, worker.shared.ts)
Test handler parameters renamed from context/_context → step/_step; all context.run/log/progress/runId usages updated to step equivalents; test descriptions adjusted to step terminology.
Website nav/config
website/.vitepress/config.ts
Navigation items changed from "Context" (/api/context) → "Step" (/api/step).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

  • Breadth: widespread, ~50 files across code, tests, docs.
  • Nature: mostly consistent mechanical renames (parameter/type/export/function), low logic density.
  • Attention hotspots:
    • Ensure no remaining context.* references (run/log/progress/runId) remain in code/tests/docs.
    • Verify exported type list and names in packages/durably/src/index.ts.
    • Confirm docs/spec-streaming.md additions (stream API, subscribe) match intended public surface and examples.
    • Validate version bump and changelog accurately reflect breaking change.

Possibly related PRs

Poem

A rabbit hops from context to step with glee, 🐰
I rename each handler, one, two, three!
From context.run to step.run, neat and bright,
Docs and tests all follow my light.
Step forward now — the API takes flight. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: renaming context to step throughout the job handler API, which is the primary refactoring across all modified files.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/context-to-step

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fe7c23c and 0b9083e.

📒 Files selected for processing (1)
  • CHANGELOG.md
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7e3cefe and fe7c23c.

📒 Files selected for processing (45)
  • CHANGELOG.md
  • CLAUDE.md
  • README.md
  • docs/spec-streaming.md
  • docs/spec.md
  • examples/browser/src/main.ts
  • examples/node/basic.ts
  • examples/react/src/App.tsx
  • packages/durably/README.md
  • packages/durably/package.json
  • packages/durably/src/context.ts
  • packages/durably/src/index.ts
  • packages/durably/src/job.ts
  • packages/durably/src/worker.ts
  • packages/durably/tests/shared/concurrency.shared.ts
  • packages/durably/tests/shared/job.shared.ts
  • packages/durably/tests/shared/log.shared.ts
  • packages/durably/tests/shared/plugin.shared.ts
  • packages/durably/tests/shared/recovery.shared.ts
  • packages/durably/tests/shared/run-api.shared.ts
  • packages/durably/tests/shared/step.shared.ts
  • packages/durably/tests/shared/worker.shared.ts
  • website/.vitepress/config.ts
  • website/api/context.md
  • website/api/define-job.md
  • website/api/events.md
  • website/api/index.md
  • website/api/step.md
  • website/guide/events.md
  • website/guide/getting-started.md
  • website/guide/index.md
  • website/guide/jobs-and-steps.md
  • website/guide/react.md
  • website/guide/resumability.md
  • website/ja/api/context.md
  • website/ja/api/define-job.md
  • website/ja/api/events.md
  • website/ja/api/index.md
  • website/ja/api/step.md
  • website/ja/guide/events.md
  • website/ja/guide/getting-started.md
  • website/ja/guide/index.md
  • website/ja/guide/jobs-and-steps.md
  • website/ja/guide/react.md
  • website/ja/guide/resumability.md
💤 Files with no reviewable changes (2)
  • website/api/context.md
  • website/ja/api/context.md
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{js,ts,jsx,tsx}: Use durably.defineJob() to define jobs with a context object and payload
Create steps via context.run() where each step's success state and return value is persisted
Use the retry() API for manual retry of failed runs; do not rely on automatic retry
Use dialect injection pattern - pass Kysely dialect to createDurably() to abstract SQLite implementations
Use event system for extensibility with events: run:start, run:complete, run:fail, step:*, log:write
In browser implementations, use SQLite WASM with OPFS backend for persistence
Configure pollingInterval default to 1000ms, heartbeatInterval to 5000ms, and staleThreshold to 30000ms

Files:

  • examples/browser/src/main.ts
  • packages/durably/src/job.ts
  • packages/durably/src/worker.ts
  • examples/react/src/App.tsx
  • packages/durably/src/context.ts
  • examples/node/basic.ts
  • packages/durably/tests/shared/concurrency.shared.ts
  • packages/durably/tests/shared/worker.shared.ts
  • packages/durably/tests/shared/log.shared.ts
  • packages/durably/src/index.ts
  • packages/durably/tests/shared/job.shared.ts
  • packages/durably/tests/shared/step.shared.ts
  • packages/durably/tests/shared/run-api.shared.ts
  • packages/durably/tests/shared/plugin.shared.ts
  • packages/durably/tests/shared/recovery.shared.ts
**/*.{js,ts}

📄 CodeRabbit inference engine (CLAUDE.md)

In Node.js implementations, use better-sqlite3 or libsql for database persistence

Files:

  • examples/browser/src/main.ts
  • packages/durably/src/job.ts
  • packages/durably/src/worker.ts
  • packages/durably/src/context.ts
  • examples/node/basic.ts
  • packages/durably/tests/shared/concurrency.shared.ts
  • packages/durably/tests/shared/worker.shared.ts
  • packages/durably/tests/shared/log.shared.ts
  • packages/durably/src/index.ts
  • packages/durably/tests/shared/job.shared.ts
  • packages/durably/tests/shared/step.shared.ts
  • packages/durably/tests/shared/run-api.shared.ts
  • packages/durably/tests/shared/plugin.shared.ts
  • packages/durably/tests/shared/recovery.shared.ts
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR
Repo: coji/durably PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T13:14:30.311Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Create steps via `context.run()` where each step's success state and return value is persisted
Learnt from: CR
Repo: coji/durably PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T13:14:30.311Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Use `durably.defineJob()` to define jobs with a context object and payload
📚 Learning: 2025-12-21T13:14:30.311Z
Learnt from: CR
Repo: coji/durably PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T13:14:30.311Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Create steps via `context.run()` where each step's success state and return value is persisted

Applied to files:

  • examples/browser/src/main.ts
  • website/ja/api/define-job.md
  • packages/durably/src/job.ts
  • packages/durably/src/worker.ts
  • website/ja/guide/resumability.md
  • website/guide/events.md
  • website/api/step.md
  • examples/react/src/App.tsx
  • packages/durably/src/context.ts
  • website/ja/api/step.md
  • examples/node/basic.ts
  • website/api/define-job.md
  • packages/durably/tests/shared/concurrency.shared.ts
  • CHANGELOG.md
  • packages/durably/tests/shared/worker.shared.ts
  • website/guide/resumability.md
  • website/ja/guide/getting-started.md
  • README.md
  • packages/durably/tests/shared/log.shared.ts
  • website/guide/getting-started.md
  • website/guide/jobs-and-steps.md
  • packages/durably/src/index.ts
  • website/ja/guide/jobs-and-steps.md
  • packages/durably/tests/shared/job.shared.ts
  • website/ja/api/index.md
  • packages/durably/tests/shared/step.shared.ts
  • website/api/index.md
  • packages/durably/README.md
  • website/ja/guide/events.md
  • CLAUDE.md
  • website/guide/index.md
  • website/ja/guide/index.md
  • packages/durably/tests/shared/run-api.shared.ts
  • packages/durably/tests/shared/plugin.shared.ts
  • website/guide/react.md
  • packages/durably/tests/shared/recovery.shared.ts
  • docs/spec.md
  • docs/spec-streaming.md
  • website/ja/guide/react.md
📚 Learning: 2025-12-21T13:14:30.311Z
Learnt from: CR
Repo: coji/durably PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T13:14:30.311Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Use `durably.defineJob()` to define jobs with a context object and payload

Applied to files:

  • website/ja/api/define-job.md
  • packages/durably/src/job.ts
  • packages/durably/src/worker.ts
  • website/guide/events.md
  • website/api/step.md
  • examples/react/src/App.tsx
  • packages/durably/src/context.ts
  • website/ja/api/step.md
  • examples/node/basic.ts
  • website/api/define-job.md
  • packages/durably/tests/shared/concurrency.shared.ts
  • CHANGELOG.md
  • packages/durably/tests/shared/worker.shared.ts
  • website/ja/guide/getting-started.md
  • packages/durably/tests/shared/log.shared.ts
  • website/guide/jobs-and-steps.md
  • packages/durably/src/index.ts
  • website/ja/guide/jobs-and-steps.md
  • packages/durably/tests/shared/job.shared.ts
  • website/ja/api/index.md
  • packages/durably/tests/shared/step.shared.ts
  • website/api/index.md
  • packages/durably/README.md
  • website/ja/guide/events.md
  • CLAUDE.md
  • website/guide/index.md
  • website/ja/guide/index.md
  • packages/durably/tests/shared/run-api.shared.ts
  • packages/durably/tests/shared/plugin.shared.ts
  • website/guide/react.md
  • docs/spec.md
  • docs/spec-streaming.md
  • website/ja/guide/react.md
📚 Learning: 2025-12-21T13:14:30.311Z
Learnt from: CR
Repo: coji/durably PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T13:14:30.311Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Use event system for extensibility with events: `run:start`, `run:complete`, `run:fail`, `step:*`, `log:write`

Applied to files:

  • website/api/events.md
  • website/ja/api/events.md
  • website/guide/events.md
  • packages/durably/tests/shared/log.shared.ts
  • website/guide/jobs-and-steps.md
  • packages/durably/src/index.ts
  • packages/durably/tests/shared/step.shared.ts
  • website/ja/guide/events.md
  • packages/durably/tests/shared/plugin.shared.ts
  • docs/spec.md
  • docs/spec-streaming.md
  • website/ja/guide/react.md
📚 Learning: 2025-12-21T13:14:30.311Z
Learnt from: CR
Repo: coji/durably PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T13:14:30.311Z
Learning: Ensure the same job definition code runs in both Node.js and browser environments

Applied to files:

  • examples/node/basic.ts
📚 Learning: 2025-12-21T13:14:30.311Z
Learnt from: CR
Repo: coji/durably PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T13:14:30.311Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Use the `retry()` API for manual retry of failed runs; do not rely on automatic retry

Applied to files:

  • website/guide/resumability.md
  • website/guide/jobs-and-steps.md
  • website/ja/guide/jobs-and-steps.md
  • packages/durably/tests/shared/recovery.shared.ts
📚 Learning: 2025-12-21T13:14:30.311Z
Learnt from: CR
Repo: coji/durably PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T13:14:30.311Z
Learning: Applies to **/*.{js,ts,jsx,tsx} : Use dialect injection pattern - pass Kysely dialect to `createDurably()` to abstract SQLite implementations

Applied to files:

  • packages/durably/tests/shared/log.shared.ts
  • packages/durably/tests/shared/step.shared.ts
📚 Learning: 2025-12-21T13:14:30.311Z
Learnt from: CR
Repo: coji/durably PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-21T13:14:30.311Z
Learning: In browser implementations, assume single tab usage (OPFS exclusivity) and handle background tab interruptions via heartbeat recovery

Applied to files:

  • docs/spec-streaming.md
🧬 Code graph analysis (3)
packages/durably/src/worker.ts (1)
packages/durably/src/context.ts (2)
  • createStepContext (9-156)
  • run (23-112)
packages/durably/src/context.ts (3)
packages/durably/src/index.ts (2)
  • Run (40-40)
  • StepContext (28-28)
packages/durably/src/storage.ts (2)
  • Run (18-32)
  • Storage (113-131)
packages/durably/src/job.ts (1)
  • StepContext (8-32)
packages/durably/tests/shared/recovery.shared.ts (1)
packages/durably/src/context.ts (1)
  • run (23-112)
🔇 Additional comments (62)
CHANGELOG.md (1)

1-26: LGTM! Clear documentation of the breaking change.

The CHANGELOG properly documents the API surface migration from context to step with a helpful migration example. The version bump to 0.2.0 is appropriate for this breaking change.

packages/durably/src/worker.ts (2)

1-1: LGTM! Import updated correctly.

The import change from createJobContext to createStepContext aligns with the broader API refactoring.


192-194: LGTM! Step context creation and usage updated correctly.

The refactoring consistently updates the variable name and method call from context to step, maintaining the same functionality while aligning with the new Inngest-style API.

packages/durably/package.json (1)

3-3: LGTM! Appropriate version bump for breaking change.

The version bump from 0.1.1 to 0.2.0 correctly reflects the breaking API changes per semantic versioning.

website/.vitepress/config.ts (1)

58-58: LGTM! Navigation updated consistently across languages.

The navigation links have been updated from Context to Step in both English and Japanese versions, aligning with the API documentation refactoring.

Also applies to: 115-115

website/ja/guide/resumability.md (2)

9-47: LGTM! Documentation examples updated consistently.

All code examples have been correctly updated to use step.run() instead of context.run(), maintaining consistency with the new API while preserving the educational content about resumability and checkpointing.


82-133: LGTM! Idempotency and batch processing examples updated correctly.

The examples demonstrating idempotent operations, non-idempotent operations with idempotency keys, and batch processing have all been correctly updated to use step.run().

examples/browser/src/main.ts (1)

31-52: LGTM! Browser example updated to use step-based API.

The job handler has been correctly updated to use the step parameter and all internal calls have been changed from context.run() to step.run(), maintaining the same image processing workflow while aligning with the new API.

packages/durably/tests/shared/job.shared.ts (1)

26-28: LGTM! Test handlers updated consistently.

The test job handlers have been correctly updated to use the _step parameter (unused, hence the underscore prefix) instead of _context, maintaining test coverage while aligning with the new API surface.

Also applies to: 108-114, 131-133

website/ja/api/events.md (1)

131-131: LGTM! Event documentation updated to reference step.log.

The documentation correctly updates the reference from context.log to step.log to align with the refactored API, while maintaining accurate Japanese translation.

website/api/events.md (1)

131-131: LGTM - Documentation correctly updated.

The log:write event description now accurately reflects that logs are fired when step.log methods are called, consistent with the API rename.

packages/durably/tests/shared/worker.shared.ts (2)

54-59: LGTM - Test correctly updated to step-based API.

The job handler now uses the step parameter and step.run() method, consistent with the API refactor.


150-152: LGTM - Unused parameters correctly prefixed.

Good use of _step and _payload prefixes for unused parameters in test callbacks.

Also applies to: 197-200

packages/durably/tests/shared/step.shared.ts (2)

7-7: LGTM - Test suite title updated.

The describe block now correctly references step.run() instead of context.run().


30-33: LGTM - All test handlers correctly updated.

All job handler callbacks now use the step parameter and step.run() method calls, maintaining test coverage while adopting the new API surface.

Also applies to: 55-58, 85-89, 120-133, 178-195, 243-245, 268-274, 296-301

website/guide/jobs-and-steps.md (1)

14-18: LGTM - User guide correctly updated.

The documentation now consistently shows the new API surface with step parameter and step.run() method throughout all examples.

Also applies to: 31-38, 52-58, 108-113

packages/durably/tests/shared/concurrency.shared.ts (1)

31-37: LGTM - Concurrency tests correctly updated.

All job handlers now use the step parameter and step.run() method. Test logic and concurrency behavior verification remain intact.

Also applies to: 67-72, 103-108, 139-146

website/ja/api/define-job.md (1)

10-10: LGTM - Japanese documentation correctly updated.

The Japanese API documentation now properly reflects the new StepContext type and step.run() usage throughout all examples and signatures.

Also applies to: 34-35, 83-103, 127-130

packages/durably/tests/shared/plugin.shared.ts (1)

40-42: LGTM - Plugin tests correctly updated.

All job handlers now use the step parameter with step.run() and step.log methods. Plugin event assertions remain properly covered.

Also applies to: 78-80, 103-106, 131-134

CLAUDE.md (2)

16-17: LGTM - Core concepts documentation updated.

The framework overview now correctly describes the step-based API with step.run() for step creation.


1-53: Note: System learnings and coding guidelines are now outdated.

The retrieved learnings and coding guidelines in this review still reference the old context.run() API. While the code changes in this PR are correct, the system's knowledge base will need updating to reflect the new step.run() API surface.

This is informational only - not a code issue.

website/ja/guide/react.md (1)

269-283: LGTM! API rename applied correctly.

The job handler parameter and all internal calls have been consistently updated from context to step, maintaining the same functionality while aligning with the new Step-centric API.

website/ja/guide/getting-started.md (2)

69-87: LGTM! Getting started examples updated correctly.

The Node.js example correctly demonstrates the new step parameter and step.run() usage pattern.


121-130: LGTM! Browser example updated consistently.

The browser example follows the same pattern with the renamed API surface.

README.md (1)

49-60: LGTM! Primary README example updated correctly.

The main usage example in the README now correctly demonstrates the new Step-centric API with step parameter and step.run() calls.

examples/react/src/App.tsx (1)

33-54: LGTM! React example updated correctly.

The job handler demonstrates proper usage of the new step parameter with all three step executions (download, resize, upload) updated to use step.run().

website/guide/index.md (2)

27-40: LGTM! Guide documentation updated correctly.

The introductory example correctly demonstrates the new API with step parameter and step.run() calls for all three steps.


45-45: Good catch updating the feature description.

The documentation text correctly references step.run() in the feature list, maintaining consistency between code examples and prose.

packages/durably/tests/shared/log.shared.ts (3)

7-7: LGTM! Test suite description updated.

The test suite description correctly reflects the new step.log API.


23-46: LGTM! Logging tests updated correctly.

All test cases correctly use the new step parameter with step.log.info() and step.run() calls. Test assertions remain valid.


146-176: LGTM! Step scoping test updated correctly.

The test correctly validates that logs inside step.run() include the step name, while logs outside have null stepName. The test expectations remain accurate with the renamed API.

website/api/step.md (1)

1-173: Excellent comprehensive Step API documentation.

This new documentation thoroughly covers the Step object API with:

  • Clear method signatures for run(), log, and progress()
  • Property documentation for runId and stepIndex
  • Practical examples demonstrating usage
  • Best practices section covering naming conventions and common pitfalls

The documentation accurately reflects the new Step-centric API and provides valuable guidance for users migrating from the context-based API.

website/guide/resumability.md (2)

9-47: LGTM! Resumability examples updated correctly.

The core resumability examples correctly demonstrate step.run() behavior for both initial execution and resume scenarios. The documentation accurately explains how step persistence works with the new API.


78-133: LGTM! Idempotency and batching examples updated correctly.

All examples demonstrating idempotent operations and batch processing patterns have been consistently updated to use step.run(). The best practices guidance remains accurate and valuable.

packages/durably/src/index.ts (1)

28-28: LGTM! Clean public API update.

The export change from JobContext to StepContext is consistent with the broader API refactor and aligns well with the step-centric terminology introduced throughout the codebase.

packages/durably/src/job.ts (2)

6-32: LGTM! Interface rename is consistent and clear.

The rename from JobContext to StepContext better reflects the interface's purpose as the step execution context. The interface members and documentation remain intact.


37-40: LGTM! Function signature update aligns with the step-centric API.

The parameter rename from context to step makes the API more intuitive and consistent with the step.run() pattern used throughout the codebase.

website/api/define-job.md (1)

10-10: LGTM! Documentation is thorough and consistent.

All references to the handler signature, parameter names, and method calls have been updated correctly to reflect the step-centric API. The cross-reference to /api/step (line 34) is appropriate.

Also applies to: 34-34, 83-104, 127-129

website/guide/react.md (1)

269-283: LGTM! React example updated correctly.

The job definition example properly demonstrates the new step-centric API with step.run() and step.progress() calls. The code is clear and consistent with the broader API changes.

website/api/index.md (1)

11-11: LGTM! API reference index is comprehensive and accurate.

All references have been updated consistently:

  • Navigation table points to the Step documentation
  • Code examples use the step parameter and step.* methods
  • Type exports list includes StepContext

Also applies to: 54-66, 76-76

website/ja/guide/index.md (1)

27-40: LGTM! Japanese documentation updated consistently.

The Japanese guide reflects the step-centric API changes with proper usage of step parameter and step.run() calls. The documentation text (line 45) correctly describes step-level persistence.

Also applies to: 45-45

website/ja/guide/events.md (1)

72-86: LGTM! Events documentation updated correctly.

The logging examples properly demonstrate the new step.log.* API for emitting log events. All parameter names and method calls are consistent with the step-centric refactor.

examples/node/basic.ts (1)

33-54: LGTM! Node.js example demonstrates the new API clearly.

The image processing job correctly uses the step parameter and step.run() calls for all three steps (download, resize, upload). The example serves as a good reference for users migrating to the new API.

packages/durably/README.md (1)

49-60: LGTM! Clean API surface update.

The example correctly demonstrates the new step-based API with the handler signature updated to (step, payload) and all step operations using step.run(). The underlying job logic remains unchanged.

website/guide/events.md (1)

72-93: LGTM! Event documentation accurately reflects the step-based API.

The logging examples correctly show step.log.info() usage and align with the updated event system where log:write fires when step.log methods are invoked.

website/ja/api/step.md (1)

1-173: LGTM! Comprehensive Japanese API documentation for Step.

This new documentation file provides thorough coverage of the Step API including methods (run(), log, progress()), properties (runId, stepIndex), usage examples, and best practices. The content aligns well with the step-centric API design.

packages/durably/src/context.ts (1)

3-14: LGTM! Type and export names correctly updated.

The function has been properly renamed from createJobContext to createStepContext, with matching updates to the import (StepContext from ./job) and return type. The JSDoc comment accurately reflects the rename. The implementation remains unchanged, ensuring no behavior modification.

website/guide/getting-started.md (2)

69-87: LGTM! Node.js quick start example correctly updated.

The handler signature and all step operations properly use the step-based API. The example clearly demonstrates the resumable step pattern with step.run().


121-130: LGTM! Browser quick start example correctly updated.

The browser example consistently uses the step parameter and step.run() for both fetch and save operations, maintaining alignment with the Node.js examples.

packages/durably/tests/shared/run-api.shared.ts (4)

304-310: LGTM! Test correctly updated to step-based API.

The triggerAndWait success test properly uses the step parameter and step.run() method, maintaining test coverage while aligning with the new API surface.


331-344: LGTM! Failure test case correctly updated.

The test demonstrates proper error handling with the step-based API, using step.run('fail-step', ...) to verify job failure behavior.


378-393: LGTM! Timeout test correctly updated.

The slow-step test case properly uses step.run() to verify timeout behavior with the updated API.


396-484: LGTM! Progress tracking tests comprehensively updated.

All progress-related tests correctly use step.progress() with various parameter combinations. The test suite description on line 396 is properly updated to step.progress(), and all test implementations consistently use the step parameter.

website/ja/guide/jobs-and-steps.md (3)

14-17: LGTM! Job definition example correctly updated.

The Japanese documentation properly shows the updated handler signature with the step parameter.


31-58: LGTM! Step creation examples consistently updated.

All code examples correctly demonstrate step.run() usage with proper Japanese explanations. The good/bad examples for step naming are clear and instructive.


108-114: LGTM! Error handling example correctly updated.

The error handling section properly demonstrates error throwing within step.run() using the updated API.

website/ja/api/index.md (3)

11-11: LGTM! API reference table correctly updated.

The core API table now properly references Step and links to the new /ja/api/step documentation page.


57-66: LGTM! Quick reference examples correctly updated.

The code snippets properly demonstrate the step-based API with async (step, payload) signature and step.run() / step.log.info() usage.


76-76: LGTM! Type exports correctly updated.

The type exports section now properly lists StepContext instead of the old JobContext type, maintaining consistency with the renamed API surface.

docs/spec.md (1)

50-50: LGTM! Documentation correctly updated to reflect step-centric API.

The specification document has been systematically updated to use the new step parameter and method names (step.run(), step.log(), step.progress()) throughout all code examples, API descriptions, and narrative sections. The changes are consistent and accurately reflect the breaking API change introduced in v0.2.0.

Also applies to: 72-79, 118-132, 333-336, 509-526, 549-564, 728-728, 748-748, 817-832

docs/spec-streaming.md (1)

36-53: LGTM! Future specification updated for consistency with current API.

The streaming specification document (planned for v0.2+) has been updated to align with the step-centric API, including:

  • Handler signatures using (step, payload) pattern
  • Method calls using step.run(), step.stream(), step.log()
  • Interface rename from JobContext to StepContext
  • Method signature progress(current, total, message?) updated

This ensures the future streaming features will be consistent with the current v0.2.0 API surface.

Also applies to: 209-224, 307-325, 333-486

packages/durably/tests/shared/recovery.shared.ts (1)

32-33: LGTM! Test code correctly updated to use step-centric API.

All test cases have been systematically updated to use the new API:

  • Handler parameter renamed: contextstep (or _step when unused)
  • Method calls updated: context.run()step.run(), context.logstep.log(), context.runIdstep.runId
  • Test assertions remain unchanged, confirming this is purely an API surface rename with no behavioral changes

Good practice observed on Line 207 using _step prefix for the unused parameter.

Also applies to: 81-89, 153-161, 207-211, 281-285, 331-336, 443-458, 496-501, 535-538, 637-641

Comment thread CHANGELOG.md Outdated
@coji coji merged commit beeb34f into main Dec 22, 2025
7 checks passed
@coji coji deleted the refactor/context-to-step branch March 5, 2026 12:14
@coderabbitai coderabbitai Bot mentioned this pull request Mar 8, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant