@kissflow/lowcode-client-sdk 1.0.44 → 1.0.49

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/nocode.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,6 +52,8 @@ 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;
@@ -59,6 +71,8 @@ declare module "core/constants" {
59
71
  DATAFORM_DELETE_ITEM: string;
60
72
  DATAFORM_DISCARD_ITEM: string;
61
73
  DATAFORM_SUBMIT_ITEM: string;
74
+ DATAFORM_INIT_FORM: string;
75
+ DATAFORM_GET_FIELD_OPTIONS: string;
62
76
  PROCESS_OPEN_FORM: string;
63
77
  PROCESS_GET_FIELDS: string;
64
78
  PROCESS_GET_MYTASK_FIELDS: string;
@@ -72,6 +86,8 @@ declare module "core/constants" {
72
86
  PROCESS_UPDATE_ITEM: string;
73
87
  PROCESS_GET_ITEM: string;
74
88
  PROCESS_DELETE_ITEM: string;
89
+ PROCESS_GET_ADMIN_ITEM: string;
90
+ PROCESS_UPDATE_ADMIN_ITEM: string;
75
91
  PROCESS_SUBMIT_ITEM: string;
76
92
  PROCESS_REJECT_ITEM: string;
77
93
  PROCESS_WITHDRAW_ITEM: string;
@@ -81,6 +97,9 @@ declare module "core/constants" {
81
97
  PROCESS_RESTART_ITEM: string;
82
98
  PROCESS_DISCARD_ITEM: string;
83
99
  PROCESS_GET_PROGRESS: string;
100
+ PROCESS_INIT_FORM: string;
101
+ PROCESS_GET_FIELD_OPTIONS: string;
102
+ PROCESS_PARSE_ATTACHMENT: string;
84
103
  BOARD_IMPORT_CSV: string;
85
104
  BOARD_OPEN_FORM: string;
86
105
  BOARD_GET_FIELDS: string;
@@ -91,10 +110,13 @@ declare module "core/constants" {
91
110
  BOARD_DELETE_ITEM: string;
92
111
  BOARD_SUBMIT_ITEM: string;
93
112
  BOARD_DISCARD_ITEM: string;
113
+ BOARD_INIT_FORM: string;
114
+ BOARD_GET_FIELD_OPTIONS: string;
94
115
  };
95
116
  export const EVENT_TYPES: {
96
117
  COMPONENT_ON_MOUNT: string;
97
118
  CC_ON_PARAMS_CHANGE: string;
119
+ CC_ON_ROUTE_CHANGE: string;
98
120
  };
99
121
  export const DEFAULTS: {
100
122
  POPUP_ID: string;
@@ -121,18 +143,27 @@ declare module "core/index" {
121
143
  declare module "form/index" {
122
144
  import { BaseSDK } from "core/index";
123
145
  export class Form extends BaseSDK {
124
- private instanceId;
146
+ private storeId;
147
+ private flowId;
125
148
  type: string;
126
- constructor(instanceId: string);
149
+ instanceId: string;
150
+ activityInstanceId?: string;
151
+ constructor(storeId: string, flowId: string, instanceId: string, activityInstanceId?: string);
127
152
  toJSON(): any;
128
153
  getField(fieldId: string): any;
129
154
  updateField(args: object): any;
155
+ getValidationErrors(): any;
156
+ getFormConfiguration(): any;
157
+ getFieldState(): any;
130
158
  getTable(tableId: string): Table;
131
159
  }
132
160
  class Table extends BaseSDK {
133
- private tableId;
161
+ private storeId;
162
+ private flowId;
134
163
  private instanceId;
135
- constructor(instanceId: string, tableId: string);
164
+ private tableId;
165
+ private activityInstanceId?;
166
+ constructor(storeId: string, flowId: string, instanceId: string, tableId: string, activityInstanceId?: string);
136
167
  toJSON(): any;
137
168
  getSelectedRows(): any;
138
169
  getRows(): TableForm[];
@@ -143,141 +174,20 @@ declare module "form/index" {
143
174
  deleteRows(rows: string[]): any;
144
175
  }
145
176
  export class TableForm extends BaseSDK {
177
+ private storeId;
178
+ private flowId;
146
179
  private instanceId;
147
180
  private tableId;
148
181
  private rowId;
182
+ private activityInstanceId?;
149
183
  type: string;
150
- constructor(instanceId: string, tableId: string, rowId: string);
184
+ constructor(storeId: string, flowId: string, instanceId: string, tableId: string, rowId: string, activityInstanceId?: string);
151
185
  getParent(): Form;
152
186
  toJSON(): any;
153
187
  getField(fieldId: string): any;
154
188
  updateField(args: object): any;
155
189
  }
156
190
  }
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 "window/NDEFReader" {
264
- import { BaseSDK } from "core/index";
265
- export class NDEFReader extends BaseSDK {
266
- id: string;
267
- constructor();
268
- scan(): Promise<unknown>;
269
- write(data: any): Promise<unknown>;
270
- addEventListener(eventName: string, cb: Function): void;
271
- makeReadOnly(): Promise<unknown>;
272
- abortScan(): Promise<unknown>;
273
- }
274
- }
275
- declare module "window/index" {
276
- import { NDEFReader } from "window/NDEFReader";
277
- export const window: {
278
- NDEFReader: typeof NDEFReader;
279
- };
280
- }
281
191
  declare module "types/external" {
282
192
  export type QueryResponse = {
283
193
  items: any[];
@@ -335,6 +245,17 @@ declare module "types/external" {
335
245
  _id: string;
336
246
  _activity_instance_id: string;
337
247
  };
248
+ export type GeolocationValue = {
249
+ Address?: string;
250
+ Latitude: string;
251
+ Longitude: string;
252
+ City?: string;
253
+ State?: string;
254
+ Country?: string;
255
+ ZipCode?: string;
256
+ Area?: string;
257
+ PlaceId?: string;
258
+ };
338
259
  export type ProcessMyItemsOptions = BaseQueryOptions & {
339
260
  status?: "draft" | "inprogress" | "completed" | "withdrawn" | "rejected" | "all";
340
261
  payload?: ProcessPayloadOptions;
@@ -353,6 +274,7 @@ declare module "types/external" {
353
274
  export type ProcessQueryResponse = QueryResponse;
354
275
  export type ProcessGetItemOptions = {
355
276
  instanceId: string;
277
+ activityInstanceId: string;
356
278
  };
357
279
  export type ProcessCreateItemOptions = {
358
280
  data?: object;
@@ -365,6 +287,13 @@ declare module "types/external" {
365
287
  export type ProcessDeleteItemOptions = {
366
288
  instanceId: string;
367
289
  };
290
+ export type ProcessGetAdminItemOptions = {
291
+ instanceId: string;
292
+ };
293
+ export type ProcessUpdateAdminItemOptions = {
294
+ instanceId: string;
295
+ data: object;
296
+ };
368
297
  export type ProcessSubmitItemOptions = {
369
298
  instanceId: string;
370
299
  activityInstanceId: string;
@@ -407,6 +336,32 @@ declare module "types/external" {
407
336
  export type ProcessDiscardItemOptions = {
408
337
  instanceId: string;
409
338
  };
339
+ export type ProcessFieldOptions = {
340
+ instanceId: string;
341
+ activityInstanceId: string;
342
+ fieldId: string;
343
+ /** Skip the server-side model lookup by supplying the field's type directly. */
344
+ fieldType?: string;
345
+ tableId?: string;
346
+ tableRowId?: string;
347
+ };
348
+ export type ProcessAttachmentFile = {
349
+ id: string;
350
+ name: string;
351
+ key: string;
352
+ size?: number;
353
+ fileExtension?: string;
354
+ };
355
+ export type ProcessParseAttachmentOptions = {
356
+ instanceId: string;
357
+ activityInstanceId: string;
358
+ fieldId: string;
359
+ file: ProcessAttachmentFile;
360
+ };
361
+ export type ProcessAttachmentParseResult = {
362
+ appliedFields: string[];
363
+ suggestedBy: string;
364
+ };
410
365
  export type FetchOptions = {
411
366
  method?: string;
412
367
  body?: string | object;
@@ -442,6 +397,14 @@ declare module "types/external" {
442
397
  data?: object;
443
398
  viewId?: string;
444
399
  };
400
+ export type DataformFieldOptions = {
401
+ instanceId: string;
402
+ fieldId: string;
403
+ /** Skip the server-side model lookup by supplying the field's type directly. */
404
+ fieldType?: string;
405
+ tableId?: string;
406
+ tableRowId?: string;
407
+ };
445
408
  export type BoardGetItemsOptions = BaseQueryOptions & {
446
409
  viewId?: string;
447
410
  payload?: PayloadOptions;
@@ -467,11 +430,20 @@ declare module "types/external" {
467
430
  export type BoardDiscardItemOptions = {
468
431
  instanceId: string;
469
432
  };
433
+ export type BoardFieldOptions = {
434
+ instanceId: string;
435
+ fieldId: string;
436
+ /** Skip the server-side model lookup by supplying the field's type directly. */
437
+ fieldType?: string;
438
+ tableId?: string;
439
+ tableRowId?: string;
440
+ };
470
441
  }
471
442
  declare module "types/internal" {
472
443
  import { userObject, accountObject, environmentObject } from "types/external";
473
444
  export interface SDKContext {
474
445
  formInstanceId: string;
446
+ flowId: string;
475
447
  tableId: string;
476
448
  tableRowId: string;
477
449
  componentId: string;
@@ -499,10 +471,271 @@ declare module "types/internal" {
499
471
  }
500
472
  export interface PageContext {
501
473
  pageId: string;
474
+ initialRoute?: string;
502
475
  }
503
476
  export interface PopupContext {
504
477
  popupId?: string;
505
478
  }
479
+ export interface FilePickerOptions {
480
+ fileExtensions?: string[];
481
+ maxSize?: number;
482
+ maxCount?: number;
483
+ imageProps?: {
484
+ sizes?: Array<[number, number]>;
485
+ crop?: boolean;
486
+ };
487
+ }
488
+ export interface ScannerOptions {
489
+ /** Allow decoding from an uploaded image instead of the camera. */
490
+ localFileScan?: boolean;
491
+ }
492
+ /** Minimal shape of a browser File/Blob object, avoids requiring the DOM lib. */
493
+ export interface UploadableFile {
494
+ name: string;
495
+ size?: number;
496
+ type?: string;
497
+ }
498
+ }
499
+ declare module "utils/client" {
500
+ import { BaseSDK } from "core/index";
501
+ import { GeolocationValue } from "types/external";
502
+ import { FilePickerOptions, ScannerOptions, UploadableFile } from "types/internal";
503
+ export class Client extends BaseSDK {
504
+ /**
505
+ * Display an info message toast in the platform.
506
+ *
507
+ * @param message - The message to display. Accepts a string or object (serialized to JSON).
508
+ * @returns A promise that resolves when the message is shown.
509
+ *
510
+ * @example
511
+ * await kf.client.showInfo("Record saved successfully");
512
+ */
513
+ showInfo(message: string | object): any;
514
+ /**
515
+ * Display a confirmation dialog and wait for the user's response.
516
+ *
517
+ * @param args - Dialog configuration.
518
+ * @param args.title - Dialog title.
519
+ * @param args.content - Body text of the dialog.
520
+ * @param args.okText - Label for the confirm button (default: "Ok").
521
+ * @param args.cancelText - Label for the cancel button (default: "Cancel").
522
+ * @returns A promise that resolves with `{ action: "OK" }` or `{ action: "CANCEL" }`.
523
+ *
524
+ * @example
525
+ * const { action } = await kf.client.showConfirm({
526
+ * title: "Delete record?",
527
+ * content: "This cannot be undone.",
528
+ * okText: "Delete",
529
+ * cancelText: "Cancel",
530
+ * });
531
+ * if (action === "OK") { ... }
532
+ */
533
+ showConfirm(args: {
534
+ title: string;
535
+ content: string;
536
+ okText: string;
537
+ cancelText: string;
538
+ }): any;
539
+ /**
540
+ * Navigate the platform to the given URL.
541
+ *
542
+ * @param url - The URL to navigate to.
543
+ *
544
+ * @example
545
+ * kf.client.redirect("https://example.com");
546
+ */
547
+ redirect(url: string): any;
548
+ /**
549
+ * Resolve a Kissflow image field value to a base64 data URL.
550
+ *
551
+ * Custom components (iframes) cannot load Kissflow-hosted images directly due to
552
+ * CORS restrictions and 302 redirects to signed S3 URLs. This method fetches the
553
+ * image in the parent window (which has the required session cookies) and returns
554
+ * a self-contained `data:image/...;base64,...` URL that can be used as `<img src>`
555
+ * without any CORS issues.
556
+ *
557
+ * @param imageValue - The image field value must contain a `key` property and
558
+ * optionally a `photos` array. Uses `photos[1]` (preview resolution) when available,
559
+ * falls back to `key`.
560
+ * @returns A promise that resolves with the base64 data URL string.
561
+ *
562
+ * @example
563
+ * const dataUrl = await kf.client.getImageUrl(imageFieldValue);
564
+ * document.querySelector("#avatar").src = dataUrl;
565
+ */
566
+ getImageUrl(imageValue: Record<string, unknown>): any;
567
+ /**
568
+ * Open the platform's file picker, upload the selected file(s), and resolve
569
+ * with their metadata.
570
+ *
571
+ * Custom components (iframes) cannot access the platform's authenticated upload
572
+ * endpoints directly. This method opens the file picker in the parent window
573
+ * (which has the required session), runs the full select → upload flow, and
574
+ * resolves once all uploads settle with an array of the uploaded files'
575
+ * metadata (each including `key`, `name`, `size`, `photos`, etc. — the same
576
+ * shape consumed by `getImageUrl`).
577
+ *
578
+ * Always resolves with an array — a single-element array for single-file
579
+ * pickers (e.g. `maxCount: 1` for `Image`), one entry per uploaded file for
580
+ * multi-file pickers (e.g. `Attachment`). Resolves with `[]` if the user closes
581
+ * the picker without completing any upload.
582
+ *
583
+ * @param options - File picker configuration (e.g. `fileExtensions`, `maxSize`,
584
+ * `maxCount`, `imageProps`).
585
+ * @returns A promise that resolves with an array of uploaded file metadata
586
+ * objects (empty if the picker was closed without uploading anything).
587
+ *
588
+ * @example
589
+ * const files = await kf.client.openFilePicker({ fileExtensions: ["JPG", "PNG"] });
590
+ * if (files.length) onChange(files[0]); // single-file consumer (Image)
591
+ *
592
+ * @example
593
+ * const files = await kf.client.openFilePicker({ maxCount: 10 });
594
+ * if (files.length) onChange([...existing, ...files]); // multi-file consumer (Attachment)
595
+ */
596
+ openFilePicker(options: FilePickerOptions): any;
597
+ /**
598
+ * Open the platform's barcode/QR scanner and resolve with the decoded text.
599
+ *
600
+ * The scanner UI (camera stream + decoding) runs in the parent window, which
601
+ * owns the camera permission — the iframe itself never accesses the camera.
602
+ * Camera-permission prompts and denials are handled inside the scanner UI;
603
+ * they are not surfaced as errors here.
604
+ *
605
+ * Resolves with `null` if the user closes the scanner without a successful
606
+ * scan (including the scanner's own inactivity timeout).
607
+ *
608
+ * Note: currently supported in web custom app UIs; the mobile (PWA) custom
609
+ * UI does not host the scanner portal yet.
610
+ *
611
+ * @param options - Scanner configuration (e.g. `localFileScan` to allow
612
+ * decoding from an uploaded image instead of the camera).
613
+ * @returns A promise that resolves with the decoded string, or `null` if the
614
+ * scanner was closed without scanning.
615
+ *
616
+ * @example
617
+ * const code = await kf.client.openScanner({ localFileScan: true });
618
+ * if (code) onChange(code);
619
+ */
620
+ openScanner(options?: ScannerOptions): any;
621
+ /**
622
+ * Open the platform's native Geolocation map picker (search, current-location
623
+ * detection, marker drag, reverse-geocoding) in a modal over the custom
624
+ * form/component. Runs in the parent window, which owns the Google Maps API
625
+ * key — the iframe itself never needs one.
626
+ *
627
+ * Resolves with `null` if the user closes the picker without selecting a
628
+ * location.
629
+ *
630
+ * @param value - Optional current geolocation value to pre-select on the map.
631
+ * @returns A promise that resolves with the picked location object, or
632
+ * `null` if the picker was closed without a selection.
633
+ *
634
+ * @example
635
+ * const location = await kf.client.pickLocation();
636
+ * if (location) onChange(location);
637
+ */
638
+ pickLocation(value?: GeolocationValue): any;
639
+ /**
640
+ * Upload a File object to Kissflow's S3 storage and resolve with its metadata.
641
+ *
642
+ * Use this when you have a File/Blob already in memory (e.g. a canvas drawing
643
+ * converted to a PNG blob) and need to upload it without opening a file picker UI.
644
+ * The platform runs the upload in the parent window (which has the required session)
645
+ * and resolves with the uploaded file's `{ key, name, ... }` metadata — the same
646
+ * shape returned by `openFilePicker`.
647
+ *
648
+ * Resolves with `null` if the upload fails.
649
+ *
650
+ * @param file - The File or Blob to upload.
651
+ * @param fileName - Optional file name override (defaults to `file.name`).
652
+ * @returns A promise that resolves with the uploaded file metadata, or `null` on failure.
653
+ *
654
+ * @example
655
+ * const blob = await new Promise<Blob>(res => canvas.toBlob(res, 'image/png'));
656
+ * const file = new File([blob], 'signature.png', { type: 'image/png' });
657
+ * const result = await kf.client.uploadFile(file);
658
+ * if (result) onChange(result);
659
+ */
660
+ uploadFile(file: UploadableFile, fileName?: string): any;
661
+ /**
662
+ * Open the platform's file preview (lightbox) for one or more files.
663
+ *
664
+ * `files` always accepts an array — pass a single-element array for fields like
665
+ * `Image`, or the full list for multi-file fields like `Attachment`. The host's
666
+ * preview UI natively renders next/prev navigation across the array; the SDK
667
+ * just passes the file list through, no extra navigation surface is needed here.
668
+ *
669
+ * @param args - Preview configuration.
670
+ * @param args.files - Array of file metadata objects to preview.
671
+ * @param args.indexOfFile - Index of the file to open the preview on (default: 0).
672
+ * @returns A promise that resolves once the user closes the preview.
673
+ *
674
+ * @example
675
+ * await kf.client.openFilePreview({ files: [imageFieldValue] });
676
+ * await kf.client.openFilePreview({ files: attachmentFieldValue, indexOfFile: 2 });
677
+ */
678
+ openFilePreview(args: {
679
+ files: Record<string, unknown>[];
680
+ indexOfFile?: number;
681
+ }): any;
682
+ }
683
+ }
684
+ declare module "utils/formatter" {
685
+ import { BaseSDK } from "core/index";
686
+ export class Formatter extends BaseSDK {
687
+ toDate(date: string): any;
688
+ toDateTime(date: string): any;
689
+ toNumber(value: string): any;
690
+ toCurrency(value: string, currencyCode: string): any;
691
+ toBoolean(value: string): any;
692
+ }
693
+ }
694
+ declare module "utils/validation" {
695
+ /**
696
+ * Validation utilities for SDK methods
697
+ */
698
+ /**
699
+ * Throws error if value is falsy
700
+ */
701
+ export function requireField(value: any, fieldName: string): void;
702
+ /**
703
+ * Returns a rejected promise if value is falsy, null otherwise
704
+ * Use for async validation in SDK methods
705
+ */
706
+ export function requireFieldAsync(value: any, fieldName: string): Promise<never> | null;
707
+ /**
708
+ * Returns a rejected promise if any of the values are falsy
709
+ * Use for validating multiple required fields
710
+ */
711
+ export function requireFieldsAsync(fields: Array<{
712
+ value: any;
713
+ name: string;
714
+ }>): Promise<never> | null;
715
+ }
716
+ declare module "utils/index" {
717
+ export * from "utils/client";
718
+ export * from "utils/formatter";
719
+ export * from "utils/validation";
720
+ export const isObject: (value: any) => boolean;
721
+ }
722
+ declare module "window/NDEFReader" {
723
+ import { BaseSDK } from "core/index";
724
+ export class NDEFReader extends BaseSDK {
725
+ id: string;
726
+ constructor();
727
+ scan(): Promise<unknown>;
728
+ write(data: any): Promise<unknown>;
729
+ addEventListener(eventName: string, cb: Function): void;
730
+ makeReadOnly(): Promise<unknown>;
731
+ abortScan(): Promise<unknown>;
732
+ }
733
+ }
734
+ declare module "window/index" {
735
+ import { NDEFReader } from "window/NDEFReader";
736
+ export const window: {
737
+ NDEFReader: typeof NDEFReader;
738
+ };
506
739
  }
507
740
  declare module "nocode" {
508
741
  import { BaseSDK } from "core/index";
@@ -545,6 +778,14 @@ declare module "app/component" {
545
778
  _id: string;
546
779
  constructor(id: any);
547
780
  watchParams(callBack: (data: any) => any): void;
781
+ /**
782
+ * Subscribe to route changes pushed by the Kissflow host
783
+ * (parent back/forward or deep-link). Used by the App UI framework
784
+ * to keep the in-iframe router in sync with the parent URL.
785
+ */
786
+ watchRoute(callBack: (data: {
787
+ route: string;
788
+ }) => any): void;
548
789
  }
549
790
  }
550
791
  declare module "app/decisiontable" {
@@ -587,6 +828,7 @@ declare module "app/page" {
587
828
  _id: string;
588
829
  popup: Popup;
589
830
  type: string;
831
+ _route: string;
590
832
  constructor(props: PageContext, isCustomComponent?: boolean);
591
833
  getParameter(key: string): any;
592
834
  getAllParameters(): any;
@@ -594,11 +836,19 @@ declare module "app/page" {
594
836
  setVariable(key: string | object, value?: any): any;
595
837
  openPopup(popupId: string, popupParams?: object): any;
596
838
  getComponent(componentId: string): Component;
839
+ /**
840
+ * Notify the Kissflow host that the custom UI navigated to `path`,
841
+ * so the parent browser URL mirrors the route. Used by the App UI framework.
842
+ */
843
+ setRoute(path: string): void;
844
+ /** Returns the initial deep-link route the page was opened with. */
845
+ getRoute(): string;
597
846
  }
598
847
  }
599
848
  declare module "dataform/index" {
600
849
  import { BaseSDK } from "core/index";
601
- import { DataformItem, DataformQueryOptions, DataformQueryResponse, DataformCreateItemOptions, DataformUpdateItemOptions, DataformGetItemOptions, DataformDeleteItemOptions, DataformDiscardItemOptions, DataformSubmitItemOptions } from "types/external";
850
+ import { Form } from "form/index";
851
+ import { DataformItem, DataformQueryOptions, DataformQueryResponse, DataformCreateItemOptions, DataformUpdateItemOptions, DataformGetItemOptions, DataformDeleteItemOptions, DataformDiscardItemOptions, DataformSubmitItemOptions, DataformFieldOptions } from "types/external";
602
852
  export class Dataform extends BaseSDK {
603
853
  private _id;
604
854
  constructor(flowId: string);
@@ -667,11 +917,36 @@ declare module "dataform/index" {
667
917
  getFields(options?: {
668
918
  viewId?: string;
669
919
  }): Promise<any>;
920
+ /**
921
+ * Initialize a form with all necessary data (schema, item data, form store)
922
+ * This is the recommended way to create a custom form for dataform records
923
+ * It automatically handles fetching schema, item data, and initializing the form store
924
+ *
925
+ * @param instanceId - Optional instance ID of the dataform record. If omitted, creates a new record
926
+ * @param viewId - Optional view ID to scope the form's schema/permissions to a specific view
927
+ * @returns Promise with Form instance ready to use
928
+ *
929
+ * @example
930
+ * // Load existing record
931
+ * const dataform = kf.app.getDataform("EmpMaster");
932
+ * const form = await dataform.initForm("emp_123");
933
+ * const data = await form.toJSON();
934
+ *
935
+ * // Load existing record scoped to a view
936
+ * const form = await dataform.initForm("emp_123", "EmpMaster_View");
937
+ *
938
+ * // Create new record
939
+ * const form = await dataform.initForm();
940
+ * await form.updateField({ firstName: "John" });
941
+ */
942
+ initForm(instanceId?: string, viewId?: string): Promise<Form>;
943
+ getFieldOptions(options?: DataformFieldOptions): Promise<DataformQueryResponse>;
670
944
  }
671
945
  }
672
946
  declare module "board/index" {
673
947
  import { BaseSDK } from "core/index";
674
- import { BoardItem, BoardGetItemOptions, BoardGetItemsOptions, BoardQueryResponse, BoardCreateItemOptions, BoardUpdateItemOptions, BoardDeleteItemOptions, BoardSubmitItemOptions, BoardDiscardItemOptions } from "types/external";
948
+ import { Form } from "form/index";
949
+ import { BoardItem, BoardGetItemOptions, BoardGetItemsOptions, BoardQueryResponse, BoardCreateItemOptions, BoardUpdateItemOptions, BoardDeleteItemOptions, BoardSubmitItemOptions, BoardDiscardItemOptions, BoardFieldOptions } from "types/external";
675
950
  export class Board extends BaseSDK {
676
951
  private _id;
677
952
  constructor(flowId: string);
@@ -751,11 +1026,47 @@ declare module "board/index" {
751
1026
  getFields(options?: {
752
1027
  viewId?: string;
753
1028
  }): Promise<any>;
1029
+ /**
1030
+ * Initialize a form for a board item with all necessary setup
1031
+ * Fetches schema, item data, creates and initializes the form store
1032
+ *
1033
+ * @param instanceId - Optional instance ID. If omitted, creates a new board item
1034
+ * @param viewId - Optional view ID to scope the form's schema/permissions to a specific view
1035
+ * @returns Promise with Form instance ready to use
1036
+ *
1037
+ * @example
1038
+ * // Create new board item
1039
+ * const board = kf.app.getBoard("Inventory");
1040
+ * const form = await board.initForm();
1041
+ * await form.updateField({ Name: "New Item" });
1042
+ *
1043
+ * // Edit existing board item
1044
+ * const form = await board.initForm("item_123");
1045
+ * const data = await form.toJSON();
1046
+ *
1047
+ * // Edit existing board item scoped to a view
1048
+ * const form = await board.initForm("item_123", "Inventory_View");
1049
+ */
1050
+ initForm(instanceId?: string, viewId?: string): Promise<Form>;
1051
+ /**
1052
+ * Get field options for dropdown/lookup fields
1053
+ * @param options - Field options (instanceId, fieldId)
1054
+ * @returns Promise containing the field options
1055
+ *
1056
+ * @example
1057
+ * const board = kf.app.getBoard("Inventory");
1058
+ * const options = await board.getFieldOptions({
1059
+ * instanceId: "item_123",
1060
+ * fieldId: "Category"
1061
+ * });
1062
+ */
1063
+ getFieldOptions(options: BoardFieldOptions): Promise<any>;
754
1064
  }
755
1065
  }
756
1066
  declare module "process/index" {
757
1067
  import { BaseSDK } from "core/index";
758
- import { ProcessItem, ProcessGetItemOptions, ProcessMyItemsOptions, ProcessMyTasksOptions, ProcessParticipatedOptions, ProcessAdminOptions, ProcessQueryResponse, ProcessCreateItemOptions, ProcessUpdateItemOptions, ProcessDeleteItemOptions, ProcessSubmitItemOptions, ProcessRejectItemOptions, ProcessWithdrawItemOptions, ProcessSendbackItemOptions, ProcessReassignItemOptions, ProcessGetReassigneesOptions, ProcessRestartItemOptions, ProcessDiscardItemOptions } from "types/external";
1068
+ import { Form } from "form/index";
1069
+ 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";
759
1070
  export class Process extends BaseSDK {
760
1071
  private _id;
761
1072
  constructor(flowId: string);
@@ -807,7 +1118,7 @@ declare module "process/index" {
807
1118
  getAdminItems(options?: ProcessAdminOptions): Promise<ProcessQueryResponse>;
808
1119
  /**
809
1120
  * Get a single process instance by ID
810
- * @param options - instanceId (required)
1121
+ * @param options - instanceId, activityInstanceId (both required)
811
1122
  * @returns Promise containing the instance data
812
1123
  */
813
1124
  getItem(options: ProcessGetItemOptions): Promise<ProcessItem>;
@@ -845,6 +1156,26 @@ declare module "process/index" {
845
1156
  * await process.deleteItem({ instanceId: "item_123" });
846
1157
  */
847
1158
  deleteItem(options: ProcessDeleteItemOptions): Promise<void>;
1159
+ /**
1160
+ * Get a single process instance as admin (requires admin access)
1161
+ * @param options - instanceId (required)
1162
+ * @returns Promise containing the instance data
1163
+ *
1164
+ * @example
1165
+ * const process = kf.app.getProcess("LeaveRequest");
1166
+ * const item = await process.getAdminItem({ instanceId: "item_123" });
1167
+ */
1168
+ getAdminItem(options: ProcessGetAdminItemOptions): Promise<ProcessItem>;
1169
+ /**
1170
+ * Update a process instance as admin (requires admin access)
1171
+ * @param options - instanceId, data (required)
1172
+ * @returns Promise containing the updated item
1173
+ *
1174
+ * @example
1175
+ * const process = kf.app.getProcess("LeaveRequest");
1176
+ * await process.updateAdminItem({ instanceId: "item_123", data: { LeaveType: "Sick" } });
1177
+ */
1178
+ updateAdminItem(options: ProcessUpdateAdminItemOptions): Promise<ProcessItem>;
848
1179
  /**
849
1180
  * Open the form UI for a process instance
850
1181
  * @param item - Process item with _id and _activity_instance_id
@@ -943,12 +1274,47 @@ declare module "process/index" {
943
1274
  getProgress(options: {
944
1275
  instanceId: string;
945
1276
  }): Promise<any>;
1277
+ /**
1278
+ * Initialize a form with all necessary data (schema, item data, form store)
1279
+ * This is the recommended way to create a custom form for dataform records
1280
+ * It automatically handles fetching schema, item data, and initializing the form store
1281
+ *
1282
+ * @param instanceId - Optional instance ID of the dataform record. If omitted, creates a new record
1283
+ * @returns Promise with Form instance ready to use
1284
+ *
1285
+ * @example
1286
+ * // Load existing record
1287
+ * const dataform = kf.app.getDataform("EmpMaster");
1288
+ * const form = await dataform.initForm("emp_123");
1289
+ * const data = await form.toJSON();
1290
+ *
1291
+ * // Create new record
1292
+ * const form = await dataform.initForm();
1293
+ * await form.updateField({ firstName: "John" });
1294
+ */
1295
+ initForm(instanceId?: string, activityInstanceId?: string): Promise<Form>;
1296
+ getFieldOptions(options?: ProcessFieldOptions): Promise<ProcessQueryResponse>;
1297
+ /**
1298
+ * Trigger AI document parsing on an uploaded file for a Smart Attachment field.
1299
+ * Matches native platform behavior: matching empty fields are auto-filled directly
1300
+ * into the form store (respecting field permissions) — no separate apply step needed.
1301
+ * Call `form.toJSON()` afterward to read the updated values.
1302
+ *
1303
+ * @example
1304
+ * const form = await process.initForm();
1305
+ * const files = await kf.client.openFilePicker({ fileExtensions: ["pdf"], maxCount: 1 });
1306
+ * await form.updateField({ [fieldId]: files });
1307
+ * await process.parseAttachment({ instanceId: form.instanceId, fieldId, file: files[0] });
1308
+ * const updated = await form.toJSON(); // other fields now auto-filled
1309
+ */
1310
+ parseAttachment(options: ProcessParseAttachmentOptions): Promise<ProcessAttachmentParseResult>;
946
1311
  }
947
1312
  }
948
1313
  declare module "app/index" {
949
1314
  import { BaseSDK } from "core/index";
950
1315
  import { Page } from "app/page";
951
1316
  import { AppContext } from "types/internal";
1317
+ import { rolesObject } from "types/external";
952
1318
  import { DecisionTable } from "app/decisiontable";
953
1319
  import { Dataform } from "dataform/index";
954
1320
  import { Board } from "board/index";
@@ -964,6 +1330,43 @@ declare module "app/index" {
964
1330
  getDataform(flowId: string): Dataform;
965
1331
  getBoard(flowId: string): Board;
966
1332
  getProcess(flowId: string): Process;
1333
+ /**
1334
+ * List the app's roles and which of them the current user is a member of.
1335
+ *
1336
+ * Only available in a Development account - use this to build a role
1337
+ * picker UI inside the component, then pass the chosen role to
1338
+ * {@link switchRole}.
1339
+ *
1340
+ * @returns A promise that resolves with `{ roles, currentRoles }` - the
1341
+ * full list of app roles and the subset the current user belongs to.
1342
+ *
1343
+ * @example
1344
+ * const { roles, currentRoles } = await kf.app.getRoles();
1345
+ */
1346
+ getRoles(): Promise<{
1347
+ roles: rolesObject[];
1348
+ currentRoles: rolesObject[];
1349
+ }>;
1350
+ /**
1351
+ * Switch the current user's active role in a Development account.
1352
+ *
1353
+ * This performs a real role change - it removes the user from their
1354
+ * current role(s) and adds them to the target role. The platform's app
1355
+ * shell (top nav, other widgets) picks up the new role on its own; no
1356
+ * page reload happens. Only available in a Development account.
1357
+ *
1358
+ * @param args - Either `roleId` or `roleName` identifying the target role
1359
+ * (use the values returned by {@link getRoles}).
1360
+ * @returns A promise that resolves with the switched-to role.
1361
+ *
1362
+ * @example
1363
+ * const { roles } = await kf.app.getRoles();
1364
+ * await kf.app.switchRole({ roleId: roles[1]._id });
1365
+ */
1366
+ switchRole(args: {
1367
+ roleId?: string;
1368
+ roleName?: string;
1369
+ }): Promise<rolesObject>;
967
1370
  }
968
1371
  export * from "app/component";
969
1372
  export { Page };