@openpkg-ts/spec 0.23.0 → 0.26.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.
Files changed (2) hide show
  1. package/dist/index.d.ts +39 -1
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -140,6 +140,8 @@ type SpecTypeParameter = {
140
140
  name: string;
141
141
  constraint?: string;
142
142
  default?: string;
143
+ variance?: "in" | "out" | "inout";
144
+ const?: boolean;
143
145
  };
144
146
  type SpecSignatureParameter = {
145
147
  name: string;
@@ -158,12 +160,24 @@ type SpecSignature = {
158
160
  parameters?: SpecSignatureParameter[];
159
161
  returns?: SpecSignatureReturn;
160
162
  description?: string;
163
+ tags?: SpecTag[];
164
+ examples?: SpecExample[];
161
165
  typeParameters?: SpecTypeParameter[];
162
166
  overloadIndex?: number;
163
167
  isImplementation?: boolean;
164
168
  throws?: SpecThrows[];
165
169
  };
166
170
  /**
171
+ * Type predicate information for type guard functions.
172
+ * Preserved in x-ts-type-predicate extension.
173
+ */
174
+ type SpecTypePredicate = {
175
+ /** The parameter name that the type guard narrows */
176
+ parameterName: string;
177
+ /** The type that the parameter is narrowed to */
178
+ type: SpecSchema;
179
+ };
180
+ /**
167
181
  * JSON Schema extension fields for TypeScript-specific type information.
168
182
  *
169
183
  * These extensions use the `x-` prefix which is valid JSON Schema for vendor extensions.
@@ -179,6 +193,8 @@ type SpecSignature = {
179
193
  * | `x-ts-function` | Marks a schema as representing a function type |
180
194
  * | `x-ts-signatures` | Contains function/method signatures for callable types |
181
195
  * | `x-ts-type-arguments`| Preserves generic type arguments for parameterized types |
196
+ * | `x-ts-type-predicate`| Preserves type guard narrowing information |
197
+ * | `x-ts-package` | Package name for external type references |
182
198
  */
183
199
  type JSONSchemaExtensions = {
184
200
  /**
@@ -206,6 +222,16 @@ type JSONSchemaExtensions = {
206
222
  * Example: Map<string, number> → { "$ref": "#/$defs/Map", "x-ts-type-arguments": [...] }
207
223
  */
208
224
  "x-ts-type-arguments"?: SpecSchema[];
225
+ /**
226
+ * Preserves type guard narrowing information for type predicate functions.
227
+ * Example: (value: unknown) => value is string → { "x-ts-type-predicate": { parameterName: "value", type: { type: "string" } } }
228
+ */
229
+ "x-ts-type-predicate"?: SpecTypePredicate;
230
+ /**
231
+ * Package name for external type references from node_modules.
232
+ * Example: AnyRouter from @trpc/server → { "$ref": "#/types/AnyRouter", "x-ts-package": "@trpc/server" }
233
+ */
234
+ "x-ts-package"?: string;
209
235
  };
210
236
  type SpecMember = {
211
237
  id?: string;
@@ -219,6 +245,10 @@ type SpecMember = {
219
245
  signatures?: SpecSignature[];
220
246
  decorators?: SpecDecorator[];
221
247
  };
248
+ type SpecInheritedMember = SpecMember & {
249
+ /** Name of the class this member was inherited from */
250
+ inheritedFrom: string;
251
+ };
222
252
  type SpecExportKind = "function" | "class" | "variable" | "interface" | "type" | "enum" | "module" | "namespace" | "reference" | "external";
223
253
  type SpecTypeKind = "class" | "interface" | "type" | "enum" | "external";
224
254
  type SpecExport = {
@@ -345,10 +375,18 @@ type SpecGenerationInfo = {
345
375
  };
346
376
  /** Supported OpenPkg spec versions */
347
377
  type OpenPkgVersion = "0.2.0" | "0.3.0" | "0.4.0";
378
+ /** Extraction mode indicating source type */
379
+ type SpecExtractionMode = "source" | "declaration-only";
380
+ /** Known limitations when extracting from declaration-only sources */
381
+ type SpecExtractionLimitation = "No JSDoc descriptions" | "No @example tags" | "No @param descriptions";
348
382
  /** Minimal generation metadata for v0.4.0 */
349
383
  type SpecGenerationMeta = {
350
384
  generator?: string;
351
385
  timestamp?: string;
386
+ /** Extraction mode: 'source' (full .ts) or 'declaration-only' (.d.ts) */
387
+ mode?: SpecExtractionMode;
388
+ /** Known limitations when in declaration-only mode */
389
+ limitations?: SpecExtractionLimitation[];
352
390
  };
353
391
  type OpenPkg = {
354
392
  $schema?: string;
@@ -491,4 +529,4 @@ declare function assertSpec(spec: unknown, version?: SchemaVersion): asserts spe
491
529
  * @returns Array of validation errors (empty if valid)
492
530
  */
493
531
  declare function getValidationErrors(spec: unknown, version?: SchemaVersion): SpecError[];
494
- export { validateSpec, recommendSemverBump, normalize, getValidationErrors, getAvailableVersions, diffSpec, dereference, categorizeBreakingChanges, calculateNextVersion, assertSpec, SpecVisibility, SpecTypeParameter, SpecTypeKind, SpecTypeAliasKind, SpecType, SpecThrows, SpecTagParam, SpecTag, SpecSource, SpecSignatureReturn, SpecSignatureParameter, SpecSignature, SpecSchemaRef, SpecSchemaPrimitive, SpecSchemaGeneric, SpecSchemaFallback, SpecSchemaComposite, SpecSchemaCombinator, SpecSchema, SpecPresentationMeta, SpecMember, SpecMappedType, SpecGenerationMeta, SpecGenerationInfo, SpecExtensions, SpecExtension, SpecExportKind, SpecExport, SpecExampleLanguage, SpecExample, SpecDiff, SpecDecorator, SpecConditionalType, SemverRecommendation, SemverBump, SCHEMA_VERSION, SCHEMA_URL, OpenPkgVersion, OpenPkgMeta, OpenPkg, MemberChangeInfo, JSON_SCHEMA_DRAFT, JSONSchemaExtensions, GenerationIssueSeverity, GenerationIssue, EntryPointDetectionMethod, CategorizedBreaking, BreakingSeverity };
532
+ export { validateSpec, recommendSemverBump, normalize, getValidationErrors, getAvailableVersions, diffSpec, dereference, categorizeBreakingChanges, calculateNextVersion, assertSpec, SpecVisibility, SpecTypePredicate, SpecTypeParameter, SpecTypeKind, SpecTypeAliasKind, SpecType, SpecThrows, SpecTagParam, SpecTag, SpecSource, SpecSignatureReturn, SpecSignatureParameter, SpecSignature, SpecSchemaRef, SpecSchemaPrimitive, SpecSchemaGeneric, SpecSchemaFallback, SpecSchemaComposite, SpecSchemaCombinator, SpecSchema, SpecPresentationMeta, SpecMember, SpecMappedType, SpecInheritedMember, SpecGenerationMeta, SpecGenerationInfo, SpecExtractionMode, SpecExtractionLimitation, SpecExtensions, SpecExtension, SpecExportKind, SpecExport, SpecExampleLanguage, SpecExample, SpecDiff, SpecDecorator, SpecConditionalType, SemverRecommendation, SemverBump, SCHEMA_VERSION, SCHEMA_URL, OpenPkgVersion, OpenPkgMeta, OpenPkg, MemberChangeInfo, JSON_SCHEMA_DRAFT, JSONSchemaExtensions, GenerationIssueSeverity, GenerationIssue, EntryPointDetectionMethod, CategorizedBreaking, BreakingSeverity };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpkg-ts/spec",
3
- "version": "0.23.0",
3
+ "version": "0.26.0",
4
4
  "description": "Shared schema, validation, and diff utilities for OpenPkg specs",
5
5
  "keywords": [
6
6
  "openpkg",