packtory 0.0.65 → 0.0.67

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 (93) hide show
  1. package/checks/check-runner.d.ts +6 -0
  2. package/checks/check-runner.d.ts.map +1 -0
  3. package/checks/check-runner.js +7 -6
  4. package/checks/check-runner.js.map +1 -1
  5. package/checks/rule.d.ts +5 -0
  6. package/checks/rule.d.ts.map +1 -0
  7. package/checks/rules/max-bundle-size.d.ts +3 -0
  8. package/checks/rules/max-bundle-size.d.ts.map +1 -0
  9. package/checks/rules/no-dev-dependency-imports.d.ts +4 -0
  10. package/checks/rules/no-dev-dependency-imports.d.ts.map +1 -0
  11. package/checks/rules/no-duplicated-files.d.ts +4 -0
  12. package/checks/rules/no-duplicated-files.d.ts.map +1 -0
  13. package/checks/rules/no-side-effects.d.ts +4 -0
  14. package/checks/rules/no-side-effects.d.ts.map +1 -0
  15. package/checks/rules/no-unused-bundle-dependencies.d.ts +4 -0
  16. package/checks/rules/no-unused-bundle-dependencies.d.ts.map +1 -0
  17. package/checks/rules/registry.d.ts +9 -0
  18. package/checks/rules/registry.d.ts.map +1 -0
  19. package/checks/rules/registry.js +13 -11
  20. package/checks/rules/registry.js.map +1 -1
  21. package/checks/rules/required-files.d.ts +4 -0
  22. package/checks/rules/required-files.d.ts.map +1 -0
  23. package/checks/rules/type-script-declaration-integrity.d.ts +3 -0
  24. package/checks/rules/type-script-declaration-integrity.d.ts.map +1 -0
  25. package/checks/rules/type-script-declaration-integrity.js +58 -0
  26. package/checks/rules/type-script-declaration-integrity.js.map +1 -0
  27. package/checks/rules/type-script-declaration-paths.js +56 -0
  28. package/checks/rules/type-script-declaration-paths.js.map +1 -0
  29. package/checks/rules/type-script-declaration-project.d.ts +2 -0
  30. package/checks/rules/type-script-declaration-project.d.ts.map +1 -0
  31. package/checks/rules/type-script-declaration-project.js +87 -0
  32. package/checks/rules/type-script-declaration-project.js.map +1 -0
  33. package/checks/rules/type-script-declaration-reachability.js +39 -0
  34. package/checks/rules/type-script-declaration-reachability.js.map +1 -0
  35. package/checks/rules/type-script-declaration-roots.js +31 -0
  36. package/checks/rules/type-script-declaration-roots.js.map +1 -0
  37. package/checks/rules/type-script-integrity.d.ts +6 -0
  38. package/checks/rules/type-script-integrity.d.ts.map +1 -0
  39. package/checks/rules/type-script-integrity.js +54 -0
  40. package/checks/rules/type-script-integrity.js.map +1 -0
  41. package/checks/rules/type-script-package-resolution.d.ts +5 -0
  42. package/checks/rules/type-script-package-resolution.d.ts.map +1 -0
  43. package/checks/rules/type-script-package-resolution.js +43 -0
  44. package/checks/rules/type-script-package-resolution.js.map +1 -0
  45. package/checks/rules/type-script-resolution-summary.js +54 -0
  46. package/checks/rules/type-script-resolution-summary.js.map +1 -0
  47. package/checks/rules/unique-target-paths.d.ts +4 -0
  48. package/checks/rules/unique-target-paths.d.ts.map +1 -0
  49. package/common/declaration-companion-paths.js +25 -0
  50. package/common/declaration-companion-paths.js.map +1 -0
  51. package/common/package-layout.js +9 -0
  52. package/common/package-layout.js.map +1 -1
  53. package/common/sort-values.js +8 -5
  54. package/common/sort-values.js.map +1 -1
  55. package/config/checks-schema.d.ts +4 -8
  56. package/config/checks-schema.d.ts.map +1 -1
  57. package/config/checks-schema.js +3 -3
  58. package/config/checks-schema.js.map +1 -1
  59. package/linker/linker.d.ts.map +1 -1
  60. package/linker/linker.js +24 -1
  61. package/linker/linker.js.map +1 -1
  62. package/linker/replacement-lookup.js +1 -1
  63. package/linker/replacement-lookup.js.map +1 -1
  64. package/package-surface/substitution-exports.js +37 -19
  65. package/package-surface/substitution-exports.js.map +1 -1
  66. package/package.json +1 -1
  67. package/packages/packtory.composition.js +24 -0
  68. package/packages/packtory.composition.js.map +1 -1
  69. package/packtory/packtory-resolve.js.map +1 -1
  70. package/packtory/packtory.d.ts +1 -0
  71. package/packtory/packtory.d.ts.map +1 -1
  72. package/packtory/packtory.js.map +1 -1
  73. package/packtory/resolved-package.d.ts +1 -1
  74. package/packtory/resolved-package.d.ts.map +1 -1
  75. package/packtory/resolved-package.js +38 -14
  76. package/packtory/resolved-package.js.map +1 -1
  77. package/report/release-diff/file-set-diff.d.ts +1 -1
  78. package/report/release-diff/file-set-diff.d.ts.map +1 -1
  79. package/report/release-diff/file-set-diff.js +16 -2
  80. package/report/release-diff/file-set-diff.js.map +1 -1
  81. package/resource-resolver/content.js +11 -2
  82. package/resource-resolver/content.js.map +1 -1
  83. package/resource-resolver/dependency-resolution-walker.js +90 -18
  84. package/resource-resolver/dependency-resolution-walker.js.map +1 -1
  85. package/resource-resolver/resource-resolver.js +1 -1
  86. package/resource-resolver/resource-resolver.js.map +1 -1
  87. package/sbom.cdx.json +5 -5
  88. package/checks/rules/are-the-types-wrong.js +0 -154
  89. package/checks/rules/are-the-types-wrong.js.map +0 -1
  90. package/file-manager/file-description-by-path.js +0 -8
  91. package/file-manager/file-description-by-path.js.map +0 -1
  92. package/report/release-diff/file-hunks.js +0 -10
  93. package/report/release-diff/file-hunks.js.map +0 -1
