@temporalio/workflow 1.4.4 → 1.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temporalio/workflow",
3
- "version": "1.4.4",
3
+ "version": "1.5.0",
4
4
  "description": "Temporal.io SDK Workflow sub-package",
5
5
  "keywords": [
6
6
  "temporal",
@@ -17,8 +17,8 @@
17
17
  "types": "lib/index.d.ts",
18
18
  "scripts": {},
19
19
  "dependencies": {
20
- "@temporalio/common": "~1.4.4",
21
- "@temporalio/proto": "~1.4.4"
20
+ "@temporalio/common": "~1.5.0",
21
+ "@temporalio/proto": "~1.5.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "source-map": "^0.7.4"
@@ -30,5 +30,5 @@
30
30
  "src",
31
31
  "lib"
32
32
  ],
33
- "gitHead": "7ae3fba6332000b35d521411404c11e32052f282"
33
+ "gitHead": "b46426d8b9b342c052d53520b50dbb991b8d5e03"
34
34
  }
@@ -1,5 +1,5 @@
1
- import { CancelledFailure, IllegalStateError } from '@temporalio/common';
2
1
  import type { AsyncLocalStorage as ALS } from 'async_hooks';
2
+ import { CancelledFailure, IllegalStateError } from '@temporalio/common';
3
3
  import { untrackPromise } from './stack-helpers';
4
4
 
5
5
  // AsyncLocalStorage is injected via vm module into global scope.
@@ -162,7 +162,8 @@ export class CancellationScope {
162
162
  * Get the current "active" scope
163
163
  */
164
164
  static current(): CancellationScope {
165
- return storage.getStore() ?? ROOT_SCOPE;
165
+ // Using globals directly instead of a helper function to avoid circular import
166
+ return storage.getStore() ?? (globalThis as any).__TEMPORAL__.activator.rootScope;
166
167
  }
167
168
 
168
169
  /** Alias to `new CancellationScope({ cancellable: true }).run(fn)` */
@@ -187,14 +188,15 @@ export class CancellationScope {
187
188
  export const storage = new AsyncLocalStorage<CancellationScope>();
188
189
 
189
190
  export class RootCancellationScope extends CancellationScope {
191
+ constructor() {
192
+ super({ cancellable: true, parent: NO_PARENT });
193
+ }
194
+
190
195
  cancel(): void {
191
196
  this.reject(new CancelledFailure('Workflow cancelled'));
192
197
  }
193
198
  }
194
199
 
195
- /** There can only be one of these */
196
- export const ROOT_SCOPE = new RootCancellationScope({ cancellable: true, parent: NO_PARENT });
197
-
198
200
  /** This function is here to avoid a circular dependency between this module and workflow.ts */
199
201
  let sleep = (_: number | string): Promise<void> => {
200
202
  throw new IllegalStateError('Workflow has not been properly initialized');
package/src/errors.ts CHANGED
@@ -1,5 +1,3 @@
1
- export { WorkflowExecutionAlreadyStartedError } from '@temporalio/common';
2
-
3
1
  /**
4
2
  * Base class for all workflow errors
5
3
  */
package/src/index.ts CHANGED
@@ -49,8 +49,6 @@
49
49
  export {
50
50
  ActivityCancellationType,
51
51
  ActivityFailure,
52
- ActivityFunction,
53
- ActivityInterface,
54
52
  ActivityOptions,
55
53
  ApplicationFailure,
56
54
  CancelledFailure,
@@ -63,13 +61,26 @@ export {
63
61
  TemporalFailure,
64
62
  TerminatedFailure,
65
63
  TimeoutFailure,
66
- UntypedActivities,
67
64
  } from '@temporalio/common';
68
65
  export * from '@temporalio/common/lib/errors';
69
- export * from '@temporalio/common/lib/interfaces';
66
+ export {
67
+ ActivityFunction,
68
+ ActivityInterface, // eslint-disable-line deprecation/deprecation
69
+ Payload,
70
+ QueryDefinition,
71
+ SearchAttributes,
72
+ SearchAttributeValue,
73
+ SignalDefinition,
74
+ UntypedActivities,
75
+ Workflow,
76
+ WorkflowQueryType,
77
+ WorkflowResultType,
78
+ WorkflowReturnType,
79
+ WorkflowSignalType,
80
+ } from '@temporalio/common/lib/interfaces';
70
81
  export * from '@temporalio/common/lib/workflow-handle';
71
82
  export * from '@temporalio/common/lib/workflow-options';
72
- export { AsyncLocalStorage, CancellationScope, CancellationScopeOptions, ROOT_SCOPE } from './cancellation-scope';
83
+ export { AsyncLocalStorage, CancellationScope, CancellationScopeOptions } from './cancellation-scope';
73
84
  export * from './errors';
74
85
  export * from './interceptors';
75
86
  export {
@@ -206,7 +206,7 @@ export interface WorkflowInternalsInterceptor {
206
206
  *
207
207
  * Implement this method to perform any resource cleanup.
208
208
  */
209
- dispose?(input: DisposeInput, next: Next<this, 'dispose'>): Promise<void>;
209
+ dispose?(input: DisposeInput, next: Next<this, 'dispose'>): void;
210
210
  }
211
211
 
212
212
  /**
package/src/interfaces.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { RetryPolicy, TemporalFailure } from '@temporalio/common';
2
- import { CommonWorkflowOptions, SearchAttributes } from '@temporalio/common';
1
+ import type { RawSourceMap } from 'source-map';
2
+ import { RetryPolicy, TemporalFailure, CommonWorkflowOptions, SearchAttributes } from '@temporalio/common';
3
3
  import { checkExtends } from '@temporalio/common/lib/type-helpers';
4
4
  import type { coresdk } from '@temporalio/proto';
5
5
 
@@ -189,7 +189,7 @@ export interface ContinueAsNewOptions {
189
189
  /**
190
190
  * Non-searchable attributes to attach to next Workflow run
191
191
  */
192
- memo?: Record<string, any>;
192
+ memo?: Record<string, unknown>;
193
193
  /**
194
194
  * Searchable attributes to attach to next Workflow run
195
195
  */
@@ -364,3 +364,15 @@ export interface EnhancedStackTrace {
364
364
  sources: Record<string, FileSlice[]>;
365
365
  stacks: StackTrace[];
366
366
  }
367
+
368
+ export interface WorkflowCreateOptions {
369
+ info: WorkflowInfo;
370
+ randomnessSeed: number[];
371
+ now: number;
372
+ patches: string[];
373
+ showStackTraceSources: boolean;
374
+ }
375
+
376
+ export interface WorkflowCreateOptionsWithSourceMap extends WorkflowCreateOptions {
377
+ sourceMap: RawSourceMap;
378
+ }