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

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 (60) hide show
  1. package/lib/app-sdk.js +2 -2
  2. package/lib/app-sdk.js.map +3 -3
  3. package/lib/modules/app.d.ts +8 -4
  4. package/lib/modules/product-installed.d.ts +40 -0
  5. package/lib/modules/product-version.d.ts +38 -0
  6. package/lib/modules/product.d.ts +4 -4
  7. package/lib/modules/public/product-version.d.ts +16 -0
  8. package/lib/modules/public/product.d.ts +2 -2
  9. package/lib/modules/public/version.d.ts +16 -0
  10. package/lib/modules/version.d.ts +16 -0
  11. package/lib/modules/workspace.d.ts +4 -2
  12. package/lib/src/constants.d.ts +7 -0
  13. package/lib/src/hailer-api.d.ts +92 -0
  14. package/lib/{index.js → src/index.d.ts} +0 -1
  15. package/lib/src/modules/activity/kanban.d.ts +36 -0
  16. package/lib/src/modules/activity.d.ts +83 -0
  17. package/lib/src/modules/app.d.ts +12 -0
  18. package/lib/src/modules/insight.d.ts +36 -0
  19. package/lib/src/modules/network.d.ts +14 -0
  20. package/lib/src/modules/permission.d.ts +9 -0
  21. package/lib/src/modules/process.d.ts +38 -0
  22. package/lib/src/modules/product-installed.d.ts +40 -0
  23. package/lib/src/modules/product-version.d.ts +16 -0
  24. package/lib/src/modules/product.d.ts +104 -0
  25. package/lib/src/modules/public/app.d.ts +17 -0
  26. package/lib/src/modules/public/form.d.ts +31 -0
  27. package/lib/src/modules/public/insight.d.ts +30 -0
  28. package/lib/src/modules/public/product-version.d.ts +16 -0
  29. package/lib/src/modules/public/product.d.ts +27 -0
  30. package/lib/src/modules/public.d.ts +22 -0
  31. package/lib/src/modules/ui/activity.d.ts +30 -0
  32. package/lib/src/modules/ui/files.d.ts +18 -0
  33. package/lib/src/modules/ui/snackbar.d.ts +18 -0
  34. package/lib/src/modules/ui.d.ts +17 -0
  35. package/lib/src/modules/user.d.ts +36 -0
  36. package/lib/src/modules/workflow.d.ts +24 -0
  37. package/lib/src/types.d.ts +381 -0
  38. package/lib/tools/publish.cjs +219 -183
  39. package/lib/tools/publish.cjs.map +7 -0
  40. package/lib/types.d.ts +9 -3
  41. package/lib/version.d.ts +0 -0
  42. package/package.json +2 -2
  43. package/lib/constants.js +0 -3
  44. package/lib/hailer-api.js +0 -147
  45. package/lib/modules/activity/kanban.js +0 -88
  46. package/lib/modules/activity.js +0 -170
  47. package/lib/modules/insight.js +0 -73
  48. package/lib/modules/network.js +0 -74
  49. package/lib/modules/process.js +0 -104
  50. package/lib/modules/public/form.js +0 -117
  51. package/lib/modules/public/insight.js +0 -114
  52. package/lib/modules/team.d.ts +0 -17
  53. package/lib/modules/ui/activity.js +0 -72
  54. package/lib/modules/ui.js +0 -10
  55. package/lib/modules/user.js +0 -133
  56. package/lib/public-api.d.ts +0 -16
  57. package/lib/public-api.js +0 -13
  58. package/lib/tools/minimal-password-prompt.d.ts +0 -1
  59. package/lib/tools/minimal-password-prompt.js +0 -50
  60. package/lib/types.js +0 -28
