@openpkg-ts/sdk 0.34.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.d.ts CHANGED
@@ -1,328 +1,220 @@
1
- import { OpenPkg, SpecExport, SpecMember, SpecSchema, SpecSignature, SpecType, SpecTypeParameter } from "@openpkg-ts/spec";
2
- interface FormatSchemaOptions {
3
- /** Include package attribution for external types */
4
- includePackage?: boolean;
5
- /** Collapse unions with more than N members (default: no collapse) */
6
- collapseUnionThreshold?: number;
1
+ import { OpenPkg, SpecExport } from "@openpkg-ts/spec";
2
+ interface DiagnosticItem {
3
+ exportId: string;
4
+ exportName: string;
5
+ issue: string;
6
+ /** Member name if issue is on a member */
7
+ member?: string;
8
+ /** Parameter name if issue is on a parameter */
9
+ param?: string;
10
+ }
11
+ interface SpecDiagnostics {
12
+ /** Exports/members without descriptions */
13
+ missingDescriptions: DiagnosticItem[];
14
+ /** Exports marked @deprecated but no reason provided */
15
+ deprecatedNoReason: DiagnosticItem[];
16
+ /** Function params without descriptions in JSDoc */
17
+ missingParamDocs: DiagnosticItem[];
7
18
  }
8
19
  /**
9
- * Format a schema to a human-readable type string.
10
- *
11
- * @param schema - The schema to format
12
- * @param options - Formatting options
13
- * @returns Formatted type string
14
- *
15
- * @example
16
- * ```ts
17
- * formatSchema({ type: 'string' }) // 'string'
18
- * formatSchema({ $ref: '#/types/User' }) // 'User'
19
- * formatSchema({ anyOf: [{ type: 'string' }, { type: 'number' }] }) // 'string | number'
20
- * formatSchema({ type: 'integer', 'x-ts-type': 'bigint' }) // 'bigint'
21
- * formatSchema({ 'x-ts-type': 'Response', 'x-ts-package': 'express' }, { includePackage: true }) // 'Response (from express)'
22
- * ```
23
- */
24
- declare function formatSchema(schema: SpecSchema | undefined, options?: FormatSchemaOptions): string;
25
- /**
26
- * Format type parameters to a string like `<T, U extends string>`.
27
- *
28
- * @param typeParams - Array of type parameters
29
- * @returns Formatted type parameters string or empty string
30
- *
31
- * @example
32
- * ```ts
33
- * formatTypeParameters([{ name: 'T' }]) // '<T>'
34
- * formatTypeParameters([{ name: 'T', constraint: 'object' }]) // '<T extends object>'
35
- * formatTypeParameters([{ name: 'T', default: 'unknown' }]) // '<T = unknown>'
36
- * formatTypeParameters([{ name: 'T', variance: 'in' }]) // '<in T>'
37
- * ```
38
- */
39
- declare function formatTypeParameters(typeParams?: SpecTypeParameter[]): string;
40
- /**
41
- * Format function parameters to a string like `(a: string, b?: number)`.
42
- *
43
- * @param sig - The signature containing parameters
44
- * @returns Formatted parameters string
45
- *
46
- * @example
47
- * ```ts
48
- * formatParameters({ parameters: [{ name: 'id', schema: { type: 'string' } }] })
49
- * // '(id: string)'
50
- * ```
51
- */
52
- declare function formatParameters(sig?: SpecSignature): string;
53
- /**
54
- * Format return type from signature.
55
- *
56
- * @param sig - The signature containing return type
57
- * @returns Formatted return type string
58
- *
59
- * @example
60
- * ```ts
61
- * formatReturnType({ returns: { schema: { type: 'Promise', items: { type: 'string' } } } })
62
- * // 'Promise<string>'
63
- * ```
64
- */
65
- declare function formatReturnType(sig?: SpecSignature): string;
66
- /**
67
- * Build a full signature string for an export.
68
- *
69
- * @param exp - The to build a signature for
70
- * @param sigIndex - Index of signature to use for overloaded functions
71
- * @returns Complete signature string
72
- *
73
- * @example
74
- * ```ts
75
- * buildSignatureString({ kind: 'function', name: 'greet', signatures: [...] })
76
- * // 'function greet(name: string): string'
77
- *
78
- * buildSignatureString({ kind: 'class', name: 'Logger', extends: 'EventEmitter' })
79
- * // 'class Logger extends EventEmitter'
80
- * ```
81
- */
82
- declare function buildSignatureString(exp: SpecExport, sigIndex?: number): string;
83
- /**
84
- * Resolve a type reference to its definition.
85
- *
86
- * @param ref - Type reference string (e.g., '#/types/User')
87
- * @param spec - The OpenPkg spec containing type definitions
88
- * @returns The resolved type definition or undefined
89
- *
90
- * @example
91
- * ```ts
92
- * resolveTypeRef('#/types/User', spec)
93
- * // { id: 'User', name: 'User', kind: 'interface', ... }
94
- * ```
95
- */
96
- declare function resolveTypeRef(ref: string, spec: OpenPkg): SpecType | undefined;
97
- /**
98
- * Check if a member is a method (has signatures).
99
- *
100
- * @param member - The member to check
101
- * @returns True if the member is a method
102
- *
103
- * @example
104
- * ```ts
105
- * isMethod({ name: 'foo', signatures: [{ parameters: [] }] }) // true
106
- * isMethod({ name: 'bar', schema: { type: 'string' } }) // false
107
- * ```
20
+ * Check if has @deprecated tag.
108
21
  */
109
- declare function isMethod(member: SpecMember): boolean;
22
+ declare function hasDeprecatedTag(exp: SpecExport): boolean;
110
23
  /**
111
- * Check if a member is a property (no signatures).
112
- *
113
- * @param member - The member to check
114
- * @returns True if the member is a property
24
+ * Get deprecation message from @deprecated tag.
25
+ * Returns undefined if no reason provided.
115
26
  */
116
- declare function isProperty(member: SpecMember): boolean;
27
+ declare function getDeprecationMessage(exp: SpecExport): string | undefined;
117
28
  /**
118
- * Get methods from members list.
119
- *
120
- * @param members - Array of members to filter
121
- * @returns Array of method members
29
+ * Find params without descriptions in JSDoc.
122
30
  */
123
- declare function getMethods(members?: SpecMember[]): SpecMember[];
31
+ declare function findMissingParamDocs(exp: SpecExport): string[];
124
32
  /**
125
- * Get properties from members list.
126
- *
127
- * @param members - Array of members to filter
128
- * @returns Array of property members
33
+ * Analyze a spec for quality issues.
129
34
  */
130
- declare function getProperties(members?: SpecMember[]): SpecMember[];
35
+ declare function analyzeSpec(spec: OpenPkg): SpecDiagnostics;
36
+ import { SpecMember } from "@openpkg-ts/spec";
131
37
  /**
132
- * Group members by visibility (public, protected, private).
133
- *
134
- * @param members - Array of members to group
135
- * @returns Object with public, protected, and private arrays
136
- *
137
- * @example
138
- * ```ts
139
- * const groups = groupByVisibility(classExport.members)
140
- * groups.public // [{ name: 'foo', visibility: 'public' }]
141
- * groups.private // [{ name: 'bar', visibility: 'private' }]
142
- * ```
38
+ * Extract badge strings from a member's visibility and flags.
39
+ * Handles: visibility (if not public), static, readonly, async, abstract
143
40
  */
144
- declare function groupByVisibility(members?: SpecMember[]): {
145
- public: SpecMember[];
146
- protected: SpecMember[];
147
- private: SpecMember[];
148
- };
41
+ declare function getMemberBadges(member: SpecMember): string[];
149
42
  /**
150
- * Sort exports alphabetically by name.
151
- *
152
- * @param items - Array of items with a name property
153
- * @returns New sorted array
43
+ * Format badges array into a display string (space-separated).
154
44
  */
155
- declare function sortByName<T extends {
45
+ declare function formatBadges(badges: string[]): string;
46
+ import { OpenPkg as OpenPkg7, SpecExport as SpecExport3, SpecExportKind as SpecExportKind4, SpecType } from "@openpkg-ts/spec";
47
+ interface HTMLOptions {
48
+ /** Page title override */
49
+ title?: string;
50
+ /** Include inline styles */
51
+ includeStyles?: boolean;
52
+ /** Custom CSS to inject */
53
+ customCSS?: string;
54
+ /** Custom head content */
55
+ headContent?: string;
56
+ /** Wrap in full HTML document */
57
+ fullDocument?: boolean;
58
+ /** Export to render (single mode) */
59
+ export?: string;
60
+ /** Exports to render (multi-mode) - overridden by `export` if both provided */
61
+ exports?: string[];
62
+ }
63
+ import { SpecExportKind } from "@openpkg-ts/spec";
64
+ interface JSONOptions {
65
+ /** Include raw spec data alongside simplified data */
66
+ includeRaw?: boolean;
67
+ /** Export to render (single mode) */
68
+ export?: string;
69
+ /** Exports to render (multi-mode) - overridden by `export` if both provided */
70
+ exports?: string[];
71
+ /** Include computed fields (signatures, formatted types) */
72
+ computed?: boolean;
73
+ /** Flatten nested structures */
74
+ flatten?: boolean;
75
+ }
76
+ interface SimplifiedParameter {
156
77
  name: string;
157
- }>(items: T[]): T[];
158
- /**
159
- * Conditional type structure from the spec.
160
- */
161
- interface SpecConditionalType {
162
- checkType: SpecSchema;
163
- extendsType: SpecSchema;
164
- trueType: SpecSchema;
165
- falseType: SpecSchema;
78
+ type: string;
79
+ required: boolean;
80
+ description?: string;
81
+ default?: unknown;
82
+ rest?: boolean;
166
83
  }
167
- /**
168
- * Mapped type structure from the spec.
169
- */
170
- interface SpecMappedType {
171
- keyType: SpecSchema;
172
- valueType: SpecSchema;
173
- readonly?: boolean | "add" | "remove";
174
- optional?: boolean | "add" | "remove";
84
+ interface SimplifiedReturn {
85
+ type: string;
86
+ description?: string;
175
87
  }
176
- /**
177
- * Format a conditional type to a human-readable string.
178
- *
179
- * @param condType - The conditional type structure
180
- * @returns Formatted conditional type string
181
- *
182
- * @example
183
- * ```ts
184
- * formatConditionalType({
185
- * checkType: { 'x-ts-type': 'T' },
186
- * extendsType: { type: 'string' },
187
- * trueType: { type: 'boolean', const: true },
188
- * falseType: { type: 'boolean', const: false }
189
- * })
190
- * // 'T extends string ? true : false'
191
- * ```
192
- */
193
- declare function formatConditionalType(condType: SpecConditionalType): string;
194
- /**
195
- * Format a mapped type to a human-readable string.
196
- *
197
- * @param mappedType - The mapped type structure
198
- * @returns Formatted mapped type string
199
- *
200
- * @example
201
- * ```ts
202
- * formatMappedType({
203
- * keyType: { 'x-ts-type': 'K in keyof T' },
204
- * valueType: { 'x-ts-type': 'T[K]' },
205
- * readonly: true
206
- * })
207
- * // '{ readonly [K in keyof T]: T[K] }'
208
- * ```
209
- */
210
- declare function formatMappedType(mappedType: SpecMappedType): string;
211
- import { OpenPkg as OpenPkg2, SpecExport as SpecExport2, SpecExportKind } from "@openpkg-ts/spec";
212
- type Predicate = (exp: SpecExport2) => boolean;
213
- /**
214
- * Chainable query builder for filtering OpenPkg exports.
215
- * Filters are lazy - predicates only run on execution methods (find, first, count, etc).
216
- */
217
- declare class QueryBuilder {
218
- private spec;
219
- private predicates;
220
- constructor(spec: OpenPkg2);
221
- /**
222
- * Filter by kind(s)
223
- */
224
- byKind(...kinds: SpecExportKind[]): this;
225
- /**
226
- * Filter by name (exact string or regex pattern)
227
- */
228
- byName(pattern: string | RegExp): this;
229
- /**
230
- * Filter by tag(s) - must have at least one matching tag
231
- */
232
- byTag(...tags: string[]): this;
233
- /**
234
- * Filter by deprecation status
235
- * @param include - true = only deprecated, false = exclude deprecated, undefined = all
236
- */
237
- deprecated(include?: boolean): this;
238
- /**
239
- * Filter to exports with descriptions only
240
- */
241
- withDescription(): this;
242
- /**
243
- * Search name and description (case-insensitive)
244
- */
245
- search(term: string): this;
246
- /**
247
- * Custom predicate filter
248
- */
249
- where(predicate: Predicate): this;
250
- /**
251
- * Filter by source module/file path (contains match)
252
- */
253
- byModule(modulePath: string): this;
254
- private matches;
255
- /**
256
- * Execute query and return matching exports
257
- */
258
- find(): SpecExport2[];
259
- /**
260
- * Execute query and return first match (or undefined)
261
- */
262
- first(): SpecExport2 | undefined;
263
- /**
264
- * Execute query and return count of matches
265
- */
266
- count(): number;
267
- /**
268
- * Execute query and return IDs of matching exports
269
- */
270
- ids(): string[];
271
- /**
272
- * Execute query and return a new filtered OpenPkg spec
273
- */
274
- toSpec(): OpenPkg2;
88
+ interface SimplifiedSignature {
89
+ parameters: SimplifiedParameter[];
90
+ returns?: SimplifiedReturn;
91
+ description?: string;
92
+ typeParameters?: string[];
275
93
  }
276
- /**
277
- * Create a query builder for the given spec
278
- */
279
- declare function query(spec: OpenPkg2): QueryBuilder;
280
- import { SpecMember as SpecMember2 } from "@openpkg-ts/spec";
281
- /**
282
- * Extract badge strings from a member's visibility and flags.
283
- * Handles: visibility (if not public), static, readonly, async, abstract
284
- */
285
- declare function getMemberBadges(member: SpecMember2): string[];
286
- /**
287
- * Format badges array into a display string (space-separated).
288
- */
289
- declare function formatBadges(badges: string[]): string;
290
- import { OpenPkg as OpenPkg3, SpecExport as SpecExport3 } from "@openpkg-ts/spec";
291
- interface DiagnosticItem {
292
- exportId: string;
293
- exportName: string;
294
- issue: string;
295
- /** Member name if issue is on a member */
296
- member?: string;
297
- /** Parameter name if issue is on a parameter */
298
- param?: string;
94
+ interface SimplifiedMember {
95
+ name: string;
96
+ kind: "property" | "method";
97
+ type?: string;
98
+ description?: string;
99
+ visibility?: "public" | "protected" | "private";
100
+ signature?: SimplifiedSignature;
299
101
  }
300
- interface SpecDiagnostics {
301
- /** Exports/members without descriptions */
302
- missingDescriptions: DiagnosticItem[];
303
- /** Exports marked @deprecated but no reason provided */
304
- deprecatedNoReason: DiagnosticItem[];
305
- /** Function params without descriptions in JSDoc */
306
- missingParamDocs: DiagnosticItem[];
102
+ interface SimplifiedExample {
103
+ code: string;
104
+ title?: string;
105
+ description?: string;
106
+ language?: string;
307
107
  }
308
- /**
309
- * Check if has @deprecated tag.
310
- */
311
- declare function hasDeprecatedTag(exp: SpecExport3): boolean;
312
- /**
313
- * Get deprecation message from @deprecated tag.
314
- * Returns undefined if no reason provided.
315
- */
316
- declare function getDeprecationMessage(exp: SpecExport3): string | undefined;
317
- /**
318
- * Find params without descriptions in JSDoc.
319
- */
320
- declare function findMissingParamDocs(exp: SpecExport3): string[];
321
- /**
322
- * Analyze a spec for quality issues.
323
- */
324
- declare function analyzeSpec(spec: OpenPkg3): SpecDiagnostics;
325
- import { OpenPkg as OpenPkg4, SpecExportKind as SpecExportKind2 } from "@openpkg-ts/spec";
108
+ interface SimplifiedExport {
109
+ id: string;
110
+ name: string;
111
+ kind: SpecExportKind;
112
+ signature: string;
113
+ description?: string;
114
+ deprecated: boolean;
115
+ tags: Array<{
116
+ name: string;
117
+ text: string;
118
+ }>;
119
+ parameters?: SimplifiedParameter[];
120
+ returns?: SimplifiedReturn;
121
+ members?: SimplifiedMember[];
122
+ examples?: SimplifiedExample[];
123
+ extends?: string;
124
+ implements?: string[];
125
+ sourceFile?: string;
126
+ sourceLine?: number;
127
+ }
128
+ interface SimplifiedSpec {
129
+ name: string;
130
+ version?: string;
131
+ description?: string;
132
+ exports: SimplifiedExport[];
133
+ byKind: Record<SpecExportKind, SimplifiedExport[]>;
134
+ totalExports: number;
135
+ }
136
+ interface MarkdownOptions {
137
+ /** Include frontmatter in output */
138
+ frontmatter?: boolean;
139
+ /** Sections to include */
140
+ sections?: {
141
+ signature?: boolean;
142
+ description?: boolean;
143
+ parameters?: boolean;
144
+ returns?: boolean;
145
+ examples?: boolean;
146
+ members?: boolean;
147
+ properties?: boolean;
148
+ methods?: boolean;
149
+ };
150
+ /** Custom frontmatter fields */
151
+ customFrontmatter?: Record<string, unknown>;
152
+ /** Use code fences for signatures */
153
+ codeSignatures?: boolean;
154
+ /** Heading level offset (0 = starts at h1, 1 = starts at h2) */
155
+ headingOffset?: number;
156
+ /** Collapse unions with more than N members (default: no collapse) */
157
+ collapseUnionThreshold?: number;
158
+ }
159
+ interface ExportMarkdownOptions extends MarkdownOptions {
160
+ /** Export to render (single mode) */
161
+ export?: string;
162
+ /** Exports to render (multi-mode) - overridden by `export` if both provided */
163
+ exports?: string[];
164
+ }
165
+ import { SpecExportKind as SpecExportKind2 } from "@openpkg-ts/spec";
166
+ type NavFormat = "fumadocs" | "docusaurus" | "generic";
167
+ type GroupBy = "kind" | "module" | "tag" | "none";
168
+ interface NavOptions {
169
+ /** Output format */
170
+ format?: NavFormat;
171
+ /** How to group exports */
172
+ groupBy?: GroupBy;
173
+ /** Base path for links */
174
+ basePath?: string;
175
+ /** Custom slug generator */
176
+ slugify?: (name: string) => string;
177
+ /** Include index pages for groups */
178
+ includeGroupIndex?: boolean;
179
+ /** Custom kind labels */
180
+ kindLabels?: Partial<Record<SpecExportKind2, string>>;
181
+ /** Sort exports alphabetically */
182
+ sortAlphabetically?: boolean;
183
+ }
184
+ interface NavItem {
185
+ title: string;
186
+ href?: string;
187
+ items?: NavItem[];
188
+ }
189
+ interface NavGroup {
190
+ title: string;
191
+ items: NavItem[];
192
+ index?: string;
193
+ }
194
+ interface GenericNav {
195
+ title: string;
196
+ groups: NavGroup[];
197
+ items: NavItem[];
198
+ }
199
+ interface FumadocsMetaItem {
200
+ title: string;
201
+ pages?: string[];
202
+ defaultOpen?: boolean;
203
+ }
204
+ interface FumadocsMeta {
205
+ root?: boolean;
206
+ title?: string;
207
+ pages?: (string | FumadocsMetaItem)[];
208
+ }
209
+ interface DocusaurusSidebarItem {
210
+ type: "category" | "doc" | "link";
211
+ label: string;
212
+ items?: DocusaurusSidebarItem[];
213
+ id?: string;
214
+ href?: string;
215
+ }
216
+ type DocusaurusSidebar = DocusaurusSidebarItem[];
217
+ import { OpenPkg as OpenPkg6, SpecExportKind as SpecExportKind3 } from "@openpkg-ts/spec";
326
218
  interface SearchOptions {
327
219
  /** Base URL for search result links */
328
220
  baseUrl?: string;
@@ -366,7 +258,7 @@ interface PagefindRecord {
366
258
  interface AlgoliaRecord {
367
259
  objectID: string;
368
260
  name: string;
369
- kind: SpecExportKind2;
261
+ kind: SpecExportKind3;
370
262
  description?: string;
371
263
  signature: string;
372
264
  content: string;
@@ -386,7 +278,7 @@ interface AlgoliaRecord {
386
278
  interface SearchRecord {
387
279
  id: string;
388
280
  name: string;
389
- kind: SpecExportKind2;
281
+ kind: SpecExportKind3;
390
282
  signature: string;
391
283
  description?: string;
392
284
  content: string;
@@ -415,7 +307,7 @@ interface SearchIndex {
415
307
  * // { records: [...], version: '1.0.0', packageName: 'my-lib' }
416
308
  * ```
417
309
  */
418
- declare function toSearchIndex2(spec: OpenPkg4, options?: SearchOptions): SearchIndex;
310
+ declare function toSearchIndex2(spec: OpenPkg6, options?: SearchOptions): SearchIndex;
419
311
  /**
420
312
  * Generate Pagefind-compatible records.
421
313
  *
@@ -431,7 +323,7 @@ declare function toSearchIndex2(spec: OpenPkg4, options?: SearchOptions): Search
431
323
  * })
432
324
  * ```
433
325
  */
434
- declare function toPagefindRecords2(spec: OpenPkg4, options?: SearchOptions): PagefindRecord[];
326
+ declare function toPagefindRecords2(spec: OpenPkg6, options?: SearchOptions): PagefindRecord[];
435
327
  /**
436
328
  * Generate Algolia-compatible records.
437
329
  *
@@ -445,7 +337,7 @@ declare function toPagefindRecords2(spec: OpenPkg4, options?: SearchOptions): Pa
445
337
  * // Upload to Algolia index
446
338
  * ```
447
339
  */
448
- declare function toAlgoliaRecords2(spec: OpenPkg4, options?: SearchOptions): AlgoliaRecord[];
340
+ declare function toAlgoliaRecords2(spec: OpenPkg6, options?: SearchOptions): AlgoliaRecord[];
449
341
  /**
450
342
  * Serialize search index to JSON string.
451
343
  *
@@ -459,207 +351,36 @@ declare function toAlgoliaRecords2(spec: OpenPkg4, options?: SearchOptions): Alg
459
351
  * fs.writeFileSync('search-index.json', json)
460
352
  * ```
461
353
  */
462
- declare function toSearchIndexJSON(spec: OpenPkg4, options?: SearchOptions & {
354
+ declare function toSearchIndexJSON(spec: OpenPkg6, options?: SearchOptions & {
463
355
  pretty?: boolean;
464
356
  }): string;
465
- import { OpenPkg as OpenPkg9, SpecExport as SpecExport5, SpecExportKind as SpecExportKind5, SpecType as SpecType2 } from "@openpkg-ts/spec";
466
- interface HTMLOptions {
467
- /** Page title override */
468
- title?: string;
469
- /** Include inline styles */
470
- includeStyles?: boolean;
471
- /** Custom CSS to inject */
472
- customCSS?: string;
473
- /** Custom head content */
474
- headContent?: string;
475
- /** Wrap in full HTML document */
476
- fullDocument?: boolean;
477
- /** Export to render (single mode) */
478
- export?: string;
479
- /** Exports to render (multi-mode) - overridden by `export` if both provided */
480
- exports?: string[];
481
- }
482
- import { SpecExportKind as SpecExportKind3 } from "@openpkg-ts/spec";
483
- interface JSONOptions {
484
- /** Include raw spec data alongside simplified data */
485
- includeRaw?: boolean;
486
- /** Export to render (single mode) */
487
- export?: string;
488
- /** Exports to render (multi-mode) - overridden by `export` if both provided */
489
- exports?: string[];
490
- /** Include computed fields (signatures, formatted types) */
491
- computed?: boolean;
492
- /** Flatten nested structures */
493
- flatten?: boolean;
494
- }
495
- interface SimplifiedParameter {
496
- name: string;
497
- type: string;
498
- required: boolean;
499
- description?: string;
500
- default?: unknown;
501
- rest?: boolean;
502
- }
503
- interface SimplifiedReturn {
504
- type: string;
505
- description?: string;
506
- }
507
- interface SimplifiedSignature {
508
- parameters: SimplifiedParameter[];
509
- returns?: SimplifiedReturn;
510
- description?: string;
511
- typeParameters?: string[];
512
- }
513
- interface SimplifiedMember {
514
- name: string;
515
- kind: "property" | "method";
516
- type?: string;
517
- description?: string;
518
- visibility?: "public" | "protected" | "private";
519
- signature?: SimplifiedSignature;
520
- }
521
- interface SimplifiedExample {
522
- code: string;
523
- title?: string;
524
- description?: string;
525
- language?: string;
526
- }
527
- interface SimplifiedExport {
528
- id: string;
529
- name: string;
530
- kind: SpecExportKind3;
531
- signature: string;
532
- description?: string;
533
- deprecated: boolean;
534
- tags: Array<{
535
- name: string;
536
- text: string;
537
- }>;
538
- parameters?: SimplifiedParameter[];
539
- returns?: SimplifiedReturn;
540
- members?: SimplifiedMember[];
541
- examples?: SimplifiedExample[];
542
- extends?: string;
543
- implements?: string[];
544
- sourceFile?: string;
545
- sourceLine?: number;
546
- }
547
- interface SimplifiedSpec {
548
- name: string;
549
- version?: string;
550
- description?: string;
551
- exports: SimplifiedExport[];
552
- byKind: Record<SpecExportKind3, SimplifiedExport[]>;
553
- totalExports: number;
554
- }
555
- interface MarkdownOptions {
556
- /** Include frontmatter in output */
557
- frontmatter?: boolean;
558
- /** Sections to include */
559
- sections?: {
560
- signature?: boolean;
561
- description?: boolean;
562
- parameters?: boolean;
563
- returns?: boolean;
564
- examples?: boolean;
565
- members?: boolean;
566
- properties?: boolean;
567
- methods?: boolean;
568
- };
569
- /** Custom frontmatter fields */
570
- customFrontmatter?: Record<string, unknown>;
571
- /** Use code fences for signatures */
572
- codeSignatures?: boolean;
573
- /** Heading level offset (0 = starts at h1, 1 = starts at h2) */
574
- headingOffset?: number;
575
- /** Collapse unions with more than N members (default: no collapse) */
576
- collapseUnionThreshold?: number;
577
- }
578
- interface ExportMarkdownOptions extends MarkdownOptions {
579
- /** Export to render (single mode) */
580
- export?: string;
581
- /** Exports to render (multi-mode) - overridden by `export` if both provided */
582
- exports?: string[];
583
- }
584
- import { SpecExportKind as SpecExportKind4 } from "@openpkg-ts/spec";
585
- type NavFormat = "fumadocs" | "docusaurus" | "generic";
586
- type GroupBy = "kind" | "module" | "tag" | "none";
587
- interface NavOptions {
588
- /** Output format */
589
- format?: NavFormat;
590
- /** How to group exports */
591
- groupBy?: GroupBy;
592
- /** Base path for links */
593
- basePath?: string;
594
- /** Custom slug generator */
595
- slugify?: (name: string) => string;
596
- /** Include index pages for groups */
597
- includeGroupIndex?: boolean;
598
- /** Custom kind labels */
599
- kindLabels?: Partial<Record<SpecExportKind4, string>>;
600
- /** Sort exports alphabetically */
601
- sortAlphabetically?: boolean;
602
- }
603
- interface NavItem {
604
- title: string;
605
- href?: string;
606
- items?: NavItem[];
607
- }
608
- interface NavGroup {
609
- title: string;
610
- items: NavItem[];
611
- index?: string;
612
- }
613
- interface GenericNav {
614
- title: string;
615
- groups: NavGroup[];
616
- items: NavItem[];
617
- }
618
- interface FumadocsMetaItem {
619
- title: string;
620
- pages?: string[];
621
- defaultOpen?: boolean;
622
- }
623
- interface FumadocsMeta {
624
- root?: boolean;
625
- title?: string;
626
- pages?: (string | FumadocsMetaItem)[];
627
- }
628
- interface DocusaurusSidebarItem {
629
- type: "category" | "doc" | "link";
630
- label: string;
631
- items?: DocusaurusSidebarItem[];
632
- id?: string;
633
- href?: string;
634
- }
635
- type DocusaurusSidebar = DocusaurusSidebarItem[];
636
- interface LoadOptions {
637
- /** Path to openpkg.json file or the spec object directly */
638
- input: string | OpenPkg9;
357
+ interface LoadOptions {
358
+ /** Path to openpkg.json file or the spec object directly */
359
+ input: string | OpenPkg7;
639
360
  }
640
361
  interface DocsInstance {
641
362
  /** The parsed OpenPkg spec */
642
- spec: OpenPkg9;
363
+ spec: OpenPkg7;
643
364
  /** Get an by its ID */
644
- getExport(id: string): SpecExport5 | undefined;
365
+ getExport(id: string): SpecExport3 | undefined;
645
366
  /** Get a type definition by its ID */
646
- getType(id: string): SpecType2 | undefined;
367
+ getType(id: string): SpecType | undefined;
647
368
  /** Get all exports of a specific kind */
648
- getExportsByKind(kind: SpecExportKind5): SpecExport5[];
369
+ getExportsByKind(kind: SpecExportKind4): SpecExport3[];
649
370
  /** Get all exports */
650
- getAllExports(): SpecExport5[];
371
+ getAllExports(): SpecExport3[];
651
372
  /** Get all type definitions */
652
- getAllTypes(): SpecType2[];
373
+ getAllTypes(): SpecType[];
653
374
  /** Get exports by JSDoc tag (e.g., '@beta', '@internal') */
654
- getExportsByTag(tagName: string): SpecExport5[];
375
+ getExportsByTag(tagName: string): SpecExport3[];
655
376
  /** Search exports by name or description */
656
- search(query: string): SpecExport5[];
377
+ search(query: string): SpecExport3[];
657
378
  /** Get exports belonging to a specific module/namespace */
658
- getModule(moduleName: string): SpecExport5[];
379
+ getModule(moduleName: string): SpecExport3[];
659
380
  /** Get deprecated exports */
660
- getDeprecated(): SpecExport5[];
381
+ getDeprecated(): SpecExport3[];
661
382
  /** Get exports grouped by kind */
662
- groupByKind(): Record<SpecExportKind5, SpecExport5[]>;
383
+ groupByKind(): Record<SpecExportKind4, SpecExport3[]>;
663
384
  /** Render spec or single to MDX */
664
385
  toMarkdown(options?: ExportMarkdownOptions): string;
665
386
  /** Render spec or single to HTML */
@@ -675,4 +396,283 @@ interface DocsInstance {
675
396
  /** Generate Algolia-compatible records */
676
397
  toAlgoliaRecords(options?: SearchOptions): AlgoliaRecord[];
677
398
  }
399
+ import { OpenPkg as OpenPkg8, SpecExport as SpecExport4, SpecMember as SpecMember2, SpecSchema, SpecSignature, SpecType as SpecType2, SpecTypeParameter } from "@openpkg-ts/spec";
400
+ interface FormatSchemaOptions {
401
+ /** Include package attribution for external types */
402
+ includePackage?: boolean;
403
+ /** Collapse unions with more than N members (default: no collapse) */
404
+ collapseUnionThreshold?: number;
405
+ }
406
+ /**
407
+ * Format a schema to a human-readable type string.
408
+ *
409
+ * @param schema - The schema to format
410
+ * @param options - Formatting options
411
+ * @returns Formatted type string
412
+ *
413
+ * @example
414
+ * ```ts
415
+ * formatSchema({ type: 'string' }) // 'string'
416
+ * formatSchema({ $ref: '#/types/User' }) // 'User'
417
+ * formatSchema({ anyOf: [{ type: 'string' }, { type: 'number' }] }) // 'string | number'
418
+ * formatSchema({ type: 'integer', 'x-ts-type': 'bigint' }) // 'bigint'
419
+ * formatSchema({ 'x-ts-type': 'Response', 'x-ts-package': 'express' }, { includePackage: true }) // 'Response (from express)'
420
+ * ```
421
+ */
422
+ declare function formatSchema(schema: SpecSchema | undefined, options?: FormatSchemaOptions): string;
423
+ /**
424
+ * Format type parameters to a string like `<T, U extends string>`.
425
+ *
426
+ * @param typeParams - Array of type parameters
427
+ * @returns Formatted type parameters string or empty string
428
+ *
429
+ * @example
430
+ * ```ts
431
+ * formatTypeParameters([{ name: 'T' }]) // '<T>'
432
+ * formatTypeParameters([{ name: 'T', constraint: 'object' }]) // '<T extends object>'
433
+ * formatTypeParameters([{ name: 'T', default: 'unknown' }]) // '<T = unknown>'
434
+ * formatTypeParameters([{ name: 'T', variance: 'in' }]) // '<in T>'
435
+ * ```
436
+ */
437
+ declare function formatTypeParameters(typeParams?: SpecTypeParameter[]): string;
438
+ /**
439
+ * Format function parameters to a string like `(a: string, b?: number)`.
440
+ *
441
+ * @param sig - The signature containing parameters
442
+ * @returns Formatted parameters string
443
+ *
444
+ * @example
445
+ * ```ts
446
+ * formatParameters({ parameters: [{ name: 'id', schema: { type: 'string' } }] })
447
+ * // '(id: string)'
448
+ * ```
449
+ */
450
+ declare function formatParameters(sig?: SpecSignature): string;
451
+ /**
452
+ * Format return type from signature.
453
+ *
454
+ * @param sig - The signature containing return type
455
+ * @returns Formatted return type string
456
+ *
457
+ * @example
458
+ * ```ts
459
+ * formatReturnType({ returns: { schema: { type: 'Promise', items: { type: 'string' } } } })
460
+ * // 'Promise<string>'
461
+ * ```
462
+ */
463
+ declare function formatReturnType(sig?: SpecSignature): string;
464
+ /**
465
+ * Build a full signature string for an export.
466
+ *
467
+ * @param exp - The to build a signature for
468
+ * @param sigIndex - Index of signature to use for overloaded functions
469
+ * @returns Complete signature string
470
+ *
471
+ * @example
472
+ * ```ts
473
+ * buildSignatureString({ kind: 'function', name: 'greet', signatures: [...] })
474
+ * // 'function greet(name: string): string'
475
+ *
476
+ * buildSignatureString({ kind: 'class', name: 'Logger', extends: 'EventEmitter' })
477
+ * // 'class Logger extends EventEmitter'
478
+ * ```
479
+ */
480
+ declare function buildSignatureString(exp: SpecExport4, sigIndex?: number): string;
481
+ /**
482
+ * Resolve a type reference to its definition.
483
+ *
484
+ * @param ref - Type reference string (e.g., '#/types/User')
485
+ * @param spec - The OpenPkg spec containing type definitions
486
+ * @returns The resolved type definition or undefined
487
+ *
488
+ * @example
489
+ * ```ts
490
+ * resolveTypeRef('#/types/User', spec)
491
+ * // { id: 'User', name: 'User', kind: 'interface', ... }
492
+ * ```
493
+ */
494
+ declare function resolveTypeRef(ref: string, spec: OpenPkg8): SpecType2 | undefined;
495
+ /**
496
+ * Check if a member is a method (has signatures).
497
+ *
498
+ * @param member - The member to check
499
+ * @returns True if the member is a method
500
+ *
501
+ * @example
502
+ * ```ts
503
+ * isMethod({ name: 'foo', signatures: [{ parameters: [] }] }) // true
504
+ * isMethod({ name: 'bar', schema: { type: 'string' } }) // false
505
+ * ```
506
+ */
507
+ declare function isMethod(member: SpecMember2): boolean;
508
+ /**
509
+ * Check if a member is a property (no signatures).
510
+ *
511
+ * @param member - The member to check
512
+ * @returns True if the member is a property
513
+ */
514
+ declare function isProperty(member: SpecMember2): boolean;
515
+ /**
516
+ * Get methods from members list.
517
+ *
518
+ * @param members - Array of members to filter
519
+ * @returns Array of method members
520
+ */
521
+ declare function getMethods(members?: SpecMember2[]): SpecMember2[];
522
+ /**
523
+ * Get properties from members list.
524
+ *
525
+ * @param members - Array of members to filter
526
+ * @returns Array of property members
527
+ */
528
+ declare function getProperties(members?: SpecMember2[]): SpecMember2[];
529
+ /**
530
+ * Group members by visibility (public, protected, private).
531
+ *
532
+ * @param members - Array of members to group
533
+ * @returns Object with public, protected, and private arrays
534
+ *
535
+ * @example
536
+ * ```ts
537
+ * const groups = groupByVisibility(classExport.members)
538
+ * groups.public // [{ name: 'foo', visibility: 'public' }]
539
+ * groups.private // [{ name: 'bar', visibility: 'private' }]
540
+ * ```
541
+ */
542
+ declare function groupByVisibility(members?: SpecMember2[]): {
543
+ public: SpecMember2[];
544
+ protected: SpecMember2[];
545
+ private: SpecMember2[];
546
+ };
547
+ /**
548
+ * Sort exports alphabetically by name.
549
+ *
550
+ * @param items - Array of items with a name property
551
+ * @returns New sorted array
552
+ */
553
+ declare function sortByName<T extends {
554
+ name: string;
555
+ }>(items: T[]): T[];
556
+ /**
557
+ * Conditional type structure from the spec.
558
+ */
559
+ interface SpecConditionalType {
560
+ checkType: SpecSchema;
561
+ extendsType: SpecSchema;
562
+ trueType: SpecSchema;
563
+ falseType: SpecSchema;
564
+ }
565
+ /**
566
+ * Mapped type structure from the spec.
567
+ */
568
+ interface SpecMappedType {
569
+ keyType: SpecSchema;
570
+ valueType: SpecSchema;
571
+ readonly?: boolean | "add" | "remove";
572
+ optional?: boolean | "add" | "remove";
573
+ }
574
+ /**
575
+ * Format a conditional type to a human-readable string.
576
+ *
577
+ * @param condType - The conditional type structure
578
+ * @returns Formatted conditional type string
579
+ *
580
+ * @example
581
+ * ```ts
582
+ * formatConditionalType({
583
+ * checkType: { 'x-ts-type': 'T' },
584
+ * extendsType: { type: 'string' },
585
+ * trueType: { type: 'boolean', const: true },
586
+ * falseType: { type: 'boolean', const: false }
587
+ * })
588
+ * // 'T extends string ? true : false'
589
+ * ```
590
+ */
591
+ declare function formatConditionalType(condType: SpecConditionalType): string;
592
+ /**
593
+ * Format a mapped type to a human-readable string.
594
+ *
595
+ * @param mappedType - The mapped type structure
596
+ * @returns Formatted mapped type string
597
+ *
598
+ * @example
599
+ * ```ts
600
+ * formatMappedType({
601
+ * keyType: { 'x-ts-type': 'K in keyof T' },
602
+ * valueType: { 'x-ts-type': 'T[K]' },
603
+ * readonly: true
604
+ * })
605
+ * // '{ readonly [K in keyof T]: T[K] }'
606
+ * ```
607
+ */
608
+ declare function formatMappedType(mappedType: SpecMappedType): string;
609
+ import { OpenPkg as OpenPkg9, SpecExport as SpecExport5, SpecExportKind as SpecExportKind5 } from "@openpkg-ts/spec";
610
+ type Predicate = (exp: SpecExport5) => boolean;
611
+ /**
612
+ * Chainable query builder for filtering OpenPkg exports.
613
+ * Filters are lazy - predicates only run on execution methods (find, first, count, etc).
614
+ */
615
+ declare class QueryBuilder {
616
+ private spec;
617
+ private predicates;
618
+ constructor(spec: OpenPkg9);
619
+ /**
620
+ * Filter by kind(s)
621
+ */
622
+ byKind(...kinds: SpecExportKind5[]): this;
623
+ /**
624
+ * Filter by name (exact string or regex pattern)
625
+ */
626
+ byName(pattern: string | RegExp): this;
627
+ /**
628
+ * Filter by tag(s) - must have at least one matching tag
629
+ */
630
+ byTag(...tags: string[]): this;
631
+ /**
632
+ * Filter by deprecation status
633
+ * @param include - true = only deprecated, false = exclude deprecated, undefined = all
634
+ */
635
+ deprecated(include?: boolean): this;
636
+ /**
637
+ * Filter to exports with descriptions only
638
+ */
639
+ withDescription(): this;
640
+ /**
641
+ * Search name and description (case-insensitive)
642
+ */
643
+ search(term: string): this;
644
+ /**
645
+ * Custom predicate filter
646
+ */
647
+ where(predicate: Predicate): this;
648
+ /**
649
+ * Filter by source module/file path (contains match)
650
+ */
651
+ byModule(modulePath: string): this;
652
+ private matches;
653
+ /**
654
+ * Execute query and return matching exports
655
+ */
656
+ find(): SpecExport5[];
657
+ /**
658
+ * Execute query and return first match (or undefined)
659
+ */
660
+ first(): SpecExport5 | undefined;
661
+ /**
662
+ * Execute query and return count of matches
663
+ */
664
+ count(): number;
665
+ /**
666
+ * Execute query and return IDs of matching exports
667
+ */
668
+ ids(): string[];
669
+ /**
670
+ * Execute query and return a new filtered OpenPkg spec
671
+ */
672
+ toSpec(): OpenPkg9;
673
+ }
674
+ /**
675
+ * Create a query builder for the given spec
676
+ */
677
+ declare function query(spec: OpenPkg9): QueryBuilder;
678
678
  export { toSearchIndexJSON, toSearchIndex2 as toSearchIndex, toPagefindRecords2 as toPagefindRecords, toAlgoliaRecords2 as toAlgoliaRecords, sortByName, resolveTypeRef, query, isProperty, isMethod, hasDeprecatedTag, groupByVisibility, getProperties, getMethods, getMemberBadges, getDeprecationMessage, formatTypeParameters, formatSchema, formatReturnType, formatParameters, formatMappedType, formatConditionalType, formatBadges, findMissingParamDocs, buildSignatureString, analyzeSpec, SpecMappedType, SpecDiagnostics, SpecConditionalType, SearchRecord, SearchOptions, SearchIndex, QueryBuilder, PagefindRecord, LoadOptions, FormatSchemaOptions, DocsInstance, DiagnosticItem, AlgoliaRecord };