@openpkg-ts/spec 0.4.1 → 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 CHANGED
@@ -1,9 +1,12 @@
1
- declare const SCHEMA_VERSION = "0.2.0";
2
- declare const SCHEMA_URL = "https://unpkg.com/@openpkg-ts/spec/schemas/v0.2.0/openpkg.schema.json";
3
- declare const JSON_SCHEMA_DRAFT = "https://json-schema.org/draft/2020-12/schema";
4
1
  type SpecTag = {
5
2
  name: string;
6
3
  text: string;
4
+ paramName?: string;
5
+ typeAnnotation?: string;
6
+ reference?: string;
7
+ language?: string;
8
+ version?: string;
9
+ reason?: string;
7
10
  };
8
11
  type SpecSource = {
9
12
  file?: string;
@@ -36,6 +39,8 @@ type SpecSignatureParameter = {
36
39
  required?: boolean;
37
40
  description?: string;
38
41
  schema: SpecSchema;
42
+ default?: unknown;
43
+ rest?: boolean;
39
44
  };
40
45
  type SpecSignatureReturn = {
41
46
  schema: SpecSchema;
@@ -47,6 +52,8 @@ type SpecSignature = {
47
52
  returns?: SpecSignatureReturn;
48
53
  description?: string;
49
54
  typeParameters?: SpecTypeParameter[];
55
+ overloadIndex?: number;
56
+ isImplementation?: boolean;
50
57
  };
51
58
  type SpecMember = {
52
59
  id?: string;
@@ -112,9 +119,11 @@ type OpenPkgMeta = {
112
119
  repository?: string;
113
120
  ecosystem?: string;
114
121
  };
122
+ /** Supported OpenPkg spec versions */
123
+ type OpenPkgVersion = "0.2.0" | "0.3.0";
115
124
  type OpenPkg = {
116
125
  $schema?: string;
117
- openpkg: "0.2.0";
126
+ openpkg: OpenPkgVersion;
118
127
  meta: OpenPkgMeta;
119
128
  exports: SpecExport[];
120
129
  types?: SpecType[];
@@ -122,6 +131,9 @@ type OpenPkg = {
122
131
  docs?: SpecDocsMetadata;
123
132
  extensions?: SpecExtension;
124
133
  };
134
+ declare const SCHEMA_VERSION: OpenPkgVersion;
135
+ declare const SCHEMA_URL = "https://unpkg.com/@openpkg-ts/spec/schemas/v0.3.0/openpkg.schema.json";
136
+ declare const JSON_SCHEMA_DRAFT = "https://json-schema.org/draft/2020-12/schema";
125
137
  declare function dereference(spec: OpenPkg): OpenPkg;
126
138
  type BreakingSeverity = "high" | "medium" | "low";
127
139
  interface CategorizedBreaking {
@@ -164,7 +176,7 @@ declare function diffSpec(oldSpec: OpenPkg, newSpec: OpenPkg): SpecDiff;
164
176
  declare function categorizeBreakingChanges(breaking: string[], oldSpec: OpenPkg, newSpec: OpenPkg, memberChanges?: MemberChangeInfo[]): CategorizedBreaking[];
165
177
  declare function normalize(spec: OpenPkg): OpenPkg;
166
178
  /** Supported schema versions */
167
- type SchemaVersion = "0.1.0" | "0.2.0" | "latest";
179
+ type SchemaVersion = "0.1.0" | "0.2.0" | "0.3.0" | "latest";
168
180
  type SpecError = {
169
181
  instancePath: string;
170
182
  message: string;
@@ -199,4 +211,4 @@ declare function assertSpec(spec: unknown, version?: SchemaVersion): asserts spe
199
211
  * @returns Array of validation errors (empty if valid)
200
212
  */
201
213
  declare function getValidationErrors(spec: unknown, version?: SchemaVersion): SpecError[];
202
- export { validateSpec, normalize, getValidationErrors, diffSpec, dereference, categorizeBreakingChanges, assertSpec, SpecVisibility, SpecTypeParameter, SpecTypeKind, SpecType, SpecTag, SpecSource, SpecSignatureReturn, SpecSignatureParameter, SpecSignature, SpecSchema, SpecMember, SpecExtension, SpecExportKind, SpecExport, SpecExample, SpecDocsMetadata, SpecDocSignal, SpecDocDrift, SpecDiff, SCHEMA_VERSION, SCHEMA_URL, OpenPkgMeta, OpenPkg, MemberChangeInfo, JSON_SCHEMA_DRAFT, CategorizedBreaking, BreakingSeverity };
214
+ export { validateSpec, normalize, getValidationErrors, diffSpec, dereference, categorizeBreakingChanges, assertSpec, SpecVisibility, SpecTypeParameter, SpecTypeKind, SpecType, SpecTag, SpecSource, SpecSignatureReturn, SpecSignatureParameter, SpecSignature, SpecSchema, SpecMember, SpecExtension, SpecExportKind, SpecExport, SpecExample, SpecDocsMetadata, SpecDocSignal, SpecDocDrift, SpecDiff, SCHEMA_VERSION, SCHEMA_URL, OpenPkgVersion, OpenPkgMeta, OpenPkg, MemberChangeInfo, JSON_SCHEMA_DRAFT, CategorizedBreaking, BreakingSeverity };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/constants.ts
2
- var SCHEMA_VERSION = "0.2.0";
3
- var SCHEMA_URL = "https://unpkg.com/@openpkg-ts/spec/schemas/v0.2.0/openpkg.schema.json";
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) {
@@ -321,8 +321,310 @@ function normalizeType(item) {
321
321
  // src/validate.ts
322
322
  import Ajv from "ajv/dist/2020.js";
323
323
  import addFormats from "ajv-formats";
324
- // schemas/v0.2.0/openpkg.schema.json
324
+ // schemas/v0.1.0/openpkg.schema.json
325
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
+ };
626
+ // schemas/v0.2.0/openpkg.schema.json
627
+ var openpkg_schema_default2 = {
326
628
  $schema: "https://json-schema.org/draft/2020-12/schema",
327
629
  $id: "https://unpkg.com/@openpkg-ts/spec/schemas/v0.2.0/openpkg.schema.json",
328
630
  title: "OpenPkg Specification",
@@ -747,10 +1049,10 @@ var openpkg_schema_default = {
747
1049
  }
748
1050
  }
749
1051
  };
750
- // schemas/v0.1.0/openpkg.schema.json
751
- var openpkg_schema_default2 = {
1052
+ // schemas/v0.3.0/openpkg.schema.json
1053
+ var openpkg_schema_default3 = {
752
1054
  $schema: "https://json-schema.org/draft/2020-12/schema",
753
- $id: "https://unpkg.com/@openpkg-ts/spec/schemas/v0.1.0/openpkg.schema.json",
1055
+ $id: "https://unpkg.com/@openpkg-ts/spec/schemas/v0.3.0/openpkg.schema.json",
754
1056
  title: "OpenPkg Specification",
755
1057
  description: "Schema for OpenPkg specification files",
756
1058
  type: "object",
@@ -765,7 +1067,7 @@ var openpkg_schema_default2 = {
765
1067
  type: "string",
766
1068
  description: "OpenPkg specification version",
767
1069
  pattern: "^[0-9]+\\.[0-9]+\\.[0-9]+$",
768
- const: "0.1.0"
1070
+ const: "0.3.0"
769
1071
  },
770
1072
  meta: {
771
1073
  type: "object",
@@ -811,9 +1113,83 @@ var openpkg_schema_default2 = {
811
1113
  items: {
812
1114
  $ref: "#/$defs/typeDef"
813
1115
  }
1116
+ },
1117
+ docs: {
1118
+ $ref: "#/$defs/docsMetadata",
1119
+ description: "Aggregate documentation coverage metadata"
814
1120
  }
815
1121
  },
816
1122
  $defs: {
1123
+ docSignal: {
1124
+ type: "string",
1125
+ enum: ["description", "params", "returns", "examples"]
1126
+ },
1127
+ docDrift: {
1128
+ type: "object",
1129
+ required: ["type", "issue"],
1130
+ properties: {
1131
+ type: {
1132
+ type: "string",
1133
+ enum: [
1134
+ "param-mismatch",
1135
+ "param-type-mismatch",
1136
+ "return-type-mismatch",
1137
+ "generic-constraint-mismatch",
1138
+ "optionality-mismatch",
1139
+ "deprecated-mismatch",
1140
+ "visibility-mismatch",
1141
+ "async-mismatch",
1142
+ "property-type-drift",
1143
+ "example-drift",
1144
+ "example-syntax-error",
1145
+ "example-runtime-error",
1146
+ "example-assertion-failed",
1147
+ "broken-link"
1148
+ ]
1149
+ },
1150
+ target: {
1151
+ type: "string",
1152
+ description: "Relevant identifier (e.g., parameter name)"
1153
+ },
1154
+ issue: {
1155
+ type: "string",
1156
+ description: "Human-friendly drift explanation"
1157
+ },
1158
+ suggestion: {
1159
+ type: "string",
1160
+ description: "Optional remediation hint"
1161
+ }
1162
+ },
1163
+ additionalProperties: false
1164
+ },
1165
+ docsMetadata: {
1166
+ type: "object",
1167
+ description: "Documentation coverage metadata",
1168
+ additionalProperties: false,
1169
+ properties: {
1170
+ coverageScore: {
1171
+ type: "number",
1172
+ minimum: 0,
1173
+ maximum: 100,
1174
+ description: "Documentation coverage value from 0-100."
1175
+ },
1176
+ missing: {
1177
+ type: "array",
1178
+ description: "Doc components missing for this entity",
1179
+ items: {
1180
+ $ref: "#/$defs/docSignal"
1181
+ },
1182
+ uniqueItems: true
1183
+ },
1184
+ drift: {
1185
+ type: "array",
1186
+ description: "Detected documentation drift signals",
1187
+ items: {
1188
+ $ref: "#/$defs/docDrift"
1189
+ }
1190
+ }
1191
+ }
1192
+ },
817
1193
  export: {
818
1194
  type: "object",
819
1195
  required: ["id", "name", "kind"],
@@ -834,6 +1210,10 @@ var openpkg_schema_default2 = {
834
1210
  type: "string",
835
1211
  description: "UI-friendly label"
836
1212
  },
1213
+ alias: {
1214
+ type: "string",
1215
+ description: "Export alias if re-exported with a different name (id uses alias, name uses original)"
1216
+ },
837
1217
  category: {
838
1218
  type: "string",
839
1219
  description: "Grouping hint for navigation"
@@ -845,7 +1225,16 @@ var openpkg_schema_default2 = {
845
1225
  kind: {
846
1226
  type: "string",
847
1227
  description: "Kind of export",
848
- enum: ["function", "class", "variable", "interface", "type", "enum"]
1228
+ enum: [
1229
+ "function",
1230
+ "class",
1231
+ "variable",
1232
+ "interface",
1233
+ "type",
1234
+ "enum",
1235
+ "namespace",
1236
+ "external"
1237
+ ]
849
1238
  },
850
1239
  description: {
851
1240
  type: "string",
@@ -874,21 +1263,28 @@ var openpkg_schema_default2 = {
874
1263
  description: "Class/interface/enum members",
875
1264
  items: { type: "object" }
876
1265
  },
1266
+ extends: {
1267
+ type: "string",
1268
+ description: "Base class or interface that this class/interface extends"
1269
+ },
1270
+ implements: {
1271
+ type: "array",
1272
+ description: "Interfaces implemented by this class",
1273
+ items: { type: "string" }
1274
+ },
877
1275
  tags: {
878
1276
  type: "array",
879
1277
  description: "JSDoc/TSDoc tags",
880
1278
  items: {
881
- type: "object",
882
- required: ["name", "text"],
883
- properties: {
884
- name: { type: "string" },
885
- text: { type: "string" }
886
- },
887
- additionalProperties: false
1279
+ $ref: "#/$defs/tag"
888
1280
  }
889
1281
  },
890
1282
  source: {
891
1283
  $ref: "#/$defs/sourceLocation"
1284
+ },
1285
+ docs: {
1286
+ $ref: "#/$defs/docsMetadata",
1287
+ description: "Documentation coverage metadata for this export"
892
1288
  }
893
1289
  }
894
1290
  },
@@ -912,6 +1308,10 @@ var openpkg_schema_default2 = {
912
1308
  type: "string",
913
1309
  description: "UI-friendly label"
914
1310
  },
1311
+ alias: {
1312
+ type: "string",
1313
+ description: "Export alias if re-exported with a different name (id uses alias, name uses original)"
1314
+ },
915
1315
  category: {
916
1316
  type: "string",
917
1317
  description: "Grouping hint for navigation"
@@ -923,7 +1323,7 @@ var openpkg_schema_default2 = {
923
1323
  kind: {
924
1324
  type: "string",
925
1325
  description: "Kind of type definition",
926
- enum: ["interface", "type", "enum", "class"]
1326
+ enum: ["interface", "type", "enum", "class", "external"]
927
1327
  },
928
1328
  description: {
929
1329
  type: "string",
@@ -941,17 +1341,20 @@ var openpkg_schema_default2 = {
941
1341
  description: "Members for classes/interfaces/enums",
942
1342
  items: { type: "object" }
943
1343
  },
1344
+ extends: {
1345
+ type: "string",
1346
+ description: "Base class or interface that this class/interface extends"
1347
+ },
1348
+ implements: {
1349
+ type: "array",
1350
+ description: "Interfaces implemented by this class",
1351
+ items: { type: "string" }
1352
+ },
944
1353
  tags: {
945
1354
  type: "array",
946
1355
  description: "JSDoc/TSDoc tags",
947
1356
  items: {
948
- type: "object",
949
- required: ["name", "text"],
950
- properties: {
951
- name: { type: "string" },
952
- text: { type: "string" }
953
- },
954
- additionalProperties: false
1357
+ $ref: "#/$defs/tag"
955
1358
  }
956
1359
  },
957
1360
  source: {
@@ -959,6 +1362,46 @@ var openpkg_schema_default2 = {
959
1362
  }
960
1363
  }
961
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
+ },
962
1405
  signature: {
963
1406
  type: "object",
964
1407
  properties: {
@@ -974,6 +1417,40 @@ var openpkg_schema_default2 = {
974
1417
  description: {
975
1418
  type: "string",
976
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"
977
1454
  }
978
1455
  }
979
1456
  },
@@ -991,6 +1468,17 @@ var openpkg_schema_default2 = {
991
1468
  },
992
1469
  schema: {
993
1470
  $ref: "#/$defs/schema"
1471
+ },
1472
+ description: {
1473
+ type: "string",
1474
+ description: "Parameter description"
1475
+ },
1476
+ default: {
1477
+ description: "Default value for the parameter"
1478
+ },
1479
+ rest: {
1480
+ type: "boolean",
1481
+ description: "Whether this is a rest parameter (...args)"
994
1482
  }
995
1483
  }
996
1484
  },
@@ -1051,10 +1539,11 @@ var openpkg_schema_default2 = {
1051
1539
  };
1052
1540
 
1053
1541
  // src/validate.ts
1054
- var LATEST_VERSION = "0.2.0";
1542
+ var LATEST_VERSION = "0.3.0";
1055
1543
  var schemas = {
1056
- "0.1.0": openpkg_schema_default2,
1057
- "0.2.0": openpkg_schema_default
1544
+ "0.1.0": openpkg_schema_default,
1545
+ "0.2.0": openpkg_schema_default2,
1546
+ "0.3.0": openpkg_schema_default3
1058
1547
  };
1059
1548
  var ajv = new Ajv({
1060
1549
  strict: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpkg-ts/spec",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "Shared schema, validation, and diff utilities for OpenPkg specs",
5
5
  "keywords": [
6
6
  "openpkg",
@@ -0,0 +1,487 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://unpkg.com/@openpkg-ts/spec/schemas/v0.3.0/openpkg.schema.json",
4
+ "title": "OpenPkg Specification",
5
+ "description": "Schema for OpenPkg specification files",
6
+ "type": "object",
7
+ "required": ["openpkg", "meta", "exports"],
8
+ "properties": {
9
+ "$schema": {
10
+ "type": "string",
11
+ "description": "Reference to the OpenPkg schema version",
12
+ "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)$"
13
+ },
14
+ "openpkg": {
15
+ "type": "string",
16
+ "description": "OpenPkg specification version",
17
+ "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$",
18
+ "const": "0.3.0"
19
+ },
20
+ "meta": {
21
+ "type": "object",
22
+ "description": "Package metadata",
23
+ "required": ["name"],
24
+ "properties": {
25
+ "name": {
26
+ "type": "string",
27
+ "description": "Package name"
28
+ },
29
+ "version": {
30
+ "type": "string",
31
+ "description": "Package version"
32
+ },
33
+ "description": {
34
+ "type": "string",
35
+ "description": "Package description"
36
+ },
37
+ "license": {
38
+ "type": "string",
39
+ "description": "Package license"
40
+ },
41
+ "repository": {
42
+ "type": "string",
43
+ "description": "Repository URL"
44
+ },
45
+ "ecosystem": {
46
+ "type": "string",
47
+ "description": "Package ecosystem"
48
+ }
49
+ }
50
+ },
51
+ "exports": {
52
+ "type": "array",
53
+ "description": "List of exported items",
54
+ "items": {
55
+ "$ref": "#/$defs/export"
56
+ }
57
+ },
58
+ "types": {
59
+ "type": "array",
60
+ "description": "List of type definitions",
61
+ "items": {
62
+ "$ref": "#/$defs/typeDef"
63
+ }
64
+ },
65
+ "docs": {
66
+ "$ref": "#/$defs/docsMetadata",
67
+ "description": "Aggregate documentation coverage metadata"
68
+ }
69
+ },
70
+ "$defs": {
71
+ "docSignal": {
72
+ "type": "string",
73
+ "enum": ["description", "params", "returns", "examples"]
74
+ },
75
+ "docDrift": {
76
+ "type": "object",
77
+ "required": ["type", "issue"],
78
+ "properties": {
79
+ "type": {
80
+ "type": "string",
81
+ "enum": [
82
+ "param-mismatch",
83
+ "param-type-mismatch",
84
+ "return-type-mismatch",
85
+ "generic-constraint-mismatch",
86
+ "optionality-mismatch",
87
+ "deprecated-mismatch",
88
+ "visibility-mismatch",
89
+ "async-mismatch",
90
+ "property-type-drift",
91
+ "example-drift",
92
+ "example-syntax-error",
93
+ "example-runtime-error",
94
+ "example-assertion-failed",
95
+ "broken-link"
96
+ ]
97
+ },
98
+ "target": {
99
+ "type": "string",
100
+ "description": "Relevant identifier (e.g., parameter name)"
101
+ },
102
+ "issue": {
103
+ "type": "string",
104
+ "description": "Human-friendly drift explanation"
105
+ },
106
+ "suggestion": {
107
+ "type": "string",
108
+ "description": "Optional remediation hint"
109
+ }
110
+ },
111
+ "additionalProperties": false
112
+ },
113
+ "docsMetadata": {
114
+ "type": "object",
115
+ "description": "Documentation coverage metadata",
116
+ "additionalProperties": false,
117
+ "properties": {
118
+ "coverageScore": {
119
+ "type": "number",
120
+ "minimum": 0,
121
+ "maximum": 100,
122
+ "description": "Documentation coverage value from 0-100."
123
+ },
124
+ "missing": {
125
+ "type": "array",
126
+ "description": "Doc components missing for this entity",
127
+ "items": {
128
+ "$ref": "#/$defs/docSignal"
129
+ },
130
+ "uniqueItems": true
131
+ },
132
+ "drift": {
133
+ "type": "array",
134
+ "description": "Detected documentation drift signals",
135
+ "items": {
136
+ "$ref": "#/$defs/docDrift"
137
+ }
138
+ }
139
+ }
140
+ },
141
+ "export": {
142
+ "type": "object",
143
+ "required": ["id", "name", "kind"],
144
+ "properties": {
145
+ "id": {
146
+ "type": "string",
147
+ "description": "Unique identifier for the export"
148
+ },
149
+ "name": {
150
+ "type": "string",
151
+ "description": "Export name"
152
+ },
153
+ "slug": {
154
+ "type": "string",
155
+ "description": "Stable slug for linking"
156
+ },
157
+ "displayName": {
158
+ "type": "string",
159
+ "description": "UI-friendly label"
160
+ },
161
+ "alias": {
162
+ "type": "string",
163
+ "description": "Export alias if re-exported with a different name (id uses alias, name uses original)"
164
+ },
165
+ "category": {
166
+ "type": "string",
167
+ "description": "Grouping hint for navigation"
168
+ },
169
+ "importPath": {
170
+ "type": "string",
171
+ "description": "Recommended import path"
172
+ },
173
+ "kind": {
174
+ "type": "string",
175
+ "description": "Kind of export",
176
+ "enum": [
177
+ "function",
178
+ "class",
179
+ "variable",
180
+ "interface",
181
+ "type",
182
+ "enum",
183
+ "namespace",
184
+ "external"
185
+ ]
186
+ },
187
+ "description": {
188
+ "type": "string",
189
+ "description": "JSDoc/TSDoc description"
190
+ },
191
+ "examples": {
192
+ "type": "array",
193
+ "description": "Usage examples from documentation",
194
+ "items": {
195
+ "type": "string"
196
+ }
197
+ },
198
+ "signatures": {
199
+ "type": "array",
200
+ "description": "Function/method signatures",
201
+ "items": {
202
+ "$ref": "#/$defs/signature"
203
+ }
204
+ },
205
+ "type": {
206
+ "description": "Type reference or inline schema for variables",
207
+ "oneOf": [{ "type": "string" }, { "$ref": "#/$defs/schema" }]
208
+ },
209
+ "members": {
210
+ "type": "array",
211
+ "description": "Class/interface/enum members",
212
+ "items": { "type": "object" }
213
+ },
214
+ "extends": {
215
+ "type": "string",
216
+ "description": "Base class or interface that this class/interface extends"
217
+ },
218
+ "implements": {
219
+ "type": "array",
220
+ "description": "Interfaces implemented by this class",
221
+ "items": { "type": "string" }
222
+ },
223
+ "tags": {
224
+ "type": "array",
225
+ "description": "JSDoc/TSDoc tags",
226
+ "items": {
227
+ "$ref": "#/$defs/tag"
228
+ }
229
+ },
230
+ "source": {
231
+ "$ref": "#/$defs/sourceLocation"
232
+ },
233
+ "docs": {
234
+ "$ref": "#/$defs/docsMetadata",
235
+ "description": "Documentation coverage metadata for this export"
236
+ }
237
+ }
238
+ },
239
+ "typeDef": {
240
+ "type": "object",
241
+ "required": ["id", "name", "kind"],
242
+ "properties": {
243
+ "id": {
244
+ "type": "string",
245
+ "description": "Unique identifier for the type"
246
+ },
247
+ "name": {
248
+ "type": "string",
249
+ "description": "Type name"
250
+ },
251
+ "slug": {
252
+ "type": "string",
253
+ "description": "Stable slug for linking"
254
+ },
255
+ "displayName": {
256
+ "type": "string",
257
+ "description": "UI-friendly label"
258
+ },
259
+ "alias": {
260
+ "type": "string",
261
+ "description": "Export alias if re-exported with a different name (id uses alias, name uses original)"
262
+ },
263
+ "category": {
264
+ "type": "string",
265
+ "description": "Grouping hint for navigation"
266
+ },
267
+ "importPath": {
268
+ "type": "string",
269
+ "description": "Recommended import path"
270
+ },
271
+ "kind": {
272
+ "type": "string",
273
+ "description": "Kind of type definition",
274
+ "enum": ["interface", "type", "enum", "class", "external"]
275
+ },
276
+ "description": {
277
+ "type": "string",
278
+ "description": "JSDoc/TSDoc description"
279
+ },
280
+ "schema": {
281
+ "$ref": "#/$defs/schema"
282
+ },
283
+ "type": {
284
+ "type": "string",
285
+ "description": "Type expression for type aliases"
286
+ },
287
+ "members": {
288
+ "type": "array",
289
+ "description": "Members for classes/interfaces/enums",
290
+ "items": { "type": "object" }
291
+ },
292
+ "extends": {
293
+ "type": "string",
294
+ "description": "Base class or interface that this class/interface extends"
295
+ },
296
+ "implements": {
297
+ "type": "array",
298
+ "description": "Interfaces implemented by this class",
299
+ "items": { "type": "string" }
300
+ },
301
+ "tags": {
302
+ "type": "array",
303
+ "description": "JSDoc/TSDoc tags",
304
+ "items": {
305
+ "$ref": "#/$defs/tag"
306
+ }
307
+ },
308
+ "source": {
309
+ "$ref": "#/$defs/sourceLocation"
310
+ }
311
+ }
312
+ },
313
+ "tag": {
314
+ "type": "object",
315
+ "description": "JSDoc/TSDoc tag with optional structured fields",
316
+ "required": ["name", "text"],
317
+ "properties": {
318
+ "name": {
319
+ "type": "string",
320
+ "description": "Tag name (e.g., 'param', 'returns', 'deprecated')"
321
+ },
322
+ "text": {
323
+ "type": "string",
324
+ "description": "Full tag text content"
325
+ },
326
+ "paramName": {
327
+ "type": "string",
328
+ "description": "For @param tags: the parameter name"
329
+ },
330
+ "typeAnnotation": {
331
+ "type": "string",
332
+ "description": "For @param/@returns: type annotation if present"
333
+ },
334
+ "reference": {
335
+ "type": "string",
336
+ "description": "For @see/@link: resolved URL or symbol reference"
337
+ },
338
+ "language": {
339
+ "type": "string",
340
+ "description": "For @example: code language hint (e.g., 'typescript', 'json')"
341
+ },
342
+ "version": {
343
+ "type": "string",
344
+ "description": "For @since/@version: semver value"
345
+ },
346
+ "reason": {
347
+ "type": "string",
348
+ "description": "For @deprecated: migration path or deprecation reason"
349
+ }
350
+ },
351
+ "additionalProperties": true
352
+ },
353
+ "signature": {
354
+ "type": "object",
355
+ "properties": {
356
+ "parameters": {
357
+ "type": "array",
358
+ "items": {
359
+ "$ref": "#/$defs/parameter"
360
+ }
361
+ },
362
+ "returns": {
363
+ "$ref": "#/$defs/returns"
364
+ },
365
+ "description": {
366
+ "type": "string",
367
+ "description": "Signature-level description"
368
+ },
369
+ "typeParameters": {
370
+ "type": "array",
371
+ "description": "Generic type parameters for this signature",
372
+ "items": {
373
+ "$ref": "#/$defs/typeParameter"
374
+ }
375
+ },
376
+ "overloadIndex": {
377
+ "type": "integer",
378
+ "minimum": 0,
379
+ "description": "Index of this overload (0-based), undefined for single signatures"
380
+ },
381
+ "isImplementation": {
382
+ "type": "boolean",
383
+ "description": "True if this is the implementation signature (not user-callable)"
384
+ }
385
+ }
386
+ },
387
+ "typeParameter": {
388
+ "type": "object",
389
+ "required": ["name"],
390
+ "properties": {
391
+ "name": {
392
+ "type": "string",
393
+ "description": "Type parameter name (e.g., 'T', 'K')"
394
+ },
395
+ "constraint": {
396
+ "type": "string",
397
+ "description": "Type constraint (e.g., 'extends string')"
398
+ },
399
+ "default": {
400
+ "type": "string",
401
+ "description": "Default type value"
402
+ }
403
+ }
404
+ },
405
+ "parameter": {
406
+ "type": "object",
407
+ "required": ["name", "required"],
408
+ "properties": {
409
+ "name": {
410
+ "type": "string",
411
+ "description": "Parameter name"
412
+ },
413
+ "required": {
414
+ "type": "boolean",
415
+ "description": "Whether the parameter is required"
416
+ },
417
+ "schema": {
418
+ "$ref": "#/$defs/schema"
419
+ },
420
+ "description": {
421
+ "type": "string",
422
+ "description": "Parameter description"
423
+ },
424
+ "default": {
425
+ "description": "Default value for the parameter"
426
+ },
427
+ "rest": {
428
+ "type": "boolean",
429
+ "description": "Whether this is a rest parameter (...args)"
430
+ }
431
+ }
432
+ },
433
+ "returns": {
434
+ "type": "object",
435
+ "properties": {
436
+ "schema": {
437
+ "$ref": "#/$defs/schema"
438
+ },
439
+ "description": {
440
+ "type": "string",
441
+ "description": "Return value description"
442
+ }
443
+ }
444
+ },
445
+ "schema": {
446
+ "anyOf": [
447
+ {
448
+ "type": "boolean"
449
+ },
450
+ {
451
+ "type": "object",
452
+ "properties": {
453
+ "$ref": {
454
+ "type": "string",
455
+ "description": "Reference to another type",
456
+ "pattern": "^#/types/[A-Za-z0-9_.-]+$"
457
+ }
458
+ },
459
+ "required": ["$ref"],
460
+ "additionalProperties": false
461
+ },
462
+ {
463
+ "type": "object",
464
+ "not": {
465
+ "required": ["$ref"]
466
+ },
467
+ "additionalProperties": true
468
+ }
469
+ ]
470
+ },
471
+ "sourceLocation": {
472
+ "type": "object",
473
+ "required": ["file", "line"],
474
+ "properties": {
475
+ "file": {
476
+ "type": "string",
477
+ "description": "Source file path"
478
+ },
479
+ "line": {
480
+ "type": "integer",
481
+ "description": "Line number in source file",
482
+ "minimum": 1
483
+ }
484
+ }
485
+ }
486
+ }
487
+ }