smartmate-workspace-tools

3.14.4 • Public • Published

smartmate-workspace-tools

A tools library to perform common operations with a Smartmate workspace. It's designed for programmatic usage. If you want a CLI interface, take a look at smartmate-cli instead.

Installation

Include it in your project as a dependency.

yarn add smartmate-workspace-tools or npm install --save smartmate-workspace-tools

Usage

This module provide various classes that you can use:

  • Workspace
  • App
  • Process
  • Table
  • Script

Sample usage

// - Model Workspace:

  // To initialize it:
    const Workspace = require('smartmate-app-tools').Workspace;
    const myWorkspace = new Workspace('/path/to/myWorkspacePth/');

  // To load its apps without running any kind of validation:
    await myWorkspace.load();

  // To get data validated and updated with all correct fields just run:
    await myWorkspace.validate(); // this runs method (load()) internally, so it is not necessary to run both

  // To get JSON data:
    await myWorkspace.toJSON(); // this runs method (validate()) internally, so it is not necessary to run both

  // Other available methods:

  myWorkspace.isLoaded();
  myWorkspace.getPath();
  myWorkspace.getApps();
  myWorkspace.getApp(appId);
  myWorkspace.saveAsZip();

// - Model App:

  // To initialize it:
    const App = require('smartmate-app-tools').App;
    const myApp = new App('/path/to/myAppPth/');

  // To load its models and processes without running any kind of validation:
    await myApp.load();

  // To get data validated and updated with all correct fields just run:
    await myApp.validate(); // this runs method (load()) internally, so it is not necessary to run both

  // To get JSON data:
    await myApp.toJSON(); // this runs method (validate()) internally, so it is not necessary to run both

  // Other available methods:

  myApp.isLoaded();
  myApp.getId();
  myApp.getFilePath();
  myApp.getRootDirectory(appId);
  myApp.getRawData();
  myApp.getTables();
  myApp.getProcesses();
  myApp.getTemplates();
  myApp.getTableByKey();
  myApp.getProcessByKey();
  myApp.getTemplateByKey();
  myApp.hasTables();
  myApp.hasProcesses();
  await myApp.getAllTableFields();
  await myApp.getVarsByProcess();

// - Model Table:

  // To initialize it:
    const Table = require('smartmate-app-tools').Table;
    const myTable = new Table(appId, '/path/to/myTablePth/');
  // or:
    myApp.getTableByKey(tableKey);

  // To load its yml data without running any kind of validation:
    await myTable.load();

  // To get data validated and updated with all correct fields just run:
    await myTable.validate(); // this runs method (load()) internally, so it is not necessary to run both

  // To get JSON data:
    await myTable.toJSON(); // this runs method (validate()) internally, so it is not necessary to run both

  // Other available methods:

  myTable.isLoaded();
  myTable.getKey();
  myTable.getFilePath();
  myTable.getAppId();
  myTable.getRawData();
  myTable.getFullName();
  await myTable.getFieldsWithAdditionalProperties();

// - Model Process:

  // To initialize it:
    const Process = require('smartmate-app-tools').Process;
    const myProcess = new Process(appId, '/path/to/myProcessPth/', tableFields);
  // or:
    myApp.getProcessByKey(processKey);

  // To load its yml data without running any kind of validation:
    await myProcess.load();

  // To get data validated and updated with all correct fields just run:
    await myProcess.validate(); // this runs method (load()) internally, so it is not necessary to run both

  // To get JSON data:
    await myProcess.toJSON(); // this runs method (validate()) internally, so it is not necessary to run both

// - Model BpmFile:

//  To initialize it:
    const myBpmFile = myProcess.getBPMNFile(processKey);

//  Other available methods:

  await myBpmFile.validate();
  myBpmFile.getAppId();
  myBpmFile.getFilePath();
  myBpmFile.isLoaded();
  myBpmFile.getRawXML();
  myBpmFile.getRawJSON();
  myBpmFile.toXML();
  myBpmFile.toJSON();
  myBpmFile.toBase64();

 //  if you get the bpmFile instance through your process, make sure to have called process.validate() before.
 //  Otherwise run myBpmFile.validate();

## Testing

yarn test [--watch]

In Windows, you need to set `LF` as the line ending sequence for some tests to pass. In particular those tests the verify XML in `process.spec.js`.

## Local development

To be able to install smartmate-schemas you need to configure an SSH key in Bitbucket.

See https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html

Readme

Keywords

none

Package Sidebar

Install

npm i smartmate-workspace-tools

Weekly Downloads

1

Version

3.14.4

License

UNLICENSED

Unpacked Size

1.32 MB

Total Files

328

Last publish

Collaborators

  • smartmate