@kissflow/lowcode-client-sdk 1.0.39 → 1.0.41

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.
@@ -24,14 +24,69 @@ declare class TableForm {
24
24
  updateField(args: object): any;
25
25
  }
26
26
  declare class Client {
27
- showInfo(message: string | object): any;
28
- showConfirm(args: {
27
+ /**
28
+ * Display an info message toast in the platform.
29
+ *
30
+ * @param message - The message to display. Accepts a string or object (serialized to JSON).
31
+ * @returns A promise that resolves when the message is shown.
32
+ *
33
+ * @example
34
+ * await kf.client.showInfo("Record saved successfully");
35
+ */
36
+ showInfo(message: string | object): any;
37
+ /**
38
+ * Display a confirmation dialog and wait for the user's response.
39
+ *
40
+ * @param args - Dialog configuration.
41
+ * @param args.title - Dialog title.
42
+ * @param args.content - Body text of the dialog.
43
+ * @param args.okText - Label for the confirm button (default: "Ok").
44
+ * @param args.cancelText - Label for the cancel button (default: "Cancel").
45
+ * @returns A promise that resolves with `{ action: "OK" }` or `{ action: "CANCEL" }`.
46
+ *
47
+ * @example
48
+ * const { action } = await kf.client.showConfirm({
49
+ * title: "Delete record?",
50
+ * content: "This cannot be undone.",
51
+ * okText: "Delete",
52
+ * cancelText: "Cancel",
53
+ * });
54
+ * if (action === "OK") { ... }
55
+ */
56
+ showConfirm(args: {
29
57
  title: string;
30
58
  content: string;
31
59
  okText: string;
32
60
  cancelText: string;
33
61
  }): any;
34
- redirect(url: string): any;
62
+ /**
63
+ * Navigate the platform to the given URL.
64
+ *
65
+ * @param url - The URL to navigate to.
66
+ *
67
+ * @example
68
+ * kf.client.redirect("https://example.com");
69
+ */
70
+ redirect(url: string): any;
71
+ /**
72
+ * Resolve a Kissflow image field value to a base64 data URL.
73
+ *
74
+ * Custom components (iframes) cannot load Kissflow-hosted images directly due to
75
+ * CORS restrictions and 302 redirects to signed S3 URLs. This method fetches the
76
+ * image in the parent window (which has the required session cookies) and returns
77
+ * a self-contained `data:image/...;base64,...` URL that can be used as `<img src>`
78
+ * without any CORS issues.
79
+ *
80
+ * @param imageValue - The image field value must contain a `key` property and
81
+ * optionally a `photos` array. Uses `photos[1]` (preview resolution) when available,
82
+ * falls back to `key`.
83
+ * @returns A promise that resolves with the base64 data URL string.
84
+ *
85
+ * @example
86
+ * const dataUrl = await kf.client.getImageUrl(imageFieldValue);
87
+ * document.querySelector("#avatar").src = dataUrl;
88
+ */
89
+ getImageUrl(imageValue: Record<string, unknown>): any;
35
90
  }
36
91
  declare class Formatter {
37
92
  toDate(date: string): any;
@@ -73,15 +128,335 @@ declare class DecisionTable {
73
128
  evaluate(payload?: object): any;
74
129
  }
75
130
  declare class Dataform {
76
- importCSV(defaultValues?: object): any;
77
- openForm(item: DataformItem): any;
131
+ /**
132
+ * Get all items from this dataform with optional filtering, sorting, and pagination
133
+ * @param options - Query options (searchValue, pageNumber, pageSize, payload)
134
+ * @returns Promise containing items and total count
135
+ */
136
+ getItems(options?: DataformQueryOptions): Promise<DataformQueryResponse>;
137
+ /**
138
+ * Get a single item by ID from this dataform
139
+ * @param options - itemId (required), optional viewId
140
+ * @returns Promise containing the item data
141
+ */
142
+ getItem(options: DataformGetItemOptions): Promise<DataformItem>;
143
+ /**
144
+ * Create a new item in this dataform
145
+ * @param options - Creation options (data: initial field values, viewId: optional view ID)
146
+ * @returns Promise containing the newly created item with _id
147
+ */
148
+ createItem(options?: DataformCreateItemOptions): Promise<DataformItem>;
149
+ /**
150
+ * Update an existing item in this dataform
151
+ * @param options - Update options (itemId: required, data: required updated values, viewId: optional view ID)
152
+ * @returns Promise containing the updated item
153
+ */
154
+ updateItem(options: DataformUpdateItemOptions): Promise<DataformItem>;
155
+ /**
156
+ * Import items from a CSV file into this dataform
157
+ * @param defaultValues - Optional default field values to apply to all imported items
158
+ */
159
+ importCSV(defaultValues?: object): any;
160
+ /**
161
+ * Open the form UI for an existing dataform item
162
+ * @param item - Dataform item with _id
163
+ */
164
+ openForm(item: DataformItem): any;
165
+ /**
166
+ * Delete an item from this dataform
167
+ * @param options - itemId (required), optional viewId
168
+ *
169
+ * @example
170
+ * await dataform.deleteItem({ itemId: "item_123" });
171
+ */
172
+ deleteItem(options: DataformDeleteItemOptions): Promise<void>;
173
+ /**
174
+ * Discard the current draft for this dataform
175
+ * @param options - optional viewId
176
+ *
177
+ * @example
178
+ * await dataform.discardItem();
179
+ */
180
+ discardItem(options?: DataformDiscardItemOptions): Promise<void>;
181
+ /**
182
+ * Submit/finalize a dataform item
183
+ * @param options - itemId (required), optional data and viewId
184
+ *
185
+ * @example
186
+ * await dataform.submitItem({ itemId: "item_123" });
187
+ */
188
+ submitItem(options: DataformSubmitItemOptions): Promise<void>;
189
+ /**
190
+ * Get field definitions for this dataform
191
+ * @param options - Optional viewId to scope fields to a specific view
192
+ */
193
+ getFields(options?: {
194
+ viewId?: string;
195
+ }): Promise<any>;
78
196
  }
79
197
  declare class Board {
80
- importCSV(defaultValues?: object): any;
81
- openForm(item: BoardItem): any;
198
+ /**
199
+ * Import data from CSV file
200
+ * @param defaultValues - Optional default values to apply to imported items
201
+ */
202
+ importCSV(defaultValues?: object): any;
203
+ /**
204
+ * Open the form UI for a board item
205
+ * @param item - Board item with _id and optional _view_id
206
+ */
207
+ openForm(item: BoardItem): any;
208
+ /**
209
+ * Get items from a board view
210
+ * @param options - Query options (viewId, searchValue, pageNumber, pageSize, payload)
211
+ * @returns Promise containing items array and total count
212
+ *
213
+ * @example
214
+ * const board = kf.app.getBoard("Inventory");
215
+ * const { items } = await board.getItems({ viewId: "AllItems_View" });
216
+ */
217
+ getItems(options?: BoardGetItemsOptions): Promise<BoardQueryResponse>;
218
+ /**
219
+ * Get a single board/case item by instance ID
220
+ * @param options - instanceId (required)
221
+ * @returns Promise containing the item data
222
+ */
223
+ getItem(options: BoardGetItemOptions): Promise<BoardItem>;
224
+ /**
225
+ * Create a new board item
226
+ * @param options - Creation options (data: initial field values)
227
+ * @returns Promise containing the newly created item with _id
228
+ *
229
+ * @example
230
+ * const board = kf.app.getBoard("Inventory");
231
+ * const item = await board.createItem({ data: { Name: "New Item" } });
232
+ */
233
+ createItem(options?: BoardCreateItemOptions): Promise<BoardItem>;
234
+ /**
235
+ * Update an existing board item
236
+ * @param options - Update options (instanceId, data)
237
+ * @returns Promise containing the updated item
238
+ *
239
+ * @example
240
+ * const board = kf.app.getBoard("Inventory");
241
+ * await board.updateItem({
242
+ * instanceId: "item_123",
243
+ * data: { Name: "Updated Item" }
244
+ * });
245
+ */
246
+ updateItem(options: BoardUpdateItemOptions): Promise<BoardItem>;
247
+ /**
248
+ * Delete a board item
249
+ * @param options - Delete options (instanceId)
250
+ * @returns Promise resolving on successful deletion
251
+ *
252
+ * @example
253
+ * const board = kf.app.getBoard("Inventory");
254
+ * await board.deleteItem({ instanceId: "item_123" });
255
+ */
256
+ deleteItem(options: BoardDeleteItemOptions): Promise<void>;
257
+ /**
258
+ * Submit a board item
259
+ * @param options - instanceId
260
+ */
261
+ submitItem(options: BoardSubmitItemOptions): Promise<void>;
262
+ /**
263
+ * Discard a board item
264
+ * @param options - instanceId
265
+ */
266
+ discardItem(options: BoardDiscardItemOptions): Promise<void>;
267
+ /**
268
+ * Get field definitions for this board
269
+ * @param options - Optional viewId to scope fields to a specific view
270
+ */
271
+ getFields(options?: {
272
+ viewId?: string;
273
+ }): Promise<any>;
82
274
  }
83
275
  declare class Process {
84
- openForm(item: ProcessItem): any;
276
+ /**
277
+ * Get my items from this process (items I initiated)
278
+ * @param options - Query options (status, searchValue, pageNumber, pageSize, payload)
279
+ * @returns Promise containing items and total count
280
+ *
281
+ * @example
282
+ * const process = kf.app.getProcess("LeaveRequest");
283
+ * // Get draft items
284
+ * const { items } = await process.getMyItems({ status: "draft" });
285
+ * // Get in-progress items
286
+ * const { items } = await process.getMyItems({ status: "inprogress" });
287
+ */
288
+ getMyItems(options?: ProcessMyItemsOptions): Promise<ProcessQueryResponse>;
289
+ /**
290
+ * Get my pending tasks from this process (tasks assigned to me)
291
+ * @param options - Query options (activityId, searchValue, pageNumber, pageSize, payload)
292
+ * @returns Promise containing tasks and total count
293
+ *
294
+ * @example
295
+ * const process = kf.app.getProcess("LeaveRequest");
296
+ * // Get all pending tasks
297
+ * const { items } = await process.getMyTasksItems();
298
+ * // Get tasks for specific activity/step
299
+ * const { items } = await process.getMyTasksItems({ activityId: "Approval_Step" });
300
+ */
301
+ getMyTasksItems(options?: ProcessMyTasksOptions): Promise<ProcessQueryResponse>;
302
+ /**
303
+ * Get items I participated in (items where I took action)
304
+ * @param options - Query options (activityId, searchValue, pageNumber, pageSize, payload)
305
+ * @returns Promise containing items and total count
306
+ *
307
+ * @example
308
+ * const process = kf.app.getProcess("LeaveRequest");
309
+ * const { items } = await process.getParticipatedItems();
310
+ */
311
+ getParticipatedItems(options?: ProcessParticipatedOptions): Promise<ProcessQueryResponse>;
312
+ /**
313
+ * Get all items as admin (requires admin access)
314
+ * @param options - Query options (searchValue, pageNumber, pageSize, payload)
315
+ * @returns Promise containing items and total count
316
+ *
317
+ * @example
318
+ * const process = kf.app.getProcess("LeaveRequest");
319
+ * const { items } = await process.getAdminItems();
320
+ */
321
+ getAdminItems(options?: ProcessAdminOptions): Promise<ProcessQueryResponse>;
322
+ /**
323
+ * Get a single process instance by ID
324
+ * @param options - instanceId (required)
325
+ * @returns Promise containing the instance data
326
+ */
327
+ getItem(options: ProcessGetItemOptions): Promise<ProcessItem>;
328
+ /**
329
+ * Create a new process instance (start a new process)
330
+ * @param options - Creation options (data: initial field values)
331
+ * @returns Promise containing the newly created process item with _id and _activity_instance_id
332
+ *
333
+ * @example
334
+ * const process = kf.app.getProcess("LeaveRequest");
335
+ * const item = await process.createItem({ data: { LeaveType: "Annual" } });
336
+ */
337
+ createItem(options?: ProcessCreateItemOptions): Promise<ProcessItem>;
338
+ /**
339
+ * Update an existing process instance
340
+ * @param options - Update options (instanceId, activityInstanceId, data)
341
+ * @returns Promise containing the updated item
342
+ *
343
+ * @example
344
+ * const process = kf.app.getProcess("LeaveRequest");
345
+ * await process.updateItem({
346
+ * instanceId: "item_123",
347
+ * activityInstanceId: "activity_456",
348
+ * data: { LeaveType: "Sick" }
349
+ * });
350
+ */
351
+ updateItem(options: ProcessUpdateItemOptions): Promise<ProcessItem>;
352
+ /**
353
+ * Delete a process instance
354
+ * @param options - Delete options (instanceId)
355
+ * @returns Promise resolving on successful deletion
356
+ *
357
+ * @example
358
+ * const process = kf.app.getProcess("LeaveRequest");
359
+ * await process.deleteItem({ instanceId: "item_123" });
360
+ */
361
+ deleteItem(options: ProcessDeleteItemOptions): Promise<void>;
362
+ /**
363
+ * Open the form UI for a process instance
364
+ * @param item - Process item with _id and _activity_instance_id
365
+ */
366
+ openForm(item: ProcessItem): any;
367
+ /**
368
+ * Submit a process task
369
+ * @param options - instanceId, activityInstanceId, optional comment
370
+ *
371
+ * @example
372
+ * await process.submitItem({ instanceId: "item_123", activityInstanceId: "act_456" });
373
+ */
374
+ submitItem(options: ProcessSubmitItemOptions): Promise<void>;
375
+ /**
376
+ * Reject a process task
377
+ * @param options - instanceId, activityInstanceId, comment (required)
378
+ *
379
+ * @example
380
+ * await process.reject({ instanceId: "item_123", activityInstanceId: "act_456", comment: "Not approved" });
381
+ */
382
+ rejectItem(options: ProcessRejectItemOptions): Promise<void>;
383
+ /**
384
+ * Withdraw a process instance (initiator only)
385
+ * @param options - instanceId, optional comment
386
+ *
387
+ * @example
388
+ * await process.withdraw({ instanceId: "item_123", comment: "Withdrawing request" });
389
+ */
390
+ withdrawItem(options: ProcessWithdrawItemOptions): Promise<void>;
391
+ /**
392
+ * Send back a process task to a previous step
393
+ * @param options - instanceId, activityInstanceId, stepId (target step), comment (required)
394
+ *
395
+ * @example
396
+ * await process.sendback({ instanceId: "item_123", activityInstanceId: "act_456", stepId: "step_789", comment: "Please revise" });
397
+ */
398
+ sendbackItem(options: ProcessSendbackItemOptions): Promise<void>;
399
+ /**
400
+ * Reassign a process task to another user
401
+ * @param options - instanceId, activityInstanceId, reassignTo (user object), comment (required), optional reassignType and reassignedFrom
402
+ *
403
+ * @example
404
+ * await process.reassign({ instanceId: "item_123", activityInstanceId: "act_456", reassignTo: { _id: "user_789" }, comment: "Reassigning to manager" });
405
+ */
406
+ reassignItem(options: ProcessReassignItemOptions): Promise<void>;
407
+ /**
408
+ * Get list of eligible reassignees for a process task
409
+ * @param options - instanceId, activityInstanceId, optional pageNumber, pageSize, query
410
+ */
411
+ getReassignees(options: ProcessGetReassigneesOptions): Promise<any>;
412
+ /**
413
+ * Restart a rejected/withdrawn process instance
414
+ * @param options - instanceId, activityInstanceId
415
+ *
416
+ * @example
417
+ * await process.restart({ instanceId: "item_123", activityInstanceId: "act_456" });
418
+ */
419
+ restartItem(options: ProcessRestartItemOptions): Promise<void>;
420
+ /**
421
+ * Discard a draft process instance
422
+ * @param options - instanceId
423
+ *
424
+ * @example
425
+ * await process.discard({ instanceId: "item_123" });
426
+ */
427
+ discardItem(options: ProcessDiscardItemOptions): Promise<void>;
428
+ /**
429
+ * Get field definitions for this process
430
+ */
431
+ getFields(): Promise<any>;
432
+ /**
433
+ * Get field definitions for a specific task step (my tasks view)
434
+ * @param options - activityId of the target step
435
+ */
436
+ getMyTaskFields(options: {
437
+ activityId: string;
438
+ }): Promise<any>;
439
+ /**
440
+ * Get field definitions for a specific task step (participated view)
441
+ * @param options - activityId of the target step
442
+ */
443
+ getParticipatedFields(options: {
444
+ activityId: string;
445
+ }): Promise<any>;
446
+ /**
447
+ * Get field definitions for the my items view filtered by status
448
+ * @param options - status filter (e.g. "draft", "inprogress", "all")
449
+ */
450
+ getMyItemsFields(options: {
451
+ status: string;
452
+ }): Promise<any>;
453
+ /**
454
+ * Get the progress/timeline of a process instance
455
+ * @param options - instanceId (required)
456
+ */
457
+ getProgress(options: {
458
+ instanceId: string;
459
+ }): Promise<any>;
85
460
  }
86
461
  declare class Application {
87
462
  page: Page
@@ -105,6 +480,45 @@ declare class kf {
105
480
  static eventParameters: any
106
481
  static api(url: string, args?: FetchOptions): Promise<any>;
107
482
  }
483
+ // ============================================
484
+ // Shared Base Types
485
+ // ============================================
486
+
487
+ declare type QueryResponse = {
488
+ items: any[];
489
+ total: number;
490
+ page?: number;
491
+ pageSize?: number;
492
+ };
493
+
494
+ declare type BaseQueryOptions = {
495
+ searchValue?: string;
496
+ pageNumber?: number;
497
+ pageSize?: number;
498
+ };
499
+
500
+ declare type PayloadSortItem = {
501
+ Id: string;
502
+ SortType: "ASC" | "DESC";
503
+ };
504
+
505
+ declare type PayloadOptions = {
506
+ Columns?: any[];
507
+ Filters?: any;
508
+ Sort?: PayloadSortItem[];
509
+ FilterParam?: any;
510
+ };
511
+
512
+ declare type ProcessPayloadOptions = {
513
+ Columns?: any[];
514
+ Filters?: any;
515
+ Sort?: PayloadSortItem[];
516
+ };
517
+
518
+ // ============================================
519
+ // Core Types
520
+ // ============================================
521
+
108
522
  declare type userObject = {
109
523
  _id: string;
110
524
  Name: string;
@@ -136,13 +550,189 @@ declare type DataformItem = {
136
550
  _id: string;
137
551
  };
138
552
 
553
+
139
554
  declare type ProcessItem = {
140
555
  _id: string;
141
556
  _activity_instance_id: string;
142
557
  };
143
558
 
559
+ // ============================================
560
+ // Process Types
561
+ // ============================================
562
+
563
+ declare type ProcessMyItemsOptions = BaseQueryOptions & {
564
+ status?: "draft" | "inprogress" | "completed" | "withdrawn" | "rejected" | "all";
565
+ payload?: ProcessPayloadOptions;
566
+ };
567
+
568
+ declare type ProcessMyTasksOptions = BaseQueryOptions & {
569
+ activityId?: string;
570
+ payload?: ProcessPayloadOptions;
571
+ };
572
+
573
+ declare type ProcessParticipatedOptions = BaseQueryOptions & {
574
+ activityId?: string;
575
+ payload?: ProcessPayloadOptions;
576
+ };
577
+
578
+ declare type ProcessAdminOptions = BaseQueryOptions & {
579
+ payload?: ProcessPayloadOptions;
580
+ };
581
+
582
+ declare type ProcessQueryResponse = QueryResponse;
583
+
584
+ declare type ProcessGetItemOptions = {
585
+ instanceId: string;
586
+ };
587
+
588
+ declare type ProcessCreateItemOptions = {
589
+ data?: object;
590
+ };
591
+
592
+ declare type ProcessUpdateItemOptions = {
593
+ instanceId: string;
594
+ activityInstanceId: string;
595
+ data: object;
596
+ };
597
+
598
+ declare type ProcessDeleteItemOptions = {
599
+ instanceId: string;
600
+ };
601
+
602
+ declare type ProcessSubmitItemOptions = {
603
+ instanceId: string;
604
+ activityInstanceId: string;
605
+ comment?: string;
606
+ };
607
+
608
+ declare type ProcessRejectItemOptions = {
609
+ instanceId: string;
610
+ activityInstanceId: string;
611
+ comment: string;
612
+ };
613
+
614
+ declare type ProcessWithdrawItemOptions = {
615
+ instanceId: string;
616
+ comment?: string;
617
+ };
618
+
619
+ declare type ProcessSendbackItemOptions = {
620
+ instanceId: string;
621
+ activityInstanceId: string;
622
+ stepId: string;
623
+ comment: string;
624
+ };
625
+
626
+ declare type ProcessReassignItemOptions = {
627
+ instanceId: string;
628
+ activityInstanceId: string;
629
+ reassignTo: object;
630
+ comment: string;
631
+ reassignType?: "initiator" | "approver" | "admin";
632
+ reassignedFrom?: object[];
633
+ };
634
+
635
+ declare type ProcessGetReassigneesOptions = {
636
+ instanceId: string;
637
+ activityInstanceId: string;
638
+ pageNumber?: number;
639
+ pageSize?: number;
640
+ query?: string;
641
+ };
642
+
643
+ declare type ProcessRestartItemOptions = {
644
+ instanceId: string;
645
+ activityInstanceId: string;
646
+ };
647
+
648
+ declare type ProcessDiscardItemOptions = {
649
+ instanceId: string;
650
+ };
651
+
144
652
  declare type FetchOptions = {
145
653
  method?: string;
146
654
  body?: string | object;
147
655
  headers?: object;
148
656
  };
657
+
658
+ // ============================================
659
+ // Dataform Types
660
+ // ============================================
661
+
662
+ declare type DataformQueryOptions = BaseQueryOptions & {
663
+ viewId?: string;
664
+ payload?: PayloadOptions;
665
+ };
666
+
667
+ declare type DataformQueryResponse = QueryResponse;
668
+
669
+ declare type DataformCreateItemOptions = {
670
+ data?: object;
671
+ viewId?: string;
672
+ };
673
+
674
+ declare type DataformUpdateItemOptions = {
675
+ itemId: string; // Required: the _id of the item to update
676
+ data: object; // Required: the updated field values
677
+ viewId?: string; // Optional: view ID for view-specific update
678
+ };
679
+
680
+ declare type DataformGetItemOptions = {
681
+ itemId: string;
682
+ viewId?: string;
683
+ };
684
+
685
+ declare type DataformDeleteItemOptions = {
686
+ itemId: string;
687
+ viewId?: string;
688
+ };
689
+
690
+ declare type DataformDiscardItemOptions = {
691
+ viewId?: string;
692
+ };
693
+
694
+ declare type DataformSubmitItemOptions = {
695
+ itemId: string;
696
+ data?: object;
697
+ viewId?: string;
698
+ };
699
+
700
+ // ============================================
701
+ // Board Types
702
+ // ============================================
703
+
704
+ declare type BoardGetItemsOptions = BaseQueryOptions & {
705
+ viewId?: string;
706
+ payload?: PayloadOptions;
707
+ };
708
+
709
+ declare type BoardQueryResponse = QueryResponse;
710
+
711
+ declare type BoardGetItemOptions = {
712
+ instanceId: string;
713
+ };
714
+
715
+ declare type BoardCreateItemOptions = {
716
+ data?: object;
717
+ };
718
+
719
+ declare type BoardUpdateItemOptions = {
720
+ instanceId: string; // Required: the _id of the item to update
721
+ data: object; // Required: the updated field values
722
+ };
723
+
724
+ declare type BoardDeleteItemOptions = {
725
+ instanceId: string; // Required: the _id of the item to delete
726
+ };
727
+
728
+ declare type BoardSubmitItemOptions = {
729
+ instanceId: string;
730
+ comment?: string;
731
+ };
732
+
733
+ declare type BoardDiscardItemOptions = {
734
+ instanceId: string;
735
+ };
736
+
737
+
738
+