@openpkg-ts/spec 0.6.0 → 0.7.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
@@ -36,8 +36,85 @@ type SpecSource = {
36
36
  line?: number;
37
37
  url?: string;
38
38
  };
39
- type SpecSchema = unknown;
40
- type SpecExample = Record<string, unknown>;
39
+ type SpecSchemaPrimitive = {
40
+ type: "string";
41
+ format?: string;
42
+ enum?: string[];
43
+ } | {
44
+ type: "number";
45
+ enum?: number[];
46
+ } | {
47
+ type: "boolean";
48
+ enum?: boolean[];
49
+ } | {
50
+ type: "integer";
51
+ format?: string;
52
+ } | {
53
+ type: "null";
54
+ } | {
55
+ type: "undefined";
56
+ } | {
57
+ type: "any";
58
+ } | {
59
+ type: "unknown";
60
+ } | {
61
+ type: "never";
62
+ } | {
63
+ type: "void";
64
+ };
65
+ type SpecSchemaComposite = {
66
+ type: "array";
67
+ items?: SpecSchema;
68
+ } | {
69
+ type: "tuple";
70
+ items: SpecSchema[];
71
+ minItems?: number;
72
+ maxItems?: number;
73
+ } | {
74
+ type: "object";
75
+ properties?: Record<string, SpecSchema>;
76
+ required?: string[];
77
+ additionalProperties?: boolean | SpecSchema;
78
+ description?: string;
79
+ } | {
80
+ type: "function";
81
+ signatures?: SpecSignature[];
82
+ };
83
+ type SpecSchemaCombinator = {
84
+ anyOf: SpecSchema[];
85
+ discriminator?: {
86
+ propertyName: string;
87
+ };
88
+ } | {
89
+ allOf: SpecSchema[];
90
+ } | {
91
+ oneOf: SpecSchema[];
92
+ };
93
+ type SpecSchemaRef = {
94
+ $ref: string;
95
+ };
96
+ type SpecSchemaFallback = {
97
+ type: string;
98
+ tsType?: string;
99
+ };
100
+ type SpecSchemaGeneric = Record<string, unknown>;
101
+ type SpecSchema = string | SpecSchemaPrimitive | SpecSchemaComposite | SpecSchemaCombinator | SpecSchemaRef | SpecSchemaFallback | SpecSchemaGeneric;
102
+ type SpecExampleLanguage = "ts" | "js" | "tsx" | "jsx" | "shell" | "json";
103
+ type SpecExample = {
104
+ code: string;
105
+ title?: string;
106
+ description?: string;
107
+ language?: SpecExampleLanguage;
108
+ runnable?: boolean;
109
+ expectedOutput?: string;
110
+ tags?: string[];
111
+ };
112
+ type SpecRelationType = "uses" | "returns" | "implements" | "extends" | "see-also" | "companion";
113
+ type SpecRelation = {
114
+ type: SpecRelationType;
115
+ target: string;
116
+ description?: string;
117
+ };
41
118
  type SpecExtension = Record<string, unknown>;
42
119
  type SpecDocSignal = "description" | "params" | "returns" | "examples";
