@trustify-da/trustify-da-javascript-client 0.3.0-ea.ff266a3 → 0.3.0-ea.ff694a0

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 (70) hide show
  1. package/README.md +179 -11
  2. package/dist/package.json +13 -4
  3. package/dist/src/analysis.d.ts +16 -0
  4. package/dist/src/analysis.js +53 -4
  5. package/dist/src/batch_opts.d.ts +24 -0
  6. package/dist/src/batch_opts.js +35 -0
  7. package/dist/src/cli.js +171 -4
  8. package/dist/src/cyclone_dx_sbom.d.ts +14 -1
  9. package/dist/src/cyclone_dx_sbom.js +34 -6
  10. package/dist/src/index.d.ts +134 -2
  11. package/dist/src/index.js +352 -6
  12. package/dist/src/license/index.d.ts +2 -2
  13. package/dist/src/license/index.js +4 -4
  14. package/dist/src/license/license_utils.d.ts +40 -0
  15. package/dist/src/license/license_utils.js +134 -0
  16. package/dist/src/license/licenses_api.js +9 -2
  17. package/dist/src/license/project_license.d.ts +1 -6
  18. package/dist/src/license/project_license.js +4 -81
  19. package/dist/src/oci_image/utils.js +11 -2
  20. package/dist/src/provider.d.ts +7 -3
  21. package/dist/src/provider.js +16 -5
  22. package/dist/src/providers/base_java.d.ts +5 -9
  23. package/dist/src/providers/base_java.js +9 -38
  24. package/dist/src/providers/base_javascript.d.ts +30 -3
  25. package/dist/src/providers/base_javascript.js +115 -25
  26. package/dist/src/providers/base_pyproject.d.ts +158 -0
  27. package/dist/src/providers/base_pyproject.js +322 -0
  28. package/dist/src/providers/golang_gomodules.d.ts +22 -12
  29. package/dist/src/providers/golang_gomodules.js +167 -120
  30. package/dist/src/providers/gomod_parser.d.ts +4 -0
  31. package/dist/src/providers/gomod_parser.js +16 -0
  32. package/dist/src/providers/java_gradle.d.ts +19 -0
  33. package/dist/src/providers/java_gradle.js +118 -3
  34. package/dist/src/providers/java_maven.d.ts +9 -1
  35. package/dist/src/providers/java_maven.js +103 -10
  36. package/dist/src/providers/javascript_bun.d.ts +10 -0
  37. package/dist/src/providers/javascript_bun.js +100 -0
  38. package/dist/src/providers/javascript_npm.d.ts +1 -0
  39. package/dist/src/providers/javascript_npm.js +21 -0
  40. package/dist/src/providers/javascript_pnpm.d.ts +1 -1
  41. package/dist/src/providers/javascript_pnpm.js +8 -4
  42. package/dist/src/providers/manifest.d.ts +2 -0
  43. package/dist/src/providers/manifest.js +22 -4
  44. package/dist/src/providers/marker_evaluator.d.ts +14 -0
  45. package/dist/src/providers/marker_evaluator.js +191 -0
  46. package/dist/src/providers/processors/yarn_berry_processor.js +88 -5
  47. package/dist/src/providers/python_controller.d.ts +5 -1
  48. package/dist/src/providers/python_controller.js +8 -4
  49. package/dist/src/providers/python_pip.d.ts +5 -0
  50. package/dist/src/providers/python_pip.js +8 -7
  51. package/dist/src/providers/python_pip_pyproject.d.ts +61 -0
  52. package/dist/src/providers/python_pip_pyproject.js +146 -0
  53. package/dist/src/providers/python_poetry.d.ts +75 -0
  54. package/dist/src/providers/python_poetry.js +238 -0
  55. package/dist/src/providers/python_uv.d.ts +55 -0
  56. package/dist/src/providers/python_uv.js +227 -0
  57. package/dist/src/providers/requirements_parser.js +4 -3
  58. package/dist/src/providers/rust_cargo.d.ts +53 -0
  59. package/dist/src/providers/rust_cargo.js +614 -0
  60. package/dist/src/providers/tree-sitter-gomod.wasm +0 -0
  61. package/dist/src/providers/tree-sitter-requirements.wasm +0 -0
  62. package/dist/src/sbom.d.ts +14 -1
  63. package/dist/src/sbom.js +13 -2
  64. package/dist/src/tools.d.ts +26 -0
  65. package/dist/src/tools.js +58 -0
  66. package/dist/src/workspace.d.ts +70 -0
  67. package/dist/src/workspace.js +256 -0
  68. package/package.json +14 -5
  69. package/dist/src/license/compatibility.d.ts +0 -18
  70. package/dist/src/license/compatibility.js +0 -45
