@hailer/app-sdk 1.0.3 → 2.0.0-beta-2

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 (66) hide show
  1. package/lib/app-sdk.js +2 -1
  2. package/lib/app-sdk.js.map +4 -4
  3. package/lib/constants.d.ts +0 -1
  4. package/lib/constants.js +3 -0
  5. package/lib/hailer-api.d.ts +4 -20
  6. package/lib/hailer-api.js +147 -0
  7. package/lib/{src/index.d.ts → index.js} +1 -0
  8. package/lib/modules/activity/kanban.js +88 -0
  9. package/lib/modules/activity.d.ts +6 -19
  10. package/lib/modules/activity.js +170 -0
  11. package/lib/modules/app.d.ts +4 -2
  12. package/lib/modules/insight.d.ts +0 -1
  13. package/lib/modules/insight.js +73 -0
  14. package/lib/modules/network.js +74 -0
  15. package/lib/modules/permission.d.ts +2 -1
  16. package/lib/modules/process.js +104 -0
  17. package/lib/modules/public/app.d.ts +2 -2
  18. package/lib/modules/public/form.js +117 -0
  19. package/lib/modules/public/insight.js +114 -0
  20. package/lib/modules/team.d.ts +17 -0
  21. package/lib/modules/ui/activity.js +72 -0
  22. package/lib/modules/ui.js +10 -0
  23. package/lib/modules/user.d.ts +1 -3
  24. package/lib/modules/user.js +133 -0
  25. package/lib/modules/workflow.d.ts +14 -2
  26. package/lib/public-api.d.ts +16 -0
  27. package/lib/public-api.js +13 -0
  28. package/lib/tools/minimal-password-prompt.d.ts +1 -0
  29. package/lib/tools/minimal-password-prompt.js +50 -0
  30. package/lib/tools/publish.cjs +121 -125
  31. package/lib/tools/replace-private.d.ts +1 -0
  32. package/lib/tools/replace-private.js +33 -0
  33. package/lib/types.d.ts +131 -42
  34. package/lib/types.js +28 -0
  35. package/package.json +2 -3
  36. package/lib/modules/product-installed.d.ts +0 -40
  37. package/lib/modules/product-version.d.ts +0 -38
  38. package/lib/modules/public/product-version.d.ts +0 -16
  39. package/lib/modules/public/version.d.ts +0 -16
  40. package/lib/modules/version.d.ts +0 -16
  41. package/lib/src/constants.d.ts +0 -7
  42. package/lib/src/hailer-api.d.ts +0 -92
  43. package/lib/src/modules/activity/kanban.d.ts +0 -36
  44. package/lib/src/modules/activity.d.ts +0 -83
  45. package/lib/src/modules/app.d.ts +0 -12
  46. package/lib/src/modules/insight.d.ts +0 -36
  47. package/lib/src/modules/network.d.ts +0 -14
  48. package/lib/src/modules/permission.d.ts +0 -9
  49. package/lib/src/modules/process.d.ts +0 -38
  50. package/lib/src/modules/product-installed.d.ts +0 -40
  51. package/lib/src/modules/product-version.d.ts +0 -16
  52. package/lib/src/modules/product.d.ts +0 -104
  53. package/lib/src/modules/public/app.d.ts +0 -17
  54. package/lib/src/modules/public/form.d.ts +0 -31
  55. package/lib/src/modules/public/insight.d.ts +0 -30
  56. package/lib/src/modules/public/product-version.d.ts +0 -16
  57. package/lib/src/modules/public/product.d.ts +0 -27
  58. package/lib/src/modules/public.d.ts +0 -22
  59. package/lib/src/modules/ui/activity.d.ts +0 -30
  60. package/lib/src/modules/ui/files.d.ts +0 -18
  61. package/lib/src/modules/ui/snackbar.d.ts +0 -18
  62. package/lib/src/modules/ui.d.ts +0 -17
  63. package/lib/src/modules/user.d.ts +0 -36
  64. package/lib/src/modules/workflow.d.ts +0 -24
  65. package/lib/src/types.d.ts +0 -381
  66. package/lib/version.d.ts +0 -0
