nestjs-temporal-core 2.0.8 → 3.0.1
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 +114 -563
- package/dist/client/temporal-client.module.d.ts +4 -2
- package/dist/client/temporal-client.module.js +59 -78
- package/dist/client/temporal-client.module.js.map +1 -1
- package/dist/client/temporal-client.service.d.ts +4 -3
- package/dist/client/temporal-client.service.js +43 -27
- package/dist/client/temporal-client.service.js.map +1 -1
- package/dist/client/temporal-schedule.service.d.ts +8 -2
- package/dist/client/temporal-schedule.service.js +86 -65
- package/dist/client/temporal-schedule.service.js.map +1 -1
- package/dist/constants.d.ts +171 -32
- package/dist/constants.js +164 -19
- package/dist/constants.js.map +1 -1
- package/dist/decorators/communication.decorators.d.ts +5 -0
- package/dist/decorators/communication.decorators.js +66 -0
- package/dist/decorators/communication.decorators.js.map +1 -0
- package/dist/decorators/core.decorators.d.ts +6 -0
- package/dist/decorators/core.decorators.js +87 -0
- package/dist/decorators/core.decorators.js.map +1 -0
- package/dist/decorators/index.d.ts +5 -6
- package/dist/decorators/index.js +5 -6
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/parameter.decorators.d.ts +2 -0
- package/dist/decorators/parameter.decorators.js +29 -0
- package/dist/decorators/parameter.decorators.js.map +1 -0
- package/dist/decorators/scheduling.decorators.d.ts +4 -0
- package/dist/decorators/scheduling.decorators.js +37 -0
- package/dist/decorators/scheduling.decorators.js.map +1 -0
- package/dist/decorators/workflow-starter.decorator.d.ts +2 -0
- package/dist/decorators/workflow-starter.decorator.js +14 -0
- package/dist/decorators/workflow-starter.decorator.js.map +1 -0
- package/dist/discovery/index.d.ts +2 -0
- package/dist/discovery/index.js +19 -0
- package/dist/discovery/index.js.map +1 -0
- package/dist/discovery/schedule-manager.service.d.ts +36 -0
- package/dist/discovery/schedule-manager.service.js +215 -0
- package/dist/discovery/schedule-manager.service.js.map +1 -0
- package/dist/discovery/workflow-discovery.service.d.ts +36 -0
- package/dist/discovery/workflow-discovery.service.js +216 -0
- package/dist/discovery/workflow-discovery.service.js.map +1 -0
- package/dist/index.d.ts +15 -8
- package/dist/index.js +27 -11
- package/dist/index.js.map +1 -1
- package/dist/interfaces/core.interface.d.ts +112 -0
- package/dist/interfaces/{base.interface.js → core.interface.js} +1 -1
- package/dist/interfaces/core.interface.js.map +1 -0
- package/dist/interfaces/discovery.interface.d.ts +61 -0
- package/dist/interfaces/{client.interface.js → discovery.interface.js} +1 -1
- package/dist/interfaces/discovery.interface.js.map +1 -0
- package/dist/interfaces/index.d.ts +4 -4
- package/dist/interfaces/index.js +4 -4
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/scheduling.interface.d.ts +17 -0
- package/dist/interfaces/{temporal.interface.js → scheduling.interface.js} +1 -1
- package/dist/interfaces/scheduling.interface.js.map +1 -0
- package/dist/interfaces/worker.interface.d.ts +20 -17
- package/dist/interfaces/workflow.interface.d.ts +41 -1
- package/dist/temporal.module.d.ts +17 -1
- package/dist/temporal.module.js +120 -53
- package/dist/temporal.module.js.map +1 -1
- package/dist/temporal.service.d.ts +50 -8
- package/dist/temporal.service.js +166 -18
- package/dist/temporal.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/worker/index.d.ts +1 -1
- package/dist/worker/index.js +1 -1
- package/dist/worker/index.js.map +1 -1
- package/dist/worker/temporal-metadata.accessor.d.ts +21 -6
- package/dist/worker/temporal-metadata.accessor.js +153 -22
- package/dist/worker/temporal-metadata.accessor.js.map +1 -1
- package/dist/worker/temporal-worker.module.d.ts +1 -1
- package/dist/worker/temporal-worker.module.js +6 -7
- package/dist/worker/temporal-worker.module.js.map +1 -1
- package/dist/worker/worker-manager.service.d.ts +24 -7
- package/dist/worker/worker-manager.service.js +218 -85
- package/dist/worker/worker-manager.service.js.map +1 -1
- package/package.json +50 -18
- package/dist/decorators/activity-method.decorator.d.ts +0 -2
- package/dist/decorators/activity-method.decorator.js +0 -35
- package/dist/decorators/activity-method.decorator.js.map +0 -1
- package/dist/decorators/activity.decorator.d.ts +0 -2
- package/dist/decorators/activity.decorator.js +0 -14
- package/dist/decorators/activity.decorator.js.map +0 -1
- package/dist/decorators/query-method.decorator.d.ts +0 -1
- package/dist/decorators/query-method.decorator.js +0 -17
- package/dist/decorators/query-method.decorator.js.map +0 -1
- package/dist/decorators/signal-method.decorator.d.ts +0 -1
- package/dist/decorators/signal-method.decorator.js +0 -17
- package/dist/decorators/signal-method.decorator.js.map +0 -1
- package/dist/decorators/workflow-method.decorator.d.ts +0 -2
- package/dist/decorators/workflow-method.decorator.js +0 -26
- package/dist/decorators/workflow-method.decorator.js.map +0 -1
- package/dist/decorators/workflow.decorator.d.ts +0 -2
- package/dist/decorators/workflow.decorator.js +0 -16
- package/dist/decorators/workflow.decorator.js.map +0 -1
- package/dist/interfaces/base.interface.d.ts +0 -13
- package/dist/interfaces/base.interface.js.map +0 -1
- package/dist/interfaces/client.interface.d.ts +0 -30
- package/dist/interfaces/client.interface.js.map +0 -1
- package/dist/interfaces/temporal.interface.d.ts +0 -33
- package/dist/interfaces/temporal.interface.js.map +0 -1
|
@@ -2,9 +2,11 @@ import { DynamicModule } from '@nestjs/common';
|
|
|
2
2
|
import { TemporalClientOptions, TemporalClientAsyncOptions } from '../interfaces';
|
|
3
3
|
export declare class TemporalClientModule {
|
|
4
4
|
private static readonly logger;
|
|
5
|
-
private static createClient;
|
|
6
5
|
static register(options: TemporalClientOptions): DynamicModule;
|
|
7
6
|
static registerAsync(options: TemporalClientAsyncOptions): DynamicModule;
|
|
7
|
+
private static createClientProvider;
|
|
8
|
+
private static createAsyncClientProvider;
|
|
8
9
|
private static createAsyncProviders;
|
|
9
|
-
private static
|
|
10
|
+
private static createClientInstance;
|
|
11
|
+
private static enhanceClientWithShutdown;
|
|
10
12
|
}
|
|
@@ -14,57 +14,7 @@ const constants_1 = require("../constants");
|
|
|
14
14
|
const temporal_client_service_1 = require("./temporal-client.service");
|
|
15
15
|
const temporal_schedule_service_1 = require("./temporal-schedule.service");
|
|
16
16
|
let TemporalClientModule = TemporalClientModule_1 = class TemporalClientModule {
|
|
17
|
-
static async createClient(options) {
|
|
18
|
-
let connection = null;
|
|
19
|
-
try {
|
|
20
|
-
this.logger.log(`Connecting to Temporal server at ${options.connection.address}`);
|
|
21
|
-
connection = await client_1.Connection.connect({
|
|
22
|
-
address: options.connection.address,
|
|
23
|
-
tls: options.connection.tls,
|
|
24
|
-
metadata: options.connection.metadata,
|
|
25
|
-
...(options.connection.apiKey && {
|
|
26
|
-
metadata: {
|
|
27
|
-
...options.connection.metadata,
|
|
28
|
-
authorization: `Bearer ${options.connection.apiKey}`,
|
|
29
|
-
},
|
|
30
|
-
}),
|
|
31
|
-
});
|
|
32
|
-
const namespace = options.namespace || constants_1.DEFAULT_NAMESPACE;
|
|
33
|
-
this.logger.log(`Connected to Temporal server, using namespace "${namespace}"`);
|
|
34
|
-
return new client_1.Client({
|
|
35
|
-
connection,
|
|
36
|
-
namespace,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
if (connection) {
|
|
41
|
-
await connection.close().catch((closeError) => {
|
|
42
|
-
this.logger.error('Failed to close Temporal connection during error handling', closeError);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
const errorMsg = `${constants_1.ERRORS.CLIENT_INITIALIZATION}: ${error.message}`;
|
|
46
|
-
this.logger.error(errorMsg, error.stack);
|
|
47
|
-
throw new Error(errorMsg);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
17
|
static register(options) {
|
|
51
|
-
const clientProvider = {
|
|
52
|
-
provide: constants_1.TEMPORAL_CLIENT,
|
|
53
|
-
useFactory: async () => {
|
|
54
|
-
try {
|
|
55
|
-
const client = await this.createClient(options);
|
|
56
|
-
return this.addShutdownHook(client);
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
this.logger.error('Failed to initialize Temporal client', error);
|
|
60
|
-
if (options.allowConnectionFailure !== false) {
|
|
61
|
-
this.logger.warn('Continuing application startup without Temporal client');
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
throw error;
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
18
|
return {
|
|
69
19
|
module: TemporalClientModule_1,
|
|
70
20
|
providers: [
|
|
@@ -72,7 +22,7 @@ let TemporalClientModule = TemporalClientModule_1 = class TemporalClientModule {
|
|
|
72
22
|
provide: constants_1.TEMPORAL_CLIENT_MODULE_OPTIONS,
|
|
73
23
|
useValue: options,
|
|
74
24
|
},
|
|
75
|
-
|
|
25
|
+
this.createClientProvider(options),
|
|
76
26
|
temporal_client_service_1.TemporalClientService,
|
|
77
27
|
temporal_schedule_service_1.TemporalScheduleService,
|
|
78
28
|
],
|
|
@@ -80,36 +30,31 @@ let TemporalClientModule = TemporalClientModule_1 = class TemporalClientModule {
|
|
|
80
30
|
};
|
|
81
31
|
}
|
|
82
32
|
static registerAsync(options) {
|
|
83
|
-
const clientProvider = {
|
|
84
|
-
provide: constants_1.TEMPORAL_CLIENT,
|
|
85
|
-
useFactory: async (clientOptions) => {
|
|
86
|
-
try {
|
|
87
|
-
const client = await this.createClient(clientOptions);
|
|
88
|
-
return this.addShutdownHook(client);
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
this.logger.error('Failed to initialize Temporal client', error);
|
|
92
|
-
if (clientOptions.allowConnectionFailure !== false) {
|
|
93
|
-
this.logger.warn('Continuing application startup without Temporal client');
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
throw error;
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
inject: [constants_1.TEMPORAL_CLIENT_MODULE_OPTIONS],
|
|
100
|
-
};
|
|
101
33
|
return {
|
|
102
34
|
module: TemporalClientModule_1,
|
|
103
35
|
imports: options.imports || [],
|
|
104
36
|
providers: [
|
|
105
37
|
...this.createAsyncProviders(options),
|
|
106
|
-
|
|
38
|
+
this.createAsyncClientProvider(),
|
|
107
39
|
temporal_client_service_1.TemporalClientService,
|
|
108
40
|
temporal_schedule_service_1.TemporalScheduleService,
|
|
109
41
|
],
|
|
110
42
|
exports: [temporal_client_service_1.TemporalClientService, temporal_schedule_service_1.TemporalScheduleService],
|
|
111
43
|
};
|
|
112
44
|
}
|
|
45
|
+
static createClientProvider(options) {
|
|
46
|
+
return {
|
|
47
|
+
provide: constants_1.TEMPORAL_CLIENT,
|
|
48
|
+
useFactory: async () => this.createClientInstance(options),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
static createAsyncClientProvider() {
|
|
52
|
+
return {
|
|
53
|
+
provide: constants_1.TEMPORAL_CLIENT,
|
|
54
|
+
useFactory: async (clientOptions) => this.createClientInstance(clientOptions),
|
|
55
|
+
inject: [constants_1.TEMPORAL_CLIENT_MODULE_OPTIONS],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
113
58
|
static createAsyncProviders(options) {
|
|
114
59
|
if (options.useFactory) {
|
|
115
60
|
return [
|
|
@@ -124,7 +69,7 @@ let TemporalClientModule = TemporalClientModule_1 = class TemporalClientModule {
|
|
|
124
69
|
return [
|
|
125
70
|
{
|
|
126
71
|
provide: constants_1.TEMPORAL_CLIENT_MODULE_OPTIONS,
|
|
127
|
-
useFactory: async (optionsFactory) =>
|
|
72
|
+
useFactory: async (optionsFactory) => optionsFactory.createClientOptions(),
|
|
128
73
|
inject: [options.useClass],
|
|
129
74
|
},
|
|
130
75
|
{
|
|
@@ -137,25 +82,61 @@ let TemporalClientModule = TemporalClientModule_1 = class TemporalClientModule {
|
|
|
137
82
|
return [
|
|
138
83
|
{
|
|
139
84
|
provide: constants_1.TEMPORAL_CLIENT_MODULE_OPTIONS,
|
|
140
|
-
useFactory: async (optionsFactory) =>
|
|
85
|
+
useFactory: async (optionsFactory) => optionsFactory.createClientOptions(),
|
|
141
86
|
inject: [options.useExisting],
|
|
142
87
|
},
|
|
143
88
|
];
|
|
144
89
|
}
|
|
145
90
|
throw new Error(constants_1.ERRORS.INVALID_OPTIONS);
|
|
146
91
|
}
|
|
147
|
-
static
|
|
92
|
+
static async createClientInstance(options) {
|
|
93
|
+
let connection = null;
|
|
94
|
+
try {
|
|
95
|
+
this.logger.log(`Connecting to Temporal server at ${options.connection.address}`);
|
|
96
|
+
const connectionConfig = {
|
|
97
|
+
address: options.connection.address,
|
|
98
|
+
tls: options.connection.tls,
|
|
99
|
+
metadata: options.connection.metadata,
|
|
100
|
+
};
|
|
101
|
+
if (options.connection.apiKey) {
|
|
102
|
+
connectionConfig.metadata = {
|
|
103
|
+
...connectionConfig.metadata,
|
|
104
|
+
authorization: `Bearer ${options.connection.apiKey}`,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
connection = await client_1.Connection.connect(connectionConfig);
|
|
108
|
+
const namespace = options.namespace || constants_1.DEFAULT_NAMESPACE;
|
|
109
|
+
this.logger.log(`Connected to Temporal server, using namespace "${namespace}"`);
|
|
110
|
+
const client = new client_1.Client({ connection, namespace });
|
|
111
|
+
return this.enhanceClientWithShutdown(client);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (connection) {
|
|
115
|
+
await connection.close().catch((closeError) => {
|
|
116
|
+
this.logger.error('Failed to close connection during error cleanup', closeError);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
const errorMsg = `${constants_1.ERRORS.CLIENT_INITIALIZATION}: ${error.message}`;
|
|
120
|
+
this.logger.error(errorMsg, error.stack);
|
|
121
|
+
if (options.allowConnectionFailure !== false) {
|
|
122
|
+
this.logger.warn('Continuing application startup without Temporal client');
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
throw new Error(errorMsg);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
static enhanceClientWithShutdown(client) {
|
|
148
129
|
const enhancedClient = client;
|
|
149
130
|
enhancedClient.onApplicationShutdown = async (signal) => {
|
|
150
131
|
this.logger.log(`Closing Temporal client connection (signal: ${signal})`);
|
|
151
|
-
|
|
152
|
-
|
|
132
|
+
try {
|
|
133
|
+
if (client?.connection) {
|
|
153
134
|
await client.connection.close();
|
|
154
135
|
this.logger.log('Temporal connection closed successfully');
|
|
155
136
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
this.logger.error('Failed to close Temporal connection', error);
|
|
159
140
|
}
|
|
160
141
|
};
|
|
161
142
|
return enhancedClient;
|
|
@@ -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,4CAKsB;AACtB,uEAAkE;AAClE,2EAAsE;AAQ/D,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;
|
|
1
|
+
{"version":3,"file":"temporal-client.module.js","sourceRoot":"","sources":["../../src/client/temporal-client.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAOwB;AACxB,+CAAwD;AAMxD,4CAKsB;AACtB,uEAAkE;AAClE,2EAAsE;AAQ/D,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAM7B,MAAM,CAAC,QAAQ,CAAC,OAA8B;QAC1C,OAAO;YACH,MAAM,EAAE,sBAAoB;YAC5B,SAAS,EAAE;gBACP;oBACI,OAAO,EAAE,0CAA8B;oBACvC,QAAQ,EAAE,OAAO;iBACpB;gBACD,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC;gBAClC,+CAAqB;gBACrB,mDAAuB;aAC1B;YACD,OAAO,EAAE,CAAC,+CAAqB,EAAE,mDAAuB,CAAC;SAC5D,CAAC;IACN,CAAC;IAKD,MAAM,CAAC,aAAa,CAAC,OAAmC;QACpD,OAAO;YACH,MAAM,EAAE,sBAAoB;YAC5B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;YAC9B,SAAS,EAAE;gBACP,GAAG,IAAI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AAC;IAC1B,CAAC;;AAtLQ,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,CAuLhC"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { OnModuleInit } from '@nestjs/common';
|
|
2
2
|
import { Client, WorkflowClient, WorkflowHandle } from '@temporalio/client';
|
|
3
|
-
import { StartWorkflowOptions } from '
|
|
3
|
+
import { StartWorkflowOptions } from 'src/interfaces';
|
|
4
4
|
export declare class TemporalClientService implements OnModuleInit {
|
|
5
5
|
private readonly client;
|
|
6
6
|
private readonly logger;
|
|
7
|
-
private workflowClient;
|
|
7
|
+
private readonly workflowClient;
|
|
8
8
|
constructor(client: Client | null);
|
|
9
9
|
onModuleInit(): Promise<void>;
|
|
10
10
|
getWorkflowClient(): WorkflowClient | null;
|
|
11
11
|
getRawClient(): Client | null;
|
|
12
|
-
private ensureClientInitialized;
|
|
13
12
|
startWorkflow<T, A extends any[]>(workflowType: string, args: A, options: StartWorkflowOptions): Promise<{
|
|
14
13
|
result: Promise<T>;
|
|
15
14
|
workflowId: string;
|
|
@@ -23,4 +22,6 @@ export declare class TemporalClientService implements OnModuleInit {
|
|
|
23
22
|
getWorkflowHandle(workflowId: string, runId?: string): Promise<WorkflowHandle>;
|
|
24
23
|
describeWorkflow(workflowId: string, runId?: string): Promise<import("@temporalio/client").WorkflowExecutionDescription>;
|
|
25
24
|
listWorkflows(query: string, pageSize?: number): import("@temporalio/client").AsyncWorkflowListIterable;
|
|
25
|
+
private ensureClientInitialized;
|
|
26
|
+
private generateWorkflowId;
|
|
26
27
|
}
|
|
@@ -20,10 +20,7 @@ let TemporalClientService = TemporalClientService_1 = class TemporalClientServic
|
|
|
20
20
|
constructor(client) {
|
|
21
21
|
this.client = client;
|
|
22
22
|
this.logger = new common_1.Logger(TemporalClientService_1.name);
|
|
23
|
-
this.workflowClient = null;
|
|
24
|
-
if (this.client) {
|
|
25
|
-
this.workflowClient = this.client.workflow;
|
|
26
|
-
}
|
|
23
|
+
this.workflowClient = this.client?.workflow || null;
|
|
27
24
|
}
|
|
28
25
|
async onModuleInit() {
|
|
29
26
|
if (!this.client) {
|
|
@@ -39,14 +36,9 @@ let TemporalClientService = TemporalClientService_1 = class TemporalClientServic
|
|
|
39
36
|
getRawClient() {
|
|
40
37
|
return this.client;
|
|
41
38
|
}
|
|
42
|
-
ensureClientInitialized() {
|
|
43
|
-
if (!this.workflowClient) {
|
|
44
|
-
throw new Error(constants_1.ERRORS.CLIENT_NOT_INITIALIZED);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
39
|
async startWorkflow(workflowType, args, options) {
|
|
48
40
|
this.ensureClientInitialized();
|
|
49
|
-
const { taskQueue, workflowId =
|
|
41
|
+
const { taskQueue, workflowId = this.generateWorkflowId(workflowType), signal, ...restOptions } = options;
|
|
50
42
|
try {
|
|
51
43
|
const startOptions = {
|
|
52
44
|
taskQueue,
|
|
@@ -60,6 +52,7 @@ let TemporalClientService = TemporalClientService_1 = class TemporalClientServic
|
|
|
60
52
|
if (signal) {
|
|
61
53
|
await handle.signal(signal.name, ...(signal.args || []));
|
|
62
54
|
}
|
|
55
|
+
this.logger.debug(`Started workflow: ${workflowType} (${workflowId})`);
|
|
63
56
|
return {
|
|
64
57
|
result: handle.result(),
|
|
65
58
|
workflowId: handle.workflowId,
|
|
@@ -68,8 +61,9 @@ let TemporalClientService = TemporalClientService_1 = class TemporalClientServic
|
|
|
68
61
|
};
|
|
69
62
|
}
|
|
70
63
|
catch (error) {
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
const errorMsg = `Failed to start workflow '${workflowType}': ${error.message}`;
|
|
65
|
+
this.logger.error(errorMsg);
|
|
66
|
+
throw new Error(errorMsg);
|
|
73
67
|
}
|
|
74
68
|
}
|
|
75
69
|
async signalWorkflow(workflowId, signalName, args = []) {
|
|
@@ -77,21 +71,26 @@ let TemporalClientService = TemporalClientService_1 = class TemporalClientServic
|
|
|
77
71
|
try {
|
|
78
72
|
const handle = await this.workflowClient.getHandle(workflowId);
|
|
79
73
|
await handle.signal(signalName, ...args);
|
|
74
|
+
this.logger.debug(`Sent signal '${signalName}' to workflow ${workflowId}`);
|
|
80
75
|
}
|
|
81
76
|
catch (error) {
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
const errorMsg = `Failed to send signal '${signalName}' to workflow ${workflowId}: ${error.message}`;
|
|
78
|
+
this.logger.error(errorMsg);
|
|
79
|
+
throw new Error(errorMsg);
|
|
84
80
|
}
|
|
85
81
|
}
|
|
86
82
|
async queryWorkflow(workflowId, queryName, args = []) {
|
|
87
83
|
this.ensureClientInitialized();
|
|
88
84
|
try {
|
|
89
85
|
const handle = await this.workflowClient.getHandle(workflowId);
|
|
90
|
-
|
|
86
|
+
const result = await handle.query(queryName, ...args);
|
|
87
|
+
this.logger.debug(`Queried '${queryName}' on workflow ${workflowId}`);
|
|
88
|
+
return result;
|
|
91
89
|
}
|
|
92
90
|
catch (error) {
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
const errorMsg = `Failed to query '${queryName}' on workflow ${workflowId}: ${error.message}`;
|
|
92
|
+
this.logger.error(errorMsg);
|
|
93
|
+
throw new Error(errorMsg);
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
async terminateWorkflow(workflowId, reason) {
|
|
@@ -99,10 +98,12 @@ let TemporalClientService = TemporalClientService_1 = class TemporalClientServic
|
|
|
99
98
|
try {
|
|
100
99
|
const handle = await this.workflowClient.getHandle(workflowId);
|
|
101
100
|
await handle.terminate(reason);
|
|
101
|
+
this.logger.log(`Terminated workflow ${workflowId}${reason ? `: ${reason}` : ''}`);
|
|
102
102
|
}
|
|
103
103
|
catch (error) {
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
const errorMsg = `Failed to terminate workflow ${workflowId}: ${error.message}`;
|
|
105
|
+
this.logger.error(errorMsg);
|
|
106
|
+
throw new Error(errorMsg);
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
async cancelWorkflow(workflowId) {
|
|
@@ -110,10 +111,12 @@ let TemporalClientService = TemporalClientService_1 = class TemporalClientServic
|
|
|
110
111
|
try {
|
|
111
112
|
const handle = await this.workflowClient.getHandle(workflowId);
|
|
112
113
|
await handle.cancel();
|
|
114
|
+
this.logger.log(`Cancelled workflow ${workflowId}`);
|
|
113
115
|
}
|
|
114
116
|
catch (error) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
const errorMsg = `Failed to cancel workflow ${workflowId}: ${error.message}`;
|
|
118
|
+
this.logger.error(errorMsg);
|
|
119
|
+
throw new Error(errorMsg);
|
|
117
120
|
}
|
|
118
121
|
}
|
|
119
122
|
async getWorkflowHandle(workflowId, runId) {
|
|
@@ -122,8 +125,9 @@ let TemporalClientService = TemporalClientService_1 = class TemporalClientServic
|
|
|
122
125
|
return await this.workflowClient.getHandle(workflowId, runId);
|
|
123
126
|
}
|
|
124
127
|
catch (error) {
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
const errorMsg = `Failed to get workflow handle for ${workflowId}: ${error.message}`;
|
|
129
|
+
this.logger.error(errorMsg);
|
|
130
|
+
throw new Error(errorMsg);
|
|
127
131
|
}
|
|
128
132
|
}
|
|
129
133
|
async describeWorkflow(workflowId, runId) {
|
|
@@ -133,8 +137,9 @@ let TemporalClientService = TemporalClientService_1 = class TemporalClientServic
|
|
|
133
137
|
return await handle.describe();
|
|
134
138
|
}
|
|
135
139
|
catch (error) {
|
|
136
|
-
|
|
137
|
-
|
|
140
|
+
const errorMsg = `Failed to describe workflow ${workflowId}: ${error.message}`;
|
|
141
|
+
this.logger.error(errorMsg);
|
|
142
|
+
throw new Error(errorMsg);
|
|
138
143
|
}
|
|
139
144
|
}
|
|
140
145
|
listWorkflows(query, pageSize = 100) {
|
|
@@ -143,10 +148,21 @@ let TemporalClientService = TemporalClientService_1 = class TemporalClientServic
|
|
|
143
148
|
return this.workflowClient.list({ query, pageSize });
|
|
144
149
|
}
|
|
145
150
|
catch (error) {
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
const errorMsg = `Failed to list workflows with query '${query}': ${error.message}`;
|
|
152
|
+
this.logger.error(errorMsg);
|
|
153
|
+
throw new Error(errorMsg);
|
|
148
154
|
}
|
|
149
155
|
}
|
|
156
|
+
ensureClientInitialized() {
|
|
157
|
+
if (!this.workflowClient) {
|
|
158
|
+
throw new Error(constants_1.ERRORS.CLIENT_NOT_INITIALIZED);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
generateWorkflowId(workflowType) {
|
|
162
|
+
const timestamp = Date.now();
|
|
163
|
+
const random = Math.random().toString(36).slice(2);
|
|
164
|
+
return `${workflowType}-${timestamp}-${random}`;
|
|
165
|
+
}
|
|
150
166
|
};
|
|
151
167
|
exports.TemporalClientService = TemporalClientService;
|
|
152
168
|
exports.TemporalClientService = TemporalClientService = TemporalClientService_1 = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"temporal-client.service.js","sourceRoot":"","sources":["../../src/client/temporal-client.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA0E;AAE1E,4CAAuD;AAIhD,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAI9B,YAEI,MAAsC;QAArB,WAAM,GAAN,MAAM,CAAe;QALzB,WAAM,GAAG,IAAI,eAAM,CAAC,uBAAqB,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"temporal-client.service.js","sourceRoot":"","sources":["../../src/client/temporal-client.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAA0E;AAE1E,4CAAuD;AAIhD,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAI9B,YAEI,MAAsC;QAArB,WAAM,GAAN,MAAM,CAAe;QALzB,WAAM,GAAG,IAAI,eAAM,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estjs/common';
|
|
2
2
|
import { Client, ScheduleClient, ScheduleHandle, ScheduleOverlapPolicy } from '@temporalio/client';
|
|
3
|
+
import { StringValue } from 'ms';
|
|
3
4
|
export declare class TemporalScheduleService implements OnModuleInit {
|
|
4
5
|
private readonly client;
|
|
5
6
|
private readonly logger;
|
|
6
7
|
private scheduleClient;
|
|
7
8
|
constructor(client: Client | null);
|
|
8
9
|
onModuleInit(): Promise<void>;
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
createCronWorkflow(scheduleId: string, workflowType: string, cronExpression: string, taskQueue: string, args?: any[], description?: string, timezone?: string): Promise<ScheduleHandle>;
|
|
11
|
+
createIntervalWorkflow(scheduleId: string, workflowType: string, interval: StringValue | number, taskQueue: string, args?: any[], description?: string): Promise<ScheduleHandle>;
|
|
11
12
|
pauseSchedule(scheduleId: string, note?: string): Promise<void>;
|
|
12
13
|
resumeSchedule(scheduleId: string, note?: string): Promise<void>;
|
|
13
14
|
deleteSchedule(scheduleId: string): Promise<void>;
|
|
14
15
|
triggerNow(scheduleId: string, overlap?: ScheduleOverlapPolicy): Promise<void>;
|
|
15
16
|
listSchedules(pageSize?: number): Promise<any[]>;
|
|
17
|
+
describeSchedule(scheduleId: string): Promise<any>;
|
|
18
|
+
updateSchedule(scheduleId: string, updateFn: (schedule: any) => any): Promise<void>;
|
|
16
19
|
getScheduleClient(): ScheduleClient | null;
|
|
20
|
+
private executeScheduleOperation;
|
|
21
|
+
private ensureClientInitialized;
|
|
22
|
+
private generateScheduledWorkflowId;
|
|
17
23
|
}
|