@hailer/app-sdk 1.0.2 → 2.0.0-beta-1

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 (53) 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/hailer-api.d.ts +4 -24
  5. package/lib/modules/activity.d.ts +6 -19
  6. package/lib/modules/app.d.ts +66 -2
  7. package/lib/modules/insight.d.ts +0 -1
  8. package/lib/modules/permission.d.ts +2 -1
  9. package/lib/modules/product.d.ts +0 -10
  10. package/lib/modules/public/app.d.ts +2 -2
  11. package/lib/modules/public.d.ts +0 -3
  12. package/lib/modules/team.d.ts +17 -0
  13. package/lib/modules/ui/activity.d.ts +7 -0
  14. package/lib/modules/user.d.ts +1 -3
  15. package/lib/modules/workflow.d.ts +14 -2
  16. package/lib/modules/workspace.d.ts +75 -1
  17. package/lib/tools/publish.cjs +4 -4
  18. package/lib/tools/replace-private.d.ts +1 -0
  19. package/lib/tools/replace-private.js +33 -0
  20. package/lib/types.d.ts +139 -54
  21. package/package.json +1 -1
  22. package/lib/modules/product-installed.d.ts +0 -40
  23. package/lib/modules/product-version.d.ts +0 -38
  24. package/lib/modules/public/product-version.d.ts +0 -16
  25. package/lib/modules/public/version.d.ts +0 -16
  26. package/lib/modules/version.d.ts +0 -16
  27. package/lib/src/constants.d.ts +0 -7
  28. package/lib/src/hailer-api.d.ts +0 -92
  29. package/lib/src/index.d.ts +0 -2
  30. package/lib/src/modules/activity/kanban.d.ts +0 -36
  31. package/lib/src/modules/activity.d.ts +0 -83
  32. package/lib/src/modules/app.d.ts +0 -12
  33. package/lib/src/modules/insight.d.ts +0 -36
  34. package/lib/src/modules/network.d.ts +0 -14
  35. package/lib/src/modules/permission.d.ts +0 -9
  36. package/lib/src/modules/process.d.ts +0 -38
  37. package/lib/src/modules/product-installed.d.ts +0 -40
  38. package/lib/src/modules/product-version.d.ts +0 -16
  39. package/lib/src/modules/product.d.ts +0 -104
  40. package/lib/src/modules/public/app.d.ts +0 -17
  41. package/lib/src/modules/public/form.d.ts +0 -31
  42. package/lib/src/modules/public/insight.d.ts +0 -30
  43. package/lib/src/modules/public/product-version.d.ts +0 -16
  44. package/lib/src/modules/public/product.d.ts +0 -27
  45. package/lib/src/modules/public.d.ts +0 -22
  46. package/lib/src/modules/ui/activity.d.ts +0 -30
  47. package/lib/src/modules/ui/files.d.ts +0 -18
  48. package/lib/src/modules/ui/snackbar.d.ts +0 -18
  49. package/lib/src/modules/ui.d.ts +0 -17
  50. package/lib/src/modules/user.d.ts +0 -36
  51. package/lib/src/modules/workflow.d.ts +0 -24
  52. package/lib/src/types.d.ts +0 -381
  53. package/lib/version.d.ts +0 -0
@@ -1,17 +1,14 @@
1
1
  import { UserApi } from './modules/user';
2
2
  import { ActivityApi } from './modules/activity';
3
3
  import { WorkspaceApi } from './modules/workspace';
4
- import { HailerApiInfo, HailerSettings, HailerSignal } from './types';
4
+ import { ApiInfo, Settings, Signal } from './types';
5
5
  import { Ui } from './modules/ui';
6
- import { Process } from './modules/process';
7
6
  import { HailerPublicApi } from './modules/public';
8
7
  import { WorkflowApi } from './modules/workflow';
9
8
  import { AppApi } from './modules/app';
10
9
  import { InsightApi } from './modules/insight';
11
10
  import { PermissionApi } from './modules/permission';
12
11
  import { ProductApi } from './modules/product';
