1.0.9 • Published 2 months ago

@os1-platform/platform-coreos-execution-engine-sdk v1.0.9

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

platform-coreos-execution-engine-sdk

OS1 workflow execution engine sdk for mobile apps. It works with both Android and iOS. With the help of exposed functions, the user and query the next execution task that needs to be executed for an objective. Based on the app's flow, appropriate screen may be rendered to display a given execution task. Optionally, it may be offloaded to the Dispatch SDK (https://github.com/foxtrotplatform/dispatch-sdk) which offers ET screens out-of-the-box. As the app user interacts with the ET screen, the required output is captured and passed to the sdk to save its progress. Internally it manages the objective's state as well as it progress seamlessly. One can also listen to event callback by registering the callback function at the time of sdk initialization.

Installation

npm install @os1-platform/platform-coreos-execution-engine-sdk@latest

Usage

import {
  DispatchExecutor as dispatchExecutor,
  IDispatch,
  IDispatchExecutor,
} from '@os1-platform/platform-coreos-execution-engine-sdk';

/**
 * Init is a one time call to bind the DispatchExecutor to the App via callbacks.
 *
**/
await dispatchExecutor.init({
  // Callback functions
  storeMultipleKeysCallback: async (args: { key: string; value: string}[]): Promise<void> => {
    // App code
  },
  readMultipleKeysCallback: async (keys: string[]): Promise<(string | null)[][]> => {
    // App code
  },
  deleteMultipleKeysCallback: async (keys: string[]): Promise<void> => {
    // App code
  },
  eventBulkSyncCallback: async (input: {
    syncType: any;
    dispatchId: string;
    data: string;
    meta?: any;
  }) => {
    // App code to react to the generated events
  }
},
'debug' // log level - 'debug', 'info', 'warn', 'error'
);

await dispatchExecutor.start('<Dispatch ID>', [
  {
    // A Dispatch job
  }
],
{}, // raw workflow json - workflow ID: data
// optional configuration
{
  maxTaskReattempt: 50,
  eventSyncBatchSize: 10,
}
);

/**
 * Get the list of Objective tasks to be executed at the moment
 * filter by the task status
 * */
await dispatchExecutor.getObjectiveTaskList([
          IDispatchExecutor.ExecutionStatus.READY,
          IDispatchExecutor.ExecutionStatus.IN_PROGRESS,
          IDispatchExecutor.ExecutionStatus.READY,
        ]);

/**
 * Get get ET for an objective task which are either ready or in-progress
 * */
const nextExecutableETs = await dispatchExecutor.getNextTask(moId, [
        IDispatchExecutor.ExecutionStatus.IN_PROGRESS,
        IDispatchExecutor.ExecutionStatus.READY,
      ]);

/**
 * Save the ET's output post execution
 * */
await dispatchExecutor.saveTaskOutput(
        [<List of Objective Task IDs>],
        taskName,
        taskId,
        {
          input, // ET's input data
          output // ET's output data
        }
      );

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Contact

Authors:

  • Shubham Laddha (shubham.laddha@delhivery.com)
  • Upanshu Bhat (upanshu.bhat@delhivery.com)
1.0.9

2 months ago

1.0.8

3 months ago

1.0.7

3 months ago

1.0.6

3 months ago

1.0.5

3 months ago

1.0.4

5 months ago

1.0.3

6 months ago

1.0.2

7 months ago

1.0.1

9 months ago

1.0.0

9 months ago