@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/lowcode.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,6 +141,21 @@ 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
|
}
|
|
@@ -121,18 +164,27 @@ declare module "core/index" {
|
|
|
121
164
|
declare module "form/index" {
|
|
122
165
|
import { BaseSDK } from "core/index";
|
|
123
166
|
export class Form extends BaseSDK {
|
|
124
|
-
private
|
|
167
|
+
private storeId;
|
|
168
|
+
private flowId;
|
|
125
169
|
type: string;
|
|
126
|
-
|
|
170
|
+
instanceId: string;
|
|
171
|
+
activityInstanceId?: string;
|
|
172
|
+
constructor(storeId: string, flowId: string, instanceId: string, activityInstanceId?: string);
|
|
127
173
|
toJSON(): any;
|
|
128
174
|
getField(fieldId: string): any;
|
|
129
175
|
updateField(args: object): any;
|
|
176
|
+
getValidationErrors(): any;
|
|
177
|
+
getFormConfiguration(): any;
|
|
178
|
+
getFieldState(): any;
|
|
130
179
|
getTable(tableId: string): Table;
|
|
131
180
|
}
|
|
132
181
|
class Table extends BaseSDK {
|
|
133
|
-
private
|
|
182
|
+
private storeId;
|
|
183
|
+
private flowId;
|
|
134
184
|
private instanceId;
|
|
135
|
-
|
|
185
|
+
private tableId;
|
|
186
|
+
private activityInstanceId?;
|
|
187
|
+
constructor(storeId: string, flowId: string, instanceId: string, tableId: string, activityInstanceId?: string);
|
|
136
188
|
toJSON(): any;
|
|
137
189
|
getSelectedRows(): any;
|
|
138
190
|
getRows(): TableForm[];
|
|
@@ -143,132 +195,20 @@ declare module "form/index" {
|
|
|
143
195
|
deleteRows(rows: string[]): any;
|
|
144
196
|
}
|
|
145
197
|
export class TableForm extends BaseSDK {
|
|
198
|
+
private storeId;
|
|
199
|
+
private flowId;
|
|
146
200
|
private instanceId;
|
|
147
201
|
private tableId;
|
|
148
202
|
private rowId;
|
|
203
|
+
private activityInstanceId?;
|
|
149
204
|
type: string;
|
|
150
|
-
constructor(instanceId: string, tableId: string, rowId: string);
|
|
205
|
+
constructor(storeId: string, flowId: string, instanceId: string, tableId: string, rowId: string, activityInstanceId?: string);
|
|
151
206
|
getParent(): Form;
|
|
152
207
|
toJSON(): any;
|
|
153
208
|
getField(fieldId: string): any;
|
|
154
209
|
updateField(args: object): any;
|
|
155
210
|
}
|
|
156
211
|
}
|
|
157
|
-
declare module "utils/client" {
|
|
158
|
-
import { BaseSDK } from "core/index";
|
|
159
|
-
export class Client extends BaseSDK {
|
|
160
|
-
/**
|
|
161
|
-
* Display an info message toast in the platform.
|
|
162
|
-
*
|
|
163
|
-
* @param message - The message to display. Accepts a string or object (serialized to JSON).
|
|
164
|
-
* @returns A promise that resolves when the message is shown.
|
|
165
|
-
*
|
|
166
|
-
* @example
|
|
167
|
-
* await kf.client.showInfo("Record saved successfully");
|
|
168
|
-
*/
|
|
169
|
-
showInfo(message: string | object): any;
|
|
170
|
-
/**
|
|
171
|
-
* Display a confirmation dialog and wait for the user's response.
|
|
172
|
-
*
|
|
173
|
-
* @param args - Dialog configuration.
|
|
174
|
-
* @param args.title - Dialog title.
|
|
175
|
-
* @param args.content - Body text of the dialog.
|
|
176
|
-
* @param args.okText - Label for the confirm button (default: "Ok").
|
|
177
|
-
* @param args.cancelText - Label for the cancel button (default: "Cancel").
|
|
178
|
-
* @returns A promise that resolves with `{ action: "OK" }` or `{ action: "CANCEL" }`.
|
|
179
|
-
*
|
|
180
|
-
* @example
|
|
181
|
-
* const { action } = await kf.client.showConfirm({
|
|
182
|
-
* title: "Delete record?",
|
|
183
|
-
* content: "This cannot be undone.",
|
|
184
|
-
* okText: "Delete",
|
|
185
|
-
* cancelText: "Cancel",
|
|
186
|
-
* });
|
|
187
|
-
* if (action === "OK") { ... }
|
|
188
|
-
*/
|
|
189
|
-
showConfirm(args: {
|
|
190
|
-
title: string;
|
|
191
|
-
content: string;
|
|
192
|
-
okText: string;
|
|
193
|
-
cancelText: string;
|
|
194
|
-
}): any;
|
|
195
|
-
/**
|
|
196
|
-
* Navigate the platform to the given URL.
|
|
197
|
-
*
|
|
198
|
-
* @param url - The URL to navigate to.
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* kf.client.redirect("https://example.com");
|
|
202
|
-
*/
|
|
203
|
-
redirect(url: string): any;
|
|
204
|
-
/**
|
|
205
|
-
* Resolve a Kissflow image field value to a base64 data URL.
|
|
206
|
-
*
|
|
207
|
-
* Custom components (iframes) cannot load Kissflow-hosted images directly due to
|
|
208
|
-
* CORS restrictions and 302 redirects to signed S3 URLs. This method fetches the
|
|
209
|
-
* image in the parent window (which has the required session cookies) and returns
|
|
210
|
-
* a self-contained `data:image/...;base64,...` URL that can be used as `<img src>`
|
|
211
|
-
* without any CORS issues.
|
|
212
|
-
*
|
|
213
|
-
* @param imageValue - The image field value must contain a `key` property and
|
|
214
|
-
* optionally a `photos` array. Uses `photos[1]` (preview resolution) when available,
|
|
215
|
-
* falls back to `key`.
|
|
216
|
-
* @returns A promise that resolves with the base64 data URL string.
|
|
217
|
-
*
|
|
218
|
-
* @example
|
|
219
|
-
* const dataUrl = await kf.client.getImageUrl(imageFieldValue);
|
|
220
|
-
* document.querySelector("#avatar").src = dataUrl;
|
|
221
|
-
*/
|
|
222
|
-
getImageUrl(imageValue: Record<string, unknown>): any;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
declare module "utils/formatter" {
|
|
226
|
-
import { BaseSDK } from "core/index";
|
|
227
|
-
export class Formatter extends BaseSDK {
|
|
228
|
-
toDate(date: string): any;
|
|
229
|
-
toDateTime(date: string): any;
|
|
230
|
-
toNumber(value: string): any;
|
|
231
|
-
toCurrency(value: string, currencyCode: string): any;
|
|
232
|
-
toBoolean(value: string): any;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
declare module "utils/validation" {
|
|
236
|
-
/**
|
|
237
|
-
* Validation utilities for SDK methods
|
|
238
|
-
*/
|
|
239
|
-
/**
|
|
240
|
-
* Throws error if value is falsy
|
|
241
|
-
*/
|
|
242
|
-
export function requireField(value: any, fieldName: string): void;
|
|
243
|
-
/**
|
|
244
|
-
* Returns a rejected promise if value is falsy, null otherwise
|
|
245
|
-
* Use for async validation in SDK methods
|
|
246
|
-
*/
|
|
247
|
-
export function requireFieldAsync(value: any, fieldName: string): Promise<never> | null;
|
|
248
|
-
/**
|
|
249
|
-
* Returns a rejected promise if any of the values are falsy
|
|
250
|
-
* Use for validating multiple required fields
|
|
251
|
-
*/
|
|
252
|
-
export function requireFieldsAsync(fields: Array<{
|
|
253
|
-
value: any;
|
|
254
|
-
name: string;
|
|
255
|
-
}>): Promise<never> | null;
|
|
256
|
-
}
|
|
257
|
-
declare module "utils/index" {
|
|
258
|
-
export * from "utils/client";
|
|
259
|
-
export * from "utils/formatter";
|
|
260
|
-
export * from "utils/validation";
|
|
261
|
-
export const isObject: (value: any) => boolean;
|
|
262
|
-
}
|
|
263
|
-
declare module "core/proxy" {
|
|
264
|
-
export class CreateProxy {
|
|
265
|
-
path: string[];
|
|
266
|
-
parent: object;
|
|
267
|
-
constructor(parent: object, target?: {}, path?: any[]);
|
|
268
|
-
get(target: object, property: string): any;
|
|
269
|
-
set(target: object, property: string, value: any, reciever: any): any;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
212
|
declare module "types/external" {
|
|
273
213
|
export type QueryResponse = {
|
|
274
214
|
items: any[];
|
|
@@ -326,6 +266,17 @@ declare module "types/external" {
|
|
|
326
266
|
_id: string;
|
|
327
267
|
_activity_instance_id: string;
|
|
328
268
|
};
|
|
269
|
+
export type GeolocationValue = {
|
|
270
|
+
Address?: string;
|
|
271
|
+
Latitude: string;
|
|
272
|
+
Longitude: string;
|
|
273
|
+
City?: string;
|
|
274
|
+
State?: string;
|
|
275
|
+
Country?: string;
|
|
276
|
+
ZipCode?: string;
|
|
277
|
+
Area?: string;
|
|
278
|
+
PlaceId?: string;
|
|
279
|
+
};
|
|
329
280
|
export type ProcessMyItemsOptions = BaseQueryOptions & {
|
|
330
281
|
status?: "draft" | "inprogress" | "completed" | "withdrawn" | "rejected" | "all";
|
|
331
282
|
payload?: ProcessPayloadOptions;
|
|
@@ -344,6 +295,7 @@ declare module "types/external" {
|
|
|
344
295
|
export type ProcessQueryResponse = QueryResponse;
|
|
345
296
|
export type ProcessGetItemOptions = {
|
|
346
297
|
instanceId: string;
|
|
298
|
+
activityInstanceId: string;
|
|
347
299
|
};
|
|
348
300
|
export type ProcessCreateItemOptions = {
|
|
349
301
|
data?: object;
|
|
@@ -356,6 +308,13 @@ declare module "types/external" {
|
|
|
356
308
|
export type ProcessDeleteItemOptions = {
|
|
357
309
|
instanceId: string;
|
|
358
310
|
};
|
|
311
|
+
export type ProcessGetAdminItemOptions = {
|
|
312
|
+
instanceId: string;
|
|
313
|
+
};
|
|
314
|
+
export type ProcessUpdateAdminItemOptions = {
|
|
315
|
+
instanceId: string;
|
|
316
|
+
data: object;
|
|
317
|
+
};
|
|
359
318
|
export type ProcessSubmitItemOptions = {
|
|
360
319
|
instanceId: string;
|
|
361
320
|
activityInstanceId: string;
|
|
@@ -398,6 +357,32 @@ declare module "types/external" {
|
|
|
398
357
|
export type ProcessDiscardItemOptions = {
|
|
399
358
|
instanceId: string;
|
|
400
359
|
};
|
|
360
|
+
export type ProcessFieldOptions = {
|
|
361
|
+
instanceId: string;
|
|
362
|
+
activityInstanceId: string;
|
|
363
|
+
fieldId: string;
|
|
364
|
+
/** Skip the server-side model lookup by supplying the field's type directly. */
|
|
365
|
+
fieldType?: string;
|
|
366
|
+
tableId?: string;
|
|
367
|
+
tableRowId?: string;
|
|
368
|
+
};
|
|
369
|
+
export type ProcessAttachmentFile = {
|
|
370
|
+
id: string;
|
|
371
|
+
name: string;
|
|
372
|
+
key: string;
|
|
373
|
+
size?: number;
|
|
374
|
+
fileExtension?: string;
|
|
375
|
+
};
|
|
376
|
+
export type ProcessParseAttachmentOptions = {
|
|
377
|
+
instanceId: string;
|
|
378
|
+
activityInstanceId: string;
|
|
379
|
+
fieldId: string;
|
|
380
|
+
file: ProcessAttachmentFile;
|
|
381
|
+
};
|
|
382
|
+
export type ProcessAttachmentParseResult = {
|
|
383
|
+
appliedFields: string[];
|
|
384
|
+
suggestedBy: string;
|
|
385
|
+
};
|
|
401
386
|
export type FetchOptions = {
|
|
402
387
|
method?: string;
|
|
403
388
|
body?: string | object;
|
|
@@ -433,6 +418,14 @@ declare module "types/external" {
|
|
|
433
418
|
data?: object;
|
|
434
419
|
viewId?: string;
|
|
435
420
|
};
|
|
421
|
+
export type DataformFieldOptions = {
|
|
422
|
+
instanceId: string;
|
|
423
|
+
fieldId: string;
|
|
424
|
+
/** Skip the server-side model lookup by supplying the field's type directly. */
|
|
425
|
+
fieldType?: string;
|
|
426
|
+
tableId?: string;
|
|
427
|
+
tableRowId?: string;
|
|
428
|
+
};
|
|
436
429
|
export type BoardGetItemsOptions = BaseQueryOptions & {
|
|
437
430
|
viewId?: string;
|
|
438
431
|
payload?: PayloadOptions;
|
|
@@ -458,11 +451,117 @@ declare module "types/external" {
|
|
|
458
451
|
export type BoardDiscardItemOptions = {
|
|
459
452
|
instanceId: string;
|
|
460
453
|
};
|
|
454
|
+
export type BoardFieldOptions = {
|
|
455
|
+
instanceId: string;
|
|
456
|
+
fieldId: string;
|
|
457
|
+
/** Skip the server-side model lookup by supplying the field's type directly. */
|
|
458
|
+
fieldType?: string;
|
|
459
|
+
tableId?: string;
|
|
460
|
+
tableRowId?: string;
|
|
461
|
+
};
|
|
462
|
+
export type AgentInputDataType = "Text" | "Number" | "Boolean" | "Attachment";
|
|
463
|
+
export type AgentOutputDataType = "string" | "number" | "boolean";
|
|
464
|
+
export type AgentInputField = {
|
|
465
|
+
Key: string;
|
|
466
|
+
Name: string;
|
|
467
|
+
DataType: AgentInputDataType;
|
|
468
|
+
Required: boolean;
|
|
469
|
+
Description?: string;
|
|
470
|
+
};
|
|
471
|
+
export type AgentOutputField = {
|
|
472
|
+
Key: string;
|
|
473
|
+
Name: string;
|
|
474
|
+
DataType: AgentOutputDataType;
|
|
475
|
+
Description?: string;
|
|
476
|
+
};
|
|
477
|
+
/**
|
|
478
|
+
* A file for an `Attachment` input: exactly one of `Key` (a Kissflow attachment) or `Url` (https).
|
|
479
|
+
* A file from `openFilePicker` or `uploadFile` has lowercase keys: pass
|
|
480
|
+
* `{ Key: file.key, FileName: file.name, Size: file.size }`.
|
|
481
|
+
*/
|
|
482
|
+
export type AgentAttachmentValue = {
|
|
483
|
+
Key: string;
|
|
484
|
+
Url?: never;
|
|
485
|
+
FileName: string;
|
|
486
|
+
Size?: number;
|
|
487
|
+
ContentType?: string;
|
|
488
|
+
} | {
|
|
489
|
+
Url: string;
|
|
490
|
+
Key?: never;
|
|
491
|
+
FileName: string;
|
|
492
|
+
Size?: number;
|
|
493
|
+
ContentType?: string;
|
|
494
|
+
};
|
|
495
|
+
export type AgentInputValue = string | number | boolean | AgentAttachmentValue;
|
|
496
|
+
/** The Agent's published invocation contract. */
|
|
497
|
+
export type AgentContract = {
|
|
498
|
+
AgentId: string;
|
|
499
|
+
Definition: {
|
|
500
|
+
Name: string;
|
|
501
|
+
Description?: string;
|
|
502
|
+
Icon?: Record<string, unknown>;
|
|
503
|
+
Inputs: AgentInputField[];
|
|
504
|
+
Outputs: AgentOutputField[];
|
|
505
|
+
MaxOutputItems: number;
|
|
506
|
+
};
|
|
507
|
+
Readiness: {
|
|
508
|
+
Ready: boolean;
|
|
509
|
+
Issues: Array<{
|
|
510
|
+
Code: string;
|
|
511
|
+
Path: string;
|
|
512
|
+
Message: string;
|
|
513
|
+
}>;
|
|
514
|
+
};
|
|
515
|
+
};
|
|
516
|
+
export type AgentExecuteOptions = {
|
|
517
|
+
/** Values keyed by input `Key`, as declared in the contract. */
|
|
518
|
+
inputData: Record<string, AgentInputValue>;
|
|
519
|
+
};
|
|
520
|
+
/** More statuses may be added; treat any status other than `Completed` or `Failed` as still in progress. */
|
|
521
|
+
export type AgentExecutionStatus = "Queued" | "NotStarted" | "Running" | "Completed" | "Failed" | (string & {});
|
|
522
|
+
/** What `execute` resolves with once the run is accepted, before it has finished. */
|
|
523
|
+
export type AgentExecutionAccepted = {
|
|
524
|
+
ExecutionId: string;
|
|
525
|
+
Status: AgentExecutionStatus;
|
|
526
|
+
};
|
|
527
|
+
export type AgentExecution = {
|
|
528
|
+
ExecutionId: string;
|
|
529
|
+
Status: AgentExecutionStatus;
|
|
530
|
+
Stage?: string;
|
|
531
|
+
/** Present on `Completed`: one row per item, keyed by output `Key`. */
|
|
532
|
+
Output?: {
|
|
533
|
+
items: Array<Record<string, string | number | boolean>>;
|
|
534
|
+
};
|
|
535
|
+
/** Present on `Failed`. */
|
|
536
|
+
Error?: {
|
|
537
|
+
Code: string;
|
|
538
|
+
Retryable: boolean;
|
|
539
|
+
Details?: unknown;
|
|
540
|
+
};
|
|
541
|
+
Warnings?: Array<Record<string, unknown>>;
|
|
542
|
+
CreatedAt?: string;
|
|
543
|
+
StartedAt?: string;
|
|
544
|
+
CompletedAt?: string;
|
|
545
|
+
};
|
|
546
|
+
/**
|
|
547
|
+
* How an Agent call fails: `error` is the message text and `errorCode` either the platform code
|
|
548
|
+
* (`KISSFLOW_ERROR_…`) or an `AGENT_…` code, including `AGENT_HOST_TIMEOUT`, `AGENT_REQUEST_NOT_SENT`,
|
|
549
|
+
* `AGENT_EXECUTE_OUTCOME_UNKNOWN` (a run may have started), `AGENT_EXECUTE_NOT_SENT` (no run started),
|
|
550
|
+
* `AGENT_HOST_UNSUPPORTED`, `AGENT_WATCH_INVALID_EVENT`, `AGENT_OBSERVATION_STOPPED`, and from the host
|
|
551
|
+
* `AGENT_READ_TIMEOUT` and `AGENT_OFFLINE`. The list may grow; fall back to `error` for an unknown code.
|
|
552
|
+
* There is no `message`: read `error` for the text.
|
|
553
|
+
*/
|
|
554
|
+
export type AgentError = {
|
|
555
|
+
isError: true;
|
|
556
|
+
error?: string;
|
|
557
|
+
errorCode?: string;
|
|
558
|
+
};
|
|
461
559
|
}
|
|
462
560
|
declare module "types/internal" {
|
|
463
561
|
import { userObject, accountObject, environmentObject } from "types/external";
|
|
464
562
|
export interface SDKContext {
|
|
465
563
|
formInstanceId: string;
|
|
564
|
+
flowId: string;
|
|
466
565
|
tableId: string;
|
|
467
566
|
tableRowId: string;
|
|
468
567
|
componentId: string;
|
|
@@ -490,10 +589,262 @@ declare module "types/internal" {
|
|
|
490
589
|
}
|
|
491
590
|
export interface PageContext {
|
|
492
591
|
pageId: string;
|
|
592
|
+
initialRoute?: string;
|
|
493
593
|
}
|
|
494
594
|
export interface PopupContext {
|
|
495
595
|
popupId?: string;
|
|
496
596
|
}
|
|
597
|
+
export interface FilePickerOptions {
|
|
598
|
+
fileExtensions?: string[];
|
|
599
|
+
maxSize?: number;
|
|
600
|
+
maxCount?: number;
|
|
601
|
+
imageProps?: {
|
|
602
|
+
sizes?: Array<[number, number]>;
|
|
603
|
+
crop?: boolean;
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
export interface ScannerOptions {
|
|
607
|
+
/** Allow decoding from an uploaded image instead of the camera. */
|
|
608
|
+
localFileScan?: boolean;
|
|
609
|
+
}
|
|
610
|
+
/** Minimal shape of a browser File/Blob object, avoids requiring the DOM lib. */
|
|
611
|
+
export interface UploadableFile {
|
|
612
|
+
name: string;
|
|
613
|
+
size?: number;
|
|
614
|
+
type?: string;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
declare module "utils/client" {
|
|
618
|
+
import { BaseSDK } from "core/index";
|
|
619
|
+
import { GeolocationValue } from "types/external";
|
|
620
|
+
import { FilePickerOptions, ScannerOptions, UploadableFile } from "types/internal";
|
|
621
|
+
export class Client extends BaseSDK {
|
|
622
|
+
/**
|
|
623
|
+
* Display an info message toast in the platform.
|
|
624
|
+
*
|
|
625
|
+
* @param message - The message to display. Accepts a string or object (serialized to JSON).
|
|
626
|
+
* @returns A promise that resolves when the message is shown.
|
|
627
|
+
*
|
|
628
|
+
* @example
|
|
629
|
+
* await kf.client.showInfo("Record saved successfully");
|
|
630
|
+
*/
|
|
631
|
+
showInfo(message: string | object): any;
|
|
632
|
+
/**
|
|
633
|
+
* Display a confirmation dialog and wait for the user's response.
|
|
634
|
+
*
|
|
635
|
+
* @param args - Dialog configuration.
|
|
636
|
+
* @param args.title - Dialog title.
|
|
637
|
+
* @param args.content - Body text of the dialog.
|
|
638
|
+
* @param args.okText - Label for the confirm button (default: "Ok").
|
|
639
|
+
* @param args.cancelText - Label for the cancel button (default: "Cancel").
|
|
640
|
+
* @returns A promise that resolves with `{ action: "OK" }` or `{ action: "CANCEL" }`.
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
* const { action } = await kf.client.showConfirm({
|
|
644
|
+
* title: "Delete record?",
|
|
645
|
+
* content: "This cannot be undone.",
|
|
646
|
+
* okText: "Delete",
|
|
647
|
+
* cancelText: "Cancel",
|
|
648
|
+
* });
|
|
649
|
+
* if (action === "OK") { ... }
|
|
650
|
+
*/
|
|
651
|
+
showConfirm(args: {
|
|
652
|
+
title: string;
|
|
653
|
+
content: string;
|
|
654
|
+
okText: string;
|
|
655
|
+
cancelText: string;
|
|
656
|
+
}): any;
|
|
657
|
+
/**
|
|
658
|
+
* Navigate the platform to the given URL.
|
|
659
|
+
*
|
|
660
|
+
* @param url - The URL to navigate to.
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* kf.client.redirect("https://example.com");
|
|
664
|
+
*/
|
|
665
|
+
redirect(url: string): any;
|
|
666
|
+
/**
|
|
667
|
+
* Resolve a Kissflow image field value to a base64 data URL.
|
|
668
|
+
*
|
|
669
|
+
* Custom components (iframes) cannot load Kissflow-hosted images directly due to
|
|
670
|
+
* CORS restrictions and 302 redirects to signed S3 URLs. This method fetches the
|
|
671
|
+
* image in the parent window (which has the required session cookies) and returns
|
|
672
|
+
* a self-contained `data:image/...;base64,...` URL that can be used as `<img src>`
|
|
673
|
+
* without any CORS issues.
|
|
674
|
+
*
|
|
675
|
+
* @param imageValue - The image field value must contain a `key` property and
|
|
676
|
+
* optionally a `photos` array. Uses `photos[1]` (preview resolution) when available,
|
|
677
|
+
* falls back to `key`.
|
|
678
|
+
* @returns A promise that resolves with the base64 data URL string.
|
|
679
|
+
*
|
|
680
|
+
* @example
|
|
681
|
+
* const dataUrl = await kf.client.getImageUrl(imageFieldValue);
|
|
682
|
+
* document.querySelector("#avatar").src = dataUrl;
|
|
683
|
+
*/
|
|
684
|
+
getImageUrl(imageValue: Record<string, unknown>): any;
|
|
685
|
+
/**
|
|
686
|
+
* Open the platform's file picker, upload the selected file(s), and resolve
|
|
687
|
+
* with their metadata.
|
|
688
|
+
*
|
|
689
|
+
* Custom components (iframes) cannot access the platform's authenticated upload
|
|
690
|
+
* endpoints directly. This method opens the file picker in the parent window
|
|
691
|
+
* (which has the required session), runs the full select → upload flow, and
|
|
692
|
+
* resolves once all uploads settle with an array of the uploaded files'
|
|
693
|
+
* metadata (each including `key`, `name`, `size`, `photos`, etc. — the same
|
|
694
|
+
* shape consumed by `getImageUrl`).
|
|
695
|
+
*
|
|
696
|
+
* Always resolves with an array — a single-element array for single-file
|
|
697
|
+
* pickers (e.g. `maxCount: 1` for `Image`), one entry per uploaded file for
|
|
698
|
+
* multi-file pickers (e.g. `Attachment`). Resolves with `[]` if the user closes
|
|
699
|
+
* the picker without completing any upload.
|
|
700
|
+
*
|
|
701
|
+
* @param options - File picker configuration (e.g. `fileExtensions`, `maxSize`,
|
|
702
|
+
* `maxCount`, `imageProps`).
|
|
703
|
+
* @returns A promise that resolves with an array of uploaded file metadata
|
|
704
|
+
* objects (empty if the picker was closed without uploading anything).
|
|
705
|
+
*
|
|
706
|
+
* @example
|
|
707
|
+
* const files = await kf.client.openFilePicker({ fileExtensions: ["JPG", "PNG"] });
|
|
708
|
+
* if (files.length) onChange(files[0]); // single-file consumer (Image)
|
|
709
|
+
*
|
|
710
|
+
* @example
|
|
711
|
+
* const files = await kf.client.openFilePicker({ maxCount: 10 });
|
|
712
|
+
* if (files.length) onChange([...existing, ...files]); // multi-file consumer (Attachment)
|
|
713
|
+
*/
|
|
714
|
+
openFilePicker(options: FilePickerOptions): any;
|
|
715
|
+
/**
|
|
716
|
+
* Open the platform's barcode/QR scanner and resolve with the decoded text.
|
|
717
|
+
*
|
|
718
|
+
* The scanner UI (camera stream + decoding) runs in the parent window, which
|
|
719
|
+
* owns the camera permission — the iframe itself never accesses the camera.
|
|
720
|
+
* Camera-permission prompts and denials are handled inside the scanner UI;
|
|
721
|
+
* they are not surfaced as errors here.
|
|
722
|
+
*
|
|
723
|
+
* Resolves with `null` if the user closes the scanner without a successful
|
|
724
|
+
* scan (including the scanner's own inactivity timeout).
|
|
725
|
+
*
|
|
726
|
+
* Note: currently supported in web custom app UIs; the mobile (PWA) custom
|
|
727
|
+
* UI does not host the scanner portal yet.
|
|
728
|
+
*
|
|
729
|
+
* @param options - Scanner configuration (e.g. `localFileScan` to allow
|
|
730
|
+
* decoding from an uploaded image instead of the camera).
|
|
731
|
+
* @returns A promise that resolves with the decoded string, or `null` if the
|
|
732
|
+
* scanner was closed without scanning.
|
|
733
|
+
*
|
|
734
|
+
* @example
|
|
735
|
+
* const code = await kf.client.openScanner({ localFileScan: true });
|
|
736
|
+
* if (code) onChange(code);
|
|
737
|
+
*/
|
|
738
|
+
openScanner(options?: ScannerOptions): any;
|
|
739
|
+
/**
|
|
740
|
+
* Open the platform's native Geolocation map picker (search, current-location
|
|
741
|
+
* detection, marker drag, reverse-geocoding) in a modal over the custom
|
|
742
|
+
* form/component. Runs in the parent window, which owns the Google Maps API
|
|
743
|
+
* key — the iframe itself never needs one.
|
|
744
|
+
*
|
|
745
|
+
* Resolves with `null` if the user closes the picker without selecting a
|
|
746
|
+
* location.
|
|
747
|
+
*
|
|
748
|
+
* @param value - Optional current geolocation value to pre-select on the map.
|
|
749
|
+
* @returns A promise that resolves with the picked location object, or
|
|
750
|
+
* `null` if the picker was closed without a selection.
|
|
751
|
+
*
|
|
752
|
+
* @example
|
|
753
|
+
* const location = await kf.client.pickLocation();
|
|
754
|
+
* if (location) onChange(location);
|
|
755
|
+
*/
|
|
756
|
+
pickLocation(value?: GeolocationValue): any;
|
|
757
|
+
/**
|
|
758
|
+
* Upload a File object to Kissflow's S3 storage and resolve with its metadata.
|
|
759
|
+
*
|
|
760
|
+
* Use this when you have a File/Blob already in memory (e.g. a canvas drawing
|
|
761
|
+
* converted to a PNG blob) and need to upload it without opening a file picker UI.
|
|
762
|
+
* The platform runs the upload in the parent window (which has the required session)
|
|
763
|
+
* and resolves with the uploaded file's `{ key, name, ... }` metadata — the same
|
|
764
|
+
* shape returned by `openFilePicker`.
|
|
765
|
+
*
|
|
766
|
+
* Resolves with `null` if the upload fails.
|
|
767
|
+
*
|
|
768
|
+
* @param file - The File or Blob to upload.
|
|
769
|
+
* @param fileName - Optional file name override (defaults to `file.name`).
|
|
770
|
+
* @returns A promise that resolves with the uploaded file metadata, or `null` on failure.
|
|
771
|
+
*
|
|
772
|
+
* @example
|
|
773
|
+
* const blob = await new Promise<Blob>(res => canvas.toBlob(res, 'image/png'));
|
|
774
|
+
* const file = new File([blob], 'signature.png', { type: 'image/png' });
|
|
775
|
+
* const result = await kf.client.uploadFile(file);
|
|
776
|
+
* if (result) onChange(result);
|
|
777
|
+
*/
|
|
778
|
+
uploadFile(file: UploadableFile, fileName?: string): any;
|
|
779
|
+
/**
|
|
780
|
+
* Open the platform's file preview (lightbox) for one or more files.
|
|
781
|
+
*
|
|
782
|
+
* `files` always accepts an array — pass a single-element array for fields like
|
|
783
|
+
* `Image`, or the full list for multi-file fields like `Attachment`. The host's
|
|
784
|
+
* preview UI natively renders next/prev navigation across the array; the SDK
|
|
785
|
+
* just passes the file list through, no extra navigation surface is needed here.
|
|
786
|
+
*
|
|
787
|
+
* @param args - Preview configuration.
|
|
788
|
+
* @param args.files - Array of file metadata objects to preview.
|
|
789
|
+
* @param args.indexOfFile - Index of the file to open the preview on (default: 0).
|
|
790
|
+
* @returns A promise that resolves once the user closes the preview.
|
|
791
|
+
*
|
|
792
|
+
* @example
|
|
793
|
+
* await kf.client.openFilePreview({ files: [imageFieldValue] });
|
|
794
|
+
* await kf.client.openFilePreview({ files: attachmentFieldValue, indexOfFile: 2 });
|
|
795
|
+
*/
|
|
796
|
+
openFilePreview(args: {
|
|
797
|
+
files: Record<string, unknown>[];
|
|
798
|
+
indexOfFile?: number;
|
|
799
|
+
}): any;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
declare module "utils/formatter" {
|
|
803
|
+
import { BaseSDK } from "core/index";
|
|
804
|
+
export class Formatter extends BaseSDK {
|
|
805
|
+
toDate(date: string): any;
|
|
806
|
+
toDateTime(date: string): any;
|
|
807
|
+
toNumber(value: string): any;
|
|
808
|
+
toCurrency(value: string, currencyCode: string): any;
|
|
809
|
+
toBoolean(value: string): any;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
declare module "utils/validation" {
|
|
813
|
+
/**
|
|
814
|
+
* Validation utilities for SDK methods
|
|
815
|
+
*/
|
|
816
|
+
/**
|
|
817
|
+
* Throws error if value is falsy
|
|
818
|
+
*/
|
|
819
|
+
export function requireField(value: any, fieldName: string): void;
|
|
820
|
+
/**
|
|
821
|
+
* Returns a rejected promise if value is falsy, null otherwise
|
|
822
|
+
* Use for async validation in SDK methods
|
|
823
|
+
*/
|
|
824
|
+
export function requireFieldAsync(value: any, fieldName: string): Promise<never> | null;
|
|
825
|
+
/**
|
|
826
|
+
* Returns a rejected promise if any of the values are falsy
|
|
827
|
+
* Use for validating multiple required fields
|
|
828
|
+
*/
|
|
829
|
+
export function requireFieldsAsync(fields: Array<{
|
|
830
|
+
value: any;
|
|
831
|
+
name: string;
|
|
832
|
+
}>): Promise<never> | null;
|
|
833
|
+
}
|
|
834
|
+
declare module "utils/index" {
|
|
835
|
+
export * from "utils/client";
|
|
836
|
+
export * from "utils/formatter";
|
|
837
|
+
export * from "utils/validation";
|
|
838
|
+
export const isObject: (value: any) => boolean;
|
|
839
|
+
}
|
|
840
|
+
declare module "core/proxy" {
|
|
841
|
+
export class CreateProxy {
|
|
842
|
+
path: string[];
|
|
843
|
+
parent: object;
|
|
844
|
+
constructor(parent: object, target?: {}, path?: any[]);
|
|
845
|
+
get(target: object, property: string): any;
|
|
846
|
+
set(target: object, property: string, value: any, reciever: any): any;
|
|
847
|
+
}
|
|
497
848
|
}
|
|
498
849
|
declare module "app/component" {
|
|
499
850
|
import { BaseSDK } from "core/index";
|
|
@@ -515,6 +866,14 @@ declare module "app/component" {
|
|
|
515
866
|
_id: string;
|
|
516
867
|
constructor(id: any);
|
|
517
868
|
watchParams(callBack: (data: any) => any): void;
|
|
869
|
+
/**
|
|
870
|
+
* Subscribe to route changes pushed by the Kissflow host
|
|
871
|
+
* (parent back/forward or deep-link). Used by the App UI framework
|
|
872
|
+
* to keep the in-iframe router in sync with the parent URL.
|
|
873
|
+
*/
|
|
874
|
+
watchRoute(callBack: (data: {
|
|
875
|
+
route: string;
|
|
876
|
+
}) => any): void;
|
|
518
877
|
}
|
|
519
878
|
}
|
|
520
879
|
declare module "app/popup" {
|
|
@@ -540,6 +899,7 @@ declare module "app/page" {
|
|
|
540
899
|
_id: string;
|
|
541
900
|
popup: Popup;
|
|
542
901
|
type: string;
|
|
902
|
+
_route: string;
|
|
543
903
|
constructor(props: PageContext, isCustomComponent?: boolean);
|
|
544
904
|
getParameter(key: string): any;
|
|
545
905
|
getAllParameters(): any;
|
|
@@ -547,6 +907,13 @@ declare module "app/page" {
|
|
|
547
907
|
setVariable(key: string | object, value?: any): any;
|
|
548
908
|
openPopup(popupId: string, popupParams?: object): any;
|
|
549
909
|
getComponent(componentId: string): Component;
|
|
910
|
+
/**
|
|
911
|
+
* Notify the Kissflow host that the custom UI navigated to `path`,
|
|
912
|
+
* so the parent browser URL mirrors the route. Used by the App UI framework.
|
|
913
|
+
*/
|
|
914
|
+
setRoute(path: string): void;
|
|
915
|
+
/** Returns the initial deep-link route the page was opened with. */
|
|
916
|
+
getRoute(): string;
|
|
550
917
|
}
|
|
551
918
|
}
|
|
552
919
|
declare module "app/decisiontable" {
|
|
@@ -557,9 +924,71 @@ declare module "app/decisiontable" {
|
|
|
557
924
|
evaluate(payload?: object): any;
|
|
558
925
|
}
|
|
559
926
|
}
|
|
927
|
+
declare module "app/agent" {
|
|
928
|
+
import { BaseSDK } from "core/index";
|
|
929
|
+
import { AgentContract, AgentError, AgentExecuteOptions, AgentExecution, AgentExecutionAccepted } from "types/external";
|
|
930
|
+
/**
|
|
931
|
+
* A published Custom Agent of the current app.
|
|
932
|
+
*
|
|
933
|
+
* Get one with `kf.app.getAgent(agentId)`. Calls run as the signed-in user, against the Agent's
|
|
934
|
+
* published (Live) definition.
|
|
935
|
+
*/
|
|
936
|
+
export class Agent extends BaseSDK {
|
|
937
|
+
private agentId;
|
|
938
|
+
private _id;
|
|
939
|
+
private activeWatches;
|
|
940
|
+
constructor(agentId: string);
|
|
941
|
+
/**
|
|
942
|
+
* Read the Agent's published contract: its inputs, outputs and readiness.
|
|
943
|
+
*
|
|
944
|
+
* @example
|
|
945
|
+
* const { Definition } = await kf.app.getAgent("AgXXXXXXXXXX").getContract();
|
|
946
|
+
*/
|
|
947
|
+
getContract(): Promise<AgentContract>;
|
|
948
|
+
/**
|
|
949
|
+
* Start a run. Resolves once the run is accepted (`ExecutionId`, `Status`), not when it finishes;
|
|
950
|
+
* use {@link onExecutionComplete} or {@link getExecution} for the result.
|
|
951
|
+
*
|
|
952
|
+
* Never retried: if the call fails with `AGENT_EXECUTE_OUTCOME_UNKNOWN`, a run may still have
|
|
953
|
+
* started, and app code cannot list runs to find it: tell the user the request may still be in
|
|
954
|
+
* progress instead of starting another. `AGENT_EXECUTE_NOT_SENT` means it was not sent (for
|
|
955
|
+
* example, the user is offline).
|
|
956
|
+
*
|
|
957
|
+
* @example
|
|
958
|
+
* const { ExecutionId } = await agent.execute({ inputData: { request: "Two desks", amount: 54000 } });
|
|
959
|
+
*/
|
|
960
|
+
execute(options: AgentExecuteOptions): Promise<AgentExecutionAccepted>;
|
|
961
|
+
/**
|
|
962
|
+
* Read a run's current state, with its `Output` once `Completed` or its `Error` once `Failed`.
|
|
963
|
+
* Callers who are not the App's authors can read only their own runs.
|
|
964
|
+
*/
|
|
965
|
+
getExecution(executionId: string): Promise<AgentExecution>;
|
|
966
|
+
/**
|
|
967
|
+
* Be told once when a run finishes. `onComplete` gets the run on `Completed` or `Failed` (read
|
|
968
|
+
* `Status`: a failed run is a result, not an error). `onWatchError` gets what stopped the
|
|
969
|
+
* observation instead: an unsupported host, an access or network failure, or the observation limit
|
|
970
|
+
* (`AGENT_OBSERVATION_STOPPED`, after about six minutes; the run may still finish, so read it later
|
|
971
|
+
* with {@link getExecution}). At most one of the two is called, at most once.
|
|
972
|
+
*
|
|
973
|
+
* Neither is called if the script that registered them stops first: form, field, gallery and
|
|
974
|
+
* table scripts stop after one minute, and they and page event scripts stop when the next script
|
|
975
|
+
* starts on the same form, component or page. In those scripts, keep the `ExecutionId` and read
|
|
976
|
+
* it later with {@link getExecution}.
|
|
977
|
+
*
|
|
978
|
+
* Returns a function that stops observing. It never cancels the run.
|
|
979
|
+
*
|
|
980
|
+
* @example
|
|
981
|
+
* const stop = agent.onExecutionComplete(ExecutionId, (run) => show(run), (err) => warn(err));
|
|
982
|
+
* // later, e.g. on unmount
|
|
983
|
+
* stop();
|
|
984
|
+
*/
|
|
985
|
+
onExecutionComplete(executionId: string, onComplete: (execution: AgentExecution) => void, onWatchError?: (error: AgentError) => void): () => void;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
560
988
|
declare module "dataform/index" {
|
|
561
989
|
import { BaseSDK } from "core/index";
|
|
562
|
-
import {
|
|
990
|
+
import { Form } from "form/index";
|
|
991
|
+
import { DataformItem, DataformQueryOptions, DataformQueryResponse, DataformCreateItemOptions, DataformUpdateItemOptions, DataformGetItemOptions, DataformDeleteItemOptions, DataformDiscardItemOptions, DataformSubmitItemOptions, DataformFieldOptions } from "types/external";
|
|
563
992
|
export class Dataform extends BaseSDK {
|
|
564
993
|
private _id;
|
|
565
994
|
constructor(flowId: string);
|
|
@@ -628,11 +1057,36 @@ declare module "dataform/index" {
|
|
|
628
1057
|
getFields(options?: {
|
|
629
1058
|
viewId?: string;
|
|
630
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>;
|
|
631
1084
|
}
|
|
632
1085
|
}
|
|
633
1086
|
declare module "board/index" {
|
|
634
1087
|
import { BaseSDK } from "core/index";
|
|
635
|
-
import {
|
|
1088
|
+
import { Form } from "form/index";
|
|
1089
|
+
import { BoardItem, BoardGetItemOptions, BoardGetItemsOptions, BoardQueryResponse, BoardCreateItemOptions, BoardUpdateItemOptions, BoardDeleteItemOptions, BoardSubmitItemOptions, BoardDiscardItemOptions, BoardFieldOptions } from "types/external";
|
|
636
1090
|
export class Board extends BaseSDK {
|
|
637
1091
|
private _id;
|
|
638
1092
|
constructor(flowId: string);
|
|
@@ -712,11 +1166,47 @@ declare module "board/index" {
|
|
|
712
1166
|
getFields(options?: {
|
|
713
1167
|
viewId?: string;
|
|
714
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>;
|
|
715
1204
|
}
|
|
716
1205
|
}
|
|
717
1206
|
declare module "process/index" {
|
|
718
1207
|
import { BaseSDK } from "core/index";
|
|
719
|
-
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";
|
|
720
1210
|
export class Process extends BaseSDK {
|
|
721
1211
|
private _id;
|
|
722
1212
|
constructor(flowId: string);
|
|
@@ -768,7 +1258,7 @@ declare module "process/index" {
|
|
|
768
1258
|
getAdminItems(options?: ProcessAdminOptions): Promise<ProcessQueryResponse>;
|
|
769
1259
|
/**
|
|
770
1260
|
* Get a single process instance by ID
|
|
771
|
-
* @param options - instanceId (required)
|
|
1261
|
+
* @param options - instanceId, activityInstanceId (both required)
|
|
772
1262
|
* @returns Promise containing the instance data
|
|
773
1263
|
*/
|
|
774
1264
|
getItem(options: ProcessGetItemOptions): Promise<ProcessItem>;
|
|
@@ -806,6 +1296,26 @@ declare module "process/index" {
|
|
|
806
1296
|
* await process.deleteItem({ instanceId: "item_123" });
|
|
807
1297
|
*/
|
|
808
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>;
|
|
809
1319
|
/**
|
|
810
1320
|
* Open the form UI for a process instance
|
|
811
1321
|
* @param item - Process item with _id and _activity_instance_id
|
|
@@ -904,13 +1414,49 @@ declare module "process/index" {
|
|
|
904
1414
|
getProgress(options: {
|
|
905
1415
|
instanceId: string;
|
|
906
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>;
|
|
907
1451
|
}
|
|
908
1452
|
}
|
|
909
1453
|
declare module "app/index" {
|
|
910
1454
|
import { BaseSDK } from "core/index";
|
|
911
1455
|
import { Page } from "app/page";
|
|
912
1456
|
import { AppContext } from "types/internal";
|
|
1457
|
+
import { rolesObject } from "types/external";
|
|
913
1458
|
import { DecisionTable } from "app/decisiontable";
|
|
1459
|
+
import { Agent } from "app/agent";
|
|
914
1460
|
import { Dataform } from "dataform/index";
|
|
915
1461
|
import { Board } from "board/index";
|
|
916
1462
|
import { Process } from "process/index";
|
|
@@ -922,11 +1468,58 @@ declare module "app/index" {
|
|
|
922
1468
|
setVariable(key: string | object, value?: any): any;
|
|
923
1469
|
openPage(pageId: string, pageParams?: object): any;
|
|
924
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;
|
|
925
1480
|
getDataform(flowId: string): Dataform;
|
|
926
1481
|
getBoard(flowId: string): Board;
|
|
927
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>;
|
|
928
1520
|
}
|
|
929
1521
|
export * from "app/component";
|
|
1522
|
+
export { Agent };
|
|
930
1523
|
export { Page };
|
|
931
1524
|
export * from "app/popup";
|
|
932
1525
|
}
|