@hailer/app-sdk 1.0.0
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/README.md +12 -0
- package/lib/constants.d.ts +7 -0
- package/lib/constants.js +12 -0
- package/lib/hailer-api.d.ts +74 -0
- package/lib/hailer-api.js +163 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/modules/activity/kanban.d.ts +38 -0
- package/lib/modules/activity/kanban.js +77 -0
- package/lib/modules/activity.d.ts +83 -0
- package/lib/modules/activity.js +130 -0
- package/lib/modules/insight.d.ts +27 -0
- package/lib/modules/insight.js +54 -0
- package/lib/modules/network.d.ts +14 -0
- package/lib/modules/network.js +33 -0
- package/lib/modules/process.d.ts +40 -0
- package/lib/modules/process.js +77 -0
- package/lib/modules/public/app.d.ts +17 -0
- package/lib/modules/public/app.js +45 -0
- package/lib/modules/public/form.d.ts +31 -0
- package/lib/modules/public/form.js +68 -0
- package/lib/modules/public/insight.d.ts +30 -0
- package/lib/modules/public/insight.js +69 -0
- package/lib/modules/public.d.ts +16 -0
- package/lib/modules/public.js +13 -0
- package/lib/modules/ui/activity.d.ts +25 -0
- package/lib/modules/ui/activity.js +28 -0
- package/lib/modules/ui/files.d.ts +18 -0
- package/lib/modules/ui/files.js +36 -0
- package/lib/modules/ui/snackbar.d.ts +19 -0
- package/lib/modules/ui/snackbar.js +32 -0
- package/lib/modules/ui.d.ts +11 -0
- package/lib/modules/ui.js +11 -0
- package/lib/modules/user.d.ts +39 -0
- package/lib/modules/user.js +76 -0
- package/lib/modules/workflow.d.ts +25 -0
- package/lib/modules/workflow.js +54 -0
- package/lib/types.d.ts +326 -0
- package/lib/types.js +9 -0
- package/package.json +28 -0
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const DEFAULT_API_VERSION = 1;
|
|
2
|
+
export declare const DEFAULT_ALLOWED_URLS: string[];
|
|
3
|
+
export declare const DEFAULT_BACKEND_URL = "https://api.hailer.com";
|
|
4
|
+
/** 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 */
|
|
5
|
+
export declare const publicBackendMap: {
|
|
6
|
+
[host: string]: string;
|
|
7
|
+
};
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { User } from './modules/user';
|
|
2
|
+
import { Activity } from './modules/activity';
|
|
3
|
+
import { Network } from './modules/network';
|
|
4
|
+
import { ApiVersion, HailerApiInfo, HailerSettings, HailerSignal } from './types';
|
|
5
|
+
import { Ui } from './modules/ui';
|
|
6
|
+
import { Insight } from './modules/insight';
|
|
7
|
+
import { Process } from './modules/process';
|
|
8
|
+
import { HailerApiPublic } from './modules/public';
|
|
9
|
+
import { Workflow } from './modules/workflow';
|
|
10
|
+
export interface Options {
|
|
11
|
+
/** When connected is called the host is ready to receive calls */
|
|
12
|
+
connected?: () => void;
|
|
13
|
+
/** Callback when app is determined to be outside of Hailer, as a standalone app */
|
|
14
|
+
outside?: (config?: any) => void;
|
|
15
|
+
/** Callback on errors, defaults to printing errors in console */
|
|
16
|
+
error?: (error: Error) => void;
|
|
17
|
+
/** Callback called on app init and when permissions have changed */
|
|
18
|
+
permissions?: () => void;
|
|
19
|
+
/** Callback called on app init and when settings have changed */
|
|
20
|
+
settings?: (data: HailerSettings) => void;
|
|
21
|
+
/** Callback called on app init and when config has changed */
|
|
22
|
+
config?: (config: any) => void;
|
|
23
|
+
/** Will be called each time a subscribed signal is emitted from Hailer frontend. To subscribe to signals, add them to options.subscribedSignals[] */
|
|
24
|
+
signals?: (signal: HailerSignal) => void;
|
|
25
|
+
/** Urls the sdk is allowed to connect to. Defaults to all Hailer instances*/
|
|
26
|
+
allowedUrls?: string[];
|
|
27
|
+
/** The signals we want the Hailer frontend to pass to the app. If an empty array is provided, all signals will be passed. */
|
|
28
|
+
subscribedSignals?: string[];
|
|
29
|
+
/** Api version to be used in the app by default */
|
|
30
|
+
apiVersion?: ApiVersion;
|
|
31
|
+
/** Public backend Api url. Defaults to https://api.hailer.com */
|
|
32
|
+
publicBackendUrl?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare class HailerApi {
|
|
35
|
+
options: Options;
|
|
36
|
+
user: User;
|
|
37
|
+
activity: Activity;
|
|
38
|
+
insight: Insight;
|
|
39
|
+
network: Network;
|
|
40
|
+
process: Process;
|
|
41
|
+
workflow: Workflow;
|
|
42
|
+
/** All public endpoints, which can be accessed while not logged in to Hailer. */
|
|
43
|
+
public: HailerApiPublic;
|
|
44
|
+
/** User interface commands */
|
|
45
|
+
ui: Ui;
|
|
46
|
+
/** Url of the Hailer instance hosting the API */
|
|
47
|
+
private hostUrl?;
|
|
48
|
+
private appId?;
|
|
49
|
+
private client;
|
|
50
|
+
private apiVersion;
|
|
51
|
+
private settings?;
|
|
52
|
+
private config?;
|
|
53
|
+
private subscribedSignals?;
|
|
54
|
+
private timer?;
|
|
55
|
+
/**
|
|
56
|
+
* Hailer API state
|
|
57
|
+
*
|
|
58
|
+
* ```
|
|
59
|
+
* true // outside hailer
|
|
60
|
+
* false // logged into hailer
|
|
61
|
+
* null // state not yet detected
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
private outside;
|
|
65
|
+
/**
|
|
66
|
+
* Create a Hailer API client for inteacting with Hailer. **NOTE** This only works when inside Hailer.
|
|
67
|
+
*
|
|
68
|
+
* This should be run after window is initialized for example in ***onMount*** in Svelte or in ***useEffect*** in React
|
|
69
|
+
*/
|
|
70
|
+
constructor(options?: Options);
|
|
71
|
+
private createEventListener;
|
|
72
|
+
info(): HailerApiInfo;
|
|
73
|
+
request(op: string, args: any[]): Promise<any>;
|
|
74
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
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.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Client } from '@wishcore/wish-rpc';
|
|
2
|
+
import { ActivityKanbanListOptions, KanbanListResponse, KanbanLoadResponse } from '../../types';
|
|
3
|
+
export declare class Kanban {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: Client);
|
|
6
|
+
/**
|
|
7
|
+
* Lists all activities in a kanban grouped by phases
|
|
8
|
+
*
|
|
9
|
+
* @param processId the id of the process the kanban relates to
|
|
10
|
+
* @param options object containing apiVersion option and requestOptions to be passed to the backend endpoint
|
|
11
|
+
*
|
|
12
|
+
* @returns activities in kanban list format
|
|
13
|
+
*
|
|
14
|
+
* @throws {HailerError} if request fails
|
|
15
|
+
*/
|
|
16
|
+
list(processId: string, options?: ActivityKanbanListOptions): Promise<KanbanListResponse>;
|
|
17
|
+
/**
|
|
18
|
+
* Loads a single activity in kanban format
|
|
19
|
+
*
|
|
20
|
+
* @param activityId activityId of the wanted activity
|
|
21
|
+
* @param options object containing apiVersion option
|
|
22
|
+
*
|
|
23
|
+
* @returns activity in kanban format
|
|
24
|
+
*
|
|
25
|
+
* @throws {HailerError} if request is incorrect
|
|
26
|
+
*/
|
|
27
|
+
load(activityId: string): Promise<KanbanLoadResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* Updates priority of activities in kanban
|
|
30
|
+
*
|
|
31
|
+
* @param activityId activityId of the wanted activity
|
|
32
|
+
* @param priority new priority for the activity
|
|
33
|
+
* @param options object containing apiVersion option
|
|
34
|
+
*
|
|
35
|
+
* @throws {HailerError} if request is incorrect
|
|
36
|
+
*/
|
|
37
|
+
updatePriority(activityId: string, priority: number): Promise<void>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Client } from '@wishcore/wish-rpc';
|
|
2
|
+
import { ActivityCreateOptions, ActivityListOptions, HailerActivity } from '../types';
|
|
3
|
+
import { Kanban } from './activity/kanban';
|
|
4
|
+
export declare class Activity {
|
|
5
|
+
private client;
|
|
6
|
+
kanban: Kanban;
|
|
7
|
+
constructor(client: Client);
|
|
8
|
+
/**
|
|
9
|
+
* Lists all activities from the specified process and phase
|
|
10
|
+
*
|
|
11
|
+
* @param processId process from current network
|
|
12
|
+
* @param phaseId phase in the process specified in processId
|
|
13
|
+
* @param options options with apiVersion and requestOptions, default values can be found in api.hailer.com/docs v3.activity.list
|
|
14
|
+
*
|
|
15
|
+
* @returns List of Hailer activities from process and phase filtered with supplied options
|
|
16
|
+
*
|
|
17
|
+
* @throws {HailerError} if request is incorrect
|
|
18
|
+
*/
|
|
19
|
+
list(processId: string, phaseId: string, options?: ActivityListOptions): Promise<HailerActivity[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Gets single activity
|
|
22
|
+
*
|
|
23
|
+
* @param activityId activity Id of the process specified in processId
|
|
24
|
+
* @param processId Process where the activityId is
|
|
25
|
+
* @param phaseId Phase where the activityId is in process specified by processId
|
|
26
|
+
* @param options options containing apiVersion
|
|
27
|
+
*
|
|
28
|
+
* @returns Hailer activity information or undefined if no activity is found
|
|
29
|
+
*
|
|
30
|
+
* @throws {HailerError} if request is incorrect
|
|
31
|
+
*/
|
|
32
|
+
get(activityId: string): Promise<HailerActivity | undefined>;
|
|
33
|
+
/**
|
|
34
|
+
* Creates activities
|
|
35
|
+
*
|
|
36
|
+
* @param processId The process where the activity is created
|
|
37
|
+
* @param activities new activities as objects
|
|
38
|
+
* @param activities.name name of the activity
|
|
39
|
+
* @param activities.fields fields of the activity
|
|
40
|
+
* @param options optional options with apiVersion and requestOptions to be passed to the backend endpoint
|
|
41
|
+
*
|
|
42
|
+
* @throws {HailerError} if request is incorrect
|
|
43
|
+
*/
|
|
44
|
+
create(processId: string, activities: {
|
|
45
|
+
name: string;
|
|
46
|
+
fields: {
|
|
47
|
+
[id: string]: string | number;
|
|
48
|
+
};
|
|
49
|
+
}[], options?: ActivityCreateOptions): Promise<HailerActivity[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Updates activites
|
|
52
|
+
*
|
|
53
|
+
* Each activity has the following parameters
|
|
54
|
+
* @param activities updated activity objects of an activity to edit
|
|
55
|
+
* @param activities.name New name of the activity
|
|
56
|
+
* @param activities.fields change values of fields, null removes current value
|
|
57
|
+
* @param activities.phaseId New phase of the activity
|
|
58
|
+
* @param options options containing apiVersion
|
|
59
|
+
*
|
|
60
|
+
* @returns The number of updated activities
|
|
61
|
+
*
|
|
62
|
+
* @throws {HailerError} if request is incorrect
|
|
63
|
+
*/
|
|
64
|
+
update(activities: {
|
|
65
|
+
_id: string;
|
|
66
|
+
name?: string;
|
|
67
|
+
fields?: {
|
|
68
|
+
[id: string]: string | number | null;
|
|
69
|
+
};
|
|
70
|
+
phaseId?: string;
|
|
71
|
+
}[]): Promise<number>;
|
|
72
|
+
/**
|
|
73
|
+
* Removes activities
|
|
74
|
+
*
|
|
75
|
+
* @param activities Ids of activities to be removed
|
|
76
|
+
* @param options options containing apiVersion
|
|
77
|
+
*
|
|
78
|
+
* @returns The number of removed activities
|
|
79
|
+
*
|
|
80
|
+
* @throws {HailerError} if request is incorrect
|
|
81
|
+
*/
|
|
82
|
+
remove(activities: string[]): Promise<number>;
|
|
83
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Client } from '@wishcore/wish-rpc';
|
|
2
|
+
import { InsightData, InsightDoc } from '../types';
|
|
3
|
+
export declare class Insight {
|
|
4
|
+
private client;
|
|
5
|
+
constructor(client: Client);
|
|
6
|
+
/**
|
|
7
|
+
* Get Insight data
|
|
8
|
+
*
|
|
9
|
+
* @param insightId the id of the Insight the data is fetched from
|
|
10
|
+
* @param options object containing apiVersion option
|
|
11
|
+
*
|
|
12
|
+
* @returns data from the Insight
|
|
13
|
+
*
|
|
14
|
+
* @throws {HailerError} if request is incorrect
|
|
15
|
+
*/
|
|
16
|
+
data(insightId: string): Promise<InsightData>;
|
|
17
|
+
/**
|
|
18
|
+
* Get Insight data
|
|
19
|
+
*
|
|
20
|
+
* @param options object containing apiVersion option
|
|
21
|
+
*
|
|
22
|
+
* @returns data from the Insight
|
|
23
|
+
*
|
|
24
|
+
* @throws {HailerError} if request is incorrect
|
|
25
|
+
*/
|
|
26
|
+
list(): Promise<InsightDoc[]>;
|
|
27
|
+
}
|