@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/index.d.ts CHANGED
@@ -1,74 +1,5 @@
1
1
  import { BreakingSeverity, CategorizedBreaking, calculateNextVersion, categorizeBreakingChanges, diffSpec, diffSpec as diffSpec2, MemberChangeInfo, recommendSemverBump, SemverBump, SemverRecommendation, SpecDiff } from "@openpkg-ts/spec";
2
- import { OpenPkg, SpecExport, SpecExportKind } from "@openpkg-ts/spec";
3
- type Predicate = (exp: SpecExport) => boolean;
4
- /**
5
- * Chainable query builder for filtering OpenPkg exports.
6
- * Filters are lazy - predicates only run on execution methods (find, first, count, etc).
7
- */
8
- declare class QueryBuilder {
9
- private spec;
10
- private predicates;
11
- constructor(spec: OpenPkg);
12
- /**
13
- * Filter by kind(s)
14
- */
15
- byKind(...kinds: SpecExportKind[]): this;
16
- /**
17
- * Filter by name (exact string or regex pattern)
18
- */
19
- byName(pattern: string | RegExp): this;
20
- /**
21
- * Filter by tag(s) - must have at least one matching tag
22
- */
23
- byTag(...tags: string[]): this;
24
- /**
25
- * Filter by deprecation status
26
- * @param include - true = only deprecated, false = exclude deprecated, undefined = all
27
- */
28
- deprecated(include?: boolean): this;
29
- /**
30
- * Filter to exports with descriptions only
31
- */
32
- withDescription(): this;
33
- /**
34
- * Search name and description (case-insensitive)
35
- */
36
- search(term: string): this;
37
- /**
38
- * Custom predicate filter
39
- */
40
- where(predicate: Predicate): this;
41
- /**
42
- * Filter by source module/file path (contains match)
43
- */
44
- byModule(modulePath: string): this;
45
- private matches;
46
- /**
47
- * Execute query and return matching exports
48
- */
49
- find(): SpecExport[];
50
- /**
51
- * Execute query and return first match (or undefined)
52
- */
53
- first(): SpecExport | undefined;
54
- /**
55
- * Execute query and return count of matches
56
- */
57
- count(): number;
58
- /**
59
- * Execute query and return IDs of matching exports
60
- */
61
- ids(): string[];
62
- /**
63
- * Execute query and return a new filtered OpenPkg spec
64
- */
65
- toSpec(): OpenPkg;
66
- }
67
- /**
68
- * Create a query builder for the given spec
69
- */
70
- declare function query(spec: OpenPkg): QueryBuilder;
71
- import { OpenPkg as OpenPkg2 } from "@openpkg-ts/spec";
2
+ import { OpenPkg } from "@openpkg-ts/spec";
72
3
  /** Configuration for resolving external package re-exports */