@@ -1,9 +1,8 @@
1
1
  import { UserApi } from './modules/user';
2
2
  import { ActivityApi } from './modules/activity';
3
3
  import { WorkspaceApi } from './modules/workspace';
4
- import { HailerApiInfo, HailerSettings, HailerSignal } from './types';
4
+ import { ApiInfo, Settings, Signal } from './types';
5
5
  import { Ui } from './modules/ui';
6
- import { Process } from './modules/process';
7
6
  import { HailerPublicApi } from './modules/public';
8
7
  import { WorkflowApi } from './modules/workflow';
9
8
  import { AppApi } from './modules/app';
@@ -20,23 +19,13 @@ export interface Options {
20
19
  /** Callback called on app init and when permissions have changed */
21
20
  permissions?: () => void;
22
21
  /** Callback called on app init and when settings have changed */
23
- settings?: (data: HailerSettings) => void;
22
+ settings?: (data: Settings) => void;
24
23
  /** Callback called on app init and when config has changed */
25
24
  config?: (config: any) => void;
26
25
  /** Will be called each time a subscribed signal is emitted from Hailer frontend. To subscribe to signals, add them to options.subscribedSignals[] */
27
- signals?: (signal: HailerSignal) => void;
26
+ signals?: (signal: Signal) => void;
28
27
  /** Urls the sdk is allowed to connect to. Defaults to all Hailer instances*/
29
28
  allowedUrls?: string[];
30
- /**
31
- * Optional signal filter, passes all signals by default
32
- *
33
- * Example:
34
- *
35
- * subscribedSignals: ['activity.create', 'activity.update']
36
- */
37
- subscribedSignals?: string[];
38
- /** Api version to be used in the app by default */
39
- apiVersion?: 1;
40
29
  /** Public backend Api url. Defaults to https://api.hailer.com */
41
30
  publicBackendUrl?: string;
42
31
  }
