@openpkg-ts/sdk 0.52.0 → 0.52.2
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 +7 -6
- package/dist/index.js +161 -76
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1149,10 +1149,6 @@ type ResolveEmpty = {
|
|
|
1149
1149
|
kind: "empty";
|
|
1150
1150
|
reason: string;
|
|
1151
1151
|
};
|
|
1152
|
-
type ResolveRemote = {
|
|
1153
|
-
kind: "remote";
|
|
1154
|
-
input: string;
|
|
1155
|
-
};
|
|
1156
1152
|
type ResolveExplicit = {
|
|
1157
1153
|
kind: "explicit";
|
|
1158
1154
|
entryFile: string;
|
|
@@ -1162,9 +1158,14 @@ type ResolveUnavailable = {
|
|
|
1162
1158
|
kind: "unavailable";
|
|
1163
1159
|
reason: string;
|
|
1164
1160
|
};
|
|
1165
|
-
type ResolveTargetResult = ResolveOk | ResolveAmbiguous | ResolveNeedsBuild | ResolveEmpty |
|
|
1161
|
+
type ResolveTargetResult = (ResolveOk | ResolveAmbiguous | ResolveNeedsBuild | ResolveEmpty | ResolveExplicit | ResolveUnavailable) & {
|
|
1162
|
+
/** Present when this resolution owns a temp clone. Call after extraction. */
|
|
1163
|
+
cleanup?: () => void;
|
|
1164
|
+
};
|
|
1166
1165
|
declare function isRemoteInput(input: string): boolean;
|
|
1167
1166
|
declare function isEntryFilePath(input: string): boolean;
|
|
1167
|
+
/** Absolute, explicit relative, slash-containing, or entry-file paths — not bare intent words. */
|
|
1168
|
+
declare function isPathLikeInput(input: string): boolean;
|
|
1168
1169
|
declare function parseGithubRepo(input: string): {
|
|
1169
1170
|
owner: string;
|
|
1170
1171
|
repo: string;
|
|
@@ -2079,4 +2080,4 @@ declare function findDiscriminatorProperty(unionTypes: ts16.Type[], checker: ts1
|
|
|
2079
2080
|
import ts17 from "typescript";
|
|
2080
2081
|
declare function isExported(node: ts17.Node): boolean;
|
|
2081
2082
|
declare function getNodeName(node: ts17.Node): string | undefined;
|
|
2082
|
-
export { zodAdapter, writtenTypeText, withDescription2 as withDescription, withDeprecated, validateSpec, valibotAdapter, typeboxAdapter, toToolSchema, toSearchIndexJSON, toSearchIndex2 as toSearchIndex, toPagefindRecords2 as toPagefindRecords, toNavigation2 as toNavigation, toMarkdown2 as toMarkdown, toJsonSchema, toJSONString, toJSON2 as toJSON, toHTML2 as toHTML, toFumadocsMetaJSON, toDocusaurusSidebarJS, toAlgoliaRecords2 as toAlgoliaRecords, stripUndefinedFromType, stripTsExtensions, sortByName, shouldEmitAliasTypeText, serializeVariable, serializeTypeAlias, serializeInterface, serializeFunctionExport, serializeEnum, serializeClass, scrubImportQualifiers, schemasAreEqual, schemaIsAny, resolveTypeRef, resolveTarget, resolveExportTarget, resolveCompiledPath, renderTypeText, registerReferencedTypes, registerAdapter, recommendSemverBump, query, pickEntry, parseGithubRepo, normalizeType, normalizeSchema, normalizeMembers, normalizeExport, mergeConfig, loadSpec, loadConfig, listExports, isTypeReference, isTypeOnlyExport, isSymbolDeprecated, isStandardJSONSchema, isSchemaType, isRemoteInput, isReadonlyPropertySymbol, isPureRefSchema, isProperty, isPrimitiveName, isMethod, isExported, isEntryFilePath, isBuiltinSymbol, isBuiltinGeneric, isAnonymous, hasDeprecatedTag, groupByVisibility, getValidationErrors, getTypeOrigin, getSourceLocation, getProperties, getParamDescription, getNonNullableType, getNodeName, getMethods, getMemberBadges, getJSDocComment, getExportKind, getExport2 as getExport, getDeprecationMessage, getAvailableVersions, toMarkdown2 as generateDocs, formatTypeParameters, formatSchema, formatReturnType, formatParameters, formatMappedType, formatConditionalType, formatBadges, findWorkspaceRoot, findMissingParamDocs, findDiscriminatorProperty, findAdapter, filterSpec, extractTypeParameters, extractStandardSchemasFromTs, extractStandardSchemasFromProject, extractStandardSchemas, extractSpec, extractSchemaType, extractParameters, extract, exportToMarkdown, exportToJsonSchema, ensureNonEmptySchema, diffSpec2 as diffSpecs, diffSpec, detectTsRuntime, deduplicateSchemas, decoratePropertySchema, declaredTypeNode, createProgram, createDocs, cloneRemote, categorizeBreakingChanges, catalogPackages, calculateNextVersion, bundleRefs, buildSignatureString, buildSchema, buildObjectSchema, buildFunctionSchema, assertSpec, asStandardSchema, arktypeAdapter, analyzeSpec, TypeRegistry, TypeReference2 as TypeReference, TsRuntime, ToolSchemaResult, ToolSchemaProvider, ToToolSchemaOptions, ToJsonSchemaOptions, StandardSchemaExtractionResult, StandardSchemaExtractionOutput, StandardJSONSchemaV1, StandardJSONSchemaTarget, StandardJSONSchemaOptions, SpecMappedType, SpecError, SpecDiff, SpecDiagnostics, SpecConditionalType, SkippedExportDetail, SimplifiedSpec, SimplifiedSignature, SimplifiedReturn, SimplifiedParameter, SimplifiedMember, SimplifiedExport, SimplifiedExample, SerializerContext, SemverRecommendation, SemverBump, SearchRecord, SearchOptions, SearchIndex, SchemaVersion, SchemaExtractionResult, SchemaAdapter, STRING_PROTOTYPE_METHODS, ResolveUnavailable, ResolveTargetResult, ResolveTargetOptions,
|
|
2083
|
+
export { zodAdapter, writtenTypeText, withDescription2 as withDescription, withDeprecated, validateSpec, valibotAdapter, typeboxAdapter, toToolSchema, toSearchIndexJSON, toSearchIndex2 as toSearchIndex, toPagefindRecords2 as toPagefindRecords, toNavigation2 as toNavigation, toMarkdown2 as toMarkdown, toJsonSchema, toJSONString, toJSON2 as toJSON, toHTML2 as toHTML, toFumadocsMetaJSON, toDocusaurusSidebarJS, toAlgoliaRecords2 as toAlgoliaRecords, stripUndefinedFromType, stripTsExtensions, sortByName, shouldEmitAliasTypeText, serializeVariable, serializeTypeAlias, serializeInterface, serializeFunctionExport, serializeEnum, serializeClass, scrubImportQualifiers, schemasAreEqual, schemaIsAny, resolveTypeRef, resolveTarget, resolveExportTarget, resolveCompiledPath, renderTypeText, registerReferencedTypes, registerAdapter, recommendSemverBump, query, pickEntry, parseGithubRepo, normalizeType, normalizeSchema, normalizeMembers, normalizeExport, mergeConfig, loadSpec, loadConfig, listExports, isTypeReference, isTypeOnlyExport, isSymbolDeprecated, isStandardJSONSchema, isSchemaType, isRemoteInput, isReadonlyPropertySymbol, isPureRefSchema, isProperty, isPrimitiveName, isPathLikeInput, isMethod, isExported, isEntryFilePath, isBuiltinSymbol, isBuiltinGeneric, isAnonymous, hasDeprecatedTag, groupByVisibility, getValidationErrors, getTypeOrigin, getSourceLocation, getProperties, getParamDescription, getNonNullableType, getNodeName, getMethods, getMemberBadges, getJSDocComment, getExportKind, getExport2 as getExport, getDeprecationMessage, getAvailableVersions, toMarkdown2 as generateDocs, formatTypeParameters, formatSchema, formatReturnType, formatParameters, formatMappedType, formatConditionalType, formatBadges, findWorkspaceRoot, findMissingParamDocs, findDiscriminatorProperty, findAdapter, filterSpec, extractTypeParameters, extractStandardSchemasFromTs, extractStandardSchemasFromProject, extractStandardSchemas, extractSpec, extractSchemaType, extractParameters, extract, exportToMarkdown, exportToJsonSchema, ensureNonEmptySchema, diffSpec2 as diffSpecs, diffSpec, detectTsRuntime, deduplicateSchemas, decoratePropertySchema, declaredTypeNode, createProgram, createDocs, cloneRemote, categorizeBreakingChanges, catalogPackages, calculateNextVersion, bundleRefs, buildSignatureString, buildSchema, buildObjectSchema, buildFunctionSchema, assertSpec, asStandardSchema, arktypeAdapter, analyzeSpec, TypeRegistry, TypeReference2 as TypeReference, TsRuntime, ToolSchemaResult, ToolSchemaProvider, ToToolSchemaOptions, ToJsonSchemaOptions, StandardSchemaExtractionResult, StandardSchemaExtractionOutput, StandardJSONSchemaV1, StandardJSONSchemaTarget, StandardJSONSchemaOptions, SpecMappedType, SpecError, SpecDiff, SpecDiagnostics, SpecConditionalType, SkippedExportDetail, SimplifiedSpec, SimplifiedSignature, SimplifiedReturn, SimplifiedParameter, SimplifiedMember, SimplifiedExport, SimplifiedExample, SerializerContext, SemverRecommendation, SemverBump, SearchRecord, SearchOptions, SearchIndex, SchemaVersion, SchemaExtractionResult, SchemaAdapter, STRING_PROTOTYPE_METHODS, ResolveUnavailable, ResolveTargetResult, ResolveTargetOptions, ResolveOk, ResolveNeedsBuild, ResolveExplicit, ResolveEmpty, ResolveAmbiguous, QueryBuilder, ProjectExtractionOutput, ProjectExtractionInfo, ProgramResult, ProgramOptions, PagefindRecord, PackageRecord, PRIMITIVES, OpenpkgConfig, NormalizeOptions, NavOptions, NavItem, NavGroup, NavFormat, NUMBER_PROTOTYPE_METHODS, MemberChangeInfo, MarkdownOptions, LoadOptions, ListExportsResult, ListExportsOptions, LATEST_VERSION, JsonSchemaDocument, JSONSchema, JSONOptions, JEV_MODEL, JEV_CONFIDENCE, HTMLOptions, GroupBy, GetExportResult, GetExportOptions, GenericNav, FumadocsMetaItem, FumadocsMeta, FormatSchemaOptions, ForgottenExport, FilterResult, FilterCriteria, ExtractionWarningCode, ExtractionWarning, ExtractStandardSchemasOptions, ExtractResult, ExtractOptions, ExtractFromProjectOptions, ExternalsConfig, ExportVerification, ExportTracker, ExportMarkdownOptions, ExportItem, EvaluateResult, EvaluateRequest, EvaluateFn, DocusaurusSidebarItem, DocusaurusSidebar, DocsInstance, DiagnosticItem, Diagnostic, CloneFn, CategorizedBreaking, CacheManagerOptions, CacheManager, CONFIG_FILENAME, BundleResult, BundleOptions, BuiltinSchema, BreakingSeverity, BUILTIN_TYPE_SCHEMAS, AsStandardSchemaOptions, AlgoliaRecord, ARRAY_PROTOTYPE_METHODS };
|
package/dist/index.js
CHANGED
|
@@ -1266,6 +1266,7 @@ import { spawn, spawnSync } from "node:child_process";
|
|
|
1266
1266
|
import * as fs3 from "node:fs";
|
|
1267
1267
|
import * as os from "node:os";
|
|
1268
1268
|
import * as path2 from "node:path";
|
|
1269
|
+
import picomatch from "picomatch";
|
|
1269
1270
|
var SKIP_DIRS = new Set(["node_modules", "dist", ".git", "target", "coverage", ".next", "out"]);
|
|
1270
1271
|
var CONV = ["src/index.ts", "src/index.tsx", "src/index.mts", "index.ts", "index.tsx"];
|
|
1271
1272
|
var ENTRY_EXT = /\.(c|m)?[tj]sx?$/;
|
|
@@ -1276,6 +1277,17 @@ function isRemoteInput(input) {
|
|
|
1276
1277
|
function isEntryFilePath(input) {
|
|
1277
1278
|
return ENTRY_EXT.test(input) || /\.d\.(ts|mts|cts)$/.test(input);
|
|
1278
1279
|
}
|
|
1280
|
+
function isPathLikeInput(input) {
|
|
1281
|
+
if (!input)
|
|
1282
|
+
return false;
|
|
1283
|
+
if (path2.isAbsolute(input))
|
|
1284
|
+
return true;
|
|
1285
|
+
if (input.startsWith("./") || input.startsWith("../"))
|
|
1286
|
+
return true;
|
|
1287
|
+
if (input.includes("/") || input.includes("\\"))
|
|
1288
|
+
return true;
|
|
1289
|
+
return isEntryFilePath(input);
|
|
1290
|
+
}
|
|
1279
1291
|
function parseGithubRepo(input) {
|
|
1280
1292
|
const trimmed = input.trim().replace(/\.git$/, "");
|
|
1281
1293
|
const https = trimmed.match(/github\.com[/:]([^/]+)\/([^/#?]+)/i);
|
|
@@ -1341,6 +1353,17 @@ function existsDir(p) {
|
|
|
1341
1353
|
return false;
|
|
1342
1354
|
}
|
|
1343
1355
|
}
|
|
1356
|
+
function isDirentDir(parent, entry) {
|
|
1357
|
+
if (entry.isDirectory())
|
|
1358
|
+
return true;
|
|
1359
|
+
if (!entry.isSymbolicLink())
|
|
1360
|
+
return false;
|
|
1361
|
+
try {
|
|
1362
|
+
return fs3.statSync(path2.join(parent, entry.name)).isDirectory();
|
|
1363
|
+
} catch {
|
|
1364
|
+
return false;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1344
1367
|
function readJson(file) {
|
|
1345
1368
|
try {
|
|
1346
1369
|
return JSON.parse(fs3.readFileSync(file, "utf-8"));
|
|
@@ -1370,53 +1393,45 @@ function parsePnpmWorkspace(yaml) {
|
|
|
1370
1393
|
}
|
|
1371
1394
|
return globs;
|
|
1372
1395
|
}
|
|
1373
|
-
function
|
|
1374
|
-
const
|
|
1375
|
-
const
|
|
1376
|
-
const
|
|
1377
|
-
if (
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1396
|
+
function expandWorkspaceGlobs(root, globs) {
|
|
1397
|
+
const include = [];
|
|
1398
|
+
const exclude = [];
|
|
1399
|
+
for (const g of globs) {
|
|
1400
|
+
if (g.startsWith("!"))
|
|
1401
|
+
exclude.push(g.slice(1));
|
|
1402
|
+
else
|
|
1403
|
+
include.push(g);
|
|
1404
|
+
}
|
|
1405
|
+
if (!include.length)
|
|
1406
|
+
return [];
|
|
1407
|
+
const dirs = [];
|
|
1408
|
+
const walk = (dir, depth) => {
|
|
1409
|
+
if (dirs.length >= MAX_PACKAGES || depth > 12)
|
|
1386
1410
|
return;
|
|
1387
|
-
if (
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
return;
|
|
1394
|
-
}
|
|
1395
|
-
for (const ent of entries) {
|
|
1396
|
-
if (!ent.isDirectory() || SKIP_DIRS.has(ent.name))
|
|
1397
|
-
continue;
|
|
1398
|
-
walk(path2.join(dir, ent.name), i);
|
|
1399
|
-
}
|
|
1411
|
+
if (existsFile(path2.join(dir, "package.json")))
|
|
1412
|
+
dirs.push(dir);
|
|
1413
|
+
let entries = [];
|
|
1414
|
+
try {
|
|
1415
|
+
entries = fs3.readdirSync(dir, { withFileTypes: true });
|
|
1416
|
+
} catch {
|
|
1400
1417
|
return;
|
|
1401
1418
|
}
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
}
|
|
1409
|
-
for (const ent of entries) {
|
|
1410
|
-
if (!ent.isDirectory() || SKIP_DIRS.has(ent.name))
|
|
1411
|
-
continue;
|
|
1412
|
-
walk(path2.join(dir, ent.name), i + 1);
|
|
1413
|
-
}
|
|
1414
|
-
return;
|
|
1419
|
+
for (const ent of entries) {
|
|
1420
|
+
if (SKIP_DIRS.has(ent.name) || ent.name.startsWith("."))
|
|
1421
|
+
continue;
|
|
1422
|
+
if (!isDirentDir(dir, ent))
|
|
1423
|
+
continue;
|
|
1424
|
+
walk(path2.join(dir, ent.name), depth + 1);
|
|
1415
1425
|
}
|
|
1416
|
-
walk(path2.join(dir, part), i + 1);
|
|
1417
1426
|
};
|
|
1418
1427
|
walk(root, 0);
|
|
1419
|
-
|
|
1428
|
+
const isMatch = picomatch(include, { ignore: exclude, dot: false, nocase: false });
|
|
1429
|
+
return dirs.filter((dir) => {
|
|
1430
|
+
const rel = path2.relative(root, dir).split(path2.sep).join("/");
|
|
1431
|
+
if (!rel || rel === ".")
|
|
1432
|
+
return include.includes(".");
|
|
1433
|
+
return isMatch(rel);
|
|
1434
|
+
});
|
|
1420
1435
|
}
|
|
1421
1436
|
function workspaceGlobs(dir) {
|
|
1422
1437
|
const pnpm = path2.join(dir, "pnpm-workspace.yaml");
|
|
@@ -1486,10 +1501,8 @@ function catalogPackages(start) {
|
|
|
1486
1501
|
};
|
|
1487
1502
|
const globs = workspaceGlobs(root);
|
|
1488
1503
|
if (globs?.length) {
|
|
1489
|
-
for (const
|
|
1490
|
-
|
|
1491
|
-
add(dir2);
|
|
1492
|
-
}
|
|
1504
|
+
for (const dir2 of expandWorkspaceGlobs(root, globs))
|
|
1505
|
+
add(dir2);
|
|
1493
1506
|
}
|
|
1494
1507
|
let dir = abs;
|
|
1495
1508
|
for (let i = 0;i < 8; i++) {
|
|
@@ -1541,9 +1554,9 @@ function collectCandidates(pkgDir, pkg) {
|
|
|
1541
1554
|
add(pkg.types, "types");
|
|
1542
1555
|
if (typeof pkg.typings === "string")
|
|
1543
1556
|
add(pkg.typings, "typings");
|
|
1544
|
-
if (pkg.exports
|
|
1557
|
+
if (pkg.exports != null) {
|
|
1545
1558
|
const exp = pkg.exports;
|
|
1546
|
-
const root = "." in exp ? exp["."] : exp;
|
|
1559
|
+
const root = typeof exp === "object" && exp !== null && !Array.isArray(exp) && "." in exp ? exp["."] : exp;
|
|
1547
1560
|
const paths = [];
|
|
1548
1561
|
collectFromExports(root, paths);
|
|
1549
1562
|
for (const p of paths)
|
|
@@ -1617,7 +1630,7 @@ function isExtractable(pkg) {
|
|
|
1617
1630
|
return false;
|
|
1618
1631
|
if (isIgnoredPath(pkg.dir))
|
|
1619
1632
|
return false;
|
|
1620
|
-
return
|
|
1633
|
+
return pickEntry(pkg.dir) !== null;
|
|
1621
1634
|
}
|
|
1622
1635
|
function intentScore(pkg, intent) {
|
|
1623
1636
|
const q = intent.toLowerCase().trim();
|
|
@@ -1821,10 +1834,16 @@ async function resolveTarget(options = {}) {
|
|
|
1821
1834
|
}
|
|
1822
1835
|
}
|
|
1823
1836
|
if (isRemoteInput(raw)) {
|
|
1837
|
+
const owned = !options.clone;
|
|
1824
1838
|
try {
|
|
1825
1839
|
const cloned = await (options.clone ?? cloneRemote)(raw);
|
|
1826
|
-
const
|
|
1827
|
-
|
|
1840
|
+
const result = await resolveLocal(cloned, cloned, ctx);
|
|
1841
|
+
if (!owned)
|
|
1842
|
+
return result;
|
|
1843
|
+
return {
|
|
1844
|
+
...result,
|
|
1845
|
+
cleanup: () => fs3.rmSync(cloned, { recursive: true, force: true })
|
|
1846
|
+
};
|
|
1828
1847
|
} catch (err) {
|
|
1829
1848
|
return {
|
|
1830
1849
|
kind: "empty",
|
|
@@ -1836,6 +1855,9 @@ async function resolveTarget(options = {}) {
|
|
|
1836
1855
|
if (existsFile(abs) && isEntryFilePath(abs)) {
|
|
1837
1856
|
return { kind: "explicit", entryFile: abs, entryPointSource: "explicit" };
|
|
1838
1857
|
}
|
|
1858
|
+
if (!existsFile(abs) && !existsDir(abs) && isPathLikeInput(options.input?.trim() || raw)) {
|
|
1859
|
+
return { kind: "empty", reason: `input does not exist: ${options.input?.trim() || raw}` };
|
|
1860
|
+
}
|
|
1839
1861
|
const startDir = existsDir(abs) ? abs : cwd;
|
|
1840
1862
|
return resolveLocal(abs, startDir, ctx);
|
|
1841
1863
|
}
|
|
@@ -2344,6 +2366,42 @@ function resolveWorkspaceEntry(pkgDir) {
|
|
|
2344
2366
|
} catch {}
|
|
2345
2367
|
return candidates.find((c) => fs4.existsSync(c));
|
|
2346
2368
|
}
|
|
2369
|
+
function isDirentDir2(parent, entry) {
|
|
2370
|
+
if (entry.isDirectory())
|
|
2371
|
+
return true;
|
|
2372
|
+
if (!entry.isSymbolicLink())
|
|
2373
|
+
return false;
|
|
2374
|
+
try {
|
|
2375
|
+
return fs4.statSync(path4.join(parent, entry.name)).isDirectory();
|
|
2376
|
+
} catch {
|
|
2377
|
+
return false;
|
|
2378
|
+
}
|
|
2379
|
+
}
|
|
2380
|
+
function extensionOf(file) {
|
|
2381
|
+
if (file.endsWith(".d.mts"))
|
|
2382
|
+
return ts2.Extension.Dmts;
|
|
2383
|
+
if (file.endsWith(".d.cts"))
|
|
2384
|
+
return ts2.Extension.Dcts;
|
|
2385
|
+
if (file.endsWith(".d.ts"))
|
|
2386
|
+
return ts2.Extension.Dts;
|
|
2387
|
+
if (file.endsWith(".mts"))
|
|
2388
|
+
return ts2.Extension.Mts;
|
|
2389
|
+
if (file.endsWith(".cts"))
|
|
2390
|
+
return ts2.Extension.Cts;
|
|
2391
|
+
if (file.endsWith(".tsx"))
|
|
2392
|
+
return ts2.Extension.Tsx;
|
|
2393
|
+
if (file.endsWith(".ts"))
|
|
2394
|
+
return ts2.Extension.Ts;
|
|
2395
|
+
if (file.endsWith(".mjs"))
|
|
2396
|
+
return ts2.Extension.Mjs;
|
|
2397
|
+
if (file.endsWith(".cjs"))
|
|
2398
|
+
return ts2.Extension.Cjs;
|
|
2399
|
+
if (file.endsWith(".jsx"))
|
|
2400
|
+
return ts2.Extension.Jsx;
|
|
2401
|
+
if (file.endsWith(".js"))
|
|
2402
|
+
return ts2.Extension.Js;
|
|
2403
|
+
return ts2.Extension.Ts;
|
|
2404
|
+
}
|
|
2347
2405
|
function resolveProjectReferences(configPath, parsedConfig) {
|
|
2348
2406
|
const additionalFiles = [];
|
|
2349
2407
|
if (!parsedConfig.projectReferences?.length) {
|
|
@@ -2427,7 +2485,7 @@ function buildWorkspaceMap(baseDir) {
|
|
|
2427
2485
|
continue;
|
|
2428
2486
|
const entries = fs4.readdirSync(globDir, { withFileTypes: true });
|
|
2429
2487
|
for (const entry of entries) {
|
|
2430
|
-
if (!entry
|
|
2488
|
+
if (!isDirentDir2(globDir, entry))
|
|
2431
2489
|
continue;
|
|
2432
2490
|
const pkgDir = path4.join(globDir, entry.name);
|
|
2433
2491
|
const pkgJsonPath = path4.join(pkgDir, "package.json");
|
|
@@ -2452,7 +2510,7 @@ function discoverAmbientTypePackages(baseDir) {
|
|
|
2452
2510
|
try {
|
|
2453
2511
|
if (fs4.existsSync(typesDir) && fs4.statSync(typesDir).isDirectory()) {
|
|
2454
2512
|
for (const entry of fs4.readdirSync(typesDir, { withFileTypes: true })) {
|
|
2455
|
-
if (
|
|
2513
|
+
if (entry.name.startsWith(".") || !isDirentDir2(typesDir, entry))
|
|
2456
2514
|
continue;
|
|
2457
2515
|
if (seen.has(entry.name))
|
|
2458
2516
|
continue;
|
|
@@ -2518,24 +2576,23 @@ function createProgram(options) {
|
|
|
2518
2576
|
const compilerHost = ts2.createCompilerHost(compilerOptions, true);
|
|
2519
2577
|
let inMemorySource;
|
|
2520
2578
|
if (workspaceMap) {
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
const
|
|
2525
|
-
if (
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
return result[0];
|
|
2579
|
+
compilerHost.resolveModuleNameLiterals = (moduleLiterals, containingFile, redirectedReference, options2, containingSourceFile) => moduleLiterals.map((literal) => {
|
|
2580
|
+
const pkgDir = workspaceMap.packages.get(literal.text);
|
|
2581
|
+
if (pkgDir) {
|
|
2582
|
+
const entryPath = resolveWorkspaceEntry(pkgDir);
|
|
2583
|
+
if (entryPath) {
|
|
2584
|
+
return {
|
|
2585
|
+
resolvedModule: {
|
|
2586
|
+
resolvedFileName: entryPath,
|
|
2587
|
+
isExternalLibraryImport: false,
|
|
2588
|
+
extension: extensionOf(entryPath)
|
|
2589
|
+
}
|
|
2590
|
+
};
|
|
2534
2591
|
}
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
};
|
|
2592
|
+
}
|
|
2593
|
+
const mode = ts2.getModeForUsageLocation(containingSourceFile, literal, options2);
|
|
2594
|
+
return ts2.resolveModuleName(literal.text, containingFile, options2, compilerHost, undefined, redirectedReference, mode);
|
|
2595
|
+
});
|
|
2539
2596
|
}
|
|
2540
2597
|
if (content !== undefined) {
|
|
2541
2598
|
inMemorySource = ts2.createSourceFile(entryFile, content, ts2.ScriptTarget.Latest, true, getScriptKind(entryFile));
|
|
@@ -6799,17 +6856,17 @@ async function extractStandardSchemasFromProject(entryFile, baseDir, options = {
|
|
|
6799
6856
|
// src/builder/external-resolver.ts
|
|
6800
6857
|
import * as fs6 from "node:fs";
|
|
6801
6858
|
import * as path8 from "node:path";
|
|
6802
|
-
import
|
|
6859
|
+
import picomatch2 from "picomatch";
|
|
6803
6860
|
import ts16 from "typescript";
|
|
6804
6861
|
function matchesExternalPattern(packageName, include, exclude) {
|
|
6805
6862
|
if (!include?.length)
|
|
6806
6863
|
return false;
|
|
6807
6864
|
const matchOptions = { bash: true };
|
|
6808
|
-
const isIncluded = include.some((p) =>
|
|
6865
|
+
const isIncluded = include.some((p) => picomatch2.isMatch(packageName, p, matchOptions));
|
|
6809
6866
|
if (!isIncluded)
|
|
6810
6867
|
return false;
|
|
6811
6868
|
if (exclude?.length) {
|
|
6812
|
-
const isExcluded = exclude.some((p) =>
|
|
6869
|
+
const isExcluded = exclude.some((p) => picomatch2.isMatch(packageName, p, matchOptions));
|
|
6813
6870
|
if (isExcluded)
|
|
6814
6871
|
return false;
|
|
6815
6872
|
}
|
|
@@ -7232,9 +7289,6 @@ function collectReferencedExternals(exportedSymbols, checker, workspacePackages)
|
|
|
7232
7289
|
visited.add(type);
|
|
7233
7290
|
const symbol = type.aliasSymbol ?? type.getSymbol();
|
|
7234
7291
|
consider(symbol);
|
|
7235
|
-
const match = symbol?.declarations?.[0]?.getSourceFile().fileName.match(NODE_MODULES_PKG2);
|
|
7236
|
-
if (match && !workspacePackages.has(match[1]))
|
|
7237
|
-
return;
|
|
7238
7292
|
for (const arg of type.aliasTypeArguments ?? [])
|
|
7239
7293
|
visit(arg, depth + 1);
|
|
7240
7294
|
const typeRef = type;
|
|
@@ -7246,11 +7300,33 @@ function collectReferencedExternals(exportedSymbols, checker, workspacePackages)
|
|
|
7246
7300
|
for (const t of type.types)
|
|
7247
7301
|
visit(t, depth + 1);
|
|
7248
7302
|
}
|
|
7303
|
+
const fileName = symbol?.declarations?.[0]?.getSourceFile().fileName;
|
|
7304
|
+
if (fileName) {
|
|
7305
|
+
if (isLibFile(fileName))
|
|
7306
|
+
return;
|
|
7307
|
+
const match = fileName.match(NODE_MODULES_PKG2);
|
|
7308
|
+
if (match && !workspacePackages.has(match[1]))
|
|
7309
|
+
return;
|
|
7310
|
+
}
|
|
7311
|
+
if (!(type.flags & ts18.TypeFlags.Object || type.isClassOrInterface()))
|
|
7312
|
+
return;
|
|
7313
|
+
if (type.isClassOrInterface()) {
|
|
7314
|
+
for (const base of checker.getBaseTypes(type) ?? [])
|
|
7315
|
+
visit(base, depth + 1);
|
|
7316
|
+
}
|
|
7317
|
+
for (const prop of type.getProperties()) {
|
|
7318
|
+
if (prop.getName().startsWith("__@"))
|
|
7319
|
+
continue;
|
|
7320
|
+
visit(checker.getTypeOfSymbol(prop), depth + 1);
|
|
7321
|
+
}
|
|
7249
7322
|
for (const sig of [...type.getCallSignatures(), ...type.getConstructSignatures()]) {
|
|
7250
7323
|
for (const param of sig.getParameters())
|
|
7251
7324
|
visit(checker.getTypeOfSymbol(param), depth + 1);
|
|
7252
7325
|
visit(sig.getReturnType(), depth + 1);
|
|
7253
7326
|
}
|
|
7327
|
+
for (const info of checker.getIndexInfosOfType(type)) {
|
|
7328
|
+
visit(info.type, depth + 1);
|
|
7329
|
+
}
|
|
7254
7330
|
};
|
|
7255
7331
|
for (const symbol of exportedSymbols) {
|
|
7256
7332
|
visit(checker.getTypeOfSymbol(symbol), 0);
|
|
@@ -7751,7 +7827,15 @@ async function extract(options) {
|
|
|
7751
7827
|
}
|
|
7752
7828
|
let followExternal = options.followExternal;
|
|
7753
7829
|
let evaluate = options.evaluate;
|
|
7754
|
-
|
|
7830
|
+
if (followExternal === "auto" && !evaluate && options.decisions !== "jev") {
|
|
7831
|
+
diagnostics.push({
|
|
7832
|
+
message: "followExternal auto requires decisions: 'jev' (or an injected evaluate)",
|
|
7833
|
+
severity: "error",
|
|
7834
|
+
code: "JEV_UNAVAILABLE"
|
|
7835
|
+
});
|
|
7836
|
+
followExternal = undefined;
|
|
7837
|
+
}
|
|
7838
|
+
const wantsJev = options.decisions === "jev";
|
|
7755
7839
|
if (wantsJev && !evaluate) {
|
|
7756
7840
|
if (process.env.AI_GATEWAY_API_KEY) {
|
|
7757
7841
|
try {
|
|
@@ -8878,6 +8962,7 @@ export {
|
|
|
8878
8962
|
isPureRefSchema,
|
|
8879
8963
|
isProperty,
|
|
8880
8964
|
isPrimitiveName,
|
|
8965
|
+
isPathLikeInput,
|
|
8881
8966
|
isMethod,
|
|
8882
8967
|
isExported,
|
|
8883
8968
|
isEntryFilePath,
|