73
4
  interface ExternalsConfig {
74
5
  /** Package patterns to resolve (globs supported, e.g., "@myorg/*") */
@@ -102,9 +33,13 @@ interface ExtractOptions {
102
33
  includePrivate?: boolean;
103
34
  /** Configuration for resolving external package re-exports */
104
35
  externals?: ExternalsConfig;
36
+ /** Max properties to serialize per object type (default: 20) */
37
+ maxProperties?: number;
38
+ /** Callback when properties are truncated */
39
+ onTruncation?: (typeName: string, actual: number, limit: number) => void;
105
40
  }
106
41
  interface ExtractResult {
107
- spec: OpenPkg2;
42
+ spec: OpenPkg;
108
43
  diagnostics: Diagnostic[];
109
44
  forgottenExports?: ForgottenExport[];
110
45
  /** Metadata about runtime schema extraction (when schemaExtraction: 'hybrid') */
@@ -117,6 +52,12 @@ interface ExtractResult {
117
52
  vendors: string[];
118
53
  /** Any errors encountered during runtime extraction */
119
54
  errors: string[];
55
+ /** Non-fatal warnings from extraction (e.g., individual schema failures) */
56
+ warnings: Array<{
57
+ code: string;
58
+ message: string;
59
+ exportName?: string;
60
+ }>;
120
61
  /** Extraction method used: 'compiled' or 'direct-ts (runtime)' */
121
62
  method?: string;
122
63
  };
@@ -222,7 +163,7 @@ declare function loadConfig(cwd: string): OpenpkgConfig | null;
222
163
  * @returns Merged config
223
164
  */
224
165
  declare function mergeConfig(fileConfig: OpenpkgConfig | null, cliOptions: Partial<OpenpkgConfig>): OpenpkgConfig;
225
- import { OpenPkg as OpenPkg3, SpecExport as SpecExport2 } from "@openpkg-ts/spec";
166
+ import { OpenPkg as OpenPkg2, SpecExport } from "@openpkg-ts/spec";
226
167
  interface DiagnosticItem {
227
168
  exportId: string;
228
169
  exportName: string;
@@ -243,20 +184,20 @@ interface SpecDiagnostics {
243
184
  /**
244
185
  * Check if has @deprecated tag.
245
186
  */
246
- declare function hasDeprecatedTag(exp: SpecExport2): boolean;
187
+ declare function hasDeprecatedTag(exp: SpecExport): boolean;
247
188
  /**
248
189
  * Get deprecation message from @deprecated tag.
249
190
  * Returns undefined if no reason provided.
250
191
  */
251
- declare function getDeprecationMessage(exp: SpecExport2): string | undefined;
192
+ declare function getDeprecationMessage(exp: SpecExport): string | undefined;
252
193
  /**
253
194
  * Find params without descriptions in JSDoc.
254
195
  */
255
- declare function findMissingParamDocs(exp: SpecExport2): string[];
196
+ declare function findMissingParamDocs(exp: SpecExport): string[];
256
197
  /**
257
198
  * Analyze a spec for quality issues.
258
199
  */
259
- declare function analyzeSpec(spec: OpenPkg3): SpecDiagnostics;
200
+ declare function analyzeSpec(spec: OpenPkg2): SpecDiagnostics;
260
201
  import { SpecMember } from "@openpkg-ts/spec";
261
202
  /**
262
203
  * Extract badge strings from a member's visibility and flags.
@@ -267,8 +208,8 @@ declare function getMemberBadges(member: SpecMember): string[];
267
208
  * Format badges array into a display string (space-separated).
268
209
  */
269
210
  declare function formatBadges(badges: string[]): string;
270
- import { OpenPkg as OpenPkg9, SpecExport as SpecExport4, SpecExportKind as SpecExportKind5, SpecType } from "@openpkg-ts/spec";
271
- import { OpenPkg as OpenPkg4 } from "@openpkg-ts/spec";
211
+ import { OpenPkg as OpenPkg8, SpecExport as SpecExport3, SpecExportKind as SpecExportKind4, SpecType } from "@openpkg-ts/spec";
212
+ import { OpenPkg as OpenPkg3 } from "@openpkg-ts/spec";
272
213
  interface HTMLOptions {
273
214
  /** Page title override */
274
215
  title?: string;
@@ -306,8 +247,8 @@ interface HTMLOptions {
306
247
  * const fragment = docs.toHTML({ export: 'greet', fullDocument: false })
307
248
  * ```
308
249
  */
309
- declare function toHTML2(spec: OpenPkg4, options?: HTMLOptions): string;
310
- import { OpenPkg as OpenPkg5, SpecExportKind as SpecExportKind2 } from "@openpkg-ts/spec";
250
+ declare function toHTML2(spec: OpenPkg3, options?: HTMLOptions): string;
251
+ import { OpenPkg as OpenPkg4, SpecExportKind } from "@openpkg-ts/spec";
311
252
  interface JSONOptions {
312
253
  /** Include raw spec data alongside simplified data */
313
254
  includeRaw?: boolean;
@@ -355,7 +296,7 @@ interface SimplifiedExample {
355
296
  interface SimplifiedExport {
356
297
  id: string;
357
298
  name: string;
358
- kind: SpecExportKind2;
299
+ kind: SpecExportKind;
359
300
  signature: string;
360
301
  description?: string;
361
302
  deprecated: boolean;
@@ -377,7 +318,7 @@ interface SimplifiedSpec {
377
318
  version?: string;
378
319
  description?: string;
379
320
  exports: SimplifiedExport[];
380
- byKind: Record<SpecExportKind2, SimplifiedExport[]>;
321
+ byKind: Record<SpecExportKind, SimplifiedExport[]>;
381
322
  totalExports: number;
382
323
  }
383
324
  /**
@@ -401,7 +342,7 @@ interface SimplifiedSpec {
401
342
  * // { id, name, kind, signature, parameters, returns, ... }
402
343
  * ```
403
344
  */
404
- declare function toJSON2(spec: OpenPkg5, options?: JSONOptions): SimplifiedSpec | SimplifiedExport;
345
+ declare function toJSON2(spec: OpenPkg4, options?: JSONOptions): SimplifiedSpec | SimplifiedExport;
405
346
  /**
406
347
  * Serialize to JSON string with formatting.
407
348
  *
@@ -409,10 +350,10 @@ declare function toJSON2(spec: OpenPkg5, options?: JSONOptions): SimplifiedSpec
409
350
  * @param options - JSON options plus pretty formatting option
410
351
  * @returns JSON string
411
352
  */
412
- declare function toJSONString(spec: OpenPkg5, options?: JSONOptions & {
353
+ declare function toJSONString(spec: OpenPkg4, options?: JSONOptions & {
413
354
  pretty?: boolean;
414
355
  }): string;
415
- import { OpenPkg as OpenPkg6, SpecExport as SpecExport3 } from "@openpkg-ts/spec";
356
+ import { OpenPkg as OpenPkg5, SpecExport as SpecExport2 } from "@openpkg-ts/spec";
416
357
  interface MarkdownOptions {
417
358
  /** Include frontmatter in output */
418
359
  frontmatter?: boolean;
@@ -458,7 +399,7 @@ interface ExportMarkdownOptions extends MarkdownOptions {
458
399
  * })
459
400
  * ```
460
401
  */
461
- declare function exportToMarkdown(exp: SpecExport3, options?: MarkdownOptions): string;
402
+ declare function exportToMarkdown(exp: SpecExport2, options?: MarkdownOptions): string;
462
403
  /**
463
404
  * Render entire spec to MDX.
464
405
  *
@@ -478,8 +419,8 @@ declare function exportToMarkdown(exp: SpecExport3, options?: MarkdownOptions):
478
419
  * // Single * const fnMdx = docs.toMarkdown({ export: 'greet' })
479
420
  * ```
480
421
  */
481
- declare function toMarkdown2(spec: OpenPkg6, options?: ExportMarkdownOptions): string;
482
- import { OpenPkg as OpenPkg7, SpecExportKind as SpecExportKind3 } from "@openpkg-ts/spec";
422
+ declare function toMarkdown2(spec: OpenPkg5, options?: ExportMarkdownOptions): string;
423
+ import { OpenPkg as OpenPkg6, SpecExportKind as SpecExportKind2 } from "@openpkg-ts/spec";
483
424
  type NavFormat = "fumadocs" | "docusaurus" | "generic";
484
425
  type GroupBy = "kind" | "module" | "tag" | "none";
485
426
  interface NavOptions {
@@ -494,7 +435,7 @@ interface NavOptions {
494
435
  /** Include index pages for groups */
495
436
  includeGroupIndex?: boolean;
496
437
  /** Custom kind labels */
497
- kindLabels?: Partial<Record<SpecExportKind3, string>>;
438
+ kindLabels?: Partial<Record<SpecExportKind2, string>>;
498
439
  /** Sort exports alphabetically */
499
440
  sortAlphabetically?: boolean;
500
441
  }
@@ -554,7 +495,7 @@ type DocusaurusSidebar = DocusaurusSidebarItem[];
554
495
  * const sidebar = docs.toNavigation({ format: 'docusaurus' })
555
496
  * ```
556
497
  */
557
- declare function toNavigation2(spec: OpenPkg7, options?: NavOptions): GenericNav | FumadocsMeta | DocusaurusSidebar;
498
+ declare function toNavigation2(spec: OpenPkg6, options?: NavOptions): GenericNav | FumadocsMeta | DocusaurusSidebar;
558
499
  /**
559
500
  * Generate Fumadocs meta.json file content.
560
501
  *
@@ -568,7 +509,7 @@ declare function toNavigation2(spec: OpenPkg7, options?: NavOptions): GenericNav
568
509
  * fs.writeFileSync('docs/api/meta.json', meta)
569
510
  * ```
570
511
  */
571
- declare function toFumadocsMetaJSON(spec: OpenPkg7, options?: Omit<NavOptions, "format">): string;
512
+ declare function toFumadocsMetaJSON(spec: OpenPkg6, options?: Omit<NavOptions, "format">): string;
572
513
  /**
573
514
  * Generate Docusaurus sidebar config.
574
515
  *
@@ -582,8 +523,8 @@ declare function toFumadocsMetaJSON(spec: OpenPkg7, options?: Omit<NavOptions, "
582
523
  * fs.writeFileSync('sidebars.js', sidebar)
583
524
  * ```
584
525
  */
585
- declare function toDocusaurusSidebarJS(spec: OpenPkg7, options?: Omit<NavOptions, "format">): string;
586
- import { OpenPkg as OpenPkg8, SpecExportKind as SpecExportKind4 } from "@openpkg-ts/spec";
526
+ declare function toDocusaurusSidebarJS(spec: OpenPkg6, options?: Omit<NavOptions, "format">): string;
527
+ import { OpenPkg as OpenPkg7, SpecExportKind as SpecExportKind3 } from "@openpkg-ts/spec";
587
528
  interface SearchOptions {
588
529
  /** Base URL for search result links */
589
530
  baseUrl?: string;
@@ -627,7 +568,7 @@ interface PagefindRecord {
627
568
  interface AlgoliaRecord {
628
569
  objectID: string;
629
570
  name: string;
630
- kind: SpecExportKind4;
571
+ kind: SpecExportKind3;
631
572
  description?: string;
632
573
  signature: string;
633
574
  content: string;
@@ -647,7 +588,7 @@ interface AlgoliaRecord {
647
588
  interface SearchRecord {
648
589
  id: string;
649
590
  name: string;
650
- kind: SpecExportKind4;
591
+ kind: SpecExportKind3;
651
592
  signature: string;
652
593
  description?: string;
653
594
  content: string;
@@ -676,7 +617,7 @@ interface SearchIndex {
676
617
  * // { records: [...], version: '1.0.0', packageName: 'my-lib' }
677
618
  * ```
678
619
  */
679
- declare function toSearchIndex2(spec: OpenPkg8, options?: SearchOptions): SearchIndex;
620
+ declare function toSearchIndex2(spec: OpenPkg7, options?: SearchOptions): SearchIndex;
680
621
  /**
681
622
  * Generate Pagefind-compatible records.
682
623
  *
@@ -692,7 +633,7 @@ declare function toSearchIndex2(spec: OpenPkg8, options?: SearchOptions): Search
692
633
  * })
693
634
  * ```
694
635
  */
695
- declare function toPagefindRecords2(spec: OpenPkg8, options?: SearchOptions): PagefindRecord[];
636
+ declare function toPagefindRecords2(spec: OpenPkg7, options?: SearchOptions): PagefindRecord[];
696
637
  /**
697
638
  * Generate Algolia-compatible records.
698
639
  *
@@ -706,7 +647,7 @@ declare function toPagefindRecords2(spec: OpenPkg8, options?: SearchOptions): Pa
706
647
  * // Upload to Algolia index
707
648
  * ```
708
649
  */
709
- declare function toAlgoliaRecords2(spec: OpenPkg8, options?: SearchOptions): AlgoliaRecord[];
650
+ declare function toAlgoliaRecords2(spec: OpenPkg7, options?: SearchOptions): AlgoliaRecord[];
710
651
  /**
711
652
  * Serialize search index to JSON string.
712
653
  *
@@ -720,36 +661,36 @@ declare function toAlgoliaRecords2(spec: OpenPkg8, options?: SearchOptions): Alg
720
661
  * fs.writeFileSync('search-index.json', json)
721
662
  * ```
722
663
  */
723
- declare function toSearchIndexJSON(spec: OpenPkg8, options?: SearchOptions & {
664
+ declare function toSearchIndexJSON(spec: OpenPkg7, options?: SearchOptions & {
724
665
  pretty?: boolean;
725
666
  }): string;
726
667
  interface LoadOptions {
727
668
  /** Path to openpkg.json file or the spec object directly */
728
- input: string | OpenPkg9;
669
+ input: string | OpenPkg8;
729
670
  }
730
671
  interface DocsInstance {
731
672
  /** The parsed OpenPkg spec */
732
- spec: OpenPkg9;
673
+ spec: OpenPkg8;
733
674
  /** Get an by its ID */
734
- getExport(id: string): SpecExport4 | undefined;
675
+ getExport(id: string): SpecExport3 | undefined;
735
676
  /** Get a type definition by its ID */
736
677
  getType(id: string): SpecType | undefined;
737
678
  /** Get all exports of a specific kind */
738
- getExportsByKind(kind: SpecExportKind5): SpecExport4[];
679
+ getExportsByKind(kind: SpecExportKind4): SpecExport3[];
739
680
  /** Get all exports */
740
- getAllExports(): SpecExport4[];
681
+ getAllExports(): SpecExport3[];
741
682
  /** Get all type definitions */
742
683
  getAllTypes(): SpecType[];
743
684
  /** Get exports by JSDoc tag (e.g., '@beta', '@internal') */
744
- getExportsByTag(tagName: string): SpecExport4[];
685
+ getExportsByTag(tagName: string): SpecExport3[];
745
686
  /** Search exports by name or description */
746
- search(query: string): SpecExport4[];
687
+ search(query: string): SpecExport3[];
747
688
  /** Get exports belonging to a specific module/namespace */
748
- getModule(moduleName: string): SpecExport4[];
689
+ getModule(moduleName: string): SpecExport3[];
749
690
  /** Get deprecated exports */
750
- getDeprecated(): SpecExport4[];
691
+ getDeprecated(): SpecExport3[];
751
692
  /** Get exports grouped by kind */
752
- groupByKind(): Record<SpecExportKind5, SpecExport4[]>;
693
+ groupByKind(): Record<SpecExportKind4, SpecExport3[]>;
753
694
  /** Render spec or single to MDX */
754
695
  toMarkdown(options?: ExportMarkdownOptions): string;
755
696
  /** Render spec or single to HTML */
@@ -777,7 +718,7 @@ interface DocsInstance {
777
718
  * const docs = loadSpec(spec)
778
719
  * ```
779
720
  */
780
- declare function loadSpec(spec: OpenPkg9): DocsInstance;
721
+ declare function loadSpec(spec: OpenPkg8): DocsInstance;
781
722
  /**
782
723
  * Creates a docs instance for querying and rendering API documentation.
783
724
  *
@@ -799,8 +740,8 @@ declare function loadSpec(spec: OpenPkg9): DocsInstance;
799
740
  * docs.search('hook')
800
741
  * ```
801
742
  */
802
- declare function createDocs(input: string | OpenPkg9): DocsInstance;
803
- import { OpenPkg as OpenPkg10, SpecExport as SpecExport5, SpecMember as SpecMember2, SpecSchema, SpecSignature, SpecType as SpecType2, SpecTypeParameter } from "@openpkg-ts/spec";
743
+ declare function createDocs(input: string | OpenPkg8): DocsInstance;
744
+ import { OpenPkg as OpenPkg9, SpecExport as SpecExport4, SpecMember as SpecMember2, SpecSchema, SpecSignature, SpecType as SpecType2, SpecTypeParameter } from "@openpkg-ts/spec";
804
745
  interface FormatSchemaOptions {
805
746
  /** Include package attribution for external types */
806
747
  includePackage?: boolean;
@@ -881,7 +822,7 @@ declare function formatReturnType(sig?: SpecSignature): string;
881
822
  * // 'class Logger extends EventEmitter'
882
823
  * ```
883
824
  */
884
- declare function buildSignatureString(exp: SpecExport5, sigIndex?: number): string;
825
+ declare function buildSignatureString(exp: SpecExport4, sigIndex?: number): string;
885
826
  /**
886
827
  * Resolve a type reference to its definition.
887
828
  *
@@ -895,7 +836,7 @@ declare function buildSignatureString(exp: SpecExport5, sigIndex?: number): stri
895
836
  * // { id: 'User', name: 'User', kind: 'interface', ... }
896
837
  * ```
897
838
  */
898
- declare function resolveTypeRef(ref: string, spec: OpenPkg10): SpecType2 | undefined;
839
+ declare function resolveTypeRef(ref: string, spec: OpenPkg9): SpecType2 | undefined;
899
840
  /**
900
841
  * Check if a member is a method (has signatures).
901
842
  *
@@ -1010,6 +951,75 @@ declare function formatConditionalType(condType: SpecConditionalType): string;
1010
951
  * ```
1011
952
  */
1012
953
  declare function formatMappedType(mappedType: SpecMappedType): string;
954
+ import { OpenPkg as OpenPkg10, SpecExport as SpecExport5, SpecExportKind as SpecExportKind5 } from "@openpkg-ts/spec";
955
+ type Predicate = (exp: SpecExport5) => boolean;
956
+ /**
957
+ * Chainable query builder for filtering OpenPkg exports.
958
+ * Filters are lazy - predicates only run on execution methods (find, first, count, etc).
959
+ */
960
+ declare class QueryBuilder {
961
+ private spec;
962
+ private predicates;
963
+ constructor(spec: OpenPkg10);
964
+ /**
965
+ * Filter by kind(s)
966
+ */
967
+ byKind(...kinds: SpecExportKind5[]): this;
968
+ /**
969
+ * Filter by name (exact string or regex pattern)
970
+ */
971
+ byName(pattern: string | RegExp): this;
972
+ /**
973
+ * Filter by tag(s) - must have at least one matching tag
974
+ */
975
+ byTag(...tags: string[]): this;
976
+ /**
977
+ * Filter by deprecation status
978
+ * @param include - true = only deprecated, false = exclude deprecated, undefined = all
979
+ */
980
+ deprecated(include?: boolean): this;
981
+ /**
982
+ * Filter to exports with descriptions only
983
+ */
984
+ withDescription(): this;
985
+ /**
986
+ * Search name and description (case-insensitive)
987
+ */
988
+ search(term: string): this;
989
+ /**
990
+ * Custom predicate filter
991
+ */
992
+ where(predicate: Predicate): this;
993
+ /**
994
+ * Filter by source module/file path (contains match)
995
+ */
996
+ byModule(modulePath: string): this;
997
+ private matches;
998
+ /**
999
+ * Execute query and return matching exports
1000
+ */
1001
+ find(): SpecExport5[];
1002
+ /**
1003
+ * Execute query and return first match (or undefined)
1004
+ */
1005
+ first(): SpecExport5 | undefined;
1006
+ /**
1007
+ * Execute query and return count of matches
1008
+ */
1009
+ count(): number;
1010
+ /**
1011
+ * Execute query and return IDs of matching exports
1012
+ */
1013
+ ids(): string[];
1014
+ /**
1015
+ * Execute query and return a new filtered OpenPkg spec
1016
+ */
1017
+ toSpec(): OpenPkg10;
1018
+ }
1019
+ /**
1020
+ * Create a query builder for the given spec
1021
+ */
1022
+ declare function query(spec: OpenPkg10): QueryBuilder;
1013
1023
  import { OpenPkg as OpenPkg11 } from "@openpkg-ts/spec";
1014
1024
  interface ReactLayoutOptions {
1015
1025
  /** Output directory for generated files */
@@ -1165,6 +1175,10 @@ interface SerializerContext {
1165
1175
  inTupleElement?: boolean;
1166
1176
  /** Include private/protected class members (default: false) */
1167
1177
  includePrivate?: boolean;
1178
+ /** Max properties to serialize per object type (default: 20) */
1179
+ maxProperties: number;
1180
+ /** Callback when properties are truncated */
1181
+ onTruncation?: (typeName: string, actual: number, limit: number) => void;
1168
1182
  }
1169
1183
  declare class TypeRegistry {
1170
1184
  private types;
@@ -1296,11 +1310,34 @@ interface ExtractStandardSchemasOptions {
1296
1310
  libraryOptions?: Record<string, unknown>;
1297
1311
  }
1298
1312
  /**
1313
+ * Warning codes for extraction diagnostics.
1314
+ *
1315
+ * - `SCHEMA_FAILED`: Standard Schema extraction failed (e.g., ~standard.jsonSchema.output() threw)
1316
+ * - `TYPEBOX_FAILED`: TypeBox schema sanitization failed
1317
+ * - `PARSE_FAILED`: Failed to parse subprocess JSON output
1318
+ * - `CLEANUP_FAILED`: Failed to delete temp worker script file
1319
+ * - `TSCONFIG_INVALID`: Could not parse tsconfig.json (uses defaults)
1320
+ */
1321
+ type ExtractionWarningCode = "SCHEMA_FAILED" | "TYPEBOX_FAILED" | "PARSE_FAILED" | "CLEANUP_FAILED" | "TSCONFIG_INVALID" | "OUTPUT_TRUNCATED";
1322
+ /**
1323
+ * Warning from extraction process.
1324
+ * Captures non-fatal issues during schema extraction.
1325
+ */
1326
+ interface ExtractionWarning {
1327
+ /** Warning type identifier */
1328
+ code: ExtractionWarningCode;
1329
+ /** Human-readable description */
1330
+ message: string;
1331
+ /** Export name if applicable */
1332
+ exportName?: string;
1333
+ }
1334
+ /**
1299
1335
  * Result of Standard Schema extraction.
1300
1336
  */
1301
1337
  interface StandardSchemaExtractionOutput {
1302
1338
  schemas: Map<string, StandardSchemaExtractionResult>;
1303
1339
  errors: string[];
1340
+ warnings: ExtractionWarning[];
1304
1341
  }
1305
1342
  /**
1306
1343
  * Check if an object implements StandardJSONSchemaV1.
@@ -1387,21 +1424,124 @@ interface ProjectExtractionOutput extends StandardSchemaExtractionOutput {
1387
1424
  * @param options - Extraction options
1388
1425
  */
1389
1426
  declare function extractStandardSchemasFromProject(entryFile: string, baseDir: string, options?: ExtractFromProjectOptions): Promise<ProjectExtractionOutput>;
1427
+ /**
1428
+ * LRU Cache implementation with optional TTL support.
1429
+ * Used for bounded caching in spec extraction to prevent memory leaks.
1430
+ */
1431
+ interface CacheManagerOptions {
1432
+ /** Maximum number of entries (default: 1000) */
1433
+ maxSize?: number;
1434
+ /** Time-to-live in milliseconds (optional, no expiry if not set) */
1435
+ ttl?: number;
1436
+ }
1437
+ /**
1438
+ * Bounded LRU cache with optional TTL.
1439
+ *
1440
+ * @example
1441
+ * ```ts
1442
+ * const cache = new CacheManager<string, number>({ maxSize: 100 });
1443
+ * cache.set('key', 42);
1444
+ * cache.get('key'); // 42
1445
+ * cache.clear();
1446
+ * ```
1447
+ */
1448
+ declare class CacheManager<
1449
+ K,
1450
+ V
1451
+ > {
1452
+ private cache;
1453
+ private readonly maxSize;
1454
+ private readonly ttl?;
1455
+ constructor(options?: CacheManagerOptions);
1456
+ /**
1457
+ * Get a value from the cache.
1458
+ * Returns undefined if not found or expired.
1459
+ * Moves accessed entry to end (most recently used).
1460
+ */
1461
+ get(key: K): V | undefined;
1462
+ /**
1463
+ * Check if key exists (without affecting LRU order).
1464
+ */
1465
+ has(key: K): boolean;
1466
+ /**
1467
+ * Set a value in the cache.
1468
+ * Evicts least recently used entry if at capacity.
1469
+ */
1470
+ set(key: K, value: V): void;
1471
+ /**
1472
+ * Delete a specific key from the cache.
1473
+ */
1474
+ delete(key: K): boolean;
1475
+ /**
1476
+ * Clear all entries from the cache.
1477
+ */
1478
+ clear(): void;
1479
+ /**
1480
+ * Get the current number of entries.
1481
+ */
1482
+ get size(): number;
1483
+ /**
1484
+ * Get all keys (for debugging/testing).
1485
+ */
1486
+ keys(): IterableIterator<K>;
1487
+ /**
1488
+ * Get all values (for debugging/testing).
1489
+ */
1490
+ values(): V[];
1491
+ }
1492
+ /**
1493
+ * Extract API specification from TypeScript source files.
1494
+ *
1495
+ * Analyzes exports from the entry file, serializes them to OpenPkg spec format,
1496
+ * and detects forgotten exports (types referenced but not exported).
1497
+ *
1498
+ * @param options - Extraction configuration
1499
+ * @param options.entryFile - Path to the entry TypeScript file
1500
+ * @param options.baseDir - Base directory for resolving imports (defaults to entryFile dir)
1501
+ * @param options.content - Optional in-memory source content (skips file read)
1502
+ * @param options.maxTypeDepth - Max depth for nested type resolution (default: 10)
1503
+ * @param options.only - Glob patterns to include (e.g., ["get*", "create*"])
1504
+ * @param options.ignore - Glob patterns to exclude (e.g., ["*Internal", "_*"])
1505
+ * @param options.onProgress - Callback fired for each export: (current, total, name) => void
1506
+ * @param options.isDtsSource - Set true when extracting from .d.ts (enables degraded mode)
1507
+ * @param options.externals - Config for resolving re-exports from external packages
1508
+ *
1509
+ * @returns Promise resolving to extraction result
1510
+ * @returns result.spec - The OpenPkg specification object
1511
+ * @returns result.diagnostics - Warnings/errors encountered during extraction
1512
+ * @returns result.verification - Stats comparing discovered vs extracted exports
1513
+ * @returns result.forgottenExports - Types referenced but not exported (internal only)
1514
+ *
1515
+ * @example
1516
+ * ```ts
1517
+ * import { extract } from '@openpkg-ts/sdk';
1518
+ *
1519
+ * const { spec, diagnostics } = await extract({
1520
+ * entryFile: './src/index.ts',
1521
+ * onProgress: (i, total, name) => console.log(`${i}/${total}: ${name}`),
1522
+ * });
1523
+ * ```
1524
+ *
1525
+ * @remarks
1526
+ * - Caches are cleared before and after extraction (via try/finally)
1527
+ * - Progress callback yields to event loop every 5 exports for UI responsiveness
1528
+ * - External package re-exports require explicit `externals.include` patterns
1529
+ */
1390
1530
  declare function extract(options: ExtractOptions): Promise<ExtractResult>;
1391
- import ts5 from "typescript";
1531
+ import ts7 from "typescript";
1392
1532
  interface ProgramOptions {
1393
1533
  entryFile: string;
1394
1534
  baseDir?: string;
1395
1535
  content?: string;
1396
1536
  }
1397
1537
  interface ProgramResult {
1398
- program: ts5.Program;
1399
- compilerHost: ts5.CompilerHost;
1400
- compilerOptions: ts5.CompilerOptions;
1401
- sourceFile?: ts5.SourceFile;
1538
+ program: ts7.Program;
1539
+ compilerHost: ts7.CompilerHost;
1540
+ compilerOptions: ts7.CompilerOptions;
1541
+ sourceFile?: ts7.SourceFile;
1402
1542
  configPath?: string;
1403
1543
  /** Resolved project references (workspace packages) */
1404
- projectReferences?: ts5.ResolvedProjectReference[];
1544
+ projectReferences?: ts7.ResolvedProjectReference[];
1405
1545
  }
1406
1546
  declare function createProgram({ entryFile, baseDir, content }: ProgramOptions): ProgramResult;
1407
1547
  import * as TS from "typescript";
@@ -1457,34 +1597,34 @@ declare const arktypeAdapter: SchemaAdapter;
1457
1597
  declare const typeboxAdapter: SchemaAdapter;
1458
1598
  declare const valibotAdapter: SchemaAdapter;
1459
1599
  declare const zodAdapter: SchemaAdapter;
1460
- import { SpecExport as SpecExport8 } from "@openpkg-ts/spec";
1461
- import ts6 from "typescript";
1462
- declare function serializeClass(node: ts6.ClassDeclaration, ctx: SerializerContext): SpecExport8 | null;
1463
1600
  import { SpecExport as SpecExport9 } from "@openpkg-ts/spec";
1464
- import ts7 from "typescript";
1465
- declare function serializeEnum(node: ts7.EnumDeclaration, ctx: SerializerContext): SpecExport9 | null;
1466
- import { SpecExport as SpecExport10 } from "@openpkg-ts/spec";
1467
1601
  import ts8 from "typescript";
1468
- declare function serializeFunctionExport(node: ts8.FunctionDeclaration | ts8.ArrowFunction, ctx: SerializerContext, nameOverride?: string): SpecExport10 | null;
1469
- import { SpecExport as SpecExport11 } from "@openpkg-ts/spec";
1602
+ declare function serializeClass(node: ts8.ClassDeclaration, ctx: SerializerContext): SpecExport9 | null;
1603
+ import { SpecExport as SpecExport10 } from "@openpkg-ts/spec";
1470
1604
  import ts9 from "typescript";
1471
- declare function serializeInterface(node: ts9.InterfaceDeclaration, ctx: SerializerContext): SpecExport11 | null;
1472
- import { SpecExport as SpecExport12 } from "@openpkg-ts/spec";
1605
+ declare function serializeEnum(node: ts9.EnumDeclaration, ctx: SerializerContext): SpecExport10 | null;
1606
+ import { SpecExport as SpecExport11 } from "@openpkg-ts/spec";
1473
1607
  import ts10 from "typescript";
1474
- declare function serializeTypeAlias(node: ts10.TypeAliasDeclaration, ctx: SerializerContext): SpecExport12 | null;
1475
- import { SpecExport as SpecExport13 } from "@openpkg-ts/spec";
1608
+ declare function serializeFunctionExport(node: ts10.FunctionDeclaration | ts10.ArrowFunction, ctx: SerializerContext, nameOverride?: string): SpecExport11 | null;
1609
+ import { SpecExport as SpecExport12 } from "@openpkg-ts/spec";
1476
1610
  import ts11 from "typescript";
1477
- declare function serializeVariable(node: ts11.VariableDeclaration, statement: ts11.VariableStatement, ctx: SerializerContext): SpecExport13 | null;
1478
- import { SpecSignatureParameter } from "@openpkg-ts/spec";
1611
+ declare function serializeInterface(node: ts11.InterfaceDeclaration, ctx: SerializerContext): SpecExport12 | null;
1612
+ import { SpecExport as SpecExport13 } from "@openpkg-ts/spec";
1479
1613
  import ts12 from "typescript";
1480
- declare function extractParameters(signature: ts12.Signature, ctx: SerializerContext): SpecSignatureParameter[];
1614
+ declare function serializeTypeAlias(node: ts12.TypeAliasDeclaration, ctx: SerializerContext): SpecExport13 | null;
1615
+ import { SpecExport as SpecExport14 } from "@openpkg-ts/spec";
1616
+ import ts13 from "typescript";
1617
+ declare function serializeVariable(node: ts13.VariableDeclaration, statement: ts13.VariableStatement, ctx: SerializerContext): SpecExport14 | null;
1618
+ import { SpecSignatureParameter } from "@openpkg-ts/spec";
1619
+ import ts14 from "typescript";
1620
+ declare function extractParameters(signature: ts14.Signature, ctx: SerializerContext): SpecSignatureParameter[];
1481
1621
  /**
1482
1622
  * Recursively register types referenced by a ts.Type.
1483
1623
  * Uses ctx.visitedTypes to prevent infinite recursion on circular types.
1484
1624
  */
1485
- declare function registerReferencedTypes(type: ts12.Type, ctx: SerializerContext, depth?: number): void;
1625
+ declare function registerReferencedTypes(type: ts14.Type, ctx: SerializerContext, depth?: number): void;
1486
1626
  import { SpecSchema as SpecSchema2 } from "@openpkg-ts/spec";
1487
- import ts13 from "typescript";
1627
+ import ts15 from "typescript";
1488
1628
  /**
1489
1629
  * Built-in type schemas with JSON Schema format hints.
1490
1630
  * Used for types that have specific serialization formats.
@@ -1503,7 +1643,7 @@ declare function isPrimitiveName(name: string): boolean;
1503
1643
  * getTypeOrigin(trpcRouterType) // Returns '@trpc/server'
1504
1644
  * getTypeOrigin(localUserType) // Returns undefined
1505
1645
  */
1506
- declare function getTypeOrigin(type: ts13.Type, _checker: ts13.TypeChecker): string | undefined;
1646
+ declare function getTypeOrigin(type: ts15.Type, _checker: ts15.TypeChecker): string | undefined;
1507
1647
  /**
1508
1648
  * Check if a name is a built-in generic type
1509
1649
  */
@@ -1511,18 +1651,18 @@ declare function isBuiltinGeneric(name: string): boolean;
1511
1651
  /**
1512
1652
  * Check if a type is anonymous (no meaningful symbol name)
1513
1653
  */
1514
- declare function isAnonymous(type: ts13.Type): boolean;
1654
+ declare function isAnonymous(type: ts15.Type): boolean;
1515
1655
  /**
1516
1656
  * Ensure schema is non-empty — fallback to x-ts-type string representation if empty.
1517
1657
  * Never emit {} as a schema; always include meaningful type info.
1518
1658
  */
1519
- declare function ensureNonEmptySchema(schema: SpecSchema2, type: ts13.Type, checker: ts13.TypeChecker): SpecSchema2;
1659
+ declare function ensureNonEmptySchema(schema: SpecSchema2, type: ts15.Type, checker: ts15.TypeChecker): SpecSchema2;
1520
1660
  /**
1521
1661
  * Build a structured SpecSchema from a TypeScript type.
1522
1662
  * Uses $ref for named types and typeArguments for generics.
1523
1663
  * Guarantees non-empty schema output via ensureNonEmptySchema wrapper.
1524
1664
  */
1525
- declare function buildSchema(type: ts13.Type, checker: ts13.TypeChecker, ctx?: SerializerContext, _depth?: number): SpecSchema2;
1665
+ declare function buildSchema(type: ts15.Type, checker: ts15.TypeChecker, ctx?: SerializerContext, _depth?: number): SpecSchema2;
1526
1666
  /**
1527
1667
  * Check if a schema is a pure $ref (only has $ref property)
1528
1668
  */
@@ -1550,8 +1690,8 @@ declare function deduplicateSchemas(schemas: SpecSchema2[]): SpecSchema2[];
1550
1690
  * Find a discriminator property in a union of object types (tagged union pattern).
1551
1691
  * A valid discriminator has a unique literal value in each union member.
1552
1692
  */
1553
- declare function findDiscriminatorProperty(unionTypes: ts13.Type[], checker: ts13.TypeChecker): string | undefined;
1554
- import { SpecExport as SpecExport14, SpecMember as SpecMember3, SpecSchema as SpecSchema3, SpecType as SpecType5 } from "@openpkg-ts/spec";
1693
+ declare function findDiscriminatorProperty(unionTypes: ts15.Type[], checker: ts15.TypeChecker): string | undefined;
1694
+ import { SpecExport as SpecExport15, SpecMember as SpecMember3, SpecSchema as SpecSchema3, SpecType as SpecType6 } from "@openpkg-ts/spec";
1555
1695
  /**
1556
1696
  * Options for schema normalization
1557
1697
  */
@@ -1582,7 +1722,7 @@ declare function normalizeSchema(schema: SpecSchema3, options?: NormalizeOptions
1582
1722
  * 2. Normalize member schemas
1583
1723
  * 3. Generate a JSON Schema from members if members exist (populates `schema` field)
1584
1724
  */
1585
- declare function normalizeExport(exp: SpecExport14, options?: NormalizeOptions): SpecExport14;
1725
+ declare function normalizeExport(exp: SpecExport15, options?: NormalizeOptions): SpecExport15;
1586
1726
  /**
1587
1727
  * Normalize a SpecType, normalizing its schema and nested schemas.
1588
1728
  *
@@ -1591,7 +1731,7 @@ declare function normalizeExport(exp: SpecExport14, options?: NormalizeOptions):
1591
1731
  * 2. Normalize member schemas
1592
1732
  * 3. Generate a JSON Schema from members if members exist (populates `schema` field)
1593
1733
  */
1594
- declare function normalizeType(type: SpecType5, options?: NormalizeOptions): SpecType5;
1734
+ declare function normalizeType(type: SpecType6, options?: NormalizeOptions): SpecType6;
1595
1735
  /**
1596
1736
  * Convert a members array to JSON Schema properties format.
1597
1737
  *
@@ -1613,7 +1753,7 @@ declare function normalizeType(type: SpecType5, options?: NormalizeOptions): Spe
1613
1753
  * @returns JSON Schema object with properties, required, and additionalProperties
1614
1754
  */
1615
1755
  declare function normalizeMembers(members: SpecMember3[], options?: NormalizeOptions): JSONSchema;
1616
- import ts14 from "typescript";
1617
- declare function isExported(node: ts14.Node): boolean;
1618
- declare function getNodeName(node: ts14.Node): string | undefined;
1619
- export { zodAdapter, withDescription2 as withDescription, valibotAdapter, typeboxAdapter, toSearchIndexJSON, toSearchIndex2 as toSearchIndex, toReactString, toReact, 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, query, normalizeType, normalizeSchema, normalizeMembers, normalizeExport, mergeConfig, loadSpec, loadConfig, 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, SkippedExportDetail, SimplifiedSpec, SimplifiedSignature, SimplifiedReturn, SimplifiedParameter, SimplifiedMember, SimplifiedExport, SimplifiedExample, SerializerContext, SemverRecommendation, SemverBump, SearchRecord, SearchOptions, SearchIndex, SchemaExtractionResult, SchemaAdapter, ReactLayoutOptions, QueryBuilder, ProjectExtractionOutput, ProjectExtractionInfo, ProgramResult, ProgramOptions, PagefindRecord, OpenpkgConfig, 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, ExternalsConfig, ExportVerification, ExportTracker, ExportMarkdownOptions, ExportItem, DocusaurusSidebarItem, DocusaurusSidebar, DocsInstance, DiagnosticItem, Diagnostic, CategorizedBreaking, CONFIG_FILENAME, BreakingSeverity, BUILTIN_TYPE_SCHEMAS, AlgoliaRecord, ARRAY_PROTOTYPE_METHODS };
1756
+ import ts16 from "typescript";
1757
+ declare function isExported(node: ts16.Node): boolean;
1758
+ declare function getNodeName(node: ts16.Node): string | undefined;
1759
+ export { zodAdapter, withDescription2 as withDescription, valibotAdapter, typeboxAdapter, toSearchIndexJSON, toSearchIndex2 as toSearchIndex, toReactString, toReact, 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, query, normalizeType, normalizeSchema, normalizeMembers, normalizeExport, mergeConfig, loadSpec, loadConfig, 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, SkippedExportDetail, SimplifiedSpec, SimplifiedSignature, SimplifiedReturn, SimplifiedParameter, SimplifiedMember, SimplifiedExport, SimplifiedExample, SerializerContext, SemverRecommendation, SemverBump, SearchRecord, SearchOptions, SearchIndex, SchemaExtractionResult, SchemaAdapter, ReactLayoutOptions, QueryBuilder, ProjectExtractionOutput, ProjectExtractionInfo, ProgramResult, ProgramOptions, PagefindRecord, OpenpkgConfig, NormalizeOptions, NavOptions, NavItem, NavGroup, NavFormat, MemberChangeInfo, MarkdownOptions, LoadOptions, ListExportsResult, ListExportsOptions, JSONSchema, JSONOptions, HTMLOptions, GroupBy, GetExportResult, GetExportOptions, GenericNav, FumadocsMetaItem, FumadocsMeta, FormatSchemaOptions, ForgottenExport, FilterResult, FilterCriteria, ExtractionWarningCode, ExtractionWarning, ExtractStandardSchemasOptions, ExtractResult, ExtractOptions, ExtractFromProjectOptions, ExternalsConfig, ExportVerification, ExportTracker, ExportMarkdownOptions, ExportItem, DocusaurusSidebarItem, DocusaurusSidebar, DocsInstance, DiagnosticItem, Diagnostic, CategorizedBreaking, CacheManagerOptions, CacheManager, CONFIG_FILENAME, BreakingSeverity, BUILTIN_TYPE_SCHEMAS, AlgoliaRecord, ARRAY_PROTOTYPE_METHODS };