@openpkg-ts/spec 0.19.0 → 0.23.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 +46 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -112,7 +112,7 @@ type SpecSchemaRef = {
|
|
|
112
112
|
type SpecSchemaFallback = {
|
|
113
113
|
type: string;
|
|
114
114
|
};
|
|
115
|
-
type SpecSchemaGeneric = Record<string, unknown>;
|
|
115
|
+
type SpecSchemaGeneric = Record<string, unknown> & Partial<JSONSchemaExtensions>;
|
|
116
116
|
type SpecSchema = string | SpecSchemaPrimitive | SpecSchemaComposite | SpecSchemaCombinator | SpecSchemaRef | SpecSchemaFallback | SpecSchemaGeneric;
|
|
117
117
|
type SpecExampleLanguage = "ts" | "js" | "tsx" | "jsx" | "shell" | "json";
|
|
118
118
|
type SpecExample = {
|
|
@@ -163,6 +163,50 @@ type SpecSignature = {
|
|
|
163
163
|
isImplementation?: boolean;
|
|
164
164
|
throws?: SpecThrows[];
|
|
165
165
|
};
|
|
166
|
+
/**
|
|
167
|
+
* JSON Schema extension fields for TypeScript-specific type information.
|
|
168
|
+
*
|
|
169
|
+
* These extensions use the `x-` prefix which is valid JSON Schema for vendor extensions.
|
|
170
|
+
* They allow consumers to preserve TypeScript-specific information while still having
|
|
171
|
+
* valid JSON Schema. The extensions are optional - a consumer can ignore them for pure
|
|
172
|
+
* JSON Schema usage.
|
|
173
|
+
*
|
|
174
|
+
* Extension semantics:
|
|
175
|
+
* | Extension | Purpose |
|
|
176
|
+
* |----------------------|----------------------------------------------------------------------|
|
|
177
|
+
* | `x-ts-type` | Preserves original TS type for types that map to JSON Schema but |
|
|
178
|
+
* | | lose fidelity (bigint → integer, symbol → string) |
|
|
179
|
+
* | `x-ts-function` | Marks a schema as representing a function type |
|
|
180
|
+
* | `x-ts-signatures` | Contains function/method signatures for callable types |
|
|
181
|
+
* | `x-ts-type-arguments`| Preserves generic type arguments for parameterized types |
|
|
182
|
+
*/
|
|
183
|
+
type JSONSchemaExtensions = {
|
|
184
|
+
/**
|
|
185
|
+
* Preserves the original TypeScript type when mapping to JSON Schema loses fidelity.
|
|
186
|
+
* Examples:
|
|
187
|
+
* - bigint → { type: "integer", "x-ts-type": "bigint" }
|
|
188
|
+
* - symbol → { type: "string", "x-ts-type": "symbol" }
|
|
189
|
+
* - void → { type: "null", "x-ts-type": "void" } (optionally)
|
|
190
|
+
* - never, any, unknown, undefined also supported
|
|
191
|
+
*/
|
|
192
|
+
"x-ts-type"?: "bigint" | "symbol" | "void" | "never" | "any" | "unknown" | "undefined" | string;
|
|
193
|
+
/**
|
|
194
|
+
* Marks a schema as representing a function type.
|
|
195
|
+
* When true, the schema represents a callable TypeScript function.
|
|
196
|
+
*/
|
|
197
|
+
"x-ts-function"?: boolean;
|
|
198
|
+
/**
|
|
199
|
+
* Contains function/method signatures for callable types.
|
|
200
|
+
* Used in conjunction with `x-ts-function` to preserve full signature information.
|
|
201
|
+
*/
|
|
202
|
+
"x-ts-signatures"?: SpecSignature[];
|
|
203
|
+
/**
|
|
204
|
+
* Preserves generic type arguments for parameterized types.
|
|
205
|
+
* Used with $ref to maintain generic instantiation information.
|
|
206
|
+
* Example: Map<string, number> → { "$ref": "#/$defs/Map", "x-ts-type-arguments": [...] }
|
|
207
|
+
*/
|
|
208
|
+
"x-ts-type-arguments"?: SpecSchema[];
|
|
209
|
+
};
|
|
166
210
|
type SpecMember = {
|
|
167
211
|
id?: string;
|
|
168
212
|
name?: string;
|
|
@@ -447,4 +491,4 @@ declare function assertSpec(spec: unknown, version?: SchemaVersion): asserts spe
|
|
|
447
491
|
* @returns Array of validation errors (empty if valid)
|
|
448
492
|
*/
|
|
449
493
|
declare function getValidationErrors(spec: unknown, version?: SchemaVersion): SpecError[];
|
|
450
|
-
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, GenerationIssueSeverity, GenerationIssue, EntryPointDetectionMethod, CategorizedBreaking, BreakingSeverity };
|
|
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 };
|