Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • ProcesioSDK

Index

Constructors

constructor

  • new ProcesioSDK(options?: ConstructorOptions): ProcesioSDK

Properties

Private baseUrl

baseUrl: string = "https://api.procesio.app"

Private portAuth

portAuth: number = 4532

Private portEndpoints

portEndpoints: number = 4321

Optional token

token?: string

Methods

authenticate

  • authenticate(username: string, password: string, authenticationRealm?: string, authenticationClientId?: string): Promise<ProcesioToken>
  • description

    Authenticates the library and returns a token

    remarks

    You should await for the response of this method before proceeding with other methods from this library, as them are dependent on the response provided by the authentication.

    usagenotes

    Authenticate and log the obtained token

    const sdkInstance = new ProcesioSDK();

    const token = await sdkInstance.authenticate('username', 'password');

    console.log(JSON.stringify(token)); // {"access_token":"<hashed_token>", "expires_in":2592000, "refresh_expires_in":2592000, "refresh_token":"<hashed_token>", "token_type":"bearer", "session_state":"5beb683c-3ed7-4f7a-be79-c2d3eb5f4e43", "scope":"email profile", "error":null, "error_description":null}

    Parameters

    • username: string

      The username associated with the account.

    • password: string

      The password associated with the account.

    • authenticationRealm: string = "procesio01"
    • authenticationClientId: string = "procesio-ui"

    Returns Promise<ProcesioToken>

    A Promise which returns an object containing all the necessary informations for authentication, like token or refresh token.

getStatus

  • getStatus(instanceId: string, workspace?: string): Promise<RestResponse<Record<"instance", ProcessInstance>>>
  • Parameters

    • instanceId: string
    • Optional workspace: string

    Returns Promise<RestResponse<Record<"instance", ProcessInstance>>>

launchProcessInstance

  • launchProcessInstance(instanceId: string, isSynchronous?: boolean, workspace?: string): Promise<RestResponse<ProcessInstance | { instanceId: string }>>
  • description

    Calls an endpoint through which you can launch an instance of a process.

    remarks

    Running a process from the PROCESIO platform is done in 3 different steps. publishProcess (generates an instance of a process), uploadFile (required ony for instances that have file inputs) and launchProcessInstance (executes the previously generated instance)

    usagenotes

    Launch an instance of a process which sends an email and log the instance id.

    const sdkInstance = new ProcesioSDK();

    await sdkInstance.authenticate('username', 'password');

    const publishReq = await sdkInstance.publishProcess('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx', {to: "[email protected]", subject: "Process launched via SDK"})

    if (!publishReq.isError && publishReq.content.flows.isValid) {
    const launchReq = await sdkInstance.launchProcessInstance(publish.content.flows.id);

    console.log(launchReq.content?.instanceId); // "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"
    }

    Parameters

    • instanceId: string

      The id of the instance. Can be obtained by publishing a process.

    • isSynchronous: boolean = false

      If true Promise will return result only after the process finishes executing, otherwise after the process starts executing.

    • Optional workspace: string

      The workspace associated with the instance. Optional.

    Returns Promise<RestResponse<ProcessInstance | { instanceId: string }>>

    A Promise which returns an object with they key instanceId.

publishProcess

  • publishProcess(processId: string, inputValues: Record<string, unknown>, workspace?: string): Promise<RestResponse<Record<"flows", ProcessInstance>>>
  • description

    Calls an endpoint through which you can publish a process with the required inputs in order to run that process.

    remarks

    Running a process from the PROCESIO platform is done in 3 different steps. publishProcess (generates an instance of a process), uploadFile (required ony for instances that have file inputs) and launchProcessInstance (executes the previously generated instance)

    usagenotes

    Publish a process which sends an email and log the instance id.

    const sdkInstance = new ProcesioSDK();

    await sdkInstance.authenticate('username', 'password');

    const publishReq = await sdkInstance.publishProcess('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx', {to: "[email protected]", subject: "Process launched via SDK"})

    console.log(publishReq.content.flows.id); // "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"

    Parameters

    • processId: string

      The id of the process. Can be obtained from the PROCESIO platform.

    • inputValues: Record<string, unknown>

      Object which contains all the inputs needed to run a process from the PROCESIO platform. The key of map is the variable name set in the process from the PROCESIO platform. The value of the map is the value of said variable. If a variable is of type file, it's value should be an object with the key name and the value the name of the file

    • Optional workspace: string

      The workspace associated with the process. Optional.

    Returns Promise<RestResponse<Record<"flows", ProcessInstance>>>

    A Promise which returns the instance of the process.

