@hailer/app-sdk 1.0.0-beta

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.
Files changed (42) hide show
  1. package/README.md +12 -0
  2. package/lib/constants.d.ts +7 -0
  3. package/lib/constants.js +12 -0
  4. package/lib/hailer-api.d.ts +76 -0
  5. package/lib/hailer-api.js +165 -0
  6. package/lib/index.d.ts +2 -0
  7. package/lib/index.js +2 -0
  8. package/lib/modules/activity/kanban.d.ts +36 -0
  9. package/lib/modules/activity/kanban.js +75 -0
  10. package/lib/modules/activity.d.ts +83 -0
  11. package/lib/modules/activity.js +130 -0
  12. package/lib/modules/app.d.ts +12 -0
  13. package/lib/modules/app.js +29 -0
  14. package/lib/modules/insight.d.ts +25 -0
  15. package/lib/modules/insight.js +52 -0
  16. package/lib/modules/network.d.ts +14 -0
  17. package/lib/modules/network.js +33 -0
  18. package/lib/modules/process.d.ts +38 -0
  19. package/lib/modules/process.js +75 -0
  20. package/lib/modules/public/app.d.ts +17 -0
  21. package/lib/modules/public/app.js +45 -0
  22. package/lib/modules/public/form.d.ts +31 -0
  23. package/lib/modules/public/form.js +68 -0
  24. package/lib/modules/public/insight.d.ts +30 -0
  25. package/lib/modules/public/insight.js +69 -0
  26. package/lib/modules/public.d.ts +16 -0
  27. package/lib/modules/public.js +13 -0
  28. package/lib/modules/ui/activity.d.ts +28 -0
  29. package/lib/modules/ui/activity.js +28 -0
  30. package/lib/modules/ui/files.d.ts +18 -0
  31. package/lib/modules/ui/files.js +36 -0
  32. package/lib/modules/ui/snackbar.d.ts +18 -0
  33. package/lib/modules/ui/snackbar.js +31 -0
  34. package/lib/modules/ui.d.ts +11 -0
  35. package/lib/modules/ui.js +11 -0
  36. package/lib/modules/user.d.ts +36 -0
  37. package/lib/modules/user.js +73 -0
  38. package/lib/modules/workflow.d.ts +24 -0
  39. package/lib/modules/workflow.js +53 -0
  40. package/lib/types.d.ts +320 -0
  41. package/lib/types.js +9 -0
  42. package/package.json +28 -0