43
120
  type SpecDocDrift = {
@@ -109,7 +186,7 @@ type SpecExport = {
109
186
  type?: string | SpecSchema;
110
187
  schema?: SpecSchema;
111
188
  description?: string;
112
- examples?: string[];
189
+ examples?: (string | SpecExample)[];
113
190
  docs?: SpecDocsMetadata;
114
191
  source?: SpecSource;
115
192
  deprecated?: boolean;
@@ -123,6 +200,7 @@ type SpecExport = {
123
200
  decorators?: SpecDecorator[];
124
201
  isAugmentation?: boolean;
125
202
  augmentedModule?: string;
203
+ related?: SpecRelation[];
126
204
  };
127
205
  type SpecType = {
128
206
  id: string;
@@ -145,6 +223,7 @@ type SpecType = {
145
223
  typeAliasKind?: SpecTypeAliasKind;
146
224
  conditionalType?: SpecConditionalType;
147
225
  mappedType?: SpecMappedType;
226
+ related?: SpecRelation[];
148
227
  };
149
228
  type OpenPkgMeta = {
150
229
  name: string;
@@ -246,4 +325,4 @@ declare function assertSpec(spec: unknown, version?: SchemaVersion): asserts spe
246
325
  * @returns Array of validation errors (empty if valid)
247
326
  */
248
327
  declare function getValidationErrors(spec: unknown, version?: SchemaVersion): SpecError[];
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 };
328
+ export { validateSpec, normalize, getValidationErrors, diffSpec, dereference, categorizeBreakingChanges, assertSpec, SpecVisibility, SpecTypeParameter, SpecTypeKind, SpecTypeAliasKind, SpecType, SpecThrows, SpecTag, SpecSource, SpecSignatureReturn, SpecSignatureParameter, SpecSignature, SpecSchemaRef, SpecSchemaPrimitive, SpecSchemaGeneric, SpecSchemaFallback, SpecSchemaComposite, SpecSchemaCombinator, SpecSchema, SpecRelationType, SpecRelation, SpecMember, SpecMappedType, SpecExtension, SpecExportKind, SpecExport, SpecExampleLanguage, 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
@@ -1244,7 +1244,7 @@ var openpkg_schema_default3 = {
1244
1244
  type: "array",
1245
1245
  description: "Usage examples from documentation",
1246
1246
  items: {
1247
- type: "string"
1247
+ $ref: "#/$defs/example"
1248
1248
  }
1249
1249
  },
1250
1250
  signatures: {
@@ -1310,6 +1310,13 @@ var openpkg_schema_default3 = {
1310
1310
  augmentedModule: {
1311
1311
  type: "string",
1312
1312
  description: "The module being augmented (e.g., 'express')"
1313
+ },
1314
+ related: {
1315
+ type: "array",
1316
+ description: "Related exports/types (auto-detected + @see tags)",
1317
+ items: {
1318
+ $ref: "#/$defs/relation"
1319
+ }
1313
1320
  }
1314
1321
  }
1315
1322
  },
@@ -1396,6 +1403,13 @@ var openpkg_schema_default3 = {
1396
1403
  mappedType: {
1397
1404
  $ref: "#/$defs/mappedType",
1398
1405
  description: "Structural details for mapped types"
1406
+ },
1407
+ related: {
1408
+ type: "array",
1409
+ description: "Related exports/types (auto-detected + @see tags)",
1410
+ items: {
1411
+ $ref: "#/$defs/relation"
1412
+ }
1399
1413
  }
1400
1414
  }
1401
1415
  },
@@ -1542,28 +1556,39 @@ var openpkg_schema_default3 = {
1542
1556
  }
1543
1557
  },
1544
1558
  schema: {
1545
- anyOf: [
1546
- {
1547
- type: "boolean"
1548
- },
1559
+ description: "Flexible JSON Schema for type representation",
1560
+ oneOf: [
1561
+ { type: "string" },
1562
+ { type: "boolean" },
1549
1563
  {
1550
1564
  type: "object",
1551
1565
  properties: {
1552
- $ref: {
1553
- type: "string",
1554
- description: "Reference to another type",
1555
- pattern: "^#/types/[A-Za-z0-9_.-]+$"
1556
- }
1557
- },
1558
- required: ["$ref"],
1559
- additionalProperties: false
1560
- },
1561
- {
1562
- type: "object",
1563
- not: {
1564
- required: ["$ref"]
1565
- },
1566
- additionalProperties: true
1566
+ type: { type: "string" },
1567
+ format: { type: "string" },
1568
+ enum: { type: "array" },
1569
+ items: { $ref: "#/$defs/schema" },
1570
+ properties: {
1571
+ type: "object",
1572
+ additionalProperties: { $ref: "#/$defs/schema" }
1573
+ },
1574
+ required: { type: "array", items: { type: "string" } },
1575
+ additionalProperties: {
1576
+ oneOf: [{ type: "boolean" }, { $ref: "#/$defs/schema" }]
1577
+ },
1578
+ anyOf: { type: "array", items: { $ref: "#/$defs/schema" } },
1579
+ allOf: { type: "array", items: { $ref: "#/$defs/schema" } },
1580
+ oneOf: { type: "array", items: { $ref: "#/$defs/schema" } },
1581
+ $ref: { type: "string" },
1582
+ discriminator: {
1583
+ type: "object",
1584
+ properties: { propertyName: { type: "string" } }
1585
+ },
1586
+ tsType: { type: "string" },
1587
+ description: { type: "string" },
1588
+ minItems: { type: "integer" },
1589
+ maxItems: { type: "integer" },
1590
+ signatures: { type: "array" }
1591
+ }
1567
1592
  }
1568
1593
  ]
1569
1594
  },
@@ -1674,6 +1699,76 @@ var openpkg_schema_default3 = {
1674
1699
  }
1675
1700
  },
1676
1701
  additionalProperties: false
1702
+ },
1703
+ exampleLanguage: {
1704
+ type: "string",
1705
+ description: "Programming language for an example",
1706
+ enum: ["ts", "js", "tsx", "jsx", "shell", "json"]
1707
+ },
1708
+ example: {
1709
+ description: "Usage example - can be a simple string or structured object",
1710
+ oneOf: [
1711
+ { type: "string" },
1712
+ {
1713
+ type: "object",
1714
+ required: ["code"],
1715
+ properties: {
1716
+ code: {
1717
+ type: "string",
1718
+ description: "The example code"
1719
+ },
1720
+ title: {
1721
+ type: "string",
1722
+ description: "Short title for the example"
1723
+ },
1724
+ description: {
1725
+ type: "string",
1726
+ description: "Longer description of what the example demonstrates"
1727
+ },
1728
+ language: {
1729
+ $ref: "#/$defs/exampleLanguage"
1730
+ },
1731
+ runnable: {
1732
+ type: "boolean",
1733
+ description: "Whether this example can be run/tested automatically"
1734
+ },
1735
+ expectedOutput: {
1736
+ type: "string",
1737
+ description: "Expected output when the example is run"
1738
+ },
1739
+ tags: {
1740
+ type: "array",
1741
+ description: "Categorization tags (e.g., 'basic', 'advanced', 'error-handling')",
1742
+ items: { type: "string" }
1743
+ }
1744
+ },
1745
+ additionalProperties: false
1746
+ }
1747
+ ]
1748
+ },
1749
+ relationType: {
1750
+ type: "string",
1751
+ description: "Type of relationship between exports",
1752
+ enum: ["uses", "returns", "implements", "extends", "see-also", "companion"]
1753
+ },
1754
+ relation: {
1755
+ type: "object",
1756
+ description: "Relationship to another export or type",
1757
+ required: ["type", "target"],
1758
+ properties: {
1759
+ type: {
1760
+ $ref: "#/$defs/relationType"
1761
+ },
1762
+ target: {
1763
+ type: "string",
1764
+ description: "Target export/type ID or reference"
1765
+ },
1766
+ description: {
1767
+ type: "string",
1768
+ description: "Optional description of the relationship"
1769
+ }
1770
+ },
1771
+ additionalProperties: false
1677
1772
  }
