@openpkg-ts/spec 0.4.0 → 0.5.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/dist/index.d.ts +43 -8
- package/dist/index.js +861 -27
- package/package.json +1 -1
- package/schemas/v0.2.0/openpkg.schema.json +10 -1
- package/schemas/v0.3.0/openpkg.schema.json +487 -0
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/constants.ts
|
|
2
|
-
var SCHEMA_VERSION = "0.
|
|
3
|
-
var SCHEMA_URL = "https://unpkg.com/@openpkg-ts/spec/schemas/v0.
|
|
2
|
+
var SCHEMA_VERSION = "0.3.0";
|
|
3
|
+
var SCHEMA_URL = "https://unpkg.com/@openpkg-ts/spec/schemas/v0.3.0/openpkg.schema.json";
|
|
4
4
|
var JSON_SCHEMA_DRAFT = "https://json-schema.org/draft/2020-12/schema";
|
|
5
5
|
// src/deref.ts
|
|
6
6
|
function dereference(spec) {
|
|
@@ -159,7 +159,21 @@ function toMap(items) {
|
|
|
159
159
|
}
|
|
160
160
|
return map;
|
|
161
161
|
}
|
|
162
|
-
var DOC_KEYS = new Set([
|
|
162
|
+
var DOC_KEYS = new Set([
|
|
163
|
+
"description",
|
|
164
|
+
"examples",
|
|
165
|
+
"tags",
|
|
166
|
+
"rawComments",
|
|
167
|
+
"source",
|
|
168
|
+
"docs",
|
|
169
|
+
"displayName",
|
|
170
|
+
"slug",
|
|
171
|
+
"importPath",
|
|
172
|
+
"category",
|
|
173
|
+
"coverageScore",
|
|
174
|
+
"missing",
|
|
175
|
+
"drift"
|
|
176
|
+
]);
|
|
163
177
|
function isDocOnlyChange(a, b) {
|
|
164
178
|
const structuralA = normalizeForComparison(removeDocFields(a));
|
|
165
179
|
const structuralB = normalizeForComparison(removeDocFields(b));
|
|
@@ -307,10 +321,738 @@ function normalizeType(item) {
|
|
|
307
321
|
// src/validate.ts
|
|
308
322
|
import Ajv from "ajv/dist/2020.js";
|
|
309
323
|
import addFormats from "ajv-formats";
|
|
324
|
+
// schemas/v0.1.0/openpkg.schema.json
|
|
325
|
+
var openpkg_schema_default = {
|
|
326
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
327
|
+
$id: "https://unpkg.com/@openpkg-ts/spec/schemas/v0.1.0/openpkg.schema.json",
|
|
328
|
+
title: "OpenPkg Specification",
|
|
329
|
+
description: "Schema for OpenPkg specification files",
|
|
330
|
+
type: "object",
|
|
331
|
+
required: ["openpkg", "meta", "exports"],
|
|
332
|
+
properties: {
|
|
333
|
+
$schema: {
|
|
334
|
+
type: "string",
|
|
335
|
+
description: "Reference to the OpenPkg schema version",
|
|
336
|
+
pattern: "^(https://raw\\.githubusercontent\\.com/ryanwaits/openpkg/main/schemas/v[0-9]+\\.[0-9]+\\.[0-9]+/openpkg\\.schema\\.json|https://unpkg\\.com/@openpkg-ts/spec/schemas/v[0-9]+\\.[0-9]+\\.[0-9]+/openpkg\\.schema\\.json)$"
|
|
337
|
+
},
|
|
338
|
+
openpkg: {
|
|
339
|
+
type: "string",
|
|
340
|
+
description: "OpenPkg specification version",
|
|
341
|
+
pattern: "^[0-9]+\\.[0-9]+\\.[0-9]+$",
|
|
342
|
+
const: "0.1.0"
|
|
343
|
+
},
|
|
344
|
+
meta: {
|
|
345
|
+
type: "object",
|
|
346
|
+
description: "Package metadata",
|
|
347
|
+
required: ["name"],
|
|
348
|
+
properties: {
|
|
349
|
+
name: {
|
|
350
|
+
type: "string",
|
|
351
|
+
description: "Package name"
|
|
352
|
+
},
|
|
353
|
+
version: {
|
|
354
|
+
type: "string",
|
|
355
|
+
description: "Package version"
|
|
356
|
+
},
|
|
357
|
+
description: {
|
|
358
|
+
type: "string",
|
|
359
|
+
description: "Package description"
|
|
360
|
+
},
|
|
361
|
+
license: {
|
|
362
|
+
type: "string",
|
|
363
|
+
description: "Package license"
|
|
364
|
+
},
|
|
365
|
+
repository: {
|
|
366
|
+
type: "string",
|
|
367
|
+
description: "Repository URL"
|
|
368
|
+
},
|
|
369
|
+
ecosystem: {
|
|
370
|
+
type: "string",
|
|
371
|
+
description: "Package ecosystem"
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
exports: {
|
|
376
|
+
type: "array",
|
|
377
|
+
description: "List of exported items",
|
|
378
|
+
items: {
|
|
379
|
+
$ref: "#/$defs/export"
|
|
380
|
+
}
|
|
381
|
+
},
|
|
382
|
+
types: {
|
|
383
|
+
type: "array",
|
|
384
|
+
description: "List of type definitions",
|
|
385
|
+
items: {
|
|
386
|
+
$ref: "#/$defs/typeDef"
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
$defs: {
|
|
391
|
+
export: {
|
|
392
|
+
type: "object",
|
|
393
|
+
required: ["id", "name", "kind"],
|
|
394
|
+
properties: {
|
|
395
|
+
id: {
|
|
396
|
+
type: "string",
|
|
397
|
+
description: "Unique identifier for the export"
|
|
398
|
+
},
|
|
399
|
+
name: {
|
|
400
|
+
type: "string",
|
|
401
|
+
description: "Export name"
|
|
402
|
+
},
|
|
403
|
+
slug: {
|
|
404
|
+
type: "string",
|
|
405
|
+
description: "Stable slug for linking"
|
|
406
|
+
},
|
|
407
|
+
displayName: {
|
|
408
|
+
type: "string",
|
|
409
|
+
description: "UI-friendly label"
|
|
410
|
+
},
|
|
411
|
+
category: {
|
|
412
|
+
type: "string",
|
|
413
|
+
description: "Grouping hint for navigation"
|
|
414
|
+
},
|
|
415
|
+
importPath: {
|
|
416
|
+
type: "string",
|
|
417
|
+
description: "Recommended import path"
|
|
418
|
+
},
|
|
419
|
+
kind: {
|
|
420
|
+
type: "string",
|
|
421
|
+
description: "Kind of export",
|
|
422
|
+
enum: ["function", "class", "variable", "interface", "type", "enum"]
|
|
423
|
+
},
|
|
424
|
+
description: {
|
|
425
|
+
type: "string",
|
|
426
|
+
description: "JSDoc/TSDoc description"
|
|
427
|
+
},
|
|
428
|
+
examples: {
|
|
429
|
+
type: "array",
|
|
430
|
+
description: "Usage examples from documentation",
|
|
431
|
+
items: {
|
|
432
|
+
type: "string"
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
signatures: {
|
|
436
|
+
type: "array",
|
|
437
|
+
description: "Function/method signatures",
|
|
438
|
+
items: {
|
|
439
|
+
$ref: "#/$defs/signature"
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
type: {
|
|
443
|
+
description: "Type reference or inline schema for variables",
|
|
444
|
+
oneOf: [{ type: "string" }, { $ref: "#/$defs/schema" }]
|
|
445
|
+
},
|
|
446
|
+
members: {
|
|
447
|
+
type: "array",
|
|
448
|
+
description: "Class/interface/enum members",
|
|
449
|
+
items: { type: "object" }
|
|
450
|
+
},
|
|
451
|
+
tags: {
|
|
452
|
+
type: "array",
|
|
453
|
+
description: "JSDoc/TSDoc tags",
|
|
454
|
+
items: {
|
|
455
|
+
type: "object",
|
|
456
|
+
required: ["name", "text"],
|
|
457
|
+
properties: {
|
|
458
|
+
name: { type: "string" },
|
|
459
|
+
text: { type: "string" }
|
|
460
|
+
},
|
|
461
|
+
additionalProperties: false
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
source: {
|
|
465
|
+
$ref: "#/$defs/sourceLocation"
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
typeDef: {
|
|
470
|
+
type: "object",
|
|
471
|
+
required: ["id", "name", "kind"],
|
|
472
|
+
properties: {
|
|
473
|
+
id: {
|
|
474
|
+
type: "string",
|
|
475
|
+
description: "Unique identifier for the type"
|
|
476
|
+
},
|
|
477
|
+
name: {
|
|
478
|
+
type: "string",
|
|
479
|
+
description: "Type name"
|
|
480
|
+
},
|
|
481
|
+
slug: {
|
|
482
|
+
type: "string",
|
|
483
|
+
description: "Stable slug for linking"
|
|
484
|
+
},
|
|
485
|
+
displayName: {
|
|
486
|
+
type: "string",
|
|
487
|
+
description: "UI-friendly label"
|
|
488
|
+
},
|
|
489
|
+
category: {
|
|
490
|
+
type: "string",
|
|
491
|
+
description: "Grouping hint for navigation"
|
|
492
|
+
},
|
|
493
|
+
importPath: {
|
|
494
|
+
type: "string",
|
|
495
|
+
description: "Recommended import path"
|
|
496
|
+
},
|
|
497
|
+
kind: {
|
|
498
|
+
type: "string",
|
|
499
|
+
description: "Kind of type definition",
|
|
500
|
+
enum: ["interface", "type", "enum", "class"]
|
|
501
|
+
},
|
|
502
|
+
description: {
|
|
503
|
+
type: "string",
|
|
504
|
+
description: "JSDoc/TSDoc description"
|
|
505
|
+
},
|
|
506
|
+
schema: {
|
|
507
|
+
$ref: "#/$defs/schema"
|
|
508
|
+
},
|
|
509
|
+
type: {
|
|
510
|
+
type: "string",
|
|
511
|
+
description: "Type expression for type aliases"
|
|
512
|
+
},
|
|
513
|
+
members: {
|
|
514
|
+
type: "array",
|
|
515
|
+
description: "Members for classes/interfaces/enums",
|
|
516
|
+
items: { type: "object" }
|
|
517
|
+
},
|
|
518
|
+
tags: {
|
|
519
|
+
type: "array",
|
|
520
|
+
description: "JSDoc/TSDoc tags",
|
|
521
|
+
items: {
|
|
522
|
+
type: "object",
|
|
523
|
+
required: ["name", "text"],
|
|
524
|
+
properties: {
|
|
525
|
+
name: { type: "string" },
|
|
526
|
+
text: { type: "string" }
|
|
527
|
+
},
|
|
528
|
+
additionalProperties: false
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
source: {
|
|
532
|
+
$ref: "#/$defs/sourceLocation"
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
},
|
|
536
|
+
signature: {
|
|
537
|
+
type: "object",
|
|
538
|
+
properties: {
|
|
539
|
+
parameters: {
|
|
540
|
+
type: "array",
|
|
541
|
+
items: {
|
|
542
|
+
$ref: "#/$defs/parameter"
|
|
543
|
+
}
|
|
544
|
+
},
|
|
545
|
+
returns: {
|
|
546
|
+
$ref: "#/$defs/returns"
|
|
547
|
+
},
|
|
548
|
+
description: {
|
|
549
|
+
type: "string",
|
|
550
|
+
description: "Signature-level description"
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
},
|
|
554
|
+
parameter: {
|
|
555
|
+
type: "object",
|
|
556
|
+
required: ["name", "required"],
|
|
557
|
+
properties: {
|
|
558
|
+
name: {
|
|
559
|
+
type: "string",
|
|
560
|
+
description: "Parameter name"
|
|
561
|
+
},
|
|
562
|
+
required: {
|
|
563
|
+
type: "boolean",
|
|
564
|
+
description: "Whether the parameter is required"
|
|
565
|
+
},
|
|
566
|
+
schema: {
|
|
567
|
+
$ref: "#/$defs/schema"
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
},
|
|
571
|
+
returns: {
|
|
572
|
+
type: "object",
|
|
573
|
+
properties: {
|
|
574
|
+
schema: {
|
|
575
|
+
$ref: "#/$defs/schema"
|
|
576
|
+
},
|
|
577
|
+
description: {
|
|
578
|
+
type: "string",
|
|
579
|
+
description: "Return value description"
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
},
|
|
583
|
+
schema: {
|
|
584
|
+
anyOf: [
|
|
585
|
+
{
|
|
586
|
+
type: "boolean"
|
|
587
|
+
},
|
|
588
|
+
{
|
|
589
|
+
type: "object",
|
|
590
|
+
properties: {
|
|
591
|
+
$ref: {
|
|
592
|
+
type: "string",
|
|
593
|
+
description: "Reference to another type",
|
|
594
|
+
pattern: "^#/types/[A-Za-z0-9_.-]+$"
|
|
595
|
+
}
|
|
596
|
+
},
|
|
597
|
+
required: ["$ref"],
|
|
598
|
+
additionalProperties: false
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
type: "object",
|
|
602
|
+
not: {
|
|
603
|
+
required: ["$ref"]
|
|
604
|
+
},
|
|
605
|
+
additionalProperties: true
|
|
606
|
+
}
|
|
607
|
+
]
|
|
608
|
+
},
|
|
609
|
+
sourceLocation: {
|
|
610
|
+
type: "object",
|
|
611
|
+
required: ["file", "line"],
|
|
612
|
+
properties: {
|
|
613
|
+
file: {
|
|
614
|
+
type: "string",
|
|
615
|
+
description: "Source file path"
|
|
616
|
+
},
|
|
617
|
+
line: {
|
|
618
|
+
type: "integer",
|
|
619
|
+
description: "Line number in source file",
|
|
620
|
+
minimum: 1
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
};
|
|
310
626
|
// schemas/v0.2.0/openpkg.schema.json
|
|
311
|
-
var
|
|
627
|
+
var openpkg_schema_default2 = {
|
|
628
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
629
|
+
$id: "https://unpkg.com/@openpkg-ts/spec/schemas/v0.2.0/openpkg.schema.json",
|
|
630
|
+
title: "OpenPkg Specification",
|
|
631
|
+
description: "Schema for OpenPkg specification files",
|
|
632
|
+
type: "object",
|
|
633
|
+
required: ["openpkg", "meta", "exports"],
|
|
634
|
+
properties: {
|
|
635
|
+
$schema: {
|
|
636
|
+
type: "string",
|
|
637
|
+
description: "Reference to the OpenPkg schema version",
|
|
638
|
+
pattern: "^(https://raw\\.githubusercontent\\.com/ryanwaits/openpkg/main/schemas/v[0-9]+\\.[0-9]+\\.[0-9]+/openpkg\\.schema\\.json|https://unpkg\\.com/@openpkg-ts/spec/schemas/v[0-9]+\\.[0-9]+\\.[0-9]+/openpkg\\.schema\\.json)$"
|
|
639
|
+
},
|
|
640
|
+
openpkg: {
|
|
641
|
+
type: "string",
|
|
642
|
+
description: "OpenPkg specification version",
|
|
643
|
+
pattern: "^[0-9]+\\.[0-9]+\\.[0-9]+$",
|
|
644
|
+
const: "0.2.0"
|
|
645
|
+
},
|
|
646
|
+
meta: {
|
|
647
|
+
type: "object",
|
|
648
|
+
description: "Package metadata",
|
|
649
|
+
required: ["name"],
|
|
650
|
+
properties: {
|
|
651
|
+
name: {
|
|
652
|
+
type: "string",
|
|
653
|
+
description: "Package name"
|
|
654
|
+
},
|
|
655
|
+
version: {
|
|
656
|
+
type: "string",
|
|
657
|
+
description: "Package version"
|
|
658
|
+
},
|
|
659
|
+
description: {
|
|
660
|
+
type: "string",
|
|
661
|
+
description: "Package description"
|
|
662
|
+
},
|
|
663
|
+
license: {
|
|
664
|
+
type: "string",
|
|
665
|
+
description: "Package license"
|
|
666
|
+
},
|
|
667
|
+
repository: {
|
|
668
|
+
type: "string",
|
|
669
|
+
description: "Repository URL"
|
|
670
|
+
},
|
|
671
|
+
ecosystem: {
|
|
672
|
+
type: "string",
|
|
673
|
+
description: "Package ecosystem"
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
},
|
|
677
|
+
exports: {
|
|
678
|
+
type: "array",
|
|
679
|
+
description: "List of exported items",
|
|
680
|
+
items: {
|
|
681
|
+
$ref: "#/$defs/export"
|
|
682
|
+
}
|
|
683
|
+
},
|
|
684
|
+
types: {
|
|
685
|
+
type: "array",
|
|
686
|
+
description: "List of type definitions",
|
|
687
|
+
items: {
|
|
688
|
+
$ref: "#/$defs/typeDef"
|
|
689
|
+
}
|
|
690
|
+
},
|
|
691
|
+
docs: {
|
|
692
|
+
$ref: "#/$defs/docsMetadata",
|
|
693
|
+
description: "Aggregate documentation coverage metadata"
|
|
694
|
+
}
|
|
695
|
+
},
|
|
696
|
+
$defs: {
|
|
697
|
+
docSignal: {
|
|
698
|
+
type: "string",
|
|
699
|
+
enum: ["description", "params", "returns", "examples"]
|
|
700
|
+
},
|
|
701
|
+
docDrift: {
|
|
702
|
+
type: "object",
|
|
703
|
+
required: ["type", "issue"],
|
|
704
|
+
properties: {
|
|
705
|
+
type: {
|
|
706
|
+
type: "string",
|
|
707
|
+
enum: [
|
|
708
|
+
"param-mismatch",
|
|
709
|
+
"param-type-mismatch",
|
|
710
|
+
"return-type-mismatch",
|
|
711
|
+
"generic-constraint-mismatch",
|
|
712
|
+
"optionality-mismatch",
|
|
713
|
+
"deprecated-mismatch",
|
|
714
|
+
"visibility-mismatch",
|
|
715
|
+
"async-mismatch",
|
|
716
|
+
"property-type-drift",
|
|
717
|
+
"example-drift",
|
|
718
|
+
"example-syntax-error",
|
|
719
|
+
"example-runtime-error",
|
|
720
|
+
"example-assertion-failed",
|
|
721
|
+
"broken-link"
|
|
722
|
+
]
|
|
723
|
+
},
|
|
724
|
+
target: {
|
|
725
|
+
type: "string",
|
|
726
|
+
description: "Relevant identifier (e.g., parameter name)"
|
|
727
|
+
},
|
|
728
|
+
issue: {
|
|
729
|
+
type: "string",
|
|
730
|
+
description: "Human-friendly drift explanation"
|
|
731
|
+
},
|
|
732
|
+
suggestion: {
|
|
733
|
+
type: "string",
|
|
734
|
+
description: "Optional remediation hint"
|
|
735
|
+
}
|
|
736
|
+
},
|
|
737
|
+
additionalProperties: false
|
|
738
|
+
},
|
|
739
|
+
docsMetadata: {
|
|
740
|
+
type: "object",
|
|
741
|
+
description: "Documentation coverage metadata",
|
|
742
|
+
additionalProperties: false,
|
|
743
|
+
properties: {
|
|
744
|
+
coverageScore: {
|
|
745
|
+
type: "number",
|
|
746
|
+
minimum: 0,
|
|
747
|
+
maximum: 100,
|
|
748
|
+
description: "Documentation coverage value from 0-100."
|
|
749
|
+
},
|
|
750
|
+
missing: {
|
|
751
|
+
type: "array",
|
|
752
|
+
description: "Doc components missing for this entity",
|
|
753
|
+
items: {
|
|
754
|
+
$ref: "#/$defs/docSignal"
|
|
755
|
+
},
|
|
756
|
+
uniqueItems: true
|
|
757
|
+
},
|
|
758
|
+
drift: {
|
|
759
|
+
type: "array",
|
|
760
|
+
description: "Detected documentation drift signals",
|
|
761
|
+
items: {
|
|
762
|
+
$ref: "#/$defs/docDrift"
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
},
|
|
767
|
+
export: {
|
|
768
|
+
type: "object",
|
|
769
|
+
required: ["id", "name", "kind"],
|
|
770
|
+
properties: {
|
|
771
|
+
id: {
|
|
772
|
+
type: "string",
|
|
773
|
+
description: "Unique identifier for the export"
|
|
774
|
+
},
|
|
775
|
+
name: {
|
|
776
|
+
type: "string",
|
|
777
|
+
description: "Export name"
|
|
778
|
+
},
|
|
779
|
+
slug: {
|
|
780
|
+
type: "string",
|
|
781
|
+
description: "Stable slug for linking"
|
|
782
|
+
},
|
|
783
|
+
displayName: {
|
|
784
|
+
type: "string",
|
|
785
|
+
description: "UI-friendly label"
|
|
786
|
+
},
|
|
787
|
+
alias: {
|
|
788
|
+
type: "string",
|
|
789
|
+
description: "Export alias if re-exported with a different name (id uses alias, name uses original)"
|
|
790
|
+
},
|
|
791
|
+
category: {
|
|
792
|
+
type: "string",
|
|
793
|
+
description: "Grouping hint for navigation"
|
|
794
|
+
},
|
|
795
|
+
importPath: {
|
|
796
|
+
type: "string",
|
|
797
|
+
description: "Recommended import path"
|
|
798
|
+
},
|
|
799
|
+
kind: {
|
|
800
|
+
type: "string",
|
|
801
|
+
description: "Kind of export",
|
|
802
|
+
enum: [
|
|
803
|
+
"function",
|
|
804
|
+
"class",
|
|
805
|
+
"variable",
|
|
806
|
+
"interface",
|
|
807
|
+
"type",
|
|
808
|
+
"enum",
|
|
809
|
+
"namespace",
|
|
810
|
+
"external"
|
|
811
|
+
]
|
|
812
|
+
},
|
|
813
|
+
description: {
|
|
814
|
+
type: "string",
|
|
815
|
+
description: "JSDoc/TSDoc description"
|
|
816
|
+
},
|
|
817
|
+
examples: {
|
|
818
|
+
type: "array",
|
|
819
|
+
description: "Usage examples from documentation",
|
|
820
|
+
items: {
|
|
821
|
+
type: "string"
|
|
822
|
+
}
|
|
823
|
+
},
|
|
824
|
+
signatures: {
|
|
825
|
+
type: "array",
|
|
826
|
+
description: "Function/method signatures",
|
|
827
|
+
items: {
|
|
828
|
+
$ref: "#/$defs/signature"
|
|
829
|
+
}
|
|
830
|
+
},
|
|
831
|
+
type: {
|
|
832
|
+
description: "Type reference or inline schema for variables",
|
|
833
|
+
oneOf: [{ type: "string" }, { $ref: "#/$defs/schema" }]
|
|
834
|
+
},
|
|
835
|
+
members: {
|
|
836
|
+
type: "array",
|
|
837
|
+
description: "Class/interface/enum members",
|
|
838
|
+
items: { type: "object" }
|
|
839
|
+
},
|
|
840
|
+
extends: {
|
|
841
|
+
type: "string",
|
|
842
|
+
description: "Base class or interface that this class/interface extends"
|
|
843
|
+
},
|
|
844
|
+
implements: {
|
|
845
|
+
type: "array",
|
|
846
|
+
description: "Interfaces implemented by this class",
|
|
847
|
+
items: { type: "string" }
|
|
848
|
+
},
|
|
849
|
+
tags: {
|
|
850
|
+
type: "array",
|
|
851
|
+
description: "JSDoc/TSDoc tags",
|
|
852
|
+
items: {
|
|
853
|
+
type: "object",
|
|
854
|
+
required: ["name", "text"],
|
|
855
|
+
properties: {
|
|
856
|
+
name: { type: "string" },
|
|
857
|
+
text: { type: "string" }
|
|
858
|
+
},
|
|
859
|
+
additionalProperties: false
|
|
860
|
+
}
|
|
861
|
+
},
|
|
862
|
+
source: {
|
|
863
|
+
$ref: "#/$defs/sourceLocation"
|
|
864
|
+
},
|
|
865
|
+
docs: {
|
|
866
|
+
$ref: "#/$defs/docsMetadata",
|
|
867
|
+
description: "Documentation coverage metadata for this export"
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
},
|
|
871
|
+
typeDef: {
|
|
872
|
+
type: "object",
|
|
873
|
+
required: ["id", "name", "kind"],
|
|
874
|
+
properties: {
|
|
875
|
+
id: {
|
|
876
|
+
type: "string",
|
|
877
|
+
description: "Unique identifier for the type"
|
|
878
|
+
},
|
|
879
|
+
name: {
|
|
880
|
+
type: "string",
|
|
881
|
+
description: "Type name"
|
|
882
|
+
},
|
|
883
|
+
slug: {
|
|
884
|
+
type: "string",
|
|
885
|
+
description: "Stable slug for linking"
|
|
886
|
+
},
|
|
887
|
+
displayName: {
|
|
888
|
+
type: "string",
|
|
889
|
+
description: "UI-friendly label"
|
|
890
|
+
},
|
|
891
|
+
alias: {
|
|
892
|
+
type: "string",
|
|
893
|
+
description: "Export alias if re-exported with a different name (id uses alias, name uses original)"
|
|
894
|
+
},
|
|
895
|
+
category: {
|
|
896
|
+
type: "string",
|
|
897
|
+
description: "Grouping hint for navigation"
|
|
898
|
+
},
|
|
899
|
+
importPath: {
|
|
900
|
+
type: "string",
|
|
901
|
+
description: "Recommended import path"
|
|
902
|
+
},
|
|
903
|
+
kind: {
|
|
904
|
+
type: "string",
|
|
905
|
+
description: "Kind of type definition",
|
|
906
|
+
enum: ["interface", "type", "enum", "class", "external"]
|
|
907
|
+
},
|
|
908
|
+
description: {
|
|
909
|
+
type: "string",
|
|
910
|
+
description: "JSDoc/TSDoc description"
|
|
911
|
+
},
|
|
912
|
+
schema: {
|
|
913
|
+
$ref: "#/$defs/schema"
|
|
914
|
+
},
|
|
915
|
+
type: {
|
|
916
|
+
type: "string",
|
|
917
|
+
description: "Type expression for type aliases"
|
|
918
|
+
},
|
|
919
|
+
members: {
|
|
920
|
+
type: "array",
|
|
921
|
+
description: "Members for classes/interfaces/enums",
|
|
922
|
+
items: { type: "object" }
|
|
923
|
+
},
|
|
924
|
+
extends: {
|
|
925
|
+
type: "string",
|
|
926
|
+
description: "Base class or interface that this class/interface extends"
|
|
927
|
+
},
|
|
928
|
+
implements: {
|
|
929
|
+
type: "array",
|
|
930
|
+
description: "Interfaces implemented by this class",
|
|
931
|
+
items: { type: "string" }
|
|
932
|
+
},
|
|
933
|
+
tags: {
|
|
934
|
+
type: "array",
|
|
935
|
+
description: "JSDoc/TSDoc tags",
|
|
936
|
+
items: {
|
|
937
|
+
type: "object",
|
|
938
|
+
required: ["name", "text"],
|
|
939
|
+
properties: {
|
|
940
|
+
name: { type: "string" },
|
|
941
|
+
text: { type: "string" }
|
|
942
|
+
},
|
|
943
|
+
additionalProperties: false
|
|
944
|
+
}
|
|
945
|
+
},
|
|
946
|
+
source: {
|
|
947
|
+
$ref: "#/$defs/sourceLocation"
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
},
|
|
951
|
+
signature: {
|
|
952
|
+
type: "object",
|
|
953
|
+
properties: {
|
|
954
|
+
parameters: {
|
|
955
|
+
type: "array",
|
|
956
|
+
items: {
|
|
957
|
+
$ref: "#/$defs/parameter"
|
|
958
|
+
}
|
|
959
|
+
},
|
|
960
|
+
returns: {
|
|
961
|
+
$ref: "#/$defs/returns"
|
|
962
|
+
},
|
|
963
|
+
description: {
|
|
964
|
+
type: "string",
|
|
965
|
+
description: "Signature-level description"
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
},
|
|
969
|
+
parameter: {
|
|
970
|
+
type: "object",
|
|
971
|
+
required: ["name", "required"],
|
|
972
|
+
properties: {
|
|
973
|
+
name: {
|
|
974
|
+
type: "string",
|
|
975
|
+
description: "Parameter name"
|
|
976
|
+
},
|
|
977
|
+
required: {
|
|
978
|
+
type: "boolean",
|
|
979
|
+
description: "Whether the parameter is required"
|
|
980
|
+
},
|
|
981
|
+
schema: {
|
|
982
|
+
$ref: "#/$defs/schema"
|
|
983
|
+
},
|
|
984
|
+
description: {
|
|
985
|
+
type: "string",
|
|
986
|
+
description: "Parameter description"
|
|
987
|
+
},
|
|
988
|
+
default: {
|
|
989
|
+
description: "Default value for the parameter"
|
|
990
|
+
},
|
|
991
|
+
rest: {
|
|
992
|
+
type: "boolean",
|
|
993
|
+
description: "Whether this is a rest parameter (...args)"
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
},
|
|
997
|
+
returns: {
|
|
998
|
+
type: "object",
|
|
999
|
+
properties: {
|
|
1000
|
+
schema: {
|
|
1001
|
+
$ref: "#/$defs/schema"
|
|
1002
|
+
},
|
|
1003
|
+
description: {
|
|
1004
|
+
type: "string",
|
|
1005
|
+
description: "Return value description"
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
},
|
|
1009
|
+
schema: {
|
|
1010
|
+
anyOf: [
|
|
1011
|
+
{
|
|
1012
|
+
type: "boolean"
|
|
1013
|
+
},
|
|
1014
|
+
{
|
|
1015
|
+
type: "object",
|
|
1016
|
+
properties: {
|
|
1017
|
+
$ref: {
|
|
1018
|
+
type: "string",
|
|
1019
|
+
description: "Reference to another type",
|
|
1020
|
+
pattern: "^#/types/[A-Za-z0-9_.-]+$"
|
|
1021
|
+
}
|
|
1022
|
+
},
|
|
1023
|
+
required: ["$ref"],
|
|
1024
|
+
additionalProperties: false
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
type: "object",
|
|
1028
|
+
not: {
|
|
1029
|
+
required: ["$ref"]
|
|
1030
|
+
},
|
|
1031
|
+
additionalProperties: true
|
|
1032
|
+
}
|
|
1033
|
+
]
|
|
1034
|
+
},
|
|
1035
|
+
sourceLocation: {
|
|
1036
|
+
type: "object",
|
|
1037
|
+
required: ["file", "line"],
|
|
1038
|
+
properties: {
|
|
1039
|
+
file: {
|
|
1040
|
+
type: "string",
|
|
1041
|
+
description: "Source file path"
|
|
1042
|
+
},
|
|
1043
|
+
line: {
|
|
1044
|
+
type: "integer",
|
|
1045
|
+
description: "Line number in source file",
|
|
1046
|
+
minimum: 1
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
// schemas/v0.3.0/openpkg.schema.json
|
|
1053
|
+
var openpkg_schema_default3 = {
|
|
312
1054
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
313
|
-
$id: "https://unpkg.com/@openpkg-ts/spec/schemas/v0.
|
|
1055
|
+
$id: "https://unpkg.com/@openpkg-ts/spec/schemas/v0.3.0/openpkg.schema.json",
|
|
314
1056
|
title: "OpenPkg Specification",
|
|
315
1057
|
description: "Schema for OpenPkg specification files",
|
|
316
1058
|
type: "object",
|
|
@@ -325,7 +1067,7 @@ var openpkg_schema_default = {
|
|
|
325
1067
|
type: "string",
|
|
326
1068
|
description: "OpenPkg specification version",
|
|
327
1069
|
pattern: "^[0-9]+\\.[0-9]+\\.[0-9]+$",
|
|
328
|
-
const: "0.
|
|
1070
|
+
const: "0.3.0"
|
|
329
1071
|
},
|
|
330
1072
|
meta: {
|
|
331
1073
|
type: "object",
|
|
@@ -483,7 +1225,16 @@ var openpkg_schema_default = {
|
|
|
483
1225
|
kind: {
|
|
484
1226
|
type: "string",
|
|
485
1227
|
description: "Kind of export",
|
|
486
|
-
enum: [
|
|
1228
|
+
enum: [
|
|
1229
|
+
"function",
|
|
1230
|
+
"class",
|
|
1231
|
+
"variable",
|
|
1232
|
+
"interface",
|
|
1233
|
+
"type",
|
|
1234
|
+
"enum",
|
|
1235
|
+
"namespace",
|
|
1236
|
+
"external"
|
|
1237
|
+
]
|
|
487
1238
|
},
|
|
488
1239
|
description: {
|
|
489
1240
|
type: "string",
|
|
@@ -525,13 +1276,7 @@ var openpkg_schema_default = {
|
|
|
525
1276
|
type: "array",
|
|
526
1277
|
description: "JSDoc/TSDoc tags",
|
|
527
1278
|
items: {
|
|
528
|
-
|
|
529
|
-
required: ["name", "text"],
|
|
530
|
-
properties: {
|
|
531
|
-
name: { type: "string" },
|
|
532
|
-
text: { type: "string" }
|
|
533
|
-
},
|
|
534
|
-
additionalProperties: false
|
|
1279
|
+
$ref: "#/$defs/tag"
|
|
535
1280
|
}
|
|
536
1281
|
},
|
|
537
1282
|
source: {
|
|
@@ -609,13 +1354,7 @@ var openpkg_schema_default = {
|
|
|
609
1354
|
type: "array",
|
|
610
1355
|
description: "JSDoc/TSDoc tags",
|
|
611
1356
|
items: {
|
|
612
|
-
|
|
613
|
-
required: ["name", "text"],
|
|
614
|
-
properties: {
|
|
615
|
-
name: { type: "string" },
|
|
616
|
-
text: { type: "string" }
|
|
617
|
-
},
|
|
618
|
-
additionalProperties: false
|
|
1357
|
+
$ref: "#/$defs/tag"
|
|
619
1358
|
}
|
|
620
1359
|
},
|
|
621
1360
|
source: {
|
|
@@ -623,6 +1362,46 @@ var openpkg_schema_default = {
|
|
|
623
1362
|
}
|
|
624
1363
|
}
|
|
625
1364
|
},
|
|
1365
|
+
tag: {
|
|
1366
|
+
type: "object",
|
|
1367
|
+
description: "JSDoc/TSDoc tag with optional structured fields",
|
|
1368
|
+
required: ["name", "text"],
|
|
1369
|
+
properties: {
|
|
1370
|
+
name: {
|
|
1371
|
+
type: "string",
|
|
1372
|
+
description: "Tag name (e.g., 'param', 'returns', 'deprecated')"
|
|
1373
|
+
},
|
|
1374
|
+
text: {
|
|
1375
|
+
type: "string",
|
|
1376
|
+
description: "Full tag text content"
|
|
1377
|
+
},
|
|
1378
|
+
paramName: {
|
|
1379
|
+
type: "string",
|
|
1380
|
+
description: "For @param tags: the parameter name"
|
|
1381
|
+
},
|
|
1382
|
+
typeAnnotation: {
|
|
1383
|
+
type: "string",
|
|
1384
|
+
description: "For @param/@returns: type annotation if present"
|
|
1385
|
+
},
|
|
1386
|
+
reference: {
|
|
1387
|
+
type: "string",
|
|
1388
|
+
description: "For @see/@link: resolved URL or symbol reference"
|
|
1389
|
+
},
|
|
1390
|
+
language: {
|
|
1391
|
+
type: "string",
|
|
1392
|
+
description: "For @example: code language hint (e.g., 'typescript', 'json')"
|
|
1393
|
+
},
|
|
1394
|
+
version: {
|
|
1395
|
+
type: "string",
|
|
1396
|
+
description: "For @since/@version: semver value"
|
|
1397
|
+
},
|
|
1398
|
+
reason: {
|
|
1399
|
+
type: "string",
|
|
1400
|
+
description: "For @deprecated: migration path or deprecation reason"
|
|
1401
|
+
}
|
|
1402
|
+
},
|
|
1403
|
+
additionalProperties: true
|
|
1404
|
+
},
|
|
626
1405
|
signature: {
|
|
627
1406
|
type: "object",
|
|
628
1407
|
properties: {
|
|
@@ -638,6 +1417,40 @@ var openpkg_schema_default = {
|
|
|
638
1417
|
description: {
|
|
639
1418
|
type: "string",
|
|
640
1419
|
description: "Signature-level description"
|
|
1420
|
+
},
|
|
1421
|
+
typeParameters: {
|
|
1422
|
+
type: "array",
|
|
1423
|
+
description: "Generic type parameters for this signature",
|
|
1424
|
+
items: {
|
|
1425
|
+
$ref: "#/$defs/typeParameter"
|
|
1426
|
+
}
|
|
1427
|
+
},
|
|
1428
|
+
overloadIndex: {
|
|
1429
|
+
type: "integer",
|
|
1430
|
+
minimum: 0,
|
|
1431
|
+
description: "Index of this overload (0-based), undefined for single signatures"
|
|
1432
|
+
},
|
|
1433
|
+
isImplementation: {
|
|
1434
|
+
type: "boolean",
|
|
1435
|
+
description: "True if this is the implementation signature (not user-callable)"
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
},
|
|
1439
|
+
typeParameter: {
|
|
1440
|
+
type: "object",
|
|
1441
|
+
required: ["name"],
|
|
1442
|
+
properties: {
|
|
1443
|
+
name: {
|
|
1444
|
+
type: "string",
|
|
1445
|
+
description: "Type parameter name (e.g., 'T', 'K')"
|
|
1446
|
+
},
|
|
1447
|
+
constraint: {
|
|
1448
|
+
type: "string",
|
|
1449
|
+
description: "Type constraint (e.g., 'extends string')"
|
|
1450
|
+
},
|
|
1451
|
+
default: {
|
|
1452
|
+
type: "string",
|
|
1453
|
+
description: "Default type value"
|
|
641
1454
|
}
|
|
642
1455
|
}
|
|
643
1456
|
},
|
|
@@ -726,6 +1539,12 @@ var openpkg_schema_default = {
|
|
|
726
1539
|
};
|
|
727
1540
|
|
|
728
1541
|
// src/validate.ts
|
|
1542
|
+
var LATEST_VERSION = "0.3.0";
|
|
1543
|
+
var schemas = {
|
|
1544
|
+
"0.1.0": openpkg_schema_default,
|
|
1545
|
+
"0.2.0": openpkg_schema_default2,
|
|
1546
|
+
"0.3.0": openpkg_schema_default3
|
|
1547
|
+
};
|
|
729
1548
|
var ajv = new Ajv({
|
|
730
1549
|
strict: false,
|
|
731
1550
|
allErrors: true,
|
|
@@ -733,8 +1552,23 @@ var ajv = new Ajv({
|
|
|
733
1552
|
$data: true
|
|
734
1553
|
});
|
|
735
1554
|
addFormats(ajv);
|
|
736
|
-
var
|
|
737
|
-
function
|
|
1555
|
+
var validatorCache = new Map;
|
|
1556
|
+
function getValidator(version = "latest") {
|
|
1557
|
+
const resolvedVersion = version === "latest" ? LATEST_VERSION : version;
|
|
1558
|
+
let validator = validatorCache.get(resolvedVersion);
|
|
1559
|
+
if (validator) {
|
|
1560
|
+
return validator;
|
|
1561
|
+
}
|
|
1562
|
+
const schema = schemas[resolvedVersion];
|
|
1563
|
+
if (!schema) {
|
|
1564
|
+
throw new Error(`Unknown schema version: ${resolvedVersion}. Available: ${Object.keys(schemas).join(", ")}`);
|
|
1565
|
+
}
|
|
1566
|
+
validator = ajv.compile(schema);
|
|
1567
|
+
validatorCache.set(resolvedVersion, validator);
|
|
1568
|
+
return validator;
|
|
1569
|
+
}
|
|
1570
|
+
function validateSpec(spec, version = "latest") {
|
|
1571
|
+
const validate = getValidator(version);
|
|
738
1572
|
const ok = validate(spec);
|
|
739
1573
|
if (ok) {
|
|
740
1574
|
return { ok: true };
|
|
@@ -749,8 +1583,8 @@ function validateSpec(spec) {
|
|
|
749
1583
|
errors
|
|
750
1584
|
};
|
|
751
1585
|
}
|
|
752
|
-
function assertSpec(spec) {
|
|
753
|
-
const result = validateSpec(spec);
|
|
1586
|
+
function assertSpec(spec, version = "latest") {
|
|
1587
|
+
const result = validateSpec(spec, version);
|
|
754
1588
|
if (!result.ok) {
|
|
755
1589
|
const details = result.errors.map((error) => `- ${error.instancePath || "/"} ${error.message}`).join(`
|
|
756
1590
|
`);
|
|
@@ -758,8 +1592,8 @@ function assertSpec(spec) {
|
|
|
758
1592
|
${details}`);
|
|
759
1593
|
}
|
|
760
1594
|
}
|
|
761
|
-
function getValidationErrors(spec) {
|
|
762
|
-
const result = validateSpec(spec);
|
|
1595
|
+
function getValidationErrors(spec, version = "latest") {
|
|
1596
|
+
const result = validateSpec(spec, version);
|
|
763
1597
|
return result.ok ? [] : result.errors;
|
|
764
1598
|
}
|
|
765
1599
|
export {
|