@openpkg-ts/sdk 0.33.1 → 0.34.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/README.md +76 -1
- package/dist/browser.d.ts +678 -0
- package/dist/browser.js +56 -0
- package/dist/index.d.ts +234 -39
- package/dist/index.js +815 -941
- package/dist/shared/chunk-skapcfq1.js +552 -0
- package/package.json +7 -3
|
@@ -0,0 +1,678 @@
|
|
|
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[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Check if has @deprecated tag.
|
|
21
|
+
*/
|
|
22
|
+
declare function hasDeprecatedTag(exp: SpecExport): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Get deprecation message from @deprecated tag.
|
|
25
|
+
* Returns undefined if no reason provided.
|
|
26
|
+
*/
|
|
27
|
+
declare function getDeprecationMessage(exp: SpecExport): string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Find params without descriptions in JSDoc.
|
|
30
|
+
*/
|
|
31
|
+
declare function findMissingParamDocs(exp: SpecExport): string[];
|
|
32
|
+
/**
|
|
33
|
+
* Analyze a spec for quality issues.
|
|
34
|
+
*/
|
|
35
|
+
declare function analyzeSpec(spec: OpenPkg): SpecDiagnostics;
|
|
36
|
+
import { SpecMember } from "@openpkg-ts/spec";
|
|
37
|
+
/**
|
|
38
|
+
* Extract badge strings from a member's visibility and flags.
|
|
39
|
+
* Handles: visibility (if not public), static, readonly, async, abstract
|
|
40
|
+
*/
|
|
41
|
+
declare function getMemberBadges(member: SpecMember): string[];
|
|
42
|
+
/**
|
|
43
|
+
* Format badges array into a display string (space-separated).
|
|
44
|
+
*/
|
|
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 {
|
|
77
|
+
name: string;
|
|
78
|
+
type: string;
|
|
79
|
+
required: boolean;
|
|
80
|
+
description?: string;
|
|
81
|
+
default?: unknown;
|
|
82
|
+
rest?: boolean;
|
|
83
|
+
}
|
|
84
|
+
interface SimplifiedReturn {
|
|
85
|
+
type: string;
|
|
86
|
+
description?: string;
|
|
87
|
+
}
|
|
88
|
+
interface SimplifiedSignature {
|
|
89
|
+
parameters: SimplifiedParameter[];
|
|
90
|
+
returns?: SimplifiedReturn;
|
|
91
|
+
description?: string;
|
|
92
|
+
typeParameters?: string[];
|
|
93
|
+
}
|
|
94
|
+
interface SimplifiedMember {
|
|
95
|
+
name: string;
|
|
96
|
+
kind: "property" | "method";
|
|
97
|
+
type?: string;
|
|
98
|
+
description?: string;
|
|
99
|
+
visibility?: "public" | "protected" | "private";
|
|
100
|
+
signature?: SimplifiedSignature;
|
|
101
|
+
}
|
|
102
|
+
interface SimplifiedExample {
|
|
103
|
+
code: string;
|
|
104
|
+
title?: string;
|
|
105
|
+
description?: string;
|
|
106
|
+
language?: string;
|
|
107
|
+
}
|
|
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";
|
|
218
|
+
interface SearchOptions {
|
|
219
|
+
/** Base URL for search result links */
|
|
220
|
+
baseUrl?: string;
|
|
221
|
+
/** Custom slug generator */
|
|
222
|
+
slugify?: (name: string) => string;
|
|
223
|
+
/** Include type signatures in search content */
|
|
224
|
+
includeSignatures?: boolean;
|
|
225
|
+
/** Include member names in search content */
|
|
226
|
+
includeMembers?: boolean;
|
|
227
|
+
/** Include parameter names in search content */
|
|
228
|
+
includeParameters?: boolean;
|
|
229
|
+
/** Weight multipliers for ranking */
|
|
230
|
+
weights?: {
|
|
231
|
+
name?: number;
|
|
232
|
+
description?: number;
|
|
233
|
+
signature?: number;
|
|
234
|
+
tags?: number;
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
interface PagefindRecord {
|
|
238
|
+
url: string;
|
|
239
|
+
content: string;
|
|
240
|
+
word_count: number;
|
|
241
|
+
filters: Record<string, string[]>;
|
|
242
|
+
meta: {
|
|
243
|
+
title: string;
|
|
244
|
+
kind?: string;
|
|
245
|
+
description?: string;
|
|
246
|
+
signature?: string;
|
|
247
|
+
};
|
|
248
|
+
anchors?: Array<{
|
|
249
|
+
element: string;
|
|
250
|
+
id: string;
|
|
251
|
+
text: string;
|
|
252
|
+
}>;
|
|
253
|
+
weighted_sections?: Array<{
|
|
254
|
+
weight: number;
|
|
255
|
+
text: string;
|
|
256
|
+
}>;
|
|
257
|
+
}
|
|
258
|
+
interface AlgoliaRecord {
|
|
259
|
+
objectID: string;
|
|
260
|
+
name: string;
|
|
261
|
+
kind: SpecExportKind3;
|
|
262
|
+
description?: string;
|
|
263
|
+
signature: string;
|
|
264
|
+
content: string;
|
|
265
|
+
tags: string[];
|
|
266
|
+
deprecated: boolean;
|
|
267
|
+
url: string;
|
|
268
|
+
hierarchy: {
|
|
269
|
+
lvl0: string;
|
|
270
|
+
lvl1: string;
|
|
271
|
+
lvl2?: string;
|
|
272
|
+
};
|
|
273
|
+
_rankingInfo?: {
|
|
274
|
+
nbTypos: number;
|
|
275
|
+
words: number;
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
interface SearchRecord {
|
|
279
|
+
id: string;
|
|
280
|
+
name: string;
|
|
281
|
+
kind: SpecExportKind3;
|
|
282
|
+
signature: string;
|
|
283
|
+
description?: string;
|
|
284
|
+
content: string;
|
|
285
|
+
keywords: string[];
|
|
286
|
+
url: string;
|
|
287
|
+
deprecated: boolean;
|
|
288
|
+
}
|
|
289
|
+
interface SearchIndex {
|
|
290
|
+
records: SearchRecord[];
|
|
291
|
+
version: string;
|
|
292
|
+
generatedAt: string;
|
|
293
|
+
packageName: string;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Generate search index from spec.
|
|
297
|
+
*
|
|
298
|
+
* @param spec - The OpenPkg spec to index
|
|
299
|
+
* @param options - Search index configuration
|
|
300
|
+
* @returns Search index with records for each *
|
|
301
|
+
* @example
|
|
302
|
+
* ```ts
|
|
303
|
+
* import { createDocs } from '@openpkg-ts/sdk'
|
|
304
|
+
*
|
|
305
|
+
* const docs = createDocs('./openpkg.json')
|
|
306
|
+
* const index = docs.toSearchIndex({ baseUrl: '/api' })
|
|
307
|
+
* // { records: [...], version: '1.0.0', packageName: 'my-lib' }
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
declare function toSearchIndex2(spec: OpenPkg6, options?: SearchOptions): SearchIndex;
|
|
311
|
+
/**
|
|
312
|
+
* Generate Pagefind-compatible records.
|
|
313
|
+
*
|
|
314
|
+
* @param spec - The OpenPkg spec to index
|
|
315
|
+
* @param options - Search configuration including weights
|
|
316
|
+
* @returns Array of Pagefind-compatible search records
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```ts
|
|
320
|
+
* const records = toPagefindRecords(spec, {
|
|
321
|
+
* baseUrl: '/docs/api',
|
|
322
|
+
* weights: { name: 10, description: 5 }
|
|
323
|
+
* })
|
|
324
|
+
* ```
|
|
325
|
+
*/
|
|
326
|
+
declare function toPagefindRecords2(spec: OpenPkg6, options?: SearchOptions): PagefindRecord[];
|
|
327
|
+
/**
|
|
328
|
+
* Generate Algolia-compatible records.
|
|
329
|
+
*
|
|
330
|
+
* @param spec - The OpenPkg spec to index
|
|
331
|
+
* @param options - Search configuration
|
|
332
|
+
* @returns Array of Algolia-compatible search records with hierarchy
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* ```ts
|
|
336
|
+
* const records = toAlgoliaRecords(spec, { baseUrl: '/api' })
|
|
337
|
+
* // Upload to Algolia index
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
declare function toAlgoliaRecords2(spec: OpenPkg6, options?: SearchOptions): AlgoliaRecord[];
|
|
341
|
+
/**
|
|
342
|
+
* Serialize search index to JSON string.
|
|
343
|
+
*
|
|
344
|
+
* @param spec - The OpenPkg spec to index
|
|
345
|
+
* @param options - Search options plus pretty formatting option
|
|
346
|
+
* @returns JSON string of search index
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```ts
|
|
350
|
+
* const json = toSearchIndexJSON(spec, { pretty: true })
|
|
351
|
+
* fs.writeFileSync('search-index.json', json)
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
declare function toSearchIndexJSON(spec: OpenPkg6, options?: SearchOptions & {
|
|
355
|
+
pretty?: boolean;
|
|
356
|
+
}): string;
|
|
357
|
+
interface LoadOptions {
|
|
358
|
+
/** Path to openpkg.json file or the spec object directly */
|
|
359
|
+
input: string | OpenPkg7;
|
|
360
|
+
}
|
|
361
|
+
interface DocsInstance {
|
|
362
|
+
/** The parsed OpenPkg spec */
|
|
363
|
+
spec: OpenPkg7;
|
|
364
|
+
/** Get an by its ID */
|
|
365
|
+
getExport(id: string): SpecExport3 | undefined;
|
|
366
|
+
/** Get a type definition by its ID */
|
|
367
|
+
getType(id: string): SpecType | undefined;
|
|
368
|
+
/** Get all exports of a specific kind */
|
|
369
|
+
getExportsByKind(kind: SpecExportKind4): SpecExport3[];
|
|
370
|
+
/** Get all exports */
|
|
371
|
+
getAllExports(): SpecExport3[];
|
|
372
|
+
/** Get all type definitions */
|
|
373
|
+
getAllTypes(): SpecType[];
|
|
374
|
+
/** Get exports by JSDoc tag (e.g., '@beta', '@internal') */
|
|
375
|
+
getExportsByTag(tagName: string): SpecExport3[];
|
|
376
|
+
/** Search exports by name or description */
|
|
377
|
+
search(query: string): SpecExport3[];
|
|
378
|
+
/** Get exports belonging to a specific module/namespace */
|
|
379
|
+
getModule(moduleName: string): SpecExport3[];
|
|
380
|
+
/** Get deprecated exports */
|
|
381
|
+
getDeprecated(): SpecExport3[];
|
|
382
|
+
/** Get exports grouped by kind */
|
|
383
|
+
groupByKind(): Record<SpecExportKind4, SpecExport3[]>;
|
|
384
|
+
/** Render spec or single to MDX */
|
|
385
|
+
toMarkdown(options?: ExportMarkdownOptions): string;
|
|
386
|
+
/** Render spec or single to HTML */
|
|
387
|
+
toHTML(options?: HTMLOptions): string;
|
|
388
|
+
/** Render spec or single to JSON structure */
|
|
389
|
+
toJSON(options?: JSONOptions): SimplifiedSpec | SimplifiedExport;
|
|
390
|
+
/** Generate navigation structure */
|
|
391
|
+
toNavigation(options?: NavOptions): GenericNav | FumadocsMeta | DocusaurusSidebar;
|
|
392
|
+
/** Generate search index */
|
|
393
|
+
toSearchIndex(options?: SearchOptions): SearchIndex;
|
|
394
|
+
/** Generate Pagefind-compatible records */
|
|
395
|
+
toPagefindRecords(options?: SearchOptions): PagefindRecord[];
|
|
396
|
+
/** Generate Algolia-compatible records */
|
|
397
|
+
toAlgoliaRecords(options?: SearchOptions): AlgoliaRecord[];
|
|
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
|
+
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 };
|