1678
1773
  }
1679
1774
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpkg-ts/spec",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Shared schema, validation, and diff utilities for OpenPkg specs",
5
5
  "keywords": [
6
6
  "openpkg",
@@ -192,7 +192,7 @@
192
192
  "type": "array",
193
193
  "description": "Usage examples from documentation",
194
194
  "items": {
195
- "type": "string"
195
+ "$ref": "#/$defs/example"
196
196
  }
197
197
  },
198
198
  "signatures": {
@@ -258,6 +258,13 @@
258
258
  "augmentedModule": {
259
259
  "type": "string",
260
260
  "description": "The module being augmented (e.g., 'express')"
261
+ },
262
+ "related": {
263
+ "type": "array",
264
+ "description": "Related exports/types (auto-detected + @see tags)",
265
+ "items": {
266
+ "$ref": "#/$defs/relation"
267
+ }
261
268
  }
262
269
  }
263
270
  },
@@ -344,6 +351,13 @@
344
351
  "mappedType": {
345
352
  "$ref": "#/$defs/mappedType",
346
353
  "description": "Structural details for mapped types"
354
+ },
355
+ "related": {
356
+ "type": "array",
357
+ "description": "Related exports/types (auto-detected + @see tags)",
358
+ "items": {
359
+ "$ref": "#/$defs/relation"
360
+ }
347
361
  }
