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

@temporalio/common

Package Overview
Dependencies
Maintainers
4
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 0.2.0 to 0.3.0

lib/workflow-handle.d.ts

57

CHANGELOG.md

@@ -6,2 +6,59 @@ # Change Log

# [0.3.0](https://github.com/temporalio/sdk-node/compare/@temporalio/common@0.2.0...@temporalio/common@0.3.0) (2021-09-15)
* feat!: Use Object instead of Map for interceptor headers ([80db27d](https://github.com/temporalio/sdk-node/commit/80db27d62bad78a71352cdc5db2b9ca49b9d1062))
* feat(workflow)!: Remove Local and Remote ActivityOptions ([d29844d](https://github.com/temporalio/sdk-node/commit/d29844d992e61354297ca660d0b103e39001f519))
* feat(workflow)!: Revise Workflow API ([3467bd7](https://github.com/temporalio/sdk-node/commit/3467bd798f5e6866412be67c0b0e645e1d66dd7f))
### BREAKING CHANGES
* Interceptors now use an Object for representing headers
instead of a Map
With this change it's easier to chain interceptors without mutating the
input.
* `ActivityOptions` no longer take a `type` attribute.
`LocalActivityOptions` and `RemoteActivityOptions` interfaces have been
removed.
* Workflow registration and invocation has been changed
- `main` has been renamed `execute`
- Workflow arguments moved from `execute` method to the Workflow factory
function (see below)
- Workflows are now defined as named functions
Old:
```ts
// workflows/myWorkflow.ts
export const workflow = { async main(...args) {}, /* signals, queries */ };
```
New:
```ts
// workflows/index.ts
export const myWorkflow = (...args) => ({ async execute() {}, /* signals, queries */ });
```
- Workflow Interceptors are now instantiated via a factory function
Old:
```ts
export const interceptors = { /* ... */ };
```
New:
```ts
export const interceptors = () => ({ /* ... */ });
```
- Workflow stubs can be constructed from a registered Workflow function
Old:
```ts
const stub = client.stub<MyWorkflowInterface>('my-workflow', opts);
```
New:
```ts
import { myWorkflow } from './workflows';
const stub = client.stub(myWorkflow, opts);
```
# [0.2.0](https://github.com/temporalio/sdk-node/compare/@temporalio/common@0.1.0...@temporalio/common@0.2.0) (2021-08-31)

@@ -8,0 +65,0 @@

21

lib/activity-options.d.ts

@@ -5,22 +5,7 @@ import { coresdk } from '@temporalio/proto/lib/coresdk';

/**
* Options for local activity invocation - will be processed by the worker running the calling workflow.
*
* **Not yet implemented**
*/
export interface LocalActivityOptions {
/**
* Indicates this is a local activity invocation
*/
type: 'local';
}
/**
* Options for remote activity invocation - will be processed from a task queue.
* @see https://www.javadoc.io/doc/io.temporal/temporal-sdk/latest/io/temporal/activity/ActivityOptions.Builder.html
*/
export interface RemoteActivityOptions {
export interface ActivityOptions {
/**
* Indicates this is a remote activity invocation.
*/
type: 'remote';
/**
* Identifier to use for tracking the activity in Workflow history.

@@ -87,6 +72,2 @@ * The `activityId` can be accessed by the activity function.

}
/**
* Used to configure the way activities are run
*/
export declare type ActivityOptions = RemoteActivityOptions | LocalActivityOptions;
export interface ActivityFunction<P extends any[], R> {

@@ -93,0 +74,0 @@ (...args: P): Promise<R>;

@@ -11,3 +11,3 @@ /**

export * from './workflow-options';
export * from './workflow-stub';
export * from './workflow-handle';
export * from './converter/data-converter';

@@ -14,0 +14,0 @@ export * from './interceptors';

@@ -23,3 +23,3 @@ "use strict";

__exportStar(require("./workflow-options"), exports);
__exportStar(require("./workflow-stub"), exports);
__exportStar(require("./workflow-handle"), exports);
__exportStar(require("./converter/data-converter"), exports);

@@ -26,0 +26,0 @@ __exportStar(require("./interceptors"), exports);

@@ -10,3 +10,3 @@ import { coresdk } from '@temporalio/proto/lib/coresdk';

/** Headers are just a mapping of header name to Payload */
export declare type Headers = Map<string, coresdk.common.IPayload>;
export declare type Headers = Record<string, coresdk.common.IPayload>;
/**

@@ -13,0 +13,0 @@ * Composes all interceptor methods into a single function

@@ -1,9 +0,10 @@

export declare type WorkflowReturnType = any;
/** Type that can be returned from a Workflow `execute` function */
export declare type WorkflowReturnType = Promise<any>;
export declare type WorkflowSignalType = (...args: any[]) => Promise<void> | void;
export declare type WorkflowQueryType = (...args: any[]) => any;
/**
* Generic workflow interface, extend this in order to validate your workflow interface definitions
* Generic Workflow execute, signal, and query handlers
*/
export interface Workflow {
main(...args: any[]): WorkflowReturnType;
export interface WorkflowHandlers {
execute(): WorkflowReturnType;
signals?: Record<string, WorkflowSignalType>;

@@ -13,2 +14,14 @@ queries?: Record<string, WorkflowQueryType>;

/**
* Generic workflow interface, extend this in order to validate your workflow interface definitions
*/
export declare type Workflow = (...args: any[]) => WorkflowHandlers;
/** Get the execute handler from Workflow interface `W` */
export declare type WorkflowExecuteHandler<W extends Workflow> = ReturnType<W>['execute'];
/** Get the return type of the execute handler from Workflow interface `W` */
export declare type WorkflowResultType<W extends Workflow> = ReturnType<WorkflowExecuteHandler<W>>;
/** Get the signal handler definitions from Workflow interface `W` */
export declare type WorkflowSignalHandlers<W extends Workflow> = ReturnType<W>['signals'];
/** Get the query handler definitions from Workflow interface `W` */
export declare type WorkflowQueryHandlers<W extends Workflow> = ReturnType<W>['queries'];
/**
* Defines options for activity retries

@@ -15,0 +28,0 @@ * @see {@link https://www.javadoc.io/doc/io.temporal/temporal-sdk/latest/io/temporal/common/RetryOptions.Builder.html | Java SDK definition}

{
"name": "@temporalio/common",
"version": "0.2.0",
"version": "0.3.0",
"description": "Temporal.io SDK common library for use in Workflow and normal code",

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

"dependencies": {
"@temporalio/proto": "^0.3.1",
"@temporalio/proto": "^0.3.2",
"ms": "^2.1.3"

@@ -27,3 +27,3 @@ },

},
"gitHead": "254e9f5793afc11cb5fb64a9829b1c55190092f0"
"gitHead": "23da8507a90049774cc6ddd28a8ec3dfc37d345f"
}

@@ -7,24 +7,7 @@ import { coresdk } from '@temporalio/proto/lib/coresdk';

/**
* Options for local activity invocation - will be processed by the worker running the calling workflow.
*
* **Not yet implemented**
*/
export interface LocalActivityOptions {
/**
* Indicates this is a local activity invocation
*/
type: 'local';
}
/**
* Options for remote activity invocation - will be processed from a task queue.
* @see https://www.javadoc.io/doc/io.temporal/temporal-sdk/latest/io/temporal/activity/ActivityOptions.Builder.html
*/
export interface RemoteActivityOptions {
export interface ActivityOptions {
/**
* Indicates this is a remote activity invocation.
*/
type: 'remote';
/**
* Identifier to use for tracking the activity in Workflow history.

@@ -99,7 +82,2 @@ * The `activityId` can be accessed by the activity function.

/**
* Used to configure the way activities are run
*/
export type ActivityOptions = RemoteActivityOptions | LocalActivityOptions;
export interface ActivityFunction<P extends any[], R> {

@@ -106,0 +84,0 @@ (...args: P): Promise<R>;

@@ -11,3 +11,3 @@ /**

export * from './workflow-options';
export * from './workflow-stub';
export * from './workflow-handle';
export * from './converter/data-converter';

@@ -14,0 +14,0 @@ export * from './interceptors';

@@ -12,3 +12,3 @@ import { coresdk } from '@temporalio/proto/lib/coresdk';

/** Headers are just a mapping of header name to Payload */
export type Headers = Map<string, coresdk.common.IPayload>;
export type Headers = Record<string, coresdk.common.IPayload>;

@@ -15,0 +15,0 @@ /**

@@ -1,2 +0,3 @@

export type WorkflowReturnType = any;
/** Type that can be returned from a Workflow `execute` function */
export type WorkflowReturnType = Promise<any>;
export type WorkflowSignalType = (...args: any[]) => Promise<void> | void;

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

/**
* Generic workflow interface, extend this in order to validate your workflow interface definitions
* Generic Workflow execute, signal, and query handlers
*/
export interface Workflow {
main(...args: any[]): WorkflowReturnType;
export interface WorkflowHandlers {
execute(): WorkflowReturnType;
signals?: Record<string, WorkflowSignalType>;

@@ -16,2 +17,16 @@ queries?: Record<string, WorkflowQueryType>;

/**
* Generic workflow interface, extend this in order to validate your workflow interface definitions
*/
export type Workflow = (...args: any[]) => WorkflowHandlers;
/** Get the execute handler from Workflow interface `W` */
export type WorkflowExecuteHandler<W extends Workflow> = ReturnType<W>['execute'];
/** Get the return type of the execute handler from Workflow interface `W` */
export type WorkflowResultType<W extends Workflow> = ReturnType<WorkflowExecuteHandler<W>>;
/** Get the signal handler definitions from Workflow interface `W` */
export type WorkflowSignalHandlers<W extends Workflow> = ReturnType<W>['signals'];
/** Get the query handler definitions from Workflow interface `W` */
export type WorkflowQueryHandlers<W extends Workflow> = ReturnType<W>['queries'];
/**
* Defines options for activity retries

@@ -18,0 +33,0 @@ * @see {@link https://www.javadoc.io/doc/io.temporal/temporal-sdk/latest/io/temporal/common/RetryOptions.Builder.html | Java SDK definition}

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