@hailer/app-sdk 1.0.0 → 1.0.1-beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/app-sdk.js +2 -0
- package/lib/app-sdk.js.map +7 -0
- package/lib/hailer-api.d.ts +16 -14
- package/lib/modules/activity/kanban.d.ts +1 -3
- package/lib/modules/activity.d.ts +8 -8
- package/lib/modules/app.d.ts +12 -0
- package/lib/modules/insight.d.ts +1 -3
- package/lib/modules/network.d.ts +3 -3
- package/lib/modules/process.d.ts +0 -2
- package/lib/modules/public/insight.d.ts +1 -1
- package/lib/modules/public.d.ts +3 -3
- package/lib/modules/ui/activity.d.ts +4 -1
- package/lib/modules/ui/snackbar.d.ts +0 -1
- package/lib/modules/user.d.ts +5 -8
- package/lib/modules/workflow.d.ts +4 -5
- package/lib/types.d.ts +10 -16
- package/package.json +4 -3
- package/lib/constants.js +0 -12
- package/lib/hailer-api.js +0 -163
- package/lib/index.js +0 -2
- package/lib/modules/activity/kanban.js +0 -77
- package/lib/modules/activity.js +0 -130
- package/lib/modules/insight.js +0 -54
- package/lib/modules/network.js +0 -33
- package/lib/modules/process.js +0 -77
- package/lib/modules/public/app.js +0 -45
- package/lib/modules/public/form.js +0 -68
- package/lib/modules/public/insight.js +0 -69
- package/lib/modules/public.js +0 -13
- package/lib/modules/ui/activity.js +0 -28
- package/lib/modules/ui/files.js +0 -36
- package/lib/modules/ui/snackbar.js +0 -32
- package/lib/modules/ui.js +0 -11
- package/lib/modules/user.js +0 -76
- package/lib/modules/workflow.js +0 -54
- package/lib/types.js +0 -9
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hailer/app-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1-beta2",
|
|
4
4
|
"description": "SDK for building Hailer Apps",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "ISC",
|
|
7
|
-
"main": "./lib/
|
|
7
|
+
"main": "./lib/app-sdk.js",
|
|
8
|
+
"type": "module",
|
|
8
9
|
"types": "./lib/index.d.ts",
|
|
9
10
|
"files": [
|
|
10
11
|
"./lib/**/*"
|
|
11
12
|
],
|
|
12
13
|
"scripts": {
|
|
13
|
-
"build": "tsc",
|
|
14
|
+
"build": "tsc && esbuild src/index.ts --bundle --format=esm --minify --sourcemap --outfile=lib/app-sdk.js",
|
|
14
15
|
"docs": "typedoc --entryPointStrategy expand ./src && open-cli ./docs/index.html"
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
package/lib/constants.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// Changing this will be a breaking change
|
|
2
|
-
export const DEFAULT_API_VERSION = 1;
|
|
3
|
-
export const DEFAULT_ALLOWED_URLS = ['https://app.hailer.com', 'https://next.hailer.com', 'https://testapp.hailer.biz', 'https://app.hailer.biz'];
|
|
4
|
-
export const DEFAULT_BACKEND_URL = 'https://api.hailer.com';
|
|
5
|
-
/** Map of which backend to use depending on which frontend is hosting the app frame, be sure to fall back to production backend if no match */
|
|
6
|
-
export const publicBackendMap = {
|
|
7
|
-
'https://app.hailer.com': DEFAULT_BACKEND_URL,
|
|
8
|
-
'https://next.hailer.com': DEFAULT_BACKEND_URL,
|
|
9
|
-
'https://app.hailer.biz': 'https://api.hailer.biz',
|
|
10
|
-
'https://testapp.hailer.biz': 'https://testapi.hailer.biz',
|
|
11
|
-
'https://localhost:9443': 'http://localhost:1337',
|
|
12
|
-
};
|
package/lib/hailer-api.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { Client } from '@wishcore/wish-rpc';
|
|
11
|
-
import { User } from './modules/user';
|
|
12
|
-
import { Activity } from './modules/activity';
|
|
13
|
-
import { Network } from './modules/network';
|
|
14
|
-
import { Ui } from './modules/ui';
|
|
15
|
-
import { Insight } from './modules/insight';
|
|
16
|
-
import { Process } from './modules/process';
|
|
17
|
-
import { DEFAULT_ALLOWED_URLS, DEFAULT_API_VERSION, DEFAULT_BACKEND_URL, publicBackendMap } from './constants';
|
|
18
|
-
import { HailerApiPublic } from './modules/public';
|
|
19
|
-
import { Workflow } from './modules/workflow';
|
|
20
|
-
export class HailerApi {
|
|
21
|
-
/**
|
|
22
|
-
* Create a Hailer API client for inteacting with Hailer. **NOTE** This only works when inside Hailer.
|
|
23
|
-
*
|
|
24
|
-
* This should be run after window is initialized for example in ***onMount*** in Svelte or in ***useEffect*** in React
|
|
25
|
-
*/
|
|
26
|
-
constructor(options = {}) {
|
|
27
|
-
var _a, _b;
|
|
28
|
-
this.options = options;
|
|
29
|
-
/**
|
|
30
|
-
* Hailer API state
|
|
31
|
-
*
|
|
32
|
-
* ```
|
|
33
|
-
* true // outside hailer
|
|
34
|
-
* false // logged into hailer
|
|
35
|
-
* null // state not yet detected
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
this.outside = null;
|
|
39
|
-
const allowedUrls = (_a = options.allowedUrls) !== null && _a !== void 0 ? _a : DEFAULT_ALLOWED_URLS;
|
|
40
|
-
this.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : DEFAULT_API_VERSION;
|
|
41
|
-
this.subscribedSignals = options.subscribedSignals;
|
|
42
|
-
this.client = new Client(msg => {
|
|
43
|
-
if (this.hostUrl) {
|
|
44
|
-
parent.postMessage(JSON.stringify(msg), this.hostUrl);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
this.user = new User(this.client);
|
|
48
|
-
this.activity = new Activity(this.client);
|
|
49
|
-
this.insight = new Insight(this.client);
|
|
50
|
-
this.network = new Network(this.client);
|
|
51
|
-
this.process = new Process(this.client);
|
|
52
|
-
this.workflow = new Workflow(this.client);
|
|
53
|
-
this.public = new HailerApiPublic(this.options);
|
|
54
|
-
this.ui = new Ui(this.client);
|
|
55
|
-
const registerMessage = JSON.stringify({ op: 'register', args: [] });
|
|
56
|
-
// If we are not in Iframe set location to outside, else wait 100ms for response to register to check if we are in Hailer
|
|
57
|
-
if (window.location === window.parent.location) {
|
|
58
|
-
// Pick a backend to use for public requests, unless it is set
|
|
59
|
-
if (!this.options.publicBackendUrl) {
|
|
60
|
-
this.options.publicBackendUrl = DEFAULT_BACKEND_URL;
|
|
61
|
-
}
|
|
62
|
-
this.public.app.config().then(config => {
|
|
63
|
-
// CSM app assumes we are inside hailer when config is called... breaks the thing...
|
|
64
|
-
// this.options.config?.(config);
|
|
65
|
-
var _a, _b;
|
|
66
|
-
this.outside = true;
|
|
67
|
-
(_b = (_a = this.options).outside) === null || _b === void 0 ? void 0 : _b.call(_a, config);
|
|
68
|
-
}).catch(error => {
|
|
69
|
-
var _a, _b;
|
|
70
|
-
(_b = (_a = this.options).error) === null || _b === void 0 ? void 0 : _b.call(_a, error);
|
|
71
|
-
console.error('Failed to get app configuration in Public App.', error);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
// if in a frame, try register to Hailer by sending register to all allowed urls
|
|
76
|
-
allowedUrls.forEach(url => parent.postMessage(registerMessage, url));
|
|
77
|
-
this.timer = setTimeout(() => {
|
|
78
|
-
var _a, _b;
|
|
79
|
-
this.outside = true;
|
|
80
|
-
(_b = (_a = this.options).outside) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
81
|
-
}, 100);
|
|
82
|
-
}
|
|
83
|
-
this.createEventListener();
|
|
84
|
-
}
|
|
85
|
-
createEventListener() {
|
|
86
|
-
window.addEventListener('message', (event) => __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
var _a, _b;
|
|
88
|
-
const data = event.data;
|
|
89
|
-
try {
|
|
90
|
-
const msg = JSON.parse(data);
|
|
91
|
-
if (msg.op === 'register') {
|
|
92
|
-
if (this.appId) {
|
|
93
|
-
console.error('App Id is already set...! Are you using hot-reload?');
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
clearTimeout(this.timer);
|
|
97
|
-
this.appId = msg.data.appId;
|
|
98
|
-
// Set host url now that we have a response
|
|
99
|
-
this.hostUrl = event.origin;
|
|
100
|
-
// Pick a backend to use for public requests, unless it is set
|
|
101
|
-
if (!this.options.publicBackendUrl) {
|
|
102
|
-
this.options.publicBackendUrl = publicBackendMap[this.hostUrl] || DEFAULT_BACKEND_URL;
|
|
103
|
-
}
|
|
104
|
-
// Register listeners for config and settings
|
|
105
|
-
this.client.request('v1.ui.settings', [], (error, data, end) => {
|
|
106
|
-
var _a, _b;
|
|
107
|
-
if (error) {
|
|
108
|
-
console.log('ui.settings error:', error, data);
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
(_b = (_a = this.options).settings) === null || _b === void 0 ? void 0 : _b.call(_a, data);
|
|
112
|
-
});
|
|
113
|
-
this.client.request('v1.config', [], (error, data, end) => {
|
|
114
|
-
var _a, _b;
|
|
115
|
-
if (error) {
|
|
116
|
-
console.log('config error:', error, data);
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
(_b = (_a = this.options).config) === null || _b === void 0 ? void 0 : _b.call(_a, data);
|
|
120
|
-
});
|
|
121
|
-
// Register subscribed signals
|
|
122
|
-
if (this.subscribedSignals) {
|
|
123
|
-
this.client.request('v1.signals', [this.subscribedSignals], (error, data, end) => {
|
|
124
|
-
var _a, _b;
|
|
125
|
-
if (error) {
|
|
126
|
-
console.log('signals error:', error, data);
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
if (data) {
|
|
130
|
-
(_b = (_a = this.options).signals) === null || _b === void 0 ? void 0 : _b.call(_a, data);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
this.outside = false;
|
|
135
|
-
// Call connected callback
|
|
136
|
-
(_b = (_a = this.options).connected) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
// bail out unless appId is set, as the app is not properly registered
|
|
140
|
-
if (!this.appId) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
this.client.messageReceived(msg);
|
|
144
|
-
}
|
|
145
|
-
catch (error) {
|
|
146
|
-
console.error('Error handling message:', error);
|
|
147
|
-
}
|
|
148
|
-
}));
|
|
149
|
-
}
|
|
150
|
-
info() {
|
|
151
|
-
return {
|
|
152
|
-
hostUrl: this.hostUrl,
|
|
153
|
-
config: this.config,
|
|
154
|
-
outside: this.outside,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
// TODO: This is here for development and debugging, might be removed later
|
|
158
|
-
request(op, args) {
|
|
159
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
return yield this.client.requestAsync(op, args);
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}
|
package/lib/index.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { HailerError } from '../../types';
|
|
11
|
-
export class Kanban {
|
|
12
|
-
constructor(client) {
|
|
13
|
-
this.client = client;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Lists all activities in a kanban grouped by phases
|
|
17
|
-
*
|
|
18
|
-
* @param processId the id of the process the kanban relates to
|
|
19
|
-
* @param options object containing apiVersion option and requestOptions to be passed to the backend endpoint
|
|
20
|
-
*
|
|
21
|
-
* @returns activities in kanban list format
|
|
22
|
-
*
|
|
23
|
-
* @throws {HailerError} if request fails
|
|
24
|
-
*/
|
|
25
|
-
list(processId, options) {
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
try {
|
|
28
|
-
const res = yield this.client.requestAsync('v1.activity.kanban.list', [processId, ...options ? [options] : []]);
|
|
29
|
-
return res;
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
throw new HailerError(error);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Loads a single activity in kanban format
|
|
38
|
-
*
|
|
39
|
-
* @param activityId activityId of the wanted activity
|
|
40
|
-
* @param options object containing apiVersion option
|
|
41
|
-
*
|
|
42
|
-
* @returns activity in kanban format
|
|
43
|
-
*
|
|
44
|
-
* @throws {HailerError} if request is incorrect
|
|
45
|
-
*/
|
|
46
|
-
load(activityId) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
try {
|
|
49
|
-
const res = yield this.client.requestAsync('v1.activity.kanban.load', [activityId]);
|
|
50
|
-
return res;
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
throw new HailerError(error);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Updates priority of activities in kanban
|
|
59
|
-
*
|
|
60
|
-
* @param activityId activityId of the wanted activity
|
|
61
|
-
* @param priority new priority for the activity
|
|
62
|
-
* @param options object containing apiVersion option
|
|
63
|
-
*
|
|
64
|
-
* @throws {HailerError} if request is incorrect
|
|
65
|
-
*/
|
|
66
|
-
updatePriority(activityId, priority) {
|
|
67
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
try {
|
|
69
|
-
const res = yield this.client.requestAsync('v1.activity.kanban.updatePriority', [{ activityId, priority }]);
|
|
70
|
-
return res;
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
throw new HailerError(error);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
package/lib/modules/activity.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { HailerError } from '../types';
|
|
11
|
-
import { Kanban } from './activity/kanban';
|
|
12
|
-
export class Activity {
|
|
13
|
-
constructor(client) {
|
|
14
|
-
this.client = client;
|
|
15
|
-
this.kanban = new Kanban(client);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Lists all activities from the specified process and phase
|
|
19
|
-
*
|
|
20
|
-
* @param processId process from current network
|
|
21
|
-
* @param phaseId phase in the process specified in processId
|
|
22
|
-
* @param options options with apiVersion and requestOptions, default values can be found in api.hailer.com/docs v3.activity.list
|
|
23
|
-
*
|
|
24
|
-
* @returns List of Hailer activities from process and phase filtered with supplied options
|
|
25
|
-
*
|
|
26
|
-
* @throws {HailerError} if request is incorrect
|
|
27
|
-
*/
|
|
28
|
-
list(processId, phaseId, options) {
|
|
29
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
try {
|
|
31
|
-
const res = yield this.client.requestAsync('v1.activity.list', [processId, phaseId, options]);
|
|
32
|
-
return res.activities;
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
throw new HailerError(error);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Gets single activity
|
|
41
|
-
*
|
|
42
|
-
* @param activityId activity Id of the process specified in processId
|
|
43
|
-
* @param processId Process where the activityId is
|
|
44
|
-
* @param phaseId Phase where the activityId is in process specified by processId
|
|
45
|
-
* @param options options containing apiVersion
|
|
46
|
-
*
|
|
47
|
-
* @returns Hailer activity information or undefined if no activity is found
|
|
48
|
-
*
|
|
49
|
-
* @throws {HailerError} if request is incorrect
|
|
50
|
-
*/
|
|
51
|
-
get(activityId) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
try {
|
|
54
|
-
// Uses the same endpoint as getAll but only returns the activity in question
|
|
55
|
-
return yield this.client.requestAsync('v1.activity.get', [activityId]);
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
throw new HailerError(error);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Creates activities
|
|
64
|
-
*
|
|
65
|
-
* @param processId The process where the activity is created
|
|
66
|
-
* @param activities new activities as objects
|
|
67
|
-
* @param activities.name name of the activity
|
|
68
|
-
* @param activities.fields fields of the activity
|
|
69
|
-
* @param options optional options with apiVersion and requestOptions to be passed to the backend endpoint
|
|
70
|
-
*
|
|
71
|
-
* @throws {HailerError} if request is incorrect
|
|
72
|
-
*/
|
|
73
|
-
create(processId, activities, options) {
|
|
74
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
-
try {
|
|
76
|
-
const res = yield this.client.requestAsync('v1.activity.create', [processId, activities, ...options ? [options] : []]);
|
|
77
|
-
return res;
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
throw new HailerError(error);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Updates activites
|
|
86
|
-
*
|
|
87
|
-
* Each activity has the following parameters
|
|
88
|
-
* @param activities updated activity objects of an activity to edit
|
|
89
|
-
* @param activities.name New name of the activity
|
|
90
|
-
* @param activities.fields change values of fields, null removes current value
|
|
91
|
-
* @param activities.phaseId New phase of the activity
|
|
92
|
-
* @param options options containing apiVersion
|
|
93
|
-
*
|
|
94
|
-
* @returns The number of updated activities
|
|
95
|
-
*
|
|
96
|
-
* @throws {HailerError} if request is incorrect
|
|
97
|
-
*/
|
|
98
|
-
update(activities) {
|
|
99
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
try {
|
|
101
|
-
const res = yield this.client.requestAsync('v1.activity.update', activities);
|
|
102
|
-
return res;
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
throw new HailerError(error);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Removes activities
|
|
111
|
-
*
|
|
112
|
-
* @param activities Ids of activities to be removed
|
|
113
|
-
* @param options options containing apiVersion
|
|
114
|
-
*
|
|
115
|
-
* @returns The number of removed activities
|
|
116
|
-
*
|
|
117
|
-
* @throws {HailerError} if request is incorrect
|
|
118
|
-
*/
|
|
119
|
-
remove(activities) {
|
|
120
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
try {
|
|
122
|
-
const res = yield this.client.requestAsync('v1.activity.remove', activities);
|
|
123
|
-
return res;
|
|
124
|
-
}
|
|
125
|
-
catch (error) {
|
|
126
|
-
throw new HailerError(error);
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
package/lib/modules/insight.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { HailerError } from '../types';
|
|
11
|
-
export class Insight {
|
|
12
|
-
constructor(client) {
|
|
13
|
-
this.client = client;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Get Insight data
|
|
17
|
-
*
|
|
18
|
-
* @param insightId the id of the Insight the data is fetched from
|
|
19
|
-
* @param options object containing apiVersion option
|
|
20
|
-
*
|
|
21
|
-
* @returns data from the Insight
|
|
22
|
-
*
|
|
23
|
-
* @throws {HailerError} if request is incorrect
|
|
24
|
-
*/
|
|
25
|
-
data(insightId) {
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
try {
|
|
28
|
-
return yield this.client.requestAsync('v1.insight.data', [insightId]);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
throw new HailerError(error);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Get Insight data
|
|
37
|
-
*
|
|
38
|
-
* @param options object containing apiVersion option
|
|
39
|
-
*
|
|
40
|
-
* @returns data from the Insight
|
|
41
|
-
*
|
|
42
|
-
* @throws {HailerError} if request is incorrect
|
|
43
|
-
*/
|
|
44
|
-
list() {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
try {
|
|
47
|
-
return yield this.client.requestAsync('v1.insight.list', []);
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
throw new HailerError(error);
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
package/lib/modules/network.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { HailerError } from '../types';
|
|
11
|
-
export class Network {
|
|
12
|
-
constructor(client) {
|
|
13
|
-
this.client = client;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Returns the current network
|
|
17
|
-
*
|
|
18
|
-
* @returns the Hailer Workspace information the user is currently in
|
|
19
|
-
*
|
|
20
|
-
* @throws {HailerError} if request is incorrect
|
|
21
|
-
*/
|
|
22
|
-
current() {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
try {
|
|
25
|
-
const res = yield this.client.requestAsync('v1.network.current', []);
|
|
26
|
-
return res;
|
|
27
|
-
}
|
|
28
|
-
catch (error) {
|
|
29
|
-
throw new HailerError(error);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
}
|
package/lib/modules/process.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { HailerError } from '../types';
|
|
11
|
-
/** @deprecated Use Workflow instead */
|
|
12
|
-
export class Process {
|
|
13
|
-
constructor(client) {
|
|
14
|
-
this.client = client;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Lists all processes from a workspace
|
|
18
|
-
*
|
|
19
|
-
* @returns all Hailer processes in the workspace the app user is currently in
|
|
20
|
-
*
|
|
21
|
-
* @throws {HailerError} if request is incorrect
|
|
22
|
-
*/
|
|
23
|
-
list() {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
try {
|
|
26
|
-
const processes = yield this.client.requestAsync('v1.process.list', []);
|
|
27
|
-
return processes;
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
throw new HailerError(error);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Gets a single process from a workspace
|
|
36
|
-
*
|
|
37
|
-
* @param processId the id of the process in question
|
|
38
|
-
* @param options object containing apiVersion option
|
|
39
|
-
*
|
|
40
|
-
* @returns the specified Hailer process
|
|
41
|
-
*
|
|
42
|
-
* @throws {HailerError} if request is incorrect
|
|
43
|
-
*/
|
|
44
|
-
get(processId) {
|
|
45
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
try {
|
|
47
|
-
const process = yield this.client.requestAsync('v1.process.get', [processId]);
|
|
48
|
-
return process;
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
throw new HailerError(error);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Gets an id of a field in a process by its name
|
|
57
|
-
*
|
|
58
|
-
* @param processId the id of the process in question
|
|
59
|
-
* @param fieldName name of the field
|
|
60
|
-
* @param options object containing apiVersion option
|
|
61
|
-
*
|
|
62
|
-
* @returns the field id as string
|
|
63
|
-
*
|
|
64
|
-
* @throws {HailerError} if request is incorrect
|
|
65
|
-
*/
|
|
66
|
-
getFieldIdByName(processId, fieldName) {
|
|
67
|
-
var _a, _b;
|
|
68
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
try {
|
|
70
|
-
return (_b = Object.values(((_a = (yield this.get(processId))) === null || _a === void 0 ? void 0 : _a.fields) || {}).find((field) => field.label.toLowerCase() === fieldName)) === null || _b === void 0 ? void 0 : _b._id;
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
throw new HailerError(error);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export class App {
|
|
11
|
-
constructor(options) {
|
|
12
|
-
this.options = options;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Read data from app API
|
|
16
|
-
*
|
|
17
|
-
* @param appId key of a specific insight
|
|
18
|
-
*
|
|
19
|
-
* @returns App manifest
|
|
20
|
-
*
|
|
21
|
-
* @throws {HailerError} if there is something wrong with the request or insight cannot be found
|
|
22
|
-
* @throws {TypeError} if Hailer cannot be reached
|
|
23
|
-
*/
|
|
24
|
-
config() {
|
|
25
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
const manifestFile = 'manifest.json';
|
|
27
|
-
const location = window.location.origin + window.location.pathname;
|
|
28
|
-
let manifestUrl = location + manifestFile;
|
|
29
|
-
if (location.endsWith('/index.html')) {
|
|
30
|
-
manifestUrl = location.slice(0, -10) + manifestFile;
|
|
31
|
-
}
|
|
32
|
-
const manifestContent = yield (yield fetch(manifestUrl)).text();
|
|
33
|
-
const manifest = JSON.parse(manifestContent);
|
|
34
|
-
const appId = manifest.appId;
|
|
35
|
-
const res = yield fetch(this.options.publicBackendUrl + '/api/v3/app/public', {
|
|
36
|
-
method: 'POST',
|
|
37
|
-
headers: {
|
|
38
|
-
'Content-Type': 'application/json',
|
|
39
|
-
},
|
|
40
|
-
body: JSON.stringify([appId])
|
|
41
|
-
});
|
|
42
|
-
return yield res.json();
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|