@anri1214/dynamic-forms-mui-mcp 0.1.5

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.
Files changed (45) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +214 -0
  3. package/dist/index.d.ts +14 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +394 -0
  6. package/dist/prompts/generateBackendEndpoint.d.ts +5 -0
  7. package/dist/prompts/generateBackendEndpoint.d.ts.map +1 -0
  8. package/dist/prompts/generateBackendEndpoint.js +33 -0
  9. package/dist/prompts/generateFormConfig.d.ts +5 -0
  10. package/dist/prompts/generateFormConfig.d.ts.map +1 -0
  11. package/dist/prompts/generateFormConfig.js +94 -0
  12. package/dist/resources/examples.d.ts +9 -0
  13. package/dist/resources/examples.d.ts.map +1 -0
  14. package/dist/resources/examples.js +16 -0
  15. package/dist/resources/fieldDocs.d.ts +5 -0
  16. package/dist/resources/fieldDocs.d.ts.map +1 -0
  17. package/dist/resources/fieldDocs.js +39 -0
  18. package/dist/resources/jsonSchema.d.ts +5 -0
  19. package/dist/resources/jsonSchema.d.ts.map +1 -0
  20. package/dist/resources/jsonSchema.js +8 -0
  21. package/dist/schema/0.1/examples/crud.json +128 -0
  22. package/dist/schema/0.1/examples/filters.json +82 -0
  23. package/dist/schema/0.1/examples/registration.json +119 -0
  24. package/dist/schema/0.1/fieldTypes.json +213 -0
  25. package/dist/schema/0.1/formSchema.json +806 -0
  26. package/dist/schema/versions.json +6 -0
  27. package/dist/schemaLoader.d.ts +37 -0
  28. package/dist/schemaLoader.d.ts.map +1 -0
  29. package/dist/schemaLoader.js +89 -0
  30. package/dist/tools/generateSchema.d.ts +30 -0
  31. package/dist/tools/generateSchema.d.ts.map +1 -0
  32. package/dist/tools/generateSchema.js +58 -0
  33. package/dist/tools/getFieldConfig.d.ts +18 -0
  34. package/dist/tools/getFieldConfig.d.ts.map +1 -0
  35. package/dist/tools/getFieldConfig.js +25 -0
  36. package/dist/tools/listFieldTypes.d.ts +13 -0
  37. package/dist/tools/listFieldTypes.d.ts.map +1 -0
  38. package/dist/tools/listFieldTypes.js +14 -0
  39. package/dist/tools/validateSchema.d.ts +10 -0
  40. package/dist/tools/validateSchema.d.ts.map +1 -0
  41. package/dist/tools/validateSchema.js +32 -0
  42. package/dist/types.d.ts +19 -0
  43. package/dist/types.d.ts.map +1 -0
  44. package/dist/types.js +1 -0
  45. package/package.json +49 -0