13
- import { ProductVersionApi } from './modules/product-version';
14
- import { ProductInstalledApi } from './modules/product-installed';
15
12
  export interface Options {
16
13
  /** When connected is called the host is ready to receive calls */
17
14
  connected?: () => void;
@@ -22,23 +19,13 @@ export interface Options {
22
19
  /** Callback called on app init and when permissions have changed */
23
20
  permissions?: () => void;
24
21
  /** Callback called on app init and when settings have changed */
25
- settings?: (data: HailerSettings) => void;
22
+ settings?: (data: Settings) => void;
26
23
  /** Callback called on app init and when config has changed */
27
24
  config?: (config: any) => void;
28
25
  /** Will be called each time a subscribed signal is emitted from Hailer frontend. To subscribe to signals, add them to options.subscribedSignals[] */
29
- signals?: (signal: HailerSignal) => void;
26
+ signals?: (signal: Signal) => void;
30
27
  /** Urls the sdk is allowed to connect to. Defaults to all Hailer instances*/
31
28
  allowedUrls?: string[];
32
- /**
33
- * Optional signal filter, passes all signals by default
34
- *
35
- * Example:
36
- *
37
- * subscribedSignals: ['activity.create', 'activity.update']
38
- */
39
- subscribedSignals?: string[];
40
- /** Api version to be used in the app by default */
41
- apiVersion?: 1;
42
29
  /** Public backend Api url. Defaults to https://api.hailer.com */
43
30
  publicBackendUrl?: string;
44
31
  }
@@ -49,12 +36,9 @@ export declare class HailerApi {
49
36
  activity: ActivityApi;
50
37
  insight: InsightApi;
51
38
  workspace: WorkspaceApi;
52
- process: Process;
53
39
  workflow: WorkflowApi;
54
40
  permission: PermissionApi;
55
41
  product: ProductApi;
56
- productVersion: ProductVersionApi;
57
- productInstalled: ProductInstalledApi;
58
42
  /** All public endpoints, which can be accessed while not logged in to Hailer. */
59
43
  public: HailerPublicApi;
60
44
  /** User interface commands */
@@ -65,10 +49,7 @@ export declare class HailerApi {
65
49
  /** If set it indicates that app is locked to a specific workspaceId */
66
50
  private workspaceId?;
67
51
  private client;
68
- private apiVersion;
69
- private settings?;
70
52
  private config?;
71
- private subscribedSignals?;
72
53
  private timer?;
73
54
  /**
74
55
  * Hailer API state
@@ -87,6 +68,5 @@ export declare class HailerApi {
87
68
  */
88
69
  constructor(options?: Options);
89
70
  private createEventListener;
90
- info(): HailerApiInfo;
91
- request(op: string, args: any[]): Promise<any>;
71
+ info(): ApiInfo;
92
72
  }
@@ -1,5 +1,5 @@
1
1
  import { Client } from '@wishcore/wish-rpc';
2
- import { ActivityCreateOptions, ActivityListOptions, Activity } from '../types';
2
+ import { ActivityCreateOptions, ActivityListOptions, Activity, ActivityFieldUpdateValue, ActivityUpdateOptions, ActivityFieldValue } from '../types';
3
3
  import { Kanban } from './activity/kanban';
4
4
  export declare class ActivityApi {
5
5
  private client;
@@ -33,30 +33,17 @@ export declare class ActivityApi {
33
33
  /**
34
34
  * Creates activities
35
35
  *
36
- * @param processId The process where the activity is created
37
- * @param activities new activities as objects
38
- * @param activities.name name of the activity
39
- * @param activities.fields fields of the activity
40
- * @param options ActivityCreateOptions
41
- *
42
36
  * @throws {HailerError} if request is incorrect
43
37
  */
44
- create(processId: string, activities: {
45
- name: string;
38
+ create(workflowId: string | undefined, activities: {
39
+ name?: string;
46
40
  fields?: {
47
- [id: string]: string | number;
41
+ [id: string]: ActivityFieldValue;
48
42
  };
49
43
  }[], options?: ActivityCreateOptions): Promise<Activity[]>;
50
44
  /**
51
45
  * Updates activites
52
46
  *
53
- * Each activity has the following parameters
54
- * @param activities updated activity objects of an activity to edit
55
- * @param activities.name New name of the activity
56
- * @param activities.fields change values of fields, null removes current value
57
- * @param activities.phaseId New phase of the activity
58
- * @param options
59
- *
60
47
  * @returns The number of updated activities
61
48
  *
62
49
  * @throws {HailerError} if request is incorrect
@@ -65,10 +52,10 @@ export declare class ActivityApi {
65
52
  _id: string;
66
53
  name?: string;
67
54
  fields?: {
68
- [id: string]: string | number | null;
55
+ [id: string]: ActivityFieldUpdateValue;
69
56
  };
70
57
  phaseId?: string;
71
- }[], options: any): Promise<number>;
58
+ }[], options?: ActivityUpdateOptions): Promise<number>;
72
59
  /**
73
60
  * Removes activities
74
61
  *
@@ -1,12 +1,76 @@
1
1
  import { Client } from '@wishcore/wish-rpc';
2
- import { HailerAppConfig } from '../types';
2
+ import { Config, ProductVersion, Version } from '../types';
3
3
  /**
4
4
  * This class is used to access Hailer public API even when the app is outside of Hailer
5
5
  */
6
6
  export declare class AppApi {
7
7
  private client;
8
+ product: {
9
+ /** Check if product is installed */
10
+ isProductInstalled(id: string): Promise<boolean>;
11
+ /** Get version */
12
+ get(id: string): Promise<ProductVersion | undefined>;
13
+ /** Install app from Hailer market */
14
+ install(id: string): Promise<boolean>;
15
+ /** Get installed version */
16
+ getInstalledVersion(id: string): Promise<Version>;
17
+ /** Get manifest content from Hailer market */
18
+ getManifest(id: string): Promise<any>;
19
+ };
8
20
  constructor(client: Client);
9
21
  config: {
10
- update: (appId: string | undefined, config: HailerAppConfig) => Promise<void>;
22
+ update: (config: Config, option?: {
23
+ appId?: string;
24
+ }) => Promise<void>;
11
25
  };
26
+ /**
27
+ * Check if product is installed
28
+ *
29
+ * @param id Id of product in Hailer market
30
+ *
31
+ * @returns true if ok else false
32
+ *
33
+ * @throws {HailerError} if request is incorrect
34
+ */
35
+ private isProductInstalled;
36
+ /**
37
+ * Get version
38
+ *
39
+ * @param id targetId
40
+ *
41
+ * @returns true if ok else false
42
+ *
43
+ * @throws {HailerError} if request is incorrect
44
+ */
45
+ private get;
46
+ /**
47
+ * Install app from Hailer market
48
+ *
49
+ * @param id Id of product in Hailer market
50
+ *
51
+ * @returns true, if installed else error
52
+ *
53
+ * @throws {HailerError} if request is incorrect
54
+ */
55
+ private install;
56
+ /**
57
+ * Get installed version from Hailer market
58
+ *
59
+ * @param id Id of product in Hailer market
60
+ *
61
+ * @returns true, if installed else error
62
+ *
63
+ * @throws {HailerError} if request is incorrect
64
+ */
65
+ private getInstalledVersion;
66
+ /**
67
+ * Get manifest content from Hailer market
68
+ *
69
+ * @param id target Id
70
+ *
71
+ * @returns Manifest content
72
+ *
73
+ * @throws {HailerError} if request is incorrect
74
+ */
75
+ private getManifest;
12
76
  }
@@ -27,7 +27,6 @@ export declare class InsightApi {
27
27
  /**
28
28
  * Get Insight data
29
29
  *
30
- *
31
30
  * @returns data from the Insight
32
31
  *
33
32
  * @throws {HailerError} if request is incorrect
@@ -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
  }
@@ -87,16 +87,6 @@ export declare class ProductApi {
87
87
  * @throws {HailerError} if request is incorrect
88
88
  */
89
89
  remove(id: string): Promise<boolean>;
90
- /**
91
- * Install something from Hailer market
92
- *
93
- * @param id Id of product in Hailer market
94
- *
95
- * @returns true, if installed else error
96
- *
97
- * @throws {HailerError} if request is incorrect
98
- */
99
- install(id: string): Promise<boolean>;
100
90
  /**
101
91
  * Set product as public or not (visible) in Hailer market
102
92
  *
@@ -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
  }
@@ -3,7 +3,6 @@ import { App } from './public/app';
3
3
  import { Form } from './public/form';
4
4
  import { InsightPublicApi } from './public/insight';
5
5
  import { ProductPublicApi } from './public/product';
6
- import { ProductVersionPublicApi } from './public/product-version';
7
6
  /**
8
7
  * This class is used to access Hailer public API even when the app is outside of Hailer
9
8
  */
@@ -16,7 +15,5 @@ export declare class HailerPublicApi {
16
15
  app: App;
17
16
  /** Access public Product information */
18
17
  product: ProductPublicApi;
19
- /** Access public Version information */
20
- productVersion: ProductVersionPublicApi;
21
18
  constructor(options: Options);
22
19
  }
@@ -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
+ }
@@ -21,6 +21,13 @@ export declare class Activity {
21
21
  end: number;
22
22
  };
23
23
  };
24
+ location?: {
25
+ type: 'area' | 'point' | 'polyline';
26
+ data: {
27
+ lng: number;
28
+ lat: number;
29
+ }[];
30
+ };
24
31
  }): Promise<{
25
32
  _id: string;
26
33
  name: string;
@@ -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
  }
@@ -1,5 +1,5 @@
1
1
  import { Client } from '@wishcore/wish-rpc';
2
- import { Workflow } from '../types';
2
+ import { IdsMap, Workflow } from '../types';
3
3
  export declare class WorkflowApi {
4
4
  private client;
5
5
  constructor(client: Client);
@@ -11,6 +11,16 @@ export declare class WorkflowApi {
11
11
  * @throws {HailerError} if request is incorrect
12
12
  */
13
13
  list(): Promise<Workflow[]>;
14
+ /**
15
+ * Gets a single process from a workspace
16
+ *
17
+ * @param workflowId the id of the process in question
18
+ *
19
+ * @returns the specified Hailer process
20
+ *
21
+ * @throws {HailerError} if request is incorrect
22
+ */
23
+ get(workflowId: string): Promise<Workflow>;
14
24
  /**
15
25
  * Gets a single process from a workspace
16
26
  *
@@ -20,5 +30,7 @@ export declare class WorkflowApi {
20
30
  *
21
31
  * @throws {HailerError} if request is incorrect
22
32
  */
23
- get(processId: string): Promise<Workflow>;
33
+ install(workflowSpec: any, option?: {
34
+ workspaceId?: string;
35
+ }): Promise<IdsMap>;
24
36
  }
@@ -1,7 +1,26 @@
1
1
  import { Client } from '@wishcore/wish-rpc';
2
- import { Workspace } from '../types';
2
+ import { ProductVersion, Workspace } from '../types';
3
3
  export declare class WorkspaceApi {
4
4
  private client;
5
+ product: {
6
+ /** Publish template in Hailer market */
7
+ publishTemplate: (template: {
8
+ workspaceId?: string;
9
+ versionId?: string;
10
+ version: string;
11
+ versionDescription: string;
12
+ title: string;
13
+ description: string;
14
+ }) => Promise<ProductVersion>;
15
+ /** Check if product is installed */
16
+ isProductInstalled(id: string): Promise<boolean>;
17
+ /** Get version */
18
+ get(id: string): Promise<ProductVersion | undefined>;
19
+ /** Install template from Hailer market */
20
+ install(id: string): Promise<boolean>;
21
+ /** Get manifest content from Hailer market */
22
+ getManifest(id: string): Promise<any>;
23
+ };
5
24
  constructor(client: Client);
6
25
  /**
7
26
  * Returns the current network
@@ -19,4 +38,59 @@ export declare class WorkspaceApi {
19
38
  * * @throws {HailerError} if request is incorrect
20
39
  */
21
40
  list(): Promise<Workspace[]>;
41
+ /**
42
+ * Publish template in Hailer market
43
+ *
44
+ * @param workspaceId Id of workspace
45
+ * @param versionId link to version (empty if first publish)
46
+ * @param version Version number
47
+ * @param versionDescription Version description
48
+ * @param title
49
+ * @param description
50
+ *
51
+ * @returns Created version in Hailer market
52
+ *
53
+ * @throws {HailerError} if request is incorrect
54
+ */
55
+ private publishTemplate;
56
+ /**
57
+ * Check if product is installed
58
+ *
59
+ * @param id Id of product in Hailer market
60
+ *
61
+ * @returns true if ok else false
62
+ *
63
+ * @throws {HailerError} if request is incorrect
64
+ */
65
+ private isProductInstalled;
66
+ /**
67
+ * Get version
68
+ *
69
+ * @param id targetId
70
+ *
71
+ * @returns true if ok else false
72
+ *
73
+ * @throws {HailerError} if request is incorrect
74
+ */
75
+ private get;
76
+ /**
77
+ * Install template from Hailer market
78
+ *
79
+ * @param id Id of product in Hailer market
80
+ *
81
+ * @returns true, if installed else error
82
+ *
83
+ * @throws {HailerError} if request is incorrect
84
+ */
85
+ private install;
86
+ /**
87
+ * Get manifest content from Hailer market
88
+ *
89
+ * @param id target Id
90
+ *
91
+ * @returns Manifest content
92
+ *
93
+ * @throws {HailerError} if request is incorrect
94
+ */
95
+ private getManifest;
22
96
  }
@@ -175,10 +175,10 @@ if (!process.env.EMAIL && !process.env.LOCAL) {
175
175
  try {
176
176
  response = JSON.parse(body);
177
177
  // Market code
178
- if (response.manifest && response.manifest.versionId) {
179
- infoMarket = 'Note! Use versionId in public/manifest.json file when creating the product in market!';
180
- // Write versionId to manifest.json
181
- manifest.versionId = response.manifest.versionId;
178
+ if (response.manifest && response.manifest.targetId) {
179
+ infoMarket = 'Note! Use targetId in public/manifest.json file when creating the product in market!';
180
+ // Write targetId to manifest.json
181
+ manifest.targetId = response.manifest.targetId;
182
182
  // Convert the modified object back to JSON
183
183
  const updatedManifestContent = JSON.stringify(manifest, null, 2);
184
184
  // Write the updated JSON content back to manifest.json
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fs_1 = require("fs");
4
+ const path_1 = require("path");
5
+ const srcFolder = (0, path_1.join)(__dirname, '../src');
6
+ const publicSrcFolder = (0, path_1.join)(__dirname, '../public-src');
7
+ const replacePrivateComments = (fileContent) => {
8
+ // Replaces all occurences of /* @ private */ with private
9
+ return fileContent.replace(/\/\* @private \*\//g, 'private');
10
+ };
11
+ const copyAndReplaceFiles = (src, dest) => {
12
+ (0, fs_1.mkdirSync)(dest, { recursive: true });
13
+ console.log('Created folder: ', dest);
14
+ (0, fs_1.readdirSync)(src).forEach((file) => {
15
+ const srcFile = (0, path_1.join)(src, file);
16
+ const destFile = (0, path_1.join)(dest, file);
17
+ if ((0, fs_1.lstatSync)(srcFile).isDirectory()) {
18
+ copyAndReplaceFiles(srcFile, destFile);
19
+ }
20
+ else if (srcFile.endsWith('.ts')) {
21
+ const updatedContent = replacePrivateComments((0, fs_1.readFileSync)(srcFile, 'utf8'));
22
+ (0, fs_1.writeFileSync)(destFile, updatedContent, 'utf8');
23
+ }
24
+ else {
25
+ (0, fs_1.copyFileSync)(srcFile, destFile);
26
+ }
27
+ });
28
+ };
29
+ if ((0, fs_1.existsSync)(publicSrcFolder)) {
30
+ (0, fs_1.rmdirSync)(publicSrcFolder, { recursive: true });
31
+ }
32
+ copyAndReplaceFiles(srcFolder, publicSrcFolder);
33
+ console.log('Public source files generated in /public-src/');