@openpkg-ts/spec 0.4.1 → 0.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpkg-ts/spec",
3
- "version": "0.4.1",
3
+ "version": "0.6.0",
4
4
  "description": "Shared schema, validation, and diff utilities for OpenPkg specs",
5
5
  "keywords": [
6
6
  "openpkg",
@@ -0,0 +1,627 @@
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
+ "typeAliasKind": {
238
+ "$ref": "#/$defs/typeAliasKind",
239
+ "description": "Kind of type alias (for type exports)"
240
+ },
241
+ "conditionalType": {
242
+ "$ref": "#/$defs/conditionalType",
243
+ "description": "Structural details for conditional types"
244
+ },
245
+ "mappedType": {
246
+ "$ref": "#/$defs/mappedType",
247
+ "description": "Structural details for mapped types"
248
+ },
249
+ "decorators": {
250
+ "type": "array",
251
+ "description": "Decorators applied to this export (class/function)",
252
+ "items": { "$ref": "#/$defs/decorator" }
253
+ },
254
+ "isAugmentation": {
255
+ "type": "boolean",
256
+ "description": "True if this is a module augmentation (declare module)"
257
+ },
258
+ "augmentedModule": {
259
+ "type": "string",
260
+ "description": "The module being augmented (e.g., 'express')"
261
+ }
262
+ }
263
+ },
264
+ "typeDef": {
265
+ "type": "object",
266
+ "required": ["id", "name", "kind"],
267
+ "properties": {
268
+ "id": {
269
+ "type": "string",
270
+ "description": "Unique identifier for the type"
271
+ },
272
+ "name": {
273
+ "type": "string",
274
+ "description": "Type name"
275
+ },
276
+ "slug": {
277
+ "type": "string",
278
+ "description": "Stable slug for linking"
279
+ },
280
+ "displayName": {
281
+ "type": "string",
282
+ "description": "UI-friendly label"
283
+ },
284
+ "alias": {
285
+ "type": "string",
286
+ "description": "Export alias if re-exported with a different name (id uses alias, name uses original)"
287
+ },
288
+ "category": {
289
+ "type": "string",
290
+ "description": "Grouping hint for navigation"
291
+ },
292
+ "importPath": {
293
+ "type": "string",
294
+ "description": "Recommended import path"
295
+ },
296
+ "kind": {
297
+ "type": "string",
298
+ "description": "Kind of type definition",
299
+ "enum": ["interface", "type", "enum", "class", "external"]
300
+ },
301
+ "description": {
302
+ "type": "string",
303
+ "description": "JSDoc/TSDoc description"
304
+ },
305
+ "schema": {
306
+ "$ref": "#/$defs/schema"
307
+ },
308
+ "type": {
309
+ "type": "string",
310
+ "description": "Type expression for type aliases"
311
+ },
312
+ "members": {
313
+ "type": "array",
314
+ "description": "Members for classes/interfaces/enums",
315
+ "items": { "type": "object" }
316
+ },
317
+ "extends": {
318
+ "type": "string",
319
+ "description": "Base class or interface that this class/interface extends"
320
+ },
321
+ "implements": {
322
+ "type": "array",
323
+ "description": "Interfaces implemented by this class",
324
+ "items": { "type": "string" }
325
+ },
326
+ "tags": {
327
+ "type": "array",
328
+ "description": "JSDoc/TSDoc tags",
329
+ "items": {
330
+ "$ref": "#/$defs/tag"
331
+ }
332
+ },
333
+ "source": {
334
+ "$ref": "#/$defs/sourceLocation"
335
+ },
336
+ "typeAliasKind": {
337
+ "$ref": "#/$defs/typeAliasKind",
338
+ "description": "Kind of type alias"
339
+ },
340
+ "conditionalType": {
341
+ "$ref": "#/$defs/conditionalType",
342
+ "description": "Structural details for conditional types"
343
+ },
344
+ "mappedType": {
345
+ "$ref": "#/$defs/mappedType",
346
+ "description": "Structural details for mapped types"
347
+ }
348
+ }
349
+ },
350
+ "tag": {
351
+ "type": "object",
352
+ "description": "JSDoc/TSDoc tag with optional structured fields",
353
+ "required": ["name", "text"],
354
+ "properties": {
355
+ "name": {
356
+ "type": "string",
357
+ "description": "Tag name (e.g., 'param', 'returns', 'deprecated')"
358
+ },
359
+ "text": {
360
+ "type": "string",
361
+ "description": "Full tag text content"
362
+ },
363
+ "paramName": {
364
+ "type": "string",
365
+ "description": "For @param tags: the parameter name"
366
+ },
367
+ "typeAnnotation": {
368
+ "type": "string",
369
+ "description": "For @param/@returns: type annotation if present"
370
+ },
371
+ "reference": {
372
+ "type": "string",
373
+ "description": "For @see/@link: resolved URL or symbol reference"
374
+ },
375
+ "language": {
376
+ "type": "string",
377
+ "description": "For @example: code language hint (e.g., 'typescript', 'json')"
378
+ },
379
+ "version": {
380
+ "type": "string",
381
+ "description": "For @since/@version: semver value"
382
+ },
383
+ "reason": {
384
+ "type": "string",
385
+ "description": "For @deprecated: migration path or deprecation reason"
386
+ }
387
+ },
388
+ "additionalProperties": true
389
+ },
390
+ "signature": {
391
+ "type": "object",
392
+ "properties": {
393
+ "parameters": {
394
+ "type": "array",
395
+ "items": {
396
+ "$ref": "#/$defs/parameter"
397
+ }
398
+ },
399
+ "returns": {
400
+ "$ref": "#/$defs/returns"
401
+ },
402
+ "description": {
403
+ "type": "string",
404
+ "description": "Signature-level description"
405
+ },
406
+ "typeParameters": {
407
+ "type": "array",
408
+ "description": "Generic type parameters for this signature",
409
+ "items": {
410
+ "$ref": "#/$defs/typeParameter"
411
+ }
412
+ },
413
+ "overloadIndex": {
414
+ "type": "integer",
415
+ "minimum": 0,
416
+ "description": "Index of this overload (0-based), undefined for single signatures"
417
+ },
418
+ "isImplementation": {
419
+ "type": "boolean",
420
+ "description": "True if this is the implementation signature (not user-callable)"
421
+ },
422
+ "throws": {
423
+ "type": "array",
424
+ "description": "Exceptions that can be thrown by this signature",
425
+ "items": { "$ref": "#/$defs/throwsInfo" }
426
+ }
427
+ }
428
+ },
429
+ "typeParameter": {
430
+ "type": "object",
431
+ "required": ["name"],
432
+ "properties": {
433
+ "name": {
434
+ "type": "string",
435
+ "description": "Type parameter name (e.g., 'T', 'K')"
436
+ },
437
+ "constraint": {
438
+ "type": "string",
439
+ "description": "Type constraint (e.g., 'extends string')"
440
+ },
441
+ "default": {
442
+ "type": "string",
443
+ "description": "Default type value"
444
+ }
445
+ }
446
+ },
447
+ "parameter": {
448
+ "type": "object",
449
+ "required": ["name", "required"],
450
+ "properties": {
451
+ "name": {
452
+ "type": "string",
453
+ "description": "Parameter name"
454
+ },
455
+ "required": {
456
+ "type": "boolean",
457
+ "description": "Whether the parameter is required"
458
+ },
459
+ "schema": {
460
+ "$ref": "#/$defs/schema"
461
+ },
462
+ "description": {
463
+ "type": "string",
464
+ "description": "Parameter description"
465
+ },
466
+ "default": {
467
+ "description": "Default value for the parameter"
468
+ },
469
+ "rest": {
470
+ "type": "boolean",
471
+ "description": "Whether this is a rest parameter (...args)"
472
+ },
473
+ "decorators": {
474
+ "type": "array",
475
+ "description": "Decorators applied to this parameter",
476
+ "items": { "$ref": "#/$defs/decorator" }
477
+ }
478
+ }
479
+ },
480
+ "returns": {
481
+ "type": "object",
482
+ "properties": {
483
+ "schema": {
484
+ "$ref": "#/$defs/schema"
485
+ },
486
+ "description": {
487
+ "type": "string",
488
+ "description": "Return value description"
489
+ }
490
+ }
491
+ },
492
+ "schema": {
493
+ "anyOf": [
494
+ {
495
+ "type": "boolean"
496
+ },
497
+ {
498
+ "type": "object",
499
+ "properties": {
500
+ "$ref": {
501
+ "type": "string",
502
+ "description": "Reference to another type",
503
+ "pattern": "^#/types/[A-Za-z0-9_.-]+$"
504
+ }
505
+ },
506
+ "required": ["$ref"],
507
+ "additionalProperties": false
508
+ },
509
+ {
510
+ "type": "object",
511
+ "not": {
512
+ "required": ["$ref"]
513
+ },
514
+ "additionalProperties": true
515
+ }
516
+ ]
517
+ },
518
+ "sourceLocation": {
519
+ "type": "object",
520
+ "required": ["file", "line"],
521
+ "properties": {
522
+ "file": {
523
+ "type": "string",
524
+ "description": "Source file path"
525
+ },
526
+ "line": {
527
+ "type": "integer",
528
+ "description": "Line number in source file",
529
+ "minimum": 1
530
+ }
531
+ }
532
+ },
533
+ "typeAliasKind": {
534
+ "type": "string",
535
+ "description": "Kind of type alias",
536
+ "enum": ["alias", "conditional", "mapped", "template-literal", "infer"]
537
+ },
538
+ "conditionalType": {
539
+ "type": "object",
540
+ "description": "Structural representation of a conditional type (T extends X ? Y : Z)",
541
+ "required": ["checkType", "extendsType", "trueType", "falseType"],
542
+ "properties": {
543
+ "checkType": {
544
+ "type": "string",
545
+ "description": "The type being checked (T)"
546
+ },
547
+ "extendsType": {
548
+ "type": "string",
549
+ "description": "The constraint type (X)"
550
+ },
551
+ "trueType": {
552
+ "type": "string",
553
+ "description": "The type when condition is true (Y)"
554
+ },
555
+ "falseType": {
556
+ "type": "string",
557
+ "description": "The type when condition is false (Z)"
558
+ }
559
+ },
560
+ "additionalProperties": false
561
+ },
562
+ "mappedType": {
563
+ "type": "object",
564
+ "description": "Structural representation of a mapped type ({ [K in keyof T]: ... })",
565
+ "required": ["typeParameter"],
566
+ "properties": {
567
+ "typeParameter": {
568
+ "type": "string",
569
+ "description": "The type parameter clause (e.g., 'K in keyof T')"
570
+ },
571
+ "nameType": {
572
+ "type": "string",
573
+ "description": "The 'as' clause for key remapping (TS 4.1+)"
574
+ },
575
+ "valueType": {
576
+ "type": "string",
577
+ "description": "The mapped value type"
578
+ },
579
+ "readonly": {
580
+ "description": "Readonly modifier (+, -, or true for present)",
581
+ "oneOf": [{ "type": "boolean" }, { "enum": ["+", "-"] }]
582
+ },
583
+ "optional": {
584
+ "description": "Optional modifier (+, -, or true for present)",
585
+ "oneOf": [{ "type": "boolean" }, { "enum": ["+", "-"] }]
586
+ }
587
+ },
588
+ "additionalProperties": false
589
+ },
590
+ "decorator": {
591
+ "type": "object",
592
+ "description": "Decorator applied to a class, member, or parameter",
593
+ "required": ["name"],
594
+ "properties": {
595
+ "name": {
596
+ "type": "string",
597
+ "description": "Decorator name (e.g., 'Injectable', 'Component')"
598
+ },
599
+ "arguments": {
600
+ "type": "array",
601
+ "description": "Evaluated decorator arguments (if possible)"
602
+ },
603
+ "argumentsText": {
604
+ "type": "array",
605
+ "description": "Raw text of decorator arguments",
606
+ "items": { "type": "string" }
607
+ }
608
+ },
609
+ "additionalProperties": false
610
+ },
611
+ "throwsInfo": {
612
+ "type": "object",
613
+ "description": "Information about an exception that can be thrown",
614
+ "properties": {
615
+ "type": {
616
+ "type": "string",
617
+ "description": "Exception type (e.g., 'ValidationError', 'Error')"
618
+ },
619
+ "description": {
620
+ "type": "string",
621
+ "description": "When/why the exception is thrown"
622
+ }
623
+ },
624
+ "additionalProperties": false
625
+ }
626
+ }
627
+ }