@@ -0,0 +1,806 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "FormSchema",
4
+ "description": "Schema for @ai-hub/dynamic-forms-mui — describes a declarative, JSON-driven dynamic form with sections, fields, validation, conditions, and dynamic options.",
5
+ "type": "object",
6
+ "required": [
7
+ "sections",
8
+ "fields"
9
+ ],
10
+ "properties": {
11
+ "sections": {
12
+ "type": "array",
13
+ "description": "Ordered list of form sections. Each section groups related fields.",
14
+ "items": {
15
+ "$ref": "#/definitions/Section"
16
+ }
17
+ },
18
+ "fields": {
19
+ "type": "object",
20
+ "description": "Map of field key → field configuration. Keys are referenced by sections.fields[].",
21
+ "additionalProperties": {
22
+ "$ref": "#/definitions/FieldConfig"
23
+ }
24
+ }
25
+ },
26
+ "definitions": {
27
+ "Section": {
28
+ "type": "object",
29
+ "required": [
30
+ "id",
31
+ "fields"
32
+ ],
33
+ "properties": {
34
+ "id": {
35
+ "type": "string",
36
+ "description": "Unique section identifier"
37
+ },
38
+ "title": {
39
+ "type": "string",
40
+ "description": "Section heading displayed to the user"
41
+ },
42
+ "description": {
43
+ "type": "string",
44
+ "description": "Optional section description"
45
+ },
46
+ "fields": {
47
+ "type": "array",
48
+ "items": {
49
+ "type": "string"
50
+ },
51
+ "description": "Ordered list of field keys that belong to this section"
52
+ }
53
+ }
54
+ },
55
+ "FieldConfig": {
56
+ "description": "Configuration for a single form field. Discriminated by the \"type\" property.",
57
+ "oneOf": [
58
+ {
59
+ "$ref": "#/definitions/TextFieldConfig"
60
+ },
61
+ {
62
+ "$ref": "#/definitions/NumberFieldConfig"
63
+ },
64
+ {
65
+ "$ref": "#/definitions/SelectFieldConfig"
66
+ },
67
+ {
68
+ "$ref": "#/definitions/AutocompleteFieldConfig"
69
+ },
70
+ {
71
+ "$ref": "#/definitions/CheckboxFieldConfig"
72
+ },
73
+ {
74
+ "$ref": "#/definitions/RadioFieldConfig"
75
+ },
76
+ {
77
+ "$ref": "#/definitions/DateFieldConfig"
78
+ },
79
+ {
80
+ "$ref": "#/definitions/FileFieldConfig"
81
+ }
82
+ ]
83
+ },
84
+ "BaseFieldConfig": {
85
+ "type": "object",
86
+ "required": [
87
+ "type",
88
+ "label"
89
+ ],
90
+ "properties": {
91
+ "type": {
92
+ "type": "string",
93
+ "enum": [
94
+ "text",
95
+ "password",
96
+ "email",
97
+ "number",
98
+ "textarea",
99
+ "select",
100
+ "multiselect",
101
+ "autocomplete",
102
+ "checkbox",
103
+ "radio",
104
+ "switch",
105
+ "date",
106
+ "dateRange",
107
+ "file"
108
+ ],
109
+ "description": "Field type discriminator"
110
+ },
111
+ "label": {
112
+ "type": "string",
113
+ "description": "Label displayed above the field"
114
+ },
115
+ "placeholder": {
116
+ "type": "string",
117
+ "description": "Placeholder text inside the field"
118
+ },
119
+ "helperText": {
120
+ "type": "string",
121
+ "description": "Helper text displayed below the field"
122
+ },
123
+ "defaultValue": {
124
+ "description": "Default value for the field"
125
+ },
126
+ "disabled": {
127
+ "type": "boolean",
128
+ "description": "Whether the field is disabled"
129
+ },
130
+ "showIf": {
131
+ "$ref": "#/definitions/Condition",
132
+ "description": "Condition to show this field"
133
+ },
134
+ "validation": {
135
+ "$ref": "#/definitions/ValidationRules"
136
+ }
137
+ }
138
+ },
139
+ "TextFieldConfig": {
140
+ "description": "Text-based field: text, password, email, or textarea",
141
+ "allOf": [
142
+ {
143
+ "$ref": "#/definitions/BaseFieldConfig"
144
+ },
145
+ {
146
+ "type": "object",
147
+ "properties": {
148
+ "type": {
149
+ "type": "string",
150
+ "enum": [
151
+ "text",
152
+ "password",
153
+ "email",
154
+ "textarea"
155
+ ]
156
+ },
157
+ "autoComplete": {
158
+ "type": "string",
159
+ "description": "HTML autocomplete attribute value"
160
+ },
161
+ "rows": {
162
+ "type": "number",
163
+ "description": "Number of visible rows (textarea only)"
164
+ }
165
+ },
166
+ "required": [
167
+ "type",
168
+ "label"
169
+ ]
170
+ }
171
+ ]
172
+ },
173
+ "NumberFieldConfig": {
174
+ "description": "Numeric input field",
175
+ "allOf": [
176
+ {
177
+ "$ref": "#/definitions/BaseFieldConfig"
178
+ },
179
+ {
180
+ "type": "object",
181
+ "properties": {
182
+ "type": {
183
+ "type": "string",
184
+ "enum": [
185
+ "number"
186
+ ]
187
+ },
188
+ "min": {
189
+ "type": "number",
190
+ "description": "Minimum allowed value"
191
+ },
192
+ "max": {
193
+ "type": "number",
194
+ "description": "Maximum allowed value"
195
+ },
196
+ "step": {
197
+ "type": "number",
198
+ "description": "Step increment"
199
+ }
200
+ },
201
+ "required": [
202
+ "type",
203
+ "label"
204
+ ]
205
+ }
206
+ ]
207
+ },
208
+ "SelectFieldConfig": {
209
+ "description": "Dropdown select or multi-select field",
210
+ "allOf": [
211
+ {
212
+ "$ref": "#/definitions/BaseFieldConfig"
213
+ },
214
+ {
215
+ "type": "object",
216
+ "properties": {
217
+ "type": {
218
+ "type": "string",
219
+ "enum": [
220
+ "select",
221
+ "multiselect"
222
+ ]
223
+ },
224
+ "options": {
225
+ "type": "array",
226
+ "items": {
227
+ "$ref": "#/definitions/Option"
228
+ },
229
+ "description": "Static options list"
230
+ },
231
+ "optionsSource": {
232
+ "$ref": "#/definitions/OptionsSource",
233
+ "description": "Dynamic options from an API"
234
+ },
235
+ "initialOptions": {
236
+ "type": "array",
237
+ "items": {
238
+ "$ref": "#/definitions/Option"
239
+ },
240
+ "description": "Pre-selected options to display before API response arrives (used with optionsSource)"
241
+ }
242
+ },
243
+ "required": [
244
+ "type",
245
+ "label"
246
+ ]
247
+ }
248
+ ]
249
+ },
250
+ "AutocompleteFieldConfig": {
251
+ "description": "Autocomplete field with async search support. Single-value selection with typeahead.",
252
+ "allOf": [
253
+ {
254
+ "$ref": "#/definitions/BaseFieldConfig"
255
+ },
256
+ {
257
+ "type": "object",
258
+ "properties": {
259
+ "type": {
260
+ "type": "string",
261
+ "enum": [
262
+ "autocomplete"
263
+ ]
264
+ },
265
+ "options": {
266
+ "type": "array",
267
+ "items": {
268
+ "$ref": "#/definitions/Option"
269
+ },
270
+ "description": "Static options list"
271
+ },
272
+ "optionsSource": {
273
+ "$ref": "#/definitions/OptionsSource",
274
+ "description": "Dynamic options from an API (supports async search via dependsOnInput)"
275
+ },
276
+ "initialOptions": {
277
+ "type": "array",
278
+ "items": {
279
+ "$ref": "#/definitions/Option"
280
+ },
281
+ "description": "Pre-selected options to display before API response arrives"
282
+ }
283
+ },
284
+ "required": [
285
+ "type",
286
+ "label"
287
+ ]
288
+ }
289
+ ]
290
+ },
291
+ "CheckboxFieldConfig": {
292
+ "description": "Checkbox or switch toggle field",
293
+ "allOf": [
294
+ {
295
+ "$ref": "#/definitions/BaseFieldConfig"
296
+ },
297
+ {
298
+ "type": "object",
299
+ "properties": {
300
+ "type": {
301
+ "type": "string",
302
+ "enum": [
303
+ "checkbox",
304
+ "switch"
305
+ ]
306
+ },
307
+ "defaultValue": {
308
+ "type": "boolean"
309
+ }
310
+ },
311
+ "required": [
312
+ "type",
313
+ "label"
314
+ ]
315
+ }
316
+ ]
317
+ },
318
+ "RadioFieldConfig": {
319
+ "description": "Radio button group field",
320
+ "allOf": [
321
+ {
322
+ "$ref": "#/definitions/BaseFieldConfig"
323
+ },
324
+ {
325
+ "type": "object",
326
+ "properties": {
327
+ "type": {
328
+ "type": "string",
329
+ "enum": [
330
+ "radio"
331
+ ]
332
+ },
333
+ "options": {
334
+ "type": "array",
335
+ "items": {
336
+ "$ref": "#/definitions/Option"
337
+ }
338
+ },
339
+ "optionsSource": {
340
+ "$ref": "#/definitions/OptionsSource"
341
+ },
342
+ "direction": {
343
+ "type": "string",
344
+ "enum": [
345
+ "row",
346
+ "column"
347
+ ],
348
+ "description": "Layout direction for radio buttons"
349
+ }
350
+ },
351
+ "required": [
352
+ "type",
353
+ "label"
354
+ ]
355
+ }
356
+ ]
357
+ },
358
+ "DateFieldConfig": {
359
+ "description": "Date or date range picker field",
360
+ "allOf": [
361
+ {
362
+ "$ref": "#/definitions/BaseFieldConfig"
363
+ },
364
+ {
365
+ "type": "object",
366
+ "properties": {
367
+ "type": {
368
+ "type": "string",
369
+ "enum": [
370
+ "date",
371
+ "dateRange"
372
+ ]
373
+ },
374
+ "includeTime": {
375
+ "type": "boolean",
376
+ "description": "Include time picker"
377
+ },
378
+ "minDate": {
379
+ "type": "string",
380
+ "description": "Minimum date (ISO 8601 string)"
381
+ },
382
+ "maxDate": {
383
+ "type": "string",
384
+ "description": "Maximum date (ISO 8601 string)"
385
+ },
386
+ "format": {
387
+ "type": "string",
388
+ "description": "Display format (e.g. \"dd/MM/yyyy\")"
389
+ }
390
+ },
391
+ "required": [
392
+ "type",
393
+ "label"
394
+ ]
395
+ }
396
+ ]
397
+ },
398
+ "FileFieldConfig": {
399
+ "description": "File upload field",
400
+ "allOf": [
401
+ {
402
+ "$ref": "#/definitions/BaseFieldConfig"
403
+ },
404
+ {
405
+ "type": "object",
406
+ "properties": {
407
+ "type": {
408
+ "type": "string",
409
+ "enum": [
410
+ "file"
411
+ ]
412
+ },
413
+ "accept": {
414
+ "type": "string",
415
+ "description": "Accepted file types (e.g. \"image/*,.pdf\")"
416
+ },
417
+ "maxSize": {
418
+ "type": "number",
419
+ "description": "Max file size in bytes"
420
+ },
421
+ "multiple": {
422
+ "type": "boolean",
423
+ "description": "Allow multiple files"
424
+ }
425
+ },
426
+ "required": [
427
+ "type",
428
+ "label"
429
+ ]
430
+ }
431
+ ]
432
+ },
433
+ "Option": {
434
+ "type": "object",
435
+ "required": [
436
+ "value",
437
+ "label"
438
+ ],
439
+ "properties": {
440
+ "value": {
441
+ "oneOf": [
442
+ {
443
+ "type": "string"
444
+ },
445
+ {
446
+ "type": "number"
447
+ }
448
+ ],
449
+ "description": "Option value submitted with the form"
450
+ },
451
+ "label": {
452
+ "type": "string",
453
+ "description": "Display text for this option"
454
+ },
455
+ "disabled": {
456
+ "type": "boolean"
457
+ }
458
+ }
459
+ },
460
+ "OptionsSource": {
461
+ "type": "object",
462
+ "required": [
463
+ "apiUrl"
464
+ ],
465
+ "description": "Configuration for loading options dynamically from an API endpoint",
466
+ "properties": {
467
+ "apiUrl": {
468
+ "type": "string",
469
+ "description": "API endpoint URL"
470
+ },
471
+ "queryParams": {
472
+ "type": "array",
473
+ "items": {
474
+ "$ref": "#/definitions/QueryParam"
475
+ },
476
+ "description": "Query parameters to append; can depend on other field values"
477
+ },
478
+ "valueKey": {
479
+ "type": "string",
480
+ "default": "value",
481
+ "description": "Key in API response object to use as option value"
482
+ },
483
+ "labelKey": {
484
+ "type": "string",
485
+ "default": "label",
486
+ "description": "Key in API response object to use as option label"
487
+ }
488
+ }
489
+ },
490
+ "QueryParam": {
491
+ "type": "object",
492
+ "required": [
493
+ "key"
494
+ ],
495
+ "properties": {
496
+ "key": {
497
+ "type": "string",
498
+ "description": "Query parameter name"
499
+ },
500
+ "dependsOn": {
501
+ "type": "string",
502
+ "description": "Field key whose value is used as this parameter"
503
+ },
504
+ "value": {
505
+ "type": "string",
506
+ "description": "Static value (used when dependsOn is not set)"
507
+ },
508
+ "dependsOnInput": {
509
+ "type": "boolean",
510
+ "description": "When true, the query param value comes from the autocomplete text input (for async search)"
511
+ }
512
+ }
513
+ },
514
+ "ValidationRules": {
515
+ "type": "object",
516
+ "description": "Validation rules for a field",
517
+ "properties": {
518
+ "required": {
519
+ "type": "boolean"
520
+ },
521
+ "requiredIf": {
522
+ "$ref": "#/definitions/Condition"
523
+ },
524
+ "minLength": {
525
+ "type": "number"
526
+ },
527
+ "maxLength": {
528
+ "type": "number"
529
+ },
530
+ "pattern": {
531
+ "type": "string",
532
+ "description": "Regex pattern string"
533
+ },
534
+ "email": {
535
+ "type": "boolean"
536
+ },
537
+ "url": {
538
+ "type": "boolean"
539
+ },
540
+ "hasUppercase": {
541
+ "oneOf": [
542
+ {
543
+ "type": "boolean"
544
+ },
545
+ {
546
+ "type": "number"
547
+ }
548
+ ],
549
+ "description": "Require uppercase letters (true or minimum count)"
550
+ },
551
+ "hasLowercase": {
552
+ "oneOf": [
553
+ {
554
+ "type": "boolean"
555
+ },
556
+ {
557
+ "type": "number"
558
+ }
559
+ ],
560
+ "description": "Require lowercase letters (true or minimum count)"
561
+ },
562
+ "hasNumber": {
563
+ "oneOf": [
564
+ {
565
+ "type": "boolean"
566
+ },
567
+ {
568
+ "type": "number"
569
+ }
570
+ ],
571
+ "description": "Require digits (true or minimum count)"
572
+ },
573
+ "hasSpecialChar": {
574
+ "oneOf": [
575
+ {
576
+ "type": "boolean"
577
+ },
578
+ {
579
+ "type": "number"
580
+ }
581
+ ],
582
+ "description": "Require special characters (true or minimum count)"
583
+ },
584
+ "includes": {
585
+ "type": "string",
586
+ "description": "String that must be included"
587
+ },
588
+ "min": {
589
+ "type": "number",
590
+ "description": "Minimum numeric value"
591
+ },
592
+ "max": {
593
+ "type": "number",
594
+ "description": "Maximum numeric value"
595
+ },
596
+ "minDate": {
597
+ "type": "string",
598
+ "description": "Minimum date (ISO 8601)"
599
+ },
600
+ "maxDate": {
601
+ "type": "string",
602
+ "description": "Maximum date (ISO 8601)"
603
+ },
604
+ "maxSize": {
605
+ "type": "number",
606
+ "description": "Max file size in bytes"
607
+ },
608
+ "minFiles": {
609
+ "type": "number"
610
+ },
611
+ "maxFiles": {
612
+ "type": "number"
613
+ },
614
+ "matchField": {
615
+ "type": "string",
616
+ "description": "Key of another field whose value must match"
617
+ },
618
+ "asyncValidation": {
619
+ "$ref": "#/definitions/AsyncValidationConfig"
620
+ },
621
+ "messages": {
622
+ "$ref": "#/definitions/ValidationMessages"
623
+ }
624
+ }
625
+ },
626
+ "AsyncValidationConfig": {
627
+ "type": "object",
628
+ "required": [
629
+ "apiUrl",
630
+ "message"
631
+ ],
632
+ "properties": {
633
+ "apiUrl": {
634
+ "type": "string",
635
+ "description": "API endpoint for async validation"
636
+ },
637
+ "queryParams": {
638
+ "type": "array",
639
+ "items": {
640
+ "$ref": "#/definitions/QueryParam"
641
+ }
642
+ },
643
+ "debounce": {
644
+ "type": "number",
645
+ "default": 500,
646
+ "description": "Debounce in ms before sending request"
647
+ },
648
+ "message": {
649
+ "type": "string",
650
+ "description": "Error message when validation fails"
651
+ }
652
+ }
653
+ },
654
+ "ValidationMessages": {
655
+ "type": "object",
656
+ "description": "Custom error messages that override defaults",
657
+ "properties": {
658
+ "required": {
659
+ "type": "string"
660
+ },
661
+ "minLength": {
662
+ "type": "string"
663
+ },
664
+ "maxLength": {
665
+ "type": "string"
666
+ },
667
+ "pattern": {
668
+ "type": "string"
669
+ },
670
+ "email": {
671
+ "type": "string"
672
+ },
673
+ "url": {
674
+ "type": "string"
675
+ },
676
+ "hasUppercase": {
677
+ "type": "string"
678
+ },
679
+ "hasLowercase": {
680
+ "type": "string"
681
+ },
682
+ "hasNumber": {
683
+ "type": "string"
684
+ },
685
+ "hasSpecialChar": {
686
+ "type": "string"
687
+ },
688
+ "includes": {
689
+ "type": "string"
690
+ },
691
+ "min": {
692
+ "type": "string"
693
+ },
694
+ "max": {
695
+ "type": "string"
696
+ },
697
+ "invalidDate": {
698
+ "type": "string"
699
+ },
700
+ "minDate": {
701
+ "type": "string"
702
+ },
703
+ "maxDate": {
704
+ "type": "string"
705
+ },
706
+ "invalidRange": {
707
+ "type": "string"
708
+ },
709
+ "maxSize": {
710
+ "type": "string"
711
+ },
712
+ "fileType": {
713
+ "type": "string"
714
+ },
715
+ "minFiles": {
716
+ "type": "string"
717
+ },
718
+ "maxFiles": {
719
+ "type": "string"
720
+ },
721
+ "matchField": {
722
+ "type": "string"
723
+ },
724
+ "asyncValidation": {
725
+ "type": "string"
726
+ }
727
+ }
728
+ },
729
+ "Condition": {
730
+ "description": "A condition expression. Can be a simple comparison, or a composite (and/or) condition.",
731
+ "oneOf": [
732
+ {
733
+ "$ref": "#/definitions/SimpleCondition"
734
+ },
735
+ {
736
+ "$ref": "#/definitions/AndCondition"
737
+ },
738
+ {
739
+ "$ref": "#/definitions/OrCondition"
740
+ }
741
+ ]
742
+ },
743
+ "SimpleCondition": {
744
+ "type": "object",
745
+ "required": [
746
+ "field",
747
+ "operator"
748
+ ],
749
+ "properties": {
750
+ "field": {
751
+ "type": "string",
752
+ "description": "Field key to evaluate"
753
+ },
754
+ "operator": {
755
+ "type": "string",
756
+ "enum": [
757
+ "equals",
758
+ "notEquals",
759
+ "in",
760
+ "notIn",
761
+ "isEmpty",
762
+ "isNotEmpty",
763
+ "gt",
764
+ "gte",
765
+ "lt",
766
+ "lte"
767
+ ],
768
+ "description": "Comparison operator"
769
+ },
770
+ "value": {
771
+ "description": "Value to compare against (not needed for isEmpty/isNotEmpty)"
772
+ }
773
+ }
774
+ },
775
+ "AndCondition": {
776
+ "type": "object",
777
+ "required": [
778
+ "and"
779
+ ],
780
+ "properties": {
781
+ "and": {
782
+ "type": "array",
783
+ "items": {
784
+ "$ref": "#/definitions/Condition"
785
+ },
786
+ "description": "All conditions must be true"
787
+ }
788
+ }
789
+ },
790
+ "OrCondition": {
791
+ "type": "object",
792
+ "required": [
793
+ "or"
794
+ ],
795
+ "properties": {
796
+ "or": {
797
+ "type": "array",
798
+ "items": {
799
+ "$ref": "#/definitions/Condition"
800
+ },
801
+ "description": "At least one condition must be true"
802
+ }
803
+ }
804
+ }
805
+ }
806
+ }