@kissflow/lowcode-client-sdk 1.0.43 → 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.
@@ -1,9 +1,14 @@
1
1
 
2
2
  declare class Form {
3
3
  type: string
4
+ instanceId: string
5
+ activityInstanceId: string
4
6
  toJSON(): any;
5
7
  getField(fieldId: string): any;
6
8
  updateField(args: object): any;
9
+ getValidationErrors(): any;
10
+ getFormConfiguration(): any;
11
+ getFieldState(): any;
7
12
  getTable(tableId: string): Table;
8
13
  }
9
14
  declare class Table {
@@ -87,6 +92,121 @@ declare class Client {
87
92
  * document.querySelector("#avatar").src = dataUrl;
88
93
  */
89
94
  getImageUrl(imageValue: Record<string, unknown>): any;
95
+ /**
96
+ * Open the platform's file picker, upload the selected file(s), and resolve
97
+ * with their metadata.
98
+ *
99
+ * Custom components (iframes) cannot access the platform's authenticated upload
100
+ * endpoints directly. This method opens the file picker in the parent window
101
+ * (which has the required session), runs the full select → upload flow, and
102
+ * resolves once all uploads settle with an array of the uploaded files'
103
+ * metadata (each including `key`, `name`, `size`, `photos`, etc. — the same
104
+ * shape consumed by `getImageUrl`).
105
+ *
106
+ * Always resolves with an array — a single-element array for single-file
107
+ * pickers (e.g. `maxCount: 1` for `Image`), one entry per uploaded file for
108
+ * multi-file pickers (e.g. `Attachment`). Resolves with `[]` if the user closes
109
+ * the picker without completing any upload.
110
+ *
111
+ * @param options - File picker configuration (e.g. `fileExtensions`, `maxSize`,
112
+ * `maxCount`, `imageProps`).
113
+ * @returns A promise that resolves with an array of uploaded file metadata
114
+ * objects (empty if the picker was closed without uploading anything).
115
+ *
116
+ * @example
117
+ * const files = await kf.client.openFilePicker({ fileExtensions: ["JPG", "PNG"] });
118
+ * if (files.length) onChange(files[0]); // single-file consumer (Image)
119
+ *
120
+ * @example
121
+ * const files = await kf.client.openFilePicker({ maxCount: 10 });
122
+ * if (files.length) onChange([...existing, ...files]); // multi-file consumer (Attachment)
123
+ */
124
+ openFilePicker(options: FilePickerOptions): any;
125
+ /**
126
+ * Open the platform's barcode/QR scanner and resolve with the decoded text.
127
+ *
128
+ * The scanner UI (camera stream + decoding) runs in the parent window, which
129
+ * owns the camera permission — the iframe itself never accesses the camera.
130
+ * Camera-permission prompts and denials are handled inside the scanner UI;
131
+ * they are not surfaced as errors here.
132
+ *
133
+ * Resolves with `null` if the user closes the scanner without a successful
134
+ * scan (including the scanner's own inactivity timeout).
135
+ *
136
+ * Note: currently supported in web custom app UIs; the mobile (PWA) custom
137
+ * UI does not host the scanner portal yet.
138
+ *
139
+ * @param options - Scanner configuration (e.g. `localFileScan` to allow
140
+ * decoding from an uploaded image instead of the camera).
141
+ * @returns A promise that resolves with the decoded string, or `null` if the
142
+ * scanner was closed without scanning.
143
+ *
144
+ * @example
145
+ * const code = await kf.client.openScanner({ localFileScan: true });
146
+ * if (code) onChange(code);
147
+ */
148
+ openScanner(options?: ScannerOptions): any;
149
+ /**
150
+ * Open the platform's native Geolocation map picker (search, current-location
151
+ * detection, marker drag, reverse-geocoding) in a modal over the custom
152
+ * form/component. Runs in the parent window, which owns the Google Maps API
153
+ * key — the iframe itself never needs one.
154
+ *
155
+ * Resolves with `null` if the user closes the picker without selecting a
156
+ * location.
157
+ *
158
+ * @param value - Optional current geolocation value to pre-select on the map.
159
+ * @returns A promise that resolves with the picked location object, or
160
+ * `null` if the picker was closed without a selection.
161
+ *
162
+ * @example
163
+ * const location = await kf.client.pickLocation();
164
+ * if (location) onChange(location);
165
+ */
166
+ pickLocation(value?: GeolocationValue): any;
167
+ /**
168
+ * Upload a File object to Kissflow's S3 storage and resolve with its metadata.
169
+ *
170
+ * Use this when you have a File/Blob already in memory (e.g. a canvas drawing
171
+ * converted to a PNG blob) and need to upload it without opening a file picker UI.
172
+ * The platform runs the upload in the parent window (which has the required session)
173
+ * and resolves with the uploaded file's `{ key, name, ... }` metadata — the same
174
+ * shape returned by `openFilePicker`.
175
+ *
176
+ * Resolves with `null` if the upload fails.
177
+ *
178
+ * @param file - The File or Blob to upload.
179
+ * @param fileName - Optional file name override (defaults to `file.name`).
180
+ * @returns A promise that resolves with the uploaded file metadata, or `null` on failure.
181
+ *
182
+ * @example
183
+ * const blob = await new Promise<Blob>(res => canvas.toBlob(res, 'image/png'));
184
+ * const file = new File([blob], 'signature.png', { type: 'image/png' });
185
+ * const result = await kf.client.uploadFile(file);
186
+ * if (result) onChange(result);
187
+ */
188
+ uploadFile(file: UploadableFile, fileName?: string): any;
189
+ /**
190
+ * Open the platform's file preview (lightbox) for one or more files.
191
+ *
192
+ * `files` always accepts an array — pass a single-element array for fields like
193
+ * `Image`, or the full list for multi-file fields like `Attachment`. The host's
194
+ * preview UI natively renders next/prev navigation across the array; the SDK
195
+ * just passes the file list through, no extra navigation surface is needed here.
196
+ *
197
+ * @param args - Preview configuration.
198
+ * @param args.files - Array of file metadata objects to preview.
199
+ * @param args.indexOfFile - Index of the file to open the preview on (default: 0).
200
+ * @returns A promise that resolves once the user closes the preview.
201
+ *
202
+ * @example
203
+ * await kf.client.openFilePreview({ files: [imageFieldValue] });
204
+ * await kf.client.openFilePreview({ files: attachmentFieldValue, indexOfFile: 2 });
205
+ */
206
+ openFilePreview(args: {
207
+ files: Record<string, unknown>[];
208
+ indexOfFile?: number;
209
+ }): any;
90
210
  }
91
211
  declare class Formatter {
92
212
  toDate(date: string): any;
@@ -109,34 +229,34 @@ declare class kf {
109
229
  // ============================================
110
230
 
111
231
  declare type QueryResponse = {
112
- items: any[];
113
- total: number;
114
- page?: number;
115
- pageSize?: number;
232
+ items: any[];
233
+ total: number;
234
+ page?: number;
235
+ pageSize?: number;
116
236
  };
117
237
 
118
238
  declare type BaseQueryOptions = {
119
- searchValue?: string;
120
- pageNumber?: number;
121
- pageSize?: number;
239
+ searchValue?: string;
240
+ pageNumber?: number;
241
+ pageSize?: number;
122
242
  };
123
243
 
124
244
  declare type PayloadSortItem = {
125
- Id: string;
126
- SortType: "ASC" | "DESC";
245
+ Id: string;
246
+ SortType: "ASC" | "DESC";
127
247
  };
128
248
 
129
249
  declare type PayloadOptions = {
130
- Columns?: any[];
131
- Filters?: any;
132
- Sort?: PayloadSortItem[];
133
- FilterParam?: any;
250
+ Columns?: any[];
251
+ Filters?: any;
252
+ Sort?: PayloadSortItem[];
253
+ FilterParam?: any;
134
254
  };
135
255
 
136
256
  declare type ProcessPayloadOptions = {
137
- Columns?: any[];
138
- Filters?: any;
139
- Sort?: PayloadSortItem[];
257
+ Columns?: any[];
258
+ Filters?: any;
259
+ Sort?: PayloadSortItem[];
140
260
  };
141
261
 
142
262
  // ============================================
@@ -144,43 +264,59 @@ declare type ProcessPayloadOptions = {
144
264
  // ============================================
145
265
 
146
266
  declare type userObject = {
147
- _id: string;
148
- Name: string;
149
- Email: string;
150
- /** @deprecated Use AppRoles instead. */
151
- Role: string;
152
- AppRoles: rolesObject[];
267
+ _id: string;
268
+ Name: string;
269
+ Email: string;
270
+ /** @deprecated Use AppRoles instead. */
271
+ Role: string;
272
+ AppRoles: rolesObject[];
153
273
  };
154
274
 
155
275
  declare type rolesObject = {
156
- _id: string;
157
- Name: string;
276
+ _id: string;
277
+ Name: string;
158
278
  };
159
279
 
160
280
  declare type accountObject = {
161
- _id: string;
281
+ _id: string;
162
282
  };
163
283
 
164
284
  declare type environmentObject = {
165
- isMobile: boolean;
285
+ isMobile: boolean;
166
286
  };
167
287
 
168
288
  declare type BoardItem = {
169
- fullscreen?: boolean;
170
- _id: string;
171
- _view_id: string;
289
+ _id: string;
290
+ _view_id: string;
172
291
  };
173
292
 
174
293
  declare type DataformItem = {
175
- fullscreen?: boolean;
176
- _id: string;
294
+ _id: string;
295
+ _view_id?: string;
177
296
  };
178
297
 
179
-
180
298
  declare type ProcessItem = {
181
- fullscreen?: boolean;
182
- _id: string;
183
- _activity_instance_id: string;
299
+ _id: string;
300
+ _activity_instance_id: string;
301
+ };
302
+
303
+ // ============================================
304
+ // Form Field Value Types
305
+ // ============================================
306
+
307
+ // The value shape a Geolocation field is stored/read as across the platform
308
+ // (native forms and custom forms alike) — Latitude/Longitude are stringified
309
+ // on save, matching the native Geolocation field's saved representation.
310
+ declare type GeolocationValue = {
311
+ Address?: string;
312
+ Latitude: string;
313
+ Longitude: string;
314
+ City?: string;
315
+ State?: string;
316
+ Country?: string;
317
+ ZipCode?: string;
318
+ Area?: string;
319
+ PlaceId?: string;
184
320
  };
185
321
 
186
322
  // ============================================
@@ -188,98 +324,144 @@ declare type ProcessItem = {
188
324
  // ============================================
189
325
 
190
326
  declare type ProcessMyItemsOptions = BaseQueryOptions & {
191
- status?: "draft" | "inprogress" | "completed" | "withdrawn" | "rejected" | "all";
192
- payload?: ProcessPayloadOptions;
327
+ status?:
328
+ | "draft"
329
+ | "inprogress"
330
+ | "completed"
331
+ | "withdrawn"
332
+ | "rejected"
333
+ | "all";
334
+ payload?: ProcessPayloadOptions;
193
335
  };
194
336
 
195
337
  declare type ProcessMyTasksOptions = BaseQueryOptions & {
196
- activityId?: string;
197
- payload?: ProcessPayloadOptions;
338
+ activityId?: string;
339
+ payload?: ProcessPayloadOptions;
198
340
  };
199
341
 
200
342
  declare type ProcessParticipatedOptions = BaseQueryOptions & {
201
- activityId?: string;
202
- payload?: ProcessPayloadOptions;
343
+ activityId?: string;
344
+ payload?: ProcessPayloadOptions;
203
345
  };
204
346
 
205
347
  declare type ProcessAdminOptions = BaseQueryOptions & {
206
- payload?: ProcessPayloadOptions;
348
+ payload?: ProcessPayloadOptions;
207
349
  };
208
350
 
209
351
  declare type ProcessQueryResponse = QueryResponse;
210
352
 
211
353
  declare type ProcessGetItemOptions = {
212
- instanceId: string;
354
+ instanceId: string;
355
+ activityInstanceId: string;
213
356
  };
214
357
 
215
358
  declare type ProcessCreateItemOptions = {
216
- data?: object;
359
+ data?: object;
217
360
  };
218
361
 
219
362
  declare type ProcessUpdateItemOptions = {
220
- instanceId: string;
221
- activityInstanceId: string;
222
- data: object;
363
+ instanceId: string;
364
+ activityInstanceId: string;
365
+ data: object;
223
366
  };
224
367
 
225
368
  declare type ProcessDeleteItemOptions = {
226
- instanceId: string;
369
+ instanceId: string;
370
+ };
371
+
372
+ declare type ProcessGetAdminItemOptions = {
373
+ instanceId: string;
374
+ };
375
+
376
+ declare type ProcessUpdateAdminItemOptions = {
377
+ instanceId: string;
378
+ data: object;
227
379
  };
228
380
 
229
381
  declare type ProcessSubmitItemOptions = {
230
- instanceId: string;
231
- activityInstanceId: string;
232
- comment?: string;
382
+ instanceId: string;
383
+ activityInstanceId: string;
384
+ comment?: string;
233
385
  };
234
386
 
235
387
  declare type ProcessRejectItemOptions = {
236
- instanceId: string;
237
- activityInstanceId: string;
238
- comment: string;
388
+ instanceId: string;
389
+ activityInstanceId: string;
390
+ comment: string;
239
391
  };
240
392
 
241
393
  declare type ProcessWithdrawItemOptions = {
242
- instanceId: string;
243
- comment?: string;
394
+ instanceId: string;
395
+ comment?: string;
244
396
  };
245
397
 
246
398
  declare type ProcessSendbackItemOptions = {
247
- instanceId: string;
248
- activityInstanceId: string;
249
- stepId: string;
250
- comment: string;
399
+ instanceId: string;
400
+ activityInstanceId: string;
401
+ stepId: string;
402
+ comment: string;
251
403
  };
252
404
 
253
405
  declare type ProcessReassignItemOptions = {
254
- instanceId: string;
255
- activityInstanceId: string;
256
- reassignTo: object;
257
- comment: string;
258
- reassignType?: "initiator" | "approver" | "admin";
259
- reassignedFrom?: object[];
406
+ instanceId: string;
407
+ activityInstanceId: string;
408
+ reassignTo: object;
409
+ comment: string;
410
+ reassignType?: "initiator" | "approver" | "admin";
411
+ reassignedFrom?: object[];
260
412
  };
261
413
 
262
414
  declare type ProcessGetReassigneesOptions = {
263
- instanceId: string;
264
- activityInstanceId: string;
265
- pageNumber?: number;
266
- pageSize?: number;
267
- query?: string;
415
+ instanceId: string;
416
+ activityInstanceId: string;
417
+ pageNumber?: number;
418
+ pageSize?: number;
419
+ query?: string;
268
420
  };
269
421
 
270
422
  declare type ProcessRestartItemOptions = {
271
- instanceId: string;
272
- activityInstanceId: string;
423
+ instanceId: string;
424
+ activityInstanceId: string;
273
425
  };
274
426
 
275
427
  declare type ProcessDiscardItemOptions = {
276
- instanceId: string;
428
+ instanceId: string;
429
+ };
430
+
431
+ declare type ProcessFieldOptions = {
432
+ instanceId: string;
433
+ activityInstanceId: string;
434
+ fieldId: string;
435
+ /** Skip the server-side model lookup by supplying the field's type directly. */
436
+ fieldType?: string;
437
+ tableId?: string;
438
+ tableRowId?: string;
439
+ };
440
+
441
+ declare type ProcessAttachmentFile = {
442
+ id: string;
443
+ name: string;
444
+ key: string;
445
+ size?: number;
446
+ fileExtension?: string;
447
+ };
448
+
449
+ declare type ProcessParseAttachmentOptions = {
450
+ instanceId: string; // form.instanceId (process record id)
451
+ activityInstanceId: string;
452
+ fieldId: string;
453
+ file: ProcessAttachmentFile;
454
+ };
455
+
456
+ declare type ProcessAttachmentParseResult = {
457
+ appliedFields: string[]; // field IDs auto-filled into the form store
458
+ suggestedBy: string; // name of the parsed file
277
459
  };
278
460
 
279
461
  declare type FetchOptions = {
280
- method?: string;
281
- body?: string | object;
282
- headers?: object;
462
+ method?: string;
463
+ body?: string | object;
464
+ headers?: object;
283
465
  };
284
466
 
285
467
  // ============================================
@@ -287,41 +469,50 @@ declare type FetchOptions = {
287
469
  // ============================================
288
470
 
289
471
  declare type DataformQueryOptions = BaseQueryOptions & {
290
- viewId?: string;
291
- payload?: PayloadOptions;
472
+ viewId?: string;
473
+ payload?: PayloadOptions;
292
474
  };
293
475
 
294
476
  declare type DataformQueryResponse = QueryResponse;
295
477
 
296
478
  declare type DataformCreateItemOptions = {
297
- data?: object;
298
- viewId?: string;
479
+ data?: object;
480
+ viewId?: string;
299
481
  };
300
482
 
301
483
  declare type DataformUpdateItemOptions = {
302
- itemId: string; // Required: the _id of the item to update
303
- data: object; // Required: the updated field values
304
- viewId?: string; // Optional: view ID for view-specific update
484
+ itemId: string; // Required: the _id of the item to update
485
+ data: object; // Required: the updated field values
486
+ viewId?: string; // Optional: view ID for view-specific update
305
487
  };
306
488
 
307
489
  declare type DataformGetItemOptions = {
308
- itemId: string;
309
- viewId?: string;
490
+ itemId: string;
491
+ viewId?: string;
310
492
  };
311
493
 
312
494
  declare type DataformDeleteItemOptions = {
313
- itemId: string;
314
- viewId?: string;
495
+ itemId: string;
496
+ viewId?: string;
315
497
  };
316
498
 
317
499
  declare type DataformDiscardItemOptions = {
318
- viewId?: string;
500
+ viewId?: string;
319
501
  };
320
502
 
321
503
  declare type DataformSubmitItemOptions = {
322
- itemId: string;
323
- data?: object;
324
- viewId?: string;
504
+ itemId: string;
505
+ data?: object;
506
+ viewId?: string;
507
+ };
508
+
509
+ declare type DataformFieldOptions = {
510
+ instanceId: string;
511
+ fieldId: string;
512
+ /** Skip the server-side model lookup by supplying the field's type directly. */
513
+ fieldType?: string;
514
+ tableId?: string;
515
+ tableRowId?: string;
325
516
  };
326
517
 
327
518
  // ============================================
@@ -329,37 +520,43 @@ declare type DataformSubmitItemOptions = {
329
520
  // ============================================
330
521
 
331
522
  declare type BoardGetItemsOptions = BaseQueryOptions & {
332
- viewId?: string;
333
- payload?: PayloadOptions;
523
+ viewId?: string;
524
+ payload?: PayloadOptions;
334
525
  };
335
526
 
336
527
  declare type BoardQueryResponse = QueryResponse;
337
528
 
338
529
  declare type BoardGetItemOptions = {
339
- instanceId: string;
530
+ instanceId: string;
340
531
  };
341
532
 
342
533
  declare type BoardCreateItemOptions = {
343
- data?: object;
534
+ data?: object;
344
535
  };
345
536
 
346
537
  declare type BoardUpdateItemOptions = {
347
- instanceId: string; // Required: the _id of the item to update
348
- data: object; // Required: the updated field values
538
+ instanceId: string; // Required: the _id of the item to update
539
+ data: object; // Required: the updated field values
349
540
  };
350
541
 
351
542
  declare type BoardDeleteItemOptions = {
352
- instanceId: string; // Required: the _id of the item to delete
543
+ instanceId: string; // Required: the _id of the item to delete
353
544
  };
354
545
 
355
546
  declare type BoardSubmitItemOptions = {
356
- instanceId: string;
357
- comment?: string;
547
+ instanceId: string;
548
+ comment?: string;
358
549
  };
359
550
 
360
551
  declare type BoardDiscardItemOptions = {
361
- instanceId: string;
552
+ instanceId: string;
362
553
  };
363
554
 
364
-
365
-
555
+ declare type BoardFieldOptions = {
556
+ instanceId: string;
557
+ fieldId: string;
558
+ /** Skip the server-side model lookup by supplying the field's type directly. */
559
+ fieldType?: string;
560
+ tableId?: string;
561
+ tableRowId?: string;
562
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kissflow/lowcode-client-sdk",
3
- "version": "1.0.43",
3
+ "version": "1.0.49",
4
4
  "description": "JavaScript SDK for developing over the Kissflow lowcode platform",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -17,6 +17,9 @@
17
17
  "import": "./dist/kf.lowcodeworkersdk.es.js"
18
18
  }
19
19
  },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
20
23
  "repository": {
21
24
  "type": "git",
22
25
  "url": "git+https://github.com/kissflow/lcnc-sdk-js.git"