package/dist/src/cli.js CHANGED
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
+ import fs from 'node:fs';
2
3
  import * as path from "path";
3
4
  import yargs from 'yargs';
4
5
  import { hideBin } from 'yargs/helpers';
5
6
  import { getProjectLicense, getLicenseDetails } from './license/index.js';
6
- import client, { selectTrustifyDABackend } from './index.js';
7
+ import client, { selectTrustifyDABackend, generateSbom } from './index.js';
7
8
  // command for component analysis take manifest type and content
8
9
  const component = {
9
10
  command: 'component </path/to/manifest>',
@@ -12,10 +13,18 @@ const component = {
12
13
  desc: 'manifest path for analyzing',
13
14
  type: 'string',
14
15
  normalize: true,
16
+ }).options({
17
+ workspaceDir: {
18
+ alias: 'w',
19
+ desc: 'Workspace root directory (for monorepos; lock file is expected here)',
20
+ type: 'string',
21
+ normalize: true,
22
+ }
15
23
  }),
16
24
  handler: async (args) => {
17
25
  let manifestName = args['/path/to/manifest'];
18
- let res = await client.componentAnalysis(manifestName);
26
+ const opts = args.workspaceDir ? { TRUSTIFY_DA_WORKSPACE_DIR: args.workspaceDir } : {};
27
+ let res = await client.componentAnalysis(manifestName, opts);
19
28
  console.log(JSON.stringify(res, null, 2));
20
29
  }
21
30
  };
@@ -117,15 +126,22 @@ const stack = {
117
126
  desc: 'For JSON report, get only the \'summary\'',
118
127
  type: 'boolean',
119
128
  conflicts: 'html'
129
+ },
130
+ workspaceDir: {
131
+ alias: 'w',
132
+ desc: 'Workspace root directory (for monorepos; lock file is expected here)',
133
+ type: 'string',
134
+ normalize: true,
120
135
  }
121
136
  }),
