dapr / dapr/js-sdk

docs(jsdoc): Phase 5 — Annotate Workflow client and runtime classes

Open
#796 1 comment 0 reactions 1 assignee Claimed by @Jeevansm25 View on GitHub
area/client documentation sdk-parity
Dominant language
JavaScript
Stars
217
Forks
104
PR merge metrics
No merged PRs in 30d

Description

## Summary

Add comprehensive JSDoc annotations to the Workflow subsystem — both the client (for managing workflow instances) and the runtime (for defining workflows and activities).

## Scope

### Workflow Client (`src/workflow/client/`)

| File | Purpose |
|------|---------|
| `DaprWorkflowClient.ts` | Start, query, pause, resume, terminate, purge workflows |
| `WorkflowState.ts` | Represents the current state of a workflow instance |
| `WorkflowFailureDetails.ts` | Error details when a workflow fails |

### Workflow Runtime (`src/workflow/runtime/`)

| File | Purpose |
|------|---------|
| `WorkflowRuntime.ts` | Registers workflows and activities, starts the task worker |
| `WorkflowContext.ts` | Context available inside workflow orchestrator functions |
| `WorkflowActivityContext.ts` | Context available inside activity functions |
| `WorkflowRuntimeStatus.ts` | Enum of workflow lifecycle states |

### Workflow Types (`src/types/workflow/`)

- `Activity.type.ts` — Activity function signature
- `Workflow.type.ts` — Workflow orchestrator function signature
- `WorkflowClientOption.ts` — Client constructor options
- `WorkflowGetResponse.type.ts` — Response from get operations
- `WorkflowRaiseOptions.type.ts` — Options for raising events
- `WorkflowRuntimeStatus.type.ts` — Status enum type
- `WorkflowStartOptions.type.ts` — Options for starting workflows
- `InputOutput.type.ts` — Generic I/O type helpers

## Requirements

- [ ] `DaprWorkflowClient`: Document every method (`start`, `get`, `pause`, `resume`, `terminate`, `purge`, `raise`, `wait`)
- [ ] `WorkflowRuntime`: Document `registerWorkflow`, `registerActivity`, `start`, `shutdown`
- [ ] `WorkflowContext`: Document all orchestration primitives:
- `callActivity` — scheduling activities
- `callChildWorkflow` — sub-orchestrations
- `createTimer` — durable timers
- `waitForExternalEvent` — external event correlation
- `continueAsNew` — eternal workflows
- `whenAll` / `whenAny` — fan-out/fan-in patterns
- [ ] `WorkflowActivityContext`: Document what's available inside activities
- [ ] `WorkflowState`: Document all properties (`instanceId`, `name`, `runtimeStatus`, `input`, `output`, `createdAt`, `lastUpdatedAt`)
- [ ] All option types: Document every property with defaults and constraints
- [ ] Add `@example` blocks showing common patterns (start → wait → get result)

## Example

```ts
/**
* Schedules an activity for execution and returns a task representing
* the pending result.
*
* Activities are the basic unit of work in a workflow — they execute
* exactly once (with at-least-once delivery) and can perform I/O,
* call external services, and interact with Dapr building blocks.
*
* @param activity - The activity function or its registered name
* @param input - Input data passed to the activity; must be JSON-serializable
* @returns A task that resolves with the activity's return value
*
* @example
* ```ts
* function* myWorkflow(ctx: WorkflowContext) {
* const result = yield ctx.callActivity(processPayment, { orderId: "123", amount: 49.99 });
* return result;
* }
* ```
*/
callActivity(activity: Activity, input?: TInput): Task;
```

## Acceptance Criteria
- [ ] All workflow client and runtime classes fully annotated
- [ ] Orchestration context primitives documented with usage examples
- [ ] Workflow types and options documented
- [ ] No logic changes — documentation only
- [ ] Builds cleanly (npm run build)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.