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

camunda-external-task-client-js

Package Overview
Dependencies
Maintainers
4
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

camunda-external-task-client-js - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1

.eslintignore

4

CHANGELOG.md
# Changelog
## 2.2.1
### Features
- Bump multiple dependencies in JS external task client ([#2801](https://github.com/camunda/camunda-bpm-platform/issues/2801))
## 2.2.0

@@ -4,0 +8,0 @@ ### Features

2

index.js

@@ -24,3 +24,3 @@ /*

Variables: require("./lib/Variables"),
File: require("./lib/File")
File: require("./lib/File"),
};

@@ -18,3 +18,3 @@ /*

const { GotError } = require("got");
const got = require("got");

@@ -27,3 +27,3 @@ /**

* This error isn't extendable, because it sets the error message in the constructor. Therefore we inherit from the
* got base error type (`got.GotError`), copy the logic form the `got.HTTPError` class and extend it with our API
* got base error type (`got.RequestError`), copy the logic form the `got.HTTPError` class and extend it with our API
* response message.

@@ -33,3 +33,3 @@ *

*/
class EngineError extends GotError {
class EngineError extends got.RequestError {
constructor(httpError) {

@@ -56,3 +56,3 @@ const { response, options } = httpError;

enumerable: false,
value: response
value: response,
});

@@ -59,0 +59,0 @@ }

@@ -23,18 +23,17 @@ /*

test("construct an error from a Camunda REST API error", () => {
//given
const httpError = new got.HTTPError(
{
body: { type: "SomeExceptionClass", message: "a detailed message" },
statusCode: 400,
statusMessage: "Bad request"
},
{}
);
// given
const response = {
body: { type: "SomeExceptionClass", message: "a detailed message" },
statusCode: 400,
statusMessage: "Bad request",
};
const httpError = new got.HTTPError(response);
httpError.response = response;
const expectedPayload =
"Response code 400 (Bad request); Error: a detailed message; Type: SomeExceptionClass";
//when
// when
const engineError = new EngineError(httpError);
//then
// then
expect(engineError.message).toEqual(expectedPayload);

@@ -44,20 +43,19 @@ });

test("construct an error with an unexpected response body", () => {
//given
const httpError = new got.HTTPError(
{
body: "Some unexpected error message",
statusCode: 400,
statusMessage: "Bad request"
},
{}
);
// given
const response = {
body: "Some unexpected error message",
statusCode: 400,
statusMessage: "Bad request",
};
const httpError = new got.HTTPError(response);
httpError.response = response;
const expectedPayload =
"Response code 400 (Bad request); Error: Some unexpected error message; Type: undefined";
//when
// when
const engineError = new EngineError(httpError);
//then
// then
expect(engineError.message).toEqual(expectedPayload);
});
});

@@ -52,3 +52,3 @@ /*

...newOptions,
responseType: "buffer"
responseType: "buffer",
});

@@ -96,3 +96,3 @@ if (headers["content-type"] === "application/json") {

return this.post("/external-task/fetchAndLock", {
json: { ...requestBody, workerId: this.workerId }
json: { ...requestBody, workerId: this.workerId },
});

@@ -110,3 +110,3 @@ }

return this.post(`/external-task/${id}/complete`, {
json: { workerId: this.workerId, variables, localVariables }
json: { workerId: this.workerId, variables, localVariables },
});

@@ -123,3 +123,3 @@ }

return this.post(`/external-task/${id}/failure`, {
json: { ...options, workerId: this.workerId }
json: { ...options, workerId: this.workerId },
});

@@ -138,3 +138,3 @@ }

return this.post(`/external-task/${id}/bpmnError`, {
json: { errorCode, workerId: this.workerId, errorMessage, variables }
json: { errorCode, workerId: this.workerId, errorMessage, variables },
});

@@ -153,4 +153,4 @@ }

lockDuration,
workerId: this.workerId
}
workerId: this.workerId,
},
});

@@ -167,3 +167,3 @@ }

return this.post(`/external-task/${id}/extendLock`, {
json: { newDuration, workerId: this.workerId }
json: { newDuration, workerId: this.workerId },
});

@@ -170,0 +170,0 @@ }

@@ -28,3 +28,3 @@ /*

workerId: "someWorker",
baseUrl: "some/baseUrl"
baseUrl: "some/baseUrl",
});

@@ -36,10 +36,10 @@ postSpy = jest.spyOn(engineService, "post");

test("post should call request with url and payload", () => {
//given
// given
const expectedUrl = "some/url";
const expectedPayload = { key: "some value" };
//when
// when
engineService.post(expectedUrl, expectedPayload);
//then
// then
expect(requestSpy).toBeCalledWith("POST", expectedUrl, expectedPayload);

@@ -49,10 +49,10 @@ });

test("get should call request with url and payload", () => {
//given
// given
const expectedUrl = "some/url";
const expectedPayload = { key: "some value" };
//when
// when
engineService.get(expectedUrl, expectedPayload);
//then
// then
expect(requestSpy).toBeCalledWith("GET", expectedUrl, expectedPayload);

@@ -62,7 +62,7 @@ });

test("fetchAndLock", () => {
//given
// given
const expectedUrl = "/external-task/fetchAndLock";
const expectedReqBody = { someKey: "some value" };
const expectedPayload = {
json: { ...expectedReqBody, workerId: engineService.workerId }
json: { ...expectedReqBody, workerId: engineService.workerId },
};

@@ -83,3 +83,3 @@

const expectedLocalVariables = {
someLocalVariable: "some local variable value"
someLocalVariable: "some local variable value",
};

@@ -90,4 +90,4 @@ const expectedPayload = {

variables: expectedVariables,
localVariables: expectedLocalVariables
}
localVariables: expectedLocalVariables,
},
};

@@ -99,3 +99,3 @@

variables: expectedVariables,
localVariables: expectedLocalVariables
localVariables: expectedLocalVariables,
});

@@ -113,3 +113,3 @@

const expectedPayload = {
json: { ...expectedRequestBody, workerId: engineService.workerId }
json: { ...expectedRequestBody, workerId: engineService.workerId },
};

@@ -134,4 +134,4 @@

errorMessage: expectedErrorMessage,
workerId: engineService.workerId
}
workerId: engineService.workerId,
},
};

@@ -158,4 +158,4 @@

newDuration: expectedNewDuration,
workerId: engineService.workerId
}
workerId: engineService.workerId,
},
};

@@ -185,3 +185,3 @@

it("should send request with given options", () => {
//given
// given
const method = "POST";

@@ -193,9 +193,9 @@ const path = "/some/url";

responseType: "buffer",
key: "some value"
key: "some value",
};
//when
// when
engineService.request(method, path, expectedPayload);
//then
// then
expect(got).toBeCalledWith(expectedUrl, expectedPayload);

@@ -205,3 +205,3 @@ });

it("should get request options from interceptors", () => {
//given
// given
const method = "POST";

@@ -213,11 +213,11 @@ const path = "/some/url";

const anotherExpectedAddedPayload = {
anotherNewKey: "another new value"
anotherNewKey: "another new value",
};
const someInterceptor = config => ({
const someInterceptor = (config) => ({
...config,
...someExpectedAddedPayload
...someExpectedAddedPayload,
});
const anotherInterceptor = config => ({
const anotherInterceptor = (config) => ({
...config,
...anotherExpectedAddedPayload
...anotherExpectedAddedPayload,
});

@@ -230,9 +230,9 @@ engineService.interceptors = [someInterceptor, anotherInterceptor];

...anotherExpectedAddedPayload,
responseType: "buffer"
responseType: "buffer",
};
//when
// when
engineService.request(method, path, expectedPayload);
//then
// then
expect(got).toBeCalledWith(expectedUrl, expectedPayload);

@@ -243,10 +243,9 @@ });

// given
const error = new got.HTTPError(
{
body: { type: "SomeExceptionClass", message: "a detailed message" },
statusCode: 400,
statusMessage: "Bad request"
},
{}
);
const response = {
body: { type: "SomeExceptionClass", message: "a detailed message" },
statusCode: 400,
statusMessage: "Bad request",
};
const error = new got.HTTPError(response);
error.response = response;

@@ -253,0 +252,0 @@ // then

@@ -66,3 +66,3 @@ /*

WRONG_MIDDLEWARES,
MISSING_FILE_OPTIONS
MISSING_FILE_OPTIONS,
};

@@ -23,3 +23,3 @@ /*

*/
const isFunction = f => typeof f === "function";
const isFunction = (f) => typeof f === "function";

@@ -37,3 +37,3 @@ /**

*/
const isArrayOfFunctions = a =>
const isArrayOfFunctions = (a) =>
Array.isArray(a) && a.length > 0 && andArrayWith(a, isFunction);

@@ -44,3 +44,3 @@

*/
const isUndefinedOrNull = a => typeof a === "undefined" || a === null;
const isUndefinedOrNull = (a) => typeof a === "undefined" || a === null;

@@ -106,3 +106,3 @@ const typeMatchers = {

return typeof a === "object";
}
},
};

