@hailer/app-sdk 1.0.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +12 -0
  2. package/lib/constants.d.ts +7 -0
  3. package/lib/constants.js +12 -0
  4. package/lib/hailer-api.d.ts +76 -0
  5. package/lib/hailer-api.js +165 -0
  6. package/lib/index.d.ts +2 -0
  7. package/lib/index.js +2 -0
  8. package/lib/modules/activity/kanban.d.ts +36 -0
  9. package/lib/modules/activity/kanban.js +75 -0
  10. package/lib/modules/activity.d.ts +83 -0
  11. package/lib/modules/activity.js +130 -0
  12. package/lib/modules/app.d.ts +12 -0
  13. package/lib/modules/app.js +29 -0
  14. package/lib/modules/insight.d.ts +25 -0
  15. package/lib/modules/insight.js +52 -0
  16. package/lib/modules/network.d.ts +14 -0
  17. package/lib/modules/network.js +33 -0
  18. package/lib/modules/process.d.ts +38 -0
  19. package/lib/modules/process.js +75 -0
  20. package/lib/modules/public/app.d.ts +17 -0
  21. package/lib/modules/public/app.js +45 -0
  22. package/lib/modules/public/form.d.ts +31 -0
  23. package/lib/modules/public/form.js +68 -0
  24. package/lib/modules/public/insight.d.ts +30 -0
  25. package/lib/modules/public/insight.js +69 -0
  26. package/lib/modules/public.d.ts +16 -0
  27. package/lib/modules/public.js +13 -0
  28. package/lib/modules/ui/activity.d.ts +28 -0
  29. package/lib/modules/ui/activity.js +28 -0
  30. package/lib/modules/ui/files.d.ts +18 -0
  31. package/lib/modules/ui/files.js +36 -0
  32. package/lib/modules/ui/snackbar.d.ts +18 -0
  33. package/lib/modules/ui/snackbar.js +31 -0
  34. package/lib/modules/ui.d.ts +11 -0
  35. package/lib/modules/ui.js +11 -0
  36. package/lib/modules/user.d.ts +36 -0
  37. package/lib/modules/user.js +73 -0
  38. package/lib/modules/workflow.d.ts +24 -0
  39. package/lib/modules/workflow.js +53 -0
  40. package/lib/types.d.ts +320 -0
  41. package/lib/types.js +9 -0
  42. package/package.json +28 -0