348
362
  }
349
363
  },
@@ -490,28 +504,39 @@
490
504
  }
491
505
  },
492
506
  "schema": {
493
- "anyOf": [
494
- {
495
- "type": "boolean"
496
- },
507
+ "description": "Flexible JSON Schema for type representation",
508
+ "oneOf": [
509
+ { "type": "string" },
510
+ { "type": "boolean" },
497
511
  {
498
512
  "type": "object",
499
513
  "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
514
+ "type": { "type": "string" },
515
+ "format": { "type": "string" },
516
+ "enum": { "type": "array" },
517
+ "items": { "$ref": "#/$defs/schema" },
518
+ "properties": {
519
+ "type": "object",
520
+ "additionalProperties": { "$ref": "#/$defs/schema" }
521
+ },
522
+ "required": { "type": "array", "items": { "type": "string" } },
523
+ "additionalProperties": {
524
+ "oneOf": [{ "type": "boolean" }, { "$ref": "#/$defs/schema" }]
525
+ },
526
+ "anyOf": { "type": "array", "items": { "$ref": "#/$defs/schema" } },
527
+ "allOf": { "type": "array", "items": { "$ref": "#/$defs/schema" } },
528
+ "oneOf": { "type": "array", "items": { "$ref": "#/$defs/schema" } },
529
+ "$ref": { "type": "string" },
530
+ "discriminator": {
531
+ "type": "object",
532
+ "properties": { "propertyName": { "type": "string" } }
533
+ },
534
+ "tsType": { "type": "string" },
535
+ "description": { "type": "string" },
536
+ "minItems": { "type": "integer" },
537
+ "maxItems": { "type": "integer" },
538
+ "signatures": { "type": "array" }
539
+ }
515
540
  }
516
541
  ]
517
542
  },
@@ -622,6 +647,76 @@
622
647
  }
623
648
  },
624
649
  "additionalProperties": false
650
+ },
651
+ "exampleLanguage": {
652
+ "type": "string",
653
+ "description": "Programming language for an example",
654
+ "enum": ["ts", "js", "tsx", "jsx", "shell", "json"]
655
+ },
656
+ "example": {
657
+ "description": "Usage example - can be a simple string or structured object",
658
+ "oneOf": [
659
+ { "type": "string" },
660
+ {
661
+ "type": "object",
662
+ "required": ["code"],
663
+ "properties": {
664
+ "code": {
665
+ "type": "string",
666
+ "description": "The example code"
667
+ },
668
+ "title": {
669
+ "type": "string",
670
+ "description": "Short title for the example"
671
+ },
672
+ "description": {
673
+ "type": "string",
674
+ "description": "Longer description of what the example demonstrates"
675
+ },
676
+ "language": {
677
+ "$ref": "#/$defs/exampleLanguage"
678
+ },
679
+ "runnable": {
680
+ "type": "boolean",
681
+ "description": "Whether this example can be run/tested automatically"
682
+ },
683
+ "expectedOutput": {
684
+ "type": "string",
685
+ "description": "Expected output when the example is run"
686
+ },
687
+ "tags": {
688
+ "type": "array",
689
+ "description": "Categorization tags (e.g., 'basic', 'advanced', 'error-handling')",
690
+ "items": { "type": "string" }
691
+ }
692
+ },
693
+ "additionalProperties": false
694
+ }
695
+ ]
696
+ },
697
+ "relationType": {
698
+ "type": "string",
699
+ "description": "Type of relationship between exports",
700
+ "enum": ["uses", "returns", "implements", "extends", "see-also", "companion"]
701
+ },
702
+ "relation": {
703
+ "type": "object",
704
+ "description": "Relationship to another export or type",
705
+ "required": ["type", "target"],
706
+ "properties": {
707
+ "type": {
708
+ "$ref": "#/$defs/relationType"
709
+ },
710
+ "target": {
711
+ "type": "string",
712
+ "description": "Target export/type ID or reference"
713
+ },
714
+ "description": {
715
+ "type": "string",
716
+ "description": "Optional description of the relationship"
717
+ }
718
+ },
719
+ "additionalProperties": false
625
720
  }
626
721
  }
627
722
  }