@openpkg-ts/sdk 0.30.1 → 0.31.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/README.md +53 -0
- package/dist/index.d.ts +137 -58
- package/dist/index.js +182 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -75,6 +75,55 @@ import { diffSpecs } from '@openpkg-ts/sdk';
|
|
|
75
75
|
|
|
76
76
|
const diff = diffSpecs(oldSpec, newSpec);
|
|
77
77
|
console.log(`Breaking: ${diff.breaking.length}`);
|
|
78
|
+
|
|
79
|
+
// With options
|
|
80
|
+
const diff = diffSpecs(oldSpec, newSpec, {
|
|
81
|
+
includeDocsOnly: false, // exclude docs-only changes
|
|
82
|
+
kinds: ['function', 'class'], // filter by kind
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### filterSpec
|
|
87
|
+
|
|
88
|
+
Immutable spec filtering by criteria.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
import { filterSpec } from '@openpkg-ts/sdk';
|
|
92
|
+
|
|
93
|
+
// Filter by kind
|
|
94
|
+
const { spec, matched, total } = filterSpec(fullSpec, {
|
|
95
|
+
kinds: ['function', 'class'],
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Filter by tags
|
|
99
|
+
filterSpec(spec, { tags: ['public'] });
|
|
100
|
+
|
|
101
|
+
// Filter deprecated exports
|
|
102
|
+
filterSpec(spec, { deprecated: true });
|
|
103
|
+
|
|
104
|
+
// Search by name/description
|
|
105
|
+
filterSpec(spec, { search: 'client' });
|
|
106
|
+
|
|
107
|
+
// Combine criteria (AND logic)
|
|
108
|
+
filterSpec(spec, {
|
|
109
|
+
kinds: ['function'],
|
|
110
|
+
hasDescription: true,
|
|
111
|
+
deprecated: false,
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### analyzeSpec
|
|
116
|
+
|
|
117
|
+
Analyze spec for quality issues.
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
import { analyzeSpec } from '@openpkg-ts/sdk';
|
|
121
|
+
|
|
122
|
+
const diagnostics = analyzeSpec(spec);
|
|
123
|
+
|
|
124
|
+
console.log(`Missing descriptions: ${diagnostics.missingDescriptions.length}`);
|
|
125
|
+
console.log(`Deprecated without reason: ${diagnostics.deprecatedNoReason.length}`);
|
|
126
|
+
console.log(`Missing param docs: ${diagnostics.missingParamDocs.length}`);
|
|
78
127
|
```
|
|
79
128
|
|
|
80
129
|
## Documentation Generation
|
|
@@ -144,6 +193,10 @@ import type {
|
|
|
144
193
|
ExtractResult,
|
|
145
194
|
DocsInstance,
|
|
146
195
|
SimplifiedSpec,
|
|
196
|
+
FilterCriteria,
|
|
197
|
+
FilterResult,
|
|
198
|
+
SpecDiagnostics,
|
|
199
|
+
DiffOptions,
|
|
147
200
|
} from '@openpkg-ts/sdk';
|
|
148
201
|
```
|
|
149
202
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,77 @@
|
|
|
1
|
+
import { OpenPkg, SpecExportKind } from "@openpkg-ts/spec";
|
|
2
|
+
type FilterCriteria = {
|
|
3
|
+
/** Filter by kinds */
|
|
4
|
+
kinds?: SpecExportKind[];
|
|
5
|
+
/** Filter by names (exact match) */
|
|
6
|
+
names?: string[];
|
|
7
|
+
/** Filter by IDs */
|
|
8
|
+
ids?: string[];
|
|
9
|
+
/** Filter by tags (must have at least one matching tag) */
|
|
10
|
+
tags?: string[];
|
|
11
|
+
/** Filter by deprecation status */
|
|
12
|
+
deprecated?: boolean;
|
|
13
|
+
/** Filter by whether has a description */
|
|
14
|
+
hasDescription?: boolean;
|
|
15
|
+
/** Search term (matches name or description, case-insensitive) */
|
|
16
|
+
search?: string;
|
|
17
|
+
/** Filter by module path (source.file contains this) */
|
|
18
|
+
module?: string;
|
|
19
|
+
};
|
|
20
|
+
type FilterResult = {
|
|
21
|
+
/** New spec with only matched exports (immutable) */
|
|
22
|
+
spec: OpenPkg;
|
|
23
|
+
/** Number of exports that matched */
|
|
24
|
+
matched: number;
|
|
25
|
+
/** Total number of exports in original spec */
|
|
26
|
+
total: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Filter a spec by various criteria.
|
|
30
|
+
* Returns a new spec with only matched exports (never mutates input).
|
|
31
|
+
* Uses AND logic: all specified criteria must match.
|
|
32
|
+
* Types are always preserved (no pruning).
|
|
33
|
+
*
|
|
34
|
+
* @param spec - The spec to filter
|
|
35
|
+
* @param criteria - Filter criteria (empty criteria matches all)
|
|
36
|
+
* @returns FilterResult with new spec, matched count, total count
|
|
37
|
+
*/
|
|
38
|
+
declare function filterSpec(spec: OpenPkg, criteria: FilterCriteria): FilterResult;
|
|
1
39
|
import { BreakingSeverity, CategorizedBreaking, calculateNextVersion, categorizeBreakingChanges, diffSpec, diffSpec as diffSpec2, MemberChangeInfo, recommendSemverBump, SemverBump, SemverRecommendation, SpecDiff } from "@openpkg-ts/spec";
|
|
40
|
+
import { OpenPkg as OpenPkg2, SpecExport } from "@openpkg-ts/spec";
|
|
41
|
+
interface DiagnosticItem {
|
|
42
|
+
exportId: string;
|
|
43
|
+
exportName: string;
|
|
44
|
+
issue: string;
|
|
45
|
+
/** Member name if issue is on a member */
|
|
46
|
+
member?: string;
|
|
47
|
+
/** Parameter name if issue is on a parameter */
|
|
48
|
+
param?: string;
|
|
49
|
+
}
|
|
50
|
+
interface SpecDiagnostics {
|
|
51
|
+
/** Exports/members without descriptions */
|
|
52
|
+
missingDescriptions: DiagnosticItem[];
|
|
53
|
+
/** Exports marked @deprecated but no reason provided */
|
|
54
|
+
deprecatedNoReason: DiagnosticItem[];
|
|
55
|
+
/** Function params without descriptions in JSDoc */
|
|
56
|
+
missingParamDocs: DiagnosticItem[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Check if has @deprecated tag.
|
|
60
|
+
*/
|
|
61
|
+
declare function hasDeprecatedTag(exp: SpecExport): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Get deprecation message from @deprecated tag.
|
|
64
|
+
* Returns undefined if no reason provided.
|
|
65
|
+
*/
|
|
66
|
+
declare function getDeprecationMessage(exp: SpecExport): string | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Find params without descriptions in JSDoc.
|
|
69
|
+
*/
|
|
70
|
+
declare function findMissingParamDocs(exp: SpecExport): string[];
|
|
71
|
+
/**
|
|
72
|
+
* Analyze a spec for quality issues.
|
|
73
|
+
*/
|
|
74
|
+
declare function analyzeSpec(spec: OpenPkg2): SpecDiagnostics;
|
|
2
75
|
import { SpecMember } from "@openpkg-ts/spec";
|
|
3
76
|
/**
|
|
4
77
|
* Extract badge strings from a member's visibility and flags.
|
|
@@ -9,8 +82,8 @@ declare function getMemberBadges(member: SpecMember): string[];
|
|
|
9
82
|
* Format badges array into a display string (space-separated).
|
|
10
83
|
*/
|
|
11
84
|
declare function formatBadges(badges: string[]): string;
|
|
12
|
-
import { OpenPkg as
|
|
13
|
-
import { OpenPkg } from "@openpkg-ts/spec";
|
|
85
|
+
import { OpenPkg as OpenPkg8, SpecExport as SpecExport3, SpecExportKind as SpecExportKind5, SpecType } from "@openpkg-ts/spec";
|
|
86
|
+
import { OpenPkg as OpenPkg3 } from "@openpkg-ts/spec";
|
|
14
87
|
interface HTMLOptions {
|
|
15
88
|
/** Page title override */
|
|
16
89
|
title?: string;
|
|
@@ -24,6 +97,8 @@ interface HTMLOptions {
|
|
|
24
97
|
fullDocument?: boolean;
|
|
25
98
|
/** Export to render (single mode) */
|
|
26
99
|
export?: string;
|
|
100
|
+
/** Exports to render (multi-mode) - overridden by `export` if both provided */
|
|
101
|
+
exports?: string[];
|
|
27
102
|
}
|
|
28
103
|
/**
|
|
29
104
|
* Render spec to standalone HTML page.
|
|
@@ -46,13 +121,15 @@ interface HTMLOptions {
|
|
|
46
121
|
* const fragment = docs.toHTML({ export: 'greet', fullDocument: false })
|
|
47
122
|
* ```
|
|
48
123
|
*/
|
|
49
|
-
declare function toHTML2(spec:
|
|
50
|
-
import { OpenPkg as
|
|
124
|
+
declare function toHTML2(spec: OpenPkg3, options?: HTMLOptions): string;
|
|
125
|
+
import { OpenPkg as OpenPkg4, SpecExportKind as SpecExportKind2 } from "@openpkg-ts/spec";
|
|
51
126
|
interface JSONOptions {
|
|
52
127
|
/** Include raw spec data alongside simplified data */
|
|
53
128
|
includeRaw?: boolean;
|
|
54
129
|
/** Export to render (single mode) */
|
|
55
130
|
export?: string;
|
|
131
|
+
/** Exports to render (multi-mode) - overridden by `export` if both provided */
|
|
132
|
+
exports?: string[];
|
|
56
133
|
/** Include computed fields (signatures, formatted types) */
|
|
57
134
|
computed?: boolean;
|
|
58
135
|
/** Flatten nested structures */
|
|
@@ -93,7 +170,7 @@ interface SimplifiedExample {
|
|
|
93
170
|
interface SimplifiedExport {
|
|
94
171
|
id: string;
|
|
95
172
|
name: string;
|
|
96
|
-
kind:
|
|
173
|
+
kind: SpecExportKind2;
|
|
97
174
|
signature: string;
|
|
98
175
|
description?: string;
|
|
99
176
|
deprecated: boolean;
|
|
@@ -115,7 +192,7 @@ interface SimplifiedSpec {
|
|
|
115
192
|
version?: string;
|
|
116
193
|
description?: string;
|
|
117
194
|
exports: SimplifiedExport[];
|
|
118
|
-
byKind: Record<
|
|
195
|
+
byKind: Record<SpecExportKind2, SimplifiedExport[]>;
|
|
119
196
|
totalExports: number;
|
|
120
197
|
}
|
|
121
198
|
/**
|
|
@@ -139,7 +216,7 @@ interface SimplifiedSpec {
|
|
|
139
216
|
* // { id, name, kind, signature, parameters, returns, ... }
|
|
140
217
|
* ```
|
|
141
218
|
*/
|
|
142
|
-
declare function toJSON2(spec:
|
|
219
|
+
declare function toJSON2(spec: OpenPkg4, options?: JSONOptions): SimplifiedSpec | SimplifiedExport;
|
|
143
220
|
/**
|
|
144
221
|
* Serialize to JSON string with formatting.
|
|
145
222
|
*
|
|
@@ -147,10 +224,10 @@ declare function toJSON2(spec: OpenPkg2, options?: JSONOptions): SimplifiedSpec
|
|
|
147
224
|
* @param options - JSON options plus pretty formatting option
|
|
148
225
|
* @returns JSON string
|
|
149
226
|
*/
|
|
150
|
-
declare function toJSONString(spec:
|
|
227
|
+
declare function toJSONString(spec: OpenPkg4, options?: JSONOptions & {
|
|
151
228
|
pretty?: boolean;
|
|
152
229
|
}): string;
|
|
153
|
-
import { OpenPkg as
|
|
230
|
+
import { OpenPkg as OpenPkg5, SpecExport as SpecExport2 } from "@openpkg-ts/spec";
|
|
154
231
|
interface MarkdownOptions {
|
|
155
232
|
/** Include frontmatter in output */
|
|
156
233
|
frontmatter?: boolean;
|
|
@@ -173,8 +250,10 @@ interface MarkdownOptions {
|
|
|
173
250
|
headingOffset?: number;
|
|
174
251
|
}
|
|
175
252
|
interface ExportMarkdownOptions extends MarkdownOptions {
|
|
176
|
-
/** Export to render */
|
|
253
|
+
/** Export to render (single mode) */
|
|
177
254
|
export?: string;
|
|
255
|
+
/** Exports to render (multi-mode) - overridden by `export` if both provided */
|
|
256
|
+
exports?: string[];
|
|
178
257
|
}
|
|
179
258
|
/**
|
|
180
259
|
* Render a single to MDX.
|
|
@@ -192,7 +271,7 @@ interface ExportMarkdownOptions extends MarkdownOptions {
|
|
|
192
271
|
* })
|
|
193
272
|
* ```
|
|
194
273
|
*/
|
|
195
|
-
declare function exportToMarkdown(exp:
|
|
274
|
+
declare function exportToMarkdown(exp: SpecExport2, options?: MarkdownOptions): string;
|
|
196
275
|
/**
|
|
197
276
|
* Render entire spec to MDX.
|
|
198
277
|
*
|
|
@@ -212,8 +291,8 @@ declare function exportToMarkdown(exp: SpecExport, options?: MarkdownOptions): s
|
|
|
212
291
|
* // Single * const fnMdx = docs.toMarkdown({ export: 'greet' })
|
|
213
292
|
* ```
|
|
214
293
|
*/
|
|
215
|
-
declare function toMarkdown2(spec:
|
|
216
|
-
import { OpenPkg as
|
|
294
|
+
declare function toMarkdown2(spec: OpenPkg5, options?: ExportMarkdownOptions): string;
|
|
295
|
+
import { OpenPkg as OpenPkg6, SpecExportKind as SpecExportKind3 } from "@openpkg-ts/spec";
|
|
217
296
|
type NavFormat = "fumadocs" | "docusaurus" | "generic";
|
|
218
297
|
type GroupBy = "kind" | "module" | "tag" | "none";
|
|
219
298
|
interface NavOptions {
|
|
@@ -228,7 +307,7 @@ interface NavOptions {
|
|
|
228
307
|
/** Include index pages for groups */
|
|
229
308
|
includeGroupIndex?: boolean;
|
|
230
309
|
/** Custom kind labels */
|
|
231
|
-
kindLabels?: Partial<Record<
|
|
310
|
+
kindLabels?: Partial<Record<SpecExportKind3, string>>;
|
|
232
311
|
/** Sort exports alphabetically */
|
|
233
312
|
sortAlphabetically?: boolean;
|
|
234
313
|
}
|
|
@@ -288,7 +367,7 @@ type DocusaurusSidebar = DocusaurusSidebarItem[];
|
|
|
288
367
|
* const sidebar = docs.toNavigation({ format: 'docusaurus' })
|
|
289
368
|
* ```
|
|
290
369
|
*/
|
|
291
|
-
declare function toNavigation2(spec:
|
|
370
|
+
declare function toNavigation2(spec: OpenPkg6, options?: NavOptions): GenericNav | FumadocsMeta | DocusaurusSidebar;
|
|
292
371
|
/**
|
|
293
372
|
* Generate Fumadocs meta.json file content.
|
|
294
373
|
*
|
|
@@ -302,7 +381,7 @@ declare function toNavigation2(spec: OpenPkg4, options?: NavOptions): GenericNav
|
|
|
302
381
|
* fs.writeFileSync('docs/api/meta.json', meta)
|
|
303
382
|
* ```
|
|
304
383
|
*/
|
|
305
|
-
declare function toFumadocsMetaJSON(spec:
|
|
384
|
+
declare function toFumadocsMetaJSON(spec: OpenPkg6, options?: Omit<NavOptions, "format">): string;
|
|
306
385
|
/**
|
|
307
386
|
* Generate Docusaurus sidebar config.
|
|
308
387
|
*
|
|
@@ -316,8 +395,8 @@ declare function toFumadocsMetaJSON(spec: OpenPkg4, options?: Omit<NavOptions, "
|
|
|
316
395
|
* fs.writeFileSync('sidebars.js', sidebar)
|
|
317
396
|
* ```
|
|
318
397
|
*/
|
|
319
|
-
declare function toDocusaurusSidebarJS(spec:
|
|
320
|
-
import { OpenPkg as
|
|
398
|
+
declare function toDocusaurusSidebarJS(spec: OpenPkg6, options?: Omit<NavOptions, "format">): string;
|
|
399
|
+
import { OpenPkg as OpenPkg7, SpecExportKind as SpecExportKind4 } from "@openpkg-ts/spec";
|
|
321
400
|
interface SearchOptions {
|
|
322
401
|
/** Base URL for search result links */
|
|
323
402
|
baseUrl?: string;
|
|
@@ -361,7 +440,7 @@ interface PagefindRecord {
|
|
|
361
440
|
interface AlgoliaRecord {
|
|
362
441
|
objectID: string;
|
|
363
442
|
name: string;
|
|
364
|
-
kind:
|
|
443
|
+
kind: SpecExportKind4;
|
|
365
444
|
description?: string;
|
|
366
445
|
signature: string;
|
|
367
446
|
content: string;
|
|
@@ -381,7 +460,7 @@ interface AlgoliaRecord {
|
|
|
381
460
|
interface SearchRecord {
|
|
382
461
|
id: string;
|
|
383
462
|
name: string;
|
|
384
|
-
kind:
|
|
463
|
+
kind: SpecExportKind4;
|
|
385
464
|
signature: string;
|
|
386
465
|
description?: string;
|
|
387
466
|
content: string;
|
|
@@ -410,7 +489,7 @@ interface SearchIndex {
|
|
|
410
489
|
* // { records: [...], version: '1.0.0', packageName: 'my-lib' }
|
|
411
490
|
* ```
|
|
412
491
|
*/
|
|
413
|
-
declare function toSearchIndex2(spec:
|
|
492
|
+
declare function toSearchIndex2(spec: OpenPkg7, options?: SearchOptions): SearchIndex;
|
|
414
493
|
/**
|
|
415
494
|
* Generate Pagefind-compatible records.
|
|
416
495
|
*
|
|
@@ -426,7 +505,7 @@ declare function toSearchIndex2(spec: OpenPkg5, options?: SearchOptions): Search
|
|
|
426
505
|
* })
|
|
427
506
|
* ```
|
|
428
507
|
*/
|
|
429
|
-
declare function toPagefindRecords2(spec:
|
|
508
|
+
declare function toPagefindRecords2(spec: OpenPkg7, options?: SearchOptions): PagefindRecord[];
|
|
430
509
|
/**
|
|
431
510
|
* Generate Algolia-compatible records.
|
|
432
511
|
*
|
|
@@ -440,7 +519,7 @@ declare function toPagefindRecords2(spec: OpenPkg5, options?: SearchOptions): Pa
|
|
|
440
519
|
* // Upload to Algolia index
|
|
441
520
|
* ```
|
|
442
521
|
*/
|
|
443
|
-
declare function toAlgoliaRecords2(spec:
|
|
522
|
+
declare function toAlgoliaRecords2(spec: OpenPkg7, options?: SearchOptions): AlgoliaRecord[];
|
|
444
523
|
/**
|
|
445
524
|
* Serialize search index to JSON string.
|
|
446
525
|
*
|
|
@@ -454,36 +533,36 @@ declare function toAlgoliaRecords2(spec: OpenPkg5, options?: SearchOptions): Alg
|
|
|
454
533
|
* fs.writeFileSync('search-index.json', json)
|
|
455
534
|
* ```
|
|
456
535
|
*/
|
|
457
|
-
declare function toSearchIndexJSON(spec:
|
|
536
|
+
declare function toSearchIndexJSON(spec: OpenPkg7, options?: SearchOptions & {
|
|
458
537
|
pretty?: boolean;
|
|
459
538
|
}): string;
|
|
460
539
|
interface LoadOptions {
|
|
461
540
|
/** Path to openpkg.json file or the spec object directly */
|
|
462
|
-
input: string |
|
|
541
|
+
input: string | OpenPkg8;
|
|
463
542
|
}
|
|
464
543
|
interface DocsInstance {
|
|
465
544
|
/** The parsed OpenPkg spec */
|
|
466
|
-
spec:
|
|
545
|
+
spec: OpenPkg8;
|
|
467
546
|
/** Get an by its ID */
|
|
468
|
-
getExport(id: string):
|
|
547
|
+
getExport(id: string): SpecExport3 | undefined;
|
|
469
548
|
/** Get a type definition by its ID */
|
|
470
549
|
getType(id: string): SpecType | undefined;
|
|
471
550
|
/** Get all exports of a specific kind */
|
|
472
|
-
getExportsByKind(kind:
|
|
551
|
+
getExportsByKind(kind: SpecExportKind5): SpecExport3[];
|
|
473
552
|
/** Get all exports */
|
|
474
|
-
getAllExports():
|
|
553
|
+
getAllExports(): SpecExport3[];
|
|
475
554
|
/** Get all type definitions */
|
|
476
555
|
getAllTypes(): SpecType[];
|
|
477
556
|
/** Get exports by JSDoc tag (e.g., '@beta', '@internal') */
|
|
478
|
-
getExportsByTag(tagName: string):
|
|
557
|
+
getExportsByTag(tagName: string): SpecExport3[];
|
|
479
558
|
/** Search exports by name or description */
|
|
480
|
-
search(query: string):
|
|
559
|
+
search(query: string): SpecExport3[];
|
|
481
560
|
/** Get exports belonging to a specific module/namespace */
|
|
482
|
-
getModule(moduleName: string):
|
|
561
|
+
getModule(moduleName: string): SpecExport3[];
|
|
483
562
|
/** Get deprecated exports */
|
|
484
|
-
getDeprecated():
|
|
563
|
+
getDeprecated(): SpecExport3[];
|
|
485
564
|
/** Get exports grouped by kind */
|
|
486
|
-
groupByKind(): Record<
|
|
565
|
+
groupByKind(): Record<SpecExportKind5, SpecExport3[]>;
|
|
487
566
|
/** Render spec or single to MDX */
|
|
488
567
|
toMarkdown(options?: ExportMarkdownOptions): string;
|
|
489
568
|
/** Render spec or single to HTML */
|
|
@@ -511,7 +590,7 @@ interface DocsInstance {
|
|
|
511
590
|
* const docs = loadSpec(spec)
|
|
512
591
|
* ```
|
|
513
592
|
*/
|
|
514
|
-
declare function loadSpec(spec:
|
|
593
|
+
declare function loadSpec(spec: OpenPkg8): DocsInstance;
|
|
515
594
|
/**
|
|
516
595
|
* Creates a docs instance for querying and rendering API documentation.
|
|
517
596
|
*
|
|
@@ -533,8 +612,8 @@ declare function loadSpec(spec: OpenPkg6): DocsInstance;
|
|
|
533
612
|
* docs.search('hook')
|
|
534
613
|
* ```
|
|
535
614
|
*/
|
|
536
|
-
declare function createDocs(input: string |
|
|
537
|
-
import { OpenPkg as
|
|
615
|
+
declare function createDocs(input: string | OpenPkg8): DocsInstance;
|
|
616
|
+
import { OpenPkg as OpenPkg9, SpecExport as SpecExport4, SpecMember as SpecMember2, SpecSchema, SpecSignature, SpecType as SpecType2, SpecTypeParameter } from "@openpkg-ts/spec";
|
|
538
617
|
interface FormatSchemaOptions {
|
|
539
618
|
/** Include package attribution for external types */
|
|
540
619
|
includePackage?: boolean;
|
|
@@ -613,7 +692,7 @@ declare function formatReturnType(sig?: SpecSignature): string;
|
|
|
613
692
|
* // 'class Logger extends EventEmitter'
|
|
614
693
|
* ```
|
|
615
694
|
*/
|
|
616
|
-
declare function buildSignatureString(exp:
|
|
695
|
+
declare function buildSignatureString(exp: SpecExport4, sigIndex?: number): string;
|
|
617
696
|
/**
|
|
618
697
|
* Resolve a type reference to its definition.
|
|
619
698
|
*
|
|
@@ -627,7 +706,7 @@ declare function buildSignatureString(exp: SpecExport3, sigIndex?: number): stri
|
|
|
627
706
|
* // { id: 'User', name: 'User', kind: 'interface', ... }
|
|
628
707
|
* ```
|
|
629
708
|
*/
|
|
630
|
-
declare function resolveTypeRef(ref: string, spec:
|
|
709
|
+
declare function resolveTypeRef(ref: string, spec: OpenPkg9): SpecType2 | undefined;
|
|
631
710
|
/**
|
|
632
711
|
* Check if a member is a method (has signatures).
|
|
633
712
|
*
|
|
@@ -742,7 +821,7 @@ declare function formatConditionalType(condType: SpecConditionalType): string;
|
|
|
742
821
|
* ```
|
|
743
822
|
*/
|
|
744
823
|
declare function formatMappedType(mappedType: SpecMappedType): string;
|
|
745
|
-
import { SpecExport as
|
|
824
|
+
import { SpecExport as SpecExport5, SpecType as SpecType3 } from "@openpkg-ts/spec";
|
|
746
825
|
interface GetExportOptions {
|
|
747
826
|
/** Entry point file path */
|
|
748
827
|
entryFile: string;
|
|
@@ -757,7 +836,7 @@ interface GetExportOptions {
|
|
|
757
836
|
}
|
|
758
837
|
interface GetExportResult {
|
|
759
838
|
/** The spec, or null if not found */
|
|
760
|
-
export:
|
|
839
|
+
export: SpecExport5 | null;
|
|
761
840
|
/** Related types referenced by the */
|
|
762
841
|
types: SpecType3[];
|
|
763
842
|
/** Errors encountered */
|
|
@@ -798,7 +877,7 @@ interface ListExportsResult {
|
|
|
798
877
|
* List all exports from a TypeScript entry point
|
|
799
878
|
*/
|
|
800
879
|
declare function listExports(options: ListExportsOptions): Promise<ListExportsResult>;
|
|
801
|
-
import { OpenPkg as
|
|
880
|
+
import { OpenPkg as OpenPkg10 } from "@openpkg-ts/spec";
|
|
802
881
|
interface ExtractOptions {
|
|
803
882
|
entryFile: string;
|
|
804
883
|
baseDir?: string;
|
|
@@ -821,7 +900,7 @@ interface ExtractOptions {
|
|
|
821
900
|
isDtsSource?: boolean;
|
|
822
901
|
}
|
|
823
902
|
interface ExtractResult {
|
|
824
|
-
spec:
|
|
903
|
+
spec: OpenPkg10;
|
|
825
904
|
diagnostics: Diagnostic[];
|
|
826
905
|
forgottenExports?: ForgottenExport[];
|
|
827
906
|
/** Metadata about runtime schema extraction (when schemaExtraction: 'hybrid') */
|
|
@@ -1227,24 +1306,24 @@ declare const arktypeAdapter: SchemaAdapter;
|
|
|
1227
1306
|
declare const typeboxAdapter: SchemaAdapter;
|
|
1228
1307
|
declare const valibotAdapter: SchemaAdapter;
|
|
1229
1308
|
declare const zodAdapter: SchemaAdapter;
|
|
1230
|
-
import { SpecExport as SpecExport6 } from "@openpkg-ts/spec";
|
|
1231
|
-
import ts6 from "typescript";
|
|
1232
|
-
declare function serializeClass(node: ts6.ClassDeclaration, ctx: SerializerContext): SpecExport6 | null;
|
|
1233
1309
|
import { SpecExport as SpecExport7 } from "@openpkg-ts/spec";
|
|
1234
|
-
import
|
|
1235
|
-
declare function
|
|
1310
|
+
import ts6 from "typescript";
|
|
1311
|
+
declare function serializeClass(node: ts6.ClassDeclaration, ctx: SerializerContext): SpecExport7 | null;
|
|
1236
1312
|
import { SpecExport as SpecExport8 } from "@openpkg-ts/spec";
|
|
1237
|
-
import
|
|
1238
|
-
declare function
|
|
1313
|
+
import ts7 from "typescript";
|
|
1314
|
+
declare function serializeEnum(node: ts7.EnumDeclaration, ctx: SerializerContext): SpecExport8 | null;
|
|
1239
1315
|
import { SpecExport as SpecExport9 } from "@openpkg-ts/spec";
|
|
1240
|
-
import
|
|
1241
|
-
declare function
|
|
1316
|
+
import ts8 from "typescript";
|
|
1317
|
+
declare function serializeFunctionExport(node: ts8.FunctionDeclaration | ts8.ArrowFunction, ctx: SerializerContext): SpecExport9 | null;
|
|
1242
1318
|
import { SpecExport as SpecExport10 } from "@openpkg-ts/spec";
|
|
1243
|
-
import
|
|
1244
|
-
declare function
|
|
1319
|
+
import ts9 from "typescript";
|
|
1320
|
+
declare function serializeInterface(node: ts9.InterfaceDeclaration, ctx: SerializerContext): SpecExport10 | null;
|
|
1245
1321
|
import { SpecExport as SpecExport11 } from "@openpkg-ts/spec";
|
|
1322
|
+
import ts10 from "typescript";
|
|
1323
|
+
declare function serializeTypeAlias(node: ts10.TypeAliasDeclaration, ctx: SerializerContext): SpecExport11 | null;
|
|
1324
|
+
import { SpecExport as SpecExport12 } from "@openpkg-ts/spec";
|
|
1246
1325
|
import ts11 from "typescript";
|
|
1247
|
-
declare function serializeVariable(node: ts11.VariableDeclaration, statement: ts11.VariableStatement, ctx: SerializerContext):
|
|
1326
|
+
declare function serializeVariable(node: ts11.VariableDeclaration, statement: ts11.VariableStatement, ctx: SerializerContext): SpecExport12 | null;
|
|
1248
1327
|
import { SpecSignatureParameter } from "@openpkg-ts/spec";
|
|
1249
1328
|
import ts12 from "typescript";
|
|
1250
1329
|
declare function extractParameters(signature: ts12.Signature, ctx: SerializerContext): SpecSignatureParameter[];
|
|
@@ -1321,7 +1400,7 @@ declare function deduplicateSchemas(schemas: SpecSchema2[]): SpecSchema2[];
|
|
|
1321
1400
|
* A valid discriminator has a unique literal value in each union member.
|
|
1322
1401
|
*/
|
|
1323
1402
|
declare function findDiscriminatorProperty(unionTypes: ts13.Type[], checker: ts13.TypeChecker): string | undefined;
|
|
1324
|
-
import { SpecExport as
|
|
1403
|
+
import { SpecExport as SpecExport13, SpecMember as SpecMember3, SpecSchema as SpecSchema3, SpecType as SpecType5 } from "@openpkg-ts/spec";
|
|
1325
1404
|
/**
|
|
1326
1405
|
* Options for schema normalization
|
|
1327
1406
|
*/
|
|
@@ -1352,7 +1431,7 @@ declare function normalizeSchema(schema: SpecSchema3, options?: NormalizeOptions
|
|
|
1352
1431
|
* 2. Normalize member schemas
|
|
1353
1432
|
* 3. Generate a JSON Schema from members if members exist (populates `schema` field)
|
|
1354
1433
|
*/
|
|
1355
|
-
declare function normalizeExport(exp:
|
|
1434
|
+
declare function normalizeExport(exp: SpecExport13, options?: NormalizeOptions): SpecExport13;
|
|
1356
1435
|
/**
|
|
1357
1436
|
* Normalize a SpecType, normalizing its schema and nested schemas.
|
|
1358
1437
|
*
|
|
@@ -1386,4 +1465,4 @@ declare function normalizeMembers(members: SpecMember3[], options?: NormalizeOpt
|
|
|
1386
1465
|
import ts14 from "typescript";
|
|
1387
1466
|
declare function isExported(node: ts14.Node): boolean;
|
|
1388
1467
|
declare function getNodeName(node: ts14.Node): string | undefined;
|
|
1389
|
-
export { zodAdapter, withDescription, valibotAdapter, typeboxAdapter, toSearchIndexJSON, toSearchIndex2 as toSearchIndex, toPagefindRecords2 as toPagefindRecords, toNavigation2 as toNavigation, toMarkdown2 as toMarkdown, toJSONString, toJSON2 as toJSON, toHTML2 as toHTML, toFumadocsMetaJSON, toDocusaurusSidebarJS, toAlgoliaRecords2 as toAlgoliaRecords, sortByName, serializeVariable, serializeTypeAlias, serializeInterface, serializeFunctionExport, serializeEnum, serializeClass, schemasAreEqual, schemaIsAny, resolveTypeRef, resolveExportTarget, resolveCompiledPath, registerReferencedTypes, registerAdapter, recommendSemverBump, normalizeType, normalizeSchema, normalizeMembers, normalizeExport, loadSpec, listExports, isTypeReference, isTypeOnlyExport, isSymbolDeprecated, isStandardJSONSchema, isSchemaType, isPureRefSchema, isProperty, isPrimitiveName, isMethod, isExported, isBuiltinGeneric, isAnonymous, groupByVisibility, getTypeOrigin, getSourceLocation, getProperties, getParamDescription, getNonNullableType, getNodeName, getMethods, getMemberBadges, getJSDocComment, getExport2 as getExport, toMarkdown2 as generateDocs, formatTypeParameters, formatSchema, formatReturnType, formatParameters, formatMappedType, formatConditionalType, formatBadges, findDiscriminatorProperty, findAdapter, extractTypeParameters, extractStandardSchemasFromTs, extractStandardSchemasFromProject, extractStandardSchemas, extractSpec, extractSchemaType, extractParameters, extract, exportToMarkdown, ensureNonEmptySchema, diffSpec2 as diffSpecs, diffSpec, detectTsRuntime, deduplicateSchemas, createProgram, createDocs, categorizeBreakingChanges, calculateNextVersion, buildSignatureString, buildSchema, arktypeAdapter, TypeRegistry, TypeReference2 as TypeReference, TsRuntime, StandardSchemaExtractionResult, StandardSchemaExtractionOutput, StandardJSONSchemaV1, StandardJSONSchemaTarget, StandardJSONSchemaOptions, SpecMappedType, SpecDiff, SpecConditionalType, SimplifiedSpec, SimplifiedSignature, SimplifiedReturn, SimplifiedParameter, SimplifiedMember, SimplifiedExport, SimplifiedExample, SerializerContext, SemverRecommendation, SemverBump, SearchRecord, SearchOptions, SearchIndex, SchemaExtractionResult, SchemaAdapter, ProjectExtractionOutput, ProjectExtractionInfo, ProgramResult, ProgramOptions, PagefindRecord, NormalizeOptions, NavOptions, NavItem, NavGroup, NavFormat, MemberChangeInfo, MarkdownOptions, LoadOptions, ListExportsResult, ListExportsOptions, JSONSchema, JSONOptions, HTMLOptions, GroupBy, GetExportResult, GetExportOptions, GenericNav, FumadocsMetaItem, FumadocsMeta, FormatSchemaOptions, ForgottenExport, ExtractStandardSchemasOptions, ExtractResult, ExtractOptions, ExtractFromProjectOptions, ExportVerification, ExportTracker, ExportMarkdownOptions, ExportItem, DocusaurusSidebarItem, DocusaurusSidebar, DocsInstance, Diagnostic, CategorizedBreaking, BreakingSeverity, BUILTIN_TYPE_SCHEMAS, AlgoliaRecord, ARRAY_PROTOTYPE_METHODS };
|
|
1468
|
+
export { zodAdapter, withDescription, valibotAdapter, typeboxAdapter, toSearchIndexJSON, toSearchIndex2 as toSearchIndex, toPagefindRecords2 as toPagefindRecords, toNavigation2 as toNavigation, toMarkdown2 as toMarkdown, toJSONString, toJSON2 as toJSON, toHTML2 as toHTML, toFumadocsMetaJSON, toDocusaurusSidebarJS, toAlgoliaRecords2 as toAlgoliaRecords, sortByName, serializeVariable, serializeTypeAlias, serializeInterface, serializeFunctionExport, serializeEnum, serializeClass, schemasAreEqual, schemaIsAny, resolveTypeRef, resolveExportTarget, resolveCompiledPath, registerReferencedTypes, registerAdapter, recommendSemverBump, normalizeType, normalizeSchema, normalizeMembers, normalizeExport, loadSpec, listExports, isTypeReference, isTypeOnlyExport, isSymbolDeprecated, isStandardJSONSchema, isSchemaType, isPureRefSchema, isProperty, isPrimitiveName, isMethod, isExported, isBuiltinGeneric, isAnonymous, hasDeprecatedTag, groupByVisibility, getTypeOrigin, getSourceLocation, getProperties, getParamDescription, getNonNullableType, getNodeName, getMethods, getMemberBadges, getJSDocComment, getExport2 as getExport, getDeprecationMessage, toMarkdown2 as generateDocs, formatTypeParameters, formatSchema, formatReturnType, formatParameters, formatMappedType, formatConditionalType, formatBadges, findMissingParamDocs, findDiscriminatorProperty, findAdapter, filterSpec, extractTypeParameters, extractStandardSchemasFromTs, extractStandardSchemasFromProject, extractStandardSchemas, extractSpec, extractSchemaType, extractParameters, extract, exportToMarkdown, ensureNonEmptySchema, diffSpec2 as diffSpecs, diffSpec, detectTsRuntime, deduplicateSchemas, createProgram, createDocs, categorizeBreakingChanges, calculateNextVersion, buildSignatureString, buildSchema, arktypeAdapter, analyzeSpec, TypeRegistry, TypeReference2 as TypeReference, TsRuntime, StandardSchemaExtractionResult, StandardSchemaExtractionOutput, StandardJSONSchemaV1, StandardJSONSchemaTarget, StandardJSONSchemaOptions, SpecMappedType, SpecDiff, SpecDiagnostics, SpecConditionalType, SimplifiedSpec, SimplifiedSignature, SimplifiedReturn, SimplifiedParameter, SimplifiedMember, SimplifiedExport, SimplifiedExample, SerializerContext, SemverRecommendation, SemverBump, SearchRecord, SearchOptions, SearchIndex, SchemaExtractionResult, SchemaAdapter, ProjectExtractionOutput, ProjectExtractionInfo, ProgramResult, ProgramOptions, PagefindRecord, NormalizeOptions, NavOptions, NavItem, NavGroup, NavFormat, MemberChangeInfo, MarkdownOptions, LoadOptions, ListExportsResult, ListExportsOptions, JSONSchema, JSONOptions, HTMLOptions, GroupBy, GetExportResult, GetExportOptions, GenericNav, FumadocsMetaItem, FumadocsMeta, FormatSchemaOptions, ForgottenExport, FilterResult, FilterCriteria, ExtractStandardSchemasOptions, ExtractResult, ExtractOptions, ExtractFromProjectOptions, ExportVerification, ExportTracker, ExportMarkdownOptions, ExportItem, DocusaurusSidebarItem, DocusaurusSidebar, DocsInstance, DiagnosticItem, Diagnostic, CategorizedBreaking, BreakingSeverity, BUILTIN_TYPE_SCHEMAS, AlgoliaRecord, ARRAY_PROTOTYPE_METHODS };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,72 @@
|
|
|
1
|
+
// src/primitives/filter.ts
|
|
2
|
+
function matchesExport(exp, criteria) {
|
|
3
|
+
if (criteria.kinds && criteria.kinds.length > 0) {
|
|
4
|
+
if (!criteria.kinds.includes(exp.kind))
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
if (criteria.names && criteria.names.length > 0) {
|
|
8
|
+
if (!criteria.names.includes(exp.name))
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
if (criteria.ids && criteria.ids.length > 0) {
|
|
12
|
+
if (!criteria.ids.includes(exp.id))
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
if (criteria.tags && criteria.tags.length > 0) {
|
|
16
|
+
const expTags = exp.tags?.map((t) => t.name) ?? [];
|
|
17
|
+
if (!criteria.tags.some((tag) => expTags.includes(tag)))
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (criteria.deprecated !== undefined) {
|
|
21
|
+
if ((exp.deprecated ?? false) !== criteria.deprecated)
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (criteria.hasDescription !== undefined) {
|
|
25
|
+
const has = Boolean(exp.description && exp.description.trim().length > 0);
|
|
26
|
+
if (has !== criteria.hasDescription)
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
if (criteria.search) {
|
|
30
|
+
const term = criteria.search.toLowerCase();
|
|
31
|
+
const nameMatch = exp.name.toLowerCase().includes(term);
|
|
32
|
+
const descMatch = exp.description?.toLowerCase().includes(term) ?? false;
|
|
33
|
+
if (!nameMatch && !descMatch)
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (criteria.module) {
|
|
37
|
+
const file = exp.source?.file ?? "";
|
|
38
|
+
if (!file.includes(criteria.module))
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
function filterSpec(spec, criteria) {
|
|
44
|
+
const total = spec.exports.length;
|
|
45
|
+
const isEmpty = Object.keys(criteria).length === 0;
|
|
46
|
+
if (isEmpty) {
|
|
47
|
+
return {
|
|
48
|
+
spec: { ...spec, exports: [...spec.exports], types: spec.types ? [...spec.types] : undefined },
|
|
49
|
+
matched: total,
|
|
50
|
+
total
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const matched = [];
|
|
54
|
+
for (const exp of spec.exports) {
|
|
55
|
+
if (matchesExport(exp, criteria)) {
|
|
56
|
+
matched.push(exp);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const newSpec = {
|
|
60
|
+
...spec,
|
|
61
|
+
exports: matched,
|
|
62
|
+
types: spec.types ? [...spec.types] : undefined
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
spec: newSpec,
|
|
66
|
+
matched: matched.length,
|
|
67
|
+
total
|
|
68
|
+
};
|
|
69
|
+
}
|
|
1
70
|
// src/primitives/diff.ts
|
|
2
71
|
import {
|
|
3
72
|
calculateNextVersion,
|
|
@@ -6,6 +75,82 @@ import {
|
|
|
6
75
|
diffSpec as diffSpec2,
|
|
7
76
|
recommendSemverBump
|
|
8
77
|
} from "@openpkg-ts/spec";
|
|
78
|
+
// src/core/diagnostics.ts
|
|
79
|
+
function hasDeprecatedTag(exp) {
|
|
80
|
+
if (exp.deprecated === true)
|
|
81
|
+
return true;
|
|
82
|
+
return exp.tags?.some((t) => t.name === "deprecated" || t.name === "@deprecated") ?? false;
|
|
83
|
+
}
|
|
84
|
+
function getDeprecationMessage(exp) {
|
|
85
|
+
const tag = exp.tags?.find((t) => t.name === "deprecated" || t.name === "@deprecated");
|
|
86
|
+
if (tag && tag.text.trim()) {
|
|
87
|
+
return tag.text.trim();
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
function findMissingParamDocs(exp) {
|
|
92
|
+
const missing = [];
|
|
93
|
+
for (const sig of exp.signatures ?? []) {
|
|
94
|
+
for (const param of sig.parameters ?? []) {
|
|
95
|
+
if (!param.description?.trim()) {
|
|
96
|
+
missing.push(param.name);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return missing;
|
|
101
|
+
}
|
|
102
|
+
function checkMemberDescriptions(exp, members) {
|
|
103
|
+
const items = [];
|
|
104
|
+
for (const member of members) {
|
|
105
|
+
if (!member.description?.trim() && member.name) {
|
|
106
|
+
items.push({
|
|
107
|
+
exportId: exp.id,
|
|
108
|
+
exportName: exp.name,
|
|
109
|
+
issue: "member missing description",
|
|
110
|
+
member: member.name
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return items;
|
|
115
|
+
}
|
|
116
|
+
function analyzeSpec(spec) {
|
|
117
|
+
const missingDescriptions = [];
|
|
118
|
+
const deprecatedNoReason = [];
|
|
119
|
+
const missingParamDocs = [];
|
|
120
|
+
for (const exp of spec.exports) {
|
|
121
|
+
if (!exp.description?.trim()) {
|
|
122
|
+
missingDescriptions.push({
|
|
123
|
+
exportId: exp.id,
|
|
124
|
+
exportName: exp.name,
|
|
125
|
+
issue: "missing description"
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (exp.members) {
|
|
129
|
+
missingDescriptions.push(...checkMemberDescriptions(exp, exp.members));
|
|
130
|
+
}
|
|
131
|
+
if (hasDeprecatedTag(exp) && !getDeprecationMessage(exp)) {
|
|
132
|
+
deprecatedNoReason.push({
|
|
133
|
+
exportId: exp.id,
|
|
134
|
+
exportName: exp.name,
|
|
135
|
+
issue: "deprecated without reason"
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
const missingParams = findMissingParamDocs(exp);
|
|
139
|
+
for (const param of missingParams) {
|
|
140
|
+
missingParamDocs.push({
|
|
141
|
+
exportId: exp.id,
|
|
142
|
+
exportName: exp.name,
|
|
143
|
+
issue: "param missing description",
|
|
144
|
+
param
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
missingDescriptions,
|
|
150
|
+
deprecatedNoReason,
|
|
151
|
+
missingParamDocs
|
|
152
|
+
};
|
|
153
|
+
}
|
|
9
154
|
// src/core/format.ts
|
|
10
155
|
function getMemberBadges(member) {
|
|
11
156
|
const badges = [];
|
|
@@ -519,10 +664,15 @@ function toHTML(spec, options = {}) {
|
|
|
519
664
|
</body>
|
|
520
665
|
</html>`;
|
|
521
666
|
}
|
|
667
|
+
let specExports = spec.exports;
|
|
668
|
+
if (options.exports?.length) {
|
|
669
|
+
const ids = new Set(options.exports);
|
|
670
|
+
specExports = spec.exports.filter((e) => ids.has(e.name) || ids.has(e.id));
|
|
671
|
+
}
|
|
522
672
|
const title = options.title || `${spec.meta.name} API Reference`;
|
|
523
673
|
const description = spec.meta.description ? `<p>${escapeHTML(spec.meta.description)}</p>` : "";
|
|
524
674
|
const byKind = {};
|
|
525
|
-
for (const exp of
|
|
675
|
+
for (const exp of specExports) {
|
|
526
676
|
if (!byKind[exp.kind])
|
|
527
677
|
byKind[exp.kind] = [];
|
|
528
678
|
byKind[exp.kind].push(exp);
|
|
@@ -665,7 +815,12 @@ function toJSON(spec, options = {}) {
|
|
|
665
815
|
}
|
|
666
816
|
return simplifyExport(exp);
|
|
667
817
|
}
|
|
668
|
-
|
|
818
|
+
let specExports = spec.exports;
|
|
819
|
+
if (options.exports?.length) {
|
|
820
|
+
const ids = new Set(options.exports);
|
|
821
|
+
specExports = spec.exports.filter((e) => ids.has(e.name) || ids.has(e.id));
|
|
822
|
+
}
|
|
823
|
+
const exports = specExports.map(simplifyExport);
|
|
669
824
|
const byKind = {};
|
|
670
825
|
for (const exp of exports) {
|
|
671
826
|
if (!byKind[exp.kind])
|
|
@@ -1018,6 +1173,13 @@ function toMarkdown(spec, options = {}) {
|
|
|
1018
1173
|
}
|
|
1019
1174
|
return exportToMarkdown(exp, options);
|
|
1020
1175
|
}
|
|
1176
|
+
let specExports = spec.exports;
|
|
1177
|
+
if (options.exports?.length) {
|
|
1178
|
+
const ids = new Set(options.exports);
|
|
1179
|
+
specExports = spec.exports.filter((e) => ids.has(e.name) || ids.has(e.id));
|
|
1180
|
+
if (specExports.length === 0)
|
|
1181
|
+
return "";
|
|
1182
|
+
}
|
|
1021
1183
|
const parts = [];
|
|
1022
1184
|
if (options.frontmatter !== false) {
|
|
1023
1185
|
const frontmatter = {
|
|
@@ -1044,7 +1206,7 @@ function toMarkdown(spec, options = {}) {
|
|
|
1044
1206
|
parts.push("");
|
|
1045
1207
|
}
|
|
1046
1208
|
const byKind = {};
|
|
1047
|
-
for (const exp of
|
|
1209
|
+
for (const exp of specExports) {
|
|
1048
1210
|
if (!byKind[exp.kind])
|
|
1049
1211
|
byKind[exp.kind] = [];
|
|
1050
1212
|
byKind[exp.kind].push(exp);
|
|
@@ -4593,6 +4755,15 @@ function extractExportItem(symbol, checker, entryFile, entrySourceFile) {
|
|
|
4593
4755
|
const declaration = targetSymbol.valueDeclaration || declarations.find((d) => d.kind !== ts12.SyntaxKind.ExportSpecifier) || declarations[0];
|
|
4594
4756
|
if (!declaration)
|
|
4595
4757
|
return null;
|
|
4758
|
+
if (ts12.isSourceFile(declaration)) {
|
|
4759
|
+
return {
|
|
4760
|
+
name,
|
|
4761
|
+
kind: "namespace",
|
|
4762
|
+
file: path2.relative(path2.dirname(entryFile), declaration.fileName),
|
|
4763
|
+
line: 1,
|
|
4764
|
+
reexport: true
|
|
4765
|
+
};
|
|
4766
|
+
}
|
|
4596
4767
|
const kind = getExportKind(declaration, checker.getTypeAtLocation(declaration));
|
|
4597
4768
|
const sourceFile = declaration.getSourceFile();
|
|
4598
4769
|
const { line } = sourceFile.getLineAndCharacterOfPosition(declaration.getStart());
|
|
@@ -4610,6 +4781,9 @@ function extractExportItem(symbol, checker, entryFile, entrySourceFile) {
|
|
|
4610
4781
|
};
|
|
4611
4782
|
}
|
|
4612
4783
|
function getExportKind(declaration, type) {
|
|
4784
|
+
if (ts12.isSourceFile(declaration)) {
|
|
4785
|
+
return "namespace";
|
|
4786
|
+
}
|
|
4613
4787
|
if (ts12.isFunctionDeclaration(declaration) || ts12.isFunctionExpression(declaration)) {
|
|
4614
4788
|
return "function";
|
|
4615
4789
|
}
|
|
@@ -5987,6 +6161,7 @@ export {
|
|
|
5987
6161
|
isExported,
|
|
5988
6162
|
isBuiltinGeneric,
|
|
5989
6163
|
isAnonymous,
|
|
6164
|
+
hasDeprecatedTag,
|
|
5990
6165
|
groupByVisibility,
|
|
5991
6166
|
getTypeOrigin,
|
|
5992
6167
|
getSourceLocation,
|
|
@@ -5998,6 +6173,7 @@ export {
|
|
|
5998
6173
|
getMemberBadges,
|
|
5999
6174
|
getJSDocComment,
|
|
6000
6175
|
getExport,
|
|
6176
|
+
getDeprecationMessage,
|
|
6001
6177
|
toMarkdown as generateDocs,
|
|
6002
6178
|
formatTypeParameters,
|
|
6003
6179
|
formatSchema,
|
|
@@ -6006,8 +6182,10 @@ export {
|
|
|
6006
6182
|
formatMappedType,
|
|
6007
6183
|
formatConditionalType,
|
|
6008
6184
|
formatBadges,
|
|
6185
|
+
findMissingParamDocs,
|
|
6009
6186
|
findDiscriminatorProperty,
|
|
6010
6187
|
findAdapter,
|
|
6188
|
+
filterSpec,
|
|
6011
6189
|
extractTypeParameters,
|
|
6012
6190
|
extractStandardSchemasFromTs,
|
|
6013
6191
|
extractStandardSchemasFromProject,
|
|
@@ -6029,6 +6207,7 @@ export {
|
|
|
6029
6207
|
buildSignatureString,
|
|
6030
6208
|
buildSchema,
|
|
6031
6209
|
arktypeAdapter,
|
|
6210
|
+
analyzeSpec,
|
|
6032
6211
|
TypeRegistry,
|
|
6033
6212
|
BUILTIN_TYPE_SCHEMAS,
|
|
6034
6213
|
ARRAY_PROTOTYPE_METHODS
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openpkg-ts/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "TypeScript API extraction SDK - programmatic primitives for OpenPkg specs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openpkg",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"test": "bun test"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@openpkg-ts/spec": "^0.
|
|
41
|
+
"@openpkg-ts/spec": "^0.31.0",
|
|
42
42
|
"typescript": "^5.0.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|