nestjs-temporal-core 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +213 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.js +9 -0
- package/dist/constants.js.map +1 -0
- package/dist/decorators/activity-method.decorator.d.ts +4 -0
- package/dist/decorators/activity-method.decorator.js +15 -0
- package/dist/decorators/activity-method.decorator.js.map +1 -0
- package/dist/decorators/activity.decorator.d.ts +4 -0
- package/dist/decorators/activity.decorator.js +16 -0
- package/dist/decorators/activity.decorator.js.map +1 -0
- package/dist/decorators/index.d.ts +4 -0
- package/dist/decorators/index.js +21 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/inject-temporal-client.decorator.d.ts +1 -0
- package/dist/decorators/inject-temporal-client.decorator.js +8 -0
- package/dist/decorators/inject-temporal-client.decorator.js.map +1 -0
- package/dist/decorators/workflow.decorator.d.ts +2 -0
- package/dist/decorators/workflow.decorator.js +13 -0
- package/dist/decorators/workflow.decorator.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/base.interface.d.ts +13 -0
- package/dist/interfaces/base.interface.js +3 -0
- package/dist/interfaces/base.interface.js.map +1 -0
- package/dist/interfaces/client.interface.d.ts +15 -0
- package/dist/interfaces/client.interface.js +3 -0
- package/dist/interfaces/client.interface.js.map +1 -0
- package/dist/interfaces/index.d.ts +3 -0
- package/dist/interfaces/index.js +20 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/worker.interface.d.ts +19 -0
- package/dist/interfaces/worker.interface.js +3 -0
- package/dist/interfaces/worker.interface.js.map +1 -0
- package/dist/temporal-client.module.d.ts +10 -0
- package/dist/temporal-client.module.js +138 -0
- package/dist/temporal-client.module.js.map +1 -0
- package/dist/temporal-client.service.d.ts +22 -0
- package/dist/temporal-client.service.js +118 -0
- package/dist/temporal-client.service.js.map +1 -0
- package/dist/temporal-metadata.accessor.d.ts +5 -0
- package/dist/temporal-metadata.accessor.js +35 -0
- package/dist/temporal-metadata.accessor.js.map +1 -0
- package/dist/temporal-worker.module.d.ts +8 -0
- package/dist/temporal-worker.module.js +270 -0
- package/dist/temporal-worker.module.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +86 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Harsh Makwana
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# NestJS Temporal Core
|
|
2
|
+
|
|
3
|
+
A NestJS integration for [Temporal.io](https://temporal.io/) that provides seamless worker and client support for building reliable distributed applications.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🚀 Easy integration with NestJS modules
|
|
8
|
+
- 🔄 Automatic worker initialization and shutdown
|
|
9
|
+
- 🎯 Declarative activity decorators
|
|
10
|
+
- 🔌 Built-in connection management
|
|
11
|
+
- 🛡️ Type-safe workflow execution
|
|
12
|
+
- 📡 Simplified client operations
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install nestjs-temporal-core @temporalio/client @temporalio/worker @temporalio/workflow
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
### 1. Register the Module
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { Module } from '@nestjs/common';
|
|
26
|
+
import { TemporalWorkerModule, TemporalClientModule } from 'nestjs-temporal-core';
|
|
27
|
+
|
|
28
|
+
@Module({
|
|
29
|
+
imports: [
|
|
30
|
+
TemporalWorkerModule.register({
|
|
31
|
+
connection: {
|
|
32
|
+
address: 'localhost:7233',
|
|
33
|
+
},
|
|
34
|
+
namespace: 'default',
|
|
35
|
+
taskQueue: 'my-task-queue',
|
|
36
|
+
workflowsPath: require.resolve('./workflows'),
|
|
37
|
+
activityClasses: [MyActivity],
|
|
38
|
+
}),
|
|
39
|
+
TemporalClientModule.register({
|
|
40
|
+
connection: {
|
|
41
|
+
address: 'localhost:7233',
|
|
42
|
+
},
|
|
43
|
+
namespace: 'default',
|
|
44
|
+
}),
|
|
45
|
+
],
|
|
46
|
+
})
|
|
47
|
+
export class AppModule {}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2. Define Activities
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { Activity, ActivityMethod } from 'nestjs-temporal-core';
|
|
54
|
+
|
|
55
|
+
@Activity()
|
|
56
|
+
export class PaymentActivity {
|
|
57
|
+
@ActivityMethod()
|
|
58
|
+
async processPayment(amount: number): Promise<string> {
|
|
59
|
+
// Implementation
|
|
60
|
+
return 'payment-id';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 3. Define Workflows
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { proxyActivities } from '@temporalio/workflow';
|
|
69
|
+
import type { PaymentActivity } from './payment.activity';
|
|
70
|
+
|
|
71
|
+
const { processPayment } = proxyActivities<PaymentActivity>({
|
|
72
|
+
startToCloseTimeout: '30 seconds',
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export async function paymentWorkflow(amount: number): Promise<string> {
|
|
76
|
+
return await processPayment(amount);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 4. Use the Client Service
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { Injectable } from '@nestjs/common';
|
|
84
|
+
import { TemporalClientService } from 'nestjs-temporal-core';
|
|
85
|
+
|
|
86
|
+
@Injectable()
|
|
87
|
+
export class PaymentService {
|
|
88
|
+
constructor(private readonly temporalClient: TemporalClientService) {}
|
|
89
|
+
|
|
90
|
+
async initiatePayment(amount: number) {
|
|
91
|
+
const { result } = await this.temporalClient.startWorkflow<string, [number]>(
|
|
92
|
+
'paymentWorkflow',
|
|
93
|
+
[amount],
|
|
94
|
+
{
|
|
95
|
+
taskQueue: 'my-task-queue',
|
|
96
|
+
},
|
|
97
|
+
);
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Advanced Configuration
|
|
104
|
+
|
|
105
|
+
### Async Configuration
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
TemporalWorkerModule.registerAsync({
|
|
109
|
+
imports: [ConfigModule],
|
|
110
|
+
useFactory: async (configService: ConfigService) => ({
|
|
111
|
+
connection: {
|
|
112
|
+
address: configService.get('TEMPORAL_ADDRESS'),
|
|
113
|
+
},
|
|
114
|
+
namespace: configService.get('TEMPORAL_NAMESPACE'),
|
|
115
|
+
taskQueue: configService.get('TEMPORAL_TASK_QUEUE'),
|
|
116
|
+
workflowsPath: require.resolve('./workflows'),
|
|
117
|
+
activityClasses: [MyActivity],
|
|
118
|
+
}),
|
|
119
|
+
inject: [ConfigService],
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### TLS Configuration
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
TemporalClientModule.register({
|
|
127
|
+
connection: {
|
|
128
|
+
address: 'temporal.example.com:7233',
|
|
129
|
+
tls: {
|
|
130
|
+
clientCertPair: {
|
|
131
|
+
crt: Buffer.from('...'),
|
|
132
|
+
key: Buffer.from('...'),
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
namespace: 'production',
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## API Reference
|
|
141
|
+
|
|
142
|
+
### Decorators
|
|
143
|
+
|
|
144
|
+
- `@Activity()`: Marks a class as a Temporal activity
|
|
145
|
+
- `@ActivityMethod()`: Marks a method as a Temporal activity implementation
|
|
146
|
+
- `@Workflow()`: Marks a class as a Temporal workflow
|
|
147
|
+
- `@InjectTemporalClient()`: Injects the Temporal client instance
|
|
148
|
+
|
|
149
|
+
### Services
|
|
150
|
+
|
|
151
|
+
#### TemporalClientService
|
|
152
|
+
|
|
153
|
+
- `startWorkflow<T, A>()`: Start a new workflow execution
|
|
154
|
+
- `signalWorkflow()`: Send a signal to a running workflow
|
|
155
|
+
- `terminateWorkflow()`: Terminate a running workflow
|
|
156
|
+
- `getWorkflowHandle()`: Get a handle to manage a workflow
|
|
157
|
+
|
|
158
|
+
### Module Options
|
|
159
|
+
|
|
160
|
+
#### TemporalWorkerOptions
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
interface TemporalWorkerOptions {
|
|
164
|
+
connection: NativeConnectionOptions;
|
|
165
|
+
namespace: string;
|
|
166
|
+
taskQueue: string;
|
|
167
|
+
workflowsPath: string;
|
|
168
|
+
activityClasses?: Array<new (...args: any[]) => any>;
|
|
169
|
+
runtimeOptions?: RuntimeOptions;
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### TemporalClientOptions
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
interface TemporalClientOptions {
|
|
177
|
+
connection: ConnectionOptions;
|
|
178
|
+
namespace?: string;
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Error Handling
|
|
183
|
+
|
|
184
|
+
The module provides built-in error handling and logging. Worker and client errors are logged using NestJS's built-in logger.
|
|
185
|
+
|
|
186
|
+
## Health Checks
|
|
187
|
+
|
|
188
|
+
The WorkerManager provides a `getStatus()` method to check the worker's health:
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
const status = await workerManager.getStatus();
|
|
192
|
+
// Returns: { isRunning: boolean; isInitializing: boolean; error: Error | null }
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Best Practices
|
|
196
|
+
|
|
197
|
+
1. Always define activity interfaces for type safety
|
|
198
|
+
2. Use meaningful workflow IDs for tracking
|
|
199
|
+
3. Implement proper error handling in activities
|
|
200
|
+
4. Set appropriate timeouts for activities and workflows
|
|
201
|
+
5. Use signals for long-running workflow coordination
|
|
202
|
+
|
|
203
|
+
## Contributing
|
|
204
|
+
|
|
205
|
+
Contributions are welcome! Please see our [contributing guidelines](CONTRIBUTING.md) for details.
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
MIT
|
|
210
|
+
|
|
211
|
+
## Author
|
|
212
|
+
|
|
213
|
+
Harsh M
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const TEMPORAL_ACTIVITY: unique symbol;
|
|
2
|
+
export declare const TEMPORAL_ACTIVITY_METHOD: unique symbol;
|
|
3
|
+
export declare const TEMPORAL_WORKFLOW: unique symbol;
|
|
4
|
+
export declare const TEMPORAL_CLIENT: unique symbol;
|
|
5
|
+
export declare const TEMPORAL_MODULE_OPTIONS: unique symbol;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TEMPORAL_MODULE_OPTIONS = exports.TEMPORAL_CLIENT = exports.TEMPORAL_WORKFLOW = exports.TEMPORAL_ACTIVITY_METHOD = exports.TEMPORAL_ACTIVITY = void 0;
|
|
4
|
+
exports.TEMPORAL_ACTIVITY = Symbol('TEMPORAL_ACTIVITY');
|
|
5
|
+
exports.TEMPORAL_ACTIVITY_METHOD = Symbol('TEMPORAL_ACTIVITY_METHOD');
|
|
6
|
+
exports.TEMPORAL_WORKFLOW = Symbol('TEMPORAL_WORKFLOW');
|
|
7
|
+
exports.TEMPORAL_CLIENT = Symbol('TEMPORAL_CLIENT');
|
|
8
|
+
exports.TEMPORAL_MODULE_OPTIONS = Symbol('TEMPORAL_MODULE_OPTIONS');
|
|
9
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAChD,QAAA,wBAAwB,GAAG,MAAM,CAAC,0BAA0B,CAAC,CAAC;AAC9D,QAAA,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAChD,QAAA,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAC5C,QAAA,uBAAuB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActivityMethod = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
function ActivityMethod(options = {}) {
|
|
7
|
+
return (target, propertyKey, descriptor) => {
|
|
8
|
+
(0, common_1.SetMetadata)(constants_1.TEMPORAL_ACTIVITY_METHOD, true)(descriptor.value);
|
|
9
|
+
const methodName = options.name || propertyKey.toString();
|
|
10
|
+
Reflect.defineMetadata('activityMethodName', methodName, descriptor.value);
|
|
11
|
+
return descriptor;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
exports.ActivityMethod = ActivityMethod;
|
|
15
|
+
//# sourceMappingURL=activity-method.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activity-method.decorator.js","sourceRoot":"","sources":["../../src/decorators/activity-method.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAC7C,4CAAwD;AAMxD,SAAgB,cAAc,CAAC,UAAiC,EAAE;IAChE,OAAO,CAAC,MAAW,EAAE,WAA4B,EAAE,UAA8B,EAAE,EAAE;QACnF,IAAA,oBAAW,EAAC,oCAAwB,EAAE,IAAI,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAG9D,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;QAC1D,OAAO,CAAC,cAAc,CAAC,oBAAoB,EAAE,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;QAE3E,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAVD,wCAUC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Activity = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
function Activity(options = {}) {
|
|
7
|
+
return (target) => {
|
|
8
|
+
(0, common_1.SetMetadata)(constants_1.TEMPORAL_ACTIVITY, true)(target);
|
|
9
|
+
if (options.name) {
|
|
10
|
+
Reflect.defineMetadata('activityName', options.name, target);
|
|
11
|
+
}
|
|
12
|
+
return target;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.Activity = Activity;
|
|
16
|
+
//# sourceMappingURL=activity.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activity.decorator.js","sourceRoot":"","sources":["../../src/decorators/activity.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAC7C,4CAAiD;AAMjD,SAAgB,QAAQ,CAAC,UAA2B,EAAE;IACpD,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAA,oBAAW,EAAC,6BAAiB,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,OAAO,CAAC,IAAI,EAAE;YAChB,OAAO,CAAC,cAAc,CAAC,cAAc,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;SAC9D;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AARD,4BAQC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./activity.decorator"), exports);
|
|
18
|
+
__exportStar(require("./activity-method.decorator"), exports);
|
|
19
|
+
__exportStar(require("./workflow.decorator"), exports);
|
|
20
|
+
__exportStar(require("./inject-temporal-client.decorator"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,8DAA4C;AAC5C,uDAAqC;AACrC,qEAAmD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const InjectTemporalClient: () => ParameterDecorator;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InjectTemporalClient = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const InjectTemporalClient = () => (0, common_1.Inject)(constants_1.TEMPORAL_CLIENT);
|
|
7
|
+
exports.InjectTemporalClient = InjectTemporalClient;
|
|
8
|
+
//# sourceMappingURL=inject-temporal-client.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject-temporal-client.decorator.js","sourceRoot":"","sources":["../../src/decorators/inject-temporal-client.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,4CAA+C;AAExC,MAAM,oBAAoB,GAAG,GAAuB,EAAE,CAAC,IAAA,eAAM,EAAC,2BAAe,CAAC,CAAC;AAAzE,QAAA,oBAAoB,wBAAqD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Workflow = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
function Workflow(options = { workflowId: '', taskQueue: '' }) {
|
|
7
|
+
return (target) => {
|
|
8
|
+
(0, common_1.SetMetadata)(constants_1.TEMPORAL_WORKFLOW, options)(target);
|
|
9
|
+
return target;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
exports.Workflow = Workflow;
|
|
13
|
+
//# sourceMappingURL=workflow.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.decorator.js","sourceRoot":"","sources":["../../src/decorators/workflow.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAC7C,4CAAiD;AAGjD,SAAgB,QAAQ,CACtB,UAA2B,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;IAE5D,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,IAAA,oBAAW,EAAC,6BAAiB,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;QAChD,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAPD,4BAOC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./temporal-client.module"), exports);
|
|
18
|
+
__exportStar(require("./temporal-worker.module"), exports);
|
|
19
|
+
__exportStar(require("./temporal-client.service"), exports);
|
|
20
|
+
__exportStar(require("./interfaces"), exports);
|
|
21
|
+
__exportStar(require("./decorators"), exports);
|
|
22
|
+
__exportStar(require("./constants"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,2DAAyC;AACzC,2DAAyC;AACzC,4DAA0C;AAG1C,+CAA6B;AAG7B,+CAA6B;AAG7B,8CAA4B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
export interface ClientCertPair {
|
|
4
|
+
crt: Buffer;
|
|
5
|
+
key: Buffer;
|
|
6
|
+
}
|
|
7
|
+
export interface TlsOptions {
|
|
8
|
+
clientCertPair: ClientCertPair;
|
|
9
|
+
}
|
|
10
|
+
export interface ConnectionOptions {
|
|
11
|
+
address: string;
|
|
12
|
+
tls?: TlsOptions;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.interface.js","sourceRoot":"","sources":["../../src/interfaces/base.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ModuleMetadata, Type } from '@nestjs/common';
|
|
2
|
+
import { ConnectionOptions } from '@temporalio/client';
|
|
3
|
+
export interface TemporalClientOptions {
|
|
4
|
+
connection: ConnectionOptions;
|
|
5
|
+
namespace?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface TemporalClientOptionsFactory {
|
|
8
|
+
createClientOptions(): Promise<TemporalClientOptions> | TemporalClientOptions;
|
|
9
|
+
}
|
|
10
|
+
export interface TemporalClientAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
11
|
+
useExisting?: Type<TemporalClientOptionsFactory>;
|
|
12
|
+
useClass?: Type<TemporalClientOptionsFactory>;
|
|
13
|
+
useFactory?: (...args: any[]) => Promise<TemporalClientOptions> | TemporalClientOptions;
|
|
14
|
+
inject?: any[];
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.interface.js","sourceRoot":"","sources":["../../src/interfaces/client.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./base.interface"), exports);
|
|
18
|
+
__exportStar(require("./client.interface"), exports);
|
|
19
|
+
__exportStar(require("./worker.interface"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,qDAAmC;AACnC,qDAAmC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ModuleMetadata, Type } from '@nestjs/common';
|
|
2
|
+
import { NativeConnectionOptions, RuntimeOptions } from '@temporalio/worker';
|
|
3
|
+
export interface TemporalWorkerOptions {
|
|
4
|
+
connection: NativeConnectionOptions;
|
|
5
|
+
namespace: string;
|
|
6
|
+
taskQueue: string;
|
|
7
|
+
workflowsPath: string;
|
|
8
|
+
activityClasses?: Array<new (...args: any[]) => any>;
|
|
9
|
+
runtimeOptions?: RuntimeOptions;
|
|
10
|
+
}
|
|
11
|
+
export interface TemporalWorkerOptionsFactory {
|
|
12
|
+
createWorkerOptions(): Promise<TemporalWorkerOptions> | TemporalWorkerOptions;
|
|
13
|
+
}
|
|
14
|
+
export interface TemporalWorkerAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
15
|
+
useExisting?: Type<TemporalWorkerOptionsFactory>;
|
|
16
|
+
useClass?: Type<TemporalWorkerOptionsFactory>;
|
|
17
|
+
useFactory?: (...args: any[]) => Promise<TemporalWorkerOptions> | TemporalWorkerOptions;
|
|
18
|
+
inject?: any[];
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker.interface.js","sourceRoot":"","sources":["../../src/interfaces/worker.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { TemporalClientOptions, TemporalClientAsyncOptions } from './interfaces';
|
|
3
|
+
export declare class TemporalClientModule {
|
|
4
|
+
private static readonly logger;
|
|
5
|
+
private static createClient;
|
|
6
|
+
static register(options: TemporalClientOptions): DynamicModule;
|
|
7
|
+
static registerAsync(options: TemporalClientAsyncOptions): DynamicModule;
|
|
8
|
+
private static createAsyncProviders;
|
|
9
|
+
private static addShutdownHook;
|
|
10
|
+
}
|