New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@5minds/processcube_engine_client

Package Overview
Dependencies
Maintainers
0
Versions
726
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@5minds/processcube_engine_client - npm Package Compare versions

Comparing version 6.0.0-renovate-cd84fb-m5aajsdm to 6.0.0-renovate-da69ed-m7fdkroq

dist/commonjs/IdentityAccessorClientCredentials.js

5

dist/Clients/FlowNodeInstanceHttpClient.d.ts

@@ -11,3 +11,6 @@ import { DataModels, IFlowNodeInstanceExtensionAdapter } from '@5minds/processcube_engine_sdk';

}): Promise<DataModels.FlowNodeInstances.FlowNodeInstanceList>;
finishUntypedTask(taskInstanceId: string, identity?: IdentityLike): Promise<void>;
/**
* @param useLegacyEndpoint If true, will use the old "Empty Activity" Socket.IO Endpoint for receiving the notification.
*/
finishUntypedTask(taskInstanceId: string, identity?: IdentityLike, useLegacyEndpoint?: boolean): Promise<void>;
finishManualTask(manualTaskInstanceId: string, identity?: IdentityLike): Promise<void>;

@@ -14,0 +17,0 @@ finishUserTask(userTaskInstanceId: string, userTaskResult: DataModels.FlowNodeInstances.UserTaskResult, identity?: IdentityLike): Promise<void>;

@@ -102,2 +102,6 @@ import { INotificationExtensionAdapter, Messages, Subscription } from '@5minds/processcube_engine_sdk';

identity?: IdentityLike;
/**
* If true, will use the old "Empty Activity" Socket.IO Endpoint for receiving the notification.
*/
useLegacyEndpoint?: boolean;
}): Promise<Subscription>;

@@ -107,2 +111,6 @@ onUntypedTaskFinished(callback: Messages.CallbackTypes.OnUntypedTaskFinishedCallback, options?: {

identity?: IdentityLike;
/**
* If true, will use the old "Empty Activity" Socket.IO Endpoint for receiving the notification.
*/
useLegacyEndpoint?: boolean;
}): Promise<Subscription>;

@@ -109,0 +117,0 @@ onManualTaskWaiting(callback: Messages.CallbackTypes.OnManualTaskWaitingCallback, options?: {

13

dist/Clients/UntypedTaskHttpClient.d.ts

@@ -11,6 +11,13 @@ import { FlowNodeInstanceSortSettings, IUntypedTaskExtensionAdapter, Messages, Subscription, UntypedTaskList, UntypedTaskQuery } from '@5minds/processcube_engine_sdk';

}): Promise<UntypedTaskList>;
finishTask(taskInstanceId: string, identity?: IdentityLike): Promise<void>;
/**
* @param useLegacyEndpoint If true, will use the old "Empty Activity" Socket.IO Endpoint for receiving the notification.
*/
finishTask(taskInstanceId: string, identity?: IdentityLike, useLegacyEndpoint?: boolean): Promise<void>;
onUntypedTaskWaiting(callback: Messages.CallbackTypes.OnUntypedTaskWaitingCallback, options?: {
subscribeOnce?: boolean;
identity?: IdentityLike;
/**
* If true, will use the old "Empty Activity" Socket.IO Endpoint for receiving the notification.
*/
useLegacyEndpoint?: boolean;
}): Promise<Subscription>;

@@ -20,4 +27,8 @@ onUntypedTaskFinished(callback: Messages.CallbackTypes.OnUntypedTaskFinishedCallback, options?: {

identity?: IdentityLike;
/**
* If true, will use the old "Empty Activity" Socket.IO Endpoint for receiving the notification.
*/
useLegacyEndpoint?: boolean;
}): Promise<Subscription>;
removeSubscription(subscription: Subscription, identity?: IdentityLike): void;
}

