Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@temporalio/common

Package Overview
Dependencies
Maintainers
8
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@temporalio/common - npm Package Compare versions

Comparing version 1.8.6 to 1.9.0-rc.0

2

lib/activity-options.d.ts

@@ -92,2 +92,4 @@ import type { coresdk } from '@temporalio/proto';

*
* @default 'COMPATIBLE'
*
* @experimental

@@ -94,0 +96,0 @@ */

38

lib/converter/failure-converter.js

@@ -7,14 +7,25 @@ "use strict";

const payload_converter_1 = require("./payload-converter");
function combineRegExp(...regexps) {
return new RegExp(regexps.map((x) => `(?:${x.source})`).join('|'));
}
/**
* Stack traces will be cutoff when on of these patterns is matched
*/
const CUTOFF_STACK_PATTERNS = [
/** Activity execution */
/\s+at Activity\.execute \(.*[\\/]worker[\\/](?:src|lib)[\\/]activity\.[jt]s:\d+:\d+\)/,
/** Workflow activation */
/\s+at Activator\.\S+NextHandler \(.*[\\/]workflow[\\/](?:src|lib)[\\/]internals\.[jt]s:\d+:\d+\)/,
/** Workflow run anything in context */
/\s+at Script\.runInContext \((?:node:vm|vm\.js):\d+:\d+\)/,
];
const CUTOFF_STACK_PATTERNS = combineRegExp(
/** Activity execution */
/\s+at Activity\.execute \(.*[\\/]worker[\\/](?:src|lib)[\\/]activity\.[jt]s:\d+:\d+\)/,
/** Workflow activation */
/\s+at Activator\.\S+NextHandler \(.*[\\/]workflow[\\/](?:src|lib)[\\/]internals\.[jt]s:\d+:\d+\)/,
/** Workflow run anything in context */
/\s+at Script\.runInContext \((?:node:vm|vm\.js):\d+:\d+\)/);
/**
* Any stack trace frames that match any of those wil be dopped.
* The "null." prefix on some cases is to avoid https://github.com/nodejs/node/issues/42417
*/
const DROPPED_STACK_FRAMES_PATTERNS = combineRegExp(
/** Internal functions used to recursively chain interceptors */
/\s+at (null\.)?next \(.*[\\/]common[\\/](?:src|lib)[\\/]interceptors\.[jt]s:\d+:\d+\)/,
/** Internal functions used to recursively chain interceptors */
/\s+at (null\.)?executeNextHandler \(.*[\\/]worker[\\/](?:src|lib)[\\/]activity\.[jt]s:\d+:\d+\)/);
/**
* Cuts out the framework part of a stack trace, leaving only user code entries

@@ -25,8 +36,7 @@ */

