@kissflow/lowcode-client-sdk 1.0.44 → 1.0.50
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/dist/index.d.ts +748 -155
- package/dist/kfsdk.es.js +608 -8
- package/dist/kfsdk.umd.js +1 -1
- package/dist/lowcode.d.ts +717 -124
- package/dist/lowcode.types.d.ts +505 -1
- package/dist/nocode.d.ts +726 -133
- package/dist/nocode.types.d.ts +290 -0
- package/dist/snippets.json +5 -0
- package/package.json +7 -2
- package/dist/kf.lowcodeworkersdk.es.js +0 -1233
- package/dist/kf.nocodeworkersdk.es.js +0 -573
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ declare module "core/constants" {
|
|
|
5
5
|
RETURN: string;
|
|
6
6
|
GET_FORM_FIELD: string;
|
|
7
7
|
UPDATE_FORM: string;
|
|
8
|
+
GET_FORM_VALIDATION_ERRORS: string;
|
|
9
|
+
GET_FORM_CONFIGURATION: string;
|
|
10
|
+
GET_FORM_FIELD_STATE: string;
|
|
8
11
|
GET_TABLE: string;
|
|
9
12
|
GET_TABLE_ROW: string;
|
|
10
13
|
ADD_TABLE_ROW: string;
|
|
@@ -19,6 +22,13 @@ declare module "core/constants" {
|
|
|
19
22
|
REDIRECT: string;
|
|
20
23
|
OPEN_PAGE: string;
|
|
21
24
|
GET_IMAGE_URL: string;
|
|
25
|
+
FILEPICKER_OPEN: string;
|
|
26
|
+
FILEPREVIEW_OPEN: string;
|
|
27
|
+
FILE_UPLOAD: string;
|
|
28
|
+
SCANNER_OPEN: string;
|
|
29
|
+
GEOLOCATION_OPEN: string;
|
|
30
|
+
GET_ROLES: string;
|
|
31
|
+
SWITCH_ROLE: string;
|
|
22
32
|
FORMAT_DATE: string;
|
|
23
33
|
FORMAT_DATE_TIME: string;
|
|
24
34
|
FORMAT_NUMBER: string;
|
|
@@ -42,12 +52,19 @@ declare module "core/constants" {
|
|
|
42
52
|
COMPONENT_ADD_EVENT_LISTENER: string;
|
|
43
53
|
CC_INITIALIZE: string;
|
|
44
54
|
CC_WATCH_PARAMS: string;
|
|
55
|
+
CC_SET_ROUTE: string;
|
|
56
|
+
CC_WATCH_ROUTE: string;
|
|
45
57
|
WINDOW_NDEF_READER_NEW: string;
|
|
46
58
|
WINDOW_NDEF_READER_SCAN: string;
|
|
47
59
|
WINDOW_NDEF_READER_WRITE: string;
|
|
48
60
|
WINDOW_NDEF_READER_ADD_EVENT_LISTENER: string;
|
|
49
61
|
WINDOW_NDEF_READER_MAKE_READONLY: string;
|
|
50
62
|
WINDOW_NDEF_READER_ABORT_SCAN: string;
|
|
63
|
+
CUSTOM_AGENT_GET_CONTRACT: string;
|
|
64
|
+
CUSTOM_AGENT_EXECUTE: string;
|
|
65
|
+
CUSTOM_AGENT_GET_EXECUTION: string;
|
|
66
|
+
CUSTOM_AGENT_WATCH_EXECUTION: string;
|
|
67
|
+
CUSTOM_AGENT_STOP_WATCH: string;
|
|
51
68
|
DECISION_TABLE_EXECUTE: string;
|
|
52
69
|
DATAFORM_IMPORT_CSV: string;
|
|
53
70
|
DATAFORM_OPEN_FORM: string;
|
|
@@ -59,6 +76,8 @@ declare module "core/constants" {
|
|
|
59
76
|
DATAFORM_DELETE_ITEM: string;
|
|
60
77
|
DATAFORM_DISCARD_ITEM: string;
|
|
61
78
|
DATAFORM_SUBMIT_ITEM: string;
|
|
79
|
+
DATAFORM_INIT_FORM: string;
|
|
80
|
+
DATAFORM_GET_FIELD_OPTIONS: string;
|
|
62
81
|
PROCESS_OPEN_FORM: string;
|
|
63
82
|
PROCESS_GET_FIELDS: string;
|
|
64
83
|
PROCESS_GET_MYTASK_FIELDS: string;
|
|
@@ -72,6 +91,8 @@ declare module "core/constants" {
|
|
|
72
91
|
PROCESS_UPDATE_ITEM: string;
|
|
73
92
|
PROCESS_GET_ITEM: string;
|
|
74
93
|
PROCESS_DELETE_ITEM: string;
|
|
94
|
+
PROCESS_GET_ADMIN_ITEM: string;
|
|
95
|
+
PROCESS_UPDATE_ADMIN_ITEM: string;
|
|
75
96
|
PROCESS_SUBMIT_ITEM: string;
|
|
76
97
|
PROCESS_REJECT_ITEM: string;
|
|
77
98
|
PROCESS_WITHDRAW_ITEM: string;
|
|
@@ -81,6 +102,9 @@ declare module "core/constants" {
|
|
|
81
102
|
PROCESS_RESTART_ITEM: string;
|
|
82
103
|
PROCESS_DISCARD_ITEM: string;
|
|
83
104
|
PROCESS_GET_PROGRESS: string;
|
|
105
|
+
PROCESS_INIT_FORM: string;
|
|
106
|
+
PROCESS_GET_FIELD_OPTIONS: string;
|
|
107
|
+
PROCESS_PARSE_ATTACHMENT: string;
|
|
84
108
|
BOARD_IMPORT_CSV: string;
|
|
85
109
|
BOARD_OPEN_FORM: string;
|
|
86
110
|
BOARD_GET_FIELDS: string;
|
|
@@ -91,10 +115,14 @@ declare module "core/constants" {
|
|
|
91
115
|
BOARD_DELETE_ITEM: string;
|
|
92
116
|
BOARD_SUBMIT_ITEM: string;
|
|
93
117
|
BOARD_DISCARD_ITEM: string;
|
|
118
|
+
BOARD_INIT_FORM: string;
|
|
119
|
+
BOARD_GET_FIELD_OPTIONS: string;
|
|
94
120
|
};
|
|
95
121
|
export const EVENT_TYPES: {
|
|
96
122
|
COMPONENT_ON_MOUNT: string;
|
|
97
123
|
CC_ON_PARAMS_CHANGE: string;
|
|
124
|
+
CC_ON_ROUTE_CHANGE: string;
|
|
125
|
+
CUSTOM_AGENT_EXECUTION_COMPLETE: string;
|
|
98
126
|
};
|
|
99
127
|
export const DEFAULTS: {
|
|
100
128
|
POPUP_ID: string;
|
|
@@ -113,126 +141,26 @@ declare module "core/index" {
|
|
|
113
141
|
}
|
|
114
142
|
export class BaseSDK extends EventBase {
|
|
115
143
|
_postMessageAsync(command: string, args: any, hasCallBack?: boolean, callBack?: (data: any) => {}): object | string | any;
|
|
144
|
+
/**
|
|
145
|
+
* Like _postMessageAsync, but settles with `timeoutError` when the host does not reply within
|
|
146
|
+
* `timeoutMs` (a host that does not know the command fails loudly instead of hanging), with
|
|
147
|
+
* `sendError` when the message cannot be posted, and can be cancelled. Every path releases the
|
|
148
|
+
* timer and the reply registration; a reply that arrives afterwards finds no entry and is ignored.
|
|
149
|
+
* `cancel()` leaves the promise unsettled: the caller that cancels has stopped waiting for it.
|
|
150
|
+
*/
|
|
151
|
+
_postMessageBounded(command: string, args: object, options: {
|
|
152
|
+
timeoutMs: number;
|
|
153
|
+
timeoutError: object;
|
|
154
|
+
sendError: object;
|
|
155
|
+
}): {
|
|
156
|
+
promise: Promise<any>;
|
|
157
|
+
cancel: () => void;
|
|
158
|
+
};
|
|
116
159
|
_postMessage(command: string, args: any, callBack?: any): void;
|
|
117
160
|
_postMessageSync(command: string, args: any): any;
|
|
118
161
|
}
|
|
119
162
|
export * from "core/constants";
|
|
120
163
|
}
|
|
121
|
-
declare module "utils/client" {
|
|
122
|
-
import { BaseSDK } from "core/index";
|
|
123
|
-
export class Client extends BaseSDK {
|
|
124
|
-
/**
|
|
125
|
-
* Display an info message toast in the platform.
|
|
126
|
-
*
|
|
127
|
-
* @param message - The message to display. Accepts a string or object (serialized to JSON).
|
|
128
|
-
* @returns A promise that resolves when the message is shown.
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* await kf.client.showInfo("Record saved successfully");
|
|
132
|
-
*/
|
|
133
|
-
showInfo(message: string | object): any;
|
|
134
|
-
/**
|
|
135
|
-
* Display a confirmation dialog and wait for the user's response.
|
|
136
|
-
*
|
|
137
|
-
* @param args - Dialog configuration.
|
|
138
|
-
* @param args.title - Dialog title.
|
|
139
|
-
* @param args.content - Body text of the dialog.
|
|
140
|
-
* @param args.okText - Label for the confirm button (default: "Ok").
|
|
141
|
-
* @param args.cancelText - Label for the cancel button (default: "Cancel").
|
|
142
|
-
* @returns A promise that resolves with `{ action: "OK" }` or `{ action: "CANCEL" }`.
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* const { action } = await kf.client.showConfirm({
|
|
146
|
-
* title: "Delete record?",
|
|
147
|
-
* content: "This cannot be undone.",
|
|
148
|
-
* okText: "Delete",
|
|
149
|
-
* cancelText: "Cancel",
|
|
150
|
-
* });
|
|
151
|
-
* if (action === "OK") { ... }
|
|
152
|
-
*/
|
|
153
|
-
showConfirm(args: {
|
|
154
|
-
title: string;
|
|
155
|
-
content: string;
|
|
156
|
-
okText: string;
|
|
157
|
-
cancelText: string;
|
|
158
|
-
}): any;
|
|
159
|
-
/**
|
|
160
|
-
* Navigate the platform to the given URL.
|
|
161
|
-
*
|
|
162
|
-
* @param url - The URL to navigate to.
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* kf.client.redirect("https://example.com");
|
|
166
|
-
*/
|
|
167
|
-
redirect(url: string): any;
|
|
168
|
-
/**
|
|
169
|
-
* Resolve a Kissflow image field value to a base64 data URL.
|
|
170
|
-
*
|
|
171
|
-
* Custom components (iframes) cannot load Kissflow-hosted images directly due to
|
|
172
|
-
* CORS restrictions and 302 redirects to signed S3 URLs. This method fetches the
|
|
173
|
-
* image in the parent window (which has the required session cookies) and returns
|
|
174
|
-
* a self-contained `data:image/...;base64,...` URL that can be used as `<img src>`
|
|
175
|
-
* without any CORS issues.
|
|
176
|
-
*
|
|
177
|
-
* @param imageValue - The image field value must contain a `key` property and
|
|
178
|
-
* optionally a `photos` array. Uses `photos[1]` (preview resolution) when available,
|
|
179
|
-
* falls back to `key`.
|
|
180
|
-
* @returns A promise that resolves with the base64 data URL string.
|
|
181
|
-
*
|
|
182
|
-
* @example
|
|
183
|
-
* const dataUrl = await kf.client.getImageUrl(imageFieldValue);
|
|
184
|
-
* document.querySelector("#avatar").src = dataUrl;
|
|
185
|
-
*/
|
|
186
|
-
getImageUrl(imageValue: Record<string, unknown>): any;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
declare module "utils/formatter" {
|
|
190
|
-
import { BaseSDK } from "core/index";
|
|
191
|
-
export class Formatter extends BaseSDK {
|
|
192
|
-
toDate(date: string): any;
|
|
193
|
-
toDateTime(date: string): any;
|
|
194
|
-
toNumber(value: string): any;
|
|
195
|
-
toCurrency(value: string, currencyCode: string): any;
|
|
196
|
-
toBoolean(value: string): any;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
declare module "utils/validation" {
|
|
200
|
-
/**
|
|
201
|
-
* Validation utilities for SDK methods
|
|
202
|
-
*/
|
|
203
|
-
/**
|
|
204
|
-
* Throws error if value is falsy
|
|
205
|
-
*/
|
|
206
|
-
export function requireField(value: any, fieldName: string): void;
|
|
207
|
-
/**
|
|
208
|
-
* Returns a rejected promise if value is falsy, null otherwise
|
|
209
|
-
* Use for async validation in SDK methods
|
|
210
|
-
*/
|
|
211
|
-
export function requireFieldAsync(value: any, fieldName: string): Promise<never> | null;
|
|
212
|
-
/**
|
|
213
|
-
* Returns a rejected promise if any of the values are falsy
|
|
214
|
-
* Use for validating multiple required fields
|
|
215
|
-
*/
|
|
216
|
-
export function requireFieldsAsync(fields: Array<{
|
|
217
|
-
value: any;
|
|
218
|
-
name: string;
|
|
219
|
-
}>): Promise<never> | null;
|
|
220
|
-
}
|
|
221
|
-
declare module "utils/index" {
|
|
222
|
-
export * from "utils/client";
|
|
223
|
-
export * from "utils/formatter";
|
|
224
|
-
export * from "utils/validation";
|
|
225
|
-
export const isObject: (value: any) => boolean;
|
|
226
|
-
}
|
|
227
|
-
declare module "core/proxy" {
|
|
228
|
-
export class CreateProxy {
|
|
229
|
-
path: string[];
|
|
230
|
-
parent: object;
|
|
231
|
-
constructor(parent: object, target?: {}, path?: any[]);
|
|
232
|
-
get(target: object, property: string): any;
|
|
233
|
-
set(target: object, property: string, value: any, reciever: any): any;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
164
|
declare module "types/external" {
|
|
237
165
|
export type QueryResponse = {
|
|
238
166
|
items: any[];
|
|
@@ -290,6 +218,17 @@ declare module "types/external" {
|
|
|
290
218
|
_id: string;
|
|
291
219
|
_activity_instance_id: string;
|
|
292
220
|
};
|
|
221
|
+
export type GeolocationValue = {
|
|
222
|
+
Address?: string;
|
|
223
|
+
Latitude: string;
|
|
224
|
+
Longitude: string;
|
|
225
|
+
City?: string;
|
|
226
|
+
State?: string;
|
|
227
|
+
Country?: string;
|
|
228
|
+
ZipCode?: string;
|
|
229
|
+
Area?: string;
|
|
230
|
+
PlaceId?: string;
|
|
231
|
+
};
|
|
293
232
|
export type ProcessMyItemsOptions = BaseQueryOptions & {
|
|
294
233
|
status?: "draft" | "inprogress" | "completed" | "withdrawn" | "rejected" | "all";
|
|
295
234
|
payload?: ProcessPayloadOptions;
|
|
@@ -308,6 +247,7 @@ declare module "types/external" {
|
|
|
308
247
|
export type ProcessQueryResponse = QueryResponse;
|
|
309
248
|
export type ProcessGetItemOptions = {
|
|
310
249
|
instanceId: string;
|
|
250
|
+
activityInstanceId: string;
|
|
311
251
|
};
|
|
312
252
|
export type ProcessCreateItemOptions = {
|
|
313
253
|
data?: object;
|
|
@@ -320,6 +260,13 @@ declare module "types/external" {
|
|
|
320
260
|
export type ProcessDeleteItemOptions = {
|
|
321
261
|
instanceId: string;
|
|
322
262
|
};
|
|
263
|
+
export type ProcessGetAdminItemOptions = {
|
|
264
|
+
instanceId: string;
|
|
265
|
+
};
|
|
266
|
+
export type ProcessUpdateAdminItemOptions = {
|
|
267
|
+
instanceId: string;
|
|
268
|
+
data: object;
|
|
269
|
+
};
|
|
323
270
|
export type ProcessSubmitItemOptions = {
|
|
324
271
|
instanceId: string;
|
|
325
272
|
activityInstanceId: string;
|
|
@@ -362,6 +309,32 @@ declare module "types/external" {
|
|
|
362
309
|
export type ProcessDiscardItemOptions = {
|
|
363
310
|
instanceId: string;
|
|
364
311
|
};
|
|
312
|
+
export type ProcessFieldOptions = {
|
|
313
|
+
instanceId: string;
|
|
314
|
+
activityInstanceId: string;
|
|
315
|
+
fieldId: string;
|
|
316
|
+
/** Skip the server-side model lookup by supplying the field's type directly. */
|
|
317
|
+
fieldType?: string;
|
|
318
|
+
tableId?: string;
|
|
319
|
+
tableRowId?: string;
|
|
320
|
+
};
|
|
321
|
+
export type ProcessAttachmentFile = {
|
|
322
|
+
id: string;
|
|
323
|
+
name: string;
|
|
324
|
+
key: string;
|
|
325
|
+
size?: number;
|
|
326
|
+
fileExtension?: string;
|
|
327
|
+
};
|
|
328
|
+
export type ProcessParseAttachmentOptions = {
|
|
329
|
+
instanceId: string;
|
|
330
|
+
activityInstanceId: string;
|
|
331
|
+
fieldId: string;
|
|
332
|
+
file: ProcessAttachmentFile;
|
|
333
|
+
};
|
|
334
|
+
export type ProcessAttachmentParseResult = {
|
|
335
|
+
appliedFields: string[];
|
|
336
|
+
suggestedBy: string;
|
|
337
|
+
};
|
|
365
338
|
export type FetchOptions = {
|
|
366
339
|
method?: string;
|
|
367
340
|
body?: string | object;
|
|
@@ -397,6 +370,14 @@ declare module "types/external" {
|
|
|
397
370
|
data?: object;
|
|
398
371
|
viewId?: string;
|
|
399
372
|
};
|
|
373
|
+
export type DataformFieldOptions = {
|
|
374
|
+
instanceId: string;
|
|
375
|
+
fieldId: string;
|
|
376
|
+
/** Skip the server-side model lookup by supplying the field's type directly. */
|
|
377
|
+
fieldType?: string;
|
|
378
|
+
tableId?: string;
|
|
379
|
+
tableRowId?: string;
|
|
380
|
+
};
|
|
400
381
|
export type BoardGetItemsOptions = BaseQueryOptions & {
|
|
401
382
|
viewId?: string;
|
|
402
383
|
payload?: PayloadOptions;
|
|
@@ -422,11 +403,117 @@ declare module "types/external" {
|
|
|
422
403
|
export type BoardDiscardItemOptions = {
|
|
423
404
|
instanceId: string;
|
|
424
405
|
};
|
|
406
|
+
export type BoardFieldOptions = {
|
|
407
|
+
instanceId: string;
|
|
408
|
+
fieldId: string;
|
|
409
|
+
/** Skip the server-side model lookup by supplying the field's type directly. */
|
|
410
|
+
fieldType?: string;
|
|
411
|
+
tableId?: string;
|
|
412
|
+
tableRowId?: string;
|
|
413
|
+
};
|
|
414
|
+
export type AgentInputDataType = "Text" | "Number" | "Boolean" | "Attachment";
|
|
415
|
+
export type AgentOutputDataType = "string" | "number" | "boolean";
|
|
416
|
+
export type AgentInputField = {
|
|
417
|
+
Key: string;
|
|
418
|
+
Name: string;
|
|
419
|
+
DataType: AgentInputDataType;
|
|
420
|
+
Required: boolean;
|
|
421
|
+
Description?: string;
|
|
422
|
+
};
|
|
423
|
+
export type AgentOutputField = {
|
|
424
|
+
Key: string;
|
|
425
|
+
Name: string;
|
|
426
|
+
DataType: AgentOutputDataType;
|
|
427
|
+
Description?: string;
|
|
428
|
+
};
|
|
429
|
+
/**
|
|
430
|
+
* A file for an `Attachment` input: exactly one of `Key` (a Kissflow attachment) or `Url` (https).
|
|
431
|
+
* A file from `openFilePicker` or `uploadFile` has lowercase keys: pass
|
|
432
|
+
* `{ Key: file.key, FileName: file.name, Size: file.size }`.
|
|
433
|
+
*/
|
|
434
|
+
export type AgentAttachmentValue = {
|
|
435
|
+
Key: string;
|
|
436
|
+
Url?: never;
|
|
437
|
+
FileName: string;
|
|
438
|
+
Size?: number;
|
|
439
|
+
ContentType?: string;
|
|
440
|
+
} | {
|
|
441
|
+
Url: string;
|
|
442
|
+
Key?: never;
|
|
443
|
+
FileName: string;
|
|
444
|
+
Size?: number;
|
|
445
|
+
ContentType?: string;
|
|
446
|
+
};
|
|
447
|
+
export type AgentInputValue = string | number | boolean | AgentAttachmentValue;
|
|
448
|
+
/** The Agent's published invocation contract. */
|
|
449
|
+
export type AgentContract = {
|
|
450
|
+
AgentId: string;
|
|
451
|
+
Definition: {
|
|
452
|
+
Name: string;
|
|
453
|
+
Description?: string;
|
|
454
|
+
Icon?: Record<string, unknown>;
|
|
455
|
+
Inputs: AgentInputField[];
|
|
456
|
+
Outputs: AgentOutputField[];
|
|
457
|
+
MaxOutputItems: number;
|
|
458
|
+
};
|
|
459
|
+
Readiness: {
|
|
460
|
+
Ready: boolean;
|
|
461
|
+
Issues: Array<{
|
|
462
|
+
Code: string;
|
|
463
|
+
Path: string;
|
|
464
|
+
Message: string;
|
|
465
|
+
}>;
|
|
466
|
+
};
|
|
467
|
+
};
|
|
468
|
+
export type AgentExecuteOptions = {
|
|
469
|
+
/** Values keyed by input `Key`, as declared in the contract. */
|
|
470
|
+
inputData: Record<string, AgentInputValue>;
|
|
471
|
+
};
|
|
472
|
+
/** More statuses may be added; treat any status other than `Completed` or `Failed` as still in progress. */
|
|
473
|
+
export type AgentExecutionStatus = "Queued" | "NotStarted" | "Running" | "Completed" | "Failed" | (string & {});
|
|
474
|
+
/** What `execute` resolves with once the run is accepted, before it has finished. */
|
|
475
|
+
export type AgentExecutionAccepted = {
|
|
476
|
+
ExecutionId: string;
|
|
477
|
+
Status: AgentExecutionStatus;
|
|
478
|
+
};
|
|
479
|
+
export type AgentExecution = {
|
|
480
|
+
ExecutionId: string;
|
|
481
|
+
Status: AgentExecutionStatus;
|
|
482
|
+
Stage?: string;
|
|
483
|
+
/** Present on `Completed`: one row per item, keyed by output `Key`. */
|
|
484
|
+
Output?: {
|
|
485
|
+
items: Array<Record<string, string | number | boolean>>;
|
|
486
|
+
};
|
|
487
|
+
/** Present on `Failed`. */
|
|
488
|
+
Error?: {
|
|
489
|
+
Code: string;
|
|
490
|
+
Retryable: boolean;
|
|
491
|
+
Details?: unknown;
|
|
492
|
+
};
|
|
493
|
+
Warnings?: Array<Record<string, unknown>>;
|
|
494
|
+
CreatedAt?: string;
|
|
495
|
+
StartedAt?: string;
|
|
496
|
+
CompletedAt?: string;
|
|
497
|
+
};
|
|
498
|
+
/**
|
|
499
|
+
* How an Agent call fails: `error` is the message text and `errorCode` either the platform code
|
|
500
|
+
* (`KISSFLOW_ERROR_…`) or an `AGENT_…` code, including `AGENT_HOST_TIMEOUT`, `AGENT_REQUEST_NOT_SENT`,
|
|
501
|
+
* `AGENT_EXECUTE_OUTCOME_UNKNOWN` (a run may have started), `AGENT_EXECUTE_NOT_SENT` (no run started),
|
|
502
|
+
* `AGENT_HOST_UNSUPPORTED`, `AGENT_WATCH_INVALID_EVENT`, `AGENT_OBSERVATION_STOPPED`, and from the host
|
|
503
|
+
* `AGENT_READ_TIMEOUT` and `AGENT_OFFLINE`. The list may grow; fall back to `error` for an unknown code.
|
|
504
|
+
* There is no `message`: read `error` for the text.
|
|
505
|
+
*/
|
|
506
|
+
export type AgentError = {
|
|
507
|
+
isError: true;
|
|
508
|
+
error?: string;
|
|
509
|
+
errorCode?: string;
|
|
510
|
+
};
|
|
425
511
|
}
|
|
426
512
|
declare module "types/internal" {
|
|
427
513
|
import { userObject, accountObject, environmentObject } from "types/external";
|
|
428
514
|
export interface SDKContext {
|
|
429
515
|
formInstanceId: string;
|
|
516
|
+
flowId: string;
|
|
430
517
|
tableId: string;
|
|
431
518
|
tableRowId: string;
|
|
432
519
|
componentId: string;
|
|
@@ -454,10 +541,262 @@ declare module "types/internal" {
|
|
|
454
541
|
}
|
|
455
542
|
export interface PageContext {
|
|
456
543
|
pageId: string;
|
|
544
|
+
initialRoute?: string;
|
|
457
545
|
}
|
|
458
546
|
export interface PopupContext {
|
|
459
547
|
popupId?: string;
|
|
460
548
|
}
|
|
549
|
+
export interface FilePickerOptions {
|
|
550
|
+
fileExtensions?: string[];
|
|
551
|
+
maxSize?: number;
|
|
552
|
+
maxCount?: number;
|
|
553
|
+
imageProps?: {
|
|
554
|
+
sizes?: Array<[number, number]>;
|
|
555
|
+
crop?: boolean;
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
export interface ScannerOptions {
|
|
559
|
+
/** Allow decoding from an uploaded image instead of the camera. */
|
|
560
|
+
localFileScan?: boolean;
|
|
561
|
+
}
|
|
562
|
+
/** Minimal shape of a browser File/Blob object, avoids requiring the DOM lib. */
|
|
563
|
+
export interface UploadableFile {
|
|
564
|
+
name: string;
|
|
565
|
+
size?: number;
|
|
566
|
+
type?: string;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
declare module "utils/client" {
|
|
570
|
+
import { BaseSDK } from "core/index";
|
|
571
|
+
import { GeolocationValue } from "types/external";
|
|
572
|
+
import { FilePickerOptions, ScannerOptions, UploadableFile } from "types/internal";
|
|
573
|
+
export class Client extends BaseSDK {
|
|
574
|
+
/**
|
|
575
|
+
* Display an info message toast in the platform.
|
|
576
|
+
*
|
|
577
|
+
* @param message - The message to display. Accepts a string or object (serialized to JSON).
|
|
578
|
+
* @returns A promise that resolves when the message is shown.
|
|
579
|
+
*
|
|
580
|
+
* @example
|
|
581
|
+
* await kf.client.showInfo("Record saved successfully");
|
|
582
|
+
*/
|
|
583
|
+
showInfo(message: string | object): any;
|
|
584
|
+
/**
|
|
585
|
+
* Display a confirmation dialog and wait for the user's response.
|
|
586
|
+
*
|
|
587
|
+
* @param args - Dialog configuration.
|
|
588
|
+
* @param args.title - Dialog title.
|
|
589
|
+
* @param args.content - Body text of the dialog.
|
|
590
|
+
* @param args.okText - Label for the confirm button (default: "Ok").
|
|
591
|
+
* @param args.cancelText - Label for the cancel button (default: "Cancel").
|
|
592
|
+
* @returns A promise that resolves with `{ action: "OK" }` or `{ action: "CANCEL" }`.
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* const { action } = await kf.client.showConfirm({
|
|
596
|
+
* title: "Delete record?",
|
|
597
|
+
* content: "This cannot be undone.",
|
|
598
|
+
* okText: "Delete",
|
|
599
|
+
* cancelText: "Cancel",
|
|
600
|
+
* });
|
|
601
|
+
* if (action === "OK") { ... }
|
|
602
|
+
*/
|
|
603
|
+
showConfirm(args: {
|
|
604
|
+
title: string;
|
|
605
|
+
content: string;
|
|
606
|
+
okText: string;
|
|
607
|
+
cancelText: string;
|
|
608
|
+
}): any;
|
|
609
|
+
/**
|
|
610
|
+
* Navigate the platform to the given URL.
|
|
611
|
+
*
|
|
612
|
+
* @param url - The URL to navigate to.
|
|
613
|
+
*
|
|
614
|
+
* @example
|
|
615
|
+
* kf.client.redirect("https://example.com");
|
|
616
|
+
*/
|
|
617
|
+
redirect(url: string): any;
|
|
618
|
+
/**
|
|
619
|
+
* Resolve a Kissflow image field value to a base64 data URL.
|
|
620
|
+
*
|
|
621
|
+
* Custom components (iframes) cannot load Kissflow-hosted images directly due to
|
|
622
|
+
* CORS restrictions and 302 redirects to signed S3 URLs. This method fetches the
|
|
623
|
+
* image in the parent window (which has the required session cookies) and returns
|
|
624
|
+
* a self-contained `data:image/...;base64,...` URL that can be used as `<img src>`
|
|
625
|
+
* without any CORS issues.
|
|
626
|
+
*
|
|
627
|
+
* @param imageValue - The image field value must contain a `key` property and
|
|
628
|
+
* optionally a `photos` array. Uses `photos[1]` (preview resolution) when available,
|
|
629
|
+
* falls back to `key`.
|
|
630
|
+
* @returns A promise that resolves with the base64 data URL string.
|
|
631
|
+
*
|
|
632
|
+
* @example
|
|
633
|
+
* const dataUrl = await kf.client.getImageUrl(imageFieldValue);
|
|
634
|
+
* document.querySelector("#avatar").src = dataUrl;
|
|
635
|
+
*/
|
|
636
|
+
getImageUrl(imageValue: Record<string, unknown>): any;
|
|
637
|
+
/**
|
|
638
|
+
* Open the platform's file picker, upload the selected file(s), and resolve
|
|
639
|
+
* with their metadata.
|
|
640
|
+
*
|
|
641
|
+
* Custom components (iframes) cannot access the platform's authenticated upload
|
|
642
|
+
* endpoints directly. This method opens the file picker in the parent window
|
|
643
|
+
* (which has the required session), runs the full select → upload flow, and
|
|
644
|
+
* resolves once all uploads settle with an array of the uploaded files'
|
|
645
|
+
* metadata (each including `key`, `name`, `size`, `photos`, etc. — the same
|
|
646
|
+
* shape consumed by `getImageUrl`).
|
|
647
|
+
*
|
|
648
|
+
* Always resolves with an array — a single-element array for single-file
|
|
649
|
+
* pickers (e.g. `maxCount: 1` for `Image`), one entry per uploaded file for
|
|
650
|
+
* multi-file pickers (e.g. `Attachment`). Resolves with `[]` if the user closes
|
|
651
|
+
* the picker without completing any upload.
|
|
652
|
+
*
|
|
653
|
+
* @param options - File picker configuration (e.g. `fileExtensions`, `maxSize`,
|
|
654
|
+
* `maxCount`, `imageProps`).
|
|
655
|
+
* @returns A promise that resolves with an array of uploaded file metadata
|
|
656
|
+
* objects (empty if the picker was closed without uploading anything).
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* const files = await kf.client.openFilePicker({ fileExtensions: ["JPG", "PNG"] });
|
|
660
|
+
* if (files.length) onChange(files[0]); // single-file consumer (Image)
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* const files = await kf.client.openFilePicker({ maxCount: 10 });
|
|
664
|
+
* if (files.length) onChange([...existing, ...files]); // multi-file consumer (Attachment)
|
|
665
|
+
*/
|
|
666
|
+
openFilePicker(options: FilePickerOptions): any;
|
|
667
|
+
/**
|
|
668
|
+
* Open the platform's barcode/QR scanner and resolve with the decoded text.
|
|
669
|
+
*
|
|
670
|
+
* The scanner UI (camera stream + decoding) runs in the parent window, which
|
|
671
|
+
* owns the camera permission — the iframe itself never accesses the camera.
|
|
672
|
+
* Camera-permission prompts and denials are handled inside the scanner UI;
|
|
673
|
+
* they are not surfaced as errors here.
|
|
674
|
+
*
|
|
675
|
+
* Resolves with `null` if the user closes the scanner without a successful
|
|
676
|
+
* scan (including the scanner's own inactivity timeout).
|
|
677
|
+
*
|
|
678
|
+
* Note: currently supported in web custom app UIs; the mobile (PWA) custom
|
|
679
|
+
* UI does not host the scanner portal yet.
|
|
680
|
+
*
|
|
681
|
+
* @param options - Scanner configuration (e.g. `localFileScan` to allow
|
|
682
|
+
* decoding from an uploaded image instead of the camera).
|
|
683
|
+
* @returns A promise that resolves with the decoded string, or `null` if the
|
|
684
|
+
* scanner was closed without scanning.
|
|
685
|
+
*
|
|
686
|
+
* @example
|
|
687
|
+
* const code = await kf.client.openScanner({ localFileScan: true });
|
|
688
|
+
* if (code) onChange(code);
|
|
689
|
+
*/
|
|
690
|
+
openScanner(options?: ScannerOptions): any;
|
|
691
|
+
/**
|
|
692
|
+
* Open the platform's native Geolocation map picker (search, current-location
|
|
693
|
+
* detection, marker drag, reverse-geocoding) in a modal over the custom
|
|
694
|
+
* form/component. Runs in the parent window, which owns the Google Maps API
|
|
695
|
+
* key — the iframe itself never needs one.
|
|
696
|
+
*
|
|
697
|
+
* Resolves with `null` if the user closes the picker without selecting a
|
|
698
|
+
* location.
|
|
699
|
+
*
|
|
700
|
+
* @param value - Optional current geolocation value to pre-select on the map.
|
|
701
|
+
* @returns A promise that resolves with the picked location object, or
|
|
702
|
+
* `null` if the picker was closed without a selection.
|
|
703
|
+
*
|
|
704
|
+
* @example
|
|
705
|
+
* const location = await kf.client.pickLocation();
|
|
706
|
+
* if (location) onChange(location);
|
|
707
|
+
*/
|
|
708
|
+
pickLocation(value?: GeolocationValue): any;
|
|
709
|
+
/**
|
|
710
|
+
* Upload a File object to Kissflow's S3 storage and resolve with its metadata.
|
|
711
|
+
*
|
|
712
|
+
* Use this when you have a File/Blob already in memory (e.g. a canvas drawing
|
|
713
|
+
* converted to a PNG blob) and need to upload it without opening a file picker UI.
|
|
714
|
+
* The platform runs the upload in the parent window (which has the required session)
|
|
715
|
+
* and resolves with the uploaded file's `{ key, name, ... }` metadata — the same
|
|
716
|
+
* shape returned by `openFilePicker`.
|
|
717
|
+
*
|
|
718
|
+
* Resolves with `null` if the upload fails.
|
|
719
|
+
*
|
|
720
|
+
* @param file - The File or Blob to upload.
|
|
721
|
+
* @param fileName - Optional file name override (defaults to `file.name`).
|
|
722
|
+
* @returns A promise that resolves with the uploaded file metadata, or `null` on failure.
|
|
723
|
+
*
|
|
724
|
+
* @example
|
|
725
|
+
* const blob = await new Promise<Blob>(res => canvas.toBlob(res, 'image/png'));
|
|
726
|
+
* const file = new File([blob], 'signature.png', { type: 'image/png' });
|
|
727
|
+
* const result = await kf.client.uploadFile(file);
|
|
728
|
+
* if (result) onChange(result);
|
|
729
|
+
*/
|
|
730
|
+
uploadFile(file: UploadableFile, fileName?: string): any;
|
|
731
|
+
/**
|
|
732
|
+
* Open the platform's file preview (lightbox) for one or more files.
|
|
733
|
+
*
|
|
734
|
+
* `files` always accepts an array — pass a single-element array for fields like
|
|
735
|
+
* `Image`, or the full list for multi-file fields like `Attachment`. The host's
|
|
736
|
+
* preview UI natively renders next/prev navigation across the array; the SDK
|
|
737
|
+
* just passes the file list through, no extra navigation surface is needed here.
|
|
738
|
+
*
|
|
739
|
+
* @param args - Preview configuration.
|
|
740
|
+
* @param args.files - Array of file metadata objects to preview.
|
|
741
|
+
* @param args.indexOfFile - Index of the file to open the preview on (default: 0).
|
|
742
|
+
* @returns A promise that resolves once the user closes the preview.
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* await kf.client.openFilePreview({ files: [imageFieldValue] });
|
|
746
|
+
* await kf.client.openFilePreview({ files: attachmentFieldValue, indexOfFile: 2 });
|
|
747
|
+
*/
|
|
748
|
+
openFilePreview(args: {
|
|
749
|
+
files: Record<string, unknown>[];
|
|
750
|
+
indexOfFile?: number;
|
|
751
|
+
}): any;
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
declare module "utils/formatter" {
|
|
755
|
+
import { BaseSDK } from "core/index";
|
|
756
|
+
export class Formatter extends BaseSDK {
|
|
757
|
+
toDate(date: string): any;
|
|
758
|
+
toDateTime(date: string): any;
|
|
759
|
+
toNumber(value: string): any;
|
|
760
|
+
toCurrency(value: string, currencyCode: string): any;
|
|
761
|
+
toBoolean(value: string): any;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
declare module "utils/validation" {
|
|
765
|
+
/**
|
|
766
|
+
* Validation utilities for SDK methods
|
|
767
|
+
*/
|
|
768
|
+
/**
|
|
769
|
+
* Throws error if value is falsy
|
|
770
|
+
*/
|
|
771
|
+
export function requireField(value: any, fieldName: string): void;
|
|
772
|
+
/**
|
|
773
|
+
* Returns a rejected promise if value is falsy, null otherwise
|
|
774
|
+
* Use for async validation in SDK methods
|
|
775
|
+
*/
|
|
776
|
+
export function requireFieldAsync(value: any, fieldName: string): Promise<never> | null;
|
|
777
|
+
/**
|
|
778
|
+
* Returns a rejected promise if any of the values are falsy
|
|
779
|
+
* Use for validating multiple required fields
|
|
780
|
+
*/
|
|
781
|
+
export function requireFieldsAsync(fields: Array<{
|
|
782
|
+
value: any;
|
|
783
|
+
name: string;
|
|
784
|
+
}>): Promise<never> | null;
|
|
785
|
+
}
|
|
786
|
+
declare module "utils/index" {
|
|
787
|
+
export * from "utils/client";
|
|
788
|
+
export * from "utils/formatter";
|
|
789
|
+
export * from "utils/validation";
|
|
790
|
+
export const isObject: (value: any) => boolean;
|
|
791
|
+
}
|
|
792
|
+
declare module "core/proxy" {
|
|
793
|
+
export class CreateProxy {
|
|
794
|
+
path: string[];
|
|
795
|
+
parent: object;
|
|
796
|
+
constructor(parent: object, target?: {}, path?: any[]);
|
|
797
|
+
get(target: object, property: string): any;
|
|
798
|
+
set(target: object, property: string, value: any, reciever: any): any;
|
|
799
|
+
}
|
|
461
800
|
}
|
|
462
801
|
declare module "app/component" {
|
|
463
802
|
import { BaseSDK } from "core/index";
|
|
@@ -479,6 +818,14 @@ declare module "app/component" {
|
|
|
479
818
|
_id: string;
|
|
480
819
|
constructor(id: any);
|
|
481
820
|
watchParams(callBack: (data: any) => any): void;
|
|
821
|
+
/**
|
|
822
|
+
* Subscribe to route changes pushed by the Kissflow host
|
|
823
|
+
* (parent back/forward or deep-link). Used by the App UI framework
|
|
824
|
+
* to keep the in-iframe router in sync with the parent URL.
|
|
825
|
+
*/
|
|
826
|
+
watchRoute(callBack: (data: {
|
|
827
|
+
route: string;
|
|
828
|
+
}) => any): void;
|
|
482
829
|
}
|
|
483
830
|
}
|
|
484
831
|
declare module "app/popup" {
|
|
@@ -504,6 +851,7 @@ declare module "app/page" {
|
|
|
504
851
|
_id: string;
|
|
505
852
|
popup: Popup;
|
|
506
853
|
type: string;
|
|
854
|
+
_route: string;
|
|
507
855
|
constructor(props: PageContext, isCustomComponent?: boolean);
|
|
508
856
|
getParameter(key: string): any;
|
|
509
857
|
getAllParameters(): any;
|
|
@@ -511,6 +859,13 @@ declare module "app/page" {
|
|
|
511
859
|
setVariable(key: string | object, value?: any): any;
|
|
512
860
|
openPopup(popupId: string, popupParams?: object): any;
|
|
513
861
|
getComponent(componentId: string): Component;
|
|
862
|
+
/**
|
|
863
|
+
* Notify the Kissflow host that the custom UI navigated to `path`,
|
|
864
|
+
* so the parent browser URL mirrors the route. Used by the App UI framework.
|
|
865
|
+
*/
|
|
866
|
+
setRoute(path: string): void;
|
|
867
|
+
/** Returns the initial deep-link route the page was opened with. */
|
|
868
|
+
getRoute(): string;
|
|
514
869
|
}
|
|
515
870
|
}
|
|
516
871
|
declare module "app/decisiontable" {
|
|
@@ -521,9 +876,119 @@ declare module "app/decisiontable" {
|
|
|
521
876
|
evaluate(payload?: object): any;
|
|
522
877
|
}
|
|
523
878
|
}
|
|
879
|
+
declare module "app/agent" {
|
|
880
|
+
import { BaseSDK } from "core/index";
|
|
881
|
+
import { AgentContract, AgentError, AgentExecuteOptions, AgentExecution, AgentExecutionAccepted } from "types/external";
|
|
882
|
+
/**
|
|
883
|
+
* A published Custom Agent of the current app.
|
|
884
|
+
*
|
|
885
|
+
* Get one with `kf.app.getAgent(agentId)`. Calls run as the signed-in user, against the Agent's
|
|
886
|
+
* published (Live) definition.
|
|
887
|
+
*/
|
|
888
|
+
export class Agent extends BaseSDK {
|
|
889
|
+
private agentId;
|
|
890
|
+
private _id;
|
|
891
|
+
private activeWatches;
|
|
892
|
+
constructor(agentId: string);
|
|
893
|
+
/**
|
|
894
|
+
* Read the Agent's published contract: its inputs, outputs and readiness.
|
|
895
|
+
*
|
|
896
|
+
* @example
|
|
897
|
+
* const { Definition } = await kf.app.getAgent("AgXXXXXXXXXX").getContract();
|
|
898
|
+
*/
|
|
899
|
+
getContract(): Promise<AgentContract>;
|
|
900
|
+
/**
|
|
901
|
+
* Start a run. Resolves once the run is accepted (`ExecutionId`, `Status`), not when it finishes;
|
|
902
|
+
* use {@link onExecutionComplete} or {@link getExecution} for the result.
|
|
903
|
+
*
|
|
904
|
+
* Never retried: if the call fails with `AGENT_EXECUTE_OUTCOME_UNKNOWN`, a run may still have
|
|
905
|
+
* started, and app code cannot list runs to find it: tell the user the request may still be in
|
|
906
|
+
* progress instead of starting another. `AGENT_EXECUTE_NOT_SENT` means it was not sent (for
|
|
907
|
+
* example, the user is offline).
|
|
908
|
+
*
|
|
909
|
+
* @example
|
|
910
|
+
* const { ExecutionId } = await agent.execute({ inputData: { request: "Two desks", amount: 54000 } });
|
|
911
|
+
*/
|
|
912
|
+
execute(options: AgentExecuteOptions): Promise<AgentExecutionAccepted>;
|
|
913
|
+
/**
|
|
914
|
+
* Read a run's current state, with its `Output` once `Completed` or its `Error` once `Failed`.
|
|
915
|
+
* Callers who are not the App's authors can read only their own runs.
|
|
916
|
+
*/
|
|
917
|
+
getExecution(executionId: string): Promise<AgentExecution>;
|
|
918
|
+
/**
|
|
919
|
+
* Be told once when a run finishes. `onComplete` gets the run on `Completed` or `Failed` (read
|
|
920
|
+
* `Status`: a failed run is a result, not an error). `onWatchError` gets what stopped the
|
|
921
|
+
* observation instead: an unsupported host, an access or network failure, or the observation limit
|
|
922
|
+
* (`AGENT_OBSERVATION_STOPPED`, after about six minutes; the run may still finish, so read it later
|
|
923
|
+
* with {@link getExecution}). At most one of the two is called, at most once.
|
|
924
|
+
*
|
|
925
|
+
* Neither is called if the script that registered them stops first: form, field, gallery and
|
|
926
|
+
* table scripts stop after one minute, and they and page event scripts stop when the next script
|
|
927
|
+
* starts on the same form, component or page. In those scripts, keep the `ExecutionId` and read
|
|
928
|
+
* it later with {@link getExecution}.
|
|
929
|
+
*
|
|
930
|
+
* Returns a function that stops observing. It never cancels the run.
|
|
931
|
+
*
|
|
932
|
+
* @example
|
|
933
|
+
* const stop = agent.onExecutionComplete(ExecutionId, (run) => show(run), (err) => warn(err));
|
|
934
|
+
* // later, e.g. on unmount
|
|
935
|
+
* stop();
|
|
936
|
+
*/
|
|
937
|
+
onExecutionComplete(executionId: string, onComplete: (execution: AgentExecution) => void, onWatchError?: (error: AgentError) => void): () => void;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
declare module "form/index" {
|
|
941
|
+
import { BaseSDK } from "core/index";
|
|
942
|
+
export class Form extends BaseSDK {
|
|
943
|
+
private storeId;
|
|
944
|
+
private flowId;
|
|
945
|
+
type: string;
|
|
946
|
+
instanceId: string;
|
|
947
|
+
activityInstanceId?: string;
|
|
948
|
+
constructor(storeId: string, flowId: string, instanceId: string, activityInstanceId?: string);
|
|
949
|
+
toJSON(): any;
|
|
950
|
+
getField(fieldId: string): any;
|
|
951
|
+
updateField(args: object): any;
|
|
952
|
+
getValidationErrors(): any;
|
|
953
|
+
getFormConfiguration(): any;
|
|
954
|
+
getFieldState(): any;
|
|
955
|
+
getTable(tableId: string): Table;
|
|
956
|
+
}
|
|
957
|
+
class Table extends BaseSDK {
|
|
958
|
+
private storeId;
|
|
959
|
+
private flowId;
|
|
960
|
+
private instanceId;
|
|
961
|
+
private tableId;
|
|
962
|
+
private activityInstanceId?;
|
|
963
|
+
constructor(storeId: string, flowId: string, instanceId: string, tableId: string, activityInstanceId?: string);
|
|
964
|
+
toJSON(): any;
|
|
965
|
+
getSelectedRows(): any;
|
|
966
|
+
getRows(): TableForm[];
|
|
967
|
+
getRow(rowId: string): TableForm;
|
|
968
|
+
addRow(rowObject: object): any;
|
|
969
|
+
addRows(rows: object[]): any;
|
|
970
|
+
deleteRow(rowId: string): any;
|
|
971
|
+
deleteRows(rows: string[]): any;
|
|
972
|
+
}
|
|
973
|
+
export class TableForm extends BaseSDK {
|
|
974
|
+
private storeId;
|
|
975
|
+
private flowId;
|
|
976
|
+
private instanceId;
|
|
977
|
+
private tableId;
|
|
978
|
+
private rowId;
|
|
979
|
+
private activityInstanceId?;
|
|
980
|
+
type: string;
|
|
981
|
+
constructor(storeId: string, flowId: string, instanceId: string, tableId: string, rowId: string, activityInstanceId?: string);
|
|
982
|
+
getParent(): Form;
|
|
983
|
+
toJSON(): any;
|
|
984
|
+
getField(fieldId: string): any;
|
|
985
|
+
updateField(args: object): any;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
524
988
|
declare module "dataform/index" {
|
|
525
989
|
import { BaseSDK } from "core/index";
|
|
526
|
-
import {
|
|
990
|
+
import { Form } from "form/index";
|
|
991
|
+
import { DataformItem, DataformQueryOptions, DataformQueryResponse, DataformCreateItemOptions, DataformUpdateItemOptions, DataformGetItemOptions, DataformDeleteItemOptions, DataformDiscardItemOptions, DataformSubmitItemOptions, DataformFieldOptions } from "types/external";
|
|
527
992
|
export class Dataform extends BaseSDK {
|
|
528
993
|
private _id;
|
|
529
994
|
constructor(flowId: string);
|
|
@@ -592,11 +1057,36 @@ declare module "dataform/index" {
|
|
|
592
1057
|
getFields(options?: {
|
|
593
1058
|
viewId?: string;
|
|
594
1059
|
}): Promise<any>;
|
|
1060
|
+
/**
|
|
1061
|
+
* Initialize a form with all necessary data (schema, item data, form store)
|
|
1062
|
+
* This is the recommended way to create a custom form for dataform records
|
|
1063
|
+
* It automatically handles fetching schema, item data, and initializing the form store
|
|
1064
|
+
*
|
|
1065
|
+
* @param instanceId - Optional instance ID of the dataform record. If omitted, creates a new record
|
|
1066
|
+
* @param viewId - Optional view ID to scope the form's schema/permissions to a specific view
|
|
1067
|
+
* @returns Promise with Form instance ready to use
|
|
1068
|
+
*
|
|
1069
|
+
* @example
|
|
1070
|
+
* // Load existing record
|
|
1071
|
+
* const dataform = kf.app.getDataform("EmpMaster");
|
|
1072
|
+
* const form = await dataform.initForm("emp_123");
|
|
1073
|
+
* const data = await form.toJSON();
|
|
1074
|
+
*
|
|
1075
|
+
* // Load existing record scoped to a view
|
|
1076
|
+
* const form = await dataform.initForm("emp_123", "EmpMaster_View");
|
|
1077
|
+
*
|
|
1078
|
+
* // Create new record
|
|
1079
|
+
* const form = await dataform.initForm();
|
|
1080
|
+
* await form.updateField({ firstName: "John" });
|
|
1081
|
+
*/
|
|
1082
|
+
initForm(instanceId?: string, viewId?: string): Promise<Form>;
|
|
1083
|
+
getFieldOptions(options?: DataformFieldOptions): Promise<DataformQueryResponse>;
|
|
595
1084
|
}
|
|
596
1085
|
}
|
|
597
1086
|
declare module "board/index" {
|
|
598
1087
|
import { BaseSDK } from "core/index";
|
|
599
|
-
import {
|
|
1088
|
+
import { Form } from "form/index";
|
|
1089
|
+
import { BoardItem, BoardGetItemOptions, BoardGetItemsOptions, BoardQueryResponse, BoardCreateItemOptions, BoardUpdateItemOptions, BoardDeleteItemOptions, BoardSubmitItemOptions, BoardDiscardItemOptions, BoardFieldOptions } from "types/external";
|
|
600
1090
|
export class Board extends BaseSDK {
|
|
601
1091
|
private _id;
|
|
602
1092
|
constructor(flowId: string);
|
|
@@ -676,11 +1166,47 @@ declare module "board/index" {
|
|
|
676
1166
|
getFields(options?: {
|
|
677
1167
|
viewId?: string;
|
|
678
1168
|
}): Promise<any>;
|
|
1169
|
+
/**
|
|
1170
|
+
* Initialize a form for a board item with all necessary setup
|
|
1171
|
+
* Fetches schema, item data, creates and initializes the form store
|
|
1172
|
+
*
|
|
1173
|
+
* @param instanceId - Optional instance ID. If omitted, creates a new board item
|
|
1174
|
+
* @param viewId - Optional view ID to scope the form's schema/permissions to a specific view
|
|
1175
|
+
* @returns Promise with Form instance ready to use
|
|
1176
|
+
*
|
|
1177
|
+
* @example
|
|
1178
|
+
* // Create new board item
|
|
1179
|
+
* const board = kf.app.getBoard("Inventory");
|
|
1180
|
+
* const form = await board.initForm();
|
|
1181
|
+
* await form.updateField({ Name: "New Item" });
|
|
1182
|
+
*
|
|
1183
|
+
* // Edit existing board item
|
|
1184
|
+
* const form = await board.initForm("item_123");
|
|
1185
|
+
* const data = await form.toJSON();
|
|
1186
|
+
*
|
|
1187
|
+
* // Edit existing board item scoped to a view
|
|
1188
|
+
* const form = await board.initForm("item_123", "Inventory_View");
|
|
1189
|
+
*/
|
|
1190
|
+
initForm(instanceId?: string, viewId?: string): Promise<Form>;
|
|
1191
|
+
/**
|
|
1192
|
+
* Get field options for dropdown/lookup fields
|
|
1193
|
+
* @param options - Field options (instanceId, fieldId)
|
|
1194
|
+
* @returns Promise containing the field options
|
|
1195
|
+
*
|
|
1196
|
+
* @example
|
|
1197
|
+
* const board = kf.app.getBoard("Inventory");
|
|
1198
|
+
* const options = await board.getFieldOptions({
|
|
1199
|
+
* instanceId: "item_123",
|
|
1200
|
+
* fieldId: "Category"
|
|
1201
|
+
* });
|
|
1202
|
+
*/
|
|
1203
|
+
getFieldOptions(options: BoardFieldOptions): Promise<any>;
|
|
679
1204
|
}
|
|
680
1205
|
}
|
|
681
1206
|
declare module "process/index" {
|
|
682
1207
|
import { BaseSDK } from "core/index";
|
|
683
|
-
import {
|
|
1208
|
+
import { Form } from "form/index";
|
|
1209
|
+
import { ProcessItem, ProcessGetItemOptions, ProcessMyItemsOptions, ProcessMyTasksOptions, ProcessParticipatedOptions, ProcessAdminOptions, ProcessQueryResponse, ProcessCreateItemOptions, ProcessUpdateItemOptions, ProcessDeleteItemOptions, ProcessGetAdminItemOptions, ProcessUpdateAdminItemOptions, ProcessSubmitItemOptions, ProcessRejectItemOptions, ProcessWithdrawItemOptions, ProcessSendbackItemOptions, ProcessReassignItemOptions, ProcessGetReassigneesOptions, ProcessRestartItemOptions, ProcessDiscardItemOptions, ProcessFieldOptions, ProcessParseAttachmentOptions, ProcessAttachmentParseResult } from "types/external";
|
|
684
1210
|
export class Process extends BaseSDK {
|
|
685
1211
|
private _id;
|
|
686
1212
|
constructor(flowId: string);
|
|
@@ -732,7 +1258,7 @@ declare module "process/index" {
|
|
|
732
1258
|
getAdminItems(options?: ProcessAdminOptions): Promise<ProcessQueryResponse>;
|
|
733
1259
|
/**
|
|
734
1260
|
* Get a single process instance by ID
|
|
735
|
-
* @param options - instanceId (required)
|
|
1261
|
+
* @param options - instanceId, activityInstanceId (both required)
|
|
736
1262
|
* @returns Promise containing the instance data
|
|
737
1263
|
*/
|
|
738
1264
|
getItem(options: ProcessGetItemOptions): Promise<ProcessItem>;
|
|
@@ -770,6 +1296,26 @@ declare module "process/index" {
|
|
|
770
1296
|
* await process.deleteItem({ instanceId: "item_123" });
|
|
771
1297
|
*/
|
|
772
1298
|
deleteItem(options: ProcessDeleteItemOptions): Promise<void>;
|
|
1299
|
+
/**
|
|
1300
|
+
* Get a single process instance as admin (requires admin access)
|
|
1301
|
+
* @param options - instanceId (required)
|
|
1302
|
+
* @returns Promise containing the instance data
|
|
1303
|
+
*
|
|
1304
|
+
* @example
|
|
1305
|
+
* const process = kf.app.getProcess("LeaveRequest");
|
|
1306
|
+
* const item = await process.getAdminItem({ instanceId: "item_123" });
|
|
1307
|
+
*/
|
|
1308
|
+
getAdminItem(options: ProcessGetAdminItemOptions): Promise<ProcessItem>;
|
|
1309
|
+
/**
|
|
1310
|
+
* Update a process instance as admin (requires admin access)
|
|
1311
|
+
* @param options - instanceId, data (required)
|
|
1312
|
+
* @returns Promise containing the updated item
|
|
1313
|
+
*
|
|
1314
|
+
* @example
|
|
1315
|
+
* const process = kf.app.getProcess("LeaveRequest");
|
|
1316
|
+
* await process.updateAdminItem({ instanceId: "item_123", data: { LeaveType: "Sick" } });
|
|
1317
|
+
*/
|
|
1318
|
+
updateAdminItem(options: ProcessUpdateAdminItemOptions): Promise<ProcessItem>;
|
|
773
1319
|
/**
|
|
774
1320
|
* Open the form UI for a process instance
|
|
775
1321
|
* @param item - Process item with _id and _activity_instance_id
|
|
@@ -868,13 +1414,49 @@ declare module "process/index" {
|
|
|
868
1414
|
getProgress(options: {
|
|
869
1415
|
instanceId: string;
|
|
870
1416
|
}): Promise<any>;
|
|
1417
|
+
/**
|
|
1418
|
+
* Initialize a form with all necessary data (schema, item data, form store)
|
|
1419
|
+
* This is the recommended way to create a custom form for dataform records
|
|
1420
|
+
* It automatically handles fetching schema, item data, and initializing the form store
|
|
1421
|
+
*
|
|
1422
|
+
* @param instanceId - Optional instance ID of the dataform record. If omitted, creates a new record
|
|
1423
|
+
* @returns Promise with Form instance ready to use
|
|
1424
|
+
*
|
|
1425
|
+
* @example
|
|
1426
|
+
* // Load existing record
|
|
1427
|
+
* const dataform = kf.app.getDataform("EmpMaster");
|
|
1428
|
+
* const form = await dataform.initForm("emp_123");
|
|
1429
|
+
* const data = await form.toJSON();
|
|
1430
|
+
*
|
|
1431
|
+
* // Create new record
|
|
1432
|
+
* const form = await dataform.initForm();
|
|
1433
|
+
* await form.updateField({ firstName: "John" });
|
|
1434
|
+
*/
|
|
1435
|
+
initForm(instanceId?: string, activityInstanceId?: string): Promise<Form>;
|
|
1436
|
+
getFieldOptions(options?: ProcessFieldOptions): Promise<ProcessQueryResponse>;
|
|
1437
|
+
/**
|
|
1438
|
+
* Trigger AI document parsing on an uploaded file for a Smart Attachment field.
|
|
1439
|
+
* Matches native platform behavior: matching empty fields are auto-filled directly
|
|
1440
|
+
* into the form store (respecting field permissions) — no separate apply step needed.
|
|
1441
|
+
* Call `form.toJSON()` afterward to read the updated values.
|
|
1442
|
+
*
|
|
1443
|
+
* @example
|
|
1444
|
+
* const form = await process.initForm();
|
|
1445
|
+
* const files = await kf.client.openFilePicker({ fileExtensions: ["pdf"], maxCount: 1 });
|
|
1446
|
+
* await form.updateField({ [fieldId]: files });
|
|
1447
|
+
* await process.parseAttachment({ instanceId: form.instanceId, fieldId, file: files[0] });
|
|
1448
|
+
* const updated = await form.toJSON(); // other fields now auto-filled
|
|
1449
|
+
*/
|
|
1450
|
+
parseAttachment(options: ProcessParseAttachmentOptions): Promise<ProcessAttachmentParseResult>;
|
|
871
1451
|
}
|
|
872
1452
|
}
|
|
873
1453
|
declare module "app/index" {
|
|
874
1454
|
import { BaseSDK } from "core/index";
|
|
875
1455
|
import { Page } from "app/page";
|
|
876
1456
|
import { AppContext } from "types/internal";
|
|
1457
|
+
import { rolesObject } from "types/external";
|
|
877
1458
|
import { DecisionTable } from "app/decisiontable";
|
|
1459
|
+
import { Agent } from "app/agent";
|
|
878
1460
|
import { Dataform } from "dataform/index";
|
|
879
1461
|
import { Board } from "board/index";
|
|
880
1462
|
import { Process } from "process/index";
|
|
@@ -886,11 +1468,58 @@ declare module "app/index" {
|
|
|
886
1468
|
setVariable(key: string | object, value?: any): any;
|
|
887
1469
|
openPage(pageId: string, pageParams?: object): any;
|
|
888
1470
|
getDecisionTable(flowId: string): DecisionTable;
|
|
1471
|
+
/**
|
|
1472
|
+
* Get a published Custom Agent of this app by its id. The handle sends no request until you call one
|
|
1473
|
+
* of its methods; see {@link Agent}.
|
|
1474
|
+
*
|
|
1475
|
+
* @example
|
|
1476
|
+
* const agent = kf.app.getAgent("AgXXXXXXXXXX");
|
|
1477
|
+
* const { ExecutionId } = await agent.execute({ inputData: { request: "Two desks" } });
|
|
1478
|
+
*/
|
|
1479
|
+
getAgent(agentId: string): Agent;
|
|
889
1480
|
getDataform(flowId: string): Dataform;
|
|
890
1481
|
getBoard(flowId: string): Board;
|
|
891
1482
|
getProcess(flowId: string): Process;
|
|
1483
|
+
/**
|
|
1484
|
+
* List the app's roles and which of them the current user is a member of.
|
|
1485
|
+
*
|
|
1486
|
+
* Only available in a Development account - use this to build a role
|
|
1487
|
+
* picker UI inside the component, then pass the chosen role to
|
|
1488
|
+
* {@link switchRole}.
|
|
1489
|
+
*
|
|
1490
|
+
* @returns A promise that resolves with `{ roles, currentRoles }` - the
|
|
1491
|
+
* full list of app roles and the subset the current user belongs to.
|
|
1492
|
+
*
|
|
1493
|
+
* @example
|
|
1494
|
+
* const { roles, currentRoles } = await kf.app.getRoles();
|
|
1495
|
+
*/
|
|
1496
|
+
getRoles(): Promise<{
|
|
1497
|
+
roles: rolesObject[];
|
|
1498
|
+
currentRoles: rolesObject[];
|
|
1499
|
+
}>;
|
|
1500
|
+
/**
|
|
1501
|
+
* Switch the current user's active role in a Development account.
|
|
1502
|
+
*
|
|
1503
|
+
* This performs a real role change - it removes the user from their
|
|
1504
|
+
* current role(s) and adds them to the target role. The platform's app
|
|
1505
|
+
* shell (top nav, other widgets) picks up the new role on its own; no
|
|
1506
|
+
* page reload happens. Only available in a Development account.
|
|
1507
|
+
*
|
|
1508
|
+
* @param args - Either `roleId` or `roleName` identifying the target role
|
|
1509
|
+
* (use the values returned by {@link getRoles}).
|
|
1510
|
+
* @returns A promise that resolves with the switched-to role.
|
|
1511
|
+
*
|
|
1512
|
+
* @example
|
|
1513
|
+
* const { roles } = await kf.app.getRoles();
|
|
1514
|
+
* await kf.app.switchRole({ roleId: roles[1]._id });
|
|
1515
|
+
*/
|
|
1516
|
+
switchRole(args: {
|
|
1517
|
+
roleId?: string;
|
|
1518
|
+
roleName?: string;
|
|
1519
|
+
}): Promise<rolesObject>;
|
|
892
1520
|
}
|
|
893
1521
|
export * from "app/component";
|
|
1522
|
+
export { Agent };
|
|
894
1523
|
export { Page };
|
|
895
1524
|
export * from "app/popup";
|
|
896
1525
|
}
|
|
@@ -916,42 +1545,6 @@ declare module "index" {
|
|
|
916
1545
|
const _default: CustomComponentSDK;
|
|
917
1546
|
export default _default;
|
|
918
1547
|
}
|
|
919
|
-
declare module "form/index" {
|
|
920
|
-
import { BaseSDK } from "core/index";
|
|
921
|
-
export class Form extends BaseSDK {
|
|
922
|
-
private instanceId;
|
|
923
|
-
type: string;
|
|
924
|
-
constructor(instanceId: string);
|
|
925
|
-
toJSON(): any;
|
|
926
|
-
getField(fieldId: string): any;
|
|
927
|
-
updateField(args: object): any;
|
|
928
|
-
getTable(tableId: string): Table;
|
|
929
|
-
}
|
|
930
|
-
class Table extends BaseSDK {
|
|
931
|
-
private tableId;
|
|
932
|
-
private instanceId;
|
|
933
|
-
constructor(instanceId: string, tableId: string);
|
|
934
|
-
toJSON(): any;
|
|
935
|
-
getSelectedRows(): any;
|
|
936
|
-
getRows(): TableForm[];
|
|
937
|
-
getRow(rowId: string): TableForm;
|
|
938
|
-
addRow(rowObject: object): any;
|
|
939
|
-
addRows(rows: object[]): any;
|
|
940
|
-
deleteRow(rowId: string): any;
|
|
941
|
-
deleteRows(rows: string[]): any;
|
|
942
|
-
}
|
|
943
|
-
export class TableForm extends BaseSDK {
|
|
944
|
-
private instanceId;
|
|
945
|
-
private tableId;
|
|
946
|
-
private rowId;
|
|
947
|
-
type: string;
|
|
948
|
-
constructor(instanceId: string, tableId: string, rowId: string);
|
|
949
|
-
getParent(): Form;
|
|
950
|
-
toJSON(): any;
|
|
951
|
-
getField(fieldId: string): any;
|
|
952
|
-
updateField(args: object): any;
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
1548
|
declare module "window/NDEFReader" {
|
|
956
1549
|
import { BaseSDK } from "core/index";
|
|
957
1550
|
export class NDEFReader extends BaseSDK {
|