@0disoft/mensor-contract 0.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.
@@ -0,0 +1,735 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "diagnostic-report-v1.schema.json",
4
+ "title": "Mensor Diagnostic Report v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schemaVersion", "producer", "status", "diagnostics", "summary"],
8
+ "properties": {
9
+ "schemaVersion": {
10
+ "const": 1
11
+ },
12
+ "producer": {
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "required": ["name", "version"],
16
+ "properties": {
17
+ "name": {
18
+ "const": "mensor"
19
+ },
20
+ "version": {
21
+ "type": "string",
22
+ "minLength": 1
23
+ }
24
+ }
25
+ },
26
+ "status": {
27
+ "enum": ["passed", "failed"]
28
+ },
29
+ "diagnostics": {
30
+ "type": "array",
31
+ "items": {
32
+ "$ref": "#/$defs/diagnostic"
33
+ }
34
+ },
35
+ "summary": {
36
+ "type": "object",
37
+ "additionalProperties": false,
38
+ "required": ["errorCount", "warningCount"],
39
+ "properties": {
40
+ "errorCount": {
41
+ "type": "integer",
42
+ "minimum": 0
43
+ },
44
+ "warningCount": {
45
+ "type": "integer",
46
+ "minimum": 0
47
+ }
48
+ }
49
+ }
50
+ },
51
+ "$defs": {
52
+ "position": {
53
+ "type": "object",
54
+ "additionalProperties": false,
55
+ "required": ["line", "character"],
56
+ "properties": {
57
+ "line": {
58
+ "type": "integer",
59
+ "minimum": 0
60
+ },
61
+ "character": {
62
+ "type": "integer",
63
+ "minimum": 0
64
+ }
65
+ }
66
+ },
67
+ "range": {
68
+ "type": "object",
69
+ "additionalProperties": false,
70
+ "required": ["start", "end"],
71
+ "properties": {
72
+ "start": {
73
+ "$ref": "#/$defs/position"
74
+ },
75
+ "end": {
76
+ "$ref": "#/$defs/position"
77
+ }
78
+ }
79
+ },
80
+ "related": {
81
+ "type": "object",
82
+ "additionalProperties": false,
83
+ "required": ["role", "message", "file", "range"],
84
+ "properties": {
85
+ "role": {
86
+ "type": "string",
87
+ "minLength": 1
88
+ },
89
+ "message": {
90
+ "type": "string",
91
+ "minLength": 1
92
+ },
93
+ "file": {
94
+ "type": "string",
95
+ "minLength": 1,
96
+ "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
97
+ },
98
+ "range": {
99
+ "$ref": "#/$defs/range"
100
+ }
101
+ }
102
+ },
103
+ "repair": {
104
+ "type": "object",
105
+ "additionalProperties": false,
106
+ "required": ["strategy", "hint", "mustPreserve", "mustNot"],
107
+ "properties": {
108
+ "strategy": {
109
+ "type": "string",
110
+ "minLength": 1
111
+ },
112
+ "hint": {
113
+ "type": "string",
114
+ "minLength": 1
115
+ },
116
+ "mustPreserve": {
117
+ "type": "array",
118
+ "items": {
119
+ "type": "string",
120
+ "minLength": 1
121
+ }
122
+ },
123
+ "mustNot": {
124
+ "type": "array",
125
+ "items": {
126
+ "type": "string",
127
+ "minLength": 1
128
+ }
129
+ }
130
+ }
131
+ },
132
+ "diagnostic": {
133
+ "oneOf": [
134
+ {
135
+ "$ref": "#/$defs/formFieldMissingDiagnostic"
136
+ },
137
+ {
138
+ "$ref": "#/$defs/formFieldUnexpectedDiagnostic"
139
+ },
140
+ {
141
+ "$ref": "#/$defs/formMethodMismatchDiagnostic"
142
+ },
143
+ {
144
+ "$ref": "#/$defs/formActionMismatchDiagnostic"
145
+ },
146
+ {
147
+ "$ref": "#/$defs/formControlCodecMismatchDiagnostic"
148
+ },
149
+ {
150
+ "$ref": "#/$defs/formControlUnsupportedDiagnostic"
151
+ },
152
+ {
153
+ "$ref": "#/$defs/handlerExportMissingDiagnostic"
154
+ },
155
+ {
156
+ "$ref": "#/$defs/routeMissingDiagnostic"
157
+ },
158
+ {
159
+ "$ref": "#/$defs/moduleBoundaryViolationDiagnostic"
160
+ },
161
+ {
162
+ "$ref": "#/$defs/moduleDynamicImportUnsupportedDiagnostic"
163
+ },
164
+ {
165
+ "$ref": "#/$defs/fileOwnershipMismatchDiagnostic"
166
+ },
167
+ {
168
+ "$ref": "#/$defs/fileRoleMismatchDiagnostic"
169
+ }
170
+ ]
171
+ },
172
+ "diagnosticBase": {
173
+ "type": "object",
174
+ "additionalProperties": false,
175
+ "required": ["code", "severity", "category", "message", "file", "range", "facts", "related", "repair"],
176
+ "properties": {
177
+ "code": {},
178
+ "severity": {},
179
+ "category": {},
180
+ "message": {
181
+ "type": "string",
182
+ "minLength": 1
183
+ },
184
+ "file": {
185
+ "type": "string",
186
+ "minLength": 1,
187
+ "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
188
+ },
189
+ "range": {
190
+ "$ref": "#/$defs/range"
191
+ },
192
+ "facts": {},
193
+ "related": {
194
+ "type": "array",
195
+ "items": {
196
+ "$ref": "#/$defs/related"
197
+ }
198
+ },
199
+ "repair": {
200
+ "$ref": "#/$defs/repair"
201
+ }
202
+ }
203
+ },
204
+ "formFieldMissingDiagnostic": {
205
+ "allOf": [
206
+ {
207
+ "$ref": "#/$defs/diagnosticBase"
208
+ },
209
+ {
210
+ "type": "object",
211
+ "properties": {
212
+ "code": {
213
+ "const": "form.field_missing"
214
+ },
215
+ "severity": {
216
+ "const": "error"
217
+ },
218
+ "category": {
219
+ "const": "form-contract"
220
+ },
221
+ "facts": {
222
+ "$ref": "#/$defs/formFieldMissingFacts"
223
+ }
224
+ }
225
+ }
226
+ ]
227
+ },
228
+ "formFieldMissingFacts": {
229
+ "type": "object",
230
+ "additionalProperties": false,
231
+ "required": ["actionId", "fieldName", "formId", "schemaPath", "template"],
232
+ "properties": {
233
+ "actionId": {
234
+ "type": "string",
235
+ "minLength": 1
236
+ },
237
+ "fieldName": {
238
+ "type": "string",
239
+ "minLength": 1
240
+ },
241
+ "formId": {
242
+ "type": "string",
243
+ "minLength": 1
244
+ },
245
+ "schemaPath": {
246
+ "type": "array",
247
+ "minItems": 1,
248
+ "items": {
249
+ "type": "string",
250
+ "minLength": 1
251
+ }
252
+ },
253
+ "template": {
254
+ "type": "string",
255
+ "minLength": 1,
256
+ "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
257
+ }
258
+ }
259
+ },
260
+ "formFieldUnexpectedDiagnostic": {
261
+ "allOf": [
262
+ {
263
+ "$ref": "#/$defs/diagnosticBase"
264
+ },
265
+ {
266
+ "type": "object",
267
+ "properties": {
268
+ "code": {
269
+ "const": "form.field_unexpected"
270
+ },
271
+ "severity": {
272
+ "const": "error"
273
+ },
274
+ "category": {
275
+ "const": "form-contract"
276
+ },
277
+ "facts": {
278
+ "$ref": "#/$defs/formFieldUnexpectedFacts"
279
+ }
280
+ }
281
+ }
282
+ ]
283
+ },
284
+ "formFieldUnexpectedFacts": {
285
+ "type": "object",
286
+ "additionalProperties": false,
287
+ "required": ["actionId", "fieldName", "formId", "template", "unknownFieldsPolicy"],
288
+ "properties": {
289
+ "actionId": {
290
+ "type": "string",
291
+ "minLength": 1
292
+ },
293
+ "fieldName": {
294
+ "type": "string",
295
+ "minLength": 1
296
+ },
297
+ "formId": {
298
+ "type": "string",
299
+ "minLength": 1
300
+ },
301
+ "template": {
302
+ "type": "string",
303
+ "minLength": 1,
304
+ "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
305
+ },
306
+ "unknownFieldsPolicy": {
307
+ "const": "reject"
308
+ }
309
+ }
310
+ },
311
+ "formMethodMismatchDiagnostic": {
312
+ "allOf": [
313
+ {
314
+ "$ref": "#/$defs/diagnosticBase"
315
+ },
316
+ {
317
+ "type": "object",
318
+ "properties": {
319
+ "code": {
320
+ "const": "form.method_mismatch"
321
+ },
322
+ "severity": {
323
+ "const": "error"
324
+ },
325
+ "category": {
326
+ "const": "form-contract"
327
+ },
328
+ "facts": {
329
+ "$ref": "#/$defs/formMethodMismatchFacts"
330
+ }
331
+ }
332
+ }
333
+ ]
334
+ },
335
+ "formMethodMismatchFacts": {
336
+ "type": "object",
337
+ "additionalProperties": false,
338
+ "required": ["actionId", "actualMethod", "expectedMethod", "formId", "template"],
339
+ "properties": {
340
+ "actionId": {
341
+ "type": "string",
342
+ "minLength": 1
343
+ },
344
+ "actualMethod": {
345
+ "type": "string"
346
+ },
347
+ "expectedMethod": {
348
+ "const": "POST"
349
+ },
350
+ "formId": {
351
+ "type": "string",
352
+ "minLength": 1
353
+ },
354
+ "template": {
355
+ "type": "string",
356
+ "minLength": 1,
357
+ "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
358
+ }
359
+ }
360
+ },
361
+ "formActionMismatchDiagnostic": {
362
+ "allOf": [
363
+ {
364
+ "$ref": "#/$defs/diagnosticBase"
365
+ },
366
+ {
367
+ "type": "object",
368
+ "properties": {
369
+ "code": {
370
+ "const": "form.action_mismatch"
371
+ },
372
+ "severity": {
373
+ "const": "error"
374
+ },
375
+ "category": {
376
+ "const": "form-contract"
377
+ },
378
+ "facts": {
379
+ "$ref": "#/$defs/formActionMismatchFacts"
380
+ }
381
+ }
382
+ }
383
+ ]
384
+ },
385
+ "formActionMismatchFacts": {
386
+ "type": "object",
387
+ "additionalProperties": false,
388
+ "required": ["actionId", "actualAction", "actualActionSource", "expectedAction", "formId", "template"],
389
+ "properties": {
390
+ "actionId": {
391
+ "type": "string",
392
+ "minLength": 1
393
+ },
394
+ "actualAction": {
395
+ "type": "string"
396
+ },
397
+ "actualActionSource": {
398
+ "enum": ["literal", "current-document"]
399
+ },
400
+ "expectedAction": {
401
+ "type": "string",
402
+ "minLength": 1
403
+ },
404
+ "formId": {
405
+ "type": "string",
406
+ "minLength": 1
407
+ },
408
+ "template": {
409
+ "type": "string",
410
+ "minLength": 1,
411
+ "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
412
+ }
413
+ }
414
+ },
415
+ "formControlCodecMismatchDiagnostic": {
416
+ "allOf": [
417
+ {
418
+ "$ref": "#/$defs/diagnosticBase"
419
+ },
420
+ {
421
+ "type": "object",
422
+ "properties": {
423
+ "code": {
424
+ "const": "form.control_codec_mismatch"
425
+ },
426
+ "severity": {
427
+ "const": "error"
428
+ },
429
+ "category": {
430
+ "const": "form-contract"
431
+ },
432
+ "facts": {
433
+ "$ref": "#/$defs/formControlCodecMismatchFacts"
434
+ }
435
+ }
436
+ }
437
+ ]
438
+ },
439
+ "formControlCodecMismatchFacts": {
440
+ "type": "object",
441
+ "additionalProperties": false,
442
+ "required": ["actionId", "controlKind", "controlType", "decoderKind", "fieldName", "formId", "multiple", "template"],
443
+ "properties": {
444
+ "actionId": {
445
+ "type": "string",
446
+ "minLength": 1
447
+ },
448
+ "controlKind": {
449
+ "enum": ["input", "select"]
450
+ },
451
+ "controlCount": { "type": "integer", "minimum": 2 },
452
+ "controlType": {
453
+ "type": "string"
454
+ },
455
+ "decoderKind": {
456
+ "const": "text"
457
+ },
458
+ "fieldName": {
459
+ "type": "string",
460
+ "minLength": 1
461
+ },
462
+ "formId": {
463
+ "type": "string",
464
+ "minLength": 1
465
+ },
466
+ "multiple": {
467
+ "type": "boolean"
468
+ },
469
+ "template": {
470
+ "type": "string",
471
+ "minLength": 1,
472
+ "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
473
+ }
474
+ }
475
+ },
476
+ "formControlUnsupportedDiagnostic": {
477
+ "allOf": [
478
+ {
479
+ "$ref": "#/$defs/diagnosticBase"
480
+ },
481
+ {
482
+ "type": "object",
483
+ "properties": {
484
+ "code": { "const": "form.control_unsupported" },
485
+ "severity": { "const": "error" },
486
+ "category": { "const": "form-contract" },
487
+ "facts": { "$ref": "#/$defs/formControlUnsupportedFacts" }
488
+ }
489
+ }
490
+ ]
491
+ },
492
+ "formControlUnsupportedFacts": {
493
+ "type": "object",
494
+ "additionalProperties": false,
495
+ "required": ["actionId", "controlKind", "controlType", "fieldName", "formId", "reason", "template"],
496
+ "properties": {
497
+ "actionId": { "type": "string", "minLength": 1 },
498
+ "controlKind": { "enum": ["button", "input"] },
499
+ "controlType": { "type": "string" },
500
+ "fieldName": { "type": "string" },
501
+ "formId": { "type": "string", "minLength": 1 },
502
+ "reason": {
503
+ "enum": ["file-input", "named-submitter", "submitter-route-override"]
504
+ },
505
+ "template": {
506
+ "type": "string",
507
+ "minLength": 1,
508
+ "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
509
+ }
510
+ }
511
+ },
512
+ "handlerExportMissingDiagnostic": {
513
+ "allOf": [
514
+ {
515
+ "$ref": "#/$defs/diagnosticBase"
516
+ },
517
+ {
518
+ "type": "object",
519
+ "properties": {
520
+ "code": { "const": "handler.export_missing" },
521
+ "severity": { "const": "error" },
522
+ "category": { "const": "project-structure" },
523
+ "facts": { "$ref": "#/$defs/handlerExportMissingFacts" }
524
+ }
525
+ }
526
+ ]
527
+ },
528
+ "handlerExportMissingFacts": {
529
+ "type": "object",
530
+ "additionalProperties": false,
531
+ "required": ["actionId", "exportName", "handlerFile"],
532
+ "properties": {
533
+ "actionId": { "type": "string", "minLength": 1 },
534
+ "exportName": { "type": "string", "minLength": 1 },
535
+ "handlerFile": {
536
+ "type": "string",
537
+ "minLength": 1,
538
+ "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
539
+ }
540
+ }
541
+ },
542
+ "routeMissingDiagnostic": {
543
+ "allOf": [
544
+ { "$ref": "#/$defs/diagnosticBase" },
545
+ {
546
+ "type": "object",
547
+ "properties": {
548
+ "code": { "const": "route.missing" },
549
+ "severity": { "const": "error" },
550
+ "category": { "const": "route-contract" },
551
+ "facts": { "$ref": "#/$defs/routeMissingFacts" }
552
+ }
553
+ }
554
+ ]
555
+ },
556
+ "routeMissingFacts": {
557
+ "type": "object",
558
+ "additionalProperties": false,
559
+ "required": ["actionId", "expectedMethod", "expectedPath", "routeIndex", "sameMethodPaths"],
560
+ "properties": {
561
+ "actionId": { "type": "string", "minLength": 1 },
562
+ "expectedMethod": { "const": "POST" },
563
+ "expectedPath": { "type": "string", "pattern": "^/[^?#]*$" },
564
+ "routeIndex": {
565
+ "type": "string",
566
+ "minLength": 1,
567
+ "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
568
+ },
569
+ "sameMethodPaths": {
570
+ "type": "array",
571
+ "uniqueItems": true,
572
+ "items": { "type": "string", "pattern": "^/[^?#]*$" }
573
+ }
574
+ }
575
+ },
576
+ "moduleBoundaryViolationDiagnostic": {
577
+ "allOf": [
578
+ { "$ref": "#/$defs/diagnosticBase" },
579
+ {
580
+ "type": "object",
581
+ "properties": {
582
+ "code": { "const": "module.boundary_violation" },
583
+ "severity": { "const": "error" },
584
+ "category": { "const": "environment-boundary" },
585
+ "facts": { "$ref": "#/$defs/moduleBoundaryViolationFacts" }
586
+ }
587
+ }
588
+ ]
589
+ },
590
+ "moduleBoundaryViolationFacts": {
591
+ "type": "object",
592
+ "additionalProperties": false,
593
+ "required": ["boundaryId", "edgeKind", "importChain", "importSpecifier", "mode", "sourceRole", "targetFile", "targetRole"],
594
+ "properties": {
595
+ "boundaryId": { "type": "string", "minLength": 1 },
596
+ "edgeKind": { "enum": ["runtime", "type"] },
597
+ "importChain": {
598
+ "type": "array",
599
+ "minItems": 2,
600
+ "items": {
601
+ "type": "string",
602
+ "minLength": 1,
603
+ "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
604
+ }
605
+ },
606
+ "importSpecifier": { "type": "string", "minLength": 1 },
607
+ "mode": { "enum": ["direct", "transitive"] },
608
+ "sourceRole": { "type": "string", "minLength": 1 },
609
+ "targetFile": {
610
+ "type": "string",
611
+ "minLength": 1,
612
+ "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
613
+ },
614
+ "targetRole": { "type": "string", "minLength": 1 }
615
+ }
616
+ },
617
+ "moduleDynamicImportUnsupportedDiagnostic": {
618
+ "allOf": [
619
+ { "$ref": "#/$defs/diagnosticBase" },
620
+ {
621
+ "type": "object",
622
+ "properties": {
623
+ "code": { "const": "module.dynamic_import_unsupported" },
624
+ "severity": { "const": "error" },
625
+ "category": { "const": "environment-boundary" },
626
+ "facts": { "$ref": "#/$defs/moduleDynamicImportUnsupportedFacts" }
627
+ }
628
+ }
629
+ ]
630
+ },
631
+ "moduleDynamicImportUnsupportedFacts": {
632
+ "type": "object",
633
+ "additionalProperties": false,
634
+ "required": ["boundaryId", "mode", "sourceRole"],
635
+ "properties": {
636
+ "boundaryId": { "type": "string", "minLength": 1 },
637
+ "mode": { "enum": ["direct", "transitive"] },
638
+ "sourceRole": { "type": "string", "minLength": 1 }
639
+ }
640
+ },
641
+ "fileOwnershipMismatchDiagnostic": {
642
+ "allOf": [
643
+ { "$ref": "#/$defs/diagnosticBase" },
644
+ {
645
+ "type": "object",
646
+ "properties": {
647
+ "code": { "const": "file.ownership_mismatch" },
648
+ "severity": { "const": "error" },
649
+ "category": { "const": "project-structure" },
650
+ "facts": { "$ref": "#/$defs/fileOwnershipMismatchFacts" }
651
+ }
652
+ }
653
+ ]
654
+ },
655
+ "fileOwnershipMismatchFacts": {
656
+ "type": "object",
657
+ "additionalProperties": false,
658
+ "required": ["actualPath", "expectedWithinFeature", "featureId", "kind", "ruleId"],
659
+ "properties": {
660
+ "actualPath": {
661
+ "type": "string",
662
+ "minLength": 1,
663
+ "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
664
+ },
665
+ "expectedWithinFeature": {
666
+ "type": "string",
667
+ "minLength": 1,
668
+ "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
669
+ },
670
+ "featureId": {
671
+ "type": ["string", "null"],
672
+ "minLength": 1
673
+ },
674
+ "kind": { "enum": ["i18n", "test"] },
675
+ "ruleId": { "type": "string", "minLength": 1 }
676
+ }
677
+ },
678
+ "fileRoleMismatchDiagnostic": {
679
+ "allOf": [
680
+ {
681
+ "$ref": "#/$defs/diagnosticBase"
682
+ },
683
+ {
684
+ "type": "object",
685
+ "properties": {
686
+ "code": {
687
+ "const": "file.role_mismatch"
688
+ },
689
+ "severity": {
690
+ "const": "error"
691
+ },
692
+ "category": {
693
+ "const": "project-structure"
694
+ },
695
+ "facts": {
696
+ "$ref": "#/$defs/fileRoleMismatchFacts"
697
+ }
698
+ }
699
+ }
700
+ ]
701
+ },
702
+ "fileRoleMismatchFacts": {
703
+ "type": "object",
704
+ "additionalProperties": false,
705
+ "required": ["actionId", "actualRole", "expectedRole", "expectedWithinFeature", "featureId", "handlerFile"],
706
+ "properties": {
707
+ "actionId": {
708
+ "type": "string",
709
+ "minLength": 1
710
+ },
711
+ "actualRole": {
712
+ "type": "string",
713
+ "minLength": 1
714
+ },
715
+ "expectedRole": {
716
+ "type": "string",
717
+ "minLength": 1
718
+ },
719
+ "expectedWithinFeature": {
720
+ "type": "string",
721
+ "minLength": 1
722
+ },
723
+ "featureId": {
724
+ "type": "string",
725
+ "minLength": 1
726
+ },
727
+ "handlerFile": {
728
+ "type": "string",
729
+ "minLength": 1,
730
+ "pattern": "^(?!/)(?!.*(?:^|/)\\.\\.(?:/|$))(?!.*\\\\).+$"
731
+ }
732
+ }
733
+ }
734
+ }
735
+ }