@@ -0,0 +1,52 @@
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 InsightApi {
12
+ constructor(client) {
13
+ this.client = client;
14
+ }
15
+ /**
16
+ * Get Insight data
17
+ *
18
+ * @param insightId the id of the Insight the data is fetched from
19
+ *
20
+ * @returns data from the Insight
21
+ *
22
+ * @throws {HailerError} if request is incorrect
23
+ */
24
+ data(insightId) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ try {
27
+ return yield this.client.requestAsync('v1.insight.data', [insightId]);
28
+ }
29
+ catch (error) {
30
+ throw new HailerError(error);
31
+ }
32
+ });
33
+ }
34
+ /**
35
+ * Get Insight data
36
+ *
37
+ *
38
+ * @returns data from the Insight
39
+ *
40
+ * @throws {HailerError} if request is incorrect
41
+ */
42
+ list() {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ try {
45
+ return yield this.client.requestAsync('v1.insight.list', []);
46
+ }
47
+ catch (error) {
48
+ throw new HailerError(error);
49
+ }
50
+ });
51
+ }
52
+ }
@@ -0,0 +1,14 @@
1
+ import { Client } from '@wishcore/wish-rpc';
2
+ import { Workspace } from '../types';
3
+ export declare class WorkspaceApi {
4
+ private client;
5
+ constructor(client: Client);
6
+ /**
7
+ * Returns the current network
8
+ *
9
+ * @returns the Hailer Workspace information the user is currently in
10
+ *
11
+ * @throws {HailerError} if request is incorrect
12
+ */
13
+ current(): Promise<Workspace>;
14
+ }
@@ -0,0 +1,33 @@
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 WorkspaceApi {
12
+ constructor(client) {
13
+ this.client = client;
14
+ }
15
+ /**
16
+ * Returns the current network
17
+ *
18
+ * @returns the Hailer Workspace information the user is currently in
19
+ *
20
+ * @throws {HailerError} if request is incorrect
21
+ */
22
+ current() {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ try {
25
+ const res = yield this.client.requestAsync('v1.network.current', []);
26
+ return res;
27
+ }
28
+ catch (error) {
29
+ throw new HailerError(error);
30
+ }
31
+ });
32
+ }
33
+ }
@@ -0,0 +1,38 @@
1
+ import { Client } from '@wishcore/wish-rpc';
2
+ import { HailerProcess } from '../types';
3
+ /** @deprecated Use Workflow instead */
4
+ export declare class Process {
5
+ private client;
6
+ constructor(client: Client);
7
+ /**
8
+ * Lists all processes from a workspace
9
+ *
10
+ * @returns all Hailer processes in the workspace the app user is currently in
11
+ *
12
+ * @throws {HailerError} if request is incorrect
13
+ */
14
+ list(): Promise<{
15
+ [key: string]: HailerProcess;
16
+ }>;
17
+ /**
18
+ * Gets a single process from a workspace
19
+ *
20
+ * @param processId the id of the process in question
21
+ *
22
+ * @returns the specified Hailer process
23
+ *
24
+ * @throws {HailerError} if request is incorrect
25
+ */
26
+ get(processId: string): Promise<HailerProcess>;
27
+ /**
28
+ * Gets an id of a field in a process by its name
29
+ *
30
+ * @param processId the id of the process in question
31
+ * @param fieldName name of the field
32
+ *
33
+ * @returns the field id as string
34
+ *
35
+ * @throws {HailerError} if request is incorrect
36
+ */
37
+ getFieldIdByName(processId: string, fieldName: string): Promise<string>;
38
+ }
@@ -0,0 +1,75 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { HailerError } from '../types';
11
+ /** @deprecated Use Workflow instead */
12
+ export class Process {
13
+ constructor(client) {
14
+ this.client = client;
15
+ }
16
+ /**
17
+ * Lists all processes from a workspace
18
+ *
19
+ * @returns all Hailer processes in the workspace the app user is currently in
20
+ *
21
+ * @throws {HailerError} if request is incorrect
22
+ */
23
+ list() {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ try {
26
+ const processes = yield this.client.requestAsync('v1.process.list', []);
27
+ return processes;
28
+ }
29
+ catch (error) {
30
+ throw new HailerError(error);
31
+ }
32
+ });
33
+ }
34
+ /**
35
+ * Gets a single process from a workspace
36
+ *
37
+ * @param processId the id of the process in question
38
+ *
39
+ * @returns the specified Hailer process
40
+ *
41
+ * @throws {HailerError} if request is incorrect
42
+ */
43
+ get(processId) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ try {
46
+ const process = yield this.client.requestAsync('v1.process.get', [processId]);
47
+ return process;
48
+ }
49
+ catch (error) {
50
+ throw new HailerError(error);
51
+ }
52
+ });
53
+ }
54
+ /**
55
+ * Gets an id of a field in a process by its name
56
+ *
57
+ * @param processId the id of the process in question
58
+ * @param fieldName name of the field
59
+ *
60
+ * @returns the field id as string
61
+ *
62
+ * @throws {HailerError} if request is incorrect
63
+ */
64
+ getFieldIdByName(processId, fieldName) {
65
+ var _a, _b;
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ try {
68
+ return (_b = Object.values(((_a = (yield this.get(processId))) === null || _a === void 0 ? void 0 : _a.fields) || {}).find((field) => field.label.toLowerCase() === fieldName)) === null || _b === void 0 ? void 0 : _b._id;
69
+ }
70
+ catch (error) {
71
+ throw new HailerError(error);
72
+ }
73
+ });
74
+ }
75
+ }
@@ -0,0 +1,17 @@
1
+ import { Options } from '../../hailer-api';
2
+ import { HailerAppConfig } from '../../types';
3
+ export declare class App {
4
+ private options;
5
+ constructor(options: Options);
6
+ /**
7
+ * Read data from app API
8
+ *
9
+ * @param appId key of a specific insight
10
+ *
11
+ * @returns App manifest
12
+ *
13
+ * @throws {HailerError} if there is something wrong with the request or insight cannot be found
14
+ * @throws {TypeError} if Hailer cannot be reached
15
+ */
16
+ config(): Promise<HailerAppConfig>;
17
+ }
@@ -0,0 +1,45 @@
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 App {
11
+ constructor(options) {
12
+ this.options = options;
13
+ }
14
+ /**
15
+ * Read data from app API
16
+ *
17
+ * @param appId key of a specific insight
18
+ *
19
+ * @returns App manifest
20
+ *
21
+ * @throws {HailerError} if there is something wrong with the request or insight cannot be found
22
+ * @throws {TypeError} if Hailer cannot be reached
23
+ */
24
+ config() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const manifestFile = 'manifest.json';
27
+ const location = window.location.origin + window.location.pathname;
28
+ let manifestUrl = location + manifestFile;
29
+ if (location.endsWith('/index.html')) {
30
+ manifestUrl = location.slice(0, -10) + manifestFile;
31
+ }
32
+ const manifestContent = yield (yield fetch(manifestUrl)).text();
33
+ const manifest = JSON.parse(manifestContent);
34
+ const appId = manifest.appId;
35
+ const res = yield fetch(this.options.publicBackendUrl + '/api/v3/app/public', {
36
+ method: 'POST',
37
+ headers: {
38
+ 'Content-Type': 'application/json',
39
+ },
40
+ body: JSON.stringify([appId])
41
+ });
42
+ return yield res.json();
43
+ });
44
+ }
45
+ }
@@ -0,0 +1,31 @@
1
+ import { Options } from '../../hailer-api';
2
+ import { FormCreateResponse, FormsData, FormsResponse } from '../../types';
3
+ export declare class Form {
4
+ private options;
5
+ constructor(options: Options);
6
+ /**
7
+ * Read data from forms
8
+ *
9
+ * @param formsKey key of a form
10
+ * @param options Overrides default request options, url defaults to https://api.hailer.com/api/v2/forms
11
+ *
12
+ * @returns forms data as object or null if form could not be found
13
+ *
14
+ * @throws {HailerError} if there is something wrong with the request or form cannot be found
15
+ * @throws {TypeError} if Hailer cannot be reached
16
+ */
17
+ data(formsKey: string): Promise<FormsResponse>;
18
+ /**
19
+ * Submits form to specified process
20
+ *
21
+ * @param formsKey key of a form
22
+ * @param formsData Data to be sent to form endpoint
23
+ * @param options Overrides default request options, url defaults to https://api.hailer.com/api/v2/forms
24
+ *
25
+ * @returns form creation data or null if form could not be created
26
+ *
27
+ * @throws {HailerError} if there is something wrong with the request or form cannot be found
28
+ * @throws {TypeError} if Hailer cannot be reached
29
+ */
30
+ submit(formsKey: string, formsData: FormsData): Promise<FormCreateResponse>;
31
+ }
@@ -0,0 +1,68 @@
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 Form {
12
+ constructor(options) {
13
+ this.options = options;
14
+ }
15
+ /**
16
+ * Read data from forms
17
+ *
18
+ * @param formsKey key of a form
19
+ * @param options Overrides default request options, url defaults to https://api.hailer.com/api/v2/forms
20
+ *
21
+ * @returns forms data as object or null if form could not be found
22
+ *
23
+ * @throws {HailerError} if there is something wrong with the request or form cannot be found
24
+ * @throws {TypeError} if Hailer cannot be reached
25
+ */
26
+ data(formsKey) {
27
+ return __awaiter(this, void 0, void 0, function* () {
28
+ const res = yield fetch(this.options.publicBackendUrl + '/api/v2/forms/process/get', {
29
+ method: 'POST',
30
+ headers: {
31
+ 'Content-Type': 'application/json',
32
+ },
33
+ body: JSON.stringify([formsKey])
34
+ });
35
+ if (!res.ok) {
36
+ throw new HailerError(yield res.json());
37
+ }
38
+ return yield res.json();
39
+ });
40
+ }
41
+ /**
42
+ * Submits form to specified process
43
+ *
44
+ * @param formsKey key of a form
45
+ * @param formsData Data to be sent to form endpoint
46
+ * @param options Overrides default request options, url defaults to https://api.hailer.com/api/v2/forms
47
+ *
48
+ * @returns form creation data or null if form could not be created
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
+ submit(formsKey, formsData) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const res = yield fetch(this.options.publicBackendUrl + '/api/v2/forms/activity/create', {
56
+ method: 'POST',
57
+ headers: {
58
+ 'Content-Type': 'application/json',
59
+ },
60
+ body: JSON.stringify([formsKey, formsData])
61
+ });
62
+ if (!res.ok) {
63
+ throw new HailerError(yield res.json());
64
+ }
65
+ return yield res.json();
66
+ });
67
+ }
68
+ }
@@ -0,0 +1,30 @@
1
+ import { Options } from '../../hailer-api';
2
+ import { InsightResponse, InsightResponseAsObjects } from '../../types';
3
+ export declare class InsightPublicApi {
4
+ private options;
5
+ constructor(options: Options);
6
+ /**
7
+ * Read data from insight API
8
+ *
9
+ * @param insightKey key of a specific insight
10
+ * @param options Overrides default request options, url defaults to https://api.hailer.com/api/v3/insight/public
11
+ *
12
+ * @returns Insight data as object
13
+ *
14
+ * @throws {HailerError} if there is something wrong with the request or insight cannot be found
15
+ * @throws {TypeError} if Hailer cannot be reached
16
+ */
17
+ data(insightKey: string): Promise<InsightResponse>;
18
+ /**
19
+ * Read data from insight API and return in an array of JavaScript objects
20
+ *
21
+ * @param insightKey key of a specific insight
22
+ * @param options Overrides default request options, url defaults to https://api.hailer.com/api/v3/insight/public
23
+ *
24
+ * @returns Insight data as array of JavaScript objects
25
+ *
26
+ * @throws {HailerError} if there is something wrong with the request or insight cannot be found
27
+ * @throws {TypeError} if Hailer cannot be reached
28
+ */
29
+ dataAsObject(insightKey: string): Promise<InsightResponseAsObjects>;
30
+ }
@@ -0,0 +1,69 @@
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
+ }
@@ -0,0 +1,16 @@
1
+ import { Options } from '../hailer-api';
2
+ import { App } from './public/app';
3
+ import { Form } from './public/form';
4
+ import { InsightPublicApi } from './public/insight';
5
+ /**
6
+ * This class is used to access Hailer public API even when the app is outside of Hailer
7
+ */
8
+ export declare class HailerPublicApi {
9
+ /** Allows accessing public insight methods. Used for reading data from Hailer even when app is outside of Hailer */
10
+ insight: InsightPublicApi;
11
+ /** Allows accessing public forms methods. Used for sending data to Hailer even when app is outside of Hailer */
12
+ form: Form;
13
+ /** Access public App information */
14
+ app: App;
15
+ constructor(options: Options);
16
+ }
@@ -0,0 +1,13 @@
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
+ }
@@ -0,0 +1,28 @@
1
+ import { Client } from '@wishcore/wish-rpc';
2
+ export type ActivityTabTypes = 'detail' | 'discussion' | 'files' | 'location' | 'linkedFrom' | 'options';
3
+ export declare class Activity {
4
+ private client;
5
+ constructor(client: Client);
6
+ /** Opens an activity in Hailer sidebar */
7
+ open(
8
+ /** Hailer Activity Id */
9
+ activityId: string, options?: {
10
+ /** Which tab to open in activity aside */
11
+ tab?: ActivityTabTypes;
12
+ }): Promise<void>;
13
+ /** Opens activity creation view in Hailer sidebar */
14
+ create(processId: string, options?: {
15
+ /** Activity name/title */
16
+ name?: string;
17
+ /** Prepopulate fields */
18
+ fields?: {
19
+ [fieldId: string]: number | string | {
20
+ start: number;
21
+ end: number;
22
+ };
23
+ };
24
+ }): Promise<{
25
+ _id: string;
26
+ name: string;
27
+ } | null>;
28
+ }
@@ -0,0 +1,28 @@
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
+ }
@@ -0,0 +1,18 @@
1
+ import { Client } from '@wishcore/wish-rpc';
2
+ export declare class Files {
3
+ private client;
4
+ constructor(client: Client);
5
+ /**
6
+ * Uploads a file to Hailer
7
+ *
8
+ * @param file file to be uploaded
9
+ * @param publicFile is the file accessible outside of Hailer
10
+ * @param options if file is public
11
+ *
12
+ * @returns File ID in Hailer as string
13
+ */
14
+ uploadFile(file: File, filename: string, options: {
15
+ isPublic?: boolean;
16
+ }): Promise<string>;
17
+ private toBase64;
18
+ }
@@ -0,0 +1,36 @@
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
+ }
@@ -0,0 +1,18 @@
1
+ import { Client } from '@wishcore/wish-rpc';
2
+ export declare class Snackbar {
3
+ private client;
4
+ constructor(client: Client);
5
+ /**
6
+ * Opens a snackbar in Hailer
7
+ * @param text the text displayed on the snackbar
8
+ * @param buttonLabel the label for the button on the snackbar, for example 'OK'
9
+ * @param duration the time the snackbar is visible in ms
10
+ */
11
+ open(
12
+ /** The text displayed on the snackbar */
13
+ text: string,
14
+ /** The label for the button on the snackbar, for example 'OK' */
15
+ buttonLabel: string,
16
+ /** The time the snackbar is visible in ms */
17
+ duration?: number): Promise<void>;
18
+ }