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

@workerbase/sdk

Package Overview
Dependencies
Maintainers
3
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@workerbase/sdk - npm Package Compare versions

Comparing version 0.1.32 to 0.1.33

dist/resources/actions/BaseAction.d.ts

39

dist/index.d.ts

@@ -1,25 +0,14 @@

import { Resources } from './resources';
export interface AuthOptions {
token: string | undefined;
url: string | undefined;
}
export interface API {
accesstoken?: string;
url?: string;
version: string;
}
export interface WorkerbaseSdk extends Resources {
_api: API;
PACKAGE_VERSION: string;
}
export declare class WorkerbaseSdk {
PACKAGE_VERSION: string;
_api: API;
constructor();
auth(config?: AuthOptions): void;
_setApiField(key: any, value: any): void;
getApiField(key: any): string;
private _prepResources;
}
export declare const Workerbase: WorkerbaseSdk;
export default Workerbase;
import { WorkerbaseSDK } from './WorkerbaseSDK';
import { StepButtonIcons, StepOptionIcons, StatusScreenIcon } from './resources/WorkerbaseIcon';
import { WorkerbaseStatusScreenColor, ListOptionsSource } from './types/steps';
import { FlexDirection } from './resources/steps/LayoutFlexStep';
import { CurrentTaskAction } from './types/action';
export declare const FLEX_DIRECTION: typeof FlexDirection;
export declare const STATUS_SCREEN_ICONS: typeof StatusScreenIcon;
export declare const ACTION_ICONS: typeof StepButtonIcons;
export declare const STATUS_SCREEN_COLORS: typeof WorkerbaseStatusScreenColor;
export declare const OPTION_ICONS: typeof StepOptionIcons;
export declare const LIST_OPTIONS_SOURCE: typeof ListOptionsSource;
export declare const CURRENT_TASK_ACTION: typeof CurrentTaskAction;
export declare const workerbase: WorkerbaseSDK;
export default workerbase;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Workerbase = exports.WorkerbaseSdk = void 0;
var resources_1 = __importDefault(require("./resources"));
var WorkerbaseSdk = /** @class */ (function () {
function WorkerbaseSdk() {
this.PACKAGE_VERSION = '1.0.0';
this._api = {
accesstoken: process.env.WB_ACCESS_TOKEN,
url: process.env.WB_API_URL,
version: this.PACKAGE_VERSION,
};
this._prepResources();
}
WorkerbaseSdk.prototype.auth = function (config) {
if (config === null || config === void 0 ? void 0 : config.token) {
this._setApiField('accesstoken', config.token);
}
else if (!this._api.accesstoken) {
throw new Error('No WB_ACCESS_TOKEN in environment or option found');
}
if (config === null || config === void 0 ? void 0 : config.url) {
this._setApiField('url', config.url);
}
else if (!this._api.url) {
throw new Error('No WB_API_URL in environment or option found');
}
};
WorkerbaseSdk.prototype._setApiField = function (key, value) {
this._api[key] = value;
};
WorkerbaseSdk.prototype.getApiField = function (key) {
return this._api[key];
};
WorkerbaseSdk.prototype._prepResources = function () {
var _this = this;
Object.keys(resources_1.default).forEach(function (name) {
_this[name] = new resources_1.default[name](_this);
});
};
return WorkerbaseSdk;
}());
exports.WorkerbaseSdk = WorkerbaseSdk;
exports.Workerbase = new WorkerbaseSdk();
exports.default = exports.Workerbase;
module.exports = exports.Workerbase;
module.exports.Workerbase = exports.Workerbase;
module.exports.default = exports.Workerbase;
exports.workerbase = exports.CURRENT_TASK_ACTION = exports.LIST_OPTIONS_SOURCE = exports.OPTION_ICONS = exports.STATUS_SCREEN_COLORS = exports.ACTION_ICONS = exports.STATUS_SCREEN_ICONS = exports.FLEX_DIRECTION = void 0;
var WorkerbaseSDK_1 = require("./WorkerbaseSDK");
var WorkerbaseIcon_1 = require("./resources/WorkerbaseIcon");
var steps_1 = require("./types/steps");
var LayoutFlexStep_1 = require("./resources/steps/LayoutFlexStep");
var action_1 = require("./types/action");
exports.FLEX_DIRECTION = LayoutFlexStep_1.FlexDirection;
exports.STATUS_SCREEN_ICONS = WorkerbaseIcon_1.StatusScreenIcon;
exports.ACTION_ICONS = WorkerbaseIcon_1.StepButtonIcons;
exports.STATUS_SCREEN_COLORS = steps_1.WorkerbaseStatusScreenColor;
exports.OPTION_ICONS = WorkerbaseIcon_1.StepOptionIcons;
exports.LIST_OPTIONS_SOURCE = steps_1.ListOptionsSource;
exports.CURRENT_TASK_ACTION = action_1.CurrentTaskAction;
exports.workerbase = new WorkerbaseSDK_1.Workerbase();
exports.default = exports.workerbase;
module.exports = exports.workerbase;
module.exports.workerbase = exports.workerbase;
module.exports.FLEX_DIRECTION = exports.FLEX_DIRECTION;
module.exports.STATUS_SCREEN_ICONS = exports.STATUS_SCREEN_ICONS;
module.exports.ACTION_ICONS = exports.ACTION_ICONS;
module.exports.STATUS_SCREEN_COLORS = exports.STATUS_SCREEN_COLORS;
module.exports.OPTION_ICONS = exports.OPTION_ICONS;
module.exports.LIST_OPTIONS_SOURCE = exports.LIST_OPTIONS_SOURCE;
module.exports.CURRENT_TASK_ACTION = exports.CURRENT_TASK_ACTION;
module.exports.default = exports.workerbase;
//# sourceMappingURL=index.js.map
{
"name": "@workerbase/sdk",
"version": "0.1.32",
"description": "",
"scripts": {
"prepare": "npm run build",
"test": "echo \"Error: no test specified\" && exit 0",
"build": "tsc",
"watch": "tsc -w --preserveWatchOutput",
"lint": "eslint --ext .js,.ts ./src/",
"lint:fix": "eslint --ext .js,.ts ./src/ --fix"
},
"repository": {
"type": "git",
"url": "git@git.workerbase.io:public-projects/workerbase-sdk.git"
},
"files": [
"dist/**"
],
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"@types/node": "^14.0.13",
"@typescript-eslint/eslint-plugin": "^2.24.0",
"@typescript-eslint/parser": "^2.24.0",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.1.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.0",
"eslint-plugin-react-hooks": "^2.5.0",
"prettier": "^1.19.1",
"typescript": "^3.9.5"
},
"dependencies": {
"axios": "^0.19.2",
"gql-query-builder": "^3.6.0",
"parseurl": "^1.3.3"
"name": "@workerbase/sdk",
"version": "0.1.33",
"description": "",
"scripts": {
"prepare": "npm run build",
"test": "echo \"Error: no test specified\" && exit 0",
"build": "tsc",
"watch": "tsc -w --preserveWatchOutput",
"lint": "eslint --ext .js,.ts ./src/",
"lint:fix": "eslint --ext .js,.ts ./src/ --fix"
},
"repository": {
"type": "git",
"url": "git@git.workerbase.io:public-projects/workerbase-sdk.git"
},
"files": [
"dist/**"
],
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"@types/node": "^14.0.13",
"@typescript-eslint/eslint-plugin": "^2.24.0",
"@typescript-eslint/parser": "^2.24.0",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.1.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.0",
"eslint-plugin-react-hooks": "^2.5.0",
"prettier": "^1.19.1",
"typescript": "^3.9.5"
},
"dependencies": {
"axios": "^0.19.2",
"gql-query-builder": "^3.6.0",
"lodash": "^4.17.21",
"v4": "^0.0.1"
}
}
# Workerbase SDK for JavaScript
## Chapter Summary
1. [Installing](#installing)
2. [Typescript](#installing)
3. [Usage](#installing)
4. [Example](#installing)
5. [Methods](#methods)
1. [Databases](#databases)
2. [Database Items](#database-items)
3. [Events/Connectors](#eventsconnectors)
4. [Functions](#functions)
5. [Locations](#locations)
6. [Media](#media)
7. [Roles](#roles)
8. [Skills](#skills)
9. [Users](#users)
10. [Tasks](#tasks)
6. [List Documentation](#list-documentation)
7. [Database Items Query](#database-items-query)
8. [Steps Documentation](#steps-documentation)
1. [Example](#example-1)
2. [Usage](#usage-1)
1. [Actions](#actions)
2. [Buttons](#buttons)
3. [Info Steps](#info-steps)
4. [Input Steps](#input-steps)
5. [Input Steps](#input-steps)
6. [Input List Steps](#input-list-steps)
7. [Flex Step](#flex-step)
8. [Enums](#enums)
## Installing
Install with npm
Install with npm:

@@ -29,22 +60,2 @@ ```sh

## Authentication setup
You can configure the Workerbase SDK authentication options wiht the `auth` mehtod:
```javascript
workerbase.auth({
url: 'https://myWorkerbaseDomain.workerbase.io',
token: TOKEN,
});
```
If you don't use the `auth` method will use the following env variables as token and url
```env
WB_ACCESS_TOKEN=token
WB_API_URL=url
```
However if you are using the Workerbase SDK directly in a Workerbase Function, **you don't need to use the specify the authentication config** as the SDK will directly use the environment variables within the Workerbase Function.
## Example

@@ -104,118 +115,174 @@

**workerbase.databases.list(\[listConfig\])**
```
workerbase.databases.list(\[listConfig\])
**workerbase.databases.get(id)**
workerbase.databases.get(id)
```
**workerbase.databases.create(value)**
More information about `List Configs` can be found [here](#list-documentation).
**workerbase.databases.update(id,value)**
### Database Items
**workerbase.databases.delete(id)**
```
Database.items.list(\[listConfig\])
### Database Items
Database.items.get(id)
**Database.items.list(\[listConfig\])**
Database.items.create(value\[,externalId\])
**Database.items.get(id)**
Database.items.createMany(values)
**Database.items.create(value\[,externalId\])**
Database.items.update(id,value)
**Database.items.createMany(values)**
Database.items.delete(id)
**Database.items.update(id,value)**
Database.items.query(query, options)
```
**Database.items.delete(id)**
More information about `Database.items.query` can be found [here](#database-items-query).
**Database.items.query(query, options)** ([Documentation](#database-items-query))
More information about `List Configs` can be found [here](#list-documentation).
### Events
### Events/Connectors
**workerbase.events.list(\[listConfig\])**
```
workerbase.connectors.list(\[listConfig\])
**workerbase.events.get(id)**
workerbase.connectors.get(id)
**workerbase.events.create(value)**
workerbase.connectors.create(value)
**workerbase.events.update(id,value)**
workerbase.connectors.update(id,value)
**workerbase.events.delete(id)**
workerbase.connectors.delete(id)
**workerbase.events.trigger(id,payload)**
workerbase.connectors.trigger(id,payload)
```
### Functions
More information about `List Configs` can be found [here](#list-documentation).
**workerbase.functions.list(\[listConfig\])**
**Deprecated** usage:
**workerbase.functions.get(id)**
```
workerbase.events.list(\[listConfig\])
**workerbase.functions.create(value)**
workerbase.events.get(id)
**workerbase.functions.update(id,value)**
workerbase.events.create(value)
**workerbase.functions.delete(id)**
workerbase.events.update(id,value)
**workerbase.functions.deploy(id)**
workerbase.events.delete(id)
**workerbase.functions.invoke(id,payload)**
workerbase.events.trigger(id,payload)
```
### Functions
```
workerbase.functions.list(\[listConfig\])
workerbase.functions.get(id)
workerbase.functions.deploy(id)
workerbase.functions.invoke(id,payload)
```
More information about `List Configs` can be found [here](#list-documentation).
### Locations
**workerbase.locations.list(\[listConfig\])**
```
workerbase.locations.list(\[listConfig\])
**workerbase.locations.get(id)**
workerbase.locations.get(id)
**workerbase.locations.create(value)**
workerbase.locations.create(value)
**workerbase.locations.update(id,value)**
workerbase.locations.update(id,value)
**workerbase.locations.delete(id)**
workerbase.locations.delete(id)
**workerbase.locations.getPartsByLevel(levelId)**
workerbase.locations.getPartsByLevel(levelId)
**workerbase.locations.getLevels()**
workerbase.locations.getLevels()
```
More information about `List Configs` can be found [here](#list-documentation).
### Media
**workerbase.media.list(\[listConfig\])**
```
workerbase.media.list(\[listConfig\])
**workerbase.media.get(id)**
workerbase.media.get(id)
**workerbase.media.delete(id)**
workerbase.media.delete(id)
```
More information about `List Configs` can be found [here](#list-documentation).
### Roles
**workerbase.roles.list(\[listConfig\])**
```
workerbase.roles.list(\[listConfig\])
**workerbase.roles.get(id)**
workerbase.roles.get(id)
**workerbase.roles.create(value)**
workerbase.roles.create(value)
**workerbase.roles.update(id,value)**
workerbase.roles.update(id,value)
**workerbase.roles.delete(id)**
workerbase.roles.delete(id)
```
More information about `List Configs` can be found [here](#list-documentation).
### Skills
**workerbase.skills.list(\[listConfig\])**
```
workerbase.skills.list(\[listConfig\])
**workerbase.skills.get(id)**
workerbase.skills.get(id)
**workerbase.skills.create(value)**
workerbase.skills.create(value)
**workerbase.skills.update(id,value)**
workerbase.skills.update(id,value)
**workerbase.skills.delete(id)**
workerbase.skills.delete(id)
```
More information about `List Configs` can be found [here](#list-documentation).
### Users
**workerbase.users.list(\[listConfig\])**
```
workerbase.users.list(\[listConfig\])
**workerbase.users.get(id)**
workerbase.users.get(id)
**workerbase.users.create(value)**
workerbase.users.create(value)
**workerbase.users.update(id,value)**
workerbase.users.update(id,value)
**workerbase.users.delete(id)**
workerbase.users.delete(id)
```
More information about `List Configs` can be found [here](#list-documentation).
### Tasks
```
workerbase.tasks.list(\[listConfig\])
workerbase.tasks.get(id)
workerbase.tasks.delete(id)
workerbase.tasks.update(id,value)
```
More information about `List Configs` can be found [here](#list-documentation).
## List documentation

@@ -251,7 +318,27 @@

Filter the list to keep only the values that match the condition object.
Example:
```typescript
const filteredList = await workerbase.users
.list({
page: 1,
perpage: 10,
sort: 'firstName',
order: 'desc',
fields: 'firstName lastName',
})
.filterBy({ firstName: 'Anna' });
```
**list().distinctBy(field)**
Return the list of all distinct values of the specified field.
Example:
```typescript
const getAllUserDepartments = await workerbase.users
.list()
.distinctBy('department');
```
## Database Items Query

@@ -593,1 +680,928 @@

```
## Steps documentation
Workinstruction steps, buttons, and actions can now be defined with the SDK:
### Example
```typescript
const workerbase = require('@workerbase/sdk');
const { FLEX_DIRECTION } = require('@workerbase/sdk');
const infoText = workerbase.steps.InfoText({
title: 'Info Text Step',
description: '',
});
infoText.showAsBox({ hideTitleBar: true });
const photoStep = workerbase.steps.InfoPhoto({
title: 'Info Photo Step',
mediaId: '5d9f0653e762e70006ab9ecd',
description: '',
});
const flexStep = workerbase.steps.LayoutFlex({
title: 'Layout Flex Step',
direction: FLEX_DIRECTION.COLUMN,
});
flexStep.addButton(workerbase.buttons.Finish());
flexStep.addButtons([workerbase.buttons.Close(), workerbase.buttons.Suspend()]);
const columnFlexGroup = flexStep.addColumn({ flex: 2 });
columnFlexGroup.addStep({ flex: 2, step: infoText });
flexStep.addStep({ flex: 2, step: photoStep });
```
### Usage
#### Actions
```typescript
const { CURRENT_TASK_ACTION } = require('@workerbase/sdk');
const close = workerbase.actions.Close();
const finish = workerbase.actions.Finish();
const suspend = workerbase.actions.Suspend();
const nextStepFunctionId = workerbase.actions.NextStepFunctionId('functionId');
const nextActionFunctionId = workerbase.actions.NextActionFunctionId(
'functionId',
);
const nextStepId = workerbase.actions.NextStepId('stepId');
const nextTaskId = workerbase.actions.NextTaskId(
'taskId',
// optional values:
{
currentTaskAction: CURRENT_TASK_ACTION.FINISH, // default is CURRENT_TASK_ACTION.CLOSE
initialStepId: 'initial step id', // default is undefined
},
);
const nextWorkinstruction = workerbase.actions.NextWorkinstruction(
'workinstructionsId',
// optional values:
{
currentTaskAction: CURRENT_TASK_ACTION.FINISH, // default is CURRENT_TASK_ACTION.CLOSE
initialStepId: 'initial step id', // default is undefined
},
);
```
More information about `CURRENT_TASK_ACTION` enum can be viewed [here](#enums).
#### Buttons
```typescript
const close = workerbase.buttons.Close();
const finish = workerbase.buttons.Finish();
const suspend = workerbase.buttons.Suspend();
const nextStepFunctionId = workerbase.buttons.NextStepFunctionId('functionId');
const nextActionFunctionId = workerbase.buttons.NextActionFunctionId(
'functionId',
);
const nextStepId = workerbase.buttons.NextStepId('stepId');
const nextTaskId = workerbase.buttons.NextTaskId('taskId');
const nextWorkinstruction = workerbase.buttons.NextWorkinstruction(
'workinstructionId',
);
const back = workerbase.buttons.Back('stepId');
const continue = workerbase.buttons.Continue('stepId');
```
Each button has additional optional values: `text`, `icon`, and `id`. If some of these values are not set by the user, the SDK auto-assigns values to them.
The variables can be specified for each button as follows:
```typescript
const { ACTION_ICONS } = require('@workerbase/sdk');
const close = workerbase.buttons.Close({
text: 'Button Text',
icon: ACTION_ICONS.CLOSE,
id: 'my id',
});
const nextActionFunctionId = workerbase.buttons.NextActionFunctionId(
'functionId',
{
text: 'Button Text',
icon: ACTION_ICONS.CONFIRM,
id: 'my id',
},
);
```
Additionally, `workerbase.buttons.NextTaskId` and `workerbase.buttons.NextWorkinstruction` have additional optional values as well:
```typescript
const { ACTION_ICONS, CURRENT_TASK_ACTION } = require('@workerbase/sdk');
const close = workerbase.buttons.NextTaskId('taskId', {
text: 'Button Text', // optional
icon: ACTION_ICONS.CLOSE, // optional
id: 'my id', // optional
// Additional optional values of NextTaskId button:
currentTaskAction: CURRENT_TASK_ACTION.FINISH, // default is CURRENT_TASK_ACTION.CLOSE
initialStepId: 'initial step id', // default is undefined
});
const close = workerbase.buttons.NextWorkinstruction('workinstructionsId', {
text: 'Button Text', // optional
icon: ACTION_ICONS.CLOSE, // optional
id: 'my id', // optional
// Additional optional values of NextWorkinstruction button:
currentTaskAction: CURRENT_TASK_ACTION.FINISH, // default is CURRENT_TASK_ACTION.CLOSE
initialStepId: 'initial step id', // default is undefined
});
```
-> More information on `ACTION_ICONS`, `CURRENT_TASK_ACTION` can be viewed [here](#enums).
You can also set the background color and the text color of each button via the following methods:
```typescript
const button = workerbase.actions.Close();
// Default is #287AF5;
button.setBackgroundColor('#00FFFF');
// Default is #DEEDFF;
button.setTextColor('#89CFF0');
```
#### Info Steps:
Each step has an optional `id` value. If it is not set by the user, the SDK will auto-generate a value for it.
For each step, the following functions can be called:
```typescript
const step = workerbase.steps.InfoText({
title: '',
description: '',
});
// Add one function
step.addButton(workerbase.buttons.Close());
// Add multiple buttons
step.addButtons([workerbase.buttons.Finish(), workerbase.buttons.Suspend()]);
// Set maxTime:
step.setMaxTime(100);
// Load variables from a function:
step.setLoadVariablesFromUrl('functionId');
```
For each step with a `description` variable, you can add rich text support via HTML:
```typescript
// H1
const description = '<h1> Hello, World! </h1>';
// H2
const description2 = '<h2> Hello, World! </h2>';
// H3
const description3 = '<h3> Hello, World! </h3>';
// Bold
const description4 = '<strong> Hello, World! </strong>';
// Italic
const description5 = '<em> Hello, World! </em>';
// Underline
const description6 = '<u> Hello, World! </u>';
// Align Left
const description7 = '<div style="text-align: left;"> Hello, World! </div>';
// Align Center
const description8 = '<div style="text-align: center;"> Hello, World! </div>';
// Align Right
const description9 = '<div style="text-align: right;"> Hello, World! </div>';
// More complex descriptions can be built with this:
const description10 =
'<div style="text-align: center;"><h1>Hello, <em>World.</em></h1></div> What a <u>wonderful</u> day.';
```
- **Info Text Step**
![Info Text Step](images/info-text-step.png)
```typescript
const step = workerbase.steps.InfoText({
title: '',
description: '',
id: '', // optional
});
```
- **Info Text Large Step**
![Info Text Large Step](images/info-large-text-step.png)
```typescript
const step = workerbase.steps.InfoTextLarge({
title: '',
description: '',
id: '', // optional
});
```
- **Info Qr Code Step**
![Info QrCode Step](images/info-qrcode-step.png)
```typescript
const step = workerbase.steps.InfoQrCode({
title: '',
payload: '',
id: '', // optional
});
```
- **Info Status Step**
![Info Status Screen Step](images/info-status-screen-step.png)
```typescript
const {
STATUS_SCREEN_COLORS,
STATUS_SCREEN_ICONS,
} = require('@workerbase/sdk');
const step = workerbase.steps.InfoStatus({
title: '',
description: '',
headline: '',
id: '', // optional
});
// Status screen icon is icon-info.png by default
step.setIcon(STATUS_SCREEN_ICONS.SUCCESS);
// Status screen color is grey by default
step.setColor(STATUS_SCREEN_COLORS.GREEN);
```
-> More information on `STATUS_SCREEN_COLORS` and `STATUS_SCREEN_ICONS` enums can be found [here](#enums).
- **Info WebView Step**
![Info Webview Step](images/info-webview-step.png)
```typescript
const step = workerbase.steps.InfoWebview({
title: '',
url: '',
id: '', // optional
});
```
- **Info Photo Step**
![Info Photo Step](images/info-photo-step.png)
```typescript
const step = workerbase.steps.InfoPhoto({
title: '',
mediaId: '',
description: '',
id: '', // optional
});
// "Show full picture" is true by default.
step.showFullPicture(false);
```
- **Info Audio Step**
![Info Audio Step](images/info-audio-step.png)
```typescript
const step = workerbase.steps.InfoAudio({
title: '',
mediaId: '',
description: '',
id: '', // optional
});
```
- **Info Video Step**
![Info Video Step](images/info-video-step.png)
```typescript
const step = workerbase.steps.InfoVideo({
title: '',
mediaId: '',
description: '',
id: '', // optional
});
```
- **Info Pdf Step**
![Info PDF Step](images/info-pdf-step.png)
```typescript
const step = workerbase.steps.InfoPdf({
title: '',
mediaId: '',
description: '',
id: '', // optional
});
// Slide mode is enabled (true) by default
step.enableSlideMode();
step.disableSlideMode();
// Default page number is 1
step.setPageNumber(3);
```
- **Info Loading Step**
![Info Loading Step](images/info-loading-step.png)
```typescript
const step = workerbase.steps.InfoLoading({
title: '',
taskAppearingDuration: '',
id: '', // optional
});
```
- **Info Location Direction Step**
![Info Location Direction Step](images/info-location-direction-step.png)
```typescript
const step = workerbase.steps.InfoLocationDirection({
title: '',
gpsLocationLatitude: '',
gpsLocationLongitude: '',
description: '',
id: '', // optional
});
```
#### Input Steps:
- **Input Text Step**
![Input Text Step](images/input-text-step.png)
```typescript
const step = workerbase.steps.InputText({
title: '',
outputVarName: '',
description: '',
id: '', // optional
});
```
- **Input Barcode Step**
![Input Barcode Step](images/input-barcode-step.png)
```typescript
const step = workerbase.steps.InputBarcode({
title: '',
outputVarName: '',
description: '',
id: '', // optional
});
// Auto-Continue is false by default
step.setAutoContinue(true);
// Allow Manual Barcode Input is false by default
step.setAllowManualBarcodeInput(true);
// Regex is an empty array by default
step.addRegex('d');
step.addMultipleRegex(['d', 'code']);
// Regex operations is empty array by default
// Begins, Contains, Ends, Equals, EqualsVar, and Regex functions mimic behavior of Workerbase UI
step.addRegexOperation(workerbase.steps.regex.Begins('abc'));
step.addRegexOperations([
workerbase.steps.regex.Contains('abc'),
workerbase.steps.regex.Ends('abc'),
workerbase.steps.regex.Equals('abc'),
workerbase.steps.regex.EqualsVar('abc'),
workerbase.steps.regex.Regex('abc'),
]);
```
- **Input Number Picker Step**
![Input Number Picker Step](images/input-numberpicker-step.png)
```typescript
const step = workerbase.steps.InputNumberPicker({
title: '',
outputVarName: '',
description: '',
id: '', // optional
});
// Integer Digits is 3 by default
step.setIntegerDigits(2);
// Decimal Digits is 0 by default
step.setDecimalDigits(3);
// Default Value Decimal is undefined by default
step.setDefaultValueDecimal('10.000');
```
- **Input Number Step**
![Input Number Step](images/input-number-step.png)
```typescript
const step = workerbase.steps.InputNumber({
title: '',
outputVarName: '',
id: '', // optional
});
// Integer Digits is 3 by default
step.setIntegerDigits(2);
// Decimal Digits is 0 by default
step.setDecimalDigits(3);
// Default Value Decimal is undefined by default
step.setDefaultValueDecimal('10.000');
```
- **Input Location Step**
![Input Location Step](images/input-location-step.png)
```typescript
const step = workerbase.steps.InputLocation({
title: '',
outputVarName: '',
minAccuracyInMeters: 3,
description: '',
id: '', // optional
});
```
- **Input Audio Step**
![Input Audio Step](images/input-audio-step.png)
```typescript
const step = workerbase.steps.InputAudio({
title: '',
outputVarName: '',
id: '', // optional
});
```
- **Input Video Step**
![Input Video Step](images/input-video-step.png)
```typescript
const step = workerbase.steps.InputVideo({
title: '',
outputVarName: '',
id: '', // optional
});
```
- **Input Photo Step**
![Input Photo Step](images/input-photo-step.png)
```typescript
const step = workerbase.steps.InputPhoto({
title: '',
outputVarName: '',
id: '', // optional
});
```
- **Input Noise Level Step**
![Input Noise Level Step](images/input-noise-level-step.png)
```typescript
const step = workerbase.steps.InputNoiseLevel({
title: '',
outputVarName: '',
measureDurationInSec: 5,
id: '', // optional
});
// Auto Continue is false by default
step.setAutoContinue(true);
// Auto Start Measurement is true by default
step.setAutoStartMeasurement(false);
// Input Required is true by default
step.setInputRequired(false);
// Warning Threshold In Decibel is 0 by default
step.setWarningThresholdInDecibel(200);
```
### Input List Steps
For each Input List Step, you can add custom options or load options from a function.
The options input type (options array, or function ID) can be specified with the `source` input variable and `LIST_OPTIONS_SOURCE` enum. More information about this enum can be found [here](#enums).
- **Input Value List Step**
![Input List Step](images/input-list-step.png)
Options for this step can be added with `ValueListOption` method:
```typescript
workerbase.steps.options.ValueListOption({
text: '',
id: '', // optional
action: ... , // optional
custom: ... , // optional
});
```
The Step can be defined as follows:
```typescript
const { LIST_OPTIONS_SOURCE } = require('@workerbase/sdk');
// Adding own options
const step = workerbase.steps.InputValueList({
title: '',
outputVarName: '',
source: LIST_OPTIONS_SOURCE.OPTIONS, // set source to OPTIONS
id: '', // optional
});
// Auto Continue is false by default
step.setAutoContinue(true);
// Require Selection is false by default
step.setRequireSelection(true);
// Adding Input Value List Options without actions manually
step.addOption(workerbase.steps.options.ValueListOption({ text: '1' }));
step.addOptions([
workerbase.steps.options.ValueListOption({ text: '2' }),
workerbase.steps.options.ValueListOption({ text: '3' }),
]);
// Add Input Value List Options with actions manually
step.setCustomNextStep(true); // Default is false. Has to be set to true to be able to add option with actions.
step.addOption(
workerbase.steps.options.ValueListOption({
text: '1',
action: workerbase.actions.Close(),
}),
);
// Add custom variables
step.addOption(
workerbase.steps.options.ValueListOption({
text: '1',
action: workerbase.actions.Close(),
custom: { yourVariableName: 'yourVariableValue' },
}),
);
// Adding Input Value List Options from a function
const optionsFromFunction = workerbase.steps.InputValueList({
title: '',
outputVarName: '',
source: LIST_OPTIONS_SOURCE.CONNECTOR, // set source to CONNECTOR
id: '', // optional
});
optionsFromFunction.setLoadOptionsFromUrl('functionId');
```
- **Input Index List Step**
![Input Index List Step](images/input-indexlist-step.png)
Options for this step can be added with `IndexListOption` method:
```typescript
workerbase.steps.options.IndexListOption({
text: '',
isHeadline: false,
id: '', // optional
custom: ... , // optional
});
```
The Step can be defined as follows:
```typescript
const { LIST_OPTIONS_SOURCE } = require('@workerbase/sdk');
// Adding options manually
const step = workerbase.steps.InputIndexList({
title: '',
outputVarName: '',
source: LIST_OPTIONS_SOURCE.OPTIONS, // set source to OPTIONS
id: '', // optional
});
// Auto Continue is false by default
step.setAutoContinue(true);
// Require Selection is false by default
step.setRequireSelection(true);
// Adding Index List Options manually (no options with actions can be added for this step)
step.addOption(
workerbase.steps.options.IndexListOption({
text: '1',
isHeadline: true,
}),
);
step.addOptions([
workerbase.steps.options.IndexListOption({ text: '2', isHeadline: true }),
workerbase.steps.options.IndexListOption({ text: '3', isHeadline: false }),
]);
// Auto Continue is false by default
step.setAutoContinue(true);
// Require Selection is false by default
step.setRequireSelection(true);
// Add Input Index List Options from a function
const optionsFromFunction = workerbase.steps.InputIndexList({
title: '',
outputVarName: '',
source: LIST_OPTIONS_SOURCE.CONNECTOR, // set source to CONNECTOR
id: '', // optional
});
optionsFromFunction.setLoadOptionsFromUrl('functionId');
```
- **Input Tile List Step**
![Input Tile List Step](images/input-tilelist-step.png)
Options for this step can be added with `TileListOption` method:
```typescript
workerbase.steps.options.TileListOption({
text: '',
id: '', // optional
action: ... , // optional
custom: ... , // optional
});
```
The Step can be defined as follows:
```typescript
const { LIST_OPTIONS_SOURCE } = require('@workerbase/sdk');
// Add options manually
const step = workerbase.steps.InputTileList({
title: '',
outputVarName: '',
source: LIST_OPTIONS_SOURCE.OPTIONS, // set source to OPTIONS
id: '', // optional
});
// Add Tile List Options manually
step.addOption(
workerbase.steps.options.TileListOption({
text: '1',
custom: { test: 'test' }, // optional
}),
);
step.addOptions([
workerbase.steps.options.TileListOption({ text: '2' }),
workerbase.steps.options.TileListOption({ text: '3' }),
]);
// Add Input Value List Options with actions manually
step.setCustomNextStep(true); // Default is false. Has to be set to true to be able to add option with actions.
step.addOption(
workerbase.steps.options.TileListOption({
text: '1',
action: workerbase.actions.Close(),
}),
);
// Adding Tile List Options with actions
step.setCustomNextStep(true); // default is false
step.addOption(
workerbase.steps.options.TileListOption({
text: 'text',
action: workerbase.actions.Suspend(),
custom: { test: 'test' }, // optional
}),
);
// Add Tile List Options from a function
const optionsFromFunction = workerbase.steps.InputTileList({
title: '',
outputVarName: '',
source: LIST_OPTIONS_SOURCE.CONNECTOR, // set source to CONNECTOR
id: '', // optional
});
optionsFromFunction.setLoadOptionsFromUrl('functionId');
```
- **Input Checkbox List**
![Input Checkbox List Step](images/input-checklist-step.png)
Options for this step can be added with `CheckboxListOption` method:
```typescript
workerbase.steps.options.CheckboxListOption({
text: '',
isChecked: false,
id: '', // optional
custom: ... , // optional
});
```
The Step can be defined as follows:
```typescript
const { LIST_OPTIONS_SOURCE } = require('@workerbase/sdk');
// Add options manually
const step = workerbase.steps.InputCheckboxList({
title: '',
outputVarName: '',
source: LIST_OPTIONS_SOURCE.OPTIONS, // set source to OPTIONS
id: '', // optional
});
// Auto Continue is false by default
step.setAutoContinue(true);
// Require to select all options
// Default is false
step.setSelectAll(true);
// Add minimum number of options that have to be selected
// Can only be set if selectAll is false.
step.setMinSelect(3); // Default is 0
// Adding Tile Checkbox Options manually (no actions can be added for this list)
step.addOption(
workerbase.steps.options.CheckboxListOption({
text: 'text',
isChecked: false,
custom: { test: 'test' }, // optional
}),
);
step.addOptions([
workerbase.steps.options.CheckboxListOption({
text: '2',
isChecked: false,
}),
workerbase.steps.options.CheckboxListOption({
text: '3',
isChecked: false,
}),
]);
// Add Checkbox List Options from a function
const optionsFromFunction = workerbase.steps.InputCheckboxList({
title: '',
outputVarName: '',
source: LIST_OPTIONS_SOURCE.CONNECTOR, // set source to CONNECTOR
id: '', // optional
});
optionsFromFunction.setLoadOptionsFromUrl('functionId');
```
- **Input Button List**
![Input Button List Step](images/input-buttonlist-step.png)
Options for this step can be added with `ButtonListOption` method:
```typescript
const { OPTION_ICONS } = require('@workerbase/sdk');
workerbase.steps.options.ButtonListOption({
text: '',
id: '',
action: workerbase.actions.Finish(),
icon: OPTION_ICONS.INFO,
custom: undefined,
});
```
The step can be defined as follows:
```typescript
const { LIST_OPTIONS_SOURCE, OPTION_ICONS } = require('@workerbase/sdk');
const step = workerbase.steps.InputButtonList({
title: '',
outputVarName: '',
source: LIST_OPTIONS_SOURCE.OPTIONS,
});
// Auto Continue is false by default
step.setAutoContinue(true);
// Require Selection is false by default
step.setRequireSelection(true);
// No photo is displayed by default
step.displayPhoto('mediaId');
// Adding Button List Options manually
step.addOption(
workerbase.steps.options.ButtonListOption({
text: 'text',
custom: { test: 'test' }, // optional
}),
);
step.addOptions([
workerbase.steps.options.ButtonListOption({ text: '2' }),
workerbase.steps.options.ButtonListOption({ text: '3' }),
]);
// Adding Button List Options with actions
step.setCustomNextStep(true); // default is false
step.addOption(
workerbase.steps.options.ButtonListOption({
text: 'text',
action: workerbase.actions.Suspend(),
custom: { test: 'test' }, // optional
}),
);
// Adding Button List Options with custom icon
step.addOption(
workerbase.steps.options.ButtonListOption({
text: 'text',
custom: { test: 'test' }, // optional
icon: OPTION_ICONS.INFO, // optional
}),
);
// Add Button List Options from a function
const optionsFromFunction = workerbase.steps.InputButtonList({
title: '',
outputVarName: '',
source: LIST_OPTIONS_SOURCE.CONNECTOR, // set source to CONNECTOR
id: '', // optional
});
optionsFromFunction.setLoadOptionsFromUrl('functionId');
```
-> More information on `OPTION_ICONS` enum can be found [here](#enums).
### Flex Step
![Input Flex Step](images/input-flex-step.png)
We added the possibility to define a custom step, consisting of multiple other steps. This can be done via the `FlexStep`.
You can add a single step, or a group of steps to the `FlexStep`:
```typescript
const { FLEX_DIRECTION } = require('@workerbase/sdk');
// Define Info Text Step
const infoText = workerbase.steps.InfoText({
title: 'Info Text Step Title',
description: 'This is the description of the step',
});
// Defaults of showAsBox is false, and hideTitleBar is true
infoText.enableShowAsBox(); // showAsBox is now true, and hideTitleBar false
// You can additionally set hideTitleBar to true
infoText.enableShowAsBox({ hideTitleBar: true }); // showAsBox and hideTitleBar are true now
// Define Info Photo Step
const photoStep = workerbase.steps.InfoPhoto({
title: '',
mediaId: '5d9f0653e762e70006ab9ecd',
description: 'This is the description of the photo',
});
const largeText = workerbase.steps.InfoTextLarge({
title: 'Info Text Large',
description: 'Description',
});
// Define Flex Step with two buttons
const flexStep = workerbase.steps.LayoutFlex({
title: 'My Layout Flex Step',
direction: FLEX_DIRECTION.COLUMN,
});
flexStep.addButtons([workerbase.buttons.Close(), workerbase.buttons.Finish()]);
// Add FlexGroup placing steps in column direction
const columnFlexGroup = flexStep.addColumn({ flex: 2 });
// Add previously defined Info Text Step to column flex group
columnFlexGroup.addStep({ flex: 2, step: infoText });
// Add FlexGroup placing steps in row direction
const rowFlexGroup = flexStep.addRow({ flex: 2 });
// Add previously defined Info Large Text Step to row flex group
rowFlexGroup.addStep({ flex: 2, step: largeText });
// Add previously defined Info Photo Step to Flex Step
flexStep.addStep({ flex: 2, step: photoStep });
```
-> More information on `FLEX_DIRECTION` enum can be found [here](#enums).
### Enums
```typescript
enum STATUS_SCREEN_ICON {
SUCCESS,
INFO,
ERROR,
}
enum STATUS_SCREEN_COLORS {
GREY,
RED,
GREEN,
}
enum LIST_OPTIONS_SOURCE {
CONNECTOR,
OPTIONS,
}
enum ACTION_ICONS {
CONFIRM,
CLOSE,
QUESTION_YELLOW,
REPEAT,
WARNING_RED_CLEAR_BG,
WARNING_RED,
WARNING_YELLOW,
WARNING,
REFRESH,
INFO,
INFO_BLUE,
BACK,
NEXT,
CONFIRM_ENCIRCLED,
CONFIRM_ENCIRCLED_GREEN,
PLUS,
MINUS,
INSTRUCTIONS,
LIST,
HOME,
}
enum OPTION_ICONS {
INFO,
ERROR,
SUCCESS,
SUPPORT,
}
enum FLEX_DIRECTION {
ROW,
COLUMN,
}
enum CURRENT_TASK_ACTION {
FINISH,
CLOSE,
SUSPEND,
}
```

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