@openpkg-ts/spec 0.5.0 → 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/dist/index.d.ts CHANGED
@@ -8,6 +8,29 @@ type SpecTag = {
8
8
  version?: string;
9
9
  reason?: string;
10
10
  };
11
+ type SpecTypeAliasKind = "alias" | "conditional" | "mapped" | "template-literal" | "infer";
12
+ type SpecConditionalType = {
13
+ checkType: string;
14
+ extendsType: string;
15
+ trueType: string;
16
+ falseType: string;
17
+ };
18
+ type SpecMappedType = {
19
+ typeParameter: string;
20
+ nameType?: string;
21
+ valueType?: string;
22
+ readonly?: "+" | "-" | true;
23
+ optional?: "+" | "-" | true;
24
+ };
25
+ type SpecDecorator = {
26
+ name: string;
27
+ arguments?: unknown[];
28
+ argumentsText?: string[];
29
+ };
30
+ type SpecThrows = {
31
+ type?: string;
32
+ description?: string;
33
+ };
11
34
  type SpecSource = {
12
35
  file?: string;
13
36
  line?: number;
@@ -41,6 +64,7 @@ type SpecSignatureParameter = {
41
64
  schema: SpecSchema;
42
65
  default?: unknown;
43
66
  rest?: boolean;
67
+ decorators?: SpecDecorator[];
44
68
  };
45
69
  type SpecSignatureReturn = {
46
70
  schema: SpecSchema;
@@ -54,6 +78,7 @@ type SpecSignature = {
54
78
  typeParameters?: SpecTypeParameter[];
55
79
  overloadIndex?: number;
56
80
  isImplementation?: boolean;
81
+ throws?: SpecThrows[];
57
82
  };
58
83
  type SpecMember = {
59
84
  id?: string;
@@ -65,6 +90,7 @@ type SpecMember = {
65
90
  flags?: Record<string, unknown>;
66
91
  schema?: SpecSchema;
67
92
  signatures?: SpecSignature[];
93
+ decorators?: SpecDecorator[];
68
94
  };
69
95
  type SpecExportKind = "function" | "class" | "variable" | "interface" | "type" | "enum" | "module" | "namespace" | "reference" | "external";
70
96
  type SpecTypeKind = "class" | "interface" | "type" | "enum" | "external";
@@ -91,6 +117,12 @@ type SpecExport = {
91
117
  tags?: SpecTag[];
92
118
  extends?: string;
93
119
  implements?: string[];
120
+ typeAliasKind?: SpecTypeAliasKind;
121
+ conditionalType?: SpecConditionalType;
122
+ mappedType?: SpecMappedType;
123
+ decorators?: SpecDecorator[];
124
+ isAugmentation?: boolean;
125
+ augmentedModule?: string;
94
126
  };
95
127
  type SpecType = {
96
128
  id: string;
@@ -110,6 +142,9 @@ type SpecType = {
110
142
  rawComments?: string;
111
143
  extends?: string;
112
144
  implements?: string[];
145
+ typeAliasKind?: SpecTypeAliasKind;
146
+ conditionalType?: SpecConditionalType;
147
+ mappedType?: SpecMappedType;
113
148
  };
114
149
  type OpenPkgMeta = {
115
150
  name: string;
@@ -211,4 +246,4 @@ declare function assertSpec(spec: unknown, version?: SchemaVersion): asserts spe
211
246
  * @returns Array of validation errors (empty if valid)
212
247
  */
213
248
  declare function getValidationErrors(spec: unknown, version?: SchemaVersion): SpecError[];
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 };
249
+ export { validateSpec, normalize, getValidationErrors, diffSpec, dereference, categorizeBreakingChanges, assertSpec, SpecVisibility, SpecTypeParameter, SpecTypeKind, SpecTypeAliasKind, SpecType, SpecThrows, SpecTag, SpecSource, SpecSignatureReturn, SpecSignatureParameter, SpecSignature, SpecSchema, SpecMember, SpecMappedType, SpecExtension, SpecExportKind, SpecExport, SpecExample, SpecDocsMetadata, SpecDocSignal, SpecDocDrift, SpecDiff, SpecDecorator, SpecConditionalType, SCHEMA_VERSION, SCHEMA_URL, OpenPkgVersion, OpenPkgMeta, OpenPkg, MemberChangeInfo, JSON_SCHEMA_DRAFT, CategorizedBreaking, BreakingSeverity };
package/dist/index.js CHANGED
@@ -1285,6 +1285,31 @@ var openpkg_schema_default3 = {
1285
1285
  docs: {
1286
1286
  $ref: "#/$defs/docsMetadata",
1287
1287
  description: "Documentation coverage metadata for this export"
1288
+ },
1289
+ typeAliasKind: {
1290
+ $ref: "#/$defs/typeAliasKind",
1291
+ description: "Kind of type alias (for type exports)"
1292
+ },
1293
+ conditionalType: {
1294
+ $ref: "#/$defs/conditionalType",
1295
+ description: "Structural details for conditional types"
1296
+ },
1297
+ mappedType: {
1298
+ $ref: "#/$defs/mappedType",
1299
+ description: "Structural details for mapped types"
1300
+ },
1301
+ decorators: {
1302
+ type: "array",
1303
+ description: "Decorators applied to this export (class/function)",
1304
+ items: { $ref: "#/$defs/decorator" }
1305
+ },
1306
+ isAugmentation: {
1307
+ type: "boolean",
1308
+ description: "True if this is a module augmentation (declare module)"
1309
+ },
1310
+ augmentedModule: {
1311
+ type: "string",
1312
+ description: "The module being augmented (e.g., 'express')"
1288
1313
  }
1289
1314
  }
1290
1315
  },
@@ -1359,6 +1384,18 @@ var openpkg_schema_default3 = {
1359
1384
  },
1360
1385
  source: {
1361
1386
  $ref: "#/$defs/sourceLocation"
1387
+ },
1388
+ typeAliasKind: {
1389
+ $ref: "#/$defs/typeAliasKind",
1390
+ description: "Kind of type alias"
1391
+ },
1392
+ conditionalType: {
1393
+ $ref: "#/$defs/conditionalType",
1394
+ description: "Structural details for conditional types"
1395
+ },
1396
+ mappedType: {
1397
+ $ref: "#/$defs/mappedType",
1398
+ description: "Structural details for mapped types"
1362
1399
  }
1363
1400
  }
1364
1401
  },
@@ -1433,6 +1470,11 @@ var openpkg_schema_default3 = {
1433
1470
  isImplementation: {
1434
1471
  type: "boolean",
1435
1472
  description: "True if this is the implementation signature (not user-callable)"
1473
+ },
1474
+ throws: {
1475
+ type: "array",
1476
+ description: "Exceptions that can be thrown by this signature",
1477
+ items: { $ref: "#/$defs/throwsInfo" }
1436
1478
  }
1437
1479
  }
1438
1480
  },
