@bluprynt/forms-core 4.0.1 → 4.1.0

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/README.md CHANGED
@@ -71,11 +71,22 @@ editor
71
71
  .addArrayItem(6, 'React')
72
72
  .setSubmittedAt('2025-01-01T00:00:00Z')
73
73
 
74
- // 3. Validate and extract the document
74
+ // 3. Optionally record and resolve machine-proposed answers
75
+ editor
76
+ .setSuggestion(1, { value: 'Alice Smith', confidence: 0.8, source: 'Passport MRZ, line 2' })
77
+ .acceptSuggestion(1) // copies the value across, keeps the suggestion
78
+ .rejectSuggestion(2) // removes a suggestion, leaves the value untouched
79
+
80
+ // 4. Validate and extract the document
75
81
  const result = editor.validate()
76
82
  const doc = editor.toJSON()
77
83
  ```
78
84
 
85
+ Suggestions live in the document's optional `suggestions` block and never affect validation or
86
+ visibility. `confidence` is a `0..1` fraction. Both the block and the three metadata properties
87
+ (`placeholder`, `answer_guidelines`, `reference_id`) on fields and sections are optional, so existing
88
+ definitions and documents keep working unchanged.
89
+
79
90
  ## Documentation
80
91
 
81
92
  | Document | Description |
@@ -123,6 +123,13 @@
123
123
  },
124
124
  "additionalProperties": false
125
125
  },
126
+ "multiselectValidation": {
127
+ "type": "object",
128
+ "properties": {
129
+ "required": { "type": "boolean" }
130
+ },
131
+ "additionalProperties": false
132
+ },
126
133
  "arrayValidation": {
127
134
  "type": "object",
128
135
  "properties": {
@@ -131,6 +138,14 @@
131
138
  },
132
139
  "additionalProperties": false
133
140
  },
141
+ "arrayObjValidation": {
142
+ "type": "object",
143
+ "properties": {
144
+ "minItems": { "type": "integer", "minimum": 0 },
145
+ "maxItems": { "type": "integer", "minimum": 1 }
146
+ },
147
+ "additionalProperties": false
148
+ },
134
149
  "fileValidation": {
135
150
  "type": "object",
136
151
  "properties": {
@@ -138,6 +153,20 @@
138
153
  },
139
154
  "additionalProperties": false
140
155
  },
156
+ "blockchainValidation": {
157
+ "type": "object",
158
+ "properties": {
159
+ "required": { "type": "boolean" }
160
+ },
161
+ "additionalProperties": false
162
+ },
163
+ "sustainabilityValidation": {
164
+ "type": "object",
165
+ "properties": {
166
+ "required": { "type": "boolean" }
167
+ },
168
+ "additionalProperties": false
169
+ },
141
170
 
142
171
  "selectOption": {
143
172
  "type": "object",
@@ -156,6 +185,9 @@
156
185
  "type": { "const": "string" },
157
186
  "label": { "type": "string" },
158
187
  "description": { "type": "string" },
188
+ "placeholder": { "type": "string" },
189
+ "answer_guidelines": { "type": "string" },
190
+ "reference_id": { "type": "string" },
159
191
  "validation": { "$ref": "#/$defs/stringValidation" }
160
192
  },
161
193
  "additionalProperties": false
@@ -167,6 +199,9 @@
167
199
  "type": { "const": "number" },
168
200
  "label": { "type": "string" },
169
201
  "description": { "type": "string" },
202
+ "placeholder": { "type": "string" },
203
+ "answer_guidelines": { "type": "string" },
204
+ "reference_id": { "type": "string" },
170
205
  "validation": { "$ref": "#/$defs/numberValidation" }
171
206
  },
172
207
  "additionalProperties": false
@@ -178,6 +213,9 @@
178
213
  "type": { "const": "boolean" },
179
214
  "label": { "type": "string" },
180
215
  "description": { "type": "string" },
216
+ "placeholder": { "type": "string" },
217
+ "answer_guidelines": { "type": "string" },
218
+ "reference_id": { "type": "string" },
181
219
  "validation": { "$ref": "#/$defs/booleanValidation" }
182
220
  },
183
221
  "additionalProperties": false
@@ -189,6 +227,9 @@
189
227
  "type": { "const": "date" },
190
228
  "label": { "type": "string" },
191
229
  "description": { "type": "string" },
230
+ "placeholder": { "type": "string" },
231
+ "answer_guidelines": { "type": "string" },
232
+ "reference_id": { "type": "string" },
192
233
  "validation": { "$ref": "#/$defs/dateValidation" }
193
234
  },
194
235
  "additionalProperties": false
@@ -200,6 +241,9 @@
200
241
  "type": { "const": "select" },
201
242
  "label": { "type": "string" },
202
243
  "description": { "type": "string" },
244
+ "placeholder": { "type": "string" },
245
+ "answer_guidelines": { "type": "string" },
246
+ "reference_id": { "type": "string" },
203
247
  "options": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/selectOption" } },
204
248
  "validation": { "$ref": "#/$defs/selectValidation" }
205
249
  },
@@ -212,10 +256,70 @@
212
256
  "type": { "const": "file" },
213
257
  "label": { "type": "string" },
214
258
  "description": { "type": "string" },
259
+ "placeholder": { "type": "string" },
260
+ "answer_guidelines": { "type": "string" },
261
+ "reference_id": { "type": "string" },
215
262
  "validation": { "$ref": "#/$defs/fileValidation" }
216
263
  },
217
264
  "additionalProperties": false
218
265
  },
266
+ "arrayItemBlockchain": {
267
+ "type": "object",
268
+ "required": ["type", "label"],
269
+ "properties": {
270
+ "type": { "const": "blockchain" },
271
+ "label": { "type": "string" },
272
+ "description": { "type": "string" },
273
+ "placeholder": { "type": "string" },
274
+ "answer_guidelines": { "type": "string" },
275
+ "reference_id": { "type": "string" },
276
+ "validation": { "$ref": "#/$defs/blockchainValidation" }
277
+ },
278
+ "additionalProperties": false
279
+ },
280
+ "arrayItemSustainability": {
281
+ "type": "object",
282
+ "required": ["type", "label"],
283
+ "properties": {
284
+ "type": { "const": "sustainability" },
285
+ "label": { "type": "string" },
286
+ "description": { "type": "string" },
287
+ "placeholder": { "type": "string" },
288
+ "answer_guidelines": { "type": "string" },
289
+ "reference_id": { "type": "string" },
290
+ "validation": { "$ref": "#/$defs/sustainabilityValidation" }
291
+ },
292
+ "additionalProperties": false
293
+ },
294
+ "arrayItemMultiselect": {
295
+ "type": "object",
296
+ "required": ["type", "label", "options"],
297
+ "properties": {
298
+ "type": { "const": "multiselect" },
299
+ "label": { "type": "string" },
300
+ "description": { "type": "string" },
301
+ "placeholder": { "type": "string" },
302
+ "answer_guidelines": { "type": "string" },
303
+ "reference_id": { "type": "string" },
304
+ "options": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/selectOption" } },
305
+ "validation": { "$ref": "#/$defs/multiselectValidation" }
306
+ },
307
+ "additionalProperties": false
308
+ },
309
+ "arrayItemStatic": {
310
+ "type": "object",
311
+ "required": ["type", "text"],
312
+ "properties": {
313
+ "type": { "const": "static" },
314
+ "text": { "type": "string" },
315
+ "label": { "type": "string" },
316
+ "description": { "type": "string" },
317
+ "placeholder": { "type": "string" },
318
+ "answer_guidelines": { "type": "string" },
319
+ "reference_id": { "type": "string" }
320
+ },
321
+ "additionalProperties": false
322
+ },
219
323
  "arrayItem": {
220
324
  "oneOf": [
221
325
  { "$ref": "#/$defs/arrayItemString" },
@@ -223,7 +327,177 @@
223
327
  { "$ref": "#/$defs/arrayItemBoolean" },
224
328
  { "$ref": "#/$defs/arrayItemDate" },
225
329
  { "$ref": "#/$defs/arrayItemSelect" },
226
- { "$ref": "#/$defs/arrayItemFile" }
330
+ { "$ref": "#/$defs/arrayItemFile" },
331
+ { "$ref": "#/$defs/arrayItemBlockchain" },
332
+ { "$ref": "#/$defs/arrayItemSustainability" },
333
+ { "$ref": "#/$defs/arrayItemMultiselect" },
334
+ { "$ref": "#/$defs/arrayItemStatic" }
335
+ ]
336
+ },
337
+ "arrayObjItemString": {
338
+ "type": "object",
339
+ "required": ["id", "type", "label"],
340
+ "properties": {
341
+ "id": { "type": "integer", "minimum": 1 },
342
+ "type": { "const": "string" },
343
+ "label": { "type": "string" },
344
+ "description": { "type": "string" },
345
+ "placeholder": { "type": "string" },
346
+ "answer_guidelines": { "type": "string" },
347
+ "reference_id": { "type": "string" },
348
+ "validation": { "$ref": "#/$defs/stringValidation" }
349
+ },
350
+ "additionalProperties": false
351
+ },
352
+ "arrayObjItemNumber": {
353
+ "type": "object",
354
+ "required": ["id", "type", "label"],
355
+ "properties": {
356
+ "id": { "type": "integer", "minimum": 1 },
357
+ "type": { "const": "number" },
358
+ "label": { "type": "string" },
359
+ "description": { "type": "string" },
360
+ "placeholder": { "type": "string" },
361
+ "answer_guidelines": { "type": "string" },
362
+ "reference_id": { "type": "string" },
363
+ "validation": { "$ref": "#/$defs/numberValidation" }
364
+ },
365
+ "additionalProperties": false
366
+ },
367
+ "arrayObjItemBoolean": {
368
+ "type": "object",
369
+ "required": ["id", "type", "label"],
370
+ "properties": {
371
+ "id": { "type": "integer", "minimum": 1 },
372
+ "type": { "const": "boolean" },
373
+ "label": { "type": "string" },
374
+ "description": { "type": "string" },
375
+ "placeholder": { "type": "string" },
376
+ "answer_guidelines": { "type": "string" },
377
+ "reference_id": { "type": "string" },
378
+ "validation": { "$ref": "#/$defs/booleanValidation" }
379
+ },
380
+ "additionalProperties": false
381
+ },
382
+ "arrayObjItemDate": {
383
+ "type": "object",
384
+ "required": ["id", "type", "label"],
385
+ "properties": {
386
+ "id": { "type": "integer", "minimum": 1 },
387
+ "type": { "const": "date" },
388
+ "label": { "type": "string" },
389
+ "description": { "type": "string" },
390
+ "placeholder": { "type": "string" },
391
+ "answer_guidelines": { "type": "string" },
392
+ "reference_id": { "type": "string" },
393
+ "validation": { "$ref": "#/$defs/dateValidation" }
394
+ },
395
+ "additionalProperties": false
396
+ },
397
+ "arrayObjItemSelect": {
398
+ "type": "object",
399
+ "required": ["id", "type", "label", "options"],
400
+ "properties": {
401
+ "id": { "type": "integer", "minimum": 1 },
402
+ "type": { "const": "select" },
403
+ "label": { "type": "string" },
404
+ "description": { "type": "string" },
405
+ "placeholder": { "type": "string" },
406
+ "answer_guidelines": { "type": "string" },
407
+ "reference_id": { "type": "string" },
408
+ "options": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/selectOption" } },
409
+ "validation": { "$ref": "#/$defs/selectValidation" }
410
+ },
411
+ "additionalProperties": false
412
+ },
413
+ "arrayObjItemMultiselect": {
414
+ "type": "object",
415
+ "required": ["id", "type", "label", "options"],
416
+ "properties": {
417
+ "id": { "type": "integer", "minimum": 1 },
418
+ "type": { "const": "multiselect" },
419
+ "label": { "type": "string" },
420
+ "description": { "type": "string" },
421
+ "placeholder": { "type": "string" },
422
+ "answer_guidelines": { "type": "string" },
423
+ "reference_id": { "type": "string" },
424
+ "options": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/selectOption" } },
425
+ "validation": { "$ref": "#/$defs/multiselectValidation" }
426
+ },
427
+ "additionalProperties": false
428
+ },
429
+ "arrayObjItemFile": {
430
+ "type": "object",
431
+ "required": ["id", "type", "label"],
432
+ "properties": {
433
+ "id": { "type": "integer", "minimum": 1 },
434
+ "type": { "const": "file" },
435
+ "label": { "type": "string" },
436
+ "description": { "type": "string" },
437
+ "placeholder": { "type": "string" },
438
+ "answer_guidelines": { "type": "string" },
439
+ "reference_id": { "type": "string" },
440
+ "validation": { "$ref": "#/$defs/fileValidation" }
441
+ },
442
+ "additionalProperties": false
443
+ },
444
+ "arrayObjItemBlockchain": {
445
+ "type": "object",
446
+ "required": ["id", "type", "label"],
447
+ "properties": {
448
+ "id": { "type": "integer", "minimum": 1 },
449
+ "type": { "const": "blockchain" },
450
+ "label": { "type": "string" },
451
+ "description": { "type": "string" },
452
+ "placeholder": { "type": "string" },
453
+ "answer_guidelines": { "type": "string" },
454
+ "reference_id": { "type": "string" },
455
+ "validation": { "$ref": "#/$defs/blockchainValidation" }
456
+ },
457
+ "additionalProperties": false
458
+ },
459
+ "arrayObjItemSustainability": {
460
+ "type": "object",
461
+ "required": ["id", "type", "label"],
462
+ "properties": {
463
+ "id": { "type": "integer", "minimum": 1 },
464
+ "type": { "const": "sustainability" },
465
+ "label": { "type": "string" },
466
+ "description": { "type": "string" },
467
+ "placeholder": { "type": "string" },
468
+ "answer_guidelines": { "type": "string" },
469
+ "reference_id": { "type": "string" },
470
+ "validation": { "$ref": "#/$defs/sustainabilityValidation" }
471
+ },
472
+ "additionalProperties": false
473
+ },
474
+ "arrayObjItemStatic": {
475
+ "type": "object",
476
+ "required": ["id", "type", "text"],
477
+ "properties": {
478
+ "id": { "type": "integer", "minimum": 1 },
479
+ "type": { "const": "static" },
480
+ "text": { "type": "string" },
481
+ "label": { "type": "string" },
482
+ "description": { "type": "string" },
483
+ "placeholder": { "type": "string" },
484
+ "answer_guidelines": { "type": "string" },
485
+ "reference_id": { "type": "string" }
486
+ },
487
+ "additionalProperties": false
488
+ },
489
+ "arrayObjItem": {
490
+ "oneOf": [
491
+ { "$ref": "#/$defs/arrayObjItemString" },
492
+ { "$ref": "#/$defs/arrayObjItemNumber" },
493
+ { "$ref": "#/$defs/arrayObjItemBoolean" },
494
+ { "$ref": "#/$defs/arrayObjItemDate" },
495
+ { "$ref": "#/$defs/arrayObjItemSelect" },
496
+ { "$ref": "#/$defs/arrayObjItemMultiselect" },
497
+ { "$ref": "#/$defs/arrayObjItemFile" },
498
+ { "$ref": "#/$defs/arrayObjItemBlockchain" },
499
+ { "$ref": "#/$defs/arrayObjItemSustainability" },
500
+ { "$ref": "#/$defs/arrayObjItemStatic" }
227
501
  ]
228
502
  },
229
503
 
@@ -235,6 +509,9 @@
235
509
  "type": { "const": "string" },
236
510
  "label": { "type": "string" },
237
511
  "description": { "type": "string" },
512
+ "placeholder": { "type": "string" },
513
+ "answer_guidelines": { "type": "string" },
514
+ "reference_id": { "type": "string" },
238
515
  "condition": { "$ref": "#/$defs/condition" },
239
516
  "validation": { "$ref": "#/$defs/stringValidation" }
240
517
  },
@@ -248,6 +525,9 @@
248
525
  "type": { "const": "number" },
249
526
  "label": { "type": "string" },
250
527
  "description": { "type": "string" },
528
+ "placeholder": { "type": "string" },
529
+ "answer_guidelines": { "type": "string" },
530
+ "reference_id": { "type": "string" },
251
531
  "condition": { "$ref": "#/$defs/condition" },
252
532
  "validation": { "$ref": "#/$defs/numberValidation" }
253
533
  },
@@ -261,6 +541,9 @@
261
541
  "type": { "const": "boolean" },
262
542
  "label": { "type": "string" },
263
543
  "description": { "type": "string" },
544
+ "placeholder": { "type": "string" },
545
+ "answer_guidelines": { "type": "string" },
546
+ "reference_id": { "type": "string" },
264
547
  "condition": { "$ref": "#/$defs/condition" },
265
548
  "validation": { "$ref": "#/$defs/booleanValidation" }
266
549
  },
@@ -274,6 +557,9 @@
274
557
  "type": { "const": "date" },
275
558
  "label": { "type": "string" },
276
559
  "description": { "type": "string" },
560
+ "placeholder": { "type": "string" },
561
+ "answer_guidelines": { "type": "string" },
562
+ "reference_id": { "type": "string" },
277
563
  "condition": { "$ref": "#/$defs/condition" },
278
564
  "validation": { "$ref": "#/$defs/dateValidation" }
279
565
  },
@@ -287,12 +573,48 @@
287
573
  "type": { "const": "select" },
288
574
  "label": { "type": "string" },
289
575
  "description": { "type": "string" },
576
+ "placeholder": { "type": "string" },
577
+ "answer_guidelines": { "type": "string" },
578
+ "reference_id": { "type": "string" },
290
579
  "condition": { "$ref": "#/$defs/condition" },
291
580
  "options": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/selectOption" } },
292
581
  "validation": { "$ref": "#/$defs/selectValidation" }
293
582
  },
294
583
  "additionalProperties": false
295
584
  },
585
+ "multiselectField": {
586
+ "type": "object",
587
+ "required": ["id", "type", "label", "options"],
588
+ "properties": {
589
+ "id": { "type": "integer", "minimum": 1 },
590
+ "type": { "const": "multiselect" },
591
+ "label": { "type": "string" },
592
+ "description": { "type": "string" },
593
+ "placeholder": { "type": "string" },
594
+ "answer_guidelines": { "type": "string" },
595
+ "reference_id": { "type": "string" },
596
+ "condition": { "$ref": "#/$defs/condition" },
597
+ "options": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/selectOption" } },
598
+ "validation": { "$ref": "#/$defs/multiselectValidation" }
599
+ },
600
+ "additionalProperties": false
601
+ },
602
+ "staticField": {
603
+ "type": "object",
604
+ "required": ["id", "type", "text"],
605
+ "properties": {
606
+ "id": { "type": "integer", "minimum": 1 },
607
+ "type": { "const": "static" },
608
+ "text": { "type": "string" },
609
+ "label": { "type": "string" },
610
+ "description": { "type": "string" },
611
+ "placeholder": { "type": "string" },
612
+ "answer_guidelines": { "type": "string" },
613
+ "reference_id": { "type": "string" },
614
+ "condition": { "$ref": "#/$defs/condition" }
615
+ },
616
+ "additionalProperties": false
617
+ },
296
618
  "arrayField": {
297
619
  "type": "object",
298
620
  "required": ["id", "type", "label", "item"],
@@ -301,12 +623,33 @@
301
623
  "type": { "const": "array" },
302
624
  "label": { "type": "string" },
303
625
  "description": { "type": "string" },
626
+ "placeholder": { "type": "string" },
627
+ "answer_guidelines": { "type": "string" },
628
+ "reference_id": { "type": "string" },
304
629
  "condition": { "$ref": "#/$defs/condition" },
305
630
  "item": { "$ref": "#/$defs/arrayItem" },
306
631
  "validation": { "$ref": "#/$defs/arrayValidation" }
307
632
  },
308
633
  "additionalProperties": false
309
634
  },
635
+ "arrayObjField": {
636
+ "type": "object",
637
+ "required": ["id", "type", "label", "items"],
638
+ "properties": {
639
+ "id": { "type": "integer", "minimum": 1 },
640
+ "type": { "const": "array_obj" },
641
+ "label": { "type": "string" },
642
+ "description": { "type": "string" },
643
+ "placeholder": { "type": "string" },
644
+ "answer_guidelines": { "type": "string" },
645
+ "reference_id": { "type": "string" },
646
+ "condition": { "$ref": "#/$defs/condition" },
647
+ "items": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/arrayObjItem" } },
648
+ "kind": { "type": "string", "enum": ["list", "table"] },
649
+ "validation": { "$ref": "#/$defs/arrayObjValidation" }
650
+ },
651
+ "additionalProperties": false
652
+ },
310
653
  "fileField": {
311
654
  "type": "object",
312
655
  "required": ["id", "type", "label"],
@@ -315,11 +658,46 @@
315
658
  "type": { "const": "file" },
316
659
  "label": { "type": "string" },
317
660
  "description": { "type": "string" },
661
+ "placeholder": { "type": "string" },
662
+ "answer_guidelines": { "type": "string" },
663
+ "reference_id": { "type": "string" },
318
664
  "condition": { "$ref": "#/$defs/condition" },
319
665
  "validation": { "$ref": "#/$defs/fileValidation" }
320
666
  },
321
667
  "additionalProperties": false
322
668
  },
669
+ "blockchainField": {
670
+ "type": "object",
671
+ "required": ["id", "type", "label"],
672
+ "properties": {
673
+ "id": { "type": "integer", "minimum": 1 },
674
+ "type": { "const": "blockchain" },
675
+ "label": { "type": "string" },
676
+ "description": { "type": "string" },
677
+ "placeholder": { "type": "string" },
678
+ "answer_guidelines": { "type": "string" },
679
+ "reference_id": { "type": "string" },
680
+ "condition": { "$ref": "#/$defs/condition" },
681
+ "validation": { "$ref": "#/$defs/blockchainValidation" }
682
+ },
683
+ "additionalProperties": false
684
+ },
685
+ "sustainabilityField": {
686
+ "type": "object",
687
+ "required": ["id", "type", "label"],
688
+ "properties": {
689
+ "id": { "type": "integer", "minimum": 1 },
690
+ "type": { "const": "sustainability" },
691
+ "label": { "type": "string" },
692
+ "description": { "type": "string" },
693
+ "placeholder": { "type": "string" },
694
+ "answer_guidelines": { "type": "string" },
695
+ "reference_id": { "type": "string" },
696
+ "condition": { "$ref": "#/$defs/condition" },
697
+ "validation": { "$ref": "#/$defs/sustainabilityValidation" }
698
+ },
699
+ "additionalProperties": false
700
+ },
323
701
  "fieldItem": {
324
702
  "oneOf": [
325
703
  { "$ref": "#/$defs/stringField" },
@@ -327,8 +705,13 @@
327
705
  { "$ref": "#/$defs/booleanField" },
328
706
  { "$ref": "#/$defs/dateField" },
329
707
  { "$ref": "#/$defs/selectField" },
708
+ { "$ref": "#/$defs/multiselectField" },
330
709
  { "$ref": "#/$defs/arrayField" },
331
- { "$ref": "#/$defs/fileField" }
710
+ { "$ref": "#/$defs/arrayObjField" },
711
+ { "$ref": "#/$defs/fileField" },
712
+ { "$ref": "#/$defs/staticField" },
713
+ { "$ref": "#/$defs/blockchainField" },
714
+ { "$ref": "#/$defs/sustainabilityField" }
332
715
  ]
333
716
  },
334
717
 
@@ -340,6 +723,9 @@
340
723
  "type": { "const": "section" },
341
724
  "title": { "type": "string" },
342
725
  "description": { "type": "string" },
726
+ "placeholder": { "type": "string" },
727
+ "answer_guidelines": { "type": "string" },
728
+ "reference_id": { "type": "string" },
343
729
  "condition": { "$ref": "#/$defs/condition" },
344
730
  "content": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/contentItem" } }
345
731
  },