@@ -18,5 +18,10 @@ "use strict";

}
async finishUntypedTask(taskInstanceId, identity) {
/**
* @param useLegacyEndpoint If true, will use the old "Empty Activity" Socket.IO Endpoint for receiving the notification.
*/
async finishUntypedTask(taskInstanceId, identity, useLegacyEndpoint) {
const requestAuthHeaders = await this.createRequestAuthHeaders(identity);
const urlRestPart = index_1.restSettings.paths.finishUntypedTask.replace(index_1.restSettings.params.untypedTaskInstanceId, taskInstanceId);
const urlRestPart = useLegacyEndpoint === true
? index_1.restSettings.paths.finishEmptyActivity.replace(index_1.restSettings.params.emptyActivityInstanceId, taskInstanceId)
: index_1.restSettings.paths.finishUntypedTask.replace(index_1.restSettings.params.untypedTaskInstanceId, taskInstanceId);
const url = this.buildUrl(urlRestPart);

@@ -23,0 +28,0 @@ await this.httpClient.put(url, {}, requestAuthHeaders);

@@ -83,5 +83,11 @@ "use strict";

async onUntypedTaskWaiting(callback, options) {
if (options?.useLegacyEndpoint === true) {
return this.createSocketIoSubscription(index_1.socketSettings.paths.emptyActivityWaiting, callback, options?.subscribeOnce, options?.identity);
}
return this.createSocketIoSubscription(index_1.socketSettings.paths.untypedTaskWaiting, callback, options?.subscribeOnce, options?.identity);
}
async onUntypedTaskFinished(callback, options) {
if (options?.useLegacyEndpoint === true) {
return this.createSocketIoSubscription(index_1.socketSettings.paths.emptyActivityFinished, callback, options?.subscribeOnce, options?.identity);
}
return this.createSocketIoSubscription(index_1.socketSettings.paths.untypedTaskFinished, callback, options?.subscribeOnce, options?.identity);

@@ -88,0 +94,0 @@ }

@@ -23,5 +23,10 @@ "use strict";

}
async finishTask(taskInstanceId, identity) {
/**
* @param useLegacyEndpoint If true, will use the old "Empty Activity" Socket.IO Endpoint for receiving the notification.
*/
async finishTask(taskInstanceId, identity, useLegacyEndpoint) {
const requestAuthHeaders = await this.createRequestAuthHeaders(identity);
const urlRestPart = index_1.restSettings.paths.finishUntypedTask.replace(index_1.restSettings.params.untypedTaskInstanceId, taskInstanceId);
const urlRestPart = useLegacyEndpoint === true
? index_1.restSettings.paths.finishEmptyActivity.replace(index_1.restSettings.params.emptyActivityInstanceId, taskInstanceId)
: index_1.restSettings.paths.finishUntypedTask.replace(index_1.restSettings.params.untypedTaskInstanceId, taskInstanceId);
const url = this.buildUrl(urlRestPart);

@@ -31,5 +36,11 @@ await this.httpClient.put(url, {}, requestAuthHeaders);

async onUntypedTaskWaiting(callback, options) {
if (options?.useLegacyEndpoint === true) {
return this.createSocketIoSubscription(index_1.socketSettings.paths.emptyActivityWaiting, callback, options?.subscribeOnce, options?.identity);
}
return this.createSocketIoSubscription(index_1.socketSettings.paths.untypedTaskWaiting, callback, options?.subscribeOnce, options?.identity);
}
async onUntypedTaskFinished(callback, options) {
if (options?.useLegacyEndpoint === true) {
return this.createSocketIoSubscription(index_1.socketSettings.paths.emptyActivityFinished, callback, options?.subscribeOnce, options?.identity);
}
return this.createSocketIoSubscription(index_1.socketSettings.paths.untypedTaskFinished, callback, options?.subscribeOnce, options?.identity);

@@ -36,0 +47,0 @@ }

@@ -12,11 +12,10 @@ "use strict";

topic;
abortSignal;
abortExecutionController = new AbortController();
customErrorHandler;
onHeartbeatCallback = null;
interval;
abortSignalSubscription;
awaitAbortSignal;
abortSignalResolver;
identityAccessor;
logger;
constructor(externalTask, processingFunction, externalTaskClient, config, topic, abortSignal, customErrorHandler) {
isDisposed = false;
constructor(externalTask, processingFunction, externalTaskClient, config, topic, onHeartbeatCallback, customErrorHandler) {
this.externalTask = externalTask;

@@ -28,3 +27,3 @@ this.processingFunction = processingFunction;

this.topic = topic;
this.abortSignal = abortSignal;
this.onHeartbeatCallback = onHeartbeatCallback;
this.customErrorHandler = customErrorHandler;

@@ -37,92 +36,147 @@ this.logger = new processcube_engine_sdk_1.Logger('external_task_execution', {

}
get disposed() {
return this.isDisposed;
}
async execute() {
try {
this.abortSignal.throwIfAborted();
this.startAbortSignalSubscription();
this.startExtendLockInterval();
const result = await Promise.race([this.processingFunction(this.externalTask.payload, this.externalTask, this.abortSignal), this.awaitAbortSignal]);
this.abortSignal.throwIfAborted();
this.stopLockingInterval();
if (typeof this.onHeartbeatCallback === 'function') {
this.onHeartbeatCallback('processExternalTask', this.externalTask.id);
}
const result = await this.processingFunction(this.externalTask.payload, this.externalTask, this.abortExecutionController.signal);
this.stopExtendLockInterval();
if (this.abortExecutionController.signal.aborted) {
return;
}
if (result) {
await this.processResult(result);
}
this.dispose();
}
catch (error) {
this.handleError('processExternalTask', error);
this.logger.error(`Error raised for external task '${this.externalTask.id}' with topic '${this.topic}': `, { err: error });
await this.evaluateError('processExternalTask', error);
await this.handleExternalTaskExecutionError(error);
}
finally {
this.dispose();
}
}
abort() {
this.logger.debug(`Abort Signal has been triggered for External Task Executor ${this.externalTask.id}`);
this.dispose();
}
async dispose() {
this.logger.debug(`Disposong Executor for External Task ${this.externalTask.id}`);
this.stopExtendLockInterval();
if (!this.abortExecutionController.signal.aborted) {
this.abortExecutionController.abort();
}
this.isDisposed = true;
// we explicitly do not dispose the identityAccessor here, since it is shared with the ExternalTaskWorker
}
async processResult(result) {
if (this.abortExecutionController.signal.aborted) {
return;
}
this.logger.trace(`Processing External Task Result ${this.externalTask.id}`, { externalTask: this.externalTask, result: result });
try {
if (result instanceof processcube_engine_sdk_1.ExternalTaskError || result instanceof Error) {
this.logger.trace(`External Task Result ${this.externalTask.id} is an error. The task will be finished as failed.`, { externalTask: this.externalTask, result: result });
return await this.handleExternalTaskExecutionError(result);
}
return await this.externalTaskClient.finishExternalTask(this.config.workerId, this.externalTask.id, result, await this.identityAccessor.getIdentity(), this.abortSignal);
if (typeof this.onHeartbeatCallback === 'function') {
this.onHeartbeatCallback('finishExternalTask', this.externalTask.id);
}
this.logger.trace(`Finishing ${this.externalTask.id} regularly.`, { externalTask: this.externalTask, result: result });
return await this.externalTaskClient.finishExternalTask(this.config.workerId, this.externalTask.id, result, await this.identityAccessor.getIdentity(), this.abortExecutionController.signal);
}
catch (error) {
this.handleError('finishExternalTask', error);
const errorIsRetryable = await this.evaluateError('finishExternalTask', error);
if (errorIsRetryable && !this.abortExecutionController.signal.aborted) {
await this.sleep(1000);
return await this.processResult(result);
}
}
}
async handleExternalTaskExecutionError(error) {
if (this.abortSignal.aborted) {
if (this.abortExecutionController.signal.aborted) {
return;
}
this.logger.error(`Error raised for external task '${this.externalTask.id}' with topic '${this.topic}': `, { err: error });
const workerError = new processcube_engine_sdk_1.ExternalTaskError(error?.errorCode || error?.name || 'ExternalTaskExecutionError', error?.errorMessage || error?.message || 'An error occurred while processing the external task.', error?.errorDetails || error?.stack || 'No error details available.');
return await this.externalTaskClient.handleError(this.config.workerId, this.externalTask.id, workerError, await this.identityAccessor.getIdentity());
}
async dispose() {
this.removeAbortSignalSubscription();
this.stopLockingInterval();
// we explicitly do not dispose the identityAccessor here, since it is shared with the ExternalTaskWorker
}
stopLockingInterval() {
if (this.interval) {
clearInterval(this.interval);
this.interval = undefined;
try {
this.logger.trace(`Reporting Error for External Task ${this.externalTask.id} to Engine`);
const workerError = new processcube_engine_sdk_1.ExternalTaskError(error?.errorCode || error?.name || 'ExternalTaskExecutionError', error?.errorMessage || error?.message || 'An error occurred while processing the external task.', error?.errorDetails || error?.stack || 'No error details available.');
if (typeof this.onHeartbeatCallback === 'function') {
this.onHeartbeatCallback('handleError', this.externalTask.id);
}
return await this.externalTaskClient.handleError(this.config.workerId, this.externalTask.id, workerError, await this.identityAccessor.getIdentity());
}
}
startAbortSignalSubscription() {
this.awaitAbortSignal = new Promise((resolve) => (this.abortSignalResolver = resolve));
this.abortSignalSubscription = () => {
if (this.abortSignalResolver) {
this.abortSignalResolver();
catch (error) {
const errorIsRetryable = await this.evaluateError('finishExternalTask', error);
if (errorIsRetryable && !this.abortExecutionController.signal.aborted) {
await this.sleep(1000);
return await this.handleExternalTaskExecutionError(error);
}
this.dispose();
};
this.abortSignal.addEventListener('abort', this.abortSignalSubscription);
}
removeAbortSignalSubscription() {
if (this.abortSignalSubscription) {
this.abortSignal.removeEventListener('abort', this.abortSignalSubscription);
}
if (this.abortSignalResolver) {
this.abortSignalResolver();
}
}
startExtendLockInterval() {
const lockExtensionBuffer = 5000;
this.logger.trace(`Starting automatic Lock extension for External Task ${this.externalTask.id}`);
this.interval = setInterval(async () => this.extendLocks(this.externalTask), this.config.lockDuration - lockExtensionBuffer);
}
async extendLocks(externalTask) {
if (this.abortExecutionController.signal.aborted) {
return;
}
if (typeof this.onHeartbeatCallback === 'function') {
this.onHeartbeatCallback('extendLock', this.externalTask.id);
}
try {
await this.externalTaskClient.extendLock(this.config.workerId, externalTask.id, this.config.lockDuration, await this.identityAccessor.getIdentity(), this.abortSignal);
this.logger.debug(`Extending Lock on External Task ${this.externalTask.id}`);
await this.externalTaskClient.extendLock(this.config.workerId, externalTask.id, this.config.lockDuration, await this.identityAccessor.getIdentity(), this.abortExecutionController.signal);
}
catch (error) {
this.handleError('extendLock', error);
// This can happen, if the lock-extension was performed after the task was already finished.
// Since this isn't really an error, a warning suffices here.
this.logger.warn(`An error occured while trying to extend the lock for ExternalTask ${externalTask.id}`, { err: error });
const errorIsRetryable = await this.evaluateError('extendLock', error);
if (errorIsRetryable && !this.abortExecutionController.signal.aborted) {
await this.sleep(1000);
await this.extendLocks(externalTask);
}
}
}
handleError(errorType, error) {
stopExtendLockInterval() {
this.logger.debug(`Disposing automatic Lock Extension for External Task ${this.externalTask.id}`);
if (this.interval) {
clearInterval(this.interval);
this.interval = undefined;
}
}
async evaluateError(errorType, error) {
if (this.abortExecutionController.signal.aborted) {
return false;
}
if (typeof this.customErrorHandler === 'function') {
this.logger.trace(`Posting error for external task ${this.externalTask.id} to subscribed custom error handlers`, { errorType: errorType, err: error });
this.customErrorHandler(errorType, error, this.externalTask);
}
if (error.code === 409) {
this.logger.warn(`Failed to run ${errorType} for External Task ${this.externalTask.id} because the task has already been finished. Aborting now, since there is nothing more to do here.`, { err: error });
this.abort();
return false;
}
this.logger.warn(`An error occured while executing ${errorType} for External Task ${this.externalTask.id}`, { err: error });
if (error.message?.match(/expired/i) && this.identityAccessor.canIdentityBeRefreshed()) {
this.logger.info('Identity has expired. Refreshing identity to get a new auth token...');
await this.identityAccessor.forceImmediateIdentityRefresh();
this.logger.info('Identity refresh completed. Retrying to process External Task now.');
return true;
}
return false;
}
async sleep(milliseconds) {
return new Promise((resolve) => {
setTimeout(() => {
resolve();
}, milliseconds);
});
}
}
exports.ExternalTaskExecution = ExternalTaskExecution;
//# sourceMappingURL=ExternalTaskExecution.js.map

@@ -55,4 +55,6 @@ "use strict";

customErrorHandler = null;
onHeartbeatCallback = null;
abortController;
abortSignal;
activelyProcessedExternalTasks = {};
constructor(engineUrl, topic, processingFunction, config) {

@@ -93,2 +95,11 @@ this._workerId = config?.workerId ?? uuid.v4();

}
onHeartbeat(callback) {
this.onHeartbeatCallback = callback;
}
getActiveExternalTasks() {
return Object.keys(this.activelyProcessedExternalTasks);
}
isExternalTaskBeingProcessed(externalTaskId) {
return this.activelyProcessedExternalTasks[externalTaskId] != null;
}
start() {

@@ -98,2 +109,6 @@ this._pollingActive = true;

this.abortSignal = this.abortController.signal;
this.abortSignal.onabort = () => {
Object.values(this.activelyProcessedExternalTasks).forEach((executor) => executor.abort());
this.activelyProcessedExternalTasks = {};
};
this.processExternalTasks();

@@ -107,3 +122,10 @@ }

}
abortExternalTaskIfPresent(externalTaskId) {
if (this.activelyProcessedExternalTasks[externalTaskId] != null) {
this.activelyProcessedExternalTasks[externalTaskId].abort();
delete this.activelyProcessedExternalTasks[externalTaskId];
}
}
dispose() {
this.stop();
this.externalTaskClient.dispose();

@@ -120,2 +142,5 @@ this.identityAccessor?.dispose();

errorCount = 0;
if (typeof this.onHeartbeatCallback === 'function') {
this.onHeartbeatCallback('fetchAndLock');
}
}

@@ -127,2 +152,7 @@ catch (error) {

logger.error('Failed to fetch and lock External Tasks.', { err: error });
if (error.message?.match(/expired/i) && this.identityAccessor.canIdentityBeRefreshed()) {
logger.info('Identity has expired. Refreshing identity to get a new auth token...');
await this.identityAccessor.forceImmediateIdentityRefresh();
logger.info('Identity refresh completed. Fetch and Lock will continue.');
}
errorCount++;

@@ -159,3 +189,4 @@ const timeoutOffset = (Math.floor(Math.random() * 10) + 1) * 30;

workerId: this.workerId,
}, this.topic, this.abortSignal, this.customErrorHandler);
}, this.topic, this.onHeartbeatCallback, this.customErrorHandler);
this.activelyProcessedExternalTasks[externalTask.id] = externalTaskExecution;
await externalTaskExecution.execute();

@@ -169,2 +200,5 @@ }

}
finally {
delete this.activelyProcessedExternalTasks[externalTask.id];
}
}

@@ -171,0 +205,0 @@ async sleep(milliseconds) {

@@ -41,2 +41,3 @@ "use strict";

const async_lock_1 = __importDefault(require("async-lock"));
const dayjs_1 = __importDefault(require("dayjs"));
const uuid = __importStar(require("uuid"));

@@ -87,2 +88,3 @@ const processcube_engine_sdk_1 = require("@5minds/processcube_engine_sdk");

identityAvailableReject;
refreshFailedCritically = false;
refreshTimeout;

@@ -116,3 +118,3 @@ disposed = false;

initialize() {
this.refreshIdentityIfNeeded();
this.fetchIdentity().then(() => this.refreshIdentityPeriodically());
}

@@ -125,2 +127,5 @@ getId() {

}
canIdentityBeRefreshed() {
return this.isDynamicRefreshObject && this.expirationTimeInMs > 0 && !this.refreshFailedCritically && !this.disposed;
}
async getIdentity() {

@@ -130,2 +135,10 @@ await this.waitUntilIdentityIsAvailable();

}
async forceImmediateIdentityRefresh() {
if (!this.isDynamicRefreshObject) {
return;
}
clearTimeout(this.refreshTimeout);
await this.fetchIdentity();
this.refreshIdentityPeriodically();
}
/**

@@ -167,8 +180,28 @@ * This method only waits the first time the identity is retrieved from any remote source to ensure no missing references occur.

}
async refreshIdentityIfNeeded() {
refreshIdentityPeriodically() {
clearTimeout(this.refreshTimeout);
if (this.canIdentityBeRefreshed()) {
const timeUntilNextRefresh = Math.max((this.expirationTimeInMs ?? 0) - Date.now() - this.getBaseMinRefreshTimeInMs(), this.getBaseMinRefreshTimeInMs());
const timeUntilNextRefresh32Bit = Math.min(timeUntilNextRefresh, 2147483647);
this.logger.debug(`Current Identity will expire at ${(0, dayjs_1.default)()
.add(this.expirationTimeInMs ?? 0, 'milliseconds')
.toISOString()}`);
this.logger.debug(`Next Refresh will be performed at ${(0, dayjs_1.default)().add(timeUntilNextRefresh32Bit, 'milliseconds').toISOString()}`);
this.refreshTimeout = setTimeout(async () => {
await this.fetchIdentity();
this.refreshIdentityPeriodically();
}, timeUntilNextRefresh32Bit);
}
else if (this.refreshFailedCritically) {
this.logger.error(`Identity refresh failed critically and won't be refreshed anymore.`);
this.identityAvailableReject(new Error('Identity refresh failed critically and wont be refreshed anymore.'));
}
}
async fetchIdentity() {
await this.asyncLock.acquire('refreshIdentity', async () => {
clearTimeout(this.refreshTimeout);
let failedCritically = false;
this.refreshFailedCritically = false;
try {
this.logger.debug('Fetching new identity');
this.latestIdentity = await this.identityGetter();
this.logger.trace('New Identity fetched');
if (this.latestIdentity == dummyIdentity || this.latestIdentity?.token == dummyIdentity.token) {

@@ -182,11 +215,8 @@ this.expirationTimeInMs = 0;

this.identityAvailableResolve();
const announceNewIdentity = async () => {
try {
await Promise.all(this.newIdentityCallbacks.map((cb) => cb(this.latestIdentity)));
}
catch (err) {
this.logger.warn('Error while refreshing identity', { err });
}
};
announceNewIdentity();
try {
await Promise.all(this.newIdentityCallbacks.map((cb) => cb(this.latestIdentity)));
}
catch (err) {
this.logger.warn('Error while publishing new identity to listeners', { err });
}
}

@@ -199,18 +229,6 @@ else {

this.logger.error('Error while refreshing identity', { err });
failedCritically =
this.refreshFailedCritically =
!err.message ||
!['ETIMEDOUT', 'ECONNRESET', 'ECONNREFUSED', 'other side closed', 'SocketError', 'EAI_AGAIN', 'EHOSTUNREACH', 'EPIPE', 'ECONNABORTED', 'EHOSTDOWN'].some((errorString) => err.message.includes(errorString));
}
const canBeRefreshed = this.expirationTimeInMs > 0 && !failedCritically && !this.disposed && this.isDynamicRefreshObject;
if (canBeRefreshed) {
const timeUntilNextRefresh = Math.max((this.expirationTimeInMs ?? 0) - Date.now() - this.getBaseMinRefreshTimeInMs(), this.getBaseMinRefreshTimeInMs());
const timeUntilNextRefresh32Bit = Math.min(timeUntilNextRefresh, 2147483647);
this.refreshTimeout = setTimeout(() => {
this.refreshIdentityIfNeeded();
}, timeUntilNextRefresh32Bit);
}
else if (failedCritically) {
this.logger.error('Identity refresh failed critically and wont be refreshed anymore.');
this.identityAvailableReject(new Error('Identity refresh failed critically and wont be refreshed anymore.'));
}
});

@@ -217,0 +235,0 @@ }

@@ -25,4 +25,4 @@ "use strict";

Object.defineProperty(exports, "IdentityAccessor", { enumerable: true, get: function () { return IdentityAccessor_1.IdentityAccessor; } });
var ClientCredentialsIdentityAccessor_1 = require("./ClientCredentialsIdentityAccessor");
Object.defineProperty(exports, "ClientCredentialsIdentityAccessor", { enumerable: true, get: function () { return ClientCredentialsIdentityAccessor_1.ClientCredentialsIdentityAccessor; } });
var IdentityAccessorClientCredentials_1 = require("./IdentityAccessorClientCredentials");
Object.defineProperty(exports, "ClientCredentialsIdentityAccessor", { enumerable: true, get: function () { return IdentityAccessorClientCredentials_1.ClientCredentialsIdentityAccessor; } });
var processcube_engine_sdk_1 = require("@5minds/processcube_engine_sdk");

@@ -29,0 +29,0 @@ Object.defineProperty(exports, "BpmnType", { enumerable: true, get: function () { return processcube_engine_sdk_1.BpmnType; } });

@@ -9,2 +9,4 @@ "use strict";

untypedTaskInstanceId: ':untyped_task_instance_id',
// Deprecated version of "untypedTaskInstanceId"
emptyActivityInstanceId: ':empty_activity_instance_id',
// Id of an Event.

@@ -154,2 +156,9 @@ eventId: ':event_id',

/**
* Finishes a specific EmptyActivity by its InstanceId. Deprecated, use "finish Untyped Task" instead
* @tags EmptyActivity
* @deprecated
* @method put
*/
finishEmptyActivity: `/empty_activities/${params.emptyActivityInstanceId}/finish`,
/**
* Finishes a specific UntypedTask by its InstanceId.

@@ -566,2 +575,16 @@ * @tags UntypedTask

/**
* Wait for an UntypedTaskWaiting notification and resolves with the notification's content.
* @tags Notifications
* @method get
* @responseType EventMessage
*/
onUntypedTaskWaiting: '/notifications/long_polling/empty_activity_waiting',
/**
* Wait for an UntypedTaskFinished notification and resolves with the notification's content.
* @tags Notifications
* @method get
* @responseType EventMessage
*/
onUntypedTaskFinished: '/notifications/long_polling/empty_activity_finished',
/**
* Wait for a ManualTaskWaiting notification and resolves with the notification's content.

@@ -568,0 +591,0 @@ * @tags Notifications

@@ -20,2 +20,4 @@ "use strict";

cronjobUpdated: 'cronjob_updated',
emptyActivityWaiting: 'empty_activity_waiting',
emptyActivityFinished: 'empty_activity_finished',
untypedTaskWaiting: 'untyped_task_waiting',

@@ -22,0 +24,0 @@ untypedTaskFinished: 'untyped_task_finished',

import { ExternalTask } from '@5minds/processcube_engine_sdk';
import { ExternalTaskApiClient } from './Clients';
import { ExternalTaskWorkerHeartbeat } from './ExternalTaskWorker';
import { HandleExternalTaskAction, IExternalTaskWorkerConfig, WorkerErrorHandler } from './Types';

@@ -10,21 +11,21 @@ export declare class ExternalTaskExecution<TExternalTaskPayload, TResultPayload extends object> {

private topic;
private abortSignal;
private abortExecutionController;
private customErrorHandler?;
private onHeartbeatCallback;
private interval;
private abortSignalSubscription;
private awaitAbortSignal;
private abortSignalResolver;
private identityAccessor;
private logger;
constructor(externalTask: ExternalTask<TExternalTaskPayload>, processingFunction: HandleExternalTaskAction<TExternalTaskPayload, TResultPayload>, externalTaskClient: ExternalTaskApiClient, config: IExternalTaskWorkerConfig, topic: string, abortSignal: AbortSignal, customErrorHandler?: WorkerErrorHandler);
private isDisposed;
constructor(externalTask: ExternalTask<TExternalTaskPayload>, processingFunction: HandleExternalTaskAction<TExternalTaskPayload, TResultPayload>, externalTaskClient: ExternalTaskApiClient, config: IExternalTaskWorkerConfig, topic: string, onHeartbeatCallback?: ExternalTaskWorkerHeartbeat, customErrorHandler?: WorkerErrorHandler);
get disposed(): boolean;
execute(): Promise<void>;
abort(): void;
private dispose;
private processResult;
private handleExternalTaskExecutionError;
private dispose;
private stopLockingInterval;
private startAbortSignalSubscription;
private removeAbortSignalSubscription;
private startExtendLockInterval;
private extendLocks;
private handleError;
private stopExtendLockInterval;
private evaluateError;
private sleep;
}
import { Identity } from '@5minds/processcube_engine_sdk';
import { HandleExternalTaskAction, IExternalTaskWorkerConfig, WorkerErrorHandler } from './Types/index';
export type ExternalTaskWorkerHeartbeat = (operation?: 'fetchAndLock' | 'processExternalTask' | 'extendLock' | 'finishExternalTask' | 'handleError', externalTaskId?: string) => void;
export declare class ExternalTaskWorker<TExternalTaskPayload, TResultPayload extends object> {

@@ -15,4 +16,6 @@ private readonly _workerId;

private customErrorHandler;
private onHeartbeatCallback;
private abortController;
private abortSignal;
private activelyProcessedExternalTasks;
constructor(engineUrl: string, topic: string, processingFunction: HandleExternalTaskAction<TExternalTaskPayload, TResultPayload>, config?: IExternalTaskWorkerConfig);

@@ -31,4 +34,8 @@ /**

onWorkerError(callback: WorkerErrorHandler): void;
onHeartbeat(callback: ExternalTaskWorkerHeartbeat): void;
getActiveExternalTasks(): string[];
isExternalTaskBeingProcessed(externalTaskId: string): boolean;
start(): void;
stop(): void;
abortExternalTaskIfPresent(externalTaskId: string): void;
dispose(): void;

@@ -35,0 +42,0 @@ private processExternalTasks;

@@ -20,5 +20,6 @@ import { Identity, Logger } from '@5minds/processcube_engine_sdk';

private identityAvailableReject;
private refreshTimeout;
private disposed;
private isDynamicRefreshObject;
protected refreshFailedCritically: boolean;
protected refreshTimeout: NodeJS.Timeout;
protected disposed: boolean;
protected isDynamicRefreshObject: boolean;
protected logger: Logger;

@@ -31,3 +32,5 @@ private newIdentityCallbacks;

getIdentitySync(): Identity;
canIdentityBeRefreshed(): boolean;
getIdentity(): Promise<Identity>;
forceImmediateIdentityRefresh(): Promise<void>;
/**

@@ -50,4 +53,5 @@ * This method only waits the first time the identity is retrieved from any remote source to ensure no missing references occur.

protected getBaseMinRefreshTimeInMs(): number;
private refreshIdentityIfNeeded;
private refreshIdentityPeriodically;
private fetchIdentity;
private getDecodedToken;
}

@@ -7,3 +7,3 @@ export * from './Client';

export { ClientCredentialsConfig, IdentityAccessor, IdentityLike } from './IdentityAccessor';
export { ClientCredentialsIdentityAccessor } from './ClientCredentialsIdentityAccessor';
export { ClientCredentialsIdentityAccessor } from './IdentityAccessorClientCredentials';
export { BpmnType, DataModels, EventType, Identity, Model, EventReceivedCallback, Subscription } from '@5minds/processcube_engine_sdk';

@@ -5,2 +5,3 @@ export declare const restSettings: {

untypedTaskInstanceId: string;
emptyActivityInstanceId: string;
eventId: string;

@@ -131,2 +132,9 @@ eventName: string;

/**
* Finishes a specific EmptyActivity by its InstanceId. Deprecated, use "finish Untyped Task" instead
* @tags EmptyActivity
* @deprecated
* @method put
*/
finishEmptyActivity: string;
/**
* Finishes a specific UntypedTask by its InstanceId.

@@ -537,2 +545,16 @@ * @tags UntypedTask

/**
* Wait for an UntypedTaskWaiting notification and resolves with the notification's content.
* @tags Notifications
* @method get
* @responseType EventMessage
*/
onUntypedTaskWaiting: string;
/**
* Wait for an UntypedTaskFinished notification and resolves with the notification's content.
* @tags Notifications
* @method get
* @responseType EventMessage
*/
onUntypedTaskFinished: string;
/**
* Wait for a ManualTaskWaiting notification and resolves with the notification's content.

@@ -539,0 +561,0 @@ * @tags Notifications

@@ -19,2 +19,4 @@ export declare const socketSettings: {

cronjobUpdated: string;
emptyActivityWaiting: string;
emptyActivityFinished: string;
untypedTaskWaiting: string;

@@ -21,0 +23,0 @@ untypedTaskFinished: string;

@@ -7,3 +7,3 @@ {

"name": "@5minds/processcube_engine_client",
"version": "6.0.0-renovate-cd84fb-m5aajsdm",
"version": "6.0.0-renovate-da69ed-m7fdkroq",
"description": "Contains a typescript based client for accessing the Engine.",

@@ -43,6 +43,7 @@ "main": "dist/commonjs/index.js",

"dependencies": {
"@5minds/processcube_engine_sdk": "6.1.0-alpha.6",
"@5minds/processcube_engine_sdk": "6.1.0-alpha.9",
"async-lock": "^1.4.1",
"bufferutil": "4.0.9",
"cross-fetch": "4.1.0",
"dayjs": "^1.11.13",
"openid-client": "^6.1.7",

@@ -49,0 +50,0 @@ "socket.io-client": "4.8.1",

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

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