@@ -114,6 +114,6 @@

*/
const getVariableType = variable => {
const match = Object.entries(
typeMatchers
).filter(([matcherKey, matcherFunction]) => matcherFunction(variable))[0];
const getVariableType = (variable) => {
const match = Object.entries(typeMatchers).filter(
([matcherKey, matcherFunction]) => matcherFunction(variable)
)[0];

@@ -137,3 +137,3 @@ return match[0];

processInstanceId,
engineService
engineService,
}) => {

@@ -188,3 +188,3 @@ let { value, type } = { ...typedValue };

serializeVariable,
deserializeVariable
deserializeVariable,
};

@@ -26,3 +26,3 @@ /*

deserializeVariable,
serializeVariable
serializeVariable,
} = require("./utils");

@@ -46,3 +46,3 @@

it("should apply test function on each element on the array and AND the results", () => {
const biggerThan5 = a => a > 5;
const biggerThan5 = (a) => a > 5;
const arr1 = [1, 2, 3, 4];

@@ -159,3 +159,3 @@ const arr2 = [6, 7, 8, 9];

type: "json",
valueInfo: {}
valueInfo: {},
};

@@ -177,3 +177,3 @@ let expectedTypedValue = { ...typedValue, value: parsedValue };

processInstanceId: "process_instance_id",
engineService: {}
engineService: {},
};

@@ -197,3 +197,3 @@ let result = deserializeVariable(options);

type: "Date",
valueInfo: {}
valueInfo: {},
};

@@ -221,7 +221,7 @@

type: "json",
valueInfo: {}
valueInfo: {},
};
let expectedTypedValue = {
...typedValue,
value: JSON.stringify(parsedValue)
value: JSON.stringify(parsedValue),
};

@@ -241,3 +241,3 @@

type: "json",
valueInfo: {}
valueInfo: {},
};

@@ -282,3 +282,3 @@

type: "Date",
valueInfo: {}
valueInfo: {},
};

@@ -285,0 +285,0 @@

@@ -38,3 +38,3 @@ /*

username: "some username",
password: "some password"
password: "some password",
});

@@ -44,5 +44,5 @@ const config = { key: "some value" };

//then
// then
expect(headers).toMatchSnapshot();
});
});

@@ -29,3 +29,3 @@ /*

WRONG_INTERCEPTOR,
WRONG_MIDDLEWARES
WRONG_MIDDLEWARES,
} = require("./__internal/errors");

@@ -36,3 +36,3 @@

isArrayOfFunctions,
isUndefinedOrNull
isUndefinedOrNull,
} = require("./__internal/utils");

@@ -46,3 +46,3 @@

lockDuration: 50000,
autoPoll: true
autoPoll: true,
};

@@ -89,3 +89,3 @@

if (this.options.use) {
this.options.use.forEach(f => f(this));
this.options.use.forEach((f) => f(this));
}

@@ -162,3 +162,3 @@

asyncResponseTimeout,
maxParallelExecutions
maxParallelExecutions,
} = this.options;

@@ -177,3 +177,3 @@

maxTasks: requiredTasksCount,
usePriority: usePriority
usePriority: usePriority,
};

@@ -205,4 +205,4 @@ if (asyncResponseTimeout) {

withoutTenantId,
localVariables
}
localVariables,
},
]) => {

@@ -287,3 +287,3 @@ let topic = { topicName, lockDuration };

//handles the case if there is no options being
// handles the case if there is no options being
if (typeof customOptions === "function") {

@@ -306,3 +306,3 @@ handler = customOptions;

lockDuration,
...customOptions
...customOptions,
};

@@ -324,3 +324,3 @@ topicSubscriptions[topic] = topicSubscription;

processInstanceId: task.processInstanceId,
engineService: this.engineService
engineService: this.engineService,
});

@@ -327,0 +327,0 @@

@@ -27,5 +27,13 @@ /*

MISSING_HANDLER,
WRONG_MIDDLEWARES
WRONG_MIDDLEWARES,
} = require("./__internal/errors");
// workaround for https://github.com/facebook/jest/issues/2157
const flushPromises = () =>
new Promise(jest.requireActual("timers").setImmediate);
const advanceTimersByTime = async (msToRun) => {
await flushPromises();
return jest.advanceTimersByTime(msToRun);
};
jest.mock("got");

@@ -39,3 +47,3 @@ jest.mock("../lib/Variables");

interval: 100,
lockDuration: 30000
lockDuration: 30000,
};

@@ -59,10 +67,10 @@

//then
// then
expect(pollSpy).toHaveBeenCalled();
});
test("should call itself again after timeout when there are no topic subscriptions", () => {
test("should call itself again after timeout when there are no topic subscriptions", async () => {
// when
client.start();
jest.advanceTimersByTime(customClientOptions.interval);
await advanceTimersByTime(customClientOptions.interval);

@@ -73,4 +81,4 @@ // then

test("should not call itself again after timeout when there are registered client", () => {
//given
test("should not call itself again after timeout when there are registered client", async () => {
// given
client.subscribe("foo", () => {});

@@ -80,6 +88,6 @@

client.start();
jest.advanceTimersByTime(customClientOptions.interval);
await advanceTimersByTime(customClientOptions.interval);
// then
expect(pollSpy).toHaveBeenCalledTimes(1);
expect(pollSpy).toHaveBeenCalledTimes(2);
});

@@ -94,8 +102,6 @@

client.start();
jest.advanceTimersByTime(customClientOptions.interval);
await advanceTimersByTime(customClientOptions.interval);
//then
// then
expect(fetchAndLockSpy).toBeCalled();
await engineService.fetchAndLock({});
jest.advanceTimersByTime(customClientOptions.interval);
expect(pollSpy).toHaveBeenCalledTimes(2);

@@ -106,3 +112,3 @@ });

describe("when autoPoll is true", () => {
it("should call itself automatically when autoPoll is true", () => {
it("should call itself automatically when autoPoll is true", async () => {
// given

@@ -112,4 +118,4 @@ const client = new Client({ ...customClientOptions, autoPoll: true });

//when
jest.advanceTimersByTime(2 * customClientOptions.interval);
// when
await advanceTimersByTime(2 * customClientOptions.interval);

@@ -125,7 +131,7 @@ // then

...customClientOptions,
autoPoll: false
autoPoll: false,
});
const fetchSpy = jest.spyOn(client.engineService, "fetchAndLock");
client.subscribe("foo", {}, function() {});
client.subscribe("foo", {}, function () {});
client.start();

@@ -142,7 +148,7 @@

usePriority: false,
autoPoll: false
autoPoll: false,
});
const fetchSpy = jest.spyOn(client.engineService, "fetchAndLock");
client.subscribe("foo", {}, function() {});
client.subscribe("foo", {}, function () {});
client.start();

@@ -162,3 +168,3 @@

autoPoll: false,
maxParallelExecutions: 1
maxParallelExecutions: 1,
});

@@ -173,6 +179,6 @@ const pollSpy = jest.spyOn(client, "poll");

client.subscribe("foo", async () => {
await new Promise(resolve =>
await new Promise((resolve) =>
setTimeout(resolve, customClientOptions.interval)
);
await new Promise(resolve =>
await new Promise((resolve) =>
setTimeout(resolve, 0.5 * customClientOptions.interval)

@@ -185,7 +191,6 @@ );

//then
// then
expect(engineService.fetchAndLock).toBeCalled();
await engineService.get();
jest.advanceTimersByTime(customClientOptions.interval);
await advanceTimersByTime(customClientOptions.interval);

@@ -195,6 +200,3 @@ expect(pollSpy).toHaveBeenCalledTimes(2);

await engineService.get();
jest.advanceTimersByTime(0.5 * customClientOptions.interval);
await engineService.get();
jest.advanceTimersByTime(0.5 * customClientOptions.interval);
await advanceTimersByTime(customClientOptions.interval);

@@ -207,6 +209,6 @@ expect(pollSpy).toHaveBeenCalledTimes(3);

describe("stop", () => {
it("should stop polling", () => {
it("should stop polling", async () => {
// given: we advance time twice then call stop
const client = new Client(customClientOptions);
jest.advanceTimersByTime(2 * customClientOptions.interval);
await advanceTimersByTime(2 * customClientOptions.interval);
client.stop();

@@ -216,3 +218,3 @@ const pollSpy = jest.spyOn(client, "poll");

// when
jest.advanceTimersByTime(2 * customClientOptions.interval);
await advanceTimersByTime(2 * customClientOptions.interval);

@@ -247,3 +249,3 @@ // then

withoutTenantId: true,
localVariables: true
localVariables: true,
};

@@ -476,3 +478,3 @@ });

it("should accept middleware function", () => {
//givena
// givena
const middleware = jest.fn();

@@ -482,3 +484,3 @@ const options = { ...customClientOptions, use: middleware };

//then
// then
expect(middleware).toBeCalledWith(client);

@@ -488,3 +490,3 @@ });

it("should accept middlewares array", () => {
//given
// given
const middlewares = [jest.fn(), jest.fn()];

@@ -494,4 +496,4 @@ const options = { ...customClientOptions, use: middlewares };

//then
middlewares.forEach(middleware =>
// then
middlewares.forEach((middleware) =>
expect(middleware).toBeCalledWith(client)

@@ -498,0 +500,0 @@ );

@@ -82,3 +82,3 @@ /*

value: this.content.toString("base64"),
valueInfo
valueInfo,
};

@@ -85,0 +85,0 @@ }

@@ -33,4 +33,4 @@ /*

mimetype: "application/json",
encoding: "utf-8"
}
encoding: "utf-8",
},
};

@@ -49,3 +49,3 @@ const file = new File({ localPath: "foo", typedValue });

encoding: "utf-8",
localPath: "foo"
localPath: "foo",
};

@@ -66,3 +66,3 @@

.fn()
.mockImplementation(() => Promise.resolve(Buffer.from("", "utf-8")))
.mockImplementation(() => Promise.resolve(Buffer.from("", "utf-8"))),
};

@@ -101,3 +101,3 @@ const remotePath = "some/remote/path";

mimetype: "application/text",
encoding: "utf-8"
encoding: "utf-8",
};

@@ -108,6 +108,6 @@ const value = "this some random value";

type: "file",
valueInfo
valueInfo,
};
const engineService = {
get: jest.fn().mockImplementation(() => Promise.resolve(value))
get: jest.fn().mockImplementation(() => Promise.resolve(value)),
};

@@ -118,3 +118,3 @@ const remotePath = "some/remote/path";

engineService,
...valueInfo
...valueInfo,
}).load();

@@ -121,0 +121,0 @@

@@ -21,3 +21,3 @@ /*

MISSING_KEYCLOAK_AUTH_PARAMS,
UNEXPECTED_KEYCLOAK_TOKEN_RESULT
UNEXPECTED_KEYCLOAK_TOKEN_RESULT,
} = require("./__internal/errors");

@@ -84,5 +84,5 @@

"Content-Type": "application/x-www-form-urlencoded",
Authorization: `Basic: ${credentials}`
Authorization: `Basic: ${credentials}`,
},
body: "grant_type=client_credentials"
body: "grant_type=client_credentials",
}).json();

@@ -136,3 +136,3 @@ } catch (e) {

beforeRequest: [
async options => {
async (options) => {
let token = this.tokenCache;

@@ -151,3 +151,3 @@ if (!token) {

const headers = {
Authorization: `Bearer ${token.access_token}`
Authorization: `Bearer ${token.access_token}`,
};

@@ -163,4 +163,4 @@

}
}
]
},
],
};

@@ -167,0 +167,0 @@

@@ -22,3 +22,3 @@ /*

MISSING_KEYCLOAK_AUTH_PARAMS,
UNEXPECTED_KEYCLOAK_TOKEN_RESULT
UNEXPECTED_KEYCLOAK_TOKEN_RESULT,
} = require("./__internal/errors");

@@ -48,3 +48,3 @@

tokenEndpoint: "some endpoint",
clientId: "some id"
clientId: "some id",
})

@@ -56,3 +56,3 @@ ).toThrowError(MISSING_KEYCLOAK_AUTH_PARAMS);

tokenEndpoint: "some endpoint",
clientSecret: "some secret"
clientSecret: "some secret",
})

@@ -64,3 +64,3 @@ ).toThrowError(MISSING_KEYCLOAK_AUTH_PARAMS);

clientId: "some password",
clientSecret: "some secret"
clientSecret: "some secret",
})

@@ -72,19 +72,14 @@ ).toThrowError(MISSING_KEYCLOAK_AUTH_PARAMS);

// given
got.mockReturnValue({
json: () =>
Promise.reject(
new got.HTTPError(
{
body: "Some keycloak error",
statusCode: 400,
statusMessage: "Bad request"
},
{}
)
)
});
const response = {
body: "Some keycloak error",
statusCode: 400,
statusMessage: "Bad request",
};
const error = new got.HTTPError(response);
error.response = response;
got.mockReturnValue({ json: () => Promise.reject(error) });
const keycloakAuthInterceptor = new KeycloakAuthInterceptor({
tokenEndpoint: "some endpoint",
clientId: "some id",
clientSecret: "some secret"
clientSecret: "some secret",
});

@@ -114,3 +109,3 @@

clientId: "some id",
clientSecret: "some secret"
clientSecret: "some secret",
});

@@ -137,3 +132,3 @@

got.mockReturnValue({
json: () => Promise.resolve({ access_token: "1234567890" })
json: () => Promise.resolve({ access_token: "1234567890" }),
});

@@ -143,3 +138,3 @@ const keycloakAuthInterceptor = new KeycloakAuthInterceptor({

clientId: "some id",
clientSecret: "some secret"
clientSecret: "some secret",
});

@@ -153,3 +148,3 @@ const options = { key: "some value" };

//then
// then
expect(options).toMatchSnapshot();

@@ -166,3 +161,3 @@ });

clientSecret: "some secret",
cacheOffset: 0
cacheOffset: 0,
});

@@ -176,3 +171,3 @@

//then
// then
expect(got).toHaveBeenCalledTimes(1);

@@ -189,3 +184,3 @@ });

clientSecret: "some secret",
cacheOffset: 10
cacheOffset: 10,
});

@@ -199,3 +194,3 @@

//then
// then
expect(got).toHaveBeenCalledTimes(2);

@@ -214,3 +209,3 @@ });

clientSecret: "some secret",
cacheOffset: 0
cacheOffset: 0,
});

@@ -225,3 +220,3 @@

//then
// then
expect(got).toHaveBeenCalledTimes(2);

@@ -228,0 +223,0 @@

@@ -23,3 +23,3 @@ /*

*/
const success = message => `${green("✓")} ${green(message)}`;
const success = (message) => `${green("✓")} ${green(message)}`;