@@ -1,117 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- 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 };
@@ -1,114 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- 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 };
@@ -1,17 +0,0 @@
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
- }
@@ -1,72 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- 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 };
package/lib/modules/ui.js DELETED
@@ -1,10 +0,0 @@
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 };
@@ -1,133 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- 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 User = /** @class */ (function () {
39
- function User(client, apiVersion) {
40
- this.client = client;
41
- this.apiVersion = apiVersion;
42
- }
43
- /**
44
- * Returns the specified user
45
- *
46
- * @param userId id of the Hailer user
47
- * @param options object containing apiVersion option
48
- *
49
- * @returns Hailer user information
50
- *
51
- * @throws {HailerError} if request is incorrect
52
- */
53
- User.prototype.get = function (userId, options) {
54
- var _a;
55
- return __awaiter(this, void 0, void 0, function () {
56
- var res, 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, ".user.get"), [userId])];
62
- case 1:
63
- res = _b.sent();
64
- return [2 /*return*/, res];
65
- case 2:
66
- error_1 = _b.sent();
67
- throw new HailerError(error_1);
68
- case 3: return [2 /*return*/];
69
- }
70
- });
71
- });
72
- };
73
- /**
74
- * Returns the current user
75
- *
76
- * @param options object containing apiVersion option
77
- *
78
- * @returns the current Hailer user information
79
- *
80
- * @throws {HailerError} if request is incorrect
81
- */
82
- User.prototype.current = function (options) {
83
- var _a;
84
- return __awaiter(this, void 0, void 0, function () {
85
- var res, 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, ".user.current"), [])];
91
- case 1:
92
- res = _b.sent();
93
- return [2 /*return*/, res];
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
- /**
103
- * Lists all Hailer users from a workspace
104
- *
105
- * @param options object containing apiVersion option
106
- *
107
- * @returns list of Hailer users in the workspace the app user is currently in
108
- *
109
- * @throws {HailerError} if request is incorrect
110
- */
111
- User.prototype.list = function (options) {
112
- var _a;
113
- return __awaiter(this, void 0, void 0, function () {
114
- var users, error_3;
115
- return __generator(this, function (_b) {
116
- switch (_b.label) {
117
- case 0:
118
- _b.trys.push([0, 2, , 3]);
119
- 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, ".user.list"), [])];
120
- case 1:
121
- users = _b.sent();
122
- return [2 /*return*/, users];
123
- case 2:
124
- error_3 = _b.sent();
125
- throw new HailerError(error_3);
126
- case 3: return [2 /*return*/];
127
- }
128
- });
129
- });
130
- };
131
- return User;
132
- }());
133
- export { User };
@@ -1,16 +0,0 @@
1
- import { Form } from './modules/public/form';
2
- import { Insight } from './modules/public/insight';
3
- export declare class HailerApiPublic {
4
- /**
5
- * Allows accessing public insight methods. Used for reading data from Hailer when app is outside of Hailer
6
- */
7
- insight: Insight;
8
- /**
9
- * Allows accessing public forms methods. Used for sending data to Hailer when app is ran outside of Hailer
10
- */
11
- form: Form;
12
- /**
13
- * This class is used to access Hailer public API when the app is outside of Hailer
14
- */
15
- constructor();
16
- }
package/lib/public-api.js DELETED
@@ -1,13 +0,0 @@
1
- import { Form } from './modules/public/form';
2
- import { Insight } from './modules/public/insight';
3
- var HailerApiPublic = /** @class */ (function () {
4
- /**
5
- * This class is used to access Hailer public API when the app is outside of Hailer
6
- */
7
- function HailerApiPublic() {
8
- this.insight = new Insight();
9
- this.form = new Form();
10
- }
11
- return HailerApiPublic;
12
- }());
13
- export { HailerApiPublic };
@@ -1 +0,0 @@
1
- export declare const prompt: (question: string, ctrlcExits?: boolean) => Promise<string>;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- // Re-written to TypeScript to fix typing issue, see: https://www.npmjs.com/package/minimal-password-prompt/v/1.1.0
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.prompt = void 0;
5
- const stdin = process.stdin;
6
- const stdout = process.stdout;
7
- const captureStdin = (onData) => {
8
- stdin.setEncoding('utf-8');
9
- stdin.setRawMode(true);
10
- stdin.on('data', onData);
11
- stdin.resume();
12
- };
13
- const releaseStdin = (onData) => {
14
- stdin.pause();
15
- stdin.removeListener('data', onData);
16
- stdin.setRawMode(false);
17
- stdout.write('\n');
18
- };
19
- const prompt = (question, ctrlcExits = true) => (new Promise((resolve, reject) => {
20
- let input = '';
21
- const onData = (data) => {
22
- switch (data) {
23
- case '\u000A': // \n
24
- case '\u000D': // \r
25
- case '\u0004': // Ctrl+D
26
- releaseStdin(onData);
27
- resolve(input);
28
- break;
29
- case '\u0003': // Ctrl+C
30
- releaseStdin(onData);
31
- if (ctrlcExits) { // exit or raise error
32
- process.exit();
33
- }
34
- else {
35
- reject(new Error('Ctrl+C'));
36
- }
37
- break;
38
- case '\u0008': // Backspace
39
- case '\u007F': // Delete
40
- input = input.slice(0, -1);
41
- break;
42
- default: // any other
43
- input += data;
44
- }
45
- ;
46
- };
47
- captureStdin(onData);
48
- stdout.write(question);
49
- }));
50
- exports.prompt = prompt;
package/lib/types.js DELETED
@@ -1,28 +0,0 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
- var HailerError = /** @class */ (function (_super) {
17
- __extends(HailerError, _super);
18
- function HailerError(error) {
19
- var _this = _super.call(this) || this;
20
- _this.code = error.code;
21
- _this.msg = error.msg;
22
- _this.debug = error.debug;
23
- Object.setPrototypeOf(_this, HailerError.prototype);
24
- return _this;
25
- }
26
- return HailerError;
27
- }(Error));
28
- export { HailerError };