@@ -1479,6 +1521,11 @@ var openpkg_schema_default3 = {
1479
1521
  rest: {
1480
1522
  type: "boolean",
1481
1523
  description: "Whether this is a rest parameter (...args)"
1524
+ },
1525
+ decorators: {
1526
+ type: "array",
1527
+ description: "Decorators applied to this parameter",
1528
+ items: { $ref: "#/$defs/decorator" }
1482
1529
  }
1483
1530
  }
1484
1531
  },
@@ -1534,6 +1581,99 @@ var openpkg_schema_default3 = {
1534
1581
  minimum: 1
1535
1582
  }
1536
1583
  }
1584
+ },
1585
+ typeAliasKind: {
1586
+ type: "string",
1587
+ description: "Kind of type alias",
1588
+ enum: ["alias", "conditional", "mapped", "template-literal", "infer"]
1589
+ },
1590
+ conditionalType: {
1591
+ type: "object",
1592
+ description: "Structural representation of a conditional type (T extends X ? Y : Z)",
1593
+ required: ["checkType", "extendsType", "trueType", "falseType"],
1594
+ properties: {
1595
+ checkType: {
1596
+ type: "string",
1597
+ description: "The type being checked (T)"
1598
+ },
1599
+ extendsType: {
1600
+ type: "string",
1601
+ description: "The constraint type (X)"
1602
+ },
1603
+ trueType: {
1604
+ type: "string",
1605
+ description: "The type when condition is true (Y)"
1606
+ },
1607
+ falseType: {
1608
+ type: "string",
1609
+ description: "The type when condition is false (Z)"
1610
+ }
1611
+ },
1612
+ additionalProperties: false
1613
+ },
1614
+ mappedType: {
1615
+ type: "object",
1616
+ description: "Structural representation of a mapped type ({ [K in keyof T]: ... })",
1617
+ required: ["typeParameter"],
1618
+ properties: {
1619
+ typeParameter: {
1620
+ type: "string",
1621
+ description: "The type parameter clause (e.g., 'K in keyof T')"
1622
+ },
1623
+ nameType: {
1624
+ type: "string",
1625
+ description: "The 'as' clause for key remapping (TS 4.1+)"
1626
+ },
1627
+ valueType: {
1628
+ type: "string",
1629
+ description: "The mapped value type"
1630
+ },
1631
+ readonly: {
1632
+ description: "Readonly modifier (+, -, or true for present)",
1633
+ oneOf: [{ type: "boolean" }, { enum: ["+", "-"] }]
1634
+ },
1635
+ optional: {
1636
+ description: "Optional modifier (+, -, or true for present)",
1637
+ oneOf: [{ type: "boolean" }, { enum: ["+", "-"] }]
1638
+ }
1639
+ },
1640
+ additionalProperties: false
1641
+ },
1642
+ decorator: {
1643
+ type: "object",
1644
+ description: "Decorator applied to a class, member, or parameter",
1645
+ required: ["name"],
1646
+ properties: {
1647
+ name: {
1648
+ type: "string",
1649
+ description: "Decorator name (e.g., 'Injectable', 'Component')"
1650
+ },
1651
+ arguments: {
1652
+ type: "array",
1653
+ description: "Evaluated decorator arguments (if possible)"
1654
+ },
1655
+ argumentsText: {
1656
+ type: "array",
1657
+ description: "Raw text of decorator arguments",
1658
+ items: { type: "string" }
1659
+ }
1660
+ },
1661
+ additionalProperties: false
1662
+ },
1663
+ throwsInfo: {
1664
+ type: "object",
1665
+ description: "Information about an exception that can be thrown",
1666
+ properties: {
1667
+ type: {
1668
+ type: "string",
1669
+ description: "Exception type (e.g., 'ValidationError', 'Error')"
1670
+ },
1671
+ description: {
1672
+ type: "string",
1673
+ description: "When/why the exception is thrown"
1674
+ }
1675
+ },
1676
+ additionalProperties: false
1537
1677
  }
1538
1678
  }
1539
1679
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpkg-ts/spec",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Shared schema, validation, and diff utilities for OpenPkg specs",
5
5
  "keywords": [
6
6
  "openpkg",
@@ -233,6 +233,31 @@
233
233
  "docs": {
234
234
  "$ref": "#/$defs/docsMetadata",
235
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')"
236
261
  }
237
262
  }
238
263
  },
@@ -307,6 +332,18 @@
307
332
  },
308
333
  "source": {
309
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"
310
347
  }
311
348
  }
312
349
  },
@@ -381,6 +418,11 @@
381
418
  "isImplementation": {
382
419
  "type": "boolean",
383
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" }
384
426
  }
385
427
  }
386
428
  },
@@ -427,6 +469,11 @@
427
469
  "rest": {
428
470
  "type": "boolean",
429
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" }
430
477
  }
431
478
  }
432
479
  },
@@ -482,6 +529,99 @@
482
529
  "minimum": 1
483
530
  }
484
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
485
625
  }
486
626
  }
487
627
  }