@hailer/app-sdk 2.7.0 → 2.9.0
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.
- package/README.md +5 -3
- package/lib/app-sdk.js +2 -2
- package/lib/app-sdk.js.map +4 -4
- package/lib/hailer-api.d.ts +3 -0
- package/lib/modules/activity.d.ts +1 -5
- package/lib/modules/admin.d.ts +28 -0
- package/lib/modules/credential.d.ts +48 -0
- package/lib/modules/insight.d.ts +13 -1
- package/lib/modules/metrics.d.ts +19 -28
- package/lib/modules/ui/activity.d.ts +6 -2
- package/lib/modules/ui/files.d.ts +1 -1
- package/lib/modules/workflow.d.ts +4 -3
- package/lib/types.d.ts +69 -0
- package/package.json +1 -4
package/lib/hailer-api.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { Payment } from './modules/payment';
|
|
|
15
15
|
import { Admin } from './modules/admin';
|
|
16
16
|
import { MetricsApi } from './modules/metrics';
|
|
17
17
|
import { HttpApi } from './modules/http';
|
|
18
|
+
import { CredentialApi } from './modules/credential';
|
|
18
19
|
export interface Options {
|
|
19
20
|
/** When connected is called the host is ready to receive calls */
|
|
20
21
|
connected?: () => void;
|
|
@@ -52,6 +53,8 @@ export declare class HailerApi {
|
|
|
52
53
|
metrics: MetricsApi;
|
|
53
54
|
/** HTTP proxy for making authenticated HTTP/WebSocket requests through the parent frame */
|
|
54
55
|
http: HttpApi;
|
|
56
|
+
/** Securely store and retrieve credentials (API keys, username/password pairs, etc.) */
|
|
57
|
+
credential: CredentialApi;
|
|
55
58
|
/** All public endpoints, which can be accessed while not logged in to Hailer. */
|
|
56
59
|
public: HailerPublicApi;
|
|
57
60
|
/** User interface commands */
|
|
@@ -22,10 +22,7 @@ export declare class ActivityApi {
|
|
|
22
22
|
/**
|
|
23
23
|
* Gets single activity
|
|
24
24
|
*
|
|
25
|
-
* @param activityId
|
|
26
|
-
* @param processId Process where the activityId is
|
|
27
|
-
* @param phaseId Phase where the activityId is in process specified by processId
|
|
28
|
-
* @param options options containing apiVersion
|
|
25
|
+
* @param activityId Id of the activity to fetch
|
|
29
26
|
*
|
|
30
27
|
* @returns Hailer activity information or undefined if no activity is found
|
|
31
28
|
*
|
|
@@ -65,7 +62,6 @@ export declare class ActivityApi {
|
|
|
65
62
|
* Removes activities
|
|
66
63
|
*
|
|
67
64
|
* @param activities Ids of activities to be removed
|
|
68
|
-
* @param options options containing apiVersion
|
|
69
65
|
*
|
|
70
66
|
* @returns The number of removed activities
|
|
71
67
|
*
|
package/lib/modules/admin.d.ts
CHANGED
|
@@ -131,6 +131,15 @@ export declare class Admin {
|
|
|
131
131
|
* @throws {HailerError} if request fails, workspace not found, or user not authorized
|
|
132
132
|
*/
|
|
133
133
|
updateWorkspaceOverrides(request: AdminUpdateOverridesRequest): Promise<boolean>;
|
|
134
|
+
/**
|
|
135
|
+
* Updates workspace marketplace settings
|
|
136
|
+
*
|
|
137
|
+
* @param request AdminUpdateMarketplaceSettingsRequest containing workspaceId and settings
|
|
138
|
+
*
|
|
139
|
+
* @returns boolean indicating success
|
|
140
|
+
*
|
|
141
|
+
* @throws {HailerError} if request fails, workspace not found, or user not authorized
|
|
142
|
+
*/
|
|
134
143
|
updateWorkspaceMarketplaceSettings(request: AdminUpdateMarketplaceSettingsRequest): Promise<boolean>;
|
|
135
144
|
/**
|
|
136
145
|
* Lists token transactions with filtering, pagination, and statistics
|
|
@@ -162,7 +171,26 @@ export declare class Admin {
|
|
|
162
171
|
* @throws {HailerError} if request fails, purchase not found, or not a Hailer invoice purchase
|
|
163
172
|
*/
|
|
164
173
|
updateInvoiceHandled(request: AdminInvoiceUpdateHandledRequest): Promise<AdminInvoiceUpdateHandledResponse>;
|
|
174
|
+
/**
|
|
175
|
+
* Links a subscription purchase to its activity
|
|
176
|
+
*
|
|
177
|
+
* @param purchaseId The purchase to update
|
|
178
|
+
* @param subscriptionActivityId The activity id to associate with the subscription
|
|
179
|
+
*
|
|
180
|
+
* @returns boolean indicating success
|
|
181
|
+
*
|
|
182
|
+
* @throws {HailerError} if request fails or user not authorized
|
|
183
|
+
*/
|
|
165
184
|
setSubscriptionActivityId(purchaseId: string, subscriptionActivityId: string): Promise<boolean>;
|
|
185
|
+
/**
|
|
186
|
+
* Lists revenue for a given month with optional filtering and pagination
|
|
187
|
+
*
|
|
188
|
+
* @param request AdminRevenueListRequest containing month, year, and optional filter/options
|
|
189
|
+
*
|
|
190
|
+
* @returns AdminRevenueListResponse with revenue rows and totals
|
|
191
|
+
*
|
|
192
|
+
* @throws {HailerError} if request fails or user not authorized
|
|
193
|
+
*/
|
|
166
194
|
listMonthlyRevenue(request: AdminRevenueListRequest): Promise<AdminRevenueListResponse>;
|
|
167
195
|
/**
|
|
168
196
|
* Gets dashboard statistics including counts for users, workspaces, activities, and messages
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Client } from '@wishcore/wish-rpc';
|
|
2
|
+
import { CredentialCreateResponse, CredentialData, CredentialDetails, CredentialListItem, CredentialType, CredentialUpdate } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Securely store and retrieve credentials — API keys, username/password pairs,
|
|
5
|
+
* or any custom key-value secret.
|
|
6
|
+
*
|
|
7
|
+
* Every operation is scoped to credentials bound to your app: the host tags each
|
|
8
|
+
* credential you create with your app's id and re-checks that tag on every read
|
|
9
|
+
* and write, so you can never reach another app's credentials. Credentials
|
|
10
|
+
* created through the SDK are always **personal** — visible only to the acting
|
|
11
|
+
* user — and cannot be deleted through the SDK.
|
|
12
|
+
*
|
|
13
|
+
* A workspace app additionally sees, in `list`, the workspace credentials tagged
|
|
14
|
+
* with it that the acting user may read, and can `get` them; those cannot be
|
|
15
|
+
* modified through the SDK.
|
|
16
|
+
*
|
|
17
|
+
* `credential.get` returns the decrypted payload directly — there is no token
|
|
18
|
+
* exchange.
|
|
19
|
+
*/
|
|
20
|
+
export declare class CredentialApi {
|
|
21
|
+
private client;
|
|
22
|
+
constructor(client: Client);
|
|
23
|
+
/**
|
|
24
|
+
* Store a new encrypted credential. The credential is personal (owner-only)
|
|
25
|
+
* and is automatically bound to your app — the host forces the app
|
|
26
|
+
* association and drops any workspace or reader association.
|
|
27
|
+
*
|
|
28
|
+
* @throws {HailerError} if the request fails or the caller lacks permission
|
|
29
|
+
*/
|
|
30
|
+
create(name: string, type: CredentialType, secret: CredentialData): Promise<CredentialCreateResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* List your app's credentials. Encrypted fields are never returned. Results
|
|
33
|
+
* are always scoped to credentials bound to your app.
|
|
34
|
+
*/
|
|
35
|
+
list(): Promise<CredentialListItem[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Fetch and decrypt one of your app's credentials. The plaintext payload is
|
|
38
|
+
* returned directly in the RPC response — no token exchange.
|
|
39
|
+
*/
|
|
40
|
+
get<T extends CredentialData = CredentialData>(credentialId: string): Promise<CredentialDetails<T>>;
|
|
41
|
+
/**
|
|
42
|
+
* Rename or rotate the secret of one of your app's personal credentials. At
|
|
43
|
+
* least one field must be provided in `updates`, and `secret` replaces the
|
|
44
|
+
* entire stored payload — there is no key-level merge. Workspace
|
|
45
|
+
* credentials cannot be updated through the SDK.
|
|
46
|
+
*/
|
|
47
|
+
update(credentialId: string, updates: CredentialUpdate): Promise<boolean>;
|
|
48
|
+
}
|
package/lib/modules/insight.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client } from '@wishcore/wish-rpc';
|
|
2
|
-
import { InsightData, InsightDoc } from '../types';
|
|
2
|
+
import { InsightData, InsightDoc, InsightQueryResult, InsightSource } from '../types';
|
|
3
3
|
export declare class InsightApi {
|
|
4
4
|
private client;
|
|
5
5
|
constructor(client: Client);
|
|
@@ -32,4 +32,16 @@ export declare class InsightApi {
|
|
|
32
32
|
* @throws {HailerError} if request is incorrect
|
|
33
33
|
*/
|
|
34
34
|
update(insightId: string, update: Partial<InsightDoc>): Promise<InsightDoc[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Run an ad-hoc query against Insight sources
|
|
37
|
+
*
|
|
38
|
+
* @param workspaceId the workspace to query within
|
|
39
|
+
* @param sources the Insight sources to query
|
|
40
|
+
* @param query the query string
|
|
41
|
+
*
|
|
42
|
+
* @returns query result with headers, rows, and details
|
|
43
|
+
*
|
|
44
|
+
* @throws {HailerError} if request is incorrect
|
|
45
|
+
*/
|
|
46
|
+
query(workspaceId: string, sources: InsightSource[], query: string): Promise<InsightQueryResult>;
|
|
35
47
|
}
|
package/lib/modules/metrics.d.ts
CHANGED
|
@@ -8,26 +8,22 @@ export interface MetricDefinition {
|
|
|
8
8
|
supportsBreakdown: boolean;
|
|
9
9
|
}
|
|
10
10
|
export interface MetricData {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
11
|
+
/** Current scalar value (when not grouped into a series) */
|
|
12
|
+
value?: number;
|
|
13
|
+
/** Labels attached to the value */
|
|
14
|
+
labels?: Record<string, string>;
|
|
15
|
+
/** One series per group, each a list of { timestamp, value } */
|
|
17
16
|
timeSeries?: Array<{
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
labels: Record<string, string>;
|
|
18
|
+
values: Array<{
|
|
19
|
+
timestamp: number;
|
|
20
|
+
value: number;
|
|
21
|
+
}>;
|
|
20
22
|
}>;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
metadata: {
|
|
26
|
-
scope?: any;
|
|
27
|
-
permissions?: any;
|
|
28
|
-
source: string;
|
|
29
|
-
executionTime?: number;
|
|
30
|
-
};
|
|
23
|
+
/** Set if this metric failed */
|
|
24
|
+
error?: boolean;
|
|
25
|
+
/** Failure detail */
|
|
26
|
+
errorMessage?: string;
|
|
31
27
|
}
|
|
32
28
|
export interface MetricOptions {
|
|
33
29
|
workspaceId?: string;
|
|
@@ -39,17 +35,13 @@ export interface MetricOptions {
|
|
|
39
35
|
interval?: '1m' | '5m' | '15m' | '30m' | '1h' | '5h';
|
|
40
36
|
/** Aggregation function to apply */
|
|
41
37
|
aggregation?: 'sum' | 'avg' | 'max' | 'min' | 'count' | 'rate' | 'increase';
|
|
42
|
-
/** Group results by specified labels (max 3). Allowed: userId, userRole, workspaceId, teamId, processId, workflowId, discussionId */
|
|
38
|
+
/** Group results by specified labels (max 3). Allowed: userId, userRole, workspaceId, teamId, processId, workflowId, discussionId, activityId, signal, type */
|
|
43
39
|
groupBy?: string[];
|
|
44
40
|
/** Limit results to top N values (1-100) */
|
|
45
41
|
topk?: number;
|
|
46
|
-
/** Additional label filters. Allowed keys: userId, userRole, workspaceId, teamId, processId, workflowId, discussionId */
|
|
42
|
+
/** Additional label filters. Allowed keys: userId, userRole, workspaceId, teamId, processId, workflowId, discussionId, activityId, signal, type */
|
|
47
43
|
labelFilters?: Record<string, string>;
|
|
48
44
|
}
|
|
49
|
-
export interface MetricListOptions {
|
|
50
|
-
category?: string;
|
|
51
|
-
includeDetails?: boolean;
|
|
52
|
-
}
|
|
53
45
|
export interface WorkspaceMetricsListOptions {
|
|
54
46
|
/** Array of workspace IDs to look up */
|
|
55
47
|
workspaceIds?: string[];
|
|
@@ -74,15 +66,14 @@ export declare class MetricsApi {
|
|
|
74
66
|
constructor(client: Client);
|
|
75
67
|
/**
|
|
76
68
|
* Get list of available metrics for current user based on permissions
|
|
77
|
-
* @param options Optional filtering options
|
|
78
69
|
* @returns Array of metric IDs or detailed metric definitions
|
|
79
70
|
*/
|
|
80
|
-
list(
|
|
71
|
+
list(): Promise<string[] | MetricDefinition[]>;
|
|
81
72
|
/**
|
|
82
73
|
* Get metrics data with optional Query Builder
|
|
83
74
|
* @param metricTypes Single metric or array of metrics to fetch
|
|
84
75
|
* @param options Optional filtering, time range, and Query Builder options
|
|
85
|
-
* @returns
|
|
76
|
+
* @returns Array of metric data, one entry per requested metric (in request order)
|
|
86
77
|
*
|
|
87
78
|
* @example
|
|
88
79
|
* // Simple query
|
|
@@ -98,7 +89,7 @@ export declare class MetricsApi {
|
|
|
98
89
|
* topk: 10
|
|
99
90
|
* });
|
|
100
91
|
*/
|
|
101
|
-
get(metricTypes: string | string[], options?: MetricOptions): Promise<MetricData>;
|
|
92
|
+
get(metricTypes: string | string[], options?: MetricOptions): Promise<MetricData[]>;
|
|
102
93
|
/**
|
|
103
94
|
* Admin endpoints for metrics management
|
|
104
95
|
*/
|
|
@@ -36,6 +36,10 @@ export declare class Activity {
|
|
|
36
36
|
_id: string;
|
|
37
37
|
name: string;
|
|
38
38
|
} | null>;
|
|
39
|
-
/**
|
|
40
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Opens multiple activity edit view in Hailer sidebar
|
|
41
|
+
*
|
|
42
|
+
* @param activityIds Ids of the activities to edit
|
|
43
|
+
*/
|
|
44
|
+
editMultiple(activityIds: string[]): Promise<void>;
|
|
41
45
|
}
|
|
@@ -7,7 +7,7 @@ import { Client } from '@wishcore/wish-rpc';
|
|
|
7
7
|
* // New way (recommended):
|
|
8
8
|
* import { FileApi } from '@hailer/app-sdk';
|
|
9
9
|
* const fileApi = new FileApi(client);
|
|
10
|
-
* const fileId = await fileApi.upload(
|
|
10
|
+
* const fileId = await fileApi.upload(file, filename, { isPublic: false });
|
|
11
11
|
*/
|
|
12
12
|
export declare class Files {
|
|
13
13
|
private client;
|
|
@@ -22,11 +22,12 @@ export declare class WorkflowApi {
|
|
|
22
22
|
*/
|
|
23
23
|
get(workflowId: string): Promise<Workflow>;
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* Installs a workflow (process) from a spec
|
|
26
26
|
*
|
|
27
|
-
* @param
|
|
27
|
+
* @param workflowSpec the workflow specification to install
|
|
28
|
+
* @param option optional target workspace
|
|
28
29
|
*
|
|
29
|
-
* @returns the
|
|
30
|
+
* @returns a map of template ids to the created ids
|
|
30
31
|
*
|
|
31
32
|
* @throws {HailerError} if request is incorrect
|
|
32
33
|
*/
|
package/lib/types.d.ts
CHANGED
|
@@ -295,6 +295,18 @@ export interface InsightResponseAsObjectItem {
|
|
|
295
295
|
[key: string]: any;
|
|
296
296
|
}
|
|
297
297
|
export type InsightResponseAsObjects = InsightResponseAsObjectItem[];
|
|
298
|
+
export type InsightSource = InsightWorkflowSource;
|
|
299
|
+
export interface InsightQueryResult {
|
|
300
|
+
headers: string[];
|
|
301
|
+
rows: (string | number | null)[][];
|
|
302
|
+
/** Per-table breakdown of the temporary tables built from sources */
|
|
303
|
+
details: {
|
|
304
|
+
[tableName: string]: {
|
|
305
|
+
headers: string[];
|
|
306
|
+
rows: number;
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
}
|
|
298
310
|
export interface KanbanListResponse {
|
|
299
311
|
map: {
|
|
300
312
|
[phaseId: string]: {
|
|
@@ -334,6 +346,8 @@ export interface KanbanLoadResponse {
|
|
|
334
346
|
phase: string;
|
|
335
347
|
}
|
|
336
348
|
export interface ActivityListOptions {
|
|
349
|
+
/** Workspace to resolve a workflow **key** in (keys are unique per workspace) */
|
|
350
|
+
workspaceId?: string;
|
|
337
351
|
sortBy?: 'name' | 'created' | 'updated' | 'following' | 'owner' | 'team' | 'completedOn' | 'priority';
|
|
338
352
|
sortOrder?: 'asc' | 'desc';
|
|
339
353
|
limit?: number;
|
|
@@ -344,6 +358,8 @@ export interface ActivityListOptions {
|
|
|
344
358
|
filters?: any;
|
|
345
359
|
}
|
|
346
360
|
export interface ActivityCreateOptions {
|
|
361
|
+
/** Workspace to resolve a workflow **key** in (keys are unique per workspace) */
|
|
362
|
+
workspaceId?: string;
|
|
347
363
|
teamId?: string;
|
|
348
364
|
fileIds?: string[];
|
|
349
365
|
followerIds?: string[];
|
|
@@ -422,6 +438,59 @@ export interface Settings {
|
|
|
422
438
|
theme: 'light' | 'dark';
|
|
423
439
|
preferredLanguages: string[];
|
|
424
440
|
}
|
|
441
|
+
export type CredentialType = 'basic' | 'apiKey' | 'custom';
|
|
442
|
+
export interface CredentialBasicData {
|
|
443
|
+
username: string;
|
|
444
|
+
password: string;
|
|
445
|
+
}
|
|
446
|
+
export interface CredentialApiKeyData {
|
|
447
|
+
apiKey: string;
|
|
448
|
+
}
|
|
449
|
+
/** Any JSON-serialisable value that can live inside a `custom` secret. */
|
|
450
|
+
export type CredentialJsonValue = string | number | boolean | null | CredentialJsonValue[] | {
|
|
451
|
+
[key: string]: CredentialJsonValue;
|
|
452
|
+
};
|
|
453
|
+
/**
|
|
454
|
+
* Free-form secret for `custom` credentials — any JSON object with 1–50
|
|
455
|
+
* top-level keys.
|
|
456
|
+
*/
|
|
457
|
+
export interface CredentialCustomData {
|
|
458
|
+
[key: string]: CredentialJsonValue;
|
|
459
|
+
}
|
|
460
|
+
export type CredentialData = CredentialBasicData | CredentialApiKeyData | CredentialCustomData;
|
|
461
|
+
/**
|
|
462
|
+
* Reader entry granting access to a workspace credential. Credentials created
|
|
463
|
+
* through the app SDK are personal and have no readers; readers only appear on
|
|
464
|
+
* workspace credentials bound to your app and surfaced in `list`.
|
|
465
|
+
*/
|
|
466
|
+
export type CredentialReader = `network_${string}` | `team_${string}` | `user_${string}`;
|
|
467
|
+
export interface CredentialCreateResponse {
|
|
468
|
+
_id: string;
|
|
469
|
+
}
|
|
470
|
+
export interface CredentialListItem {
|
|
471
|
+
_id: string;
|
|
472
|
+
name: string;
|
|
473
|
+
type: CredentialType;
|
|
474
|
+
/** Set only on workspace credentials — absent on personal ones. */
|
|
475
|
+
workspaceId?: string;
|
|
476
|
+
/** The app the credential is bound to; always your own app's id. */
|
|
477
|
+
appId?: string;
|
|
478
|
+
/** Workspace credentials only. */
|
|
479
|
+
readers?: CredentialReader[];
|
|
480
|
+
createdBy: string;
|
|
481
|
+
created: number;
|
|
482
|
+
updated: number;
|
|
483
|
+
}
|
|
484
|
+
export interface CredentialUpdate {
|
|
485
|
+
name?: string;
|
|
486
|
+
/** Replaces the entire stored payload — there is no key-level merge. */
|
|
487
|
+
secret?: CredentialData;
|
|
488
|
+
}
|
|
489
|
+
/** Decrypted credential as returned by `credential.get`. */
|
|
490
|
+
export interface CredentialDetails<T extends CredentialData = CredentialData> {
|
|
491
|
+
type: CredentialType;
|
|
492
|
+
secret: T;
|
|
493
|
+
}
|
|
425
494
|
export interface ApiInfo {
|
|
426
495
|
/** Url of the Hailer instance hosting the API */
|
|
427
496
|
hostUrl?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hailer/app-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "SDK for building Hailer Apps",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "ISC",
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"watch": "concurrently --kill-others \"npm run watch-tsc\" \"npm run watch-esbuild\"",
|
|
17
17
|
"watch-tsc": "tsc --watch",
|
|
18
18
|
"watch-esbuild": "esbuild src/index.ts --bundle --format=esm --sourcemap --outfile=lib/app-sdk.js --watch",
|
|
19
|
-
"docs": "typedoc --entryPointStrategy expand ./src && open-cli ./docs/index.html",
|
|
20
19
|
"test": "vitest run",
|
|
21
20
|
"test:watch": "vitest",
|
|
22
21
|
"lint": "eslint .",
|
|
@@ -47,8 +46,6 @@
|
|
|
47
46
|
"eslint-plugin-diff": "2.1.7",
|
|
48
47
|
"husky": "9.1.7",
|
|
49
48
|
"lint-staged": "17.0.5",
|
|
50
|
-
"open-cli": "^9.0.0",
|
|
51
|
-
"typedoc": "^0.24.8",
|
|
52
49
|
"typescript": "^5.1.3",
|
|
53
50
|
"vitest": "^4.1.4"
|
|
54
51
|
},
|