@openpkg-ts/extract 0.23.0 → 0.23.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/bin/tspec.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  extract
4
- } from "../shared/chunk-y5d5qgyt.js";
4
+ } from "../shared/chunk-8898fs2f.js";
5
5
 
6
6
  // src/cli/spec.ts
7
7
  import * as fs from "node:fs";
@@ -1015,6 +1015,7 @@ function serializeClass(node, ctx) {
1015
1015
  const name = symbol?.getName() ?? node.name?.getText();
1016
1016
  if (!name)
1017
1017
  return null;
1018
+ const deprecated = isSymbolDeprecated(symbol);
1018
1019
  const declSourceFile = node.getSourceFile();
1019
1020
  const { description, tags, examples } = getJSDocComment(node);
1020
1021
  const source = getSourceLocation(node, declSourceFile);
@@ -1070,6 +1071,7 @@ function serializeClass(node, ctx) {
1070
1071
  signatures: signatures.length > 0 ? signatures : undefined,
1071
1072
  extends: extendsClause,
1072
1073
  implements: implementsClause?.length ? implementsClause : undefined,
1074
+ ...deprecated ? { deprecated: true } : {},
1073
1075
  ...examples.length > 0 ? { examples } : {}
1074
1076
  };
1075
1077
  }
@@ -1245,6 +1247,7 @@ function serializeEnum(node, ctx) {
1245
1247
  const name = symbol?.getName() ?? node.name?.getText();
1246
1248
  if (!name)
1247
1249
  return null;
1250
+ const deprecated = isSymbolDeprecated(symbol);
1248
1251
  const declSourceFile = node.getSourceFile();
1249
1252
  const { description, tags, examples } = getJSDocComment(node);
1250
1253
  const source = getSourceLocation(node, declSourceFile);
@@ -1277,6 +1280,7 @@ function serializeEnum(node, ctx) {
1277
1280
  tags,
1278
1281
  source,
1279
1282
  members,
1283
+ ...deprecated ? { deprecated: true } : {},
1280
1284
  ...examples.length > 0 ? { examples } : {}
1281
1285
  };
1282
1286
  }
@@ -1287,6 +1291,7 @@ function serializeFunctionExport(node, ctx) {
1287
1291
  const name = symbol?.getName() ?? node.name?.getText();
1288
1292
  if (!name)
1289
1293
  return null;
1294
+ const deprecated = isSymbolDeprecated(symbol);
1290
1295
  const declSourceFile = node.getSourceFile();
1291
1296
  const { description, tags, examples } = getJSDocComment(node);
1292
1297
  const source = getSourceLocation(node, declSourceFile);
@@ -1313,6 +1318,7 @@ function serializeFunctionExport(node, ctx) {
1313
1318
  source,
1314
1319
  typeParameters,
1315
1320
  signatures,
1321
+ ...deprecated ? { deprecated: true } : {},
1316
1322
  ...examples.length > 0 ? { examples } : {}
1317
1323
  };
1318
1324
  }
@@ -1325,6 +1331,7 @@ function serializeInterface(node, ctx) {
1325
1331
  const name = symbol?.getName() ?? node.name?.getText();
1326
1332
  if (!name)
1327
1333
  return null;
1334
+ const deprecated = isSymbolDeprecated(symbol);
1328
1335
  const declSourceFile = node.getSourceFile();
1329
1336
  const { description, tags, examples } = getJSDocComment(node);
1330
1337
  const source = getSourceLocation(node, declSourceFile);
@@ -1365,6 +1372,7 @@ function serializeInterface(node, ctx) {
1365
1372
  typeParameters,
1366
1373
  members: members.length > 0 ? members : undefined,
1367
1374
  extends: extendsClause,
1375
+ ...deprecated ? { deprecated: true } : {},
1368
1376
  ...examples.length > 0 ? { examples } : {}
1369
1377
  };
1370
1378
  }
@@ -1484,6 +1492,7 @@ function serializeTypeAlias(node, ctx) {
1484
1492
  const name = symbol?.getName() ?? node.name?.getText();
1485
1493
  if (!name)
1486
1494
  return null;
1495
+ const deprecated = isSymbolDeprecated(symbol);
1487
1496
  const declSourceFile = node.getSourceFile();
1488
1497
  const { description, tags, examples } = getJSDocComment(node);
1489
1498
  const source = getSourceLocation(node, declSourceFile);
@@ -1500,6 +1509,7 @@ function serializeTypeAlias(node, ctx) {
1500
1509
  source,
1501
1510
  typeParameters,
1502
1511
  schema,
1512
+ ...deprecated ? { deprecated: true } : {},
1503
1513
  ...examples.length > 0 ? { examples } : {}
1504
1514
  };
1505
1515
  }
