Skip to content

Commit 9d28e2c

Browse files
authored
fix(workflow): Remove accidental import of large protos into workflow library (#1203)
1 parent 27b2a22 commit 9d28e2c

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

packages/common/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export { Headers, Next } from './interceptors';
2020
export * from './interfaces';
2121
export * from './logger';
2222
export * from './retry-policy';
23-
export { type Timestamp, Duration, StringValue } from './time';
23+
export type { Timestamp, Duration, StringValue } from './time';
2424
export * from './workflow-handle';
2525
export * from './workflow-options';
2626
export * from './versioning-intent';
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import type { coresdk } from '@temporalio/proto';
2+
import type { VersioningIntent as VersioningIntentString } from './versioning-intent';
3+
import { assertNever, checkExtends } from './type-helpers';
4+
5+
// Avoid importing the proto implementation to reduce workflow bundle size
6+
// Copied from coresdk.common.VersioningIntent
7+
/**
8+
* Protobuf enum representation of {@link VersioningIntentString}.
9+
*
10+
* @experimental
11+
*/
12+
export enum VersioningIntent {
13+
UNSPECIFIED = 0,
14+
COMPATIBLE = 1,
15+
DEFAULT = 2,
16+
}
17+
18+
checkExtends<coresdk.common.VersioningIntent, VersioningIntent>();
19+
checkExtends<VersioningIntent, coresdk.common.VersioningIntent>();
20+
21+
export function versioningIntentToProto(intent: VersioningIntentString | undefined): VersioningIntent {
22+
switch (intent) {
23+
case 'DEFAULT':
24+
return VersioningIntent.DEFAULT;
25+
case 'COMPATIBLE':
26+
return VersioningIntent.COMPATIBLE;
27+
case undefined:
28+
return VersioningIntent.UNSPECIFIED;
29+
default:
30+
assertNever('Unexpected VersioningIntent', intent);
31+
}
32+
}

packages/workflow/src/workflow.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,14 @@ import {
1212
SignalDefinition,
1313
toPayloads,
1414
UntypedActivities,
15-
VersioningIntent,
1615
WithWorkflowArgs,
1716
Workflow,
1817
WorkflowResultType,
1918
WorkflowReturnType,
2019
} from '@temporalio/common';
21-
import { assertNever } from '@temporalio/common/lib/type-helpers';
20+
import { versioningIntentToProto } from '@temporalio/common/lib/versioning-intent-enum';
2221
import { Duration, msOptionalToTs, msToNumber, msToTs, tsToMs } from '@temporalio/common/lib/time';
2322
import { composeInterceptors } from '@temporalio/common/lib/interceptors';
24-
import { coresdk } from '@temporalio/proto';
2523
import { CancellationScope, registerSleepImplementation } from './cancellation-scope';
2624
import {
2725
ActivityInput,
@@ -1336,16 +1334,3 @@ function assertInWorkflowContext(message: string): Activator {
13361334
if (activator == null) throw new IllegalStateError(message);
13371335
return activator;
13381336
}
1339-
1340-
function versioningIntentToProto(intent: VersioningIntent | undefined): coresdk.common.VersioningIntent {
1341-
switch (intent) {
1342-
case 'DEFAULT':
1343-
return coresdk.common.VersioningIntent.DEFAULT;
1344-
case 'COMPATIBLE':
1345-
return coresdk.common.VersioningIntent.COMPATIBLE;
1346-
case undefined:
1347-
return coresdk.common.VersioningIntent.UNSPECIFIED;
1348-
default:
1349-
assertNever('Unexpected VersioningIntent', intent);
1350-
}
1351-
}

0 commit comments

Comments
 (0)