@prodisco/search-libs 0.1.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.
Files changed (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +379 -0
  3. package/dist/__tests__/extractor.test.d.ts +5 -0
  4. package/dist/__tests__/extractor.test.d.ts.map +1 -0
  5. package/dist/__tests__/extractor.test.js +452 -0
  6. package/dist/__tests__/extractor.test.js.map +1 -0
  7. package/dist/__tests__/library-indexer.test.d.ts +5 -0
  8. package/dist/__tests__/library-indexer.test.d.ts.map +1 -0
  9. package/dist/__tests__/library-indexer.test.js +611 -0
  10. package/dist/__tests__/library-indexer.test.js.map +1 -0
  11. package/dist/__tests__/schema.test.d.ts +5 -0
  12. package/dist/__tests__/schema.test.d.ts.map +1 -0
  13. package/dist/__tests__/schema.test.js +231 -0
  14. package/dist/__tests__/schema.test.js.map +1 -0
  15. package/dist/__tests__/script-parser.test.d.ts +5 -0
  16. package/dist/__tests__/script-parser.test.d.ts.map +1 -0
  17. package/dist/__tests__/script-parser.test.js +178 -0
  18. package/dist/__tests__/script-parser.test.js.map +1 -0
  19. package/dist/__tests__/search-engine.test.d.ts +5 -0
  20. package/dist/__tests__/search-engine.test.d.ts.map +1 -0
  21. package/dist/__tests__/search-engine.test.js +497 -0
  22. package/dist/__tests__/search-engine.test.js.map +1 -0
  23. package/dist/extractor/ast-parser.d.ts +48 -0
  24. package/dist/extractor/ast-parser.d.ts.map +1 -0
  25. package/dist/extractor/ast-parser.js +118 -0
  26. package/dist/extractor/ast-parser.js.map +1 -0
  27. package/dist/extractor/function-extractor.d.ts +20 -0
  28. package/dist/extractor/function-extractor.d.ts.map +1 -0
  29. package/dist/extractor/function-extractor.js +169 -0
  30. package/dist/extractor/function-extractor.js.map +1 -0
  31. package/dist/extractor/index.d.ts +22 -0
  32. package/dist/extractor/index.d.ts.map +1 -0
  33. package/dist/extractor/index.js +194 -0
  34. package/dist/extractor/index.js.map +1 -0
  35. package/dist/extractor/method-extractor.d.ts +30 -0
  36. package/dist/extractor/method-extractor.d.ts.map +1 -0
  37. package/dist/extractor/method-extractor.js +163 -0
  38. package/dist/extractor/method-extractor.js.map +1 -0
  39. package/dist/extractor/package-resolver.d.ts +77 -0
  40. package/dist/extractor/package-resolver.d.ts.map +1 -0
  41. package/dist/extractor/package-resolver.js +766 -0
  42. package/dist/extractor/package-resolver.js.map +1 -0
  43. package/dist/extractor/type-extractor.d.ts +15 -0
  44. package/dist/extractor/type-extractor.d.ts.map +1 -0
  45. package/dist/extractor/type-extractor.js +206 -0
  46. package/dist/extractor/type-extractor.js.map +1 -0
  47. package/dist/extractor/types.d.ts +116 -0
  48. package/dist/extractor/types.d.ts.map +1 -0
  49. package/dist/extractor/types.js +5 -0
  50. package/dist/extractor/types.js.map +1 -0
  51. package/dist/index.d.ts +18 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +21 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/library-indexer.d.ts +104 -0
  56. package/dist/library-indexer.d.ts.map +1 -0
  57. package/dist/library-indexer.js +295 -0
  58. package/dist/library-indexer.js.map +1 -0
  59. package/dist/schema/base-schema.d.ts +63 -0
  60. package/dist/schema/base-schema.d.ts.map +1 -0
  61. package/dist/schema/base-schema.js +63 -0
  62. package/dist/schema/base-schema.js.map +1 -0
  63. package/dist/schema/index.d.ts +6 -0
  64. package/dist/schema/index.d.ts.map +1 -0
  65. package/dist/schema/index.js +6 -0
  66. package/dist/schema/index.js.map +1 -0
  67. package/dist/schema/schema-builder.d.ts +47 -0
  68. package/dist/schema/schema-builder.d.ts.map +1 -0
  69. package/dist/schema/schema-builder.js +236 -0
  70. package/dist/schema/schema-builder.js.map +1 -0
  71. package/dist/script/index.d.ts +6 -0
  72. package/dist/script/index.d.ts.map +1 -0
  73. package/dist/script/index.js +5 -0
  74. package/dist/script/index.js.map +1 -0
  75. package/dist/script/script-parser.d.ts +18 -0
  76. package/dist/script/script-parser.d.ts.map +1 -0
  77. package/dist/script/script-parser.js +246 -0
  78. package/dist/script/script-parser.js.map +1 -0
  79. package/dist/script/types.d.ts +32 -0
  80. package/dist/script/types.d.ts.map +1 -0
  81. package/dist/script/types.js +5 -0
  82. package/dist/script/types.js.map +1 -0
  83. package/dist/search/index.d.ts +7 -0
  84. package/dist/search/index.d.ts.map +1 -0
  85. package/dist/search/index.js +7 -0
  86. package/dist/search/index.js.map +1 -0
  87. package/dist/search/query-builder.d.ts +59 -0
  88. package/dist/search/query-builder.d.ts.map +1 -0
  89. package/dist/search/query-builder.js +103 -0
  90. package/dist/search/query-builder.js.map +1 -0
  91. package/dist/search/result-formatter.d.ts +61 -0
  92. package/dist/search/result-formatter.d.ts.map +1 -0
  93. package/dist/search/result-formatter.js +170 -0
  94. package/dist/search/result-formatter.js.map +1 -0
  95. package/dist/search/search-engine.d.ts +105 -0
  96. package/dist/search/search-engine.d.ts.map +1 -0
  97. package/dist/search/search-engine.js +245 -0
  98. package/dist/search/search-engine.js.map +1 -0
  99. package/package.json +41 -0
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Extract methods from TypeScript class declarations
3
+ */
4
+ import * as ts from 'typescript';
5
+ import { readFileSync, existsSync } from 'fs';
6
+ import { createSourceFile, getJSDocDescription, extractParameterInfo, isAsyncMethod, isStaticMethod, isPrivateMember, } from './ast-parser.js';
7
+ /**
8
+ * Extract all methods from a TypeScript file
9
+ *
10
+ * @param filePath - Path to the .d.ts file
11
+ * @param libraryName - Name of the library
12
+ * @param classFilter - Optional filter function for class names
13
+ * @param exportAliases - Optional map of internal class names to exported aliases
14
+ * @param publicExports - Optional set of publicly exported names (only index these)
15
+ */
16
+ export function extractMethodsFromFile(filePath, libraryName, classFilter, exportAliases, publicExports) {
17
+ if (!existsSync(filePath)) {
18
+ return [];
19
+ }
20
+ const sourceCode = readFileSync(filePath, 'utf-8');
21
+ const sourceFile = createSourceFile(filePath, sourceCode);
22
+ const methods = [];
23
+ function visit(node) {
24
+ if (ts.isClassDeclaration(node) && node.name) {
25
+ const internalClassName = node.name.text;
26
+ // Use exported alias if available (e.g., ObjectCoreV1Api -> CoreV1Api)
27
+ const className = exportAliases?.get(internalClassName) ?? internalClassName;
28
+ // If we have public exports info, only index classes that are publicly exported
29
+ // A class is public if:
30
+ // 1. Its internal name has an alias in the export map (aliased export)
31
+ // 2. OR its name is directly in the public exports set
32
+ if (publicExports && publicExports.size > 0) {
33
+ const isAliasedExport = exportAliases?.has(internalClassName);
34
+ const isDirectExport = publicExports.has(internalClassName);
35
+ if (!isAliasedExport && !isDirectExport) {
36
+ // This class is not publicly exported, skip it
37
+ return;
38
+ }
39
+ }
40
+ // Apply class filter if provided (filter on the public name)
41
+ if (classFilter && !classFilter(className)) {
42
+ return;
43
+ }
44
+ const classMethods = extractMethodsFromClass(node, sourceFile, libraryName, filePath, className // Pass the resolved className (with alias applied)
45
+ );
46
+ methods.push(...classMethods);
47
+ }
48
+ ts.forEachChild(node, visit);
49
+ }
50
+ visit(sourceFile);
51
+ return methods;
52
+ }
53
+ /**
54
+ * Extract methods from a class declaration
55
+ *
56
+ * @param classNode - The class declaration AST node
57
+ * @param sourceFile - The source file containing the class
58
+ * @param libraryName - Name of the library
59
+ * @param filePath - Path to the source file
60
+ * @param resolvedClassName - Optional pre-resolved class name (with export alias applied)
61
+ */
62
+ export function extractMethodsFromClass(classNode, sourceFile, libraryName, filePath, resolvedClassName) {
63
+ if (!classNode.name)
64
+ return [];
65
+ // Use resolved name if provided, otherwise use the internal name
66
+ const className = resolvedClassName ?? classNode.name.text;
67
+ const methods = [];
68
+ const defaultReturnType = filePath.endsWith('.js') || filePath.endsWith('.mjs') || filePath.endsWith('.cjs')
69
+ ? 'any'
70
+ : 'void';
71
+ for (const member of classNode.members) {
72
+ // Handle method declarations
73
+ if (ts.isMethodDeclaration(member) && member.name) {
74
+ const methodName = member.name.getText(sourceFile);
75
+ // Skip private methods, constructors, and internal methods
76
+ if (methodName === 'constructor' ||
77
+ isPrivateMember(member, sourceFile, methodName)) {
78
+ continue;
79
+ }
80
+ const description = getJSDocDescription(member) ||
81
+ `${methodName} method of ${className}`;
82
+ const parameters = extractParameterInfo(member.parameters, sourceFile);
83
+ const returnType = member.type?.getText(sourceFile) || defaultReturnType;
84
+ const isStatic = isStaticMethod(member);
85
+ const isAsync = isAsyncMethod(member, sourceFile);
86
+ methods.push({
87
+ name: methodName,
88
+ className,
89
+ description,
90
+ parameters,
91
+ returnType,
92
+ isStatic,
93
+ isAsync,
94
+ sourceFile: filePath,
95
+ library: libraryName,
96
+ });
97
+ }
98
+ // Handle method signatures (for interfaces/abstract classes)
99
+ if (ts.isMethodSignature(member) && member.name) {
100
+ const methodName = member.name.getText(sourceFile);
101
+ // Skip private methods
102
+ if (isPrivateMember(member, sourceFile, methodName)) {
103
+ continue;
104
+ }
105
+ const description = getJSDocDescription(member) ||
106
+ `${methodName} method of ${className}`;
107
+ const parameters = extractParameterInfo(member.parameters, sourceFile);
108
+ const returnType = member.type?.getText(sourceFile) || defaultReturnType;
109
+ const isAsync = isAsyncMethod(member, sourceFile);
110
+ methods.push({
111
+ name: methodName,
112
+ className,
113
+ description,
114
+ parameters,
115
+ returnType,
116
+ isStatic: false,
117
+ isAsync,
118
+ sourceFile: filePath,
119
+ library: libraryName,
120
+ });
121
+ }
122
+ }
123
+ return methods;
124
+ }
125
+ /**
126
+ * Extract methods from an interface declaration (for type libraries)
127
+ */
128
+ export function extractMethodsFromInterface(interfaceNode, sourceFile, libraryName, filePath) {
129
+ if (!interfaceNode.name)
130
+ return [];
131
+ const interfaceName = interfaceNode.name.text;
132
+ const methods = [];
133
+ const defaultReturnType = filePath.endsWith('.js') || filePath.endsWith('.mjs') || filePath.endsWith('.cjs')
134
+ ? 'any'
135
+ : 'void';
136
+ for (const member of interfaceNode.members) {
137
+ if (ts.isMethodSignature(member) && member.name) {
138
+ const methodName = member.name.getText(sourceFile);
139
+ // Skip private methods
140
+ if (methodName.startsWith('_')) {
141
+ continue;
142
+ }
143
+ const description = getJSDocDescription(member) ||
144
+ `${methodName} method of ${interfaceName}`;
145
+ const parameters = extractParameterInfo(member.parameters, sourceFile);
146
+ const returnType = member.type?.getText(sourceFile) || defaultReturnType;
147
+ const isAsync = isAsyncMethod(member, sourceFile);
148
+ methods.push({
149
+ name: methodName,
150
+ className: interfaceName,
151
+ description,
152
+ parameters,
153
+ returnType,
154
+ isStatic: false,
155
+ isAsync,
156
+ sourceFile: filePath,
157
+ library: libraryName,
158
+ });
159
+ }
160
+ }
161
+ return methods;
162
+ }
163
+ //# sourceMappingURL=method-extractor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"method-extractor.js","sourceRoot":"","sources":["../../src/extractor/method-extractor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAE9C,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CACpC,QAAgB,EAChB,WAAmB,EACnB,WAA4C,EAC5C,aAAmC,EACnC,aAA2B;IAE3B,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,UAAU,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,gBAAgB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAE1D,MAAM,OAAO,GAAsB,EAAE,CAAC;IAEtC,SAAS,KAAK,CAAC,IAAa;QAC1B,IAAI,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC7C,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC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,CAAC;QAC1G,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,MAAM,CAAC;IAEX,KAAK,MAAM,MAAM,IAAI,aAAa,CAAC,OAAO,EAAE,CAAC;QAC3C,IAAI,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAEnD,uBAAuB;YACvB,IAAI,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC/B,SAAS;YACX,CAAC;YAED,MAAM,WAAW,GACf,mBAAmB,CAAC,MAAM,CAAC;gBAC3B,GAAG,UAAU,cAAc,aAAa,EAAE,CAAC;YAE7C,MAAM,UAAU,GAAG,oBAAoB,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YACvE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI,iBAAiB,CAAC;YACzE,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YAElD,OAAO,CAAC,IAAI,CAAC;gBACX,IAAI,EAAE,UAAU;gBAChB,SAAS,EAAE,aAAa;gBACxB,WAAW;gBACX,UAAU;gBACV,UAAU;gBACV,QAAQ,EAAE,KAAK;gBACf,OAAO;gBACP,UAAU,EAAE,QAAQ;gBACpB,OAAO,EAAE,WAAW;aACrB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Resolve npm packages and find their .d.ts files
3
+ */
4
+ import type { PackageInfo } from './types.js';
5
+ /**
6
+ * Resolve a package and find all its .d.ts files
7
+ */
8
+ export declare function resolvePackage(packageName: string, basePath?: string): PackageInfo | null;
9
+ /**
10
+ * Find the main ESM JavaScript entry file for a package.
11
+ *
12
+ * This is intended as a fallback for packages that ship no `.d.ts` files.
13
+ * Scope: ESM only (`.js` with `"type":"module"` or `.mjs`). CommonJS (`.cjs`)
14
+ * is intentionally out of scope.
15
+ */
16
+ export declare function findMainEsmJs(packagePath: string, packageJson: Record<string, unknown>): string | undefined;
17
+ /**
18
+ * Read and parse package.json
19
+ */
20
+ export declare function getPackageJson(packageJsonPath: string): Record<string, unknown> | null;
21
+ /**
22
+ * Find all .d.ts files in a package
23
+ */
24
+ export declare function findDtsFiles(packagePath: string, typesDir?: string, maxDepth?: number): string[];
25
+ /**
26
+ * Get all exportable types from a package's main entry point
27
+ */
28
+ export declare function getPackageExports(packagePath: string, packageJson: Record<string, unknown>): string[];
29
+ /**
30
+ * Result of parsing exports from a package entry point
31
+ */
32
+ export interface ExportParseResult {
33
+ /** Map of internal class names to their exported aliases (e.g., ObjectCoreV1Api -> CoreV1Api) */
34
+ aliasMap: Map<string, string>;
35
+ /** Set of all publicly exported names (the names users see and use) */
36
+ publicExports: Set<string>;
37
+ }
38
+ /**
39
+ * Parse exports from a package's entry point to determine:
40
+ * 1. Which names are publicly exported (visible to users)
41
+ * 2. Which internal names map to which public aliases
42
+ *
43
+ * Parses export statements like:
44
+ * export { ObjectCoreV1Api as CoreV1Api } from './gen/api/coreV1Api';
45
+ * export { SomeClass } from './module'; // No alias, SomeClass is public
46
+ * export class PublicClass { } // Directly exported class
47
+ *
48
+ * Recursively follows `export * from './module'` re-exports.
49
+ */
50
+ export declare function buildExportInfo(mainDtsPath: string): ExportParseResult;
51
+ /**
52
+ * Result of computing the public export surface of an ESM JavaScript package entry.
53
+ *
54
+ * - `filesToParse`: entry + all statically referenced re-export targets (relative only)
55
+ * - `exportAllowlistByFile`: per-file set of declaration names that are part of the public API
56
+ * - `aliasMapByFile`: per-file map from declaration name -> public export name (when renamed)
57
+ */
58
+ export interface ESMExportSurface {
59
+ entryFile: string;
60
+ filesToParse: string[];
61
+ exportAllowlistByFile: Map<string, Set<string>>;
62
+ aliasMapByFile: Map<string, Map<string, string>>;
63
+ /** Names users can import from the package entry (public surface) */
64
+ publicExports: Set<string>;
65
+ }
66
+ /**
67
+ * Build the public export surface for an ESM entry file.
68
+ *
69
+ * This follows only *relative* static re-exports (`./...`). Re-exports from
70
+ * dependencies are intentionally ignored.
71
+ */
72
+ export declare function buildEsmExportSurface(entryFile: string): ESMExportSurface;
73
+ /**
74
+ * @deprecated Use buildExportInfo instead
75
+ */
76
+ export declare function buildExportAliasMap(mainDtsPath: string): Map<string, string>;
77
+ //# sourceMappingURL=package-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-resolver.d.ts","sourceRoot":"","sources":["../../src/extractor/package-resolver.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;GAEG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,QAAQ,GAAE,MAAsB,GAC/B,WAAW,GAAG,IAAI,CAoDpB;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,MAAM,GAAG,SAAS,CAyEpB;AA+GD;;GAEG;AACH,wBAAgB,cAAc,CAC5B,eAAe,EAAE,MAAM,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAWhC;AAoFD;;GAEG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,EACjB,QAAQ,GAAE,MAAU,GACnB,MAAM,EAAE,CAyEV;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,MAAM,EAAE,CAeV;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,iGAAiG;IACjG,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