@diia-inhouse/workflow 1.17.11 → 2.5.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/dist/activities/index.d.ts +1 -0
- package/dist/activities/index.js +2 -18
- package/dist/activities/proxy.d.ts +34 -0
- package/dist/activities/proxy.js +16 -24
- package/dist/activity.d.ts +2 -0
- package/dist/activity.js +2 -15
- package/dist/cli/checkWorkflowDeterminism.js +249 -275
- package/dist/cli/determinism/errorClassifier.js +56 -60
- package/dist/cli/determinism/historyFiles.js +68 -97
- package/dist/cli/determinism/index.js +7 -19
- package/dist/cli/determinism/replayExecutor.js +114 -133
- package/dist/cli/determinism/replayOptions.js +13 -22
- package/dist/cli/determinism/report.js +55 -45
- package/dist/cli/determinism/reportPrinter.js +101 -138
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +79 -119
- package/dist/cli/syncTemporalSchedules.js +74 -91
- package/dist/cli/updateTemporalSchedule.js +43 -53
- package/dist/client.d.ts +3 -0
- package/dist/client.js +3 -19
- package/dist/common.d.ts +2 -0
- package/dist/common.js +2 -13
- package/dist/encryption/crypto.d.ts +7 -0
- package/dist/encryption/crypto.js +20 -22
- package/dist/encryption/dataConverter.d.ts +7 -0
- package/dist/encryption/dataConverter.js +15 -22
- package/dist/encryption/encryptionCodec.d.ts +31 -0
- package/dist/encryption/encryptionCodec.js +108 -124
- package/dist/encryption/index.d.ts +3 -0
- package/dist/encryption/index.js +4 -20
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -42
- package/dist/instrumentation.js +6 -10
- package/dist/interceptors/asyncLocalStorageBridge.js +29 -66
- package/dist/interceptors/traceLogAttributes.d.ts +6 -0
- package/dist/interceptors/traceLogAttributes.js +16 -54
- package/dist/interceptors.d.ts +6 -0
- package/dist/interceptors.js +6 -8
- package/dist/interfaces/config.d.ts +58 -0
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/services/schedulesExporter.d.ts +96 -0
- package/dist/interfaces/services/worker.d.ts +60 -0
- package/dist/operations.d.ts +9 -0
- package/dist/operations.js +11 -75
- package/dist/services/client.d.ts +24 -0
- package/dist/services/client.js +89 -96
- package/dist/services/schedulesExporter.d.ts +101 -0
- package/dist/services/schedulesExporter.js +456 -0
- package/dist/services/worker/identity.d.ts +4 -0
- package/dist/services/worker/identity.js +6 -9
- package/dist/services/worker.d.ts +124 -0
- package/dist/services/worker.js +324 -304
- package/dist/services/workerHealth.d.ts +15 -0
- package/dist/services/workerHealth.js +26 -35
- package/dist/testing.d.ts +42 -0
- package/dist/testing.js +43 -54
- package/dist/worker.d.ts +9 -0
- package/dist/worker.js +7 -25
- package/package.json +40 -37
- package/dist/activities/index.js.map +0 -1
- package/dist/activities/proxy.js.map +0 -1
- package/dist/activity.js.map +0 -1
- package/dist/cli/checkWorkflowDeterminism.js.map +0 -1
- package/dist/cli/determinism/errorClassifier.js.map +0 -1
- package/dist/cli/determinism/historyFiles.js.map +0 -1
- package/dist/cli/determinism/index.js.map +0 -1
- package/dist/cli/determinism/replayExecutor.js.map +0 -1
- package/dist/cli/determinism/replayOptions.js.map +0 -1
- package/dist/cli/determinism/report.js.map +0 -1
- package/dist/cli/determinism/reportPrinter.js.map +0 -1
- package/dist/cli/determinism/types.js +0 -3
- package/dist/cli/determinism/types.js.map +0 -1
- package/dist/cli/index.js.map +0 -1
- package/dist/cli/syncTemporalSchedules.js.map +0 -1
- package/dist/cli/updateTemporalSchedule.js.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/common.js.map +0 -1
- package/dist/encryption/crypto.js.map +0 -1
- package/dist/encryption/dataConverter.js.map +0 -1
- package/dist/encryption/encryptionCodec.js.map +0 -1
- package/dist/encryption/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/instrumentation.js.map +0 -1
- package/dist/interceptors/asyncLocalStorageBridge.js.map +0 -1
- package/dist/interceptors/index.js +0 -8
- package/dist/interceptors/index.js.map +0 -1
- package/dist/interceptors/traceLogAttributes.js.map +0 -1
- package/dist/interceptors.js.map +0 -1
- package/dist/interfaces/config.js +0 -3
- package/dist/interfaces/config.js.map +0 -1
- package/dist/interfaces/index.js +0 -18
- package/dist/interfaces/index.js.map +0 -1
- package/dist/interfaces/services/worker.js +0 -3
- package/dist/interfaces/services/worker.js.map +0 -1
- package/dist/operations.js.map +0 -1
- package/dist/services/client.js.map +0 -1
- package/dist/services/index.js +0 -19
- package/dist/services/index.js.map +0 -1
- package/dist/services/worker/identity.js.map +0 -1
- package/dist/services/worker/index.js +0 -18
- package/dist/services/worker/index.js.map +0 -1
- package/dist/services/worker.js.map +0 -1
- package/dist/services/workerHealth.js.map +0 -1
- package/dist/testing.js.map +0 -1
- package/dist/types/activities/index.d.ts +0 -1
- package/dist/types/activities/proxy.d.ts +0 -35
- package/dist/types/activity.d.ts +0 -1
- package/dist/types/cli/checkWorkflowDeterminism.d.ts +0 -19
- package/dist/types/cli/determinism/errorClassifier.d.ts +0 -15
- package/dist/types/cli/determinism/historyFiles.d.ts +0 -18
- package/dist/types/cli/determinism/index.d.ts +0 -10
- package/dist/types/cli/determinism/replayExecutor.d.ts +0 -9
- package/dist/types/cli/determinism/replayOptions.d.ts +0 -7
- package/dist/types/cli/determinism/report.d.ts +0 -16
- package/dist/types/cli/determinism/reportPrinter.d.ts +0 -5
- package/dist/types/cli/determinism/types.d.ts +0 -44
- package/dist/types/cli/index.d.ts +0 -2
- package/dist/types/cli/syncTemporalSchedules.d.ts +0 -12
- package/dist/types/cli/updateTemporalSchedule.d.ts +0 -9
- package/dist/types/client.d.ts +0 -2
- package/dist/types/common.d.ts +0 -1
- package/dist/types/encryption/crypto.d.ts +0 -3
- package/dist/types/encryption/dataConverter.d.ts +0 -3
- package/dist/types/encryption/encryptionCodec.d.ts +0 -27
- package/dist/types/encryption/index.d.ts +0 -3
- package/dist/types/index.d.ts +0 -3
- package/dist/types/instrumentation.d.ts +0 -2
- package/dist/types/interceptors/asyncLocalStorageBridge.d.ts +0 -21
- package/dist/types/interceptors/index.d.ts +0 -2
- package/dist/types/interceptors/traceLogAttributes.d.ts +0 -2
- package/dist/types/interceptors.d.ts +0 -2
- package/dist/types/interfaces/config.d.ts +0 -38
- package/dist/types/interfaces/index.d.ts +0 -1
- package/dist/types/interfaces/services/worker.d.ts +0 -37
- package/dist/types/operations.d.ts +0 -5
- package/dist/types/services/client.d.ts +0 -20
- package/dist/types/services/index.d.ts +0 -2
- package/dist/types/services/worker/identity.d.ts +0 -1
- package/dist/types/services/worker/index.d.ts +0 -1
- package/dist/types/services/worker.d.ts +0 -113
- package/dist/types/services/workerHealth.d.ts +0 -11
- package/dist/types/testing.d.ts +0 -42
- package/dist/types/worker.d.ts +0 -3
- package/dist/worker.js.map +0 -1
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
-
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
3
|
-
import { Worker, WorkerOptions } from '@temporalio/worker';
|
|
4
|
-
import { EnvService } from '@diia-inhouse/env';
|
|
5
|
-
import { AlsData, Logger } from '@diia-inhouse/types';
|
|
6
|
-
import { AppConfig } from '../interfaces/config';
|
|
7
|
-
import type { ActivityClass, App, WorkerBootstrapOptions } from '../interfaces/services/worker';
|
|
8
|
-
export type { ActivityClass, App, State, WorkerBootstrapOptions } from '../interfaces/services/worker';
|
|
9
|
-
export type { WorkerHealthDetails } from './workerHealth';
|
|
10
|
-
export { buildWorkerIdentity } from './worker/identity';
|
|
11
|
-
export { WorkerHealthService } from './workerHealth';
|
|
12
|
-
/**
|
|
13
|
-
* Applies service process configuration overrides when the worker runs separately.
|
|
14
|
-
*
|
|
15
|
-
* When `temporal.workerInProcess` is `false`, disables `temporal` and `temporal-worker` scrapers
|
|
16
|
-
* so the main service does not scrape metrics that the worker process handles.
|
|
17
|
-
*
|
|
18
|
-
* Mutates the config object in place. Safe to call when scrapers are absent.
|
|
19
|
-
*/
|
|
20
|
-
export declare function applyServiceProcessConfig(config: AppConfig): void;
|
|
21
|
-
/**
|
|
22
|
-
* Applies worker process configuration overrides.
|
|
23
|
-
*
|
|
24
|
-
* - Disables queue consumers on all rabbit connections (unless `temporal.disableQueueConsumers` is `false`)
|
|
25
|
-
* - Overrides `metrics.custom.port` with the `'temporal-worker'` scraper port and disables that scraper to prevent self-scraping
|
|
26
|
-
*
|
|
27
|
-
* Mutates the config object in place. Safe to call when queue config is absent.
|
|
28
|
-
*/
|
|
29
|
-
export declare function applyWorkerProcessConfig(config: AppConfig): void;
|
|
30
|
-
export declare function instantiateActivities(app: App, workerActivities: Record<string, ActivityClass>): Record<string, (...args: unknown[]) => Promise<unknown>>;
|
|
31
|
-
/**
|
|
32
|
-
* Initializes and starts Temporal worker with full dependency injection support.
|
|
33
|
-
*
|
|
34
|
-
* This is the recommended way to initialize Temporal workers. It handles:
|
|
35
|
-
* - Automatic dependency injection for activities
|
|
36
|
-
* - AsyncLocalStorage setup for distributed tracing
|
|
37
|
-
* - OpenTelemetry integration
|
|
38
|
-
* - Activity instantiation and binding
|
|
39
|
-
*
|
|
40
|
-
* @param app - App instance for DI container and config access
|
|
41
|
-
* @param options - Worker configuration options
|
|
42
|
-
* @param options.nodeTracerProvider - OpenTelemetry tracer provider
|
|
43
|
-
* @param options.workflowsPath - Path to workflows module
|
|
44
|
-
* @param options.activities - Activity classes to instantiate
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```typescript
|
|
48
|
-
* // Define your activities
|
|
49
|
-
* const workerActivities = {
|
|
50
|
-
* userActivity: UserActivity,
|
|
51
|
-
* notificationActivity: NotificationActivity,
|
|
52
|
-
* }
|
|
53
|
-
*
|
|
54
|
-
* // Initialize and start the worker
|
|
55
|
-
* await initTemporalWorker(app, {
|
|
56
|
-
* nodeTracerProvider,
|
|
57
|
-
* workflowsPath: require.resolve('./worker/workflows'),
|
|
58
|
-
* activities: workerActivities,
|
|
59
|
-
* })
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
export declare function initTemporalWorker(app: App, options: {
|
|
63
|
-
nodeTracerProvider: NodeTracerProvider;
|
|
64
|
-
workflowsPath: string;
|
|
65
|
-
activities: Record<string, ActivityClass>;
|
|
66
|
-
} & Omit<WorkerOptions, 'taskQueue' | 'activities' | 'workflowsPath'>): Promise<void>;
|
|
67
|
-
/**
|
|
68
|
-
* Bootstraps and runs Temporal worker with graceful shutdown.
|
|
69
|
-
*
|
|
70
|
-
* Handles both in-process and separate-process worker topologies:
|
|
71
|
-
*
|
|
72
|
-
* - **In-process** (`workerInProcess` is `true` or unset): initializes and runs the worker.
|
|
73
|
-
* - **Separate process** (called from a dedicated worker entry with `configFactory`/`deps`):
|
|
74
|
-
* manages the full application lifecycle: setConfig → apply worker overrides → setDeps →
|
|
75
|
-
* initialize → start → run worker.
|
|
76
|
-
* - **Service-only** (`workerInProcess` is `false`, no `configFactory`): disables temporal
|
|
77
|
-
* scrapers on the main service (worker handles them separately) and returns immediately.
|
|
78
|
-
*
|
|
79
|
-
* Automatically integrates worker health with the app's centralized health check
|
|
80
|
-
* system via `HealthCheck.addHealthCheckable()`.
|
|
81
|
-
*
|
|
82
|
-
* @param app - App instance for DI container and config access
|
|
83
|
-
* @param options - Worker bootstrap options
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* ```typescript
|
|
87
|
-
* // Separate worker process with full lifecycle management
|
|
88
|
-
* const app = new Application(serviceName, nodeTracerProvider, loggerConfig)
|
|
89
|
-
*
|
|
90
|
-
* await bootstrapWorker(app, {
|
|
91
|
-
* configFactory,
|
|
92
|
-
* deps,
|
|
93
|
-
* workflowsPath: require.resolve('./worker/workflows'),
|
|
94
|
-
* activities: workerActivities,
|
|
95
|
-
* nodeTracerProvider,
|
|
96
|
-
* })
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
export declare function bootstrapWorker(app: App, options: WorkerBootstrapOptions): Promise<void>;
|
|
100
|
-
/**
|
|
101
|
-
* Initializes Temporal worker.
|
|
102
|
-
*
|
|
103
|
-
* @param config - Application configuration
|
|
104
|
-
* @param options - Worker options including workflows path
|
|
105
|
-
* @param envService - Environment service instance
|
|
106
|
-
* @param logger - Logger instance (optional)
|
|
107
|
-
* @param nodeTracerProvider - OpenTelemetry tracer provider (optional)
|
|
108
|
-
* @param asyncLocalStorage - AsyncLocalStorage instance for tracing context (optional)
|
|
109
|
-
* @returns Configured Temporal worker
|
|
110
|
-
*/
|
|
111
|
-
export declare function initWorker({ temporal: temporalConfig, metrics: { custom: metricsConfig } }: AppConfig, options: Omit<WorkerOptions, 'taskQueue'> & {
|
|
112
|
-
taskQueue?: string;
|
|
113
|
-
}, envService: EnvService, logger?: Logger, nodeTracerProvider?: NodeTracerProvider, asyncLocalStorage?: AsyncLocalStorage<AlsData>): Promise<Worker>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { WorkerStatus } from '@temporalio/worker';
|
|
2
|
-
import { HealthCheckResult, OnHealthCheck } from '@diia-inhouse/types';
|
|
3
|
-
import { WorkerStatusProvider } from '../interfaces/services/worker';
|
|
4
|
-
export interface WorkerHealthDetails {
|
|
5
|
-
worker: WorkerStatus | 'NOT_INITIALIZED';
|
|
6
|
-
}
|
|
7
|
-
export declare class WorkerHealthService implements OnHealthCheck {
|
|
8
|
-
private statusProvider?;
|
|
9
|
-
setStatusProvider(provider: WorkerStatusProvider): void;
|
|
10
|
-
onHealthCheck(): Promise<HealthCheckResult<WorkerHealthDetails>>;
|
|
11
|
-
}
|
package/dist/types/testing.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export { defaultActivityInfo, MockActivityEnvironment, TestWorkflowEnvironment, TimeSkippingWorkflowClient, workflowInterceptorModules, } from '@temporalio/testing';
|
|
2
|
-
type ActivityMethods<T> = T extends {
|
|
3
|
-
prototype: infer P;
|
|
4
|
-
} ? {
|
|
5
|
-
[K in keyof P]?: P[K] extends (...args: any[]) => any ? (...args: Parameters<P[K]>) => ReturnType<P[K]> : never;
|
|
6
|
-
} : never;
|
|
7
|
-
/**
|
|
8
|
-
* Redefines instantiated activities for use in test environments.
|
|
9
|
-
*
|
|
10
|
-
* This function allows to override specific activity methods with mock implementations
|
|
11
|
-
* while preserving the overall activity structure.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* // Original activities object
|
|
15
|
-
* const activities = instantiateActivities(app, workerActivities)
|
|
16
|
-
*
|
|
17
|
-
* // Mock specific methods for testing
|
|
18
|
-
* const mockedActivities = {
|
|
19
|
-
* ...activities,
|
|
20
|
-
* ...mockActivities<typeof workerActivities>({
|
|
21
|
-
* user: {
|
|
22
|
-
* getProfile: async (userId) => ({ id: userId, name: 'Test User' }),
|
|
23
|
-
* },
|
|
24
|
-
* payment: {
|
|
25
|
-
* process: async () => ({ success: true, transactionId: 'mock-123' })
|
|
26
|
-
* }
|
|
27
|
-
* })
|
|
28
|
-
* }
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* // Using with test runner
|
|
32
|
-
* await runWorkflow({
|
|
33
|
-
* workflow: myWorkflow,
|
|
34
|
-
* args: [workflowInput],
|
|
35
|
-
* activities: mockedActivities
|
|
36
|
-
* })
|
|
37
|
-
*/
|
|
38
|
-
export declare function mockActivities<TActivities extends Record<string, {
|
|
39
|
-
prototype: unknown;
|
|
40
|
-
}>>(activities: {
|
|
41
|
-
[K in keyof TActivities]?: ActivityMethods<TActivities[K]>;
|
|
42
|
-
}): Record<string, (...args: unknown[]) => unknown>;
|
package/dist/types/worker.d.ts
DELETED
package/dist/worker.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6CAS2B;AALvB,0GAAA,gBAAgB,OAAA;AAChB,iGAAA,OAAO,OAAA;AAEP,4GAAA,kBAAkB,OAAA;AAClB,gGAAA,MAAM,OAAA;AAGV,iDAA8B;AAE9B,oDAAiC"}
|