run

  • run(processId: string, inputValues: Record<string, unknown>, isSynchronous?: boolean, workspace?: string): Promise<RestResponse<ProcessInstance | { instanceId: string }>>
  • description

    Calls an endpoint through which you can run a process with the required inputs.

    remarks

    This method only works for processes than don't have file inputs.

    usagenotes

    Runs a process which sends an email and log the instance id.

    const sdkInstance = new ProcesioSDK();

    await sdkInstance.authenticate('username', 'password');

    const runReq = await sdkInstance.run('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx', {to: "[email protected]", subject: "Process launched via SDK"})

    console.log(runReq.content?.instanceId?.id); // "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"

    Parameters

    • processId: string

      The id of the process. Can be obtained from the PROCESIO platform.

    • inputValues: Record<string, unknown>

      Object which contains all the inputs needed to run a process from the PROCESIO platform. The key of map is the variable name set in the process from the PROCESIO platform. The value of the map is the value of said input variable.

    • isSynchronous: boolean = false

      If true Promise will return result only after the process finishes executing, otherwise after the process starts executing.

    • Optional workspace: string

      The workspace associated with the process. Optional.

    Returns Promise<RestResponse<ProcessInstance | { instanceId: string }>>

    A Promise which returns an object with they key instanceId.

runProcess

  • runProcess(processId: string, inputValues: Record<string, unknown>, isSynchronous?: boolean, workspace?: string): Promise<RestResponse<ProcessInstance | { instanceId: string }>>
  • description

    Run a process with the required inputs.

    usagenotes

    Runs a process which sends an email and log the instance id.

    const sdkInstance = new ProcesioSDK();

    await sdkInstance.authenticate('username', 'password');

    const runReq = await sdkInstance.runProcess('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx', {to: "[email protected]", subject: "Process launched via SDK"})

    console.log(runReq.content?.instanceId?.id); // "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"

    Parameters

    • processId: string

      The id of the process. Can be obtained from the PROCESIO platform.

    • inputValues: Record<string, unknown>

      Object which contains all the inputs needed to run a process from the PROCESIO platform. The key of map is the variable name set in the process from the PROCESIO platform. The value of the map is the value of said input variable.

    • isSynchronous: boolean = false
    • Optional workspace: string

      The workspace associated with the process. Optional.

    Returns Promise<RestResponse<ProcessInstance | { instanceId: string }>>

    A Promise which returns an object with they key instanceId.

uploadFile

  • uploadFile(instanceId: string, variableName: string, fileId: string, file: File, workspace?: string): Promise<any>
  • description

    Calls an endpoint through which you can upload a file associated to an input.

    remarks

    Running a process from the PROCESIO platform is done in 3 different steps. publishProcess (generates an instance of a process), uploadFile (required ony for instances that have file inputs) and launchProcessInstance (executes the previously generated instance)

    usagenotes

    Execute a process which sends an email with attachments and log the instance id.

    const sdkInstance = new ProcesioSDK();

    await sdkInstance.authenticate('username', 'password');

    document
    .getElementById("file")
    .addEventListener("change", handleFileSelect, false);

    function handleFileSelect(evt) {
    const files = evt.target.files; // FileList object
    const file = files[0];

    const publishReq = await sdkInstance.publishProcess('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx', {to: "[email protected]", subject: "Process launched via SDK", attachments: {name: file.name}})

    if (!publishReq.isError && publishReq.content.flows.isValid) {
    const fileVariable = publishReq.content.flows.variables.find((variable) => variable.name === "attachments");

    await sdkInstance.uploadFile(publishReq.content.flows.id, fileVariable.name, fileVariable.defaultValue.id, file)

    const launchReq = await sdkInstance.launchProcessInstance(publishReq.content.flows.id);

    console.log(launchReq.content?.instanceId); // "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"
    }
    }

    Parameters

    • instanceId: string

      The id of the instance. Can be obtained by publishing a process.

    • variableName: string

      The name of the input variable.

    • fileId: string

      The id of the file. Can be obtained on the publish response in the in the variable property.

    • file: File
    • workspace: string = ""

      The workspace associated with the instance. Optional.

    Returns Promise<any>

    A Response Promise which returns the id of the file.

Generated using TypeDoc