nestjs-temporal-core 2.0.2 → 2.0.3
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/README.md +135 -21
- package/dist/client/temporal-client.module.js +41 -14
- package/dist/client/temporal-client.module.js.map +1 -1
- package/dist/client/temporal-client.service.d.ts +4 -7
- package/dist/client/temporal-client.service.js +14 -5
- package/dist/client/temporal-client.service.js.map +1 -1
- package/dist/constants.d.ts +34 -1
- package/dist/constants.js +35 -2
- package/dist/constants.js.map +1 -1
- package/dist/decorators/activity-method.decorator.d.ts +8 -1
- package/dist/decorators/activity-method.decorator.js +21 -3
- package/dist/decorators/activity-method.decorator.js.map +1 -1
- package/dist/decorators/activity.decorator.d.ts +5 -1
- package/dist/decorators/activity.decorator.js +3 -3
- package/dist/decorators/activity.decorator.js.map +1 -1
- package/dist/decorators/workflow.decorator.d.ts +16 -2
- package/dist/decorators/workflow.decorator.js +11 -4
- package/dist/decorators/workflow.decorator.js.map +1 -1
- package/dist/interfaces/base.interface.d.ts +4 -2
- package/dist/interfaces/client.interface.d.ts +27 -1
- package/dist/interfaces/worker.interface.d.ts +17 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/worker/temporal-metadata.accessor.d.ts +11 -0
- package/dist/worker/temporal-metadata.accessor.js +78 -1
- package/dist/worker/temporal-metadata.accessor.js.map +1 -1
- package/dist/worker/temporal-worker.module.d.ts +2 -1
- package/dist/worker/temporal-worker.module.js +17 -10
- package/dist/worker/temporal-worker.module.js.map +1 -1
- package/dist/worker/worker-manager.service.d.ts +8 -7
- package/dist/worker/worker-manager.service.js +116 -54
- package/dist/worker/worker-manager.service.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# NestJS Temporal Core
|
|
2
2
|
|
|
3
|
-
A NestJS integration for [Temporal.io](https://temporal.io/) that provides seamless worker and client support for building reliable distributed applications.
|
|
3
|
+
A robust NestJS integration for [Temporal.io](https://temporal.io/) that provides seamless worker and client support for building reliable distributed applications.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- 🚀 Easy integration with NestJS modules
|
|
8
8
|
- 🔄 Automatic worker initialization and shutdown
|
|
9
|
-
- 🎯 Declarative activity decorators
|
|
9
|
+
- 🎯 Declarative activity and workflow decorators
|
|
10
10
|
- 🔌 Built-in connection management
|
|
11
11
|
- 🛡️ Type-safe workflow execution
|
|
12
12
|
- 📡 Simplified client operations
|
|
@@ -14,6 +14,10 @@ A NestJS integration for [Temporal.io](https://temporal.io/) that provides seaml
|
|
|
14
14
|
- 🎛️ Configurable runtime options
|
|
15
15
|
- 🔄 Enhanced worker options customization
|
|
16
16
|
- 📊 Worker status monitoring
|
|
17
|
+
- 📅 Cron workflow scheduling
|
|
18
|
+
- 🔍 Query handling support
|
|
19
|
+
- 📣 Signal handling
|
|
20
|
+
- 🚦 Workflow retry policies
|
|
17
21
|
|
|
18
22
|
## Installation
|
|
19
23
|
|
|
@@ -52,14 +56,23 @@ import { TemporalWorkerModule, TemporalClientModule } from 'nestjs-temporal-core
|
|
|
52
56
|
taskQueue: 'my-task-queue',
|
|
53
57
|
workflowsPath: require.resolve('./workflows'),
|
|
54
58
|
activityClasses: [MyActivity],
|
|
55
|
-
//
|
|
59
|
+
// Optional runtime configuration
|
|
56
60
|
runtimeOptions: {
|
|
57
61
|
// Add your runtime options here
|
|
58
62
|
},
|
|
59
|
-
//
|
|
63
|
+
// Optional worker configuration
|
|
60
64
|
workerOptions: {
|
|
61
65
|
// Add your worker options here
|
|
62
66
|
},
|
|
67
|
+
// Auto-start configuration
|
|
68
|
+
autoStart: {
|
|
69
|
+
enabled: true,
|
|
70
|
+
delayMs: 1000, // Start worker after 1 second
|
|
71
|
+
},
|
|
72
|
+
// Optional monitoring configuration
|
|
73
|
+
monitoring: {
|
|
74
|
+
statsIntervalMs: 60000, // Log stats every minute
|
|
75
|
+
},
|
|
63
76
|
}),
|
|
64
77
|
TemporalClientModule.register({
|
|
65
78
|
connection: {
|
|
@@ -77,13 +90,27 @@ export class AppModule {}
|
|
|
77
90
|
```typescript
|
|
78
91
|
import { Activity, ActivityMethod } from 'nestjs-temporal-core';
|
|
79
92
|
|
|
80
|
-
@Activity(
|
|
93
|
+
@Activity({
|
|
94
|
+
name: 'PaymentActivities', // Optional custom name
|
|
95
|
+
description: 'Activities for payment processing',
|
|
96
|
+
})
|
|
81
97
|
export class PaymentActivity {
|
|
82
|
-
@ActivityMethod(
|
|
98
|
+
@ActivityMethod({
|
|
99
|
+
name: 'processPayment', // Optional custom name
|
|
100
|
+
timeout: {
|
|
101
|
+
startToClose: '30s',
|
|
102
|
+
},
|
|
103
|
+
})
|
|
83
104
|
async processPayment(amount: number): Promise<string> {
|
|
84
105
|
// Implementation
|
|
85
106
|
return 'payment-id';
|
|
86
107
|
}
|
|
108
|
+
|
|
109
|
+
@ActivityMethod()
|
|
110
|
+
async refundPayment(paymentId: string): Promise<boolean> {
|
|
111
|
+
// Implementation
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
87
114
|
}
|
|
88
115
|
```
|
|
89
116
|
|
|
@@ -93,13 +120,17 @@ export class PaymentActivity {
|
|
|
93
120
|
import { proxyActivities } from '@temporalio/workflow';
|
|
94
121
|
import type { PaymentActivity } from './payment.activity';
|
|
95
122
|
|
|
96
|
-
const { processPayment } = proxyActivities<PaymentActivity>({
|
|
123
|
+
const { processPayment, refundPayment } = proxyActivities<PaymentActivity>({
|
|
97
124
|
startToCloseTimeout: '30 seconds',
|
|
98
125
|
});
|
|
99
126
|
|
|
100
127
|
export async function paymentWorkflow(amount: number): Promise<string> {
|
|
101
128
|
return await processPayment(amount);
|
|
102
129
|
}
|
|
130
|
+
|
|
131
|
+
export async function refundWorkflow(paymentId: string): Promise<boolean> {
|
|
132
|
+
return await refundPayment(paymentId);
|
|
133
|
+
}
|
|
103
134
|
```
|
|
104
135
|
|
|
105
136
|
### 5. Use the Client Service
|
|
@@ -113,14 +144,33 @@ export class PaymentService {
|
|
|
113
144
|
constructor(private readonly temporalClient: TemporalClientService) {}
|
|
114
145
|
|
|
115
146
|
async initiatePayment(amount: number) {
|
|
116
|
-
const { result,
|
|
147
|
+
const { result, workflowId } = await this.temporalClient.startWorkflow<string, [number]>(
|
|
117
148
|
'paymentWorkflow',
|
|
118
149
|
[amount],
|
|
119
150
|
{
|
|
120
151
|
taskQueue: 'my-task-queue',
|
|
152
|
+
workflowExecutionTimeout: '1h',
|
|
153
|
+
workflowTaskTimeout: '10s',
|
|
154
|
+
retry: {
|
|
155
|
+
maximumAttempts: 3,
|
|
156
|
+
},
|
|
121
157
|
},
|
|
122
158
|
);
|
|
123
|
-
|
|
159
|
+
|
|
160
|
+
// Wait for the workflow to complete
|
|
161
|
+
const paymentId = await result;
|
|
162
|
+
|
|
163
|
+
return { paymentId, workflowId };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async checkPaymentStatus(workflowId: string) {
|
|
167
|
+
// Query a running workflow
|
|
168
|
+
return await this.temporalClient.queryWorkflow<string>(workflowId, 'getPaymentStatus');
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async cancelPayment(workflowId: string, reason: string) {
|
|
172
|
+
// Signal a running workflow
|
|
173
|
+
await this.temporalClient.signalWorkflow(workflowId, 'cancelPayment', [reason]);
|
|
124
174
|
}
|
|
125
175
|
}
|
|
126
176
|
```
|
|
@@ -135,17 +185,17 @@ TemporalWorkerModule.registerAsync({
|
|
|
135
185
|
useFactory: async (configService: ConfigService) => ({
|
|
136
186
|
connection: {
|
|
137
187
|
address: configService.get('TEMPORAL_ADDRESS'),
|
|
188
|
+
connectionTimeout: configService.get('TEMPORAL_CONNECTION_TIMEOUT', 5000),
|
|
138
189
|
},
|
|
139
190
|
namespace: configService.get('TEMPORAL_NAMESPACE'),
|
|
140
191
|
taskQueue: configService.get('TEMPORAL_TASK_QUEUE'),
|
|
141
192
|
workflowsPath: require.resolve('./workflows'),
|
|
142
193
|
activityClasses: [MyActivity],
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
workerOptions: {
|
|
147
|
-
// Add worker options
|
|
194
|
+
autoStart: {
|
|
195
|
+
enabled: configService.get('TEMPORAL_WORKER_AUTOSTART', true),
|
|
196
|
+
delayMs: configService.get('TEMPORAL_WORKER_START_DELAY', 0),
|
|
148
197
|
},
|
|
198
|
+
allowWorkerFailure: configService.get('TEMPORAL_ALLOW_WORKER_FAILURE', true),
|
|
149
199
|
}),
|
|
150
200
|
inject: [ConfigService],
|
|
151
201
|
});
|
|
@@ -161,10 +211,15 @@ TemporalClientModule.register({
|
|
|
161
211
|
clientCertPair: {
|
|
162
212
|
crt: Buffer.from('...'),
|
|
163
213
|
key: Buffer.from('...'),
|
|
214
|
+
ca: Buffer.from('...'), // Optional CA certificate
|
|
164
215
|
},
|
|
216
|
+
serverName: 'temporal.example.com', // Optional for SNI
|
|
217
|
+
verifyServer: true, // Optional, defaults to true
|
|
165
218
|
},
|
|
219
|
+
connectionTimeout: 10000, // 10 seconds
|
|
166
220
|
},
|
|
167
221
|
namespace: 'production',
|
|
222
|
+
allowConnectionFailure: true, // Allow application to start if Temporal connection fails
|
|
168
223
|
});
|
|
169
224
|
```
|
|
170
225
|
|
|
@@ -172,9 +227,9 @@ TemporalClientModule.register({
|
|
|
172
227
|
|
|
173
228
|
### Decorators
|
|
174
229
|
|
|
175
|
-
- `@Activity()`: Marks a class as a Temporal activity
|
|
176
|
-
- `@ActivityMethod(
|
|
177
|
-
- `@Workflow(options
|
|
230
|
+
- `@Activity(options?)`: Marks a class as a Temporal activity with optional configuration
|
|
231
|
+
- `@ActivityMethod(options?)`: Marks a method as a Temporal activity implementation with optional configuration
|
|
232
|
+
- `@Workflow(options)`: Marks a class as a Temporal workflow with configuration
|
|
178
233
|
|
|
179
234
|
### Services
|
|
180
235
|
|
|
@@ -182,16 +237,17 @@ TemporalClientModule.register({
|
|
|
182
237
|
|
|
183
238
|
- `startWorkflow<T, A>()`: Start a new workflow execution
|
|
184
239
|
- `signalWorkflow()`: Send a signal to a running workflow
|
|
240
|
+
- `queryWorkflow<T>()`: Query a running workflow
|
|
185
241
|
- `terminateWorkflow()`: Terminate a running workflow
|
|
242
|
+
- `cancelWorkflow()`: Request cancellation of a workflow
|
|
186
243
|
- `getWorkflowHandle()`: Get a handle to manage a workflow
|
|
187
244
|
- `getWorkflowClient()`: Get the underlying workflow client instance
|
|
188
245
|
|
|
189
246
|
#### WorkerManager
|
|
190
247
|
|
|
191
|
-
- `
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
- namespace: string
|
|
248
|
+
- `startWorker()`: Manually start the worker if it's not running
|
|
249
|
+
- `shutdown()`: Gracefully shutdown the worker
|
|
250
|
+
- `getWorker()`: Get the underlying worker instance
|
|
195
251
|
|
|
196
252
|
### Module Options
|
|
197
253
|
|
|
@@ -206,6 +262,21 @@ interface TemporalWorkerOptions {
|
|
|
206
262
|
activityClasses?: Array<new (...args: any[]) => any>;
|
|
207
263
|
runtimeOptions?: RuntimeOptions;
|
|
208
264
|
workerOptions?: WorkerOptions;
|
|
265
|
+
autoStart?: {
|
|
266
|
+
enabled?: boolean;
|
|
267
|
+
delayMs?: number;
|
|
268
|
+
};
|
|
269
|
+
allowWorkerFailure?: boolean;
|
|
270
|
+
monitoring?: {
|
|
271
|
+
statsIntervalMs?: number;
|
|
272
|
+
metrics?: {
|
|
273
|
+
enabled?: boolean;
|
|
274
|
+
prometheus?: {
|
|
275
|
+
enabled?: boolean;
|
|
276
|
+
port?: number;
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
};
|
|
209
280
|
}
|
|
210
281
|
```
|
|
211
282
|
|
|
@@ -215,6 +286,46 @@ interface TemporalWorkerOptions {
|
|
|
215
286
|
interface TemporalClientOptions {
|
|
216
287
|
connection: ConnectionOptions;
|
|
217
288
|
namespace?: string;
|
|
289
|
+
allowConnectionFailure?: boolean;
|
|
290
|
+
reconnect?: {
|
|
291
|
+
enabled?: boolean;
|
|
292
|
+
maxAttempts?: number;
|
|
293
|
+
initialDelayMs?: number;
|
|
294
|
+
maxDelayMs?: number;
|
|
295
|
+
backoffCoefficient?: number;
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Activity Method Options
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
interface ActivityMethodOptions {
|
|
304
|
+
name?: string;
|
|
305
|
+
description?: string;
|
|
306
|
+
timeout?: {
|
|
307
|
+
startToClose?: string | number;
|
|
308
|
+
scheduleToStart?: string | number;
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Workflow Options
|
|
314
|
+
|
|
315
|
+
```typescript
|
|
316
|
+
interface TemporalWorkflowDecoratorOptions {
|
|
317
|
+
name?: string;
|
|
318
|
+
description?: string;
|
|
319
|
+
taskQueue: string;
|
|
320
|
+
workflowIdPrefix?: string;
|
|
321
|
+
executionTimeout?: string;
|
|
322
|
+
workflowTaskTimeout?: string;
|
|
323
|
+
retry?: {
|
|
324
|
+
maximumAttempts?: number;
|
|
325
|
+
initialInterval?: number;
|
|
326
|
+
maximumInterval?: number;
|
|
327
|
+
backoffCoefficient?: number;
|
|
328
|
+
};
|
|
218
329
|
}
|
|
219
330
|
```
|
|
220
331
|
|
|
@@ -226,6 +337,7 @@ The module includes comprehensive error handling:
|
|
|
226
337
|
- Client operations include detailed error messages and proper error propagation
|
|
227
338
|
- Activity and workflow errors are properly captured and logged
|
|
228
339
|
- Connection errors are handled gracefully with automatic cleanup
|
|
340
|
+
- Configurable failure modes for both client and worker connections
|
|
229
341
|
|
|
230
342
|
## Best Practices
|
|
231
343
|
|
|
@@ -237,6 +349,8 @@ The module includes comprehensive error handling:
|
|
|
237
349
|
6. Monitor worker status using the WorkerManager service
|
|
238
350
|
7. Configure appropriate runtime and worker options for production deployments
|
|
239
351
|
8. Implement proper TLS security for production environments
|
|
352
|
+
9. Use workflow queries for reading workflow state without side effects
|
|
353
|
+
10. Configure graceful shutdown for workers to prevent activity interruptions
|
|
240
354
|
|
|
241
355
|
## Contributing
|
|
242
356
|
|
|
@@ -12,25 +12,34 @@ const common_1 = require("@nestjs/common");
|
|
|
12
12
|
const client_1 = require("@temporalio/client");
|
|
13
13
|
const constants_1 = require("../constants");
|
|
14
14
|
const temporal_client_service_1 = require("./temporal-client.service");
|
|
15
|
-
let TemporalClientModule =
|
|
15
|
+
let TemporalClientModule = TemporalClientModule_1 = class TemporalClientModule {
|
|
16
16
|
static async createClient(options) {
|
|
17
17
|
let connection = null;
|
|
18
18
|
try {
|
|
19
|
+
this.logger.log(`Connecting to Temporal server at ${options.connection.address}`);
|
|
19
20
|
connection = await client_1.Connection.connect({
|
|
20
21
|
address: options.connection.address,
|
|
21
22
|
tls: options.connection.tls,
|
|
23
|
+
...(options.connection.connectionTimeout && {
|
|
24
|
+
connectionTimeout: options.connection.connectionTimeout,
|
|
25
|
+
}),
|
|
22
26
|
});
|
|
27
|
+
const namespace = options.namespace || constants_1.DEFAULT_NAMESPACE;
|
|
28
|
+
this.logger.log(`Connected to Temporal server, using namespace "${namespace}"`);
|
|
23
29
|
return new client_1.Client({
|
|
24
30
|
connection,
|
|
25
|
-
namespace
|
|
31
|
+
namespace,
|
|
26
32
|
});
|
|
27
33
|
}
|
|
28
34
|
catch (error) {
|
|
29
35
|
if (connection) {
|
|
30
|
-
await connection.close().catch(() => {
|
|
36
|
+
await connection.close().catch((closeError) => {
|
|
37
|
+
this.logger.error('Failed to close Temporal connection during error handling', closeError);
|
|
31
38
|
});
|
|
32
39
|
}
|
|
33
|
-
|
|
40
|
+
const errorMsg = `${constants_1.ERRORS.CLIENT_INITIALIZATION}: ${error.message}`;
|
|
41
|
+
this.logger.error(errorMsg, error.stack);
|
|
42
|
+
throw new Error(errorMsg);
|
|
34
43
|
}
|
|
35
44
|
}
|
|
36
45
|
static register(options) {
|
|
@@ -42,8 +51,12 @@ let TemporalClientModule = exports.TemporalClientModule = TemporalClientModule_1
|
|
|
42
51
|
return this.addShutdownHook(client);
|
|
43
52
|
}
|
|
44
53
|
catch (error) {
|
|
45
|
-
this.logger.error('Failed to initialize Temporal client',
|
|
46
|
-
|
|
54
|
+
this.logger.error('Failed to initialize Temporal client', error);
|
|
55
|
+
if (options.allowConnectionFailure !== false) {
|
|
56
|
+
this.logger.warn('Continuing application startup without Temporal client');
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
throw error;
|
|
47
60
|
}
|
|
48
61
|
},
|
|
49
62
|
};
|
|
@@ -69,8 +82,12 @@ let TemporalClientModule = exports.TemporalClientModule = TemporalClientModule_1
|
|
|
69
82
|
return this.addShutdownHook(client);
|
|
70
83
|
}
|
|
71
84
|
catch (error) {
|
|
72
|
-
this.logger.error('Failed to initialize Temporal client',
|
|
73
|
-
|
|
85
|
+
this.logger.error('Failed to initialize Temporal client', error);
|
|
86
|
+
if (clientOptions.allowConnectionFailure !== false) {
|
|
87
|
+
this.logger.warn('Continuing application startup without Temporal client');
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
throw error;
|
|
74
91
|
}
|
|
75
92
|
},
|
|
76
93
|
inject: [constants_1.TEMPORAL_MODULE_OPTIONS],
|
|
@@ -78,7 +95,11 @@ let TemporalClientModule = exports.TemporalClientModule = TemporalClientModule_1
|
|
|
78
95
|
return {
|
|
79
96
|
module: TemporalClientModule_1,
|
|
80
97
|
imports: options.imports || [],
|
|
81
|
-
providers: [
|
|
98
|
+
providers: [
|
|
99
|
+
...this.createAsyncProviders(options),
|
|
100
|
+
clientProvider,
|
|
101
|
+
temporal_client_service_1.TemporalClientService,
|
|
102
|
+
],
|
|
82
103
|
exports: [temporal_client_service_1.TemporalClientService],
|
|
83
104
|
};
|
|
84
105
|
}
|
|
@@ -114,20 +135,26 @@ let TemporalClientModule = exports.TemporalClientModule = TemporalClientModule_1
|
|
|
114
135
|
},
|
|
115
136
|
];
|
|
116
137
|
}
|
|
117
|
-
throw new Error(
|
|
138
|
+
throw new Error(constants_1.ERRORS.INVALID_OPTIONS);
|
|
118
139
|
}
|
|
119
140
|
static addShutdownHook(client) {
|
|
120
141
|
const enhancedClient = client;
|
|
121
|
-
enhancedClient.onApplicationShutdown = async () => {
|
|
142
|
+
enhancedClient.onApplicationShutdown = async (signal) => {
|
|
143
|
+
this.logger.log(`Closing Temporal client connection (signal: ${signal || 'unknown'})`);
|
|
122
144
|
if (client?.connection) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
145
|
+
try {
|
|
146
|
+
await client.connection.close();
|
|
147
|
+
this.logger.log('Temporal connection closed successfully');
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
this.logger.error('Failed to close Temporal connection', error);
|
|
151
|
+
}
|
|
126
152
|
}
|
|
127
153
|
};
|
|
128
154
|
return enhancedClient;
|
|
129
155
|
}
|
|
130
156
|
};
|
|
157
|
+
exports.TemporalClientModule = TemporalClientModule;
|
|
131
158
|
TemporalClientModule.logger = new common_1.Logger(TemporalClientModule_1.name);
|
|
132
159
|
exports.TemporalClientModule = TemporalClientModule = TemporalClientModule_1 = __decorate([
|
|
133
160
|
(0, common_1.Global)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temporal-client.module.js","sourceRoot":"","sources":["../../src/client/temporal-client.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAOwB;AACxB,+CAAwD;AAMxD,
|
|
1
|
+
{"version":3,"file":"temporal-client.module.js","sourceRoot":"","sources":["../../src/client/temporal-client.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAOwB;AACxB,+CAAwD;AAMxD,4CAAmG;AACnG,uEAAkE;AAQ3D,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAQrB,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,OAA8B;QAC5D,IAAI,UAAU,GAAsB,IAAI,CAAC;QACzC,IAAI,CAAC;YACD,IAAI,CAAC,MA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I,KAAK,CAAC,kBAAM,CAAC,eAAe,CAAC,CAAC;IAC5C,CAAC;IAOO,MAAM,CAAC,eAAe,CAAC,MAAc;QACzC,MAAM,cAAc,GAAG,MAAwC,CAAC;QAEhE,cAAc,CAAC,qBAAqB,GAAG,KAAK,EAAE,MAAe,EAAE,EAAE;YAC7D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,+CAA+C,MAAM,IAAI,SAAS,GAAG,CAAC,CAAC;YAEvF,IAAI,MAAM,EAAE,UAAU,EAAE,CAAC;gBACrB,IAAI,CAAC;oBACD,MAAM,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;oBAChC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAC;gBAC/D,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;gBACpE,CAAC;YACL,CAAC;QACL,CAAC,CAAC;QAEF,OAAO,cAAc,CAAC;IAC1B,CAAC;;AA9LQ,oDAAoB;AACL,2BAAM,GAAG,IAAI,eAAM,CAAC,sBAAoB,CAAC,IAAI,CAAC,AAAxC,CAAyC;+BAD9D,oBAAoB;IAFhC,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,oBAAoB,CA+LhC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OnModuleInit } from '@nestjs/common';
|
|
2
2
|
import { Client, WorkflowClient, WorkflowHandle } from '@temporalio/client';
|
|
3
|
+
import { StartWorkflowOptions } from 'src/interfaces';
|
|
3
4
|
export declare class TemporalClientService implements OnModuleInit {
|
|
4
5
|
private readonly client;
|
|
5
6
|
private readonly logger;
|
|
@@ -8,17 +9,13 @@ export declare class TemporalClientService implements OnModuleInit {
|
|
|
8
9
|
onModuleInit(): Promise<void>;
|
|
9
10
|
getWorkflowClient(): WorkflowClient | null;
|
|
10
11
|
private ensureClientInitialized;
|
|
11
|
-
startWorkflow<T, A extends any[]>(workflowType: string, args: A, options: {
|
|
12
|
-
taskQueue: string;
|
|
13
|
-
workflowId?: string;
|
|
14
|
-
signal?: string;
|
|
15
|
-
}): Promise<{
|
|
12
|
+
startWorkflow<T, A extends any[]>(workflowType: string, args: A, options: StartWorkflowOptions): Promise<{
|
|
16
13
|
result: Promise<T>;
|
|
17
14
|
workflowId: string;
|
|
18
15
|
firstExecutionRunId: string;
|
|
19
16
|
handle: WorkflowHandle;
|
|
20
17
|
}>;
|
|
21
|
-
signalWorkflow(workflowId: string, signalName: string, args
|
|
18
|
+
signalWorkflow(workflowId: string, signalName: string, args?: any[]): Promise<void>;
|
|
22
19
|
terminateWorkflow(workflowId: string, reason?: string): Promise<void>;
|
|
23
|
-
getWorkflowHandle(workflowId: string): Promise<WorkflowHandle>;
|
|
20
|
+
getWorkflowHandle(workflowId: string, runId?: string): Promise<WorkflowHandle>;
|
|
24
21
|
}
|
|
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.TemporalClientService = void 0;
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
18
|
const constants_1 = require("../constants");
|
|
19
|
-
let TemporalClientService =
|
|
19
|
+
let TemporalClientService = TemporalClientService_1 = class TemporalClientService {
|
|
20
20
|
constructor(client) {
|
|
21
21
|
this.client = client;
|
|
22
22
|
this.logger = new common_1.Logger(TemporalClientService_1.name);
|
|
@@ -29,6 +29,9 @@ let TemporalClientService = exports.TemporalClientService = TemporalClientServic
|
|
|
29
29
|
if (!this.client) {
|
|
30
30
|
this.logger.warn('Temporal client not initialized - some features may be unavailable');
|
|
31
31
|
}
|
|
32
|
+
else {
|
|
33
|
+
this.logger.log('Temporal client initialized successfully');
|
|
34
|
+
}
|
|
32
35
|
}
|
|
33
36
|
getWorkflowClient() {
|
|
34
37
|
return this.workflowClient;
|
|
@@ -40,12 +43,13 @@ let TemporalClientService = exports.TemporalClientService = TemporalClientServic
|
|
|
40
43
|
}
|
|
41
44
|
async startWorkflow(workflowType, args, options) {
|
|
42
45
|
this.ensureClientInitialized();
|
|
43
|
-
const { taskQueue, workflowId = `${workflowType}-${Date.now()}-${Math.random().toString(36).slice(2)}`, } = options;
|
|
46
|
+
const { taskQueue, workflowId = `${workflowType}-${Date.now()}-${Math.random().toString(36).slice(2)}`, ...restOptions } = options;
|
|
44
47
|
try {
|
|
45
48
|
const handle = await this.workflowClient.start(workflowType, {
|
|
46
49
|
args,
|
|
47
50
|
taskQueue,
|
|
48
51
|
workflowId,
|
|
52
|
+
...restOptions,
|
|
49
53
|
});
|
|
50
54
|
return {
|
|
51
55
|
result: handle.result(),
|
|
@@ -55,16 +59,18 @@ let TemporalClientService = exports.TemporalClientService = TemporalClientServic
|
|
|
55
59
|
};
|
|
56
60
|
}
|
|
57
61
|
catch (error) {
|
|
62
|
+
this.logger.error(`Failed to start workflow '${workflowType}': ${error.message}`);
|
|
58
63
|
throw new Error(`Failed to start workflow '${workflowType}': ${error.message}`);
|
|
59
64
|
}
|
|
60
65
|
}
|
|
61
|
-
async signalWorkflow(workflowId, signalName, args) {
|
|
66
|
+
async signalWorkflow(workflowId, signalName, args = []) {
|
|
62
67
|
this.ensureClientInitialized();
|
|
63
68
|
try {
|
|
64
69
|
const handle = await this.workflowClient.getHandle(workflowId);
|
|
65
70
|
await handle.signal(signalName, ...args);
|
|
66
71
|
}
|
|
67
72
|
catch (error) {
|
|
73
|
+
this.logger.error(`Failed to send signal '${signalName}' to workflow ${workflowId}: ${error.message}`);
|
|
68
74
|
throw new Error(`Failed to send signal '${signalName}' to workflow ${workflowId}: ${error.message}`);
|
|
69
75
|
}
|
|
70
76
|
}
|
|
@@ -75,19 +81,22 @@ let TemporalClientService = exports.TemporalClientService = TemporalClientServic
|
|
|
75
81
|
await handle.terminate(reason);
|
|
76
82
|
}
|
|
77
83
|
catch (error) {
|
|
84
|
+
this.logger.error(`Failed to terminate workflow ${workflowId}: ${error.message}`);
|
|
78
85
|
throw new Error(`Failed to terminate workflow ${workflowId}: ${error.message}`);
|
|
79
86
|
}
|
|
80
87
|
}
|
|
81
|
-
async getWorkflowHandle(workflowId) {
|
|
88
|
+
async getWorkflowHandle(workflowId, runId) {
|
|
82
89
|
this.ensureClientInitialized();
|
|
83
90
|
try {
|
|
84
|
-
return await this.workflowClient.getHandle(workflowId);
|
|
91
|
+
return await this.workflowClient.getHandle(workflowId, runId);
|
|
85
92
|
}
|
|
86
93
|
catch (error) {
|
|
94
|
+
this.logger.error(`Failed to get workflow handle for ${workflowId}: ${error.message}`);
|
|
87
95
|
throw new Error(`Failed to get workflow handle for ${workflowId}: ${error.message}`);
|
|
88
96
|
}
|
|
89
97
|
}
|
|
90
98
|
};
|
|
99
|
+
exports.TemporalClientService = TemporalClientService;
|
|
91
100
|
exports.TemporalClientService = TemporalClientService = TemporalClientService_1 = __decorate([
|
|
92
101
|
(0, common_1.Injectable)(),
|
|
93
102
|
__param(0, (0, common_1.Inject)(constants_1.TEMPORAL_CLIENT)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temporal-client.service.js","sourceRoot":"","sources":["../../src/client/temporal-client.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA0E;AAE1E,4CAA+C;
|
|
1
|
+
{"version":3,"file":"temporal-client.service.js","sourceRoot":"","sources":["../../src/client/temporal-client.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA0E;AAE1E,4CAA+C;AAIxC,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAI9B,YAEI,MAAsC;QAArB,WAAM,GAAN,MAAM,CAAe;QALzB,WAAM,GAAG,IAAI,eAAM,CAAC,uBAAqB,CAAC,IAAI,CAAC,CAAC;QACzD,mBAAc,GAA0B,IAAI,CAAC;QAMjD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,QA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kB,EAAE,KAAc;QACtD,IAAI,CAAC,uBAAuB,EAAE,CAAC;QAE/B,IAAI,CAAC;YACD,OAAO,MAAM,IAAI,CAAC,cAAe,CAAC,SAAS,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACnE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qCAAqC,UAAU,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACvF,MAAM,IAAI,KAAK,CAAC,qCAAqC,UAAU,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACzF,CAAC;IACL,CAAC;CACJ,CAAA;AArIY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAMJ,WAAA,IAAA,eAAM,EAAC,2BAAe,CAAC,CAAA;;GALnB,qBAAqB,CAqIjC"}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,9 +1,42 @@
|
|
|
1
1
|
export declare const TEMPORAL_MODULE_OPTIONS = "TEMPORAL_MODULE_OPTIONS";
|
|
2
2
|
export declare const TEMPORAL_CLIENT_MODULE_OPTIONS = "TEMPORAL_CLIENT_MODULE_OPTIONS";
|
|
3
3
|
export declare const TEMPORAL_WORKER_MODULE_OPTIONS = "TEMPORAL_WORKER_MODULE_OPTIONS";
|
|
4
|
+
export declare const TEMPORAL_CLIENT = "TEMPORAL_CLIENT";
|
|
5
|
+
export declare const TEMPORAL_CONNECTION = "TEMPORAL_CONNECTION";
|
|
4
6
|
export declare const TEMPORAL_ACTIVITY = "TEMPORAL_ACTIVITY";
|
|
5
7
|
export declare const TEMPORAL_ACTIVITY_METHOD = "TEMPORAL_ACTIVITY_METHOD";
|
|
6
8
|
export declare const TEMPORAL_ACTIVITY_METHOD_NAME = "TEMPORAL_ACTIVITY_METHOD_NAME";
|
|
9
|
+
export declare const TEMPORAL_ACTIVITY_METHOD_OPTIONS = "TEMPORAL_ACTIVITY_METHOD_OPTIONS";
|
|
10
|
+
export declare const TEMPORAL_ACTIVITY_OPTIONS = "TEMPORAL_ACTIVITY_OPTIONS";
|
|
7
11
|
export declare const TEMPORAL_WORKFLOW = "TEMPORAL_WORKFLOW";
|
|
8
12
|
export declare const TEMPORAL_WORKFLOW_METHOD = "TEMPORAL_WORKFLOW_METHOD";
|
|
9
|
-
export declare const
|
|
13
|
+
export declare const TEMPORAL_WORKFLOW_METHOD_NAME = "TEMPORAL_WORKFLOW_METHOD_NAME";
|
|
14
|
+
export declare const TEMPORAL_WORKFLOW_OPTIONS = "TEMPORAL_WORKFLOW_OPTIONS";
|
|
15
|
+
export declare const TEMPORAL_SIGNAL_METHOD = "TEMPORAL_SIGNAL_METHOD";
|
|
16
|
+
export declare const TEMPORAL_SIGNAL_NAME = "TEMPORAL_SIGNAL_NAME";
|
|
17
|
+
export declare const TEMPORAL_QUERY_METHOD = "TEMPORAL_QUERY_METHOD";
|
|
18
|
+
export declare const TEMPORAL_QUERY_NAME = "TEMPORAL_QUERY_NAME";
|
|
19
|
+
export declare const DEFAULT_NAMESPACE = "default";
|
|
20
|
+
export declare const DEFAULT_TASK_QUEUE = "default-task-queue";
|
|
21
|
+
export declare const DEFAULT_ACTIVITY_RETRY_ATTEMPTS = 3;
|
|
22
|
+
export declare const DEFAULT_CONNECTION_TIMEOUT_MS = 5000;
|
|
23
|
+
export declare const DEFAULT_WORKFLOW_ID_REUSE_POLICY = "WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE";
|
|
24
|
+
export declare const DEFAULT_WORKFLOW_ID_CONFLICT_POLICY = "WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE";
|
|
25
|
+
export declare const DEFAULT_WORKER_SHUTDOWN_GRACE_PERIOD_MS = 5000;
|
|
26
|
+
export declare const DEFAULT_MAX_CONCURRENT_ACTIVITIES = 100;
|
|
27
|
+
export declare const DEFAULT_MAX_CONCURRENT_WORKFLOW_TASKS = 100;
|
|
28
|
+
export declare const DEFAULT_WORKER_MONITORING_INTERVAL_MS = 60000;
|
|
29
|
+
export declare const ERRORS: {
|
|
30
|
+
CLIENT_INITIALIZATION: string;
|
|
31
|
+
WORKER_INITIALIZATION: string;
|
|
32
|
+
CLIENT_NOT_INITIALIZED: string;
|
|
33
|
+
WORKER_NOT_INITIALIZED: string;
|
|
34
|
+
INVALID_OPTIONS: string;
|
|
35
|
+
MISSING_TASK_QUEUE: string;
|
|
36
|
+
MISSING_WORKFLOW_TYPE: string;
|
|
37
|
+
MISSING_ACTIVITY_TYPE: string;
|
|
38
|
+
ACTIVITY_NOT_FOUND: string;
|
|
39
|
+
WORKFLOW_NOT_FOUND: string;
|
|
40
|
+
INVALID_DECORATOR_USAGE: string;
|
|
41
|
+
SCHEDULE_CLIENT_NOT_INITIALIZED: string;
|
|
42
|
+
};
|
package/dist/constants.js
CHANGED
|
@@ -1,13 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ERRORS = exports.DEFAULT_WORKER_MONITORING_INTERVAL_MS = exports.DEFAULT_MAX_CONCURRENT_WORKFLOW_TASKS = exports.DEFAULT_MAX_CONCURRENT_ACTIVITIES = exports.DEFAULT_WORKER_SHUTDOWN_GRACE_PERIOD_MS = exports.DEFAULT_WORKFLOW_ID_CONFLICT_POLICY = exports.DEFAULT_WORKFLOW_ID_REUSE_POLICY = exports.DEFAULT_CONNECTION_TIMEOUT_MS = exports.DEFAULT_ACTIVITY_RETRY_ATTEMPTS = exports.DEFAULT_TASK_QUEUE = exports.DEFAULT_NAMESPACE = exports.TEMPORAL_QUERY_NAME = exports.TEMPORAL_QUERY_METHOD = exports.TEMPORAL_SIGNAL_NAME = exports.TEMPORAL_SIGNAL_METHOD = exports.TEMPORAL_WORKFLOW_OPTIONS = exports.TEMPORAL_WORKFLOW_METHOD_NAME = exports.TEMPORAL_WORKFLOW_METHOD = exports.TEMPORAL_WORKFLOW = exports.TEMPORAL_ACTIVITY_OPTIONS = exports.TEMPORAL_ACTIVITY_METHOD_OPTIONS = exports.TEMPORAL_ACTIVITY_METHOD_NAME = exports.TEMPORAL_ACTIVITY_METHOD = exports.TEMPORAL_ACTIVITY = exports.TEMPORAL_CONNECTION = exports.TEMPORAL_CLIENT = exports.TEMPORAL_WORKER_MODULE_OPTIONS = exports.TEMPORAL_CLIENT_MODULE_OPTIONS = exports.TEMPORAL_MODULE_OPTIONS = void 0;
|
|
4
4
|
exports.TEMPORAL_MODULE_OPTIONS = 'TEMPORAL_MODULE_OPTIONS';
|
|
5
5
|
exports.TEMPORAL_CLIENT_MODULE_OPTIONS = 'TEMPORAL_CLIENT_MODULE_OPTIONS';
|
|
6
6
|
exports.TEMPORAL_WORKER_MODULE_OPTIONS = 'TEMPORAL_WORKER_MODULE_OPTIONS';
|
|
7
|
+
exports.TEMPORAL_CLIENT = 'TEMPORAL_CLIENT';
|
|
8
|
+
exports.TEMPORAL_CONNECTION = 'TEMPORAL_CONNECTION';
|
|
7
9
|
exports.TEMPORAL_ACTIVITY = 'TEMPORAL_ACTIVITY';
|
|
8
10
|
exports.TEMPORAL_ACTIVITY_METHOD = 'TEMPORAL_ACTIVITY_METHOD';
|
|
9
11
|
exports.TEMPORAL_ACTIVITY_METHOD_NAME = 'TEMPORAL_ACTIVITY_METHOD_NAME';
|
|
12
|
+
exports.TEMPORAL_ACTIVITY_METHOD_OPTIONS = 'TEMPORAL_ACTIVITY_METHOD_OPTIONS';
|
|
13
|
+
exports.TEMPORAL_ACTIVITY_OPTIONS = 'TEMPORAL_ACTIVITY_OPTIONS';
|
|
10
14
|
exports.TEMPORAL_WORKFLOW = 'TEMPORAL_WORKFLOW';
|
|
11
15
|
exports.TEMPORAL_WORKFLOW_METHOD = 'TEMPORAL_WORKFLOW_METHOD';
|
|
12
|
-
exports.
|
|
16
|
+
exports.TEMPORAL_WORKFLOW_METHOD_NAME = 'TEMPORAL_WORKFLOW_METHOD_NAME';
|
|
17
|
+
exports.TEMPORAL_WORKFLOW_OPTIONS = 'TEMPORAL_WORKFLOW_OPTIONS';
|
|
18
|
+
exports.TEMPORAL_SIGNAL_METHOD = 'TEMPORAL_SIGNAL_METHOD';
|
|
19
|
+
exports.TEMPORAL_SIGNAL_NAME = 'TEMPORAL_SIGNAL_NAME';
|
|
20
|
+
exports.TEMPORAL_QUERY_METHOD = 'TEMPORAL_QUERY_METHOD';
|
|
21
|
+
exports.TEMPORAL_QUERY_NAME = 'TEMPORAL_QUERY_NAME';
|
|
22
|
+
exports.DEFAULT_NAMESPACE = 'default';
|
|
23
|
+
exports.DEFAULT_TASK_QUEUE = 'default-task-queue';
|
|
24
|
+
exports.DEFAULT_ACTIVITY_RETRY_ATTEMPTS = 3;
|
|
25
|
+
exports.DEFAULT_CONNECTION_TIMEOUT_MS = 5000;
|
|
26
|
+
exports.DEFAULT_WORKFLOW_ID_REUSE_POLICY = 'WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE';
|
|
27
|
+
exports.DEFAULT_WORKFLOW_ID_CONFLICT_POLICY = 'WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE';
|
|
28
|
+
exports.DEFAULT_WORKER_SHUTDOWN_GRACE_PERIOD_MS = 5000;
|
|
29
|
+
exports.DEFAULT_MAX_CONCURRENT_ACTIVITIES = 100;
|
|
30
|
+
exports.DEFAULT_MAX_CONCURRENT_WORKFLOW_TASKS = 100;
|
|
31
|
+
exports.DEFAULT_WORKER_MONITORING_INTERVAL_MS = 60000;
|
|
32
|
+
exports.ERRORS = {
|
|
33
|
+
CLIENT_INITIALIZATION: 'Failed to initialize Temporal client',
|
|
34
|
+
WORKER_INITIALIZATION: 'Failed to initialize Temporal worker',
|
|
35
|
+
CLIENT_NOT_INITIALIZED: 'Temporal client not initialized',
|
|
36
|
+
WORKER_NOT_INITIALIZED: 'Temporal worker not initialized',
|
|
37
|
+
INVALID_OPTIONS: 'Invalid Temporal module options',
|
|
38
|
+
MISSING_TASK_QUEUE: 'Task queue is required',
|
|
39
|
+
MISSING_WORKFLOW_TYPE: 'Workflow type is required',
|
|
40
|
+
MISSING_ACTIVITY_TYPE: 'Activity type is required',
|
|
41
|
+
ACTIVITY_NOT_FOUND: 'Activity not found',
|
|
42
|
+
WORKFLOW_NOT_FOUND: 'Workflow not found',
|
|
43
|
+
INVALID_DECORATOR_USAGE: 'Invalid decorator usage',
|
|
44
|
+
SCHEDULE_CLIENT_NOT_INITIALIZED: 'Temporal schedule client not initialized',
|
|
45
|
+
};
|
|
13
46
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAUa,QAAA,uBAAuB,GAAG,yBAAyB,CAAC;AACpD,QAAA,8BAA8B,GAAG,gCAAgC,CAAC;AAClE,QAAA,8BAA8B,GAAG,gCAAgC,CAAC;AAClE,QAAA,eAAe,GAAG,iBAAiB,CAAC;AACpC,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAK5C,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AACxC,QAAA,wBAAwB,GAAG,0BAA0B,CAAC;AACtD,QAAA,6BAA6B,GAAG,+BAA+B,CAAC;AAChE,QAAA,gCAAgC,GAAG,kCAAkC,CAAC;AACtE,QAAA,yBAAyB,GAAG,2BAA2B,CAAC;AAKxD,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AACxC,QAAA,wBAAwB,GAAG,0BAA0B,CAAC;AACtD,QAAA,6BAA6B,GAAG,+BAA+B,CAAC;AAChE,QAAA,yBAAyB,GAAG,2BAA2B,CAAC;AAKxD,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAClD,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAK9C,QAAA,qBAAqB,GAAG,uBAAuB,CAAC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