@@ -47,7 +36,6 @@ export declare class HailerApi {
47
36
  activity: ActivityApi;
48
37
  insight: InsightApi;
49
38
  workspace: WorkspaceApi;
50
- process: Process;
51
39
  workflow: WorkflowApi;
52
40
  permission: PermissionApi;
53
41
  product: ProductApi;
@@ -61,10 +49,7 @@ export declare class HailerApi {
61
49
  /** If set it indicates that app is locked to a specific workspaceId */
62
50
  private workspaceId?;
63
51
  private client;
64
- private apiVersion;
65
- private settings?;
66
52
  private config?;
67
- private subscribedSignals?;
68
53
  private timer?;
69
54
  /**
70
55
  * Hailer API state
@@ -83,6 +68,5 @@ export declare class HailerApi {
83
68
  */
84
69
  constructor(options?: Options);
85
70
  private createEventListener;
86
- info(): HailerApiInfo;
87
- request(op: string, args: any[]): Promise<any>;
71
+ info(): ApiInfo;
88
72
  }
@@ -0,0 +1,147 @@
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
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import { Client } from '@wishcore/wish-rpc';
38
+ import { User } from './modules/user';
39
+ import { Activity } from './modules/activity';
40
+ import { Network } from './modules/network';
41
+ import { Ui } from './modules/ui';
42
+ import { Insight } from './modules/insight';
43
+ import { Process } from './modules/process';
44
+ import { DEFAULT_ALLOWED_URLS, DEFAULT_API_VERSION } from './constants';
45
+ var HailerApi = /** @class */ (function () {
46
+ /**
47
+ * Create a Hailer API client for inteacting with Hailer. **NOTE** This only works when inside Hailer.
48
+ *
49
+ * This should be run after window is initialized for example in ***onMount*** in Svelte or in ***useEffect*** in React
50
+ */
51
+ function HailerApi(options) {
52
+ if (options === void 0) { options = {}; }
53
+ var _this = this;
54
+ var _a, _b, _c, _d;
55
+ this.options = options;
56
+ var allowedUrls = (_a = options.allowedUrls) !== null && _a !== void 0 ? _a : DEFAULT_ALLOWED_URLS;
57
+ this.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : DEFAULT_API_VERSION;
58
+ this.subscribedSignals = options.subscribedSignals;
59
+ this.client = new Client(function (msg) {
60
+ if (_this.hostUrl) {
61
+ parent.postMessage(JSON.stringify(msg), _this.hostUrl);
62
+ }
63
+ });
64
+ this.user = new User(this.client, this.apiVersion);
65
+ this.activity = new Activity(this.client, this.apiVersion);
66
+ this.insight = new Insight(this.client, this.apiVersion);
67
+ this.network = new Network(this.client, this.apiVersion);
68
+ this.process = new Process(this.client, this.apiVersion);
69
+ this.ui = new Ui(this.client, this.apiVersion);
70
+ var registerMessage = JSON.stringify({ op: 'register', args: [] });
71
+ // If we are not in Iframe set location to outside, else wait 100ms for response to register to check if we are in Hailer
72
+ if (window.location === window.parent.location) {
73
+ (_d = (_c = this.options).outside) === null || _d === void 0 ? void 0 : _d.call(_c);
74
+ }
75
+ else {
76
+ // if in a frame, try register to Hailer by sending register to all allowed urls
77
+ allowedUrls.forEach(function (url) { return parent.postMessage(registerMessage, url); });
78
+ this.timer = setTimeout(function () { var _a, _b; return (_b = (_a = _this.options).outside) === null || _b === void 0 ? void 0 : _b.call(_a); }, 100);
79
+ }
80
+ this.createEventListener();
81
+ }
82
+ HailerApi.prototype.createEventListener = function () {
83
+ var _this = this;
84
+ window.addEventListener('message', function (event) {
85
+ var _a, _b;
86
+ var data = event.data;
87
+ try {
88
+ var msg = JSON.parse(data);
89
+ if (msg.op === 'register') {
90
+ clearTimeout(_this.timer);
91
+ _this.appId = msg.data.appId;
92
+ // Set host url now that we have a response
93
+ _this.hostUrl = event.origin;
94
+ // Register listeners for config and settings
95
+ _this.client.request("v".concat(_this.apiVersion, ".ui.settings"), [], function (error, data, end) {
96
+ var _a, _b;
97
+ if (error) {
98
+ console.log('ui.settings error:', error, data);
99
+ return;
100
+ }
101
+ (_b = (_a = _this.options).settings) === null || _b === void 0 ? void 0 : _b.call(_a, data);
102
+ });
103
+ _this.client.request("v".concat(_this.apiVersion, ".config"), [], function (error, data, end) {
104
+ var _a, _b;
105
+ if (error) {
106
+ console.log('config error:', error, data);
107
+ return;
108
+ }
109
+ (_b = (_a = _this.options).config) === null || _b === void 0 ? void 0 : _b.call(_a, data);
110
+ });
111
+ // Register subscribed signals
112
+ if (_this.subscribedSignals) {
113
+ _this.client.request("v".concat(_this.apiVersion, ".signals"), [_this.subscribedSignals], function (error, data, end) {
114
+ var _a, _b;
115
+ if (error) {
116
+ console.log('signals error:', error, data);
117
+ return;
118
+ }
119
+ if (data) {
120
+ (_b = (_a = _this.options).signals) === null || _b === void 0 ? void 0 : _b.call(_a, data);
121
+ }
122
+ });
123
+ }
124
+ // Call connected callback
125
+ (_b = (_a = _this.options).connected) === null || _b === void 0 ? void 0 : _b.call(_a);
126
+ }
127
+ _this.client.messageReceived(msg);
128
+ }
129
+ catch (error) {
130
+ console.error(error);
131
+ }
132
+ });
133
+ };
134
+ // TODO: This is here for development and debugging, might be removed later
135
+ HailerApi.prototype.request = function (op, args) {
136
+ return __awaiter(this, void 0, void 0, function () {
137
+ return __generator(this, function (_a) {
138
+ switch (_a.label) {
139
+ case 0: return [4 /*yield*/, this.client.requestAsync(op, args)];
140
+ case 1: return [2 /*return*/, _a.sent()];
141
+ }
142
+ });
143
+ });
144
+ };
145
+ return HailerApi;
146
+ }());
147
+ export { HailerApi };
@@ -1,2 +1,3 @@
1
1
  export { HailerApi } from './hailer-api';
2
+ export { HailerApiPublic } from './public-api';
2
3
  export * from './types';
@@ -0,0 +1,88 @@
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
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ var Kanban = /** @class */ (function () {
38
+ function Kanban(client, apiVersion) {
39
+ this.client = client;
40
+ this.apiVersion = apiVersion;
41
+ }
42
+ /**
43
+ * Lists all activities in a kanban grouped by phases
44
+ *
45
+ * @param processId the id of the process the kanban relates to
46
+ * @param options object containing apiVersion option and requestOptions to be passed to the backend endpoint
47
+ *
48
+ * @returns activities in kanban list format
49
+ */
50
+ Kanban.prototype.list = function (processId, options) {
51
+ var _a;
52
+ return __awaiter(this, void 0, void 0, function () {
53
+ var res;
54
+ return __generator(this, function (_b) {
55
+ switch (_b.label) {
56
+ case 0: return [4 /*yield*/, this.client.requestAsync("v".concat((_a = options === null || options === void 0 ? void 0 : options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion, ".activity.kanban.list"), [processId, options === null || options === void 0 ? void 0 : options.requestOptions])];
57
+ case 1:
58
+ res = _b.sent();
59
+ return [2 /*return*/, res];
60
+ }
61
+ });
62
+ });
63
+ };
64
+ /**
65
+ * Loads a single activity in kanban format
66
+ *
67
+ * @param activityId activityId of the wanted activity
68
+ * @param options object containing apiVersion option
69
+ *
70
+ * @returns activity in kanban format
71
+ */
72
+ Kanban.prototype.load = function (activityId, options) {
73
+ var _a;
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ var res;
76
+ return __generator(this, function (_b) {
77
+ switch (_b.label) {
78
+ case 0: return [4 /*yield*/, this.client.requestAsync("v".concat((_a = options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion, ".activity.kanban.load"), [activityId])];
79
+ case 1:
80
+ res = _b.sent();
81
+ return [2 /*return*/, res];
82
+ }
83
+ });
84
+ });
85
+ };
86
+ return Kanban;
87
+ }());
88
+ export { Kanban };
@@ -1,5 +1,5 @@
1
1
  import { Client } from '@wishcore/wish-rpc';
2
- import { ActivityCreateOptions, ActivityListOptions, Activity } from '../types';
2
+ import { ActivityCreateOptions, ActivityListOptions, Activity, ActivityFieldUpdateValue, ActivityUpdateOptions, ActivityFieldValue } from '../types';
3
3
  import { Kanban } from './activity/kanban';
4
4
  export declare class ActivityApi {
5
5
  private client;
@@ -33,30 +33,17 @@ export declare class ActivityApi {
33
33
  /**
34
34
  * Creates activities
35
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
36
  * @throws {HailerError} if request is incorrect
43
37
  */
44
- create(processId: string, activities: {
45
- name: string;
38
+ create(workflowId: string | undefined, activities: {
39
+ name?: string;
46
40
  fields?: {
47
- [id: string]: string | number;
41
+ [id: string]: ActivityFieldValue;
48
42
  };
49
43
  }[], options?: ActivityCreateOptions): Promise<Activity[]>;
50
44
  /**
51
45
  * Updates activites
52
46
  *
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
47
  * @returns The number of updated activities
61
48
  *
62
49
  * @throws {HailerError} if request is incorrect
@@ -65,10 +52,10 @@ export declare class ActivityApi {
65
52
  _id: string;
66
53
  name?: string;
67
54
  fields?: {
68
- [id: string]: string | number | null;
55
+ [id: string]: ActivityFieldUpdateValue;
69
56
  };
70
57
  phaseId?: string;
71
- }[], options: any): Promise<number>;
58
+ }[], options?: ActivityUpdateOptions): Promise<number>;
72
59
  /**
73
60
  * Removes activities
74
61
  *
@@ -0,0 +1,170 @@
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
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import { HailerError } from '../types';
38
+ var Activity = /** @class */ (function () {
39
+ function Activity(client, apiVersion) {
40
+ this.client = client;
41
+ this.apiVersion = apiVersion;
42
+ }
43
+ /**
44
+ * Lists all activities from the specified process and phase
45
+ *
46
+ * @param processId process from current network
47
+ * @param phaseId phase in the process specified in processId
48
+ * @param options options with apiVersion and requestOptions, default values can be found in api.hailer.com/docs v3.activity.list
49
+ *
50
+ * @returns List of Hailer activities from process and phase filtered with supplied options
51
+ *
52
+ * @throws {HailerError} if request is incorrect
53
+ */
54
+ Activity.prototype.list = function (processId, phaseId, options) {
55
+ var _a;
56
+ return __awaiter(this, void 0, void 0, function () {
57
+ var res, error_1;
58
+ return __generator(this, function (_b) {
59
+ switch (_b.label) {
60
+ case 0:
61
+ _b.trys.push([0, 2, , 3]);
62
+ return [4 /*yield*/, this.client.requestAsync("v".concat((_a = options === null || options === void 0 ? void 0 : options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion, ".activity.list"), [processId, phaseId, options === null || options === void 0 ? void 0 : options.requestOptions])];
63
+ case 1:
64
+ res = _b.sent();
65
+ return [2 /*return*/, res.activities];
66
+ case 2:
67
+ error_1 = _b.sent();
68
+ throw new HailerError(error_1);
69
+ case 3: return [2 /*return*/];
70
+ }
71
+ });
72
+ });
73
+ };
74
+ /**
75
+ * Gets single activity
76
+ *
77
+ * @param activityId activity Id of the process specified in processId
78
+ * @param processId Process where the activityId is
79
+ * @param phaseId Phase where the activityId is in process specified by processId
80
+ * @param options options containing apiVersion
81
+ *
82
+ * @returns Hailer activity information
83
+ *
84
+ * @throws {HailerError} if request is incorrect
85
+ */
86
+ Activity.prototype.get = function (activityId, processId, phaseId, options) {
87
+ var _a;
88
+ return __awaiter(this, void 0, void 0, function () {
89
+ var res, error_2;
90
+ return __generator(this, function (_b) {
91
+ switch (_b.label) {
92
+ case 0:
93
+ _b.trys.push([0, 2, , 3]);
94
+ return [4 /*yield*/, this.client.requestAsync("v".concat((_a = options === null || options === void 0 ? void 0 : options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion, ".activity.list"), [processId, phaseId])];
95
+ case 1:
96
+ res = _b.sent();
97
+ return [2 /*return*/, res.activities.find(function (activity) { return activity._id === activityId; })];
98
+ case 2:
99
+ error_2 = _b.sent();
100
+ throw new HailerError(error_2);
101
+ case 3: return [2 /*return*/];
102
+ }
103
+ });
104
+ });
105
+ };
106
+ /**
107
+ * Creates an activity
108
+ *
109
+ * @param processId The process where the activity is created
110
+ * @param activity Attributes of the new activity
111
+ * @param options optional options with apiVersion and requestOptions to be passed to the backend endpoint
112
+ *
113
+ * @throws {HailerError} if request is incorrect
114
+ */
115
+ Activity.prototype.create = function (processId, activities, options) {
116
+ var _a;
117
+ return __awaiter(this, void 0, void 0, function () {
118
+ var res, error_3;
119
+ return __generator(this, function (_b) {
120
+ switch (_b.label) {
121
+ case 0:
122
+ _b.trys.push([0, 2, , 3]);
123
+ return [4 /*yield*/, this.client.requestAsync("v".concat((_a = options === null || options === void 0 ? void 0 : options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion, ".activity.create"), [processId, activities])];
124
+ case 1:
125
+ res = _b.sent();
126
+ return [2 /*return*/, res];
127
+ case 2:
128
+ error_3 = _b.sent();
129
+ throw new HailerError(error_3);
130
+ case 3: return [2 /*return*/];
131
+ }
132
+ });
133
+ });
134
+ };
135
+ /**
136
+ * Updates an activity
137
+ *
138
+ * @param _id Id of an activity to edit
139
+ * @param name New name of the activity
140
+ * @param fields change values of fields, null removes current value
141
+ * @param phaseId New phase of the activity
142
+ * @param options options containing apiVersion
143
+ *
144
+ * @returns The number of updated activities
145
+ *
146
+ * @throws {HailerError} if request is incorrect
147
+ */
148
+ Activity.prototype.update = function (activity, options) {
149
+ var _a;
150
+ return __awaiter(this, void 0, void 0, function () {
151
+ var res, error_4;
152
+ return __generator(this, function (_b) {
153
+ switch (_b.label) {
154
+ case 0:
155
+ _b.trys.push([0, 2, , 3]);
156
+ return [4 /*yield*/, this.client.requestAsync("v".concat((_a = options === null || options === void 0 ? void 0 : options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion, ".activity.update"), [activity])];
157
+ case 1:
158
+ res = _b.sent();
159
+ return [2 /*return*/, res];
160
+ case 2:
161
+ error_4 = _b.sent();
162
+ throw new HailerError(error_4);
163
+ case 3: return [2 /*return*/];
164
+ }
165
+ });
166
+ });
167
+ };
168
+ return Activity;
169
+ }());
170
+ export { Activity };
@@ -1,5 +1,5 @@
1
1
  import { Client } from '@wishcore/wish-rpc';
2
- import { HailerAppConfig, ProductVersion, Version } from '../types';
2
+ import { Config, ProductVersion, Version } from '../types';
3
3
  /**
4
4
  * This class is used to access Hailer public API even when the app is outside of Hailer
5
5
  */
@@ -19,7 +19,9 @@ export declare class AppApi {
19
19
  };
20
20
  constructor(client: Client);
21
21
  config: {
22
- update: (appId: string | undefined, config: HailerAppConfig) => Promise<void>;
22
+ update: (config: Config, option?: {
23
+ appId?: string;
24
+ }) => Promise<void>;
23
25
  };
24
26
  /**
25
27
  * Check if product is installed
@@ -27,7 +27,6 @@ export declare class InsightApi {
27
27
  /**
28
28
  * Get Insight data
29
29
  *
30
- *
31
30
  * @returns data from the Insight
32
31
  *
33
32
  * @throws {HailerError} if request is incorrect
@@ -0,0 +1,73 @@
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
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import { HailerError } from '../types';
38
+ var Insight = /** @class */ (function () {
39
+ function Insight(client, apiVersion) {
40
+ this.client = client;
41
+ this.apiVersion = apiVersion;
42
+ }
43
+ /**
44
+ * Get Insight data
45
+ *
46
+ * @param insightId the id of the Insight the data is fetched from
47
+ * @param options object containing apiVersion option
48
+ *
49
+ * @returns data from the Insight
50
+ *
51
+ * @throws {HailerError} if request is incorrect
52
+ */
53
+ Insight.prototype.data = function (insightId, options) {
54
+ var _a;
55
+ return __awaiter(this, void 0, void 0, function () {
56
+ var error_1;
57
+ return __generator(this, function (_b) {
58
+ switch (_b.label) {
59
+ case 0:
60
+ _b.trys.push([0, 2, , 3]);
61
+ return [4 /*yield*/, this.client.requestAsync("v".concat((_a = options === null || options === void 0 ? void 0 : options.apiVersion) !== null && _a !== void 0 ? _a : this.apiVersion, ".insight.data"), [insightId])];
62
+ case 1: return [2 /*return*/, _b.sent()];
63
+ case 2:
64
+ error_1 = _b.sent();
65
+ throw new HailerError(error_1);
66
+ case 3: return [2 /*return*/];
67
+ }
68
+ });
69
+ });
70
+ };
71
+ return Insight;
72
+ }());
73
+ export { Insight };