@temporalio/workflow
Advanced tools
Comparing version 1.8.0 to 1.8.1
@@ -103,2 +103,4 @@ /** | ||
} | ||
/** Input for WorkflowOutboundCallsInterceptor.getLogAttributes */ | ||
export type GetLogAttributesInput = Record<string, unknown>; | ||
/** | ||
@@ -139,2 +141,8 @@ * Implement any of these methods to intercept Workflow code calls to the Temporal APIs, like scheduling an activity and starting a timer | ||
startChildWorkflowExecution?: (input: StartChildWorkflowExecutionInput, next: Next<this, 'startChildWorkflowExecution'>) => Promise<[Promise<string>, Promise<unknown>]>; | ||
/** | ||
* Called on each invocation of the `workflow.log` methods. | ||
* | ||
* The attributes returned in this call are attached to every log message. | ||
*/ | ||
getLogAttributes?: (input: GetLogAttributesInput, next: Next<this, 'getLogAttributes'>) => Record<string, unknown>; | ||
} | ||
@@ -141,0 +149,0 @@ /** Input for WorkflowInternalsInterceptor.concludeActivation */ |
import type { RawSourceMap } from 'source-map'; | ||
import { RetryPolicy, TemporalFailure, CommonWorkflowOptions, SearchAttributes, SignalDefinition, QueryDefinition, Duration } from '@temporalio/common'; | ||
import { RetryPolicy, TemporalFailure, CommonWorkflowOptions, SearchAttributes, SignalDefinition, QueryDefinition, Duration, VersioningIntent } from '@temporalio/common'; | ||
import type { coresdk } from '@temporalio/proto'; | ||
@@ -178,2 +178,9 @@ /** | ||
searchAttributes?: SearchAttributes; | ||
/** | ||
* When using the Worker Versioning feature, specifies whether this Workflow should | ||
* Continue-as-New onto a worker with a compatible Build Id or not. See {@link VersioningIntent}. | ||
* | ||
* @experimental | ||
*/ | ||
versioningIntent?: VersioningIntent; | ||
} | ||
@@ -263,2 +270,9 @@ /** | ||
parentClosePolicy?: ParentClosePolicy; | ||
/** | ||
* When using the Worker Versioning feature, specifies whether this Child Workflow should run on | ||
* a worker with a compatible Build Id or not. See {@link VersioningIntent}. | ||
* | ||
* @experimental | ||
*/ | ||
versioningIntent?: VersioningIntent; | ||
} | ||
@@ -265,0 +279,0 @@ export type RequiredChildWorkflowOptions = Required<Pick<ChildWorkflowOptions, 'workflowId' | 'cancellationType'>> & { |
@@ -24,3 +24,3 @@ "use strict"; | ||
static is(error) { | ||
return error instanceof ContinueAsNew || (error instanceof Error && error[isContinueAsNew]); | ||
return error instanceof ContinueAsNew || error?.[isContinueAsNew] === true; | ||
} | ||
@@ -27,0 +27,0 @@ } |
@@ -44,8 +44,8 @@ /** | ||
defaultWorkerLogger: { | ||
trace(message: string, attrs: Record<string, unknown>): void; | ||
debug(message: string, attrs: Record<string, unknown>): void; | ||
info(message: string, attrs: Record<string, unknown>): void; | ||
warn(message: string, attrs: Record<string, unknown>): void; | ||
error(message: string, attrs: Record<string, unknown>): void; | ||
trace(message: string, attrs?: Record<string, unknown>): void; | ||
debug(message: string, attrs?: Record<string, unknown>): void; | ||
info(message: string, attrs?: Record<string, unknown>): void; | ||
warn(message: string, attrs?: Record<string, unknown>): void; | ||
error(message: string, attrs?: Record<string, unknown>): void; | ||
}; | ||
} |
@@ -97,3 +97,3 @@ import { ActivityFunction, ActivityOptions, LocalActivityOptions, QueryDefinition, SearchAttributes, SignalDefinition, UntypedActivities, WithWorkflowArgs, Workflow, WorkflowResultType, WorkflowReturnType } from '@temporalio/common'; | ||
* export function execute(): Promise<void> { | ||
* const response = await httpGet('http://example.com'); | ||
* const response = await httpGet("http://example.com"); | ||
* // ... | ||
@@ -263,4 +263,4 @@ * } | ||
* async execute() { | ||
* logger.info('hey ho'); | ||
* logger.error('lets go'); | ||
* logger.info("hey ho"); | ||
* logger.error("lets go"); | ||
* } | ||
@@ -267,0 +267,0 @@ * }; |
@@ -5,4 +5,6 @@ "use strict"; | ||
const common_1 = require("@temporalio/common"); | ||
const type_helpers_1 = require("@temporalio/common/lib/type-helpers"); | ||
const time_1 = require("@temporalio/common/lib/time"); | ||
const interceptors_1 = require("@temporalio/common/lib/interceptors"); | ||
const proto_1 = require("@temporalio/proto"); | ||
const cancellation_scope_1 = require("./cancellation-scope"); | ||
@@ -90,7 +92,2 @@ const interfaces_1 = require("./interfaces"); | ||
/** | ||
* Hooks up activity promise to current cancellation scope and completion callbacks. | ||
* | ||
* Returns `false` if the current scope is already cancelled. | ||
*/ | ||
/** | ||
* Push a scheduleActivity command into activator accumulator and register completion | ||
@@ -134,2 +131,3 @@ */ | ||
doNotEagerlyExecute: !(options.allowEagerDispatch ?? true), | ||
versioningIntent: versioningIntentToProto(options.versioningIntent), | ||
}, | ||
@@ -298,2 +296,3 @@ }); | ||
memo: options.memo && (0, common_1.mapToPayloads)(activator.payloadConverter, options.memo), | ||
versioningIntent: versioningIntentToProto(options.versioningIntent), | ||
}, | ||
@@ -402,3 +401,3 @@ }); | ||
* export function execute(): Promise<void> { | ||
* const response = await httpGet('http://example.com'); | ||
* const response = await httpGet("http://example.com"); | ||
* // ... | ||
@@ -631,4 +630,4 @@ * } | ||
* async execute() { | ||
* logger.info('hey ho'); | ||
* logger.error('lets go'); | ||
* logger.info("hey ho"); | ||
* logger.error("lets go"); | ||
* } | ||
@@ -689,2 +688,3 @@ * }; | ||
workflowTaskTimeout: (0, time_1.msOptionalToTs)(options.workflowTaskTimeout), | ||
versioningIntent: versioningIntentToProto(options.versioningIntent), | ||
}); | ||
@@ -1002,6 +1002,8 @@ }); | ||
(message, attrs) => { | ||
assertInWorkflowContext('Workflow.log(...) may only be used from a Workflow Execution.)'); | ||
const activator = assertInWorkflowContext('Workflow.log(...) may only be used from a Workflow Execution.'); | ||
const getLogAttributes = (0, interceptors_1.composeInterceptors)(activator.interceptors.outbound, 'getLogAttributes', (a) => a); | ||
return loggerSinks.defaultWorkerLogger[level](message, { | ||
// Inject the call time in nanosecond resolution as expected by the worker logger. | ||
[LogTimestamp]: (0, internals_1.getActivator)().getTimeOfDay(), | ||
[LogTimestamp]: activator.getTimeOfDay(), | ||
...getLogAttributes({}), | ||
...attrs, | ||
@@ -1018,2 +1020,14 @@ }); | ||
} | ||
function versioningIntentToProto(intent) { | ||
switch (intent) { | ||
case 'DEFAULT': | ||
return proto_1.coresdk.common.VersioningIntent.DEFAULT; | ||
case 'COMPATIBLE': | ||
return proto_1.coresdk.common.VersioningIntent.COMPATIBLE; | ||
case undefined: | ||
return proto_1.coresdk.common.VersioningIntent.UNSPECIFIED; | ||
default: | ||
(0, type_helpers_1.assertNever)('Unexpected VersioningIntent', intent); | ||
} | ||
} | ||
//# sourceMappingURL=workflow.js.map |
{ | ||
"name": "@temporalio/workflow", | ||
"version": "1.8.0", | ||
"version": "1.8.1", | ||
"description": "Temporal.io SDK Workflow sub-package", | ||
@@ -25,4 +25,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@temporalio/common": "1.8.0", | ||
"@temporalio/proto": "1.8.0" | ||
"@temporalio/common": "1.8.1", | ||
"@temporalio/proto": "1.8.1" | ||
}, | ||
@@ -39,3 +39,3 @@ "devDependencies": { | ||
], | ||
"gitHead": "17d16e4dca39513470dd4b6e30d9af06dafd00d6" | ||
"gitHead": "97808111bbec478260e915726bb9730a489f8fa4" | ||
} |
@@ -121,2 +121,5 @@ /** | ||
/** Input for WorkflowOutboundCallsInterceptor.getLogAttributes */ | ||
export type GetLogAttributesInput = Record<string, unknown>; | ||
/** | ||
@@ -165,2 +168,9 @@ * Implement any of these methods to intercept Workflow code calls to the Temporal APIs, like scheduling an activity and starting a timer | ||
) => Promise<[Promise<string>, Promise<unknown>]>; | ||
/** | ||
* Called on each invocation of the `workflow.log` methods. | ||
* | ||
* The attributes returned in this call are attached to every log message. | ||
*/ | ||
getLogAttributes?: (input: GetLogAttributesInput, next: Next<this, 'getLogAttributes'>) => Record<string, unknown>; | ||
} | ||
@@ -167,0 +177,0 @@ |
@@ -10,2 +10,3 @@ import type { RawSourceMap } from 'source-map'; | ||
Duration, | ||
VersioningIntent, | ||
} from '@temporalio/common'; | ||
@@ -190,3 +191,3 @@ import { checkExtends } from '@temporalio/common/lib/type-helpers'; | ||
static is(error: unknown): error is ContinueAsNew { | ||
return error instanceof ContinueAsNew || (error instanceof Error && (error as any)[isContinueAsNew]); | ||
return error instanceof ContinueAsNew || (error as any)?.[isContinueAsNew] === true; | ||
} | ||
@@ -225,2 +226,9 @@ } | ||
searchAttributes?: SearchAttributes; | ||
/** | ||
* When using the Worker Versioning feature, specifies whether this Workflow should | ||
* Continue-as-New onto a worker with a compatible Build Id or not. See {@link VersioningIntent}. | ||
* | ||
* @experimental | ||
*/ | ||
versioningIntent?: VersioningIntent; | ||
} | ||
@@ -328,2 +336,10 @@ | ||
parentClosePolicy?: ParentClosePolicy; | ||
/** | ||
* When using the Worker Versioning feature, specifies whether this Child Workflow should run on | ||
* a worker with a compatible Build Id or not. See {@link VersioningIntent}. | ||
* | ||
* @experimental | ||
*/ | ||
versioningIntent?: VersioningIntent; | ||
} | ||
@@ -330,0 +346,0 @@ |
@@ -48,8 +48,8 @@ /** | ||
defaultWorkerLogger: { | ||
trace(message: string, attrs: Record<string, unknown>): void; | ||
debug(message: string, attrs: Record<string, unknown>): void; | ||
info(message: string, attrs: Record<string, unknown>): void; | ||
warn(message: string, attrs: Record<string, unknown>): void; | ||
error(message: string, attrs: Record<string, unknown>): void; | ||
trace(message: string, attrs?: Record<string, unknown>): void; | ||
debug(message: string, attrs?: Record<string, unknown>): void; | ||
info(message: string, attrs?: Record<string, unknown>): void; | ||
warn(message: string, attrs?: Record<string, unknown>): void; | ||
error(message: string, attrs?: Record<string, unknown>): void; | ||
}; | ||
} |
@@ -15,2 +15,3 @@ import { | ||
UntypedActivities, | ||
VersioningIntent, | ||
WithWorkflowArgs, | ||
@@ -21,4 +22,6 @@ Workflow, | ||
} from '@temporalio/common'; | ||
import { assertNever } from '@temporalio/common/lib/type-helpers'; | ||
import { Duration, msOptionalToTs, msToNumber, msToTs, tsToMs } from '@temporalio/common/lib/time'; | ||
import { composeInterceptors } from '@temporalio/common/lib/interceptors'; | ||
import { coresdk } from '@temporalio/proto'; | ||
import { CancellationScope, registerSleepImplementation } from './cancellation-scope'; | ||
@@ -137,7 +140,2 @@ import { | ||
/** | ||
* Hooks up activity promise to current cancellation scope and completion callbacks. | ||
* | ||
* Returns `false` if the current scope is already cancelled. | ||
*/ | ||
/** | ||
* Push a scheduleActivity command into activator accumulator and register completion | ||
@@ -183,2 +181,3 @@ */ | ||
doNotEagerlyExecute: !(options.allowEagerDispatch ?? true), | ||
versioningIntent: versioningIntentToProto(options.versioningIntent), | ||
}, | ||
@@ -382,2 +381,3 @@ }); | ||
memo: options.memo && mapToPayloads(activator.payloadConverter, options.memo), | ||
versioningIntent: versioningIntentToProto(options.versioningIntent), | ||
}, | ||
@@ -522,3 +522,3 @@ }); | ||
* export function execute(): Promise<void> { | ||
* const response = await httpGet('http://example.com'); | ||
* const response = await httpGet("http://example.com"); | ||
* // ... | ||
@@ -900,4 +900,4 @@ * } | ||
* async execute() { | ||
* logger.info('hey ho'); | ||
* logger.error('lets go'); | ||
* logger.info("hey ho"); | ||
* logger.error("lets go"); | ||
* } | ||
@@ -971,2 +971,3 @@ * }; | ||
workflowTaskTimeout: msOptionalToTs(options.workflowTaskTimeout), | ||
versioningIntent: versioningIntentToProto(options.versioningIntent), | ||
}); | ||
@@ -1319,7 +1320,9 @@ }); | ||
level, | ||
(message: string, attrs: Record<string, unknown>) => { | ||
assertInWorkflowContext('Workflow.log(...) may only be used from a Workflow Execution.)'); | ||
(message: string, attrs?: Record<string, unknown>) => { | ||
const activator = assertInWorkflowContext('Workflow.log(...) may only be used from a Workflow Execution.'); | ||
const getLogAttributes = composeInterceptors(activator.interceptors.outbound, 'getLogAttributes', (a) => a); | ||
return loggerSinks.defaultWorkerLogger[level](message, { | ||
// Inject the call time in nanosecond resolution as expected by the worker logger. | ||
[LogTimestamp]: getActivator().getTimeOfDay(), | ||
[LogTimestamp]: activator.getTimeOfDay(), | ||
...getLogAttributes({}), | ||
...attrs, | ||
@@ -1337,1 +1340,14 @@ }); | ||
} | ||
function versioningIntentToProto(intent: VersioningIntent | undefined): coresdk.common.VersioningIntent { | ||
switch (intent) { | ||
case 'DEFAULT': | ||
return coresdk.common.VersioningIntent.DEFAULT; | ||
case 'COMPATIBLE': | ||
return coresdk.common.VersioningIntent.COMPATIBLE; | ||
case undefined: | ||
return coresdk.common.VersioningIntent.UNSPECIFIED; | ||
default: | ||
assertNever('Unexpected VersioningIntent', intent); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
346242
7322
+ Added@temporalio/common@1.8.1(transitive)
+ Added@temporalio/proto@1.8.1(transitive)
- Removed@temporalio/common@1.8.0(transitive)
- Removed@temporalio/proto@1.8.0(transitive)
Updated@temporalio/common@1.8.1
Updated@temporalio/proto@1.8.1