@@ -0,0 +1,6 @@
1
+ import type { ChecksSettings, PackageChecksSettings, PackageConfigsByName } from '../config/config.ts';
2
+ import type { AnalyzedBundle } from '../dead-code-eliminator/analyzed-bundle.ts';
3
+ import type { PublishedPackageWithManifest } from '../published-package/published-package.ts';
4
+ import type { AllCheckRules } from './rules/registry.ts';
5
+ export {};
6
+ //# sourceMappingURL=check-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-runner.d.ts","sourceRoot":"","sources":["../../../../source/checks/check-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB;AACtG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C;AAChF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,2CAA2C;AAC7F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB"}
@@ -1,8 +1,9 @@
1
- import { allRules } from "./rules/registry.js";
2
- export async function runChecks(params) {
3
- const issues = await Promise.all(allRules.map(async function (rule) {
4
- return await rule.run(params);
5
- }));
6
- return issues.flat();
1
+ export function createCheckRunner(dependencies) {
2
+ return async function runChecks(params) {
3
+ const issues = await Promise.all(dependencies.rules.map(async function (rule) {
4
+ return await rule.run(params);
5
+ }));
6
+ return issues.flat();
7
+ };
7
8
  }
8
9
  //# sourceMappingURL=check-runner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"check-runner.js","sourceRoot":"","sources":["../../../../source/checks/check-runner.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAU/C,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,MAAyB;IACrD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAC5B,QAAQ,CAAC,GAAG,CAAC,KAAK,WAAW,IAAI;QAC7B,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC,CAAC,CACL,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC"}
1
+ {"version":3,"file":"check-runner.js","sourceRoot":"","sources":["../../../../source/checks/check-runner.ts"],"names":[],"mappings":"AAmBA,MAAM,UAAU,iBAAiB,CAAC,YAAqC;IACnE,OAAO,KAAK,UAAU,SAAS,CAAC,MAAM;QAClC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAC5B,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,WAAW,IAAI;YACvC,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAClC,CAAC,CAAC,CACL,CAAC;QACF,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { z, type ZodMiniType } from 'zod/mini';
2
+ import type { AnalyzedBundle } from '../dead-code-eliminator/analyzed-bundle.ts';
3
+ import type { PublishedPackageWithManifest } from '../published-package/published-package.ts';
4
+ export {};
5
+ //# sourceMappingURL=rule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule.d.ts","sourceRoot":"","sources":["../../../../source/checks/rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,KAAK,WAAW,EAAE,MAAM,UAAU;AAE9C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4CAA4C;AAChF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,2CAA2C"}
@@ -0,0 +1,3 @@
1
+ import type { CheckRuleDefinition } from '../rule.ts';
2
+ export {};
3
+ //# sourceMappingURL=max-bundle-size.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"max-bundle-size.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/max-bundle-size.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAiB,MAAM,YAAY"}
@@ -0,0 +1,4 @@
1
+ import type { z } from 'zod/mini';
2
+ import { type CheckRuleDefinition, emptyPerPackageSchema, enabledOnlyGlobalSchema } from '../rule.ts';
3
+ export {};
4
+ //# sourceMappingURL=no-dev-dependency-imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-dev-dependency-imports.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/no-dev-dependency-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,UAAU;AAEjC,OAAO,EACH,KAAK,mBAAmB,EACxB,qBAAqB,EACrB,uBAAuB,EAG1B,MAAM,YAAY"}
@@ -0,0 +1,4 @@
1
+ import type { z } from 'zod/mini';
2
+ import { type CheckRuleDefinition, pathAllowListGlobalSchema, pathAllowListPerPackageSchema } from '../rule.ts';
3
+ export {};
4
+ //# sourceMappingURL=no-duplicated-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-duplicated-files.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/no-duplicated-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,UAAU;AAEjC,OAAO,EACH,KAAK,mBAAmB,EACxB,yBAAyB,EACzB,6BAA6B,EAEhC,MAAM,YAAY"}
@@ -0,0 +1,4 @@
1
+ import type { z } from 'zod/mini';
2
+ import { type CheckRuleDefinition } from '../rule.ts';
3
+ export {};
4
+ //# sourceMappingURL=no-side-effects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-side-effects.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/no-side-effects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,UAAU;AAEjC,OAAO,EAGH,KAAK,mBAAmB,EAE3B,MAAM,YAAY"}
@@ -0,0 +1,4 @@
1
+ import type { z } from 'zod/mini';
2
+ import { emptyPerPackageSchema, enabledOnlyGlobalSchema, type CheckRuleDefinition } from '../rule.ts';
3
+ export {};
4
+ //# sourceMappingURL=no-unused-bundle-dependencies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unused-bundle-dependencies.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/no-unused-bundle-dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,UAAU;AAGjC,OAAO,EACH,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,mBAAmB,EAG3B,MAAM,YAAY"}
@@ -0,0 +1,9 @@
1
+ import { maxBundleSizeRule } from './max-bundle-size.ts';
2
+ import { noDevDependencyImportsRule } from './no-dev-dependency-imports.ts';
3
+ import { noDuplicatedFilesRule } from './no-duplicated-files.ts';
4
+ import { noSideEffectsRule } from './no-side-effects.ts';
5
+ import { noUnusedBundleDependenciesRule } from './no-unused-bundle-dependencies.ts';
6
+ import { requiredFilesRule } from './required-files.ts';
7
+ import { type TypeScriptIntegrityDependencies, type TypeScriptIntegrityRule } from './type-script-integrity.ts';
8
+ import { uniqueTargetPathsRule } from './unique-target-paths.ts';
9
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB;AACxD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB;AACxD,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB;AACvD,OAAO,EAEH,KAAK,+BAA+B,EACpC,KAAK,uBAAuB,EAC/B,MAAM,4BAA4B;AACnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B"}
@@ -1,19 +1,21 @@
1
- import { areTheTypesWrongRule } from "./are-the-types-wrong.js";
2
1
  import { maxBundleSizeRule } from "./max-bundle-size.js";
3
2
  import { noDevDependencyImportsRule } from "./no-dev-dependency-imports.js";
4
3
  import { noDuplicatedFilesRule } from "./no-duplicated-files.js";
5
4
  import { noSideEffectsRule } from "./no-side-effects.js";
6
5
  import { noUnusedBundleDependenciesRule } from "./no-unused-bundle-dependencies.js";
7
6
  import { requiredFilesRule } from "./required-files.js";
7
+ import { createTypeScriptIntegrityRule } from "./type-script-integrity.js";
8
8
  import { uniqueTargetPathsRule } from "./unique-target-paths.js";
9
- export const allRules = [
10
- areTheTypesWrongRule,
11
- noDuplicatedFilesRule,
12
- requiredFilesRule,
13
- maxBundleSizeRule,
14
- noUnusedBundleDependenciesRule,
15
- noDevDependencyImportsRule,
16
- uniqueTargetPathsRule,
17
- noSideEffectsRule
18
- ];
9
+ export function createAllRules(dependencies) {
10
+ return [
11
+ createTypeScriptIntegrityRule(dependencies),
12
+ noDuplicatedFilesRule,
13
+ requiredFilesRule,
14
+ maxBundleSizeRule,
15
+ noUnusedBundleDependenciesRule,
16
+ noDevDependencyImportsRule,
17
+ uniqueTargetPathsRule,
18
+ noSideEffectsRule
19
+ ];
20
+ }
19
21
  //# sourceMappingURL=registry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../../source/checks/rules/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,CAAC,MAAM,QAAQ,GAAG;IACpB,oBAAoB;IACpB,qBAAqB;IACrB,iBAAiB;IACjB,iBAAiB;IACjB,8BAA8B;IAC9B,0BAA0B;IAC1B,qBAAqB;IACrB,iBAAiB;CACX,CAAC"}
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../../source/checks/rules/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EACH,6BAA6B,EAGhC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAejE,MAAM,UAAU,cAAc,CAAC,YAAmC;IAC9D,OAAO;QACH,6BAA6B,CAAC,YAAY,CAAC;QAC3C,qBAAqB;QACrB,iBAAiB;QACjB,iBAAiB;QACjB,8BAA8B;QAC9B,0BAA0B;QAC1B,qBAAqB;QACrB,iBAAiB;KACpB,CAAC;AACN,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { z } from 'zod/mini';
2
+ import type { CheckRuleDefinition } from '../rule.ts';
3
+ export {};
4
+ //# sourceMappingURL=required-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"required-files.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/required-files.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU;AAG5B,OAAO,KAAK,EAAE,mBAAmB,EAAiB,MAAM,YAAY"}
@@ -0,0 +1,3 @@
1
+ import type { PublishedPackageWithManifest } from '../../published-package/published-package.ts';
2
+ import type { DeclarationProjectsFactory } from './type-script-declaration-project.ts';
3
+ //# sourceMappingURL=type-script-declaration-integrity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-script-declaration-integrity.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-declaration-integrity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8CAA8C;AAEhG,OAAO,KAAK,EAGR,0BAA0B,EAE7B,MAAM,sCAAsC"}
@@ -0,0 +1,58 @@
1
+ import { isDeclarationPath } from "./type-script-declaration-paths.js";
2
+ import { reachableDeclarationPaths } from "./type-script-declaration-reachability.js";
3
+ import { declarationRootsFromManifest } from "./type-script-declaration-roots.js";
4
+ function collectPackageFiles(publishedPackage) {
5
+ return [
6
+ {
7
+ filePath: publishedPackage.manifestFile.filePath,
8
+ content: publishedPackage.manifestFile.content
9
+ },
10
+ ...publishedPackage.contents.map(function (entry) {
11
+ return {
12
+ filePath: entry.fileDescription.targetFilePath,
13
+ content: entry.fileDescription.content
14
+ };
15
+ })
16
+ ];
17
+ }
18
+ function collectDeclarationPaths(packageFiles) {
19
+ return new Set(packageFiles
20
+ .map(function (packageFile) {
21
+ return packageFile.filePath;
22
+ })
23
+ .filter(isDeclarationPath));
24
+ }
25
+ function checkedDeclarationPaths(project, declarationPaths, rootPaths, declarationMode) {
26
+ if (declarationMode === 'all') {
27
+ return declarationPaths;
28
+ }
29
+ return reachableDeclarationPaths({
30
+ declarationPaths,
31
+ rootPaths,
32
+ moduleSpecifiersOf: project.moduleSpecifiersOf
33
+ });
34
+ }
35
+ function formatDeclarationDiagnostic(packageName, modeLabel, diagnostic) {
36
+ return (`Package "${packageName}" failed TypeScript integrity in ${modeLabel}: ` +
37
+ `${diagnostic.declarationPath}:${diagnostic.line} TS${diagnostic.code}: ${diagnostic.message}`);
38
+ }
39
+ export function createDeclarationIntegritySummarizer(dependencies) {
40
+ const { createDeclarationProjects } = dependencies;
41
+ return function summarizeDeclarationIntegrity(packageName, publishedPackage, declarationMode) {
42
+ const packageFiles = collectPackageFiles(publishedPackage);
43
+ const declarationPaths = collectDeclarationPaths(packageFiles);
44
+ const rootPaths = declarationRootsFromManifest(publishedPackage.manifestFile.content);
45
+ return createDeclarationProjects(packageName, packageFiles).flatMap(function (project) {
46
+ const checkedPaths = checkedDeclarationPaths(project, declarationPaths, rootPaths, declarationMode);
47
+ return project
48
+ .listDiagnostics()
49
+ .filter(function (diagnostic) {
50
+ return checkedPaths.has(diagnostic.declarationPath);
51
+ })
52
+ .map(function (diagnostic) {
53
+ return formatDeclarationDiagnostic(packageName, project.modeLabel, diagnostic);
54
+ });
55
+ });
56
+ };
57
+ }
58
+ //# sourceMappingURL=type-script-declaration-integrity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-script-declaration-integrity.js","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-declaration-integrity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAOvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAclF,SAAS,mBAAmB,CAAC,gBAAwD;IACjF,OAAO;QACH;YACI,QAAQ,EAAE,gBAAgB,CAAC,YAAY,CAAC,QAAQ;YAChD,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,OAAO;SACjD;QACD,GAAG,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,KAAK;YAC5C,OAAO;gBACH,QAAQ,EAAE,KAAK,CAAC,eAAe,CAAC,cAAc;gBAC9C,OAAO,EAAE,KAAK,CAAC,eAAe,CAAC,OAAO;aACzC,CAAC;QACN,CAAC,CAAC;KACL,CAAC;AACN,CAAC;AAED,SAAS,uBAAuB,CAAC,YAAoC;IACjE,OAAO,IAAI,GAAG,CACV,YAAY;SACP,GAAG,CAAC,UAAU,WAAW;QACtB,OAAO,WAAW,CAAC,QAAQ,CAAC;IAChC,CAAC,CAAC;SACD,MAAM,CAAC,iBAAiB,CAAC,CACjC,CAAC;AACN,CAAC;AAED,SAAS,uBAAuB,CAC5B,OAA2B,EAC3B,gBAAqC,EACrC,SAA8B,EAC9B,eAAgC;IAEhC,IAAI,eAAe,KAAK,KAAK,EAAE,CAAC;QAC5B,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IAED,OAAO,yBAAyB,CAAC;QAC7B,gBAAgB;QAChB,SAAS;QACT,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;KACjD,CAAC,CAAC;AACP,CAAC;AAED,SAAS,2BAA2B,CAChC,WAAmB,EACnB,SAAiB,EACjB,UAA2C;IAE3C,OAAO,CACH,YAAY,WAAW,oCAAoC,SAAS,IAAI;QACxE,GAAG,UAAU,CAAC,eAAe,IAAI,UAAU,CAAC,IAAI,MAAM,UAAU,CAAC,IAAI,KAAK,UAAU,CAAC,OAAO,EAAE,CACjG,CAAC;AACN,CAAC;AAED,MAAM,UAAU,oCAAoC,CAChD,YAA8C;IAE9C,MAAM,EAAE,yBAAyB,EAAE,GAAG,YAAY,CAAC;IAEnD,OAAO,SAAS,6BAA6B,CAAC,WAAW,EAAE,gBAAgB,EAAE,eAAe;QACxF,MAAM,YAAY,GAAG,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;QAC3D,MAAM,gBAAgB,GAAG,uBAAuB,CAAC,YAAY,CAAC,CAAC;QAC/D,MAAM,SAAS,GAAG,4BAA4B,CAAC,gBAAgB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAEtF,OAAO,yBAAyB,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,OAAO,CAAC,UAAU,OAAO;YACjF,MAAM,YAAY,GAAG,uBAAuB,CAAC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;YAEpG,OAAO,OAAO;iBACT,eAAe,EAAE;iBACjB,MAAM,CAAC,UAAU,UAAU;gBACxB,OAAO,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;YACxD,CAAC,CAAC;iBACD,GAAG,CAAC,UAAU,UAAU;gBACrB,OAAO,2BAA2B,CAAC,WAAW,EAAE,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YACnF,CAAC,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,56 @@
1
+ import path from 'node:path';
2
+ const declarationExtensions = ['.d.ts', '.d.mts', '.d.cts'];
3
+ const knownDeclarationExtensions = [
4
+ {
5
+ javascriptExtension: '.js',
6
+ declarationExtensions: ['.d.ts']
7
+ },
8
+ {
9
+ javascriptExtension: '.mjs',
10
+ declarationExtensions: ['.d.mts', '.d.ts']
11
+ },
12
+ {
13
+ javascriptExtension: '.cjs',
14
+ declarationExtensions: ['.d.cts', '.d.ts']
15
+ }
16
+ ];
17
+ export function isDeclarationPath(filePath) {
18
+ return declarationExtensions.some(function (extension) {
19
+ return filePath.endsWith(extension);
20
+ });
21
+ }
22
+ export function isRelativeSpecifier(specifier) {
23
+ return specifier.startsWith('./') || specifier.startsWith('../');
24
+ }
25
+ function stripJavascriptExtension(resolvedPath, javascriptExtension) {
26
+ return resolvedPath.slice(0, -javascriptExtension.length);
27
+ }
28
+ function declarationCandidatesForKnownExtension(resolvedPath) {
29
+ const knownExtension = knownDeclarationExtensions.find(function (candidate) {
30
+ return resolvedPath.endsWith(candidate.javascriptExtension);
31
+ });
32
+ if (knownExtension === undefined) {
33
+ return undefined;
34
+ }
35
+ const basePath = stripJavascriptExtension(resolvedPath, knownExtension.javascriptExtension);
36
+ return knownExtension.declarationExtensions.map(function (declarationExtension) {
37
+ return `${basePath}${declarationExtension}`;
38
+ });
39
+ }
40
+ function declarationCandidatesForExtensionlessPath(resolvedPath) {
41
+ return [
42
+ resolvedPath,
43
+ ...declarationExtensions.map(function (declarationExtension) {
44
+ return `${resolvedPath}${declarationExtension}`;
45
+ }),
46
+ ...declarationExtensions.map(function (declarationExtension) {
47
+ return `${resolvedPath}/index${declarationExtension}`;
48
+ })
49
+ ];
50
+ }
51
+ export function declarationCandidatesFor(importerPath, specifier) {
52
+ const resolvedPath = path.posix.normalize(path.posix.join(path.posix.dirname(importerPath), specifier));
53
+ return declarationCandidatesForKnownExtension(resolvedPath) ??
54
+ declarationCandidatesForExtensionlessPath(resolvedPath);
55
+ }
56
+ //# sourceMappingURL=type-script-declaration-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-script-declaration-paths.js","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-declaration-paths.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAO7B,MAAM,qBAAqB,GAAG,CAAE,OAAO,EAAE,QAAQ,E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AG,QAAQ,GAAG,oBAAoB,EAAE,CAAC;IAChD,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,yCAAyC,CAAC,YAAoB;IACnE,OAAO;QACH,YAAY;QACZ,GAAG,qBAAqB,CAAC,GAAG,CAAC,UAAU,oBAAoB;YACvD,OAAO,GAAG,YAAY,GAAG,oBAAoB,EAAE,CAAC;QACpD,CAAC,CAAC;QACF,GAAG,qBAAqB,CAAC,GAAG,CAAC,UAAU,oBAAoB;YACvD,OAAO,GAAG,YAAY,SAAS,oBAAoB,EAAE,CAAC;QAC1D,CAAC,CAAC;KACL,CAAC;AACN,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,YAAoB,EAAE,SAAiB;IAC5E,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;IACxG,OAAO,sCAAsC,CAAC,YAAY,CAAC;QACvD,yCAAyC,CAAC,YAAY,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { type Project as TSMorphProject } from 'ts-morph';
2
+ //# sourceMappingURL=type-script-declaration-project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-script-declaration-project.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-declaration-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,KAAK,OAAO,IAAI,cAAc,EAEjC,MAAM,UAAU"}
@@ -0,0 +1,87 @@
1
+ import { ModuleKind, ModuleResolutionKind, ScriptTarget, ts as typescript } from 'ts-morph';
2
+ import { installedPackageFilePath, packageRelativeFilePath } from "../../common/package-layout.js";
3
+ function declarationCompilerModes() {
4
+ return [
5
+ {
6
+ label: 'node16-esm',
7
+ module: ModuleKind.Node16,
8
+ moduleResolution: ModuleResolutionKind.Node16
9
+ },
10
+ {
11
+ label: 'bundler',
12
+ module: ModuleKind.ESNext,
13
+ moduleResolution: ModuleResolutionKind.Bundler
14
+ }
15
+ ];
16
+ }
17
+ function moduleSpecifiersIn(sourceFile) {
18
+ return [
19
+ ...sourceFile.getImportDeclarations(),
20
+ ...sourceFile.getExportDeclarations()
21
+ ]
22
+ .map(function (declaration) {
23
+ return declaration.getModuleSpecifierValue();
24
+ })
25
+ .filter(function (specifier) {
26
+ return specifier !== undefined;
27
+ });
28
+ }
29
+ function toDeclarationDiagnostic(packageName, diagnostic) {
30
+ const sourceFile = diagnostic.getSourceFile();
31
+ const start = diagnostic.getStart();
32
+ if (sourceFile === undefined || start === undefined) {
33
+ return undefined;
34
+ }
35
+ return {
36
+ declarationPath: packageRelativeFilePath(packageName, sourceFile.getFilePath()),
37
+ line: sourceFile.getLineAndColumnAtPos(start).line,
38
+ code: diagnostic.getCode(),
39
+ message: typescript.flattenDiagnosticMessageText(diagnostic.compilerObject.messageText, '\n')
40
+ };
41
+ }
42
+ function isDeclarationDiagnostic(diagnostic) {
43
+ return diagnostic !== undefined;
44
+ }
45
+ function createModeProject(project, packageName, modeLabel) {
46
+ return {
47
+ modeLabel,
48
+ moduleSpecifiersOf(declarationPath) {
49
+ return moduleSpecifiersIn(project.getSourceFileOrThrow(installedPackageFilePath(packageName, declarationPath)));
50
+ },
51
+ listDiagnostics() {
52
+ return project
53
+ .getPreEmitDiagnostics()
54
+ .map(function (diagnostic) {
55
+ return toDeclarationDiagnostic(packageName, diagnostic);
56
+ })
57
+ .filter(isDeclarationDiagnostic);
58
+ }
59
+ };
60
+ }
61
+ export function createDeclarationProjectFactory(dependencies) {
62
+ const { Project } = dependencies;
63
+ function createProjectForMode(packageName, packageFiles, compilerMode) {
64
+ const project = new Project({
65
+ useInMemoryFileSystem: true,
66
+ skipAddingFilesFromTsConfig: true,
67
+ compilerOptions: {
68
+ module: compilerMode.module,
69
+ moduleResolution: compilerMode.moduleResolution,
70
+ noEmit: true,
71
+ skipLibCheck: false,
72
+ strict: true,
73
+ target: ScriptTarget.ESNext
74
+ }
75
+ });
76
+ for (const packageFile of packageFiles) {
77
+ project.createSourceFile(installedPackageFilePath(packageName, packageFile.filePath), packageFile.content);
78
+ }
79
+ return createModeProject(project, packageName, compilerMode.label);
80
+ }
81
+ return function createDeclarationProjects(packageName, packageFiles) {
82
+ return declarationCompilerModes().map(function (compilerMode) {
83
+ return createProjectForMode(packageName, packageFiles, compilerMode);
84
+ });
85
+ };
86
+ }
87
+ //# sourceMappingURL=type-script-declaration-project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-script-declaration-project.js","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-declaration-project.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,oBAAoB,EACpB,YAAY,EACZ,EAAE,IAAI,UAAU,EAInB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAmCnG,SAAS,wBAAwB;IAC7B,OAAO;QACH;YACI,KAAK,EAAE,YAAY;YACnB,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,gBAAgB,EAAE,oBAAoB,CAAC,MAAM;SAChD;QACD;YACI,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,gBAAgB,EAAE,oBAAoB,CAAC,OAAO;SACjD;KACJ,CAAC;AACN,CAAC;AAED,SAAS,kBAAkB,CAAC,UAAgC;IACxD,OAAO;QACH,GAAG,UAAU,CAAC,qBAAqB,EAAE;QACrC,GAAG,UAAU,CAAC,qBAAqB,EAAE;KACxC;SACI,GAAG,CAAC,UAAU,WAAW;QACtB,OAAO,WAAW,CAAC,uBAAuB,EAAE,CAAC;IACjD,CAAC,CAAC;SACD,MAAM,CAAC,UAAU,SAAS;QACvB,OAAO,SAAS,KAAK,SAAS,CAAC;IACnC,CAAC,CAAC,CAAC;AACX,CAAC;AAED,SAAS,uBAAuB,CAC5B,WAAm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C;QAErC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC;YACxB,qBAAqB,EAAE,IAAI;YAC3B,2BAA2B,EAAE,IAAI;YACjC,eAAe,EAAE;gBACb,MAAM,EAAE,YAAY,CAAC,MAAM;gBAC3B,gBAAgB,EAAE,YAAY,CAAC,gBAAgB;gBAC/C,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,KAAK;gBACnB,MAAM,EAAE,IAAI;gBACZ,MAAM,EAAE,YAAY,CAAC,MAAM;aAC9B;SACJ,CAAC,CAAC;QAEH,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;YACrC,OAAO,CAAC,gBAAgB,CAAC,wBAAwB,CAAC,WAAW,EAAE,WAAW,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;QAC/G,CAAC;QAED,OAAO,iBAAiB,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IACvE,CAAC;IAED,OAAO,SAAS,yBAAyB,CAAC,WAAW,EAAE,YAAY;QAC/D,OAAO,wBAAwB,EAAE,CAAC,GAAG,CAAC,UAAU,YAAY;YACxD,OAAO,oBAAoB,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { createDirectedGraph } from "../../directed-graph/graph.js";
2
+ import { declarationCandidatesFor, isRelativeSpecifier } from "./type-script-declaration-paths.js";
3
+ function referencedDeclarationPaths(references, declarationPath) {
4
+ const referencedPaths = references
5
+ .moduleSpecifiersOf(declarationPath)
6
+ .filter(isRelativeSpecifier)
7
+ .flatMap(function (specifier) {
8
+ return declarationCandidatesFor(declarationPath, specifier);
9
+ })
10
+ .filter(function (candidate) {
11
+ return references.declarationPaths.has(candidate);
12
+ });
13
+ return new Set(referencedPaths);
14
+ }
15
+ function buildDeclarationGraph(references) {
16
+ const graph = createDirectedGraph();
17
+ for (const declarationPath of references.declarationPaths) {
18
+ graph.addNode(declarationPath, undefined);
19
+ }
20
+ for (const declarationPath of references.declarationPaths) {
21
+ for (const referencedPath of referencedDeclarationPaths(references, declarationPath)) {
22
+ graph.connect({ from: declarationPath, to: referencedPath });
23
+ }
24
+ }
25
+ return graph;
26
+ }
27
+ export function reachableDeclarationPaths(references) {
28
+ const graph = buildDeclarationGraph(references);
29
+ const reachable = new Set();
30
+ for (const rootPath of references.rootPaths) {
31
+ if (references.declarationPaths.has(rootPath)) {
32
+ graph.visitBreadthFirstSearch(rootPath, function (node) {
33
+ reachable.add(node.id);
34
+ });
35
+ }
36
+ }
37
+ return reachable;
38
+ }
39
+ //# sourceMappingURL=type-script-declaration-reachability.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-script-declaration-reachability.js","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-declaration-reachability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAsB,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAQnG,SAAS,0BAA0B,CAAC,UAAiC,EAAE,eAAuB;IAC1F,MAAM,eAAe,GAAG,UAAU;SAC7B,kBAAkB,CAAC,eAAe,CAAC;SACnC,MAAM,CAAC,mBAAmB,CAAC;SAC3B,OAAO,CAAC,UAAU,SAAS;QACxB,OAAO,wBAAwB,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAChE,CAAC,CAAC;SACD,MAAM,CAAC,UAAU,SAAS;QACvB,OAAO,UAAU,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEP,OAAO,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC;AACpC,CAAC;AAED,SAAS,qBAAqB,CAAC,UAAiC;IAC5D,MAAM,KAAK,GAAG,mBAAmB,EAAqB,CAAC;IAEvD,KAAK,MAAM,eAAe,IAAI,UAAU,CAAC,gBAAgB,EAAE,CAAC;QACxD,KAAK,CAAC,OAAO,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,MAAM,eAAe,IAAI,UAAU,CAAC,gBAAgB,EAAE,CAAC;QACxD,KAAK,MAAM,cAAc,IAAI,0BAA0B,CAAC,UAAU,EAAE,eAAe,CAAC,EAAE,CAAC;YACnF,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QACjE,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,UAAiC;IACvE,MAAM,KAAK,GAAG,qBAAqB,CAAC,UAAU,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IAEpC,KAAK,MAAM,QAAQ,IAAI,UAAU,CAAC,SAAS,EAAE,CAAC;QAC1C,IAAI,UAAU,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5C,KAAK,CAAC,uBAAuB,CAAC,QAAQ,EAAE,UAAU,IAAI;gBAClD,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC"}
@@ -0,0 +1,31 @@
1
+ const relativeSpecifierPrefix = './';
2
+ function isRecord(value) {
3
+ return Object.prototype.toString.call(value) === '[object Object]';
4
+ }
5
+ function packagePathsIn(value) {
6
+ if (typeof value === 'string') {
7
+ return value.startsWith(relativeSpecifierPrefix)
8
+ ? [value.slice(relativeSpecifierPrefix.length)]
9
+ : [value];
10
+ }
11
+ if (typeof value === 'object' && value !== null) {
12
+ return Object.values(value).flatMap(packagePathsIn);
13
+ }
14
+ return [];
15
+ }
16
+ function parseManifestContent(manifestContent) {
17
+ const manifest = JSON.parse(manifestContent);
18
+ if (!isRecord(manifest)) {
19
+ return {};
20
+ }
21
+ return manifest;
22
+ }
23
+ export function declarationRootsFromManifest(manifestContent) {
24
+ const manifest = parseManifestContent(manifestContent);
25
+ return new Set([
26
+ ...packagePathsIn(manifest.exports),
27
+ ...packagePathsIn(manifest.types),
28
+ ...packagePathsIn(manifest.typings)
29
+ ]);
30
+ }
31
+ //# sourceMappingURL=type-script-declaration-roots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-script-declaration-roots.js","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-declaration-roots.ts"],"names":[],"mappings":"AAAA,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC,SAAS,QAAQ,CAAC,KAAc;IAC5B,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,iBAAiB,CAAC;AACvE,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,UAAU,CAAC,uBAAuB,CAAC;YAC5C,CAAC,CAAC,CAAE,KAAK,CAAC,KAAK,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAE;YACjD,CAAC,CAAC,CAAE,KAAK,CAAE,CAAC;IACpB,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC9C,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAED,SAAS,oBAAoB,CAAC,eAAuB;IACjD,MAAM,QAAQ,GAAY,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IACtD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,eAAuB;IAChE,MAAM,QAAQ,GAAG,oBAAoB,CAAC,eAAe,CAAC,CAAC;IACvD,OAAO,IAAI,GAAG,CAAC;QACX,GAAG,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC;QACnC,GAAG,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC;QACjC,GAAG,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC;KACtC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { z } from 'zod/mini';
2
+ import type { CheckRuleDefinition } from '../rule.ts';
3
+ import type { DeclarationIntegritySummarizer } from './type-script-declaration-integrity.ts';
4
+ import type { PackageResolutionAnalyzer } from './type-script-package-resolution.ts';
5
+ export {};
6
+ //# sourceMappingURL=type-script-integrity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-script-integrity.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-integrity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU;AAE5B,OAAO,KAAK,EAAE,mBAAmB,EAAiB,MAAM,YAAY;AACpE,OAAO,KAAK,EAAE,8BAA8B,EAAmB,MAAM,wCAAwC;AAC7G,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,qCAAqC"}
@@ -0,0 +1,54 @@
1
+ import { z } from 'zod/mini';
2
+ import { summarizeResolutionReport } from "./type-script-resolution-summary.js";
3
+ const ruleName = 'typeScriptIntegrity';
4
+ const checkedResolutionKinds = ['node16-esm', 'bundler'];
5
+ const declarationModeValues = ['all', 'exports-graph'];
6
+ const defaultDeclarationMode = 'all';
7
+ const globalSchema = z.strictObject({
8
+ enabled: z.boolean(),
9
+ declarations: z.optional(z.enum(declarationModeValues))
10
+ });
11
+ const perPackageSchema = z.strictObject({});
12
+ export const typeScriptIntegritySchemas = {
13
+ globalSchema,
14
+ perPackageSchema
15
+ };
16
+ export function createTypeScriptIntegrityRule(dependencies) {
17
+ const { analyzePackageResolution, summarizeDeclarationIntegrity } = dependencies;
18
+ async function summarizePackageResolution(packageName, publishedPackage) {
19
+ try {
20
+ const report = await analyzePackageResolution(publishedPackage, checkedResolutionKinds);
21
+ return summarizeResolutionReport(packageName, report, checkedResolutionKinds);
22
+ }
23
+ catch (error) {
24
+ return [`Package "${packageName}" failed TypeScript integrity: ${String(error)}`];
25
+ }
26
+ }
27
+ async function runForPackage(packageName, publishedPackage, declarationMode) {
28
+ return [
29
+ ...await summarizePackageResolution(packageName, publishedPackage),
30
+ ...summarizeDeclarationIntegrity(packageName, publishedPackage, declarationMode)
31
+ ];
32
+ }
33
+ async function run(params) {
34
+ const globalConfig = params.settings?.typeScriptIntegrity;
35
+ if (globalConfig?.enabled !== true) {
36
+ return [];
37
+ }
38
+ const declarationMode = globalConfig.declarations ?? defaultDeclarationMode;
39
+ const issuesByBundle = await Promise.all(params.bundles.map(async function (bundle) {
40
+ const publishedPackage = params.publishedPackages?.get(bundle.name);
41
+ if (publishedPackage === undefined) {
42
+ throw new Error(`Published package missing for "${bundle.name}"`);
43
+ }
44
+ return await runForPackage(bundle.name, publishedPackage, declarationMode);
45
+ }));
46
+ return issuesByBundle.flat();
47
+ }
48
+ return {
49
+ name: ruleName,
50
+ ...typeScriptIntegritySchemas,
51
+ run
52
+ };
53
+ }
54
+ //# sourceMappingURL=type-script-integrity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-script-integrity.js","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-integrity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,UAAU,CAAC;AAK7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAEhF,MAAM,QAAQ,GAAG,qBAAqB,CAAC;AACvC,MAAM,sBAAsB,GAA8B,CAAE,YAAY,EAAE,SAAS,CAAE,CAAC;AACtF,M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AmB,CAAC;QAC1D,IAAI,YAAY,EAAE,OAAO,KAAK,IAAI,EAAE,CAAC;YACjC,OAAO,EAAE,CAAC;QACd,CAAC;QAED,MAAM,eAAe,GAAG,YAAY,CAAC,YAAY,IAAI,sBAAsB,CAAC;QAC5E,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,GAAG,CACpC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,WAAW,MAAM;YACrC,MAAM,gBAAgB,GAAG,MAAM,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACpE,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBACjC,MAAM,IAAI,KAAK,CAAC,kCAAkC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;YACtE,CAAC;YAED,OAAO,MAAM,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,gBAAgB,EAAE,eAAe,CAAC,CAAC;QAC/E,CAAC,CAAC,CACL,CAAC;QACF,OAAO,cAAc,CAAC,IAAI,EAAE,CAAC;IACjC,CAAC;IAED,OAAO;QACH,IAAI,EAAE,QAAQ;QACd,GAAG,0BAA0B;QAC7B,GAAG;KACN,CAAC;AACN,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { Analysis, CheckResult, Package as TypesPackage, Problem, ProblemKind, ResolutionKind } from '@arethetypeswrong/core';
2
+ import type { problemKindInfo as ProblemKindInfo } from '@arethetypeswrong/core/problems';
3
+ import type { PublishedPackageWithManifest } from '../../published-package/published-package.ts';
4
+ export {};
5
+ //# sourceMappingURL=type-script-package-resolution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-script-package-resolution.d.ts","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-package-resolution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,QAAQ,EACR,WAAW,EACX,OAAO,IAAI,YAAY,EACvB,OAAO,EACP,WAAW,EACX,cAAc,EACjB,MAAM,wBAAwB;AAC/B,OAAO,KAAK,EAAE,eAAe,IAAI,eAAe,EAAE,MAAM,iCAAiC;AAEzF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8CAA8C"}
@@ -0,0 +1,43 @@
1
+ import { installedPackageFilePath } from "../../common/package-layout.js";
2
+ function packageFileContents(publishedPackage) {
3
+ const files = {
4
+ [installedPackageFilePath(publishedPackage.name, publishedPackage.manifestFile.filePath)]: publishedPackage.manifestFile.content
5
+ };
6
+ for (const entry of publishedPackage.contents) {
7
+ files[installedPackageFilePath(publishedPackage.name, entry.fileDescription.targetFilePath)] = entry
8
+ .fileDescription
9
+ .content;
10
+ }
11
+ return files;
12
+ }
13
+ export function createPackageResolutionAnalyzer(dependencies) {
14
+ const { Package, checkPackage, problemKindInfo, problemAffectsResolutionKind, problemAffectsEntrypointResolution } = dependencies;
15
+ function toProblemReport(problem, analysis, resolutionKinds) {
16
+ return {
17
+ kind: problem.kind,
18
+ shortDescription: problemKindInfo[problem.kind].shortDescription,
19
+ affectedResolutionKinds: resolutionKinds.filter(function (resolutionKind) {
20
+ return problemAffectsResolutionKind(problem, resolutionKind, analysis);
21
+ }),
22
+ affectedEntrypoints: Object.keys(analysis.entrypoints).filter(function (entrypoint) {
23
+ return resolutionKinds.some(function (resolutionKind) {
24
+ return problemAffectsEntrypointResolution(problem, entrypoint, resolutionKind, analysis);
25
+ });
26
+ })
27
+ };
28
+ }
29
+ return async function analyzePackageResolution(publishedPackage, resolutionKinds) {
30
+ const result = await checkPackage(new Package(packageFileContents(publishedPackage), publishedPackage.name, publishedPackage.version));
31
+ if (result.types === false) {
32
+ return { kind: 'missing-declarations' };
33
+ }
34
+ return {
35
+ kind: 'analyzed',
36
+ entrypoints: Object.keys(result.entrypoints),
37
+ problems: result.problems.map(function (problem) {
38
+ return toProblemReport(problem, result, resolutionKinds);
39
+ })
40
+ };
41
+ };
42
+ }
43
+ //# sourceMappingURL=type-script-package-resolution.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-script-package-resolution.js","sourceRoot":"","sources":["../../../../../source/checks/rules/type-script-package-resolution.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AA4C1E,SAAS,mBAAmB,CACxB,gBAAwD;IAExD,MAAM,KAAK,GAAwC;QAC/C,CAAC,wBAAwB,CAAC,gBAAgB,CAAC,IAAI,EAAE,gBAAgB,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,EACrF,gBAAgB,CAAC,YAAY,CAAC,OAAO;KAC5C,CAAC;IAEF,KAAK,MAAM,KAAK,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAAC;QAC5C,KAAK,CAAC,wBAAwB,CAAC,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC,GAAG,KAAK;aAC/F,eAAe;aACf,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC3C,YAA2C;IAE3C,MAAM,EACF,OAAO,EACP,YAAY,EACZ,eAAe,EACf,4BAA4B,EAC5B,kCAAkC,EACrC,GAAG,YAAY,CAAC;IAEjB,SAAS,eAAe,CACpB,OAAgB,EAChB,QAAkB,EAClB,eAA0C;QAE1C,OAAO;YACH,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,gBAAgB,EAAE,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,gBAAgB;YAChE,uBAAuB,EAAE,eAAe,CAAC,MAAM,CAAC,UAAU,cAAc;gBACpE,OAAO,4BAA4B,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;YAC3E,CAAC,CAAC;YACF,mBAAmB,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,UAAU,UAAU;gBAC9E,OAAO,eAAe,CAAC,IAAI,CAAC,UAAU,cAAc;oBAChD,OAAO,kCAAkC,CAA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