@@ -1673,6 +1683,7 @@ function serializeVariable(node, statement, ctx) {
1673
1683
  const name = symbol?.getName() ?? node.name.getText();
1674
1684
  if (!name)
1675
1685
  return null;
1686
+ const deprecated = isSymbolDeprecated(symbol);
1676
1687
  const declSourceFile = node.getSourceFile();
1677
1688
  const { description, tags, examples } = getJSDocComment(statement);
1678
1689
  const source = getSourceLocation(node, declSourceFile);
@@ -1694,6 +1705,7 @@ function serializeVariable(node, statement, ctx) {
1694
1705
  source,
1695
1706
  schema,
1696
1707
  ...flags ? { flags } : {},
1708
+ ...deprecated ? { deprecated: true } : {},
1697
1709
  ...examples.length > 0 ? { examples } : {}
1698
1710
  };
1699
1711
  }
@@ -2768,7 +2780,8 @@ async function extract(options) {
2768
2780
  }
2769
2781
  const meta = await getPackageMeta(entryFile, baseDir);
2770
2782
  const types = ctx.typeRegistry.getAll();
2771
- const forgottenExports = collectForgottenExports(exports, types, program, sourceFile, exportedIds);
2783
+ const projectBaseDir = baseDir ?? path3.dirname(entryFile);
2784
+ const forgottenExports = collectForgottenExports(exports, types, program, sourceFile, exportedIds, projectBaseDir);
2772
2785
  for (const forgotten of forgottenExports) {
2773
2786
  const refSummary = forgotten.referencedBy.slice(0, 3).map((r) => `${r.exportName} (${r.location})`).join(", ");
2774
2787
  const moreRefs = forgotten.referencedBy.length > 3 ? ` +${forgotten.referencedBy.length - 3} more` : "";
@@ -2799,8 +2812,8 @@ async function extract(options) {
2799
2812
  }
2800
2813
  let runtimeMetadata;
2801
2814
  if (options.schemaExtraction === "hybrid") {
2802
- const projectBaseDir = baseDir || path3.dirname(entryFile);
2803
- const runtimeResult = await extractStandardSchemasFromProject(entryFile, projectBaseDir, {
2815
+ const projectBaseDir2 = baseDir || path3.dirname(entryFile);
2816
+ const runtimeResult = await extractStandardSchemasFromProject(entryFile, projectBaseDir2, {
2804
2817
  target: options.schemaTarget || "draft-2020-12",
2805
2818
  timeout: 15000
2806
2819
  });
@@ -2916,10 +2929,14 @@ function findTypeDefinition(typeName, program, sourceFile) {
2916
2929
  }
2917
2930
  return;
2918
2931
  }
2919
- function isExternalType2(definedIn) {
2932
+ function isExternalType2(definedIn, baseDir) {
2920
2933
  if (!definedIn)
2921
2934
  return true;
2922
- return definedIn.includes("node_modules");
2935
+ if (definedIn.includes("node_modules"))
2936
+ return true;
2937
+ const normalizedDefined = path3.resolve(definedIn);
2938
+ const normalizedBase = path3.resolve(baseDir);
2939
+ return !normalizedDefined.startsWith(normalizedBase);
2923
2940
  }
2924
2941
  function hasInternalTag(typeName, program, sourceFile) {
2925
2942
  const checker = program.getTypeChecker();
@@ -2929,7 +2946,7 @@ function hasInternalTag(typeName, program, sourceFile) {
2929
2946
  const jsTags = symbol.getJsDocTags();
2930
2947
  return jsTags.some((tag) => tag.name === "internal");
2931
2948
  }
2932
- function collectForgottenExports(exports, types, program, sourceFile, exportedIds) {
2949
+ function collectForgottenExports(exports, types, program, sourceFile, exportedIds, baseDir) {
2933
2950
  const definedTypes = new Set(types.map((t) => t.id));
2934
2951
  const referencedTypes = new Map;
2935
2952
  for (const exp of exports) {
@@ -2959,7 +2976,7 @@ function collectForgottenExports(exports, types, program, sourceFile, exportedId
2959
2976
  if (exportedIds.has(typeName))
2960
2977
  continue;
2961
2978
  const definedIn = findTypeDefinition(typeName, program, sourceFile);
2962
- const isExternal = isExternalType2(definedIn);
2979
+ const isExternal = isExternalType2(definedIn, baseDir);
2963
2980
  forgottenExports.push({
2964
2981
  name: typeName,
2965
2982
  definedIn,
package/dist/src/index.js CHANGED
@@ -46,7 +46,7 @@ import {
46
46
  valibotAdapter,
47
47
  withDescription,
48
48
  zodAdapter
49
- } from "../shared/chunk-y5d5qgyt.js";
49
+ } from "../shared/chunk-8898fs2f.js";
50
50
  // src/types/utils.ts
51
51
  function isExported(node) {
52
52
  const modifiers = node.modifiers;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpkg-ts/extract",
3
- "version": "0.23.0",
3
+ "version": "0.23.2",
4
4
  "description": "TypeScript export extraction to OpenPkg spec",
5
5
  "keywords": [
6
6
  "openpkg",