Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ env:
IS_MAIN_OR_RELEASE: ${{ vars.IS_TEMPORALIO_SDK_TYPESCRIPT_REPO == 'true' && github.event_name != 'pull_request' && ( github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') || startsWith(github.ref, 'refs/heads/releases')) }}

# Use these variables to force specific version of CLI/Time Skipping Server for SDK tests
TESTS_CLI_VERSION: 'v1.6.2-server-1.31.0-151.6'
# TESTS_CLI_VERSION: 'v1.7.0'
# TESTS_TIME_SKIPPING_SERVER_VERSION: 'v1.24.1'

jobs:
Expand Down Expand Up @@ -202,7 +202,13 @@ jobs:
--db-filename temporal.sqlite \
--sqlite-pragma journal_mode=WAL \
--sqlite-pragma synchronous=OFF \
--headless &> ./devserver.log &
--headless &> ./devserver.log \
--dynamic-config-value system.enableActivityEagerExecution=true \
--dynamic-config-value history.enableRequestIdRefLinks=true \
--dynamic-config-value frontend.activityAPIsEnabled=true \
--dynamic-config-value activity.enableStandalone=true \
--dynamic-config-value history.enableChasm=true \
--dynamic-config-value history.enableTransitionHistory=true &
- name: Run Tests (Node)
if: matrix.node != 'bun'
Expand Down
42 changes: 35 additions & 7 deletions packages/activity/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,26 @@ export const asyncLocalStorage: AsyncLocalStorage<Context> = (globalThis as any)
* Holds information about the current Activity Execution. Retrieved inside an Activity with `Context.current().info`.
*/
export interface Info {
/**
* Task token associated with this activity execution. Can be used for asynchronous completion
*/
readonly taskToken: Uint8Array;
/**
* Base64 encoded `taskToken`
* Base64 encoded {@link taskToken}
*/
readonly base64TaskToken: string;
/**
* ID of this activity
*/
readonly activityId: string;
/**
* Exposed Activity function name
*/
readonly activityType: string;
/**
* The namespace this Activity is running in
*
* @deprecated Use {@link namespace} instead
*/
readonly activityNamespace: string;
/**
Expand All @@ -176,20 +184,22 @@ export interface Info {
*/
readonly isLocal: boolean;
/**
* Information about the Workflow that scheduled the Activity
* Information about the Workflow that scheduled the Activity. Not set if the activity was not started by a Workflow
*/
readonly workflowExecution: {
readonly workflowExecution?: {
readonly workflowId: string;
readonly runId: string;
};
/**
* The namespace of the Workflow that scheduled this Activity
* The namespace of the Workflow that scheduled this Activity. Not set if the activity was not started by a Workflow
*
* @deprecated Use {@link namespace} instead
*/
readonly workflowNamespace: string;
readonly workflowNamespace?: string;
/**
* The module name of the Workflow that scheduled this Activity
* The module name of the Workflow that scheduled this Activity. Not set if the activity was not started by a Workflow
*/
readonly workflowType: string;
readonly workflowType?: string;
/**
* Timestamp for when this Activity was first scheduled.
* For retries, this will have the timestamp of the first attempt.
Expand Down Expand Up @@ -249,6 +259,24 @@ export interface Info {
* version), but it may still be defined server-side.
*/
readonly retryPolicy?: RetryPolicy;
/**
* The namespace this Activity is running in
*/
readonly namespace: string;
/**
* ID of the current run of this activity. Can be used to differentiate between different activity executions that
* share the same ID. Activities started by a Workflow don't have activity run ID - instead, they can be identified by
* workflow ID and workflow run ID; see {@link workflowExecution}
*
* @experimental Standalone Activities are experimental. APIs may be subject to change.
*/
readonly activityRunId?: string;
/**
* Whether this activity was started by a workflow
*
* @experimental Standalone Activities are experimental. APIs may be subject to change.
*/
readonly inWorkflow: boolean;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking just since this is currently experimental, but making Info enforce that inWorkflow: true implies that workflowExecution etc are present would be nice

e.g.

  type Info = BaseInfo & (
    | { readonly inWorkflow: true;
        readonly workflowExecution: { workflowId: string; runId: string };
        readonly workflowNamespace: string;
        readonly workflowType: string;
        readonly activityRunId?: undefined }
    | { readonly inWorkflow: false;
        readonly activityRunId: string;
        readonly workflowExecution?: undefined;
        readonly workflowNamespace?: undefined;
        readonly workflowType?: undefined }
  );

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't really work in a way that's helpful to the users, because ActivityContext.current().info still has to be the most general type and TS compiler doesn't support type assertions on this.

}

/**
Expand Down
Loading
Loading