@@ -29,3 +29,3 @@ /**

*/
const error = message => `${red("✖")} ${red(message)}`;
const error = (message) => `${red("✖")} ${red(message)}`;

@@ -38,3 +38,3 @@ const levels = {

debug: 4,
silly: 5
silly: 5,
};

@@ -69,7 +69,7 @@

client.on("subscribe", topic => {
client.on("subscribe", (topic) => {
log("info", success(`subscribed to topic ${topic}`));
});
client.on("unsubscribe", topic => {
client.on("unsubscribe", (topic) => {
log("info", success(`unsubscribed from topic ${topic}`));

@@ -86,3 +86,3 @@ });

client.on("poll:success", tasks => {
client.on("poll:success", (tasks) => {
const output = success(`polled ${tasks.length} tasks`);

@@ -92,3 +92,3 @@ log("debug", output);

client.on("poll:error", e => {
client.on("poll:error", (e) => {
const output = error(`polling failed with ${e}`);

@@ -151,4 +151,4 @@ log("error", output);

*/
const level = level => {
return function(client) {
const level = (level) => {
return function (client) {
logger(client, level);

@@ -155,0 +155,0 @@ };

@@ -22,3 +22,3 @@ /*

MISSING_DURATION,
MISSING_NEW_DURATION
MISSING_NEW_DURATION,
} = require("./__internal/errors");

@@ -25,0 +25,0 @@ const { isUndefinedOrNull } = require("./__internal/utils");

@@ -24,3 +24,3 @@ /*

MISSING_DURATION,
MISSING_NEW_DURATION
MISSING_NEW_DURATION,
} = require("./__internal/errors");

@@ -38,3 +38,3 @@ const TaskService = require("./TaskService");

workerId: "someWorker",
baseUrl: "some/baseUrl"
baseUrl: "some/baseUrl",
});

@@ -98,10 +98,10 @@ taskService = new TaskService(new events(), engineService);

test("should call api complete with provided task", () => {
//given
// given
const completeSpy = jest.spyOn(engineService, "complete");
const expectedTaskId = "foo";
//when
// when
taskService.complete(expectedTaskId);
//then
// then
expect(completeSpy).toBeCalledWith({ id: expectedTaskId });

@@ -111,3 +111,3 @@ });

test("should call api complete with provided variables and localVariables", () => {
//given
// given
const completeSpy = jest.spyOn(engineService, "complete");

@@ -119,4 +119,4 @@ const expectedTaskId = "foo";

type: "string",
valueInfo: {}
}
valueInfo: {},
},
};

@@ -127,4 +127,4 @@ const expectedLocalVariables = {

type: "string",
valueInfo: {}
}
valueInfo: {},
},
};

@@ -136,10 +136,10 @@ const variables = new Variables();

//when
// when
taskService.complete(expectedTaskId, variables, localVariables);
//then
// then
expect(completeSpy).toBeCalledWith({
id: expectedTaskId,
variables: expectedVariables,
localVariables: expectedLocalVariables
localVariables: expectedLocalVariables,
});

@@ -170,3 +170,3 @@ });

test("should call api handleFailure with provided task and error message", () => {
//given
// given
const handleFailureSpy = jest.spyOn(engineService, "handleFailure");

@@ -176,6 +176,6 @@ const expectedPayload = { errorMessage: "some error message" };

//when
// when
taskService.handleFailure(expectedTaskId, expectedPayload);
//then
// then
expect(handleFailureSpy).toBeCalledWith(

@@ -217,3 +217,3 @@ { id: expectedTaskId },

test("should call api handleBpmnError with provided task and error code", () => {
//given
// given
const handleBpmnErrorSpy = jest.spyOn(engineService, "handleBpmnError");

@@ -223,6 +223,6 @@ const expectedTaskId = "foo";

//when
// when
taskService.handleBpmnError(expectedTaskId, expectedErrorCode);
//then
// then
expect(handleBpmnErrorSpy).toBeCalledWith(

@@ -237,3 +237,3 @@ { id: expectedTaskId },

test("should call api handleBpmnError with provided task, error code, error message and variables", () => {
//given
// given
const handleBpmnErrorSpy = jest.spyOn(engineService, "handleBpmnError");

@@ -247,4 +247,4 @@ const expectedTaskId = "foo";

type: "string",
valueInfo: {}
}
valueInfo: {},
},
};

@@ -254,3 +254,3 @@ const variables = new Variables();

//when
// when
taskService.handleBpmnError(

@@ -263,3 +263,3 @@ expectedTaskId,

//then
// then
expect(handleBpmnErrorSpy).toBeCalledWith(

@@ -350,10 +350,10 @@ { id: expectedTaskId },

const lockSpy = jest.spyOn(engineService, "lock");
//given
// given
const expectedTaskId = "foo";
const lockDuration = 42;
//when
// when
await taskService.lock(expectedTaskId, lockDuration);
//then
// then
expect(lockSpy).toHaveBeenCalledWith(

@@ -392,9 +392,9 @@ { id: expectedTaskId },

test("should call api unlock with provided task", () => {
//given
// given
const expectedTaskId = "foo";
//when
// when
taskService.unlock(expectedTaskId);
//then
// then
expect(unlockSpy).toBeCalledWith({ id: expectedTaskId });

@@ -401,0 +401,0 @@ });

@@ -22,3 +22,3 @@ /*

serializeVariable,
deserializeVariable
deserializeVariable,
} = require("./__internal/utils");

@@ -35,3 +35,3 @@

*/
this.getTyped = variableName => {
this.getTyped = (variableName) => {
let typedValue = initialVariables[variableName];

@@ -47,3 +47,3 @@

processInstanceId,
engineService
engineService,
});

@@ -56,3 +56,3 @@ };

*/
this.get = variableName => {
this.get = (variableName) => {
const { value } = { ...this.getTyped(variableName) };

@@ -88,8 +88,7 @@ return value;

this.setTyped = (variableName, typedValue) => {
initialVariables[variableName] = dirtyVariables[
variableName
] = serializeVariable({
key: variableName,
typedValue
});
initialVariables[variableName] = dirtyVariables[variableName] =
serializeVariable({
key: variableName,
typedValue,
});
return this;

@@ -121,3 +120,3 @@ };

value,
valueInfo: { transient: true }
valueInfo: { transient: true },
});

@@ -131,3 +130,3 @@ };

*/
this.setAll = values => {
this.setAll = (values) => {
const self = this;

@@ -145,3 +144,3 @@ Object.entries(values).forEach(([key, value]) => {

*/
this.setAllTyped = typedValues => {
this.setAllTyped = (typedValues) => {
const self = this;

@@ -148,0 +147,0 @@ Object.entries(typedValues).forEach(([key, typedValue]) => {

@@ -49,3 +49,3 @@ /*

value: new Date("2018-01-23T14:42:45.435+0200"),
valueInfo: {}
valueInfo: {},
},

@@ -55,4 +55,4 @@ zex: {

value: null,
valueInfo: {}
}
valueInfo: {},
},
});

@@ -66,3 +66,3 @@

value: file,
valueInfo: {}
valueInfo: {},
});

@@ -110,3 +110,3 @@ });

value: { name: "bazname" },
valueInfo: {}
valueInfo: {},
};

@@ -127,3 +127,3 @@

const typedValues = {
foo: { value: "fooValue", type: "string", valueInfo: {} }
foo: { value: "fooValue", type: "string", valueInfo: {} },
};

@@ -168,3 +168,3 @@ variables.set("bar", "barValue");

foo: "FooValue",
bar: 2
bar: 2,
};

@@ -171,0 +171,0 @@

{
"version": "2.2.0",
"version": "2.2.1",
"name": "camunda-external-task-client-js",

@@ -14,16 +14,16 @@ "main": "index.js",

"devDependencies": {
"eslint": "^4.18.1",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-bpmn-io": "0.4.1",
"eslint-plugin-camunda-licensed": "0.4.2",
"eslint-plugin-jest": "^21.12.2",
"eslint-plugin-prettier": "^2.6.0",
"form-data": "^2.3.2",
"jest": "22.4.2",
"eslint": "^7.32.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-bpmn-io": "^0.14.1",
"eslint-plugin-camunda-licensed": "^0.4.6",
"eslint-plugin-jest": "^27.1.3",
"eslint-plugin-prettier": "^4.2.1",
"form-data": "^4.0.0",
"jest": "^27.5.1",
"license-checker": "^25.0.1",
"prettier": "^1.11.1"
"prettier": "^2.7.1"
},
"dependencies": {
"chalk": "^2.3.2",
"got": "^10.6.0"
"chalk": "^4.1.2",
"got": "^11.8.5"
},

@@ -30,0 +30,0 @@ "description": "Implement your [BPMN Service Task](https://docs.camunda.org/manual/latest/user-guide/process-engine/external-tasks/) in NodeJS.",

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