const acc = Array();
lineLoop: for (const line of lines) {
for (const pattern of CUTOFF_STACK_PATTERNS) {
if (pattern.test(line))
break lineLoop;
}
acc.push(line);
for (const line of lines) {
if (CUTOFF_STACK_PATTERNS.test(line))
break;
if (!DROPPED_STACK_FRAMES_PATTERNS.test(line))
acc.push(line);
}

@@ -33,0 +43,0 @@ return acc.join('\n');

@@ -184,3 +184,4 @@ "use strict";

return ((0, type_helpers_1.isRecord)(type) &&
type.constructor.name === 'Type' &&
// constructor.name may get mangled by minifiers; thanksfuly protobufjs also sets a className property
type.constructor.className === 'Type' &&
(0, type_helpers_1.hasOwnProperties)(type, ['parent', 'name', 'create', 'encode', 'decode']) &&

@@ -204,3 +205,4 @@ typeof type.name === 'string' &&

function isRoot(root) {
return (0, type_helpers_1.isRecord)(root) && root.constructor.name === 'Root';
// constructor.name may get mangled by minifiers; thanksfuly protobufjs also sets a className property
return (0, type_helpers_1.isRecord)(root) && root.constructor.className === 'Root';
}

@@ -207,0 +209,0 @@ class DefaultPayloadConverterWithProtobufs extends payload_converter_1.CompositePayloadConverter {

@@ -12,4 +12,7 @@ import { AnyFunc, OmitLastParam } from './type-helpers';

/**
* Composes all interceptor methods into a single function
* Compose all interceptor methods into a single function.
*
* Calling the composed function results in calling each of the provided interceptor, in order (from the first to
* the last), followed by the original function provided as argument to `composeInterceptors()`.
*
* @param interceptors a list of interceptors

@@ -16,0 +19,0 @@ * @param method the name of the interceptor method to compose

@@ -5,4 +5,7 @@ "use strict";

/**
* Composes all interceptor methods into a single function
* Compose all interceptor methods into a single function.
*
* Calling the composed function results in calling each of the provided interceptor, in order (from the first to
* the last), followed by the original function provided as argument to `composeInterceptors()`.
*
* @param interceptors a list of interceptors

@@ -18,3 +21,3 @@ * @param method the name of the interceptor method to compose

const prev = next;
// We loose type safety here because Typescript can't deduce that interceptor[method] is a function that returns
// We lose type safety here because Typescript can't deduce that interceptor[method] is a function that returns
// the same type as Next<I, M>

@@ -21,0 +24,0 @@ next = ((input) => interceptor[method](input, prev));

@@ -5,2 +5,4 @@ import type { temporal } from '@temporalio/proto';

export type WorkflowReturnType = Promise<any>;
export type WorkflowUpdateType = (...args: any[]) => Promise<any> | any;
export type WorkflowUpdateValidatorType = (...args: any[]) => void;
export type WorkflowSignalType = (...args: any[]) => Promise<void> | void;

@@ -16,6 +18,27 @@ export type WorkflowQueryType = (...args: any[]) => any;

declare const argsBrand: unique symbol;
declare const retBrand: unique symbol;
/**
* An interface representing a Workflow update definition, as returned from {@link defineUpdate}
*
* @remarks `Args` can be used for parameter type inference in handler functions and WorkflowHandle methods.
* `Name` can optionally be specified with a string literal type to preserve type-level knowledge of the update name.
*/
export interface UpdateDefinition<Ret, Args extends any[] = [], Name extends string = string> {
type: 'update';
name: Name;
/**
* Virtual type brand to maintain a distinction between {@link UpdateDefinition} types with different args.
* This field is not present at run-time.
*/
[argsBrand]: Args;
/**
* Virtual type brand to maintain a distinction between {@link UpdateDefinition} types with different return types.
* This field is not present at run-time.
*/
[retBrand]: Ret;
}
/**
* An interface representing a Workflow signal definition, as returned from {@link defineSignal}
*
* @remarks `Args` can be used for parameter type inference in handler functions and *WorkflowHandle methods.
* @remarks `Args` can be used for parameter type inference in handler functions and WorkflowHandle methods.
* `Name` can optionally be specified with a string literal type to preserve type-level knowledge of the signal name.

@@ -32,7 +55,6 @@ */

}
declare const retBrand: unique symbol;
/**
* An interface representing a Workflow query definition as returned from {@link defineQuery}
*
* @remarks `Args` and `Ret` can be used for parameter type inference in handler functions and *WorkflowHandle methods.
* @remarks `Args` and `Ret` can be used for parameter type inference in handler functions and WorkflowHandle methods.
* `Name` can optionally be specified with a string literal type to preserve type-level knowledge of the query name.

@@ -39,0 +61,0 @@ */

@@ -5,5 +5,7 @@ /// <reference types="node" />

/**
* Overrides the target name used for SSL host name checking.
* If this attribute is not specified, the name used for SSL host name checking will be the host from {@link ServerOptions.url}.
* This _should_ be used for testing only.
* Overrides the target name (SNI) used for TLS host name checking.
* If this attribute is not specified, the name used for TLS host name checking will be the host from {@link ServerOptions.url}.
* This can be useful when you have reverse proxy in front of temporal server, and you may want to override the SNI to
* direct traffic to the appropriate backend server based on custom routing rules. Oppositely, connections could be refused
* if the provided SNI does not match the expected host. Adding this override should be done with care.
*/

@@ -10,0 +12,0 @@ serverNameOverride?: string;

@@ -62,1 +62,2 @@ /** Shorthand alias */

export declare function SymbolBasedInstanceOfError<E extends Error>(markerName: string): (clazz: Class<E>) => void;
export declare function deepFreeze<T>(object: T): T;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SymbolBasedInstanceOfError = exports.assertNever = exports.errorCode = exports.errorMessage = exports.isAbortError = exports.isError = exports.hasOwnProperties = exports.hasOwnProperty = exports.isRecord = exports.checkExtends = void 0;
exports.deepFreeze = exports.SymbolBasedInstanceOfError = exports.assertNever = exports.errorCode = exports.errorMessage = exports.isAbortError = exports.isError = exports.hasOwnProperties = exports.hasOwnProperty = exports.isRecord = exports.checkExtends = void 0;
/** Verify that an type _Copy extends _Orig */

@@ -115,2 +115,24 @@ function checkExtends() {

exports.SymbolBasedInstanceOfError = SymbolBasedInstanceOfError;
// Thanks MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
function deepFreeze(object) {
// Retrieve the property names defined on object
const propNames = Object.getOwnPropertyNames(object);
// Freeze properties before freezing self
for (const name of propNames) {
const value = object[name];
if (value && typeof value === 'object') {
try {
deepFreeze(value);
}
catch (err) {
// This is okay, there are some typed arrays that cannot be frozen (encodingKeys)
}
}
else if (typeof value === 'function') {
Object.freeze(value);
}
}
return Object.freeze(object);
}
exports.deepFreeze = deepFreeze;
//# sourceMappingURL=type-helpers.js.map
/**
* Indicates whether the user intends certain commands to be run on a compatible worker Build Id
* version or not.
* Indicates whether the user intends certain commands to be run on a compatible worker Build Id version or not.
*
* `COMPATIBLE` indicates that the command should run on a worker with compatible version if
* possible. It may not be possible if the target task queue does not also have knowledge of the
* current worker's Build Id.
* `COMPATIBLE` indicates that the command should run on a worker with compatible version if possible. It may not be
* possible if the target task queue does not also have knowledge of the current worker's Build Id.
*
* `DEFAULT` indicates that the command should run on the target task queue's current
* overall-default Build Id.
* `DEFAULT` indicates that the command should run on the target task queue's current overall-default Build Id.
*
* Where this type is accepted optionally, an unset value indicates that the SDK should choose the
* most sensible default behavior for the type of command, accounting for whether the command will
* be run on the same task queue as the current worker.
* Where this type is accepted optionally, an unset value indicates that the SDK should choose the most sensible default
* behavior for the type of command, accounting for whether the command will be run on the same task queue as the
* current worker. The default behavior for starting Workflows is `DEFAULT`. The default behavior for Workflows starting
* Activities, starting Child Workflows, or Continuing As New is `COMPATIBLE`.
*

@@ -16,0 +14,0 @@ * @experimental

@@ -1,6 +0,4 @@

import type { google } from '@temporalio/proto';
import { SearchAttributes, Workflow } from './interfaces';
import { RetryPolicy } from './retry-policy';
import { Duration } from './time';
import { Replace } from './type-helpers';
/**

@@ -114,8 +112,2 @@ * Concept: {@link https://docs.temporal.io/concepts/what-is-a-workflow-id-reuse-policy/ | Workflow Id Reuse Policy}

export type CommonWorkflowOptions = BaseWorkflowOptions & WorkflowDurationOptions;
export type WithCompiledWorkflowOptions<T extends CommonWorkflowOptions> = Replace<T, {
workflowExecutionTimeout?: google.protobuf.IDuration;
workflowRunTimeout?: google.protobuf.IDuration;
workflowTaskTimeout?: google.protobuf.IDuration;
}>;
export declare function compileWorkflowOptions<T extends CommonWorkflowOptions>(options: T): WithCompiledWorkflowOptions<T>;
export declare function extractWorkflowType<T extends Workflow>(workflowTypeOrFunc: string | T): string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractWorkflowType = exports.compileWorkflowOptions = exports.WorkflowIdReusePolicy = void 0;
const time_1 = require("./time");
exports.extractWorkflowType = exports.WorkflowIdReusePolicy = void 0;
const type_helpers_1 = require("./type-helpers");

@@ -43,12 +42,2 @@ // Avoid importing the proto implementation to reduce workflow bundle size

(0, type_helpers_1.checkExtends)();
function compileWorkflowOptions(options) {
const { workflowExecutionTimeout, workflowRunTimeout, workflowTaskTimeout, ...rest } = options;
return {
...rest,
workflowExecutionTimeout: (0, time_1.msOptionalToTs)(workflowExecutionTimeout),
workflowRunTimeout: (0, time_1.msOptionalToTs)(workflowRunTimeout),
workflowTaskTimeout: (0, time_1.msOptionalToTs)(workflowTaskTimeout),
};
}
exports.compileWorkflowOptions = compileWorkflowOptions;
function extractWorkflowType(workflowTypeOrFunc) {

@@ -55,0 +44,0 @@ if (typeof workflowTypeOrFunc === 'string')

{
"name": "@temporalio/common",
"version": "1.8.6",
"version": "1.9.0-rc.0",
"description": "Common library for code that's used across the Client, Worker, and/or Workflow",

@@ -15,4 +15,3 @@ "main": "lib/index.js",

"dependencies": {
"@opentelemetry/api": "^1.4.1",
"@temporalio/proto": "1.8.6",
"@temporalio/proto": "1.9.0-rc.0",
"long": "^5.2.0",

@@ -39,3 +38,3 @@ "ms": "^3.0.0-canary.1",

],
"gitHead": "1e95cf92ec5e6efffb7aedb064ea46be05df0c14"
"gitHead": "ca3e508e62de02b2c9bb40d0d889003cebba282d"
}

@@ -109,2 +109,4 @@ import type { coresdk } from '@temporalio/proto';

*
* @default 'COMPATIBLE'
*
* @experimental

@@ -111,0 +113,0 @@ */

@@ -18,6 +18,10 @@ import {

function combineRegExp(...regexps: RegExp[]): RegExp {
return new RegExp(regexps.map((x) => `(?:${x.source})`).join('|'));
}
/**
* Stack traces will be cutoff when on of these patterns is matched
*/
const CUTOFF_STACK_PATTERNS = [
const CUTOFF_STACK_PATTERNS = combineRegExp(
/** Activity execution */

@@ -28,6 +32,17 @@ /\s+at Activity\.execute \(.*[\\/]worker[\\/](?:src|lib)[\\/]activity\.[jt]s:\d+:\d+\)/,

/** Workflow run anything in context */
/\s+at Script\.runInContext \((?:node:vm|vm\.js):\d+:\d+\)/,
];
/\s+at Script\.runInContext \((?:node:vm|vm\.js):\d+:\d+\)/
);
/**
* Any stack trace frames that match any of those wil be dopped.
* The "null." prefix on some cases is to avoid https://github.com/nodejs/node/issues/42417
*/
const DROPPED_STACK_FRAMES_PATTERNS = combineRegExp(
/** Internal functions used to recursively chain interceptors */
/\s+at (null\.)?next \(.*[\\/]common[\\/](?:src|lib)[\\/]interceptors\.[jt]s:\d+:\d+\)/,
/** Internal functions used to recursively chain interceptors */
/\s+at (null\.)?executeNextHandler \(.*[\\/]worker[\\/](?:src|lib)[\\/]activity\.[jt]s:\d+:\d+\)/
);
/**
* Cuts out the framework part of a stack trace, leaving only user code entries

@@ -38,7 +53,5 @@ */

const acc = Array<string>();
lineLoop: for (const line of lines) {
for (const pattern of CUTOFF_STACK_PATTERNS) {
if (pattern.test(line)) break lineLoop;
}
acc.push(line);
for (const line of lines) {
if (CUTOFF_STACK_PATTERNS.test(line)) break;
if (!DROPPED_STACK_FRAMES_PATTERNS.test(line)) acc.push(line);
}

@@ -45,0 +58,0 @@ return acc.join('\n');

@@ -195,3 +195,4 @@ import * as protoJsonSerializer from 'proto3-json-serializer';

isRecord(type) &&
type.constructor.name === 'Type' &&
// constructor.name may get mangled by minifiers; thanksfuly protobufjs also sets a className property
(type.constructor as any).className === 'Type' &&
hasOwnProperties(type, ['parent', 'name', 'create', 'encode', 'decode']) &&

@@ -218,3 +219,4 @@ typeof type.name === 'string' &&

function isRoot(root: unknown): root is Root {
return isRecord(root) && root.constructor.name === 'Root';
// constructor.name may get mangled by minifiers; thanksfuly protobufjs also sets a className property
return isRecord(root) && (root.constructor as any).className === 'Root';
}

@@ -221,0 +223,0 @@

@@ -15,4 +15,7 @@ import { AnyFunc, OmitLastParam } from './type-helpers';

/**
* Composes all interceptor methods into a single function
* Compose all interceptor methods into a single function.
*
* Calling the composed function results in calling each of the provided interceptor, in order (from the first to
* the last), followed by the original function provided as argument to `composeInterceptors()`.
*
* @param interceptors a list of interceptors

@@ -28,3 +31,3 @@ * @param method the name of the interceptor method to compose

const prev = next;
// We loose type safety here because Typescript can't deduce that interceptor[method] is a function that returns
// We lose type safety here because Typescript can't deduce that interceptor[method] is a function that returns
// the same type as Next<I, M>

@@ -31,0 +34,0 @@ next = ((input: any) => (interceptor[method] as any)(input, prev)) as any;

@@ -7,2 +7,4 @@ import type { temporal } from '@temporalio/proto';

export type WorkflowReturnType = Promise<any>;
export type WorkflowUpdateType = (...args: any[]) => Promise<any> | any;
export type WorkflowUpdateValidatorType = (...args: any[]) => void;
export type WorkflowSignalType = (...args: any[]) => Promise<void> | void;

@@ -20,6 +22,29 @@ export type WorkflowQueryType = (...args: any[]) => any;

declare const argsBrand: unique symbol;
declare const retBrand: unique symbol;
/**
* An interface representing a Workflow update definition, as returned from {@link defineUpdate}
*
* @remarks `Args` can be used for parameter type inference in handler functions and WorkflowHandle methods.
* `Name` can optionally be specified with a string literal type to preserve type-level knowledge of the update name.
*/
export interface UpdateDefinition<Ret, Args extends any[] = [], Name extends string = string> {
type: 'update';
name: Name;
/**
* Virtual type brand to maintain a distinction between {@link UpdateDefinition} types with different args.
* This field is not present at run-time.
*/
[argsBrand]: Args;
/**
* Virtual type brand to maintain a distinction between {@link UpdateDefinition} types with different return types.
* This field is not present at run-time.
*/
[retBrand]: Ret;
}
/**
* An interface representing a Workflow signal definition, as returned from {@link defineSignal}
*
* @remarks `Args` can be used for parameter type inference in handler functions and *WorkflowHandle methods.
* @remarks `Args` can be used for parameter type inference in handler functions and WorkflowHandle methods.
* `Name` can optionally be specified with a string literal type to preserve type-level knowledge of the signal name.

@@ -37,7 +62,6 @@ */

declare const retBrand: unique symbol;
/**
* An interface representing a Workflow query definition as returned from {@link defineQuery}
*
* @remarks `Args` and `Ret` can be used for parameter type inference in handler functions and *WorkflowHandle methods.
* @remarks `Args` and `Ret` can be used for parameter type inference in handler functions and WorkflowHandle methods.
* `Name` can optionally be specified with a string literal type to preserve type-level knowledge of the query name.

@@ -44,0 +68,0 @@ */

/** TLS configuration options. */
export interface TLSConfig {
/**
* Overrides the target name used for SSL host name checking.
* If this attribute is not specified, the name used for SSL host name checking will be the host from {@link ServerOptions.url}.
* This _should_ be used for testing only.
* Overrides the target name (SNI) used for TLS host name checking.
* If this attribute is not specified, the name used for TLS host name checking will be the host from {@link ServerOptions.url}.
* This can be useful when you have reverse proxy in front of temporal server, and you may want to override the SNI to
* direct traffic to the appropriate backend server based on custom routing rules. Oppositely, connections could be refused
* if the provided SNI does not match the expected host. Adding this override should be done with care.
*/

@@ -8,0 +10,0 @@ serverNameOverride?: string;

@@ -143,1 +143,24 @@ /** Shorthand alias */

}
// Thanks MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
export function deepFreeze<T>(object: T): T {
// Retrieve the property names defined on object
const propNames = Object.getOwnPropertyNames(object);
// Freeze properties before freezing self
for (const name of propNames) {
const value = (object as any)[name];
if (value && typeof value === 'object') {
try {
deepFreeze(value);
} catch (err) {
// This is okay, there are some typed arrays that cannot be frozen (encodingKeys)
}
} else if (typeof value === 'function') {
Object.freeze(value);
}
}
return Object.freeze(object);
}
/**
* Indicates whether the user intends certain commands to be run on a compatible worker Build Id
* version or not.
* Indicates whether the user intends certain commands to be run on a compatible worker Build Id version or not.
*
* `COMPATIBLE` indicates that the command should run on a worker with compatible version if
* possible. It may not be possible if the target task queue does not also have knowledge of the
* current worker's Build Id.
* `COMPATIBLE` indicates that the command should run on a worker with compatible version if possible. It may not be
* possible if the target task queue does not also have knowledge of the current worker's Build Id.
*
* `DEFAULT` indicates that the command should run on the target task queue's current
* overall-default Build Id.
* `DEFAULT` indicates that the command should run on the target task queue's current overall-default Build Id.
*
* Where this type is accepted optionally, an unset value indicates that the SDK should choose the
* most sensible default behavior for the type of command, accounting for whether the command will
* be run on the same task queue as the current worker.
* Where this type is accepted optionally, an unset value indicates that the SDK should choose the most sensible default
* behavior for the type of command, accounting for whether the command will be run on the same task queue as the
* current worker. The default behavior for starting Workflows is `DEFAULT`. The default behavior for Workflows starting
* Activities, starting Child Workflows, or Continuing As New is `COMPATIBLE`.
*

@@ -16,0 +14,0 @@ * @experimental

@@ -1,6 +0,6 @@

import type { temporal, google } from '@temporalio/proto';
import type { temporal } from '@temporalio/proto';
import { SearchAttributes, Workflow } from './interfaces';
import { RetryPolicy } from './retry-policy';
import { Duration, msOptionalToTs } from './time';
import { checkExtends, Replace } from './type-helpers';
import { Duration } from './time';
import { checkExtends } from './type-helpers';

@@ -138,22 +138,2 @@ // Avoid importing the proto implementation to reduce workflow bundle size

export type WithCompiledWorkflowOptions<T extends CommonWorkflowOptions> = Replace<
T,
{
workflowExecutionTimeout?: google.protobuf.IDuration;
workflowRunTimeout?: google.protobuf.IDuration;
workflowTaskTimeout?: google.protobuf.IDuration;
}
>;
export function compileWorkflowOptions<T extends CommonWorkflowOptions>(options: T): WithCompiledWorkflowOptions<T> {
const { workflowExecutionTimeout, workflowRunTimeout, workflowTaskTimeout, ...rest } = options;
return {
...rest,
workflowExecutionTimeout: msOptionalToTs(workflowExecutionTimeout),
workflowRunTimeout: msOptionalToTs(workflowRunTimeout),
workflowTaskTimeout: msOptionalToTs(workflowTaskTimeout),
};
}
export function extractWorkflowType<T extends Workflow>(workflowTypeOrFunc: string | T): string {

@@ -160,0 +140,0 @@ if (typeof workflowTypeOrFunc === 'string') return workflowTypeOrFunc as string;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc