@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
@@ -0,0 +1,74 @@
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 Network = /** @class */ (function () {
39
+ function Network(client, apiVersion) {
40
+ this.client = client;
41
+ this.apiVersion = apiVersion;
42
+ }
43
+ /**
44
+ * Returns the current network
45
+ *
46
+ * @param options object containing apiVersion option
47
+ *
48
+ * @returns the Hailer Workspace information the user is currently in
49
+ *
50
+ * @throws {HailerError} if request is incorrect
51
+ */
52
+ Network.prototype.current = function (options) {
53
+ var _a;
54
+ return __awaiter(this, void 0, void 0, function () {
55
+ var res, error_1;
56
+ return __generator(this, function (_b) {
57
+ switch (_b.label) {
58
+ case 0:
59
+ _b.trys.push([0, 2, , 3]);
60
+ 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, ".network.current"), [])];
61
+ case 1:
62
+ res = _b.sent();
63
+ return [2 /*return*/, res];
64
+ case 2:
65
+ error_1 = _b.sent();
66
+ throw new HailerError(error_1);
67
+ case 3: return [2 /*return*/];
68
+ }
69
+ });
70
+ });
71
+ };
72
+ return Network;
73
+ }());
74
+ export { Network };
@@ -1,9 +1,10 @@
1
1
  import { Client } from '@wishcore/wish-rpc';
2
+ import { PermissionMap } from '../types';
2
3
  /**
3
4
  * This class is used to access Hailer public API even when the app is outside of Hailer
4
5
  */
5
6
  export declare class PermissionApi {
6
7
  private client;
7
8
  constructor(client: Client);
8
- map: () => Promise<void>;
9
+ map: () => Promise<PermissionMap>;
9
10
  }
@@ -0,0 +1,104 @@
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 Process = /** @class */ (function () {
39
+ function Process(client, apiVersion) {
40
+ this.client = client;
41
+ this.apiVersion = apiVersion;
42
+ }
43
+ /**
44
+ * Lists all processes from a workspace
45
+ *
46
+ * @param options object containing apiVersion option
47
+ *
48
+ * @returns all Hailer processes in the workspace the app user is currently in
49
+ *
50
+ * @throws {HailerError} if request is incorrect
51
+ */
52
+ Process.prototype.list = function (options) {
53
+ var _a;
54
+ return __awaiter(this, void 0, void 0, function () {
55
+ var processes, error_1;
56
+ return __generator(this, function (_b) {
57
+ switch (_b.label) {
58
+ case 0:
59
+ _b.trys.push([0, 2, , 3]);
60
+ 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, ".process.list"), [])];
61
+ case 1:
62
+ processes = _b.sent();
63
+ return [2 /*return*/, processes];
64
+ case 2:
65
+ error_1 = _b.sent();
66
+ throw new HailerError(error_1);
67
+ case 3: return [2 /*return*/];
68
+ }
69
+ });
70
+ });
71
+ };
72
+ /**
73
+ * Gets a single process from a workspace
74
+ *
75
+ * @param processId the id of the process in question
76
+ * @param options object containing apiVersion option
77
+ *
78
+ * @returns the specified Hailer process
79
+ *
80
+ * @throws {HailerError} if request is incorrect
81
+ */
82
+ Process.prototype.get = function (processId, options) {
83
+ var _a;
84
+ return __awaiter(this, void 0, void 0, function () {
85
+ var process_1, error_2;
86
+ return __generator(this, function (_b) {
87
+ switch (_b.label) {
88
+ case 0:
89
+ _b.trys.push([0, 2, , 3]);
90
+ 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, ".process.get"), [processId])];
91
+ case 1:
92
+ process_1 = _b.sent();
93
+ return [2 /*return*/, process_1];
94
+ case 2:
95
+ error_2 = _b.sent();
96
+ throw new HailerError(error_2);
97
+ case 3: return [2 /*return*/];
98
+ }
99
+ });
100
+ });
101
+ };
102
+ return Process;
103
+ }());
104
+ export { Process };
@@ -1,5 +1,5 @@
1
1
  import { Options } from '../../hailer-api';
2
- import { HailerAppConfig } from '../../types';
2
+ import { Config } from '../../types';
3
3
  export declare class App {
4
4
  private options;
5
5
  constructor(options: Options);
@@ -13,5 +13,5 @@ export declare class App {
13
13
  * @throws {HailerError} if there is something wrong with the request or insight cannot be found
14
14
  * @throws {TypeError} if Hailer cannot be reached
15
15
  */
16
- config(): Promise<HailerAppConfig>;
16
+ config(): Promise<Config>;
17
17
  }
@@ -0,0 +1,117 @@
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 Form = /** @class */ (function () {
39
+ function Form() {
40
+ this.defaultFormsApi = 'https://api.hailer.com/api/v2/forms';
41
+ }
42
+ /**
43
+ * Read data from forms
44
+ *
45
+ * @param formsKey key of a form
46
+ * @param options Overrides default request options, url defaults to https://api.hailer.com/api/v2/forms
47
+ *
48
+ * @returns forms data as object or null if form could not be found
49
+ *
50
+ * @throws {HailerError} if there is something wrong with the request or form cannot be found
51
+ * @throws {TypeError} if Hailer cannot be reached
52
+ */
53
+ Form.prototype.data = function (formsKey, options) {
54
+ var _a;
55
+ return __awaiter(this, void 0, void 0, function () {
56
+ var res, _b;
57
+ return __generator(this, function (_c) {
58
+ switch (_c.label) {
59
+ case 0: return [4 /*yield*/, fetch("".concat((_a = options === null || options === void 0 ? void 0 : options.url) !== null && _a !== void 0 ? _a : this.defaultFormsApi, "/process/get"), {
60
+ method: 'POST',
61
+ headers: {
62
+ 'Content-Type': 'application/json',
63
+ },
64
+ body: JSON.stringify([formsKey])
65
+ })];
66
+ case 1:
67
+ res = _c.sent();
68
+ if (!!res.ok) return [3 /*break*/, 3];
69
+ _b = HailerError.bind;
70
+ return [4 /*yield*/, res.json()];
71
+ case 2: throw new (_b.apply(HailerError, [void 0, _c.sent()]))();
72
+ case 3: return [4 /*yield*/, res.json()];
73
+ case 4: return [2 /*return*/, _c.sent()];
74
+ }
75
+ });
76
+ });
77
+ };
78
+ /**
79
+ * Submits form to specified process
80
+ *
81
+ * @param formsKey key of a form
82
+ * @param formsData Data to be sent to form endpoint
83
+ * @param options Overrides default request options, url defaults to https://api.hailer.com/api/v2/forms
84
+ *
85
+ * @returns form creation data or null if form could not be created
86
+ *
87
+ * @throws {HailerError} if there is something wrong with the request or form cannot be found
88
+ * @throws {TypeError} if Hailer cannot be reached
89
+ */
90
+ Form.prototype.submit = function (formsKey, formsData, options) {
91
+ var _a;
92
+ return __awaiter(this, void 0, void 0, function () {
93
+ var res, _b;
94
+ return __generator(this, function (_c) {
95
+ switch (_c.label) {
96
+ case 0: return [4 /*yield*/, fetch("".concat((_a = options === null || options === void 0 ? void 0 : options.url) !== null && _a !== void 0 ? _a : this.defaultFormsApi, "/activity/create"), {
97
+ method: 'POST',
98
+ headers: {
99
+ 'Content-Type': 'application/json',
100
+ },
101
+ body: JSON.stringify([formsKey, formsData])
102
+ })];
103
+ case 1:
104
+ res = _c.sent();
105
+ if (!!res.ok) return [3 /*break*/, 3];
106
+ _b = HailerError.bind;
107
+ return [4 /*yield*/, res.json()];
108
+ case 2: throw new (_b.apply(HailerError, [void 0, _c.sent()]))();
109
+ case 3: return [4 /*yield*/, res.json()];
110
+ case 4: return [2 /*return*/, _c.sent()];
111
+ }
112
+ });
113
+ });
114
+ };
115
+ return Form;
116
+ }());
117
+ export { Form };
@@ -0,0 +1,114 @@
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() {
40
+ this.defaultInsightApi = 'https://api.hailer.com/api/v3/insight/public';
41
+ }
42
+ /**
43
+ * Read data from insight API
44
+ *
45
+ * @param insightKey key of a specific insight
46
+ * @param options Overrides default request options, url defaults to https://api.hailer.com/api/v3/insight/public
47
+ *
48
+ * @returns Insight data as object
49
+ *
50
+ * @throws {HailerError} if there is something wrong with the request or insight cannot be found
51
+ * @throws {TypeError} if Hailer cannot be reached
52
+ */
53
+ Insight.prototype.data = function (insightKey, options) {
54
+ var _a;
55
+ return __awaiter(this, void 0, void 0, function () {
56
+ var res, _b;
57
+ return __generator(this, function (_c) {
58
+ switch (_c.label) {
59
+ case 0: return [4 /*yield*/, fetch((_a = options === null || options === void 0 ? void 0 : options.url) !== null && _a !== void 0 ? _a : this.defaultInsightApi, {
60
+ method: 'POST',
61
+ headers: {
62
+ 'Content-Type': 'application/json',
63
+ },
64
+ body: JSON.stringify([insightKey])
65
+ })];
66
+ case 1:
67
+ res = _c.sent();
68
+ if (!!res.ok) return [3 /*break*/, 3];
69
+ _b = HailerError.bind;
70
+ return [4 /*yield*/, res.json()];
71
+ case 2: throw new (_b.apply(HailerError, [void 0, _c.sent()]))();
72
+ case 3: return [4 /*yield*/, res.json()];
73
+ case 4: return [2 /*return*/, _c.sent()];
74
+ }
75
+ });
76
+ });
77
+ };
78
+ /**
79
+ * Read data from insight API and return in an array of JavaScript objects
80
+ *
81
+ * @param insightKey key of a specific insight
82
+ * @param options Overrides default request options, url defaults to https://api.hailer.com/api/v3/insight/public
83
+ *
84
+ * @returns Insight data as array of JavaScript objects
85
+ *
86
+ * @throws {HailerError} if there is something wrong with the request or insight cannot be found
87
+ * @throws {TypeError} if Hailer cannot be reached
88
+ */
89
+ Insight.prototype.dataAsObject = function (insightKey, options) {
90
+ return __awaiter(this, void 0, void 0, function () {
91
+ var res, input, data;
92
+ return __generator(this, function (_a) {
93
+ switch (_a.label) {
94
+ case 0: return [4 /*yield*/, this.data(insightKey, options)];
95
+ case 1:
96
+ res = _a.sent();
97
+ input = res.data;
98
+ data = [];
99
+ input.rows.forEach(function (row) {
100
+ // The object keys are constructed dynamically, so any is necessary
101
+ var object = {};
102
+ input.headers.forEach(function (header, headerIndex) {
103
+ object[header] = row[headerIndex];
104
+ });
105
+ data.push(object);
106
+ });
107
+ return [2 /*return*/, data];
108
+ }
109
+ });
110
+ });
111
+ };
112
+ return Insight;
113
+ }());
114
+ export { Insight };
@@ -0,0 +1,17 @@
1
+ import { Client } from '@wishcore/wish-rpc';
2
+ import { TeamMap } from '../types';
3
+ export declare class TeamApi {
4
+ private client;
5
+ constructor(client: Client);
6
+ /**
7
+ * Lists all Hailer teams from a workspace
8
+ *
9
+ *
10
+ * @returns list of Hailer teams in the workspace the app user is currently in
11
+ *
12
+ * @throws {HailerError} if request is incorrect
13
+ */
14
+ list(): Promise<{
15
+ [workspaceId: string]: TeamMap;
16
+ }>;
17
+ }
@@ -0,0 +1,72 @@
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 Activity = /** @class */ (function () {
38
+ function Activity(client, apiVersion) {
39
+ this.client = client;
40
+ this.apiVersion = apiVersion;
41
+ }
42
+ /** Opens an activity in Hailer sidebar */
43
+ Activity.prototype.open = function (
44
+ /** Hailer Activity Id */
45
+ activityId, options) {
46
+ var _a;
47
+ return __awaiter(this, void 0, void 0, function () {
48
+ return __generator(this, function (_b) {
49
+ switch (_b.label) {
50
+ 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, ".ui.activity.open"), [activityId, options === null || options === void 0 ? void 0 : options.requestOptions])];
51
+ case 1:
52
+ _b.sent();
53
+ return [2 /*return*/];
54
+ }
55
+ });
56
+ });
57
+ };
58
+ /** Opens an activity in Hailer sidebar */
59
+ Activity.prototype.create = function (workflowId, options) {
60
+ var _a;
61
+ return __awaiter(this, void 0, void 0, function () {
62
+ return __generator(this, function (_b) {
63
+ switch (_b.label) {
64
+ 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, ".ui.activity.create"), [workflowId, options === null || options === void 0 ? void 0 : options.requestOptions])];
65
+ case 1: return [2 /*return*/, _b.sent()];
66
+ }
67
+ });
68
+ });
69
+ };
70
+ return Activity;
71
+ }());
72
+ export { Activity };
@@ -0,0 +1,10 @@
1
+ import { Activity } from './ui/activity';
2
+ var Ui = /** @class */ (function () {
3
+ function Ui(client, apiVersion) {
4
+ this.client = client;
5
+ this.apiVersion = apiVersion;
6
+ this.activity = new Activity(client, apiVersion);
7
+ }
8
+ return Ui;
9
+ }());
10
+ export { Ui };
@@ -30,7 +30,5 @@ export declare class UserApi {
30
30
  *
31
31
  * @throws {HailerError} if request is incorrect
32
32
  */
33
- list(): Promise<{
34
- [key: string]: User;
35
- }>;
33
+ list(): Promise<User[]>;
36
34
  }