122
137
  handler: async (args) => {
123
138
  let manifest = args['/path/to/manifest'];
124
139
  let html = args['html'];
125
140
  let summary = args['summary'];
141
+ const opts = args.workspaceDir ? { TRUSTIFY_DA_WORKSPACE_DIR: args.workspaceDir } : {};
126
142
  let theProvidersSummary = new Map();
127
143
  let theProvidersObject = {};
128
- let res = await client.stackAnalysis(manifest, html);
144
+ let res = await client.stackAnalysis(manifest, html, opts);
129
145
  if (summary) {
130
146
  for (let provider in res.providers) {
131
147
  if (res.providers[provider].sources !== undefined) {
@@ -143,6 +159,108 @@ const stack = {
143
159
  console.log(html ? res : JSON.stringify(!html && summary ? theProvidersObject : res, null, 2));
144
160
  }
145
161
  };
162
+ // command for batch stack analysis (workspace)
163
+ const stackBatch = {
164
+ command: 'stack-batch </path/to/workspace-root> [--html|--summary] [--concurrency <n>] [--ignore <pattern>...] [--metadata] [--fail-fast]',
165
+ desc: 'produce stack report for all packages/crates in a workspace (Cargo or JS/TS)',
166
+ builder: yargs => yargs.positional('/path/to/workspace-root', {
167
+ desc: 'workspace root directory (containing Cargo.toml+Cargo.lock or package.json+lock file)',
168
+ type: 'string',
169
+ normalize: true,
170
+ }).options({
171
+ html: {
172
+ alias: 'r',
173
+ desc: 'Get the report as HTML instead of JSON',
174
+ type: 'boolean',
175
+ conflicts: 'summary'
176
+ },
177
+ summary: {
178
+ alias: 's',
179
+ desc: 'For JSON report, get only the \'summary\' per package',
180
+ type: 'boolean',
181
+ conflicts: 'html'
182
+ },
183
+ concurrency: {
184
+ alias: 'c',
185
+ desc: 'Max parallel SBOM generations (default: 10, env: TRUSTIFY_DA_BATCH_CONCURRENCY)',
186
+ type: 'number',
187
+ },
188
+ ignore: {
189
+ alias: 'i',
190
+ desc: 'Extra glob patterns excluded from workspace discovery (merged with defaults). Repeat flag per pattern. Env: TRUSTIFY_DA_WORKSPACE_DISCOVERY_IGNORE (comma-separated)',
191
+ type: 'string',
192
+ array: true,
193
+ },
194
+ metadata: {
195
+ alias: 'm',
196
+ desc: 'Return { analysis, metadata } with per-manifest errors (env: TRUSTIFY_DA_BATCH_METADATA=true)',
197
+ type: 'boolean',
198
+ default: false,
199
+ },
200
+ failFast: {
201
+ desc: 'Stop on first invalid package.json or SBOM error (env: TRUSTIFY_DA_CONTINUE_ON_ERROR=false)',
202
+ type: 'boolean',
203
+ default: false,
204
+ }
205
+ }),
206
+ handler: async (args) => {
207
+ const workspaceRoot = args['/path/to/workspace-root'];
208
+ const html = args['html'];
209
+ const summary = args['summary'];
210
+ const opts = {};
211
+ if (args.concurrency != null) {
212
+ opts.batchConcurrency = args.concurrency;
213
+ }
214
+ const extraIgnores = Array.isArray(args.ignore) ? args.ignore.filter(p => p != null && String(p).trim()) : [];
215
+ if (extraIgnores.length > 0) {
216
+ opts.workspaceDiscoveryIgnore = extraIgnores;
217
+ }
218
+ if (args.metadata) {
219
+ opts.batchMetadata = true;
220
+ }
221
+ if (args.failFast) {
222
+ opts.continueOnError = false;
223
+ }
224
+ let res = await client.stackAnalysisBatch(workspaceRoot, html, opts);
225
+ const batchAnalysis = res && typeof res === 'object' && res != null && 'analysis' in res ? res.analysis : res;
226
+ if (summary && !html && typeof batchAnalysis === 'object') {
227
+ const summaries = {};
228
+ for (const [purl, report] of Object.entries(batchAnalysis)) {
229
+ if (report?.providers) {
230
+ for (const provider of Object.keys(report.providers)) {
231
+ const sources = report.providers[provider]?.sources;
232
+ if (sources) {
233
+ for (const [source, data] of Object.entries(sources)) {
234
+ if (data?.summary) {
235
+ if (!summaries[purl]) {
236
+ summaries[purl] = {};
237
+ }
238
+ if (!summaries[purl][provider]) {
239
+ summaries[purl][provider] = {};
240
+ }
241
+ summaries[purl][provider][source] = data.summary;
242
+ }
243
+ }
244
+ }
245
+ }
246
+ }
247
+ }
248
+ if (res && typeof res === 'object' && res != null && 'metadata' in res) {
249
+ res = { analysis: summaries, metadata: res.metadata };
250
+ }
251
+ else {
252
+ res = summaries;
253
+ }
254
+ }
255
+ if (html) {
256
+ const htmlContent = res && typeof res === 'object' && 'analysis' in res ? res.analysis : res;
257
+ console.log(htmlContent);
258
+ }
259
+ else {
260
+ console.log(JSON.stringify(res, null, 2));
261
+ }
262
+ }
263
+ };
146
264
  // command for license checking
147
265
  const license = {
148
266
  command: 'license </path/to/manifest>',
@@ -208,14 +326,63 @@ const license = {
208
326
  console.log(JSON.stringify(output, null, 2));
209
327
  }
210
328
  };
329
+ const sbom = {
330
+ command: 'sbom </path/to/manifest> [--output]',
331
+ desc: 'generate a CycloneDX SBOM from a manifest file',
332
+ builder: yargs => yargs.positional('/path/to/manifest', {
333
+ desc: 'manifest path for SBOM generation',
334
+ type: 'string',
335
+ normalize: true,
336
+ }).options({
337
+ output: {
338
+ alias: 'o',
339
+ desc: 'Write SBOM JSON to a file instead of stdout',
340
+ type: 'string',
341
+ normalize: true,
342
+ },
343
+ workspaceDir: {
344
+ alias: 'w',
345
+ desc: 'Workspace root directory (for monorepos; lock file is expected here)',
346
+ type: 'string',
347
+ normalize: true,
348
+ }
349
+ }),
350
+ handler: async (args) => {
351
+ let manifest = args['/path/to/manifest'];
352
+ const opts = args.workspaceDir ? { TRUSTIFY_DA_WORKSPACE_DIR: args.workspaceDir } : {};
353
+ let result;
354
+ try {
355
+ result = await generateSbom(manifest, opts);
356
+ }
357
+ catch (err) {
358
+ console.error(JSON.stringify({ error: `Failed to generate SBOM: ${err.message}` }, null, 2));
359
+ process.exit(1);
360
+ }
361
+ const json = JSON.stringify(result, null, 2);
362
+ if (args.output) {
363
+ try {
364
+ fs.writeFileSync(args.output, json);
365
+ }
366
+ catch (err) {
367
+ console.error(JSON.stringify({ error: `Failed to write output file: ${err.message}` }, null, 2));
368
+ process.exit(1);
369
+ }
370
+ }
371
+ else {
372
+ console.log(json);
373
+ }
374
+ }
375
+ };
211
376
  // parse and invoke the command
212
377
  yargs(hideBin(process.argv))
213
- .usage(`Usage: ${process.argv[0].includes("node") ? path.parse(process.argv[1]).base : path.parse(process.argv[0]).base} {component|stack|image|validate-token|license}`)
378
+ .usage(`Usage: ${process.argv[0].includes("node") ? path.parse(process.argv[1]).base : path.parse(process.argv[0]).base} {component|stack|stack-batch|image|validate-token|license|sbom}`)
214
379
  .command(stack)
380
+ .command(stackBatch)
215
381
  .command(component)
216
382
  .command(image)
217
383
  .command(validateToken)
218
384
  .command(license)
385
+ .command(sbom)
219
386
  .scriptName('')
220
387
  .version(false)
221
388
  .demandCommand(1)
@@ -18,9 +18,14 @@ export default class CycloneDxSbom {
18
18
  * Adds a dependency relationship between two components in the SBOM
19
19
  * @param {PackageURL} sourceRef - The source component (parent)
20
20
  * @param {PackageURL} targetRef - The target component (dependency)
21
+ * @param {string} [scope] - Scope of the dependency
22
+ * @param {Array<{alg: string, content: string}>} [targetHashes] - Optional hashes for the target component
21
23
  * @return {CycloneDxSbom} The updated SBOM
22
24
  */
23
- addDependency(sourceRef: PackageURL, targetRef: PackageURL, scope: any): CycloneDxSbom;
25
+ addDependency(sourceRef: PackageURL, targetRef: PackageURL, scope?: string, targetHashes?: Array<{
26
+ alg: string;
27
+ content: string;
28
+ }>): CycloneDxSbom;
24
29
  /** @param {{}} opts - various options, settings and configuration of application.
25
30
  * @return String CycloneDx Sbom json object in a string format
26
31
  */
@@ -50,6 +55,7 @@ export default class CycloneDxSbom {
50
55
  version: any;
51
56
  scope: any;
52
57
  licenses?: any;
58
+ hashes?: any;
53
59
  };
54
60
  /**
55
61
  * This method gets an array of dependencies to be ignored, and remove all of them from CycloneDx Sbom
@@ -70,6 +76,13 @@ export default class CycloneDxSbom {
70
76
  * @return {boolean}
71
77
  */
72
78
  checkIfPackageInsideDependsOnList(component: any, name: string): boolean;
79
+ /**
80
+ * Checks if any entry in the dependsOn list of sourceRef starts with the given purl prefix.
81
+ * @param {PackageURL} sourceRef - The source component
82
+ * @param {string} purlPrefix - The purl prefix to match (e.g. "pkg:npm/minimist@")
83
+ * @return {boolean}
84
+ */
85
+ checkDependsOnByPurlPrefix(sourceRef: PackageURL, purlPrefix: string): boolean;
73
86
  /** Removes the root component from the sbom
74
87
  */
75
88
  removeRootComponent(): void;
@@ -6,10 +6,11 @@ import { PackageURL } from "packageurl-js";
6
6
  * @param type type of package - application or library
7
7
  * @param scope scope of the component - runtime or compile
8
8
  * @param licenses optional license string or array of licenses for the component
9
- * @return {{"bom-ref": string, name, purl: string, type, version, scope, licenses?}}
9
+ * @param hashes optional array of hash objects for the component, e.g. [{alg: "SHA-256", content: "..."}]
10
+ * @return {{"bom-ref": string, name, purl: string, type, version, scope, licenses?, hashes?}}
10
11
  * @private
11
12
  */
12
- function getComponent(component, type, scope, licenses) {
13
+ function getComponent(component, type, scope, licenses, hashes) {
13
14
  let componentObject;
14
15
  if (component instanceof PackageURL) {
15
16
  if (component.namespace) {
@@ -47,6 +48,10 @@ function getComponent(component, type, scope, licenses) {
47
48
  return lic;
48
49
  });
49
50
  }
51
+ // Add hashes if provided (CycloneDX 1.4 format).
52
+ if (hashes && hashes.length > 0) {
53
+ componentObject.hashes = hashes;
54
+ }
50
55
  return componentObject;
51
56
  }
52
57
  function createDependency(dependency) {
@@ -86,16 +91,24 @@ export default class CycloneDxSbom {
86
91
  * Adds a dependency relationship between two components in the SBOM
87
92
  * @param {PackageURL} sourceRef - The source component (parent)
88
93
  * @param {PackageURL} targetRef - The target component (dependency)
94
+ * @param {string} [scope] - Scope of the dependency
95
+ * @param {Array<{alg: string, content: string}>} [targetHashes] - Optional hashes for the target component
89
96
  * @return {CycloneDxSbom} The updated SBOM
90
97
  */
91
- addDependency(sourceRef, targetRef, scope) {
98
+ addDependency(sourceRef, targetRef, scope, targetHashes) {
92
99
  const sourcePurl = sourceRef.toString();
93
100
  const targetPurl = targetRef.toString();
94
101
  // Ensure both components exist in the components list
95
102
  [sourceRef, targetRef].forEach((ref, index) => {
96
103
  const purl = index === 0 ? sourcePurl : targetPurl;
97
- if (this.getComponentIndex(purl) < 0) {
98
- this.components.push(getComponent(ref, "library", scope));
104
+ const existingIndex = this.getComponentIndex(purl);
105
+ if (existingIndex < 0) {
106
+ const hashes = index === 1 ? targetHashes : undefined;
107
+ this.components.push(getComponent(ref, "library", scope, undefined, hashes));
108
+ }
109
+ else if (index === 1 && targetHashes && targetHashes.length > 0 && !this.components[existingIndex].hashes) {
110
+ // Update hashes if the component was first seen without them (e.g. as a source)
111
+ this.components[existingIndex].hashes = targetHashes;
99
112
  }
100
113
  });
101
114
  // Ensure source dependency exists
@@ -120,6 +133,7 @@ export default class CycloneDxSbom {
120
133
  getAsJsonString(opts) {
121
134
  let manifestType = opts["manifest-type"];
122
135
  this.setSourceManifest(opts["source-manifest"]);
136
+ const rootPurl = this.rootComponent?.purl;
123
137
  this.sbomObject = {
124
138
  "bomFormat": "CycloneDX",
125
139
  "specVersion": "1.4",
@@ -129,7 +143,7 @@ export default class CycloneDxSbom {
129
143
  "component": this.rootComponent,
130
144
  "properties": new Array()
131
145
  },
132
- "components": this.components,
146
+ "components": this.components.filter(c => c.purl !== rootPurl),
133
147
  "dependencies": this.dependencies
134
148
  };
135
149
  if (this.rootComponent === undefined) {
@@ -241,6 +255,20 @@ export default class CycloneDxSbom {
241
255
  return false;
242
256
  }
243
257
  }
258
+ /**
259
+ * Checks if any entry in the dependsOn list of sourceRef starts with the given purl prefix.
260
+ * @param {PackageURL} sourceRef - The source component
261
+ * @param {string} purlPrefix - The purl prefix to match (e.g. "pkg:npm/minimist@")
262
+ * @return {boolean}
263
+ */
264
+ checkDependsOnByPurlPrefix(sourceRef, purlPrefix) {
265
+ const sourcePurl = sourceRef.toString();
266
+ const depIndex = this.getDependencyIndex(sourcePurl);
267
+ if (depIndex < 0) {
268
+ return false;
269
+ }
270
+ return this.dependencies[depIndex].dependsOn.some(dep => dep.startsWith(purlPrefix));
271
+ }
244
272
  /** Removes the root component from the sbom
245
273
  */
246
274
  removeRootComponent() {
@@ -13,16 +13,28 @@ export function selectTrustifyDABackend(opts?: {
13
13
  TRUSTIFY_DA_DEBUG?: string | undefined;
14
14
  TRUSTIFY_DA_BACKEND_URL?: string | undefined;
15
15
  }): string;
16
+ /**
17
+ * Generate a CycloneDX SBOM from a manifest file. No backend HTTP request is made.
18
+ *
19
+ * @param {string} manifestPath - path to the manifest file (e.g. pom.xml, package.json)
20
+ * @param {Options} [opts={}] - optional options (e.g. workspace dir, tool paths)
21
+ * @returns {Promise<object>} parsed CycloneDX SBOM JSON object
22
+ * @throws {Error} if the manifest is unsupported or SBOM generation fails
23
+ */
24
+ export function generateSbom(manifestPath: string, opts?: Options): Promise<object>;
16
25
  export { parseImageRef } from "./oci_image/utils.js";
17
26
  export { ImageRef } from "./oci_image/images.js";
18
27
  declare namespace _default {
19
28
  export { componentAnalysis };
20
29
  export { stackAnalysis };
30
+ export { stackAnalysisBatch };
21
31
  export { imageAnalysis };
22
32
  export { validateToken };
33
+ export { generateSbom };
23
34
  }
24
35
  export default _default;
25
36
  export type Options = {
37
+ TRUSTIFY_DA_CARGO_PATH?: string | undefined;
26
38
  TRUSTIFY_DA_DOCKER_PATH?: string | undefined;
27
39
  TRUSTIFY_DA_GO_MVS_LOGIC_ENABLED?: string | undefined;
28
40
  TRUSTIFY_DA_GO_PATH?: string | undefined;
@@ -47,12 +59,45 @@ export type Options = {
47
59
  TRUSTIFY_DA_SYFT_CONFIG_PATH?: string | undefined;
48
60
  TRUSTIFY_DA_SYFT_PATH?: string | undefined;
49
61
  TRUSTIFY_DA_YARN_PATH?: string | undefined;
62
+ TRUSTIFY_DA_WORKSPACE_DIR?: string | undefined;
50
63
  TRUSTIFY_DA_LICENSE_CHECK?: string | undefined;
51
64
  MATCH_MANIFEST_VERSIONS?: string | undefined;
52
65
  TRUSTIFY_DA_SOURCE?: string | undefined;
53
66
  TRUSTIFY_DA_TOKEN?: string | undefined;
54
67
  TRUSTIFY_DA_TELEMETRY_ID?: string | undefined;
55
- [key: string]: string | undefined;
68
+ TRUSTIFY_DA_WORKSPACE_DIR?: string | undefined;
69
+ batchConcurrency?: number | undefined;
70
+ TRUSTIFY_DA_BATCH_CONCURRENCY?: string | undefined;
71
+ workspaceDiscoveryIgnore?: string[] | undefined;
72
+ TRUSTIFY_DA_WORKSPACE_DISCOVERY_IGNORE?: string | undefined;
73
+ continueOnError?: boolean | undefined;
74
+ TRUSTIFY_DA_CONTINUE_ON_ERROR?: string | undefined;
75
+ batchMetadata?: boolean | undefined;
76
+ TRUSTIFY_DA_BATCH_METADATA?: string | undefined;
77
+ TRUSTIFY_DA_UV_PATH?: string | undefined;
78
+ TRUSTIFY_DA_POETRY_PATH?: string | undefined;
79
+ [key: string]: string | number | boolean | string[] | undefined;
80
+ };
81
+ export type BatchAnalysisMetadata = {
82
+ workspaceRoot: string;
83
+ ecosystem: "javascript" | "cargo" | "pyproject" | "unknown";
84
+ total: number;
85
+ successful: number;
86
+ failed: number;
87
+ errors: Array<{
88
+ manifestPath: string;
89
+ phase: "validation" | "sbom";
90
+ reason: string;
91
+ }>;
92
+ };
93
+ export type SbomResult = {
94
+ ok: true;
95
+ purl: string;
96
+ sbom: object;
97
+ } | {
98
+ ok: false;
99
+ manifestPath: string;
100
+ reason: string;
56
101
  };
57
102
  /**
58
103
  * Get component analysis report for a manifest content.
@@ -91,6 +136,81 @@ declare function stackAnalysis(manifest: string, html: false, opts?: Options | u
91
136
  * or backend request failed
92
137
  */
93
138
  declare function stackAnalysis(manifest: string, html?: boolean | undefined, opts?: Options | undefined): Promise<string | import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport>;
139
+ /**
140
+ * @overload
141
+ * @param {string} workspaceRoot
142
+ * @param {true} html
143
+ * @param {Options & { batchMetadata: true }} opts
144
+ * @returns {Promise<{ analysis: string, metadata: BatchAnalysisMetadata }>}
145
+ * @throws {Error}
146
+ */
147
+ declare function stackAnalysisBatch(workspaceRoot: string, html: true, opts: Options & {
148
+ batchMetadata: true;
149
+ }): Promise<{
150
+ analysis: string;
151
+ metadata: BatchAnalysisMetadata;
152
+ }>;
153
+ /**
154
+ * @overload
155
+ * @param {string} workspaceRoot
156
+ * @param {true} html
157
+ * @param {Options & { batchMetadata?: false }} [opts={}]
158
+ * @returns {Promise<string>}
159
+ * @throws {Error}
160
+ */
161
+ declare function stackAnalysisBatch(workspaceRoot: string, html: true, opts?: (Options & {
162
+ batchMetadata?: false;
163
+ }) | undefined): Promise<string>;
164
+ /**
165
+ * @overload
166
+ * @param {string} workspaceRoot
167
+ * @param {false} html
168
+ * @param {Options & { batchMetadata: true }} opts
169
+ * @returns {Promise<{ analysis: Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>, metadata: BatchAnalysisMetadata }>}
170
+ * @throws {Error}
171
+ */
172
+ declare function stackAnalysisBatch(workspaceRoot: string, html: false, opts: Options & {
173
+ batchMetadata: true;
174
+ }): Promise<{
175
+ analysis: {
176
+ [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
177
+ };
178
+ metadata: BatchAnalysisMetadata;
179
+ }>;
180
+ /**
181
+ * @overload
182
+ * @param {string} workspaceRoot
183
+ * @param {false} html
184
+ * @param {Options & { batchMetadata?: false }} [opts={}]
185
+ * @returns {Promise<Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>>}
186
+ * @throws {Error}
187
+ */
188
+ declare function stackAnalysisBatch(workspaceRoot: string, html: false, opts?: (Options & {
189
+ batchMetadata?: false;
190
+ }) | undefined): Promise<{
191
+ [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
192
+ }>;
193
+ /**
194
+ * Get stack analysis for all workspace packages/crates (batch).
195
+ * Detects ecosystem from workspace root: Cargo (Cargo.toml + Cargo.lock) or JS/TS (package.json + lock file).
196
+ * SBOMs are generated in parallel (see `batchConcurrency`) unless `continueOnError: false` (fail-fast sequential).
197
+ * With `opts.batchMetadata` / `TRUSTIFY_DA_BATCH_METADATA`, returns `{ analysis, metadata }` including validation and SBOM errors.
198
+ *
199
+ * @overload
200
+ * @param {string} workspaceRoot - Path to workspace root (containing lock file and workspace config)
201
+ * @param {boolean} [html=false] - true returns HTML, false returns JSON report
202
+ * @param {Options} [opts={}] - `batchConcurrency`, discovery ignores, `continueOnError` (default true), `batchMetadata` (default false)
203
+ * @returns {Promise<string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>|{ analysis: string|Object.<string, import('@trustify-da/trustify-da-api-model/model/v5/AnalysisReport').AnalysisReport>, metadata: BatchAnalysisMetadata }>}
204
+ * @throws {Error} if workspace root invalid, no manifests found, no packages pass validation, no SBOMs produced, or backend request failed. When `opts.batchMetadata` is set, `error.batchMetadata` may be set on thrown errors.
205
+ */
206
+ declare function stackAnalysisBatch(workspaceRoot: string, html?: boolean | undefined, opts?: Options | undefined): Promise<string | {
207
+ [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
208
+ } | {
209
+ analysis: string | {
210
+ [x: string]: import("@trustify-da/trustify-da-api-model/model/v5/AnalysisReport").AnalysisReport;
211
+ };
212
+ metadata: BatchAnalysisMetadata;
213
+ }>;
94
214
  /**
95
215
  * @overload
96
216
  * @param {Array<string>} imageRefs
@@ -131,4 +251,16 @@ declare function imageAnalysis(imageRefs: Array<string>, html?: boolean | undefi
131
251
  * @throws {Error} if the backend request failed.
132
252
  */
133
253
  declare function validateToken(opts?: Options): Promise<object>;
134
- export { getProjectLicense, findLicenseFilePath, identifyLicenseViaBackend, getLicenseDetails, licensesFromReport, normalizeLicensesResponse, runLicenseCheck, getCompatibility } from "./license/index.js";
254
+ import { discoverMavenModules } from './providers/java_maven.js';
255
+ import { discoverGradleSubprojects } from './providers/java_gradle.js';
256
+ import { discoverGoWorkspaceModules } from './providers/golang_gomodules.js';
257
+ import { discoverUvWorkspaceMembers } from './providers/python_uv.js';
258
+ import { discoverWorkspacePackages } from './workspace.js';
259
+ import { discoverWorkspaceCrates } from './workspace.js';
260
+ import { validatePackageJson } from './workspace.js';
261
+ import { resolveWorkspaceDiscoveryIgnore } from './workspace.js';
262
+ import { filterManifestPathsByDiscoveryIgnore } from './workspace.js';
263
+ import { resolveContinueOnError } from './batch_opts.js';
264
+ import { resolveBatchMetadata } from './batch_opts.js';
265
+ export { discoverMavenModules, discoverGradleSubprojects, discoverGoWorkspaceModules, discoverUvWorkspaceMembers, discoverWorkspacePackages, discoverWorkspaceCrates, validatePackageJson, resolveWorkspaceDiscoveryIgnore, filterManifestPathsByDiscoveryIgnore, resolveContinueOnError, resolveBatchMetadata };
266
+ export { getProjectLicense, findLicenseFilePath, identifyLicense, getLicenseDetails, licensesFromReport, normalizeLicensesResponse, runLicenseCheck, getCompatibility } from "./license/index.js";