@hailer/app-sdk 1.0.1-beta → 1.0.1-beta3

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.
@@ -1,69 +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
- import { HailerError } from '../../types';
11
- export class InsightPublicApi {
12
- constructor(options) {
13
- this.options = options;
14
- }
15
- /**
16
- * Read data from insight API
17
- *
18
- * @param insightKey key of a specific insight
19
- * @param options Overrides default request options, url defaults to https://api.hailer.com/api/v3/insight/public
20
- *
21
- * @returns Insight data as object
22
- *
23
- * @throws {HailerError} if there is something wrong with the request or insight cannot be found
24
- * @throws {TypeError} if Hailer cannot be reached
25
- */
26
- data(insightKey) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- const res = yield fetch(this.options.publicBackendUrl + '/api/v3/insight/public', {
29
- method: 'POST',
30
- headers: {
31
- 'Content-Type': 'application/json',
32
- },
33
- body: JSON.stringify([insightKey])
34
- });
35
- if (!res.ok) {
36
- throw new HailerError(yield res.json());
37
- }
38
- return yield res.json();
39
- });
40
- }
41
- /**
42
- * Read data from insight API and return in an array of JavaScript objects
43
- *
44
- * @param insightKey key of a specific insight
45
- * @param options Overrides default request options, url defaults to https://api.hailer.com/api/v3/insight/public
46
- *
47
- * @returns Insight data as array of JavaScript objects
48
- *
49
- * @throws {HailerError} if there is something wrong with the request or insight cannot be found
50
- * @throws {TypeError} if Hailer cannot be reached
51
- */
52
- dataAsObject(insightKey) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- const res = yield this.data(insightKey);
55
- const input = res.data;
56
- const data = [];
57
- input.rows.forEach((row) => {
58
- // The object keys are constructed dynamically, so any is necessary
59
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
60
- const object = {};
61
- input.headers.forEach((header, headerIndex) => {
62
- object[header] = row[headerIndex];
63
- });
64
- data.push(object);
65
- });
66
- return data;
67
- });
68
- }
69
- }
@@ -1,13 +0,0 @@
1
- import { App } from './public/app';
2
- import { Form } from './public/form';
3
- import { InsightPublicApi } from './public/insight';
4
- /**
5
- * This class is used to access Hailer public API even when the app is outside of Hailer
6
- */
7
- export class HailerPublicApi {
8
- constructor(options) {
9
- this.insight = new InsightPublicApi(options);
10
- this.form = new Form(options);
11
- this.app = new App(options);
12
- }
13
- }
@@ -1,28 +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
- export class Activity {
11
- constructor(client) {
12
- this.client = client;
13
- }
14
- /** Opens an activity in Hailer sidebar */
15
- open(
16
- /** Hailer Activity Id */
17
- activityId, options) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- yield this.client.requestAsync('v1.ui.activity.open', [activityId, ...options ? [options] : []]);
20
- });
21
- }
22
- /** Opens activity creation view in Hailer sidebar */
23
- create(processId, options) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- return yield this.client.requestAsync('v1.ui.activity.create', [processId, ...options ? [options] : []]);
26
- });
27
- }
28
- }
@@ -1,36 +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
- export class Files {
11
- constructor(client) {
12
- this.client = client;
13
- }
14
- /**
15
- * Uploads a file to Hailer
16
- *
17
- * @param file file to be uploaded
18
- * @param publicFile is the file accessible outside of Hailer
19
- * @param options if file is public
20
- *
21
- * @returns File ID in Hailer as string
22
- */
23
- uploadFile(file, filename, options) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- return yield this.client.requestAsync('v1.ui.file.upload', [yield this.toBase64(file), filename, !!(options === null || options === void 0 ? void 0 : options.isPublic)]);
26
- });
27
- }
28
- toBase64(file) {
29
- return new Promise((resolve, reject) => {
30
- const reader = new FileReader();
31
- reader.readAsDataURL(file);
32
- reader.onload = () => { var _a; return resolve((_a = reader.result) !== null && _a !== void 0 ? _a : ''); };
33
- reader.onerror = reject;
34
- });
35
- }
36
- }
@@ -1,31 +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
- export class Snackbar {
11
- constructor(client) {
12
- this.client = client;
13
- }
14
- /**
15
- * Opens a snackbar in Hailer
16
- * @param text the text displayed on the snackbar
17
- * @param buttonLabel the label for the button on the snackbar, for example 'OK'
18
- * @param duration the time the snackbar is visible in ms
19
- */
20
- open(
21
- /** The text displayed on the snackbar */
22
- text,
23
- /** The label for the button on the snackbar, for example 'OK' */
24
- buttonLabel,
25
- /** The time the snackbar is visible in ms */
26
- duration) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- yield this.client.requestAsync('v1.ui.snackbar.open', [text, buttonLabel, duration]);
29
- });
30
- }
31
- }
package/lib/modules/ui.js DELETED
@@ -1,11 +0,0 @@
1
- import { Activity } from './ui/activity';
2
- import { Snackbar } from './ui/snackbar';
3
- import { Files } from './ui/files';
4
- export class Ui {
5
- constructor(client) {
6
- this.client = client;
7
- this.activity = new Activity(client);
8
- this.snackbar = new Snackbar(client);
9
- this.files = new Files(client);
10
- }
11
- }
@@ -1,73 +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
- import { HailerError } from '../types';
11
- export class UserApi {
12
- constructor(client) {
13
- this.client = client;
14
- }
15
- /**
16
- * Returns the specified user
17
- *
18
- * @param userId id of the Hailer user
19
- *
20
- * @returns Hailer user information
21
- *
22
- * @throws {HailerError} if request is incorrect
23
- */
24
- get(userId) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- try {
27
- const res = yield this.client.requestAsync('v1.user.get', [userId]);
28
- return res;
29
- }
30
- catch (error) {
31
- throw new HailerError(error);
32
- }
33
- });
34
- }
35
- /**
36
- * Returns the current user
37
- *
38
- *
39
- * @returns the current Hailer user information
40
- *
41
- * @throws {HailerError} if request is incorrect
42
- */
43
- current() {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- try {
46
- const res = yield this.client.requestAsync('v1.user.current', []);
47
- return res;
48
- }
49
- catch (error) {
50
- throw new HailerError(error);
51
- }
52
- });
53
- }
54
- /**
55
- * Lists all Hailer users from a workspace
56
- *
57
- *
58
- * @returns list of Hailer users in the workspace the app user is currently in
59
- *
60
- * @throws {HailerError} if request is incorrect
61
- */
62
- list() {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- try {
65
- const users = yield this.client.requestAsync('v1.user.list', []);
66
- return users;
67
- }
68
- catch (error) {
69
- throw new HailerError(error);
70
- }
71
- });
72
- }
73
- }
@@ -1,53 +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
- import { HailerError } from '../types';
11
- export class WorkflowApi {
12
- constructor(client) {
13
- this.client = client;
14
- }
15
- /**
16
- * Lists all processes from a workspace
17
- *
18
- * @returns all Hailer processes in the workspace the app user is currently in
19
- *
20
- * @throws {HailerError} if request is incorrect
21
- */
22
- list() {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- try {
25
- const processes = yield this.client.requestAsync('v1.workflow.list', []);
26
- return processes;
27
- }
28
- catch (error) {
29
- throw new HailerError(error);
30
- }
31
- });
32
- }
33
- /**
34
- * Gets a single process from a workspace
35
- *
36
- * @param processId the id of the process in question
37
- *
38
- * @returns the specified Hailer process
39
- *
40
- * @throws {HailerError} if request is incorrect
41
- */
42
- get(processId) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- try {
45
- const process = yield this.client.requestAsync('v1.workflow.get', [processId]);
46
- return process;
47
- }
48
- catch (error) {
49
- throw new HailerError(error);
50
- }
51
- });
52
- }
53
- }
package/lib/types.js DELETED
@@ -1,9 +0,0 @@
1
- export class HailerError extends Error {
2
- constructor(error) {
3
- super();
4
- this.code = error.code;
5
- this.msg = error.msg;
6
- this.debug = error.debug;
7
- Object.setPrototypeOf(this, HailerError.prototype);
8
- }
9
- }