package/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # Hailer apps SDK
2
+
3
+ ## Building
4
+ ```bash
5
+ npm run build
6
+ ```
7
+
8
+ ## Documentation
9
+ Create a docs folder with typedoc
10
+ ```bash
11
+ npm run docs
12
+ ```
@@ -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
+ };
@@ -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', 'https://localhost:9443'];
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,76 @@
1
+ import { UserApi } from './modules/user';
2
+ import { ActivityApi } from './modules/activity';
3
+ import { WorkspaceApi } from './modules/network';
4
+ import { HailerApiInfo, HailerSettings, HailerSignal } from './types';
5
+ import { Ui } from './modules/ui';
6
+ import { Process } from './modules/process';
7
+ import { HailerPublicApi } from './modules/public';
8
+ import { WorkflowApi } from './modules/workflow';
9
+ import { AppApi } from './modules/app';
10
+ import { InsightApi } from './modules/insight';
11
+ export interface Options {
12
+ /** When connected is called the host is ready to receive calls */
13
+ connected?: () => void;
14
+ /** Callback when app is determined to be outside of Hailer, as a standalone app */
15
+ outside?: (config?: any) => void;
16
+ /** Callback on errors, defaults to printing errors in console */
17
+ error?: (error: Error) => void;
18
+ /** Callback called on app init and when permissions have changed */
19
+ permissions?: () => void;
20
+ /** Callback called on app init and when settings have changed */
21
+ settings?: (data: HailerSettings) => void;
22
+ /** Callback called on app init and when config has changed */
23
+ config?: (config: any) => void;
24
+ /** Will be called each time a subscribed signal is emitted from Hailer frontend. To subscribe to signals, add them to options.subscribedSignals[] */
25
+ signals?: (signal: HailerSignal) => void;
26
+ /** Urls the sdk is allowed to connect to. Defaults to all Hailer instances*/
27
+ allowedUrls?: string[];
28
+ /** The signals we want the Hailer frontend to pass to the app. If an empty array is provided, all signals will be passed. */
29
+ subscribedSignals?: string[];
30
+ /** Api version to be used in the app by default */
31
+ apiVersion?: 1;
32
+ /** Public backend Api url. Defaults to https://api.hailer.com */
33
+ publicBackendUrl?: string;
34
+ }
35
+ export declare class HailerApi {
36
+ options: Options;
37
+ user: UserApi;
38
+ app: AppApi;
39
+ activity: ActivityApi;
40
+ insight: InsightApi;
41
+ network: WorkspaceApi;
42
+ process: Process;
43
+ workflow: WorkflowApi;
44
+ /** All public endpoints, which can be accessed while not logged in to Hailer. */
45
+ public: HailerPublicApi;
46
+ /** User interface commands */
47
+ ui: Ui;
48
+ /** Url of the Hailer instance hosting the API */
49
+ private hostUrl?;
50
+ private appId?;
51
+ private client;
52
+ private apiVersion;
53
+ private settings?;
54
+ private config?;
55
+ private subscribedSignals?;
56
+ private timer?;
57
+ /**
58
+ * Hailer API state
59
+ *
60
+ * ```
61
+ * true // outside hailer
62
+ * false // logged into hailer
63
+ * null // state not yet detected
64
+ * ```
65
+ */
66
+ private outside;
67
+ /**
68
+ * Create a Hailer API client for inteacting with Hailer. **NOTE** This only works when inside Hailer.
69
+ *
70
+ * This should be run after window is initialized for example in ***onMount*** in Svelte or in ***useEffect*** in React
71
+ */
72
+ constructor(options?: Options);
73
+ private createEventListener;
74
+ info(): HailerApiInfo;
75
+ request(op: string, args: any[]): Promise<any>;
76
+ }
@@ -0,0 +1,165 @@
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 { UserApi } from './modules/user';
12
+ import { ActivityApi } from './modules/activity';
13
+ import { WorkspaceApi } from './modules/network';
14
+ import { Ui } from './modules/ui';
15
+ import { Process } from './modules/process';
16
+ import { DEFAULT_ALLOWED_URLS, DEFAULT_API_VERSION, DEFAULT_BACKEND_URL, publicBackendMap } from './constants';
17
+ import { HailerPublicApi } from './modules/public';
18
+ import { WorkflowApi } from './modules/workflow';
19
+ import { AppApi } from './modules/app';
20
+ import { InsightApi } from './modules/insight';
21
+ export class HailerApi {
22
+ /**
23
+ * Create a Hailer API client for inteacting with Hailer. **NOTE** This only works when inside Hailer.
24
+ *
25
+ * This should be run after window is initialized for example in ***onMount*** in Svelte or in ***useEffect*** in React
26
+ */
27
+ constructor(options = {}) {
28
+ var _a, _b;
29
+ this.options = options;
30
+ /**
31
+ * Hailer API state
32
+ *
33
+ * ```
34
+ * true // outside hailer
35
+ * false // logged into hailer
36
+ * null // state not yet detected
37
+ * ```
38
+ */
39
+ this.outside = null;
40
+ const allowedUrls = (_a = options.allowedUrls) !== null && _a !== void 0 ? _a : DEFAULT_ALLOWED_URLS;
41
+ this.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : DEFAULT_API_VERSION;
42
+ this.subscribedSignals = options.subscribedSignals;
43
+ this.client = new Client(msg => {
44
+ if (this.hostUrl) {
45
+ parent.postMessage(JSON.stringify(msg), this.hostUrl);
46
+ }
47
+ });
48
+ this.user = new UserApi(this.client);
49
+ this.app = new AppApi(this.client);
50
+ this.activity = new ActivityApi(this.client);
51
+ this.insight = new InsightApi(this.client);
52
+ this.network = new WorkspaceApi(this.client);
53
+ this.process = new Process(this.client);
54
+ this.workflow = new WorkflowApi(this.client);
55
+ this.public = new HailerPublicApi(this.options);
56
+ this.ui = new Ui(this.client);
57
+ const registerMessage = JSON.stringify({ op: 'register', args: [] });
58
+ // If we are not in Iframe set location to outside, else wait 100ms for response to register to check if we are in Hailer
59
+ if (window.location === window.parent.location) {
60
+ // Pick a backend to use for public requests, unless it is set
61
+ if (!this.options.publicBackendUrl) {
62
+ this.options.publicBackendUrl = DEFAULT_BACKEND_URL;
63
+ }
64
+ this.public.app.config().then(config => {
65
+ // CSM app assumes we are inside hailer when config is called... breaks the thing...
66
+ // this.options.config?.(config);
67
+ var _a, _b;
68
+ this.outside = true;
69
+ (_b = (_a = this.options).outside) === null || _b === void 0 ? void 0 : _b.call(_a, config);
70
+ }).catch(error => {
71
+ var _a, _b;
72
+ (_b = (_a = this.options).error) === null || _b === void 0 ? void 0 : _b.call(_a, error);
73
+ console.error('Failed to get app configuration in Public App.', error);
74
+ });
75
+ }
76
+ else {
77
+ // if in a frame, try register to Hailer by sending register to all allowed urls
78
+ allowedUrls.forEach(url => parent.postMessage(registerMessage, url));
79
+ this.timer = setTimeout(() => {
80
+ var _a, _b;
81
+ this.outside = true;
82
+ (_b = (_a = this.options).outside) === null || _b === void 0 ? void 0 : _b.call(_a);
83
+ }, 100);
84
+ }
85
+ this.createEventListener();
86
+ }
87
+ createEventListener() {
88
+ window.addEventListener('message', (event) => __awaiter(this, void 0, void 0, function* () {
89
+ var _a, _b;
90
+ const data = event.data;
91
+ try {
92
+ const msg = JSON.parse(data);
93
+ if (msg.op === 'register') {
94
+ if (this.appId) {
95
+ console.error('App Id is already set...! Are you using hot-reload?');
96
+ return;
97
+ }
98
+ clearTimeout(this.timer);
99
+ this.appId = msg.data.appId;
100
+ // Set host url now that we have a response
101
+ this.hostUrl = event.origin;
102
+ // Pick a backend to use for public requests, unless it is set
103
+ if (!this.options.publicBackendUrl) {
104
+ this.options.publicBackendUrl = publicBackendMap[this.hostUrl] || DEFAULT_BACKEND_URL;
105
+ }
106
+ // Register listeners for config and settings
107
+ this.client.request('v1.ui.settings', [], (error, data, end) => {
108
+ var _a, _b;
109
+ if (error) {
110
+ console.log('ui.settings error:', error, data);
111
+ return;
112
+ }
113
+ (_b = (_a = this.options).settings) === null || _b === void 0 ? void 0 : _b.call(_a, data);
114
+ });
115
+ this.client.request('v1.config', [], (error, data, end) => {
116
+ var _a, _b;
117
+ if (error) {
118
+ console.log('config error:', error, data);
119
+ return;
120
+ }
121
+ (_b = (_a = this.options).config) === null || _b === void 0 ? void 0 : _b.call(_a, data);
122
+ });
123
+ // Register subscribed signals
124
+ if (this.subscribedSignals) {
125
+ this.client.request('v1.signals', [this.subscribedSignals], (error, data, end) => {
126
+ var _a, _b;
127
+ if (error) {
128
+ console.log('signals error:', error, data);
129
+ return;
130
+ }
131
+ if (data) {
132
+ (_b = (_a = this.options).signals) === null || _b === void 0 ? void 0 : _b.call(_a, data);
133
+ }
134
+ });
135
+ }
136
+ this.outside = false;
137
+ // Call connected callback
138
+ (_b = (_a = this.options).connected) === null || _b === void 0 ? void 0 : _b.call(_a);
139
+ return;
140
+ }
141
+ // bail out unless appId is set, as the app is not properly registered
142
+ if (!this.appId) {
143
+ return;
144
+ }
145
+ this.client.messageReceived(msg);
146
+ }
147
+ catch (error) {
148
+ console.error('Error handling message:', error);
149
+ }
150
+ }));
151
+ }
152
+ info() {
153
+ return {
154
+ hostUrl: this.hostUrl,
155
+ config: this.config,
156
+ outside: this.outside,
157
+ };
158
+ }
159
+ // TODO: This is here for development and debugging, might be removed later
160
+ request(op, args) {
161
+ return __awaiter(this, void 0, void 0, function* () {
162
+ return yield this.client.requestAsync(op, args);
163
+ });
164
+ }
165
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { HailerApi } from './hailer-api';
2
+ export * from './types';
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { HailerApi } from './hailer-api';
2
+ export * from './types';
@@ -0,0 +1,36 @@
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 ActivityKanbanListOptions
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
+ *
22
+ * @returns activity in kanban format
23
+ *
24
+ * @throws {HailerError} if request is incorrect
25
+ */
26
+ load(activityId: string): Promise<KanbanLoadResponse>;
27
+ /**
28
+ * Updates priority of activities in kanban
29
+ *
30
+ * @param activityId activityId of the wanted activity
31
+ * @param priority new priority for the activity
32
+ *
33
+ * @throws {HailerError} if request is incorrect
34
+ */
35
+ updatePriority(activityId: string, priority: number): Promise<void>;
36
+ }
@@ -0,0 +1,75 @@
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 ActivityKanbanListOptions
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
+ *
41
+ * @returns activity in kanban format
42
+ *
43
+ * @throws {HailerError} if request is incorrect
44
+ */
45
+ load(activityId) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ try {
48
+ const res = yield this.client.requestAsync('v1.activity.kanban.load', [activityId]);
49
+ return res;
50
+ }
51
+ catch (error) {
52
+ throw new HailerError(error);
53
+ }
54
+ });
55
+ }
56
+ /**
57
+ * Updates priority of activities in kanban
58
+ *
59
+ * @param activityId activityId of the wanted activity
60
+ * @param priority new priority for the activity
61
+ *
62
+ * @throws {HailerError} if request is incorrect
63
+ */
64
+ updatePriority(activityId, priority) {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ try {
67
+ const res = yield this.client.requestAsync('v1.activity.kanban.updatePriority', [{ activityId, priority }]);
68
+ return res;
69
+ }
70
+ catch (error) {
71
+ throw new HailerError(error);
72
+ }
73
+ });
74
+ }
75
+ }
@@ -0,0 +1,83 @@
1
+ import { Client } from '@wishcore/wish-rpc';
2
+ import { ActivityCreateOptions, ActivityListOptions, Activity } from '../types';
3
+ import { Kanban } from './activity/kanban';
4
+ export declare class ActivityApi {
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 ActivityListOptions
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<Activity[]>;
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<Activity | 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 ActivityCreateOptions
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<Activity[]>;
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
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 ActivityApi {
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 ActivityListOptions
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 ActivityCreateOptions
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
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,12 @@
1
+ import { Client } from '@wishcore/wish-rpc';
2
+ import { HailerAppConfig } from '../types';
3
+ /**
4
+ * This class is used to access Hailer public API even when the app is outside of Hailer
5
+ */
6
+ export declare class AppApi {
7
+ private client;
8
+ constructor(client: Client);
9
+ config: {
10
+ update: (appId: string, config: HailerAppConfig) => Promise<void>;
11
+ };
12
+ }
@@ -0,0 +1,29 @@
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
+ /**
12
+ * This class is used to access Hailer public API even when the app is outside of Hailer
13
+ */
14
+ export class AppApi {
15
+ constructor(client) {
16
+ this.client = client;
17
+ this.config = {
18
+ update: (appId, config) => __awaiter(this, void 0, void 0, function* () {
19
+ try {
20
+ return yield this.client.requestAsync('v1.app.config.update', [appId, config]);
21
+ }
22
+ catch (error) {
23
+ console.log('Errorasd ', error);
24
+ throw new HailerError(error);
25
+ }
26
+ })
27
+ };
28
+ }
29
+ }
@@ -0,0 +1,25 @@
1
+ import { Client } from '@wishcore/wish-rpc';
2
+ import { InsightData, InsightDoc } from '../types';
3
+ export declare class InsightApi {
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
+ *
11
+ * @returns data from the Insight
12
+ *
13
+ * @throws {HailerError} if request is incorrect
14
+ */
15
+ data(insightId: string): Promise<InsightData>;
16
+ /**
17
+ * Get Insight data
18
+ *
19
+ *
20
+ * @returns data from the Insight
21
+ *
22
+ * @throws {HailerError} if request is incorrect
23
+ */
24
+ list(): Promise<InsightDoc[]>;
25
+ }