Temporal-Forge
(A Next-Gen Temporal Workflow Orchestration Framework for TypeScript)

Temporal-Forge supercharges Temporal.io workflows by eliminating boilerplate, automating state management, and enabling seamless hierarchical orchestration.
- Decorator-Based API β Write workflows in a declarative, intuitive way
- Event-Driven Updates β No pollingβWorkflows automatically synchronize state
- State Normalization & Hierarchical Management β Built-in entity normalization & child workflow orchestration
- ContinueAsNew & Long-Running Workflow Support β Efficiently persists state and prevents history bloat
- API Integration β Load & sync external data in real-time
- Built-in Observability β OpenTelemetry support for tracing and debugging
π‘ Why Use Temporal-Forge?
- π Faster Workflow Development β No need to manually manage signals, queries, or updates.
- π§ Intelligent State Management β Normalized entities with automatic denormalization and caching.
- π― Precision Updates β Changes only propagate where needed, eliminating redundant state syncing.
- π€ Automatic Child Workflow Handling β Start, stop, and update workflows without writing extra logic.
π Key Features
1οΈβ£ Step-Based Workflow Execution
Temporal-Forge simplifies workflow design using decorators like @Step()
, @Query()
, and @Signal()
to define workflow logic.
- Step-based execution with dependencies
- Conditional branching & dynamic workflow control
- Lifecycle hooks (
@Before()
, @After()
, @Hook()
)
2οΈβ£ Advanced Stateful Workflow Management
Stateful workflows handle complex entity relationships with automatic state tracking.
β Automatic child workflow execution & cancellation
β Parent workflows automatically sync child state changes
β Limitless nesting of parent-child workflows
3οΈβ£ Event-Driven, Subscription-Based Updates (No Polling)
- Entities update automatically across workflows
- Only relevant workflows receive updates via event-driven signals
- Ancestor tracking prevents infinite loops & redundant updates
π‘ How it Works? β Each workflow subscribes to only the data it cares about.
If an entity updates, only dependent workflows receive updates, ensuring low-latency state propagation.
4οΈβ£ Normalized State & Cached Denormalization
State is structured using normalizr
, ensuring efficient, normalized entity management.
β Automatically flattens nested relationships
β StateManager & limitRecursion cache queries to optimize lookups
β Denormalization is fully cached & optimized
5οΈβ£ Auto-Managed Child Workflow Lifecycle
- β
Starts child workflows when needed
- β
Cancels workflows when dependencies change
- β
Passes subscription objects so child workflows notify parents of updates
No more manual child workflow managementβit just works.
π¦ Installation
npm install temporal-forge
or
yarn add temporal-forge
π§ Requirements:
- Node.js 20+
- Temporal.ioβs TypeScript SDK 1.11.7+
π Quick Start
Basic Workflow
import { Temporal, Workflow } from 'temporal-forge';
@Temporal()
class SimpleWorkflow extends Workflow {
async execute() {
this.log.info('Executing workflow...');
}
}
export default SimpleWorkflow;
Stateful Workflow Example
type User = {
id: string;
likes: Like[];
};
type Like = {
id: string;
user: User;
};
import { Temporal, StatefulWorkflow, SchemaManagerStatefulWorkflowParams, StatefulWorkflowOptions } from 'temporal-forge';
@Temporal({
schemaName: "User",
schemas: SchemaManager.schemas
})
class UserWorkflow extends StatefulWorkflow<
StatefulWorkflowParams<User>,
StatefulWorkflowOptions
> {
@Property({ path: 'likes' })
protected likes!: Like[];
async execute() {
this.log.info('Executing workflow, all children in this.likes will have been auto started...');
}
}
export default UserWorkflow;
SchemaManager.parseYAML(`
User:
idAttribute: id
likes: [Like]
Like:
idAttribute: id
user: User
`);
π‘ This workflow automatically normalizes state and updates subscribers whenever data is changed!
π Documentation
π Read the full docs:
π οΈ Core Concepts
β Step-Based Execution β Define steps using @Step()
β Workflow Lifecycle Management β Manage workflow execution state
β Query & Signal Handling β Real-time data retrieval and updates
β Automatic Retry & Error Handling β Decorators like @OnError()
simplify failure recovery
π Advanced Topics
- Handling Circular Workflow Relationships β Prevents redundant updates
- Security & API Token Management β Securely handle external API access
- ContinueAsNew Optimization β Ensures long-running workflows stay within Temporalβs execution limits
π Full API reference available in docs/API.md
π§ͺ Testing & Validation
Temporal-Forge includes a comprehensive test suite:
- β
Unit tests for decorators, subscriptions, and state management
- β
Integration tests covering real-world workflow scenarios
- β
SonarCloud reports for maintainability, security, and reliability
π‘ Run tests locally:
npm run test
π€ Contributing
π We welcome contributions! Whether it's bug fixes, feature requests, or documentation improvementsβjoin the project and help make Temporal-Forge even better.
π See CONTRIBUTING.md for details.
π License
MIT License β See the LICENSE file for more details.
π‘ "Those who say it cannot be done should stop interrupting the people doing it."