@openpkg-ts/spec 0.10.0 → 0.11.1
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 +26 -102
- package/dist/index.js +455 -94
- package/package.json +1 -1
- package/schemas/v0.3.0/openpkg.schema.json +13 -3
- package/schemas/v0.4.0/openpkg.schema.json +378 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
type SpecTag = {
|
|
2
2
|
name: string;
|
|
3
3
|
text: string;
|
|
4
|
-
paramName?: string;
|
|
5
|
-
typeAnnotation?: string;
|
|
6
|
-
reference?: string;
|
|
7
|
-
language?: string;
|
|
8
|
-
version?: string;
|
|
9
|
-
reason?: string;
|
|
10
4
|
};
|
|
11
5
|
type SpecTypeAliasKind = "alias" | "conditional" | "mapped" | "template-literal" | "infer";
|
|
12
6
|
type SpecConditionalType = {
|
|
@@ -95,7 +89,6 @@ type SpecSchemaRef = {
|
|
|
95
89
|
};
|
|
96
90
|
type SpecSchemaFallback = {
|
|
97
91
|
type: string;
|
|
98
|
-
tsType?: string;
|
|
99
92
|
};
|
|
100
93
|
type SpecSchemaGeneric = Record<string, unknown>;
|
|
101
94
|
type SpecSchema = string | SpecSchemaPrimitive | SpecSchemaComposite | SpecSchemaCombinator | SpecSchemaRef | SpecSchemaFallback | SpecSchemaGeneric;
|
|
@@ -105,54 +98,22 @@ type SpecExample = {
|
|
|
105
98
|
title?: string;
|
|
106
99
|
description?: string;
|
|
107
100
|
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
101
|
};
|
|
118
102
|
type SpecExtension = Record<string, unknown>;
|
|
119
|
-
/**
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
issue: string;
|
|
127
|
-
suggestion?: string;
|
|
103
|
+
/** Presentation metadata for an export/type (moved from inline fields) */
|
|
104
|
+
type SpecPresentationMeta = {
|
|
105
|
+
slug?: string;
|
|
106
|
+
displayName?: string;
|
|
107
|
+
category?: string;
|
|
108
|
+
importPath?: string;
|
|
109
|
+
alias?: string;
|
|
128
110
|
};
|
|
129
|
-
/**
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
* - `semantic`: Metadata/visibility/reference issues
|
|
134
|
-
* - `example`: Code example problems
|
|
135
|
-
*/
|
|
136
|
-
type DriftCategory = "structural" | "semantic" | "example";
|
|
137
|
-
/**
|
|
138
|
-
* Maps each drift type to its category.
|
|
139
|
-
*/
|
|
140
|
-
declare const DRIFT_CATEGORIES: Record<DriftType, DriftCategory>;
|
|
141
|
-
/**
|
|
142
|
-
* Human-readable category labels.
|
|
143
|
-
*/
|
|
144
|
-
declare const DRIFT_CATEGORY_LABELS: Record<DriftCategory, string>;
|
|
145
|
-
/**
|
|
146
|
-
* Category descriptions for help text.
|
|
147
|
-
*/
|
|
148
|
-
declare const DRIFT_CATEGORY_DESCRIPTIONS: Record<DriftCategory, string>;
|
|
149
|
-
type SpecVisibility = "public" | "protected" | "private";
|
|
150
|
-
type SpecDocsMetadata = {
|
|
151
|
-
coverageScore?: number;
|
|
152
|
-
/** Rule IDs that failed quality checks */
|
|
153
|
-
missing?: string[];
|
|
154
|
-
drift?: SpecDocDrift[];
|
|
111
|
+
/** Extensions structure with typed presentation field */
|
|
112
|
+
type SpecExtensions = {
|
|
113
|
+
presentation?: Record<string, SpecPresentationMeta>;
|
|
114
|
+
[key: string]: unknown;
|
|
155
115
|
};
|
|
116
|
+
type SpecVisibility = "public" | "protected" | "private";
|
|
156
117
|
type SpecTypeParameter = {
|
|
157
118
|
name: string;
|
|
158
119
|
constraint?: string;
|
|
@@ -170,7 +131,6 @@ type SpecSignatureParameter = {
|
|
|
170
131
|
type SpecSignatureReturn = {
|
|
171
132
|
schema: SpecSchema;
|
|
172
133
|
description?: string;
|
|
173
|
-
tsType?: string;
|
|
174
134
|
};
|
|
175
135
|
type SpecSignature = {
|
|
176
136
|
parameters?: SpecSignatureParameter[];
|
|
@@ -198,11 +158,6 @@ type SpecTypeKind = "class" | "interface" | "type" | "enum" | "external";
|
|
|
198
158
|
type SpecExport = {
|
|
199
159
|
id: string;
|
|
200
160
|
name: string;
|
|
201
|
-
slug?: string;
|
|
202
|
-
displayName?: string;
|
|
203
|
-
alias?: string;
|
|
204
|
-
category?: string;
|
|
205
|
-
importPath?: string;
|
|
206
161
|
kind: SpecExportKind;
|
|
207
162
|
signatures?: SpecSignature[];
|
|
208
163
|
typeParameters?: SpecTypeParameter[];
|
|
@@ -221,18 +176,10 @@ type SpecExport = {
|
|
|
221
176
|
conditionalType?: SpecConditionalType;
|
|
222
177
|
mappedType?: SpecMappedType;
|
|
223
178
|
decorators?: SpecDecorator[];
|
|
224
|
-
isAugmentation?: boolean;
|
|
225
|
-
augmentedModule?: string;
|
|
226
|
-
related?: SpecRelation[];
|
|
227
179
|
};
|
|
228
180
|
type SpecType = {
|
|
229
181
|
id: string;
|
|
230
182
|
name: string;
|
|
231
|
-
slug?: string;
|
|
232
|
-
displayName?: string;
|
|
233
|
-
alias?: string;
|
|
234
|
-
category?: string;
|
|
235
|
-
importPath?: string;
|
|
236
183
|
kind: SpecTypeKind;
|
|
237
184
|
description?: string;
|
|
238
185
|
schema?: SpecSchema;
|
|
@@ -246,7 +193,6 @@ type SpecType = {
|
|
|
246
193
|
typeAliasKind?: SpecTypeAliasKind;
|
|
247
194
|
conditionalType?: SpecConditionalType;
|
|
248
195
|
mappedType?: SpecMappedType;
|
|
249
|
-
related?: SpecRelation[];
|
|
250
196
|
};
|
|
251
197
|
type OpenPkgMeta = {
|
|
252
198
|
name: string;
|
|
@@ -330,7 +276,12 @@ type SpecGenerationInfo = {
|
|
|
330
276
|
fromCache?: boolean;
|
|
331
277
|
};
|
|
332
278
|
/** Supported OpenPkg spec versions */
|
|
333
|
-
type OpenPkgVersion = "0.2.0" | "0.3.0";
|
|
279
|
+
type OpenPkgVersion = "0.2.0" | "0.3.0" | "0.4.0";
|
|
280
|
+
/** Minimal generation metadata for v0.4.0 */
|
|
281
|
+
type SpecGenerationMeta = {
|
|
282
|
+
generator?: string;
|
|
283
|
+
timestamp?: string;
|
|
284
|
+
};
|
|
334
285
|
type OpenPkg = {
|
|
335
286
|
$schema?: string;
|
|
336
287
|
openpkg: OpenPkgVersion;
|
|
@@ -338,25 +289,14 @@ type OpenPkg = {
|
|
|
338
289
|
exports: SpecExport[];
|
|
339
290
|
types?: SpecType[];
|
|
340
291
|
examples?: SpecExample[];
|
|
341
|
-
extensions?:
|
|
342
|
-
/**
|
|
343
|
-
generation
|
|
292
|
+
extensions?: SpecExtensions;
|
|
293
|
+
/** Optional generation metadata (minimal in v0.4.0) */
|
|
294
|
+
generation?: SpecGenerationMeta | SpecGenerationInfo;
|
|
344
295
|
};
|
|
345
296
|
declare const SCHEMA_VERSION: OpenPkgVersion;
|
|
346
|
-
declare const SCHEMA_URL = "https://unpkg.com/@openpkg-ts/spec/schemas/v0.
|
|
297
|
+
declare const SCHEMA_URL = "https://unpkg.com/@openpkg-ts/spec/schemas/v0.4.0/openpkg.schema.json";
|
|
347
298
|
declare const JSON_SCHEMA_DRAFT = "https://json-schema.org/draft/2020-12/schema";
|
|
348
299
|
declare function dereference(spec: OpenPkg): OpenPkg;
|
|
349
|
-
/**
|
|
350
|
-
* Export with optional docs metadata for diff comparison.
|
|
351
|
-
* Pure OpenPkg specs won't have docs; enriched specs will.
|
|
352
|
-
*/
|
|
353
|
-
type ExportWithDocs = SpecExport & {
|
|
354
|
-
docs?: SpecDocsMetadata;
|
|
355
|
-
};
|
|
356
|
-
type SpecWithDocs = OpenPkg & {
|
|
357
|
-
docs?: SpecDocsMetadata;
|
|
358
|
-
exports: ExportWithDocs[];
|
|
359
|
-
};
|
|
360
300
|
type BreakingSeverity = "high" | "medium" | "low";
|
|
361
301
|
interface CategorizedBreaking {
|
|
362
302
|
id: string;
|
|
@@ -376,31 +316,15 @@ type SpecDiff = {
|
|
|
376
316
|
breaking: string[];
|
|
377
317
|
nonBreaking: string[];
|
|
378
318
|
docsOnly: string[];
|
|
379
|
-
coverageDelta: number;
|
|
380
|
-
oldCoverage: number;
|
|
381
|
-
newCoverage: number;
|
|
382
|
-
newUndocumented: string[];
|
|
383
|
-
improvedExports: string[];
|
|
384
|
-
regressedExports: string[];
|
|
385
|
-
driftIntroduced: number;
|
|
386
|
-
driftResolved: number;
|
|
387
319
|
};
|
|
388
320
|
/**
|
|
389
321
|
* Compare two OpenPkg specs and compute differences.
|
|
390
|
-
* If specs are enriched (have docs metadata), coverage changes are tracked.
|
|
391
|
-
* For pure structural specs, coverage fields will be 0.
|
|
392
322
|
*/
|
|
393
|
-
declare function diffSpec(oldSpec:
|
|
323
|
+
declare function diffSpec(oldSpec: OpenPkg, newSpec: OpenPkg): SpecDiff;
|
|
394
324
|
/**
|
|
395
325
|
* Categorize breaking changes by severity
|
|
396
|
-
*
|
|
397
|
-
* @param breaking - Array of breaking change IDs
|
|
398
|
-
* @param oldSpec - Previous spec version
|
|
399
|
-
* @param newSpec - Current spec version
|
|
400
|
-
* @param memberChanges - Optional member-level changes for classes
|
|
401
|
-
* @returns Categorized breaking changes sorted by severity (high first)
|
|
402
326
|
*/
|
|
403
|
-
declare function categorizeBreakingChanges(breaking: string[], oldSpec:
|
|
327
|
+
declare function categorizeBreakingChanges(breaking: string[], oldSpec: OpenPkg, newSpec: OpenPkg, memberChanges?: MemberChangeInfo[]): CategorizedBreaking[];
|
|
404
328
|
/**
|
|
405
329
|
* Semver version bump type.
|
|
406
330
|
*/
|
|
@@ -460,7 +384,7 @@ declare function recommendSemverBump(diff: SpecDiff): SemverRecommendation;
|
|
|
460
384
|
declare function calculateNextVersion(currentVersion: string, bump: SemverBump): string;
|
|
461
385
|
declare function normalize(spec: OpenPkg): OpenPkg;
|
|
462
386
|
/** Supported schema versions */
|
|
463
|
-
type SchemaVersion = "0.1.0" | "0.2.0" | "0.3.0" | "latest";
|
|
387
|
+
type SchemaVersion = "0.1.0" | "0.2.0" | "0.3.0" | "0.4.0" | "latest";
|
|
464
388
|
type SpecError = {
|
|
465
389
|
instancePath: string;
|
|
466
390
|
message: string;
|
|
@@ -495,4 +419,4 @@ declare function assertSpec(spec: unknown, version?: SchemaVersion): asserts spe
|
|
|
495
419
|
* @returns Array of validation errors (empty if valid)
|
|
496
420
|
*/
|
|
497
421
|
declare function getValidationErrors(spec: unknown, version?: SchemaVersion): SpecError[];
|
|
498
|
-
export { validateSpec, recommendSemverBump, normalize, getValidationErrors, diffSpec, dereference, categorizeBreakingChanges, calculateNextVersion, assertSpec, SpecVisibility, SpecTypeParameter, SpecTypeKind, SpecTypeAliasKind, SpecType, SpecThrows, SpecTag, SpecSource, SpecSignatureReturn, SpecSignatureParameter, SpecSignature, SpecSchemaRef, SpecSchemaPrimitive, SpecSchemaGeneric, SpecSchemaFallback, SpecSchemaComposite, SpecSchemaCombinator, SpecSchema,
|
|
422
|
+
export { validateSpec, recommendSemverBump, normalize, getValidationErrors, diffSpec, dereference, categorizeBreakingChanges, calculateNextVersion, assertSpec, SpecVisibility, SpecTypeParameter, SpecTypeKind, SpecTypeAliasKind, SpecType, SpecThrows, 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 };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/constants.ts
|
|
2
|
-
var SCHEMA_VERSION = "0.
|
|
3
|
-
var SCHEMA_URL = "https://unpkg.com/@openpkg-ts/spec/schemas/v0.
|
|
2
|
+
var SCHEMA_VERSION = "0.4.0";
|
|
3
|
+
var SCHEMA_URL = "https://unpkg.com/@openpkg-ts/spec/schemas/v0.4.0/openpkg.schema.json";
|
|
4
4
|
var JSON_SCHEMA_DRAFT = "https://json-schema.org/draft/2020-12/schema";
|
|
5
5
|
// src/deref.ts
|
|
6
6
|
function dereference(spec) {
|
|
@@ -72,47 +72,10 @@ function diffSpec(oldSpec, newSpec) {
|
|
|
72
72
|
const result = {
|
|
73
73
|
breaking: [],
|
|
74
74
|
nonBreaking: [],
|
|
75
|
-
docsOnly: []
|
|
76
|
-
coverageDelta: 0,
|
|
77
|
-
oldCoverage: 0,
|
|
78
|
-
newCoverage: 0,
|
|
79
|
-
newUndocumented: [],
|
|
80
|
-
improvedExports: [],
|
|
81
|
-
regressedExports: [],
|
|
82
|
-
driftIntroduced: 0,
|
|
83
|
-
driftResolved: 0
|
|
75
|
+
docsOnly: []
|
|
84
76
|
};
|
|
85
77
|
diffCollections(result, oldSpec.exports, newSpec.exports);
|
|
86
78
|
diffCollections(result, oldSpec.types ?? [], newSpec.types ?? []);
|
|
87
|
-
result.oldCoverage = oldSpec.docs?.coverageScore ?? 0;
|
|
88
|
-
result.newCoverage = newSpec.docs?.coverageScore ?? 0;
|
|
89
|
-
result.coverageDelta = Math.round((result.newCoverage - result.oldCoverage) * 10) / 10;
|
|
90
|
-
const oldExportMap = toExportMap(oldSpec.exports);
|
|
91
|
-
const newExportMap = toExportMap(newSpec.exports);
|
|
92
|
-
for (const [id, newExport] of newExportMap.entries()) {
|
|
93
|
-
const oldExport = oldExportMap.get(id);
|
|
94
|
-
const newScore = newExport.docs?.coverageScore ?? 0;
|
|
95
|
-
const newDriftCount = newExport.docs?.drift?.length ?? 0;
|
|
96
|
-
if (!oldExport) {
|
|
97
|
-
if (newScore < 100 || (newExport.docs?.missing?.length ?? 0) > 0) {
|
|
98
|
-
result.newUndocumented.push(id);
|
|
99
|
-
}
|
|
100
|
-
result.driftIntroduced += newDriftCount;
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
const oldScore = oldExport.docs?.coverageScore ?? 0;
|
|
104
|
-
const oldDriftCount = oldExport.docs?.drift?.length ?? 0;
|
|
105
|
-
if (newScore > oldScore) {
|
|
106
|
-
result.improvedExports.push(id);
|
|
107
|
-
} else if (newScore < oldScore) {
|
|
108
|
-
result.regressedExports.push(id);
|
|
109
|
-
}
|
|
110
|
-
if (newDriftCount > oldDriftCount) {
|
|
111
|
-
result.driftIntroduced += newDriftCount - oldDriftCount;
|
|
112
|
-
} else if (oldDriftCount > newDriftCount) {
|
|
113
|
-
result.driftResolved += oldDriftCount - newDriftCount;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
79
|
return result;
|
|
117
80
|
}
|
|
118
81
|
function toExportMap(exports) {
|
|
@@ -159,21 +122,7 @@ function toMap(items) {
|
|
|
159
122
|
}
|
|
160
123
|
return map;
|
|
161
124
|
}
|
|
162
|
-
var DOC_KEYS = new Set([
|
|
163
|
-
"description",
|
|
164
|
-
"examples",
|
|
165
|
-
"tags",
|
|
166
|
-
"rawComments",
|
|
167
|
-
"source",
|
|
168
|
-
"docs",
|
|
169
|
-
"displayName",
|
|
170
|
-
"slug",
|
|
171
|
-
"importPath",
|
|
172
|
-
"category",
|
|
173
|
-
"coverageScore",
|
|
174
|
-
"missing",
|
|
175
|
-
"drift"
|
|
176
|
-
]);
|
|
125
|
+
var DOC_KEYS = new Set(["description", "examples", "tags", "rawComments", "source"]);
|
|
177
126
|
function isDocOnlyChange(a, b) {
|
|
178
127
|
const structuralA = normalizeForComparison(removeDocFields(a));
|
|
179
128
|
const structuralB = normalizeForComparison(removeDocFields(b));
|
|
@@ -353,7 +302,7 @@ var DEFAULT_ECOSYSTEM = "js/ts";
|
|
|
353
302
|
var arrayFieldsByExport = ["signatures", "members", "examples", "tags"];
|
|
354
303
|
var arrayFieldsByType = ["members", "tags"];
|
|
355
304
|
function normalize(spec) {
|
|
356
|
-
const normalized =
|
|
305
|
+
const normalized = structuredClone(spec);
|
|
357
306
|
normalized.meta = {
|
|
358
307
|
ecosystem: normalized.meta?.ecosystem ?? DEFAULT_ECOSYSTEM,
|
|
359
308
|
...normalized.meta
|
|
@@ -364,53 +313,78 @@ function normalize(spec) {
|
|
|
364
313
|
const types = Array.isArray(normalized.types) ? [...normalized.types] : [];
|
|
365
314
|
types.sort((a, b) => (a.name || "").localeCompare(b.name || ""));
|
|
366
315
|
normalized.types = types.map((item) => normalizeType(item));
|
|
316
|
+
if (normalized.generation) {
|
|
317
|
+
normalized.generation = normalizeGeneration(normalized.generation);
|
|
318
|
+
}
|
|
367
319
|
return normalized;
|
|
368
320
|
}
|
|
321
|
+
function normalizeGeneration(gen) {
|
|
322
|
+
if (!gen)
|
|
323
|
+
return;
|
|
324
|
+
const extendedGen = gen;
|
|
325
|
+
if (extendedGen.generator && typeof extendedGen.generator === "object") {
|
|
326
|
+
return {
|
|
327
|
+
generator: `${extendedGen.generator.name}@${extendedGen.generator.version}`,
|
|
328
|
+
timestamp: extendedGen.timestamp
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
return gen;
|
|
332
|
+
}
|
|
369
333
|
function normalizeExport(item) {
|
|
370
|
-
const clone =
|
|
334
|
+
const clone = structuredClone(item);
|
|
371
335
|
for (const field of arrayFieldsByExport) {
|
|
372
336
|
if (!Array.isArray(clone[field])) {
|
|
373
337
|
clone[field] = [];
|
|
374
338
|
}
|
|
375
339
|
}
|
|
340
|
+
if (clone.type !== undefined && typeof clone.type !== "string") {
|
|
341
|
+
if (!clone.schema) {
|
|
342
|
+
clone.schema = clone.type;
|
|
343
|
+
}
|
|
344
|
+
delete clone.type;
|
|
345
|
+
}
|
|
346
|
+
if (clone.tags && clone.tags.length > 0) {
|
|
347
|
+
clone.tags = clone.tags.map(normalizeTag);
|
|
348
|
+
}
|
|
349
|
+
if (clone.members && clone.members.length > 0) {
|
|
350
|
+
clone.members = clone.members.map(normalizeMember);
|
|
351
|
+
}
|
|
376
352
|
return clone;
|
|
377
353
|
}
|
|
378
354
|
function normalizeType(item) {
|
|
379
|
-
const clone =
|
|
355
|
+
const clone = structuredClone(item);
|
|
380
356
|
for (const field of arrayFieldsByType) {
|
|
381
357
|
if (!Array.isArray(clone[field])) {
|
|
382
358
|
clone[field] = [];
|
|
383
359
|
}
|
|
384
360
|
}
|
|
361
|
+
if (clone.type !== undefined && typeof clone.type !== "string") {
|
|
362
|
+
if (!clone.schema) {
|
|
363
|
+
clone.schema = clone.type;
|
|
364
|
+
}
|
|
365
|
+
delete clone.type;
|
|
366
|
+
}
|
|
367
|
+
if (clone.tags && clone.tags.length > 0) {
|
|
368
|
+
clone.tags = clone.tags.map(normalizeTag);
|
|
369
|
+
}
|
|
370
|
+
if (clone.members && clone.members.length > 0) {
|
|
371
|
+
clone.members = clone.members.map(normalizeMember);
|
|
372
|
+
}
|
|
373
|
+
return clone;
|
|
374
|
+
}
|
|
375
|
+
function normalizeTag(tag) {
|
|
376
|
+
return {
|
|
377
|
+
name: tag.name,
|
|
378
|
+
text: tag.text
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
function normalizeMember(member) {
|
|
382
|
+
const clone = structuredClone(member);
|
|
383
|
+
if (clone.tags && clone.tags.length > 0) {
|
|
384
|
+
clone.tags = clone.tags.map(normalizeTag);
|
|
385
|
+
}
|
|
385
386
|
return clone;
|
|
386
387
|
}
|
|
387
|
-
// src/types.ts
|
|
388
|
-
var DRIFT_CATEGORIES = {
|
|
389
|
-
"param-mismatch": "structural",
|
|
390
|
-
"param-type-mismatch": "structural",
|
|
391
|
-
"return-type-mismatch": "structural",
|
|
392
|
-
"optionality-mismatch": "structural",
|
|
393
|
-
"generic-constraint-mismatch": "structural",
|
|
394
|
-
"property-type-drift": "structural",
|
|
395
|
-
"async-mismatch": "structural",
|
|
396
|
-
"deprecated-mismatch": "semantic",
|
|
397
|
-
"visibility-mismatch": "semantic",
|
|
398
|
-
"broken-link": "semantic",
|
|
399
|
-
"example-drift": "example",
|
|
400
|
-
"example-syntax-error": "example",
|
|
401
|
-
"example-runtime-error": "example",
|
|
402
|
-
"example-assertion-failed": "example"
|
|
403
|
-
};
|
|
404
|
-
var DRIFT_CATEGORY_LABELS = {
|
|
405
|
-
structural: "Signature mismatches",
|
|
406
|
-
semantic: "Metadata issues",
|
|
407
|
-
example: "Example problems"
|
|
408
|
-
};
|
|
409
|
-
var DRIFT_CATEGORY_DESCRIPTIONS = {
|
|
410
|
-
structural: "JSDoc types or parameters don't match the actual code signature",
|
|
411
|
-
semantic: "Deprecation, visibility, or reference issues",
|
|
412
|
-
example: "@example code has errors or doesn't work correctly"
|
|
413
|
-
};
|
|
414
388
|
// src/validate.ts
|
|
415
389
|
import Ajv from "ajv/dist/2020.js";
|
|
416
390
|
import addFormats from "ajv-formats";
|
|
@@ -1855,16 +1829,18 @@ var openpkg_schema_default3 = {
|
|
|
1855
1829
|
]
|
|
1856
1830
|
},
|
|
1857
1831
|
schema: {
|
|
1858
|
-
description: "Flexible JSON Schema for type representation",
|
|
1832
|
+
description: "Flexible JSON Schema for type representation (supports Standard JSON Schema output)",
|
|
1859
1833
|
oneOf: [
|
|
1860
1834
|
{ type: "string" },
|
|
1861
1835
|
{ type: "boolean" },
|
|
1862
1836
|
{
|
|
1863
1837
|
type: "object",
|
|
1864
1838
|
properties: {
|
|
1839
|
+
$schema: { type: "string", description: "JSON Schema draft URI" },
|
|
1865
1840
|
type: { type: "string" },
|
|
1866
1841
|
format: { type: "string" },
|
|
1867
1842
|
enum: { type: "array" },
|
|
1843
|
+
const: { description: "Constant value" },
|
|
1868
1844
|
items: { $ref: "#/$defs/schema" },
|
|
1869
1845
|
prefixedItems: {
|
|
1870
1846
|
type: "array",
|
|
@@ -1877,7 +1853,7 @@ var openpkg_schema_default3 = {
|
|
|
1877
1853
|
},
|
|
1878
1854
|
required: { type: "array", items: { type: "string" } },
|
|
1879
1855
|
additionalProperties: {
|
|
1880
|
-
oneOf: [{ type: "boolean" }, {
|
|
1856
|
+
oneOf: [{ type: "boolean" }, { type: "object", additionalProperties: true }]
|
|
1881
1857
|
},
|
|
1882
1858
|
anyOf: { type: "array", items: { $ref: "#/$defs/schema" } },
|
|
1883
1859
|
allOf: { type: "array", items: { $ref: "#/$defs/schema" } },
|
|
@@ -1887,10 +1863,18 @@ var openpkg_schema_default3 = {
|
|
|
1887
1863
|
type: "object",
|
|
1888
1864
|
properties: { propertyName: { type: "string" } }
|
|
1889
1865
|
},
|
|
1890
|
-
tsType: { type: "string" },
|
|
1891
1866
|
description: { type: "string" },
|
|
1867
|
+
default: { description: "Default value for the schema" },
|
|
1868
|
+
minimum: { type: "number", description: "Minimum value for numbers" },
|
|
1869
|
+
maximum: { type: "number", description: "Maximum value for numbers" },
|
|
1870
|
+
exclusiveMinimum: { type: "number" },
|
|
1871
|
+
exclusiveMaximum: { type: "number" },
|
|
1872
|
+
minLength: { type: "integer", description: "Minimum string length" },
|
|
1873
|
+
maxLength: { type: "integer", description: "Maximum string length" },
|
|
1874
|
+
pattern: { type: "string", description: "Regex pattern for strings" },
|
|
1892
1875
|
minItems: { type: "integer" },
|
|
1893
1876
|
maxItems: { type: "integer" },
|
|
1877
|
+
uniqueItems: { type: "boolean" },
|
|
1894
1878
|
signatures: { type: "array", items: { $ref: "#/$defs/signature" } }
|
|
1895
1879
|
}
|
|
1896
1880
|
}
|
|
@@ -2129,13 +2113,393 @@ var openpkg_schema_default3 = {
|
|
|
2129
2113
|
}
|
|
2130
2114
|
}
|
|
2131
2115
|
};
|
|
2116
|
+
// schemas/v0.4.0/openpkg.schema.json
|
|
2117
|
+
var openpkg_schema_default4 = {
|
|
2118
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
2119
|
+
$id: "https://unpkg.com/@openpkg-ts/spec/schemas/v0.4.0/openpkg.schema.json",
|
|
2120
|
+
title: "OpenPkg Specification v0.4.0",
|
|
2121
|
+
description: "Minimal tool-agnostic TypeScript export representation",
|
|
2122
|
+
type: "object",
|
|
2123
|
+
required: ["openpkg", "meta", "exports"],
|
|
2124
|
+
properties: {
|
|
2125
|
+
$schema: {
|
|
2126
|
+
type: "string",
|
|
2127
|
+
description: "Reference to the OpenPkg schema version"
|
|
2128
|
+
},
|
|
2129
|
+
openpkg: {
|
|
2130
|
+
type: "string",
|
|
2131
|
+
const: "0.4.0"
|
|
2132
|
+
},
|
|
2133
|
+
meta: {
|
|
2134
|
+
type: "object",
|
|
2135
|
+
required: ["name"],
|
|
2136
|
+
properties: {
|
|
2137
|
+
name: { type: "string" },
|
|
2138
|
+
version: { type: "string" },
|
|
2139
|
+
description: { type: "string" },
|
|
2140
|
+
license: { type: "string" },
|
|
2141
|
+
repository: { type: "string" },
|
|
2142
|
+
ecosystem: { type: "string" }
|
|
2143
|
+
}
|
|
2144
|
+
},
|
|
2145
|
+
exports: {
|
|
2146
|
+
type: "array",
|
|
2147
|
+
items: { $ref: "#/$defs/export" }
|
|
2148
|
+
},
|
|
2149
|
+
types: {
|
|
2150
|
+
type: "array",
|
|
2151
|
+
items: { $ref: "#/$defs/typeDef" }
|
|
2152
|
+
},
|
|
2153
|
+
examples: {
|
|
2154
|
+
type: "array",
|
|
2155
|
+
items: { $ref: "#/$defs/example" }
|
|
2156
|
+
},
|
|
2157
|
+
extensions: {
|
|
2158
|
+
type: "object",
|
|
2159
|
+
properties: {
|
|
2160
|
+
presentation: {
|
|
2161
|
+
type: "object",
|
|
2162
|
+
additionalProperties: { $ref: "#/$defs/presentationMeta" }
|
|
2163
|
+
}
|
|
2164
|
+
},
|
|
2165
|
+
additionalProperties: true
|
|
2166
|
+
},
|
|
2167
|
+
generation: {
|
|
2168
|
+
$ref: "#/$defs/generationMeta",
|
|
2169
|
+
description: "Optional generation metadata"
|
|
2170
|
+
}
|
|
2171
|
+
},
|
|
2172
|
+
$defs: {
|
|
2173
|
+
generationMeta: {
|
|
2174
|
+
type: "object",
|
|
2175
|
+
properties: {
|
|
2176
|
+
generator: { type: "string" },
|
|
2177
|
+
timestamp: { type: "string", format: "date-time" }
|
|
2178
|
+
}
|
|
2179
|
+
},
|
|
2180
|
+
presentationMeta: {
|
|
2181
|
+
type: "object",
|
|
2182
|
+
properties: {
|
|
2183
|
+
slug: { type: "string" },
|
|
2184
|
+
displayName: { type: "string" },
|
|
2185
|
+
category: { type: "string" },
|
|
2186
|
+
importPath: { type: "string" },
|
|
2187
|
+
alias: { type: "string" }
|
|
2188
|
+
},
|
|
2189
|
+
additionalProperties: false
|
|
2190
|
+
},
|
|
2191
|
+
export: {
|
|
2192
|
+
type: "object",
|
|
2193
|
+
required: ["id", "name", "kind"],
|
|
2194
|
+
properties: {
|
|
2195
|
+
id: { type: "string" },
|
|
2196
|
+
name: { type: "string" },
|
|
2197
|
+
kind: {
|
|
2198
|
+
type: "string",
|
|
2199
|
+
enum: [
|
|
2200
|
+
"function",
|
|
2201
|
+
"class",
|
|
2202
|
+
"variable",
|
|
2203
|
+
"interface",
|
|
2204
|
+
"type",
|
|
2205
|
+
"enum",
|
|
2206
|
+
"module",
|
|
2207
|
+
"namespace",
|
|
2208
|
+
"reference",
|
|
2209
|
+
"external"
|
|
2210
|
+
]
|
|
2211
|
+
},
|
|
2212
|
+
description: { type: "string" },
|
|
2213
|
+
examples: {
|
|
2214
|
+
type: "array",
|
|
2215
|
+
items: { $ref: "#/$defs/example" }
|
|
2216
|
+
},
|
|
2217
|
+
signatures: {
|
|
2218
|
+
type: "array",
|
|
2219
|
+
items: { $ref: "#/$defs/signature" }
|
|
2220
|
+
},
|
|
2221
|
+
type: { type: "string" },
|
|
2222
|
+
schema: { $ref: "#/$defs/schema" },
|
|
2223
|
+
members: {
|
|
2224
|
+
type: "array",
|
|
2225
|
+
items: { $ref: "#/$defs/member" }
|
|
2226
|
+
},
|
|
2227
|
+
extends: { type: "string" },
|
|
2228
|
+
implements: {
|
|
2229
|
+
type: "array",
|
|
2230
|
+
items: { type: "string" }
|
|
2231
|
+
},
|
|
2232
|
+
tags: {
|
|
2233
|
+
type: "array",
|
|
2234
|
+
items: { $ref: "#/$defs/tag" }
|
|
2235
|
+
},
|
|
2236
|
+
source: { $ref: "#/$defs/sourceLocation" },
|
|
2237
|
+
deprecated: { type: "boolean" },
|
|
2238
|
+
flags: { type: "object", additionalProperties: true },
|
|
2239
|
+
typeParameters: {
|
|
2240
|
+
type: "array",
|
|
2241
|
+
items: { $ref: "#/$defs/typeParameter" }
|
|
2242
|
+
},
|
|
2243
|
+
typeAliasKind: { $ref: "#/$defs/typeAliasKind" },
|
|
2244
|
+
conditionalType: { $ref: "#/$defs/conditionalType" },
|
|
2245
|
+
mappedType: { $ref: "#/$defs/mappedType" },
|
|
2246
|
+
decorators: {
|
|
2247
|
+
type: "array",
|
|
2248
|
+
items: { $ref: "#/$defs/decorator" }
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
},
|
|
2252
|
+
typeDef: {
|
|
2253
|
+
type: "object",
|
|
2254
|
+
required: ["id", "name", "kind"],
|
|
2255
|
+
properties: {
|
|
2256
|
+
id: { type: "string" },
|
|
2257
|
+
name: { type: "string" },
|
|
2258
|
+
kind: {
|
|
2259
|
+
type: "string",
|
|
2260
|
+
enum: ["interface", "type", "enum", "class", "external"]
|
|
2261
|
+
},
|
|
2262
|
+
description: { type: "string" },
|
|
2263
|
+
schema: { $ref: "#/$defs/schema" },
|
|
2264
|
+
type: { type: "string" },
|
|
2265
|
+
members: {
|
|
2266
|
+
type: "array",
|
|
2267
|
+
items: { $ref: "#/$defs/member" }
|
|
2268
|
+
},
|
|
2269
|
+
extends: { type: "string" },
|
|
2270
|
+
implements: {
|
|
2271
|
+
type: "array",
|
|
2272
|
+
items: { type: "string" }
|
|
2273
|
+
},
|
|
2274
|
+
tags: {
|
|
2275
|
+
type: "array",
|
|
2276
|
+
items: { $ref: "#/$defs/tag" }
|
|
2277
|
+
},
|
|
2278
|
+
source: { $ref: "#/$defs/sourceLocation" },
|
|
2279
|
+
rawComments: { type: "string" },
|
|
2280
|
+
typeAliasKind: { $ref: "#/$defs/typeAliasKind" },
|
|
2281
|
+
conditionalType: { $ref: "#/$defs/conditionalType" },
|
|
2282
|
+
mappedType: { $ref: "#/$defs/mappedType" }
|
|
2283
|
+
}
|
|
2284
|
+
},
|
|
2285
|
+
tag: {
|
|
2286
|
+
type: "object",
|
|
2287
|
+
required: ["name", "text"],
|
|
2288
|
+
properties: {
|
|
2289
|
+
name: { type: "string" },
|
|
2290
|
+
text: { type: "string" }
|
|
2291
|
+
},
|
|
2292
|
+
additionalProperties: false
|
|
2293
|
+
},
|
|
2294
|
+
signature: {
|
|
2295
|
+
type: "object",
|
|
2296
|
+
properties: {
|
|
2297
|
+
parameters: {
|
|
2298
|
+
type: "array",
|
|
2299
|
+
items: { $ref: "#/$defs/parameter" }
|
|
2300
|
+
},
|
|
2301
|
+
returns: { $ref: "#/$defs/returns" },
|
|
2302
|
+
description: { type: "string" },
|
|
2303
|
+
typeParameters: {
|
|
2304
|
+
type: "array",
|
|
2305
|
+
items: { $ref: "#/$defs/typeParameter" }
|
|
2306
|
+
},
|
|
2307
|
+
overloadIndex: { type: "integer", minimum: 0 },
|
|
2308
|
+
isImplementation: { type: "boolean" },
|
|
2309
|
+
throws: {
|
|
2310
|
+
type: "array",
|
|
2311
|
+
items: { $ref: "#/$defs/throwsInfo" }
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
},
|
|
2315
|
+
typeParameter: {
|
|
2316
|
+
type: "object",
|
|
2317
|
+
required: ["name"],
|
|
2318
|
+
properties: {
|
|
2319
|
+
name: { type: "string" },
|
|
2320
|
+
constraint: { type: "string" },
|
|
2321
|
+
default: { type: "string" }
|
|
2322
|
+
}
|
|
2323
|
+
},
|
|
2324
|
+
parameter: {
|
|
2325
|
+
type: "object",
|
|
2326
|
+
required: ["name"],
|
|
2327
|
+
properties: {
|
|
2328
|
+
name: { type: "string" },
|
|
2329
|
+
required: { type: "boolean" },
|
|
2330
|
+
schema: { $ref: "#/$defs/schema" },
|
|
2331
|
+
description: { type: "string" },
|
|
2332
|
+
default: {},
|
|
2333
|
+
rest: { type: "boolean" },
|
|
2334
|
+
decorators: {
|
|
2335
|
+
type: "array",
|
|
2336
|
+
items: { $ref: "#/$defs/decorator" }
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
},
|
|
2340
|
+
returns: {
|
|
2341
|
+
type: "object",
|
|
2342
|
+
properties: {
|
|
2343
|
+
schema: { $ref: "#/$defs/schema" },
|
|
2344
|
+
description: { type: "string" }
|
|
2345
|
+
}
|
|
2346
|
+
},
|
|
2347
|
+
schema: {
|
|
2348
|
+
oneOf: [
|
|
2349
|
+
{ type: "string" },
|
|
2350
|
+
{ type: "boolean" },
|
|
2351
|
+
{
|
|
2352
|
+
type: "object",
|
|
2353
|
+
properties: {
|
|
2354
|
+
$schema: { type: "string" },
|
|
2355
|
+
type: { type: "string" },
|
|
2356
|
+
format: { type: "string" },
|
|
2357
|
+
enum: { type: "array" },
|
|
2358
|
+
const: {},
|
|
2359
|
+
items: { $ref: "#/$defs/schema" },
|
|
2360
|
+
prefixedItems: {
|
|
2361
|
+
type: "array",
|
|
2362
|
+
items: { $ref: "#/$defs/schema" }
|
|
2363
|
+
},
|
|
2364
|
+
properties: {
|
|
2365
|
+
type: "object",
|
|
2366
|
+
additionalProperties: { $ref: "#/$defs/schema" }
|
|
2367
|
+
},
|
|
2368
|
+
required: { type: "array", items: { type: "string" } },
|
|
2369
|
+
additionalProperties: {
|
|
2370
|
+
oneOf: [{ type: "boolean" }, { type: "object" }]
|
|
2371
|
+
},
|
|
2372
|
+
anyOf: { type: "array", items: { $ref: "#/$defs/schema" } },
|
|
2373
|
+
allOf: { type: "array", items: { $ref: "#/$defs/schema" } },
|
|
2374
|
+
oneOf: { type: "array", items: { $ref: "#/$defs/schema" } },
|
|
2375
|
+
$ref: { type: "string" },
|
|
2376
|
+
discriminator: {
|
|
2377
|
+
type: "object",
|
|
2378
|
+
properties: { propertyName: { type: "string" } }
|
|
2379
|
+
},
|
|
2380
|
+
description: { type: "string" },
|
|
2381
|
+
default: {},
|
|
2382
|
+
minimum: { type: "number" },
|
|
2383
|
+
maximum: { type: "number" },
|
|
2384
|
+
exclusiveMinimum: { type: "number" },
|
|
2385
|
+
exclusiveMaximum: { type: "number" },
|
|
2386
|
+
minLength: { type: "integer" },
|
|
2387
|
+
maxLength: { type: "integer" },
|
|
2388
|
+
pattern: { type: "string" },
|
|
2389
|
+
minItems: { type: "integer" },
|
|
2390
|
+
maxItems: { type: "integer" },
|
|
2391
|
+
uniqueItems: { type: "boolean" },
|
|
2392
|
+
signatures: { type: "array", items: { $ref: "#/$defs/signature" } }
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
]
|
|
2396
|
+
},
|
|
2397
|
+
sourceLocation: {
|
|
2398
|
+
type: "object",
|
|
2399
|
+
properties: {
|
|
2400
|
+
file: { type: "string" },
|
|
2401
|
+
line: { type: "integer", minimum: 1 },
|
|
2402
|
+
url: { type: "string" }
|
|
2403
|
+
}
|
|
2404
|
+
},
|
|
2405
|
+
typeAliasKind: {
|
|
2406
|
+
type: "string",
|
|
2407
|
+
enum: ["alias", "conditional", "mapped", "template-literal", "infer"]
|
|
2408
|
+
},
|
|
2409
|
+
conditionalType: {
|
|
2410
|
+
type: "object",
|
|
2411
|
+
required: ["checkType", "extendsType", "trueType", "falseType"],
|
|
2412
|
+
properties: {
|
|
2413
|
+
checkType: { type: "string" },
|
|
2414
|
+
extendsType: { type: "string" },
|
|
2415
|
+
trueType: { type: "string" },
|
|
2416
|
+
falseType: { type: "string" }
|
|
2417
|
+
},
|
|
2418
|
+
additionalProperties: false
|
|
2419
|
+
},
|
|
2420
|
+
mappedType: {
|
|
2421
|
+
type: "object",
|
|
2422
|
+
required: ["typeParameter"],
|
|
2423
|
+
properties: {
|
|
2424
|
+
typeParameter: { type: "string" },
|
|
2425
|
+
nameType: { type: "string" },
|
|
2426
|
+
valueType: { type: "string" },
|
|
2427
|
+
readonly: {
|
|
2428
|
+
oneOf: [{ type: "boolean" }, { enum: ["+", "-"] }]
|
|
2429
|
+
},
|
|
2430
|
+
optional: {
|
|
2431
|
+
oneOf: [{ type: "boolean" }, { enum: ["+", "-"] }]
|
|
2432
|
+
}
|
|
2433
|
+
},
|
|
2434
|
+
additionalProperties: false
|
|
2435
|
+
},
|
|
2436
|
+
decorator: {
|
|
2437
|
+
type: "object",
|
|
2438
|
+
required: ["name"],
|
|
2439
|
+
properties: {
|
|
2440
|
+
name: { type: "string" },
|
|
2441
|
+
arguments: { type: "array" },
|
|
2442
|
+
argumentsText: { type: "array", items: { type: "string" } }
|
|
2443
|
+
},
|
|
2444
|
+
additionalProperties: false
|
|
2445
|
+
},
|
|
2446
|
+
throwsInfo: {
|
|
2447
|
+
type: "object",
|
|
2448
|
+
properties: {
|
|
2449
|
+
type: { type: "string" },
|
|
2450
|
+
description: { type: "string" }
|
|
2451
|
+
},
|
|
2452
|
+
additionalProperties: false
|
|
2453
|
+
},
|
|
2454
|
+
exampleLanguage: {
|
|
2455
|
+
type: "string",
|
|
2456
|
+
enum: ["ts", "js", "tsx", "jsx", "shell", "json"]
|
|
2457
|
+
},
|
|
2458
|
+
example: {
|
|
2459
|
+
oneOf: [
|
|
2460
|
+
{ type: "string" },
|
|
2461
|
+
{
|
|
2462
|
+
type: "object",
|
|
2463
|
+
required: ["code"],
|
|
2464
|
+
properties: {
|
|
2465
|
+
code: { type: "string" },
|
|
2466
|
+
title: { type: "string" },
|
|
2467
|
+
description: { type: "string" },
|
|
2468
|
+
language: { $ref: "#/$defs/exampleLanguage" }
|
|
2469
|
+
},
|
|
2470
|
+
additionalProperties: false
|
|
2471
|
+
}
|
|
2472
|
+
]
|
|
2473
|
+
},
|
|
2474
|
+
visibility: {
|
|
2475
|
+
type: "string",
|
|
2476
|
+
enum: ["public", "protected", "private"]
|
|
2477
|
+
},
|
|
2478
|
+
member: {
|
|
2479
|
+
type: "object",
|
|
2480
|
+
properties: {
|
|
2481
|
+
id: { type: "string" },
|
|
2482
|
+
name: { type: "string" },
|
|
2483
|
+
kind: { type: "string" },
|
|
2484
|
+
description: { type: "string" },
|
|
2485
|
+
visibility: { $ref: "#/$defs/visibility" },
|
|
2486
|
+
tags: { type: "array", items: { $ref: "#/$defs/tag" } },
|
|
2487
|
+
flags: { type: "object", additionalProperties: true },
|
|
2488
|
+
schema: { $ref: "#/$defs/schema" },
|
|
2489
|
+
signatures: { type: "array", items: { $ref: "#/$defs/signature" } },
|
|
2490
|
+
decorators: { type: "array", items: { $ref: "#/$defs/decorator" } }
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
};
|
|
2132
2495
|
|
|
2133
2496
|
// src/validate.ts
|
|
2134
|
-
var LATEST_VERSION = "0.
|
|
2497
|
+
var LATEST_VERSION = "0.4.0";
|
|
2135
2498
|
var schemas = {
|
|
2136
2499
|
"0.1.0": openpkg_schema_default,
|
|
2137
2500
|
"0.2.0": openpkg_schema_default2,
|
|
2138
|
-
"0.3.0": openpkg_schema_default3
|
|
2501
|
+
"0.3.0": openpkg_schema_default3,
|
|
2502
|
+
"0.4.0": openpkg_schema_default4
|
|
2139
2503
|
};
|
|
2140
2504
|
var ajv = new Ajv({
|
|
2141
2505
|
strict: false,
|
|
@@ -2200,8 +2564,5 @@ export {
|
|
|
2200
2564
|
assertSpec,
|
|
2201
2565
|
SCHEMA_VERSION,
|
|
2202
2566
|
SCHEMA_URL,
|
|
2203
|
-
JSON_SCHEMA_DRAFT
|
|
2204
|
-
DRIFT_CATEGORY_LABELS,
|
|
2205
|
-
DRIFT_CATEGORY_DESCRIPTIONS,
|
|
2206
|
-
DRIFT_CATEGORIES
|
|
2567
|
+
JSON_SCHEMA_DRAFT
|
|
2207
2568
|
};
|
package/package.json
CHANGED
|
@@ -710,16 +710,18 @@
|
|
|
710
710
|
]
|
|
711
711
|
},
|
|
712
712
|
"schema": {
|
|
713
|
-
"description": "Flexible JSON Schema for type representation",
|
|
713
|
+
"description": "Flexible JSON Schema for type representation (supports Standard JSON Schema output)",
|
|
714
714
|
"oneOf": [
|
|
715
715
|
{ "type": "string" },
|
|
716
716
|
{ "type": "boolean" },
|
|
717
717
|
{
|
|
718
718
|
"type": "object",
|
|
719
719
|
"properties": {
|
|
720
|
+
"$schema": { "type": "string", "description": "JSON Schema draft URI" },
|
|
720
721
|
"type": { "type": "string" },
|
|
721
722
|
"format": { "type": "string" },
|
|
722
723
|
"enum": { "type": "array" },
|
|
724
|
+
"const": { "description": "Constant value" },
|
|
723
725
|
"items": { "$ref": "#/$defs/schema" },
|
|
724
726
|
"prefixedItems": {
|
|
725
727
|
"type": "array",
|
|
@@ -732,7 +734,7 @@
|
|
|
732
734
|
},
|
|
733
735
|
"required": { "type": "array", "items": { "type": "string" } },
|
|
734
736
|
"additionalProperties": {
|
|
735
|
-
"oneOf": [{ "type": "boolean" }, { "
|
|
737
|
+
"oneOf": [{ "type": "boolean" }, { "type": "object", "additionalProperties": true }]
|
|
736
738
|
},
|
|
737
739
|
"anyOf": { "type": "array", "items": { "$ref": "#/$defs/schema" } },
|
|
738
740
|
"allOf": { "type": "array", "items": { "$ref": "#/$defs/schema" } },
|
|
@@ -742,10 +744,18 @@
|
|
|
742
744
|
"type": "object",
|
|
743
745
|
"properties": { "propertyName": { "type": "string" } }
|
|
744
746
|
},
|
|
745
|
-
"tsType": { "type": "string" },
|
|
746
747
|
"description": { "type": "string" },
|
|
748
|
+
"default": { "description": "Default value for the schema" },
|
|
749
|
+
"minimum": { "type": "number", "description": "Minimum value for numbers" },
|
|
750
|
+
"maximum": { "type": "number", "description": "Maximum value for numbers" },
|
|
751
|
+
"exclusiveMinimum": { "type": "number" },
|
|
752
|
+
"exclusiveMaximum": { "type": "number" },
|
|
753
|
+
"minLength": { "type": "integer", "description": "Minimum string length" },
|
|
754
|
+
"maxLength": { "type": "integer", "description": "Maximum string length" },
|
|
755
|
+
"pattern": { "type": "string", "description": "Regex pattern for strings" },
|
|
747
756
|
"minItems": { "type": "integer" },
|
|
748
757
|
"maxItems": { "type": "integer" },
|
|
758
|
+
"uniqueItems": { "type": "boolean" },
|
|
749
759
|
"signatures": { "type": "array", "items": { "$ref": "#/$defs/signature" } }
|
|
750
760
|
}
|
|
751
761
|
}
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://unpkg.com/@openpkg-ts/spec/schemas/v0.4.0/openpkg.schema.json",
|
|
4
|
+
"title": "OpenPkg Specification v0.4.0",
|
|
5
|
+
"description": "Minimal tool-agnostic TypeScript export representation",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["openpkg", "meta", "exports"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"$schema": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Reference to the OpenPkg schema version"
|
|
12
|
+
},
|
|
13
|
+
"openpkg": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"const": "0.4.0"
|
|
16
|
+
},
|
|
17
|
+
"meta": {
|
|
18
|
+
"type": "object",
|
|
19
|
+
"required": ["name"],
|
|
20
|
+
"properties": {
|
|
21
|
+
"name": { "type": "string" },
|
|
22
|
+
"version": { "type": "string" },
|
|
23
|
+
"description": { "type": "string" },
|
|
24
|
+
"license": { "type": "string" },
|
|
25
|
+
"repository": { "type": "string" },
|
|
26
|
+
"ecosystem": { "type": "string" }
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"exports": {
|
|
30
|
+
"type": "array",
|
|
31
|
+
"items": { "$ref": "#/$defs/export" }
|
|
32
|
+
},
|
|
33
|
+
"types": {
|
|
34
|
+
"type": "array",
|
|
35
|
+
"items": { "$ref": "#/$defs/typeDef" }
|
|
36
|
+
},
|
|
37
|
+
"examples": {
|
|
38
|
+
"type": "array",
|
|
39
|
+
"items": { "$ref": "#/$defs/example" }
|
|
40
|
+
},
|
|
41
|
+
"extensions": {
|
|
42
|
+
"type": "object",
|
|
43
|
+
"properties": {
|
|
44
|
+
"presentation": {
|
|
45
|
+
"type": "object",
|
|
46
|
+
"additionalProperties": { "$ref": "#/$defs/presentationMeta" }
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"additionalProperties": true
|
|
50
|
+
},
|
|
51
|
+
"generation": {
|
|
52
|
+
"$ref": "#/$defs/generationMeta",
|
|
53
|
+
"description": "Optional generation metadata"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"$defs": {
|
|
57
|
+
"generationMeta": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"properties": {
|
|
60
|
+
"generator": { "type": "string" },
|
|
61
|
+
"timestamp": { "type": "string", "format": "date-time" }
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"presentationMeta": {
|
|
65
|
+
"type": "object",
|
|
66
|
+
"properties": {
|
|
67
|
+
"slug": { "type": "string" },
|
|
68
|
+
"displayName": { "type": "string" },
|
|
69
|
+
"category": { "type": "string" },
|
|
70
|
+
"importPath": { "type": "string" },
|
|
71
|
+
"alias": { "type": "string" }
|
|
72
|
+
},
|
|
73
|
+
"additionalProperties": false
|
|
74
|
+
},
|
|
75
|
+
"export": {
|
|
76
|
+
"type": "object",
|
|
77
|
+
"required": ["id", "name", "kind"],
|
|
78
|
+
"properties": {
|
|
79
|
+
"id": { "type": "string" },
|
|
80
|
+
"name": { "type": "string" },
|
|
81
|
+
"kind": {
|
|
82
|
+
"type": "string",
|
|
83
|
+
"enum": [
|
|
84
|
+
"function",
|
|
85
|
+
"class",
|
|
86
|
+
"variable",
|
|
87
|
+
"interface",
|
|
88
|
+
"type",
|
|
89
|
+
"enum",
|
|
90
|
+
"module",
|
|
91
|
+
"namespace",
|
|
92
|
+
"reference",
|
|
93
|
+
"external"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
"description": { "type": "string" },
|
|
97
|
+
"examples": {
|
|
98
|
+
"type": "array",
|
|
99
|
+
"items": { "$ref": "#/$defs/example" }
|
|
100
|
+
},
|
|
101
|
+
"signatures": {
|
|
102
|
+
"type": "array",
|
|
103
|
+
"items": { "$ref": "#/$defs/signature" }
|
|
104
|
+
},
|
|
105
|
+
"type": { "type": "string" },
|
|
106
|
+
"schema": { "$ref": "#/$defs/schema" },
|
|
107
|
+
"members": {
|
|
108
|
+
"type": "array",
|
|
109
|
+
"items": { "$ref": "#/$defs/member" }
|
|
110
|
+
},
|
|
111
|
+
"extends": { "type": "string" },
|
|
112
|
+
"implements": {
|
|
113
|
+
"type": "array",
|
|
114
|
+
"items": { "type": "string" }
|
|
115
|
+
},
|
|
116
|
+
"tags": {
|
|
117
|
+
"type": "array",
|
|
118
|
+
"items": { "$ref": "#/$defs/tag" }
|
|
119
|
+
},
|
|
120
|
+
"source": { "$ref": "#/$defs/sourceLocation" },
|
|
121
|
+
"deprecated": { "type": "boolean" },
|
|
122
|
+
"flags": { "type": "object", "additionalProperties": true },
|
|
123
|
+
"typeParameters": {
|
|
124
|
+
"type": "array",
|
|
125
|
+
"items": { "$ref": "#/$defs/typeParameter" }
|
|
126
|
+
},
|
|
127
|
+
"typeAliasKind": { "$ref": "#/$defs/typeAliasKind" },
|
|
128
|
+
"conditionalType": { "$ref": "#/$defs/conditionalType" },
|
|
129
|
+
"mappedType": { "$ref": "#/$defs/mappedType" },
|
|
130
|
+
"decorators": {
|
|
131
|
+
"type": "array",
|
|
132
|
+
"items": { "$ref": "#/$defs/decorator" }
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
"typeDef": {
|
|
137
|
+
"type": "object",
|
|
138
|
+
"required": ["id", "name", "kind"],
|
|
139
|
+
"properties": {
|
|
140
|
+
"id": { "type": "string" },
|
|
141
|
+
"name": { "type": "string" },
|
|
142
|
+
"kind": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"enum": ["interface", "type", "enum", "class", "external"]
|
|
145
|
+
},
|
|
146
|
+
"description": { "type": "string" },
|
|
147
|
+
"schema": { "$ref": "#/$defs/schema" },
|
|
148
|
+
"type": { "type": "string" },
|
|
149
|
+
"members": {
|
|
150
|
+
"type": "array",
|
|
151
|
+
"items": { "$ref": "#/$defs/member" }
|
|
152
|
+
},
|
|
153
|
+
"extends": { "type": "string" },
|
|
154
|
+
"implements": {
|
|
155
|
+
"type": "array",
|
|
156
|
+
"items": { "type": "string" }
|
|
157
|
+
},
|
|
158
|
+
"tags": {
|
|
159
|
+
"type": "array",
|
|
160
|
+
"items": { "$ref": "#/$defs/tag" }
|
|
161
|
+
},
|
|
162
|
+
"source": { "$ref": "#/$defs/sourceLocation" },
|
|
163
|
+
"rawComments": { "type": "string" },
|
|
164
|
+
"typeAliasKind": { "$ref": "#/$defs/typeAliasKind" },
|
|
165
|
+
"conditionalType": { "$ref": "#/$defs/conditionalType" },
|
|
166
|
+
"mappedType": { "$ref": "#/$defs/mappedType" }
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
"tag": {
|
|
170
|
+
"type": "object",
|
|
171
|
+
"required": ["name", "text"],
|
|
172
|
+
"properties": {
|
|
173
|
+
"name": { "type": "string" },
|
|
174
|
+
"text": { "type": "string" }
|
|
175
|
+
},
|
|
176
|
+
"additionalProperties": false
|
|
177
|
+
},
|
|
178
|
+
"signature": {
|
|
179
|
+
"type": "object",
|
|
180
|
+
"properties": {
|
|
181
|
+
"parameters": {
|
|
182
|
+
"type": "array",
|
|
183
|
+
"items": { "$ref": "#/$defs/parameter" }
|
|
184
|
+
},
|
|
185
|
+
"returns": { "$ref": "#/$defs/returns" },
|
|
186
|
+
"description": { "type": "string" },
|
|
187
|
+
"typeParameters": {
|
|
188
|
+
"type": "array",
|
|
189
|
+
"items": { "$ref": "#/$defs/typeParameter" }
|
|
190
|
+
},
|
|
191
|
+
"overloadIndex": { "type": "integer", "minimum": 0 },
|
|
192
|
+
"isImplementation": { "type": "boolean" },
|
|
193
|
+
"throws": {
|
|
194
|
+
"type": "array",
|
|
195
|
+
"items": { "$ref": "#/$defs/throwsInfo" }
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"typeParameter": {
|
|
200
|
+
"type": "object",
|
|
201
|
+
"required": ["name"],
|
|
202
|
+
"properties": {
|
|
203
|
+
"name": { "type": "string" },
|
|
204
|
+
"constraint": { "type": "string" },
|
|
205
|
+
"default": { "type": "string" }
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
"parameter": {
|
|
209
|
+
"type": "object",
|
|
210
|
+
"required": ["name"],
|
|
211
|
+
"properties": {
|
|
212
|
+
"name": { "type": "string" },
|
|
213
|
+
"required": { "type": "boolean" },
|
|
214
|
+
"schema": { "$ref": "#/$defs/schema" },
|
|
215
|
+
"description": { "type": "string" },
|
|
216
|
+
"default": {},
|
|
217
|
+
"rest": { "type": "boolean" },
|
|
218
|
+
"decorators": {
|
|
219
|
+
"type": "array",
|
|
220
|
+
"items": { "$ref": "#/$defs/decorator" }
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
"returns": {
|
|
225
|
+
"type": "object",
|
|
226
|
+
"properties": {
|
|
227
|
+
"schema": { "$ref": "#/$defs/schema" },
|
|
228
|
+
"description": { "type": "string" }
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
"schema": {
|
|
232
|
+
"oneOf": [
|
|
233
|
+
{ "type": "string" },
|
|
234
|
+
{ "type": "boolean" },
|
|
235
|
+
{
|
|
236
|
+
"type": "object",
|
|
237
|
+
"properties": {
|
|
238
|
+
"$schema": { "type": "string" },
|
|
239
|
+
"type": { "type": "string" },
|
|
240
|
+
"format": { "type": "string" },
|
|
241
|
+
"enum": { "type": "array" },
|
|
242
|
+
"const": {},
|
|
243
|
+
"items": { "$ref": "#/$defs/schema" },
|
|
244
|
+
"prefixedItems": {
|
|
245
|
+
"type": "array",
|
|
246
|
+
"items": { "$ref": "#/$defs/schema" }
|
|
247
|
+
},
|
|
248
|
+
"properties": {
|
|
249
|
+
"type": "object",
|
|
250
|
+
"additionalProperties": { "$ref": "#/$defs/schema" }
|
|
251
|
+
},
|
|
252
|
+
"required": { "type": "array", "items": { "type": "string" } },
|
|
253
|
+
"additionalProperties": {
|
|
254
|
+
"oneOf": [{ "type": "boolean" }, { "type": "object" }]
|
|
255
|
+
},
|
|
256
|
+
"anyOf": { "type": "array", "items": { "$ref": "#/$defs/schema" } },
|
|
257
|
+
"allOf": { "type": "array", "items": { "$ref": "#/$defs/schema" } },
|
|
258
|
+
"oneOf": { "type": "array", "items": { "$ref": "#/$defs/schema" } },
|
|
259
|
+
"$ref": { "type": "string" },
|
|
260
|
+
"discriminator": {
|
|
261
|
+
"type": "object",
|
|
262
|
+
"properties": { "propertyName": { "type": "string" } }
|
|
263
|
+
},
|
|
264
|
+
"description": { "type": "string" },
|
|
265
|
+
"default": {},
|
|
266
|
+
"minimum": { "type": "number" },
|
|
267
|
+
"maximum": { "type": "number" },
|
|
268
|
+
"exclusiveMinimum": { "type": "number" },
|
|
269
|
+
"exclusiveMaximum": { "type": "number" },
|
|
270
|
+
"minLength": { "type": "integer" },
|
|
271
|
+
"maxLength": { "type": "integer" },
|
|
272
|
+
"pattern": { "type": "string" },
|
|
273
|
+
"minItems": { "type": "integer" },
|
|
274
|
+
"maxItems": { "type": "integer" },
|
|
275
|
+
"uniqueItems": { "type": "boolean" },
|
|
276
|
+
"signatures": { "type": "array", "items": { "$ref": "#/$defs/signature" } }
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
]
|
|
280
|
+
},
|
|
281
|
+
"sourceLocation": {
|
|
282
|
+
"type": "object",
|
|
283
|
+
"properties": {
|
|
284
|
+
"file": { "type": "string" },
|
|
285
|
+
"line": { "type": "integer", "minimum": 1 },
|
|
286
|
+
"url": { "type": "string" }
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
"typeAliasKind": {
|
|
290
|
+
"type": "string",
|
|
291
|
+
"enum": ["alias", "conditional", "mapped", "template-literal", "infer"]
|
|
292
|
+
},
|
|
293
|
+
"conditionalType": {
|
|
294
|
+
"type": "object",
|
|
295
|
+
"required": ["checkType", "extendsType", "trueType", "falseType"],
|
|
296
|
+
"properties": {
|
|
297
|
+
"checkType": { "type": "string" },
|
|
298
|
+
"extendsType": { "type": "string" },
|
|
299
|
+
"trueType": { "type": "string" },
|
|
300
|
+
"falseType": { "type": "string" }
|
|
301
|
+
},
|
|
302
|
+
"additionalProperties": false
|
|
303
|
+
},
|
|
304
|
+
"mappedType": {
|
|
305
|
+
"type": "object",
|
|
306
|
+
"required": ["typeParameter"],
|
|
307
|
+
"properties": {
|
|
308
|
+
"typeParameter": { "type": "string" },
|
|
309
|
+
"nameType": { "type": "string" },
|
|
310
|
+
"valueType": { "type": "string" },
|
|
311
|
+
"readonly": {
|
|
312
|
+
"oneOf": [{ "type": "boolean" }, { "enum": ["+", "-"] }]
|
|
313
|
+
},
|
|
314
|
+
"optional": {
|
|
315
|
+
"oneOf": [{ "type": "boolean" }, { "enum": ["+", "-"] }]
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
"additionalProperties": false
|
|
319
|
+
},
|
|
320
|
+
"decorator": {
|
|
321
|
+
"type": "object",
|
|
322
|
+
"required": ["name"],
|
|
323
|
+
"properties": {
|
|
324
|
+
"name": { "type": "string" },
|
|
325
|
+
"arguments": { "type": "array" },
|
|
326
|
+
"argumentsText": { "type": "array", "items": { "type": "string" } }
|
|
327
|
+
},
|
|
328
|
+
"additionalProperties": false
|
|
329
|
+
},
|
|
330
|
+
"throwsInfo": {
|
|
331
|
+
"type": "object",
|
|
332
|
+
"properties": {
|
|
333
|
+
"type": { "type": "string" },
|
|
334
|
+
"description": { "type": "string" }
|
|
335
|
+
},
|
|
336
|
+
"additionalProperties": false
|
|
337
|
+
},
|
|
338
|
+
"exampleLanguage": {
|
|
339
|
+
"type": "string",
|
|
340
|
+
"enum": ["ts", "js", "tsx", "jsx", "shell", "json"]
|
|
341
|
+
},
|
|
342
|
+
"example": {
|
|
343
|
+
"oneOf": [
|
|
344
|
+
{ "type": "string" },
|
|
345
|
+
{
|
|
346
|
+
"type": "object",
|
|
347
|
+
"required": ["code"],
|
|
348
|
+
"properties": {
|
|
349
|
+
"code": { "type": "string" },
|
|
350
|
+
"title": { "type": "string" },
|
|
351
|
+
"description": { "type": "string" },
|
|
352
|
+
"language": { "$ref": "#/$defs/exampleLanguage" }
|
|
353
|
+
},
|
|
354
|
+
"additionalProperties": false
|
|
355
|
+
}
|
|
356
|
+
]
|
|
357
|
+
},
|
|
358
|
+
"visibility": {
|
|
359
|
+
"type": "string",
|
|
360
|
+
"enum": ["public", "protected", "private"]
|
|
361
|
+
},
|
|
362
|
+
"member": {
|
|
363
|
+
"type": "object",
|
|
364
|
+
"properties": {
|
|
365
|
+
"id": { "type": "string" },
|
|
366
|
+
"name": { "type": "string" },
|
|
367
|
+
"kind": { "type": "string" },
|
|
368
|
+
"description": { "type": "string" },
|
|
369
|
+
"visibility": { "$ref": "#/$defs/visibility" },
|
|
370
|
+
"tags": { "type": "array", "items": { "$ref": "#/$defs/tag" } },
|
|
371
|
+
"flags": { "type": "object", "additionalProperties": true },
|
|
372
|
+
"schema": { "$ref": "#/$defs/schema" },
|
|
373
|
+
"signatures": { "type": "array", "items": { "$ref": "#/$defs/signature" } },
|
|
374
|
+
"decorators": { "type": "array", "items": { "$ref": "#/$defs/decorator" } }
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|