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

@temporalio/workflow

Package Overview
Dependencies
Maintainers
4
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@temporalio/workflow - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

3

commonjs/errors.d.ts

@@ -43,2 +43,5 @@ import * as iface from '@temporalio/proto';

}
/**
* Used in different parts of the project to signal that something unexpected has happened
*/
export declare class IllegalStateError extends Error {

@@ -45,0 +48,0 @@ readonly name: string;

4

commonjs/errors.js

@@ -57,3 +57,5 @@ "use strict";

exports.CancellationError = CancellationError;
/// Used in different parts of the project to signal to the user that they've done something wrong
/**
* Used in different parts of the project to signal that something unexpected has happened
*/
class IllegalStateError extends Error {

@@ -60,0 +62,0 @@ constructor() {

@@ -24,2 +24,15 @@ /**

*
* ### Signals
*
* To add signal handlers to a workflow, add a signals property to the exported workflow object.
* Signal handlers can return either `void` or `Promise<void>`, you may schedule activities and timers from a signal handler.
*
* #### Interface
* <!--SNIPSTART nodejs-workflow-signal-interface-->
* <!--SNIPEND-->
*
* #### Implementation
* <!--SNIPSTART nodejs-workflow-signal-implementation-->
* <!--SNIPEND-->
*
* ### Deterministic built-ins

@@ -26,0 +39,0 @@ * It is safe to call `Math.random()` and `Date()` in workflow code as they are replaced with deterministic versions. We also provide a deterministic {@link uuid4} function for convenience.

@@ -25,2 +25,15 @@ "use strict";

*
* ### Signals
*
* To add signal handlers to a workflow, add a signals property to the exported workflow object.
* Signal handlers can return either `void` or `Promise<void>`, you may schedule activities and timers from a signal handler.
*
* #### Interface
* <!--SNIPSTART nodejs-workflow-signal-interface-->
* <!--SNIPEND-->
*
* #### Implementation
* <!--SNIPSTART nodejs-workflow-signal-implementation-->
* <!--SNIPEND-->
*
* ### Deterministic built-ins

@@ -27,0 +40,0 @@ * It is safe to call `Math.random()` and `Date()` in workflow code as they are replaced with deterministic versions. We also provide a deterministic {@link uuid4} function for convenience.

@@ -55,4 +55,5 @@ import * as iface from '@temporalio/proto';

queryWorkflow(activation: iface.coresdk.workflow_activation.IQueryWorkflow): void;
signalWorkflow(_activation: iface.coresdk.workflow_activation.ISignalWorkflow): void;
signalWorkflow(activation: iface.coresdk.workflow_activation.ISignalWorkflow): void;
updateRandomSeed(activation: iface.coresdk.workflow_activation.IUpdateRandomSeed): void;
removeFromCache(): void;
}

@@ -59,0 +60,0 @@ /**

@@ -179,4 +179,27 @@ "use strict";

}
signalWorkflow(_activation) {
throw new Error('Not implemented');
signalWorkflow(activation) {
if (exports.state.workflow === undefined) {
throw new Error('state.workflow is not defined');
}
const { signals } = exports.state.workflow;
if (signals === undefined) {
throw new Error('Workflow did not define any signals');
}
if (!activation.signalName) {
throw new Error('Missing activation signalName');
}
const fn = signals[activation.signalName];
if (fn === undefined) {
throw new Error(`Workflow did not register a signal named ${activation.signalName}`);
}
try {
// TODO: support custom converter
const retOrPromise = fn(...data_converter_1.arrayFromPayloads(data_converter_1.defaultDataConverter, activation.input));
if (retOrPromise instanceof Promise) {
retOrPromise.catch(failWorkflow);
}
}
catch (err) {
failWorkflow(err);
}
}

@@ -189,2 +212,5 @@ updateRandomSeed(activation) {

}
removeFromCache() {
throw new errors_1.IllegalStateError('removeFromCache activation job should not reach workflow');
}
}

@@ -191,0 +217,0 @@ exports.Activator = Activator;

@@ -43,2 +43,5 @@ import * as iface from '@temporalio/proto';

}
/**
* Used in different parts of the project to signal that something unexpected has happened
*/
export declare class IllegalStateError extends Error {

@@ -45,0 +48,0 @@ readonly name: string;

@@ -48,3 +48,5 @@ export class WorkflowExecutionTerminatedError extends Error {

}
/// Used in different parts of the project to signal to the user that they've done something wrong
/**
* Used in different parts of the project to signal that something unexpected has happened
*/
export class IllegalStateError extends Error {

@@ -51,0 +53,0 @@ constructor() {

@@ -24,2 +24,15 @@ /**

*
* ### Signals
*
* To add signal handlers to a workflow, add a signals property to the exported workflow object.
* Signal handlers can return either `void` or `Promise<void>`, you may schedule activities and timers from a signal handler.
*
* #### Interface
* <!--SNIPSTART nodejs-workflow-signal-interface-->
* <!--SNIPEND-->
*
* #### Implementation
* <!--SNIPSTART nodejs-workflow-signal-implementation-->
* <!--SNIPEND-->
*
* ### Deterministic built-ins

@@ -26,0 +39,0 @@ * It is safe to call `Math.random()` and `Date()` in workflow code as they are replaced with deterministic versions. We also provide a deterministic {@link uuid4} function for convenience.

@@ -24,2 +24,15 @@ /**

*
* ### Signals
*
* To add signal handlers to a workflow, add a signals property to the exported workflow object.
* Signal handlers can return either `void` or `Promise<void>`, you may schedule activities and timers from a signal handler.
*
* #### Interface
* <!--SNIPSTART nodejs-workflow-signal-interface-->
* <!--SNIPEND-->
*
* #### Implementation
* <!--SNIPSTART nodejs-workflow-signal-implementation-->
* <!--SNIPEND-->
*
* ### Deterministic built-ins

@@ -26,0 +39,0 @@ * It is safe to call `Math.random()` and `Date()` in workflow code as they are replaced with deterministic versions. We also provide a deterministic {@link uuid4} function for convenience.

@@ -55,4 +55,5 @@ import * as iface from '@temporalio/proto';

queryWorkflow(activation: iface.coresdk.workflow_activation.IQueryWorkflow): void;
signalWorkflow(_activation: iface.coresdk.workflow_activation.ISignalWorkflow): void;
signalWorkflow(activation: iface.coresdk.workflow_activation.ISignalWorkflow): void;
updateRandomSeed(activation: iface.coresdk.workflow_activation.IUpdateRandomSeed): void;
removeFromCache(): void;
}

@@ -59,0 +60,0 @@ /**

@@ -6,3 +6,3 @@ import Long from 'long';

import { alea } from './alea';
import { CancellationError } from './errors';
import { CancellationError, IllegalStateError } from './errors';
import { errorToUserCodeFailure } from './common';

@@ -155,4 +155,27 @@ import { tsToMs, nullToUndefined } from './time';

}
signalWorkflow(_activation) {
throw new Error('Not implemented');
signalWorkflow(activation) {
if (state.workflow === undefined) {
throw new Error('state.workflow is not defined');
}
const { signals } = state.workflow;
if (signals === undefined) {
throw new Error('Workflow did not define any signals');
}
if (!activation.signalName) {
throw new Error('Missing activation signalName');
}
const fn = signals[activation.signalName];
if (fn === undefined) {
throw new Error(`Workflow did not register a signal named ${activation.signalName}`);
}
try {
// TODO: support custom converter
const retOrPromise = fn(...arrayFromPayloads(defaultDataConverter, activation.input));
if (retOrPromise instanceof Promise) {
retOrPromise.catch(failWorkflow);
}
}
catch (err) {
failWorkflow(err);
}
}

@@ -165,2 +188,5 @@ updateRandomSeed(activation) {

}
removeFromCache() {
throw new IllegalStateError('removeFromCache activation job should not reach workflow');
}
}

@@ -167,0 +193,0 @@ /**

{
"name": "@temporalio/workflow",
"version": "0.1.4",
"description": "Temporal.io Workflow SDK",
"version": "0.1.5",
"description": "Temporal.io SDK Workflow sub-package",
"main": "./commonjs/index.js",

@@ -17,3 +17,3 @@ "types": "./commonjs/index.d.ts",

"dependencies": {
"@temporalio/proto": "^0.1.4"
"@temporalio/proto": "^0.1.5"
},

@@ -23,3 +23,3 @@ "bugs": {

},
"homepage": "https://github.com/temporalio/sdk-node#readme",
"homepage": "https://github.com/temporalio/sdk-node/tree/main/packages/workflow",
"files": [

@@ -32,3 +32,3 @@ "es2020",

},
"gitHead": "cd169da9d8223a141bde5e1837a8ccf0d34911af"
"gitHead": "04add82114c495399c4c5d438ea1ce161673fd8b"
}
# `@temporalio/workflow`
[![NPM](https://img.shields.io/npm/v/@temporalio/workflow)](https://www.npmjs.com/package/@temporalio/workflow)
[![NPM](https://img.shields.io/npm/v/@temporalio/workflow?style=for-the-badge)](https://www.npmjs.com/package/@temporalio/workflow)
Part of the [Temporal](https://temporal.io) [NodeJS SDK](https://www.npmjs.com/package/temporalio).
See documentation on the [documentation site](https://docs.temporal.io/docs/node/reference/README).
See documentation on the [documentation site](https://docs.temporal.io/docs/node/introduction).
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