@scanoss_test/sdk 2.0.6 → 2.0.8
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.mts +33 -1
- package/dist/index.d.ts +33 -1
- package/dist/index.js +34 -11
- package/dist/index.mjs +34 -11
- package/package.json +6 -6
- package/src/client.ts +32 -5
- package/src/gen/scanoss/v1/commands_pb.ts +81 -10
- package/src/types.ts +15 -0
package/dist/index.d.mts
CHANGED
|
@@ -162,6 +162,12 @@ type ScanResult$1 = Message<"scanoss.v1.ScanResult"> & {
|
|
|
162
162
|
* @generated from field: int32 total_matches = 4;
|
|
163
163
|
*/
|
|
164
164
|
totalMatches: number;
|
|
165
|
+
/**
|
|
166
|
+
* Raw JSON response from SCANOSS API
|
|
167
|
+
*
|
|
168
|
+
* @generated from field: string raw_json = 5;
|
|
169
|
+
*/
|
|
170
|
+
rawJson: string;
|
|
165
171
|
};
|
|
166
172
|
/**
|
|
167
173
|
* Filter files result
|
|
@@ -286,6 +292,15 @@ interface FileResult {
|
|
|
286
292
|
path: string;
|
|
287
293
|
matches: Match[];
|
|
288
294
|
}
|
|
295
|
+
/** Progress information during scan */
|
|
296
|
+
interface ScanProgress {
|
|
297
|
+
filesScanned: number;
|
|
298
|
+
totalFiles: number;
|
|
299
|
+
currentFile: string;
|
|
300
|
+
matchesSoFar: number;
|
|
301
|
+
}
|
|
302
|
+
/** Progress callback function */
|
|
303
|
+
type ProgressCallback = (progress: ScanProgress) => void;
|
|
289
304
|
/** Scan command parameters */
|
|
290
305
|
interface ScanParams {
|
|
291
306
|
path: string;
|
|
@@ -295,6 +310,10 @@ interface ScanParams {
|
|
|
295
310
|
exclude?: string[];
|
|
296
311
|
apiUrl?: string;
|
|
297
312
|
apiKey?: string;
|
|
313
|
+
/** Number of files per batch for progress reporting (0 = no progress) */
|
|
314
|
+
batchSize?: number;
|
|
315
|
+
/** Callback function for progress updates */
|
|
316
|
+
onProgress?: ProgressCallback;
|
|
298
317
|
}
|
|
299
318
|
/** Scan result */
|
|
300
319
|
interface ScanResult {
|
|
@@ -391,6 +410,19 @@ declare class Scanoss {
|
|
|
391
410
|
private send;
|
|
392
411
|
/**
|
|
393
412
|
* Scan files for open source matches.
|
|
413
|
+
*
|
|
414
|
+
* @param params - Scan parameters including path, filters, and optional progress callback
|
|
415
|
+
* @example
|
|
416
|
+
* ```typescript
|
|
417
|
+
* // Scan with progress reporting
|
|
418
|
+
* const result = await scanoss.scan({
|
|
419
|
+
* path: './src',
|
|
420
|
+
* batchSize: 50,
|
|
421
|
+
* onProgress: (progress) => {
|
|
422
|
+
* console.log(`Scanned ${progress.filesScanned}/${progress.totalFiles} files`);
|
|
423
|
+
* }
|
|
424
|
+
* });
|
|
425
|
+
* ```
|
|
394
426
|
*/
|
|
395
427
|
scan(params: ScanParams): Promise<ScanResult$1>;
|
|
396
428
|
/**
|
|
@@ -441,4 +473,4 @@ declare class ScanossError extends Error {
|
|
|
441
473
|
*/
|
|
442
474
|
declare function getBinaryPath(): string;
|
|
443
475
|
|
|
444
|
-
export { type FileInfo, type FileResult, type FilterFilesParams, type FilterFilesResult, type FingerprintParams, type FingerprintResult, type GenerateSbomParams, type GenerateSbomResult, type Match, type OutputFormat, type ScanParams, type ScanResult, type ScanType, Scanoss, ScanossError, type ScanossOptions, type VersionResult, getBinaryPath };
|
|
476
|
+
export { type FileInfo, type FileResult, type FilterFilesParams, type FilterFilesResult, type FingerprintParams, type FingerprintResult, type GenerateSbomParams, type GenerateSbomResult, type Match, type OutputFormat, type ProgressCallback, type ScanParams, type ScanProgress, type ScanResult, type ScanType, Scanoss, ScanossError, type ScanossOptions, type VersionResult, getBinaryPath };
|
package/dist/index.d.ts
CHANGED
|
@@ -162,6 +162,12 @@ type ScanResult$1 = Message<"scanoss.v1.ScanResult"> & {
|
|
|
162
162
|
* @generated from field: int32 total_matches = 4;
|
|
163
163
|
*/
|
|
164
164
|
totalMatches: number;
|
|
165
|
+
/**
|
|
166
|
+
* Raw JSON response from SCANOSS API
|
|
167
|
+
*
|
|
168
|
+
* @generated from field: string raw_json = 5;
|
|
169
|
+
*/
|
|
170
|
+
rawJson: string;
|
|
165
171
|
};
|
|
166
172
|
/**
|
|
167
173
|
* Filter files result
|
|
@@ -286,6 +292,15 @@ interface FileResult {
|
|
|
286
292
|
path: string;
|
|
287
293
|
matches: Match[];
|
|
288
294
|
}
|
|
295
|
+
/** Progress information during scan */
|
|
296
|
+
interface ScanProgress {
|
|
297
|
+
filesScanned: number;
|
|
298
|
+
totalFiles: number;
|
|
299
|
+
currentFile: string;
|
|
300
|
+
matchesSoFar: number;
|
|
301
|
+
}
|
|
302
|
+
/** Progress callback function */
|
|
303
|
+
type ProgressCallback = (progress: ScanProgress) => void;
|
|
289
304
|
/** Scan command parameters */
|
|
290
305
|
interface ScanParams {
|
|
291
306
|
path: string;
|
|
@@ -295,6 +310,10 @@ interface ScanParams {
|
|
|
295
310
|
exclude?: string[];
|
|
296
311
|
apiUrl?: string;
|
|
297
312
|
apiKey?: string;
|
|
313
|
+
/** Number of files per batch for progress reporting (0 = no progress) */
|
|
314
|
+
batchSize?: number;
|
|
315
|
+
/** Callback function for progress updates */
|
|
316
|
+
onProgress?: ProgressCallback;
|
|
298
317
|
}
|
|
299
318
|
/** Scan result */
|
|
300
319
|
interface ScanResult {
|
|
@@ -391,6 +410,19 @@ declare class Scanoss {
|
|
|
391
410
|
private send;
|
|
392
411
|
/**
|
|
393
412
|
* Scan files for open source matches.
|
|
413
|
+
*
|
|
414
|
+
* @param params - Scan parameters including path, filters, and optional progress callback
|
|
415
|
+
* @example
|
|
416
|
+
* ```typescript
|
|
417
|
+
* // Scan with progress reporting
|
|
418
|
+
* const result = await scanoss.scan({
|
|
419
|
+
* path: './src',
|
|
420
|
+
* batchSize: 50,
|
|
421
|
+
* onProgress: (progress) => {
|
|
422
|
+
* console.log(`Scanned ${progress.filesScanned}/${progress.totalFiles} files`);
|
|
423
|
+
* }
|
|
424
|
+
* });
|
|
425
|
+
* ```
|
|
394
426
|
*/
|
|
395
427
|
scan(params: ScanParams): Promise<ScanResult$1>;
|
|
396
428
|
/**
|
|
@@ -441,4 +473,4 @@ declare class ScanossError extends Error {
|
|
|
441
473
|
*/
|
|
442
474
|
declare function getBinaryPath(): string;
|
|
443
475
|
|
|
444
|
-
export { type FileInfo, type FileResult, type FilterFilesParams, type FilterFilesResult, type FingerprintParams, type FingerprintResult, type GenerateSbomParams, type GenerateSbomResult, type Match, type OutputFormat, type ScanParams, type ScanResult, type ScanType, Scanoss, ScanossError, type ScanossOptions, type VersionResult, getBinaryPath };
|
|
476
|
+
export { type FileInfo, type FileResult, type FilterFilesParams, type FilterFilesResult, type FingerprintParams, type FingerprintResult, type GenerateSbomParams, type GenerateSbomResult, type Match, type OutputFormat, type ProgressCallback, type ScanParams, type ScanProgress, type ScanResult, type ScanType, Scanoss, ScanossError, type ScanossOptions, type VersionResult, getBinaryPath };
|
package/dist/index.js
CHANGED
|
@@ -88,14 +88,14 @@ var import_codegenv22 = require("@bufbuild/protobuf/codegenv2");
|
|
|
88
88
|
var file_scanoss_v1_enums = /* @__PURE__ */ (0, import_codegenv22.fileDesc)("ChZzY2Fub3NzL3YxL2VudW1zLnByb3RvEgpzY2Fub3NzLnYxKqgBCgxPdXRwdXRGb3JtYXQSHQoZT1VUUFVUX0ZPUk1BVF9VTlNQRUNJRklFRBAAEhYKEk9VVFBVVF9GT1JNQVRfSlNPThABEhYKEk9VVFBVVF9GT1JNQVRfU1BEWBACEhsKF09VVFBVVF9GT1JNQVRfQ1lDTE9ORURYEAMSFQoRT1VUUFVUX0ZPUk1BVF9DU1YQBBIVChFPVVRQVVRfRk9STUFUX1dGUBAFKlYKCFNjYW5UeXBlEhkKFVNDQU5fVFlQRV9VTlNQRUNJRklFRBAAEhYKElNDQU5fVFlQRV9JREVOVElGWRABEhcKE1NDQU5fVFlQRV9CTEFDS0xJU1QQAkJNCg9jb20uc2Nhbm9zcy5nZW5QAVo4Z2l0aHViLmNvbS9zY2Fub3NzL3NjYW5vc3MvY29yZS9nZW4vc2Nhbm9zcy92MTtzY2Fub3NzdjFiBnByb3RvMw");
|
|
89
89
|
|
|
90
90
|
// src/gen/scanoss/v1/commands_pb.ts
|
|
91
|
-
var file_scanoss_v1_commands = /* @__PURE__ */ (0, import_codegenv23.fileDesc)("
|
|
91
|
+
var file_scanoss_v1_commands = /* @__PURE__ */ (0, import_codegenv23.fileDesc)("ChlzY2Fub3NzL3YxL2NvbW1hbmRzLnByb3RvEgpzY2Fub3NzLnYxIqECCgdSZXF1ZXN0EgoKAmlkGAEgASgFEicKBHNjYW4YAiABKAsyFy5zY2Fub3NzLnYxLlNjYW5Db21tYW5kSAASNgoMZmlsdGVyX2ZpbGVzGAMgASgLMh4uc2Nhbm9zcy52MS5GaWx0ZXJGaWxlc0NvbW1hbmRIABI1CgtmaW5nZXJwcmludBgEIAEoCzIeLnNjYW5vc3MudjEuRmluZ2VycHJpbnRDb21tYW5kSAASOAoNZ2VuZXJhdGVfc2JvbRgFIAEoCzIfLnNjYW5vc3MudjEuR2VuZXJhdGVTYm9tQ29tbWFuZEgAEi0KB3ZlcnNpb24YBiABKAsyGi5zY2Fub3NzLnYxLlZlcnNpb25Db21tYW5kSABCCQoHY29tbWFuZCKFAwoIUmVzcG9uc2USCgoCaWQYASABKAUSEAoIaXNfZmluYWwYByABKAgSJgoEc2NhbhgCIAEoCzIWLnNjYW5vc3MudjEuU2NhblJlc3VsdEgAEjUKDGZpbHRlcl9maWxlcxgDIAEoCzIdLnNjYW5vc3MudjEuRmlsdGVyRmlsZXNSZXN1bHRIABI0CgtmaW5nZXJwcmludBgEIAEoCzIdLnNjYW5vc3MudjEuRmluZ2VycHJpbnRSZXN1bHRIABI3Cg1nZW5lcmF0ZV9zYm9tGAUgASgLMh4uc2Nhbm9zcy52MS5HZW5lcmF0ZVNib21SZXN1bHRIABIsCgd2ZXJzaW9uGAYgASgLMhkuc2Nhbm9zcy52MS5WZXJzaW9uUmVzdWx0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XJwcmludENvbW1hbmQSDAoEcGF0aBgBIAEoCRIPCgdpbmNsdWRlGAIgAygJEg8KB2V4Y2x1ZGUYAyADKAkSEwoLb3V0cHV0X3BhdGgYBCABKAkiXgoRRmluZ2VycHJpbnRSZXN1bHQSCwoDd2ZwGAEgASgJEhMKC291dHB1dF9wYXRoGAIgASgJEhIKCmZpbGVfY291bnQYAyABKAUSEwoLdG90YWxfYnl0ZXMYBCABKAMihwEKE0dlbmVyYXRlU2JvbUNvbW1hbmQSEgoKaW5wdXRfcGF0aBgBIAEoCRIoCgZmb3JtYXQYAiABKA4yGC5zY2Fub3NzLnYxLk91dHB1dEZvcm1hdBITCgtvdXRwdXRfcGF0aBgDIAEoCRIMCgRuYW1lGAQgASgJEg8KB3ZlcnNpb24YBSABKAkiegoSR2VuZXJhdGVTYm9tUmVzdWx0EgwKBHNib20YASABKAkSEwoLb3V0cHV0X3BhdGgYAiABKAkSKAoGZm9ybWF0GAMgASgOMhguc2Nhbm9zcy52MS5PdXRwdXRGb3JtYXQSFwoPY29tcG9uZW50X2NvdW50GAQgASgFIhAKDlZlcnNpb25Db21tYW5kIlgKDVZlcnNpb25SZXN1bHQSDwoHdmVyc2lvbhgBIAEoCRIOCgZjb21taXQYAiABKAkSEgoKYnVpbGRfZGF0ZRgDIAEoCRISCgpnb192ZXJzaW9uGAQgASgJQk0KD2NvbS5zY2Fub3NzLmdlblABWjhnaXRodWIuY29tL3NjYW5vc3Mvc2Nhbm9zcy9jb3JlL2dlbi9zY2Fub3NzL3YxO3NjYW5vc3N2MWIGcHJvdG8z", [file_scanoss_v1_types, file_scanoss_v1_enums]);
|
|
92
92
|
var RequestSchema = /* @__PURE__ */ (0, import_codegenv23.messageDesc)(file_scanoss_v1_commands, 0);
|
|
93
93
|
var ResponseSchema = /* @__PURE__ */ (0, import_codegenv23.messageDesc)(file_scanoss_v1_commands, 1);
|
|
94
94
|
var ScanCommandSchema = /* @__PURE__ */ (0, import_codegenv23.messageDesc)(file_scanoss_v1_commands, 2);
|
|
95
|
-
var FilterFilesCommandSchema = /* @__PURE__ */ (0, import_codegenv23.messageDesc)(file_scanoss_v1_commands,
|
|
96
|
-
var FingerprintCommandSchema = /* @__PURE__ */ (0, import_codegenv23.messageDesc)(file_scanoss_v1_commands,
|
|
97
|
-
var GenerateSbomCommandSchema = /* @__PURE__ */ (0, import_codegenv23.messageDesc)(file_scanoss_v1_commands,
|
|
98
|
-
var VersionCommandSchema = /* @__PURE__ */ (0, import_codegenv23.messageDesc)(file_scanoss_v1_commands,
|
|
95
|
+
var FilterFilesCommandSchema = /* @__PURE__ */ (0, import_codegenv23.messageDesc)(file_scanoss_v1_commands, 5);
|
|
96
|
+
var FingerprintCommandSchema = /* @__PURE__ */ (0, import_codegenv23.messageDesc)(file_scanoss_v1_commands, 7);
|
|
97
|
+
var GenerateSbomCommandSchema = /* @__PURE__ */ (0, import_codegenv23.messageDesc)(file_scanoss_v1_commands, 9);
|
|
98
|
+
var VersionCommandSchema = /* @__PURE__ */ (0, import_codegenv23.messageDesc)(file_scanoss_v1_commands, 11);
|
|
99
99
|
|
|
100
100
|
// src/client.ts
|
|
101
101
|
var Scanoss = class {
|
|
@@ -153,10 +153,19 @@ var Scanoss = class {
|
|
|
153
153
|
response.result.value.code,
|
|
154
154
|
response.result.value.message
|
|
155
155
|
));
|
|
156
|
-
|
|
156
|
+
this.pending.delete(response.id);
|
|
157
|
+
} else if (response.result.case === "scanProgress" && pending.onProgress) {
|
|
158
|
+
const progress = response.result.value;
|
|
159
|
+
pending.onProgress({
|
|
160
|
+
filesScanned: progress.filesScanned,
|
|
161
|
+
totalFiles: progress.totalFiles,
|
|
162
|
+
currentFile: progress.currentFile,
|
|
163
|
+
matchesSoFar: progress.matchesSoFar
|
|
164
|
+
});
|
|
165
|
+
} else if (response.isFinal || response.result.case !== "scanProgress") {
|
|
157
166
|
pending.resolve(response);
|
|
167
|
+
this.pending.delete(response.id);
|
|
158
168
|
}
|
|
159
|
-
this.pending.delete(response.id);
|
|
160
169
|
}
|
|
161
170
|
} catch (err) {
|
|
162
171
|
console.error("Failed to parse daemon response:", err);
|
|
@@ -169,13 +178,13 @@ var Scanoss = class {
|
|
|
169
178
|
}
|
|
170
179
|
this.pending.clear();
|
|
171
180
|
}
|
|
172
|
-
send(request) {
|
|
181
|
+
send(request, onProgress) {
|
|
173
182
|
return new Promise((resolve, reject) => {
|
|
174
183
|
if (!this.process || this.closed) {
|
|
175
184
|
reject(new Error("Daemon process is not running"));
|
|
176
185
|
return;
|
|
177
186
|
}
|
|
178
|
-
this.pending.set(request.id, { resolve, reject });
|
|
187
|
+
this.pending.set(request.id, { resolve, reject, onProgress });
|
|
179
188
|
const data = (0, import_protobuf.toBinary)(RequestSchema, request);
|
|
180
189
|
const lengthBuf = Buffer.alloc(4);
|
|
181
190
|
lengthBuf.writeUInt32BE(data.length);
|
|
@@ -185,6 +194,19 @@ var Scanoss = class {
|
|
|
185
194
|
}
|
|
186
195
|
/**
|
|
187
196
|
* Scan files for open source matches.
|
|
197
|
+
*
|
|
198
|
+
* @param params - Scan parameters including path, filters, and optional progress callback
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* // Scan with progress reporting
|
|
202
|
+
* const result = await scanoss.scan({
|
|
203
|
+
* path: './src',
|
|
204
|
+
* batchSize: 50,
|
|
205
|
+
* onProgress: (progress) => {
|
|
206
|
+
* console.log(`Scanned ${progress.filesScanned}/${progress.totalFiles} files`);
|
|
207
|
+
* }
|
|
208
|
+
* });
|
|
209
|
+
* ```
|
|
188
210
|
*/
|
|
189
211
|
async scan(params) {
|
|
190
212
|
const id = ++this.requestId;
|
|
@@ -195,13 +217,14 @@ var Scanoss = class {
|
|
|
195
217
|
include: params.include ?? [],
|
|
196
218
|
exclude: params.exclude ?? [],
|
|
197
219
|
apiUrl: params.apiUrl,
|
|
198
|
-
apiKey: params.apiKey
|
|
220
|
+
apiKey: params.apiKey,
|
|
221
|
+
batchSize: params.batchSize ?? 0
|
|
199
222
|
});
|
|
200
223
|
const request = (0, import_protobuf.create)(RequestSchema, {
|
|
201
224
|
id,
|
|
202
225
|
command: { case: "scan", value: scanCmd }
|
|
203
226
|
});
|
|
204
|
-
const response = await this.send(request);
|
|
227
|
+
const response = await this.send(request, params.onProgress);
|
|
205
228
|
if (response.result.case !== "scan") {
|
|
206
229
|
throw new Error("Unexpected response type");
|
|
207
230
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -67,14 +67,14 @@ import { enumDesc, fileDesc as fileDesc2 } from "@bufbuild/protobuf/codegenv2";
|
|
|
67
67
|
var file_scanoss_v1_enums = /* @__PURE__ */ fileDesc2("ChZzY2Fub3NzL3YxL2VudW1zLnByb3RvEgpzY2Fub3NzLnYxKqgBCgxPdXRwdXRGb3JtYXQSHQoZT1VUUFVUX0ZPUk1BVF9VTlNQRUNJRklFRBAAEhYKEk9VVFBVVF9GT1JNQVRfSlNPThABEhYKEk9VVFBVVF9GT1JNQVRfU1BEWBACEhsKF09VVFBVVF9GT1JNQVRfQ1lDTE9ORURYEAMSFQoRT1VUUFVUX0ZPUk1BVF9DU1YQBBIVChFPVVRQVVRfRk9STUFUX1dGUBAFKlYKCFNjYW5UeXBlEhkKFVNDQU5fVFlQRV9VTlNQRUNJRklFRBAAEhYKElNDQU5fVFlQRV9JREVOVElGWRABEhcKE1NDQU5fVFlQRV9CTEFDS0xJU1QQAkJNCg9jb20uc2Nhbm9zcy5nZW5QAVo4Z2l0aHViLmNvbS9zY2Fub3NzL3NjYW5vc3MvY29yZS9nZW4vc2Nhbm9zcy92MTtzY2Fub3NzdjFiBnByb3RvMw");
|
|
68
68
|
|
|
69
69
|
// src/gen/scanoss/v1/commands_pb.ts
|
|
70
|
-
var file_scanoss_v1_commands = /* @__PURE__ */ fileDesc3("
|
|
70
|
+
var file_scanoss_v1_commands = /* @__PURE__ */ fileDesc3("ChlzY2Fub3NzL3YxL2NvbW1hbmRzLnByb3RvEgpzY2Fub3NzLnYxIqECCgdSZXF1ZXN0EgoKAm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iABKA4yGC5zY2Fub3NzLnYxLk91dHB1dEZvcm1hdBITCgtvdXRwdXRfcGF0aBgDIAEoCRIMCgRuYW1lGAQgASgJEg8KB3ZlcnNpb24YBSABKAkiegoSR2VuZXJhdGVTYm9tUmVzdWx0EgwKBHNib20YASABKAkSEwoLb3V0cHV0X3BhdGgYAiABKAkSKAoGZm9ybWF0GAMgASgOMhguc2Nhbm9zcy52MS5PdXRwdXRGb3JtYXQSFwoPY29tcG9uZW50X2NvdW50GAQgASgFIhAKDlZlcnNpb25Db21tYW5kIlgKDVZlcnNpb25SZXN1bHQSDwoHdmVyc2lvbhgBIAEoCRIOCgZjb21taXQYAiABKAkSEgoKYnVpbGRfZGF0ZRgDIAEoCRISCgpnb192ZXJzaW9uGAQgASgJQk0KD2NvbS5zY2Fub3NzLmdlblABWjhnaXRodWIuY29tL3NjYW5vc3Mvc2Nhbm9zcy9jb3JlL2dlbi9zY2Fub3NzL3YxO3NjYW5vc3N2MWIGcHJvdG8z", [file_scanoss_v1_types, file_scanoss_v1_enums]);
|
|
71
71
|
var RequestSchema = /* @__PURE__ */ messageDesc2(file_scanoss_v1_commands, 0);
|
|
72
72
|
var ResponseSchema = /* @__PURE__ */ messageDesc2(file_scanoss_v1_commands, 1);
|
|
73
73
|
var ScanCommandSchema = /* @__PURE__ */ messageDesc2(file_scanoss_v1_commands, 2);
|
|
74
|
-
var FilterFilesCommandSchema = /* @__PURE__ */ messageDesc2(file_scanoss_v1_commands,
|
|
75
|
-
var FingerprintCommandSchema = /* @__PURE__ */ messageDesc2(file_scanoss_v1_commands,
|
|
76
|
-
var GenerateSbomCommandSchema = /* @__PURE__ */ messageDesc2(file_scanoss_v1_commands,
|
|
77
|
-
var VersionCommandSchema = /* @__PURE__ */ messageDesc2(file_scanoss_v1_commands,
|
|
74
|
+
var FilterFilesCommandSchema = /* @__PURE__ */ messageDesc2(file_scanoss_v1_commands, 5);
|
|
75
|
+
var FingerprintCommandSchema = /* @__PURE__ */ messageDesc2(file_scanoss_v1_commands, 7);
|
|
76
|
+
var GenerateSbomCommandSchema = /* @__PURE__ */ messageDesc2(file_scanoss_v1_commands, 9);
|
|
77
|
+
var VersionCommandSchema = /* @__PURE__ */ messageDesc2(file_scanoss_v1_commands, 11);
|
|
78
78
|
|
|
79
79
|
// src/client.ts
|
|
80
80
|
var Scanoss = class {
|
|
@@ -132,10 +132,19 @@ var Scanoss = class {
|
|
|
132
132
|
response.result.value.code,
|
|
133
133
|
response.result.value.message
|
|
134
134
|
));
|
|
135
|
-
|
|
135
|
+
this.pending.delete(response.id);
|
|
136
|
+
} else if (response.result.case === "scanProgress" && pending.onProgress) {
|
|
137
|
+
const progress = response.result.value;
|
|
138
|
+
pending.onProgress({
|
|
139
|
+
filesScanned: progress.filesScanned,
|
|
140
|
+
totalFiles: progress.totalFiles,
|
|
141
|
+
currentFile: progress.currentFile,
|
|
142
|
+
matchesSoFar: progress.matchesSoFar
|
|
143
|
+
});
|
|
144
|
+
} else if (response.isFinal || response.result.case !== "scanProgress") {
|
|
136
145
|
pending.resolve(response);
|
|
146
|
+
this.pending.delete(response.id);
|
|
137
147
|
}
|
|
138
|
-
this.pending.delete(response.id);
|
|
139
148
|
}
|
|
140
149
|
} catch (err) {
|
|
141
150
|
console.error("Failed to parse daemon response:", err);
|
|
@@ -148,13 +157,13 @@ var Scanoss = class {
|
|
|
148
157
|
}
|
|
149
158
|
this.pending.clear();
|
|
150
159
|
}
|
|
151
|
-
send(request) {
|
|
160
|
+
send(request, onProgress) {
|
|
152
161
|
return new Promise((resolve, reject) => {
|
|
153
162
|
if (!this.process || this.closed) {
|
|
154
163
|
reject(new Error("Daemon process is not running"));
|
|
155
164
|
return;
|
|
156
165
|
}
|
|
157
|
-
this.pending.set(request.id, { resolve, reject });
|
|
166
|
+
this.pending.set(request.id, { resolve, reject, onProgress });
|
|
158
167
|
const data = toBinary(RequestSchema, request);
|
|
159
168
|
const lengthBuf = Buffer.alloc(4);
|
|
160
169
|
lengthBuf.writeUInt32BE(data.length);
|
|
@@ -164,6 +173,19 @@ var Scanoss = class {
|
|
|
164
173
|
}
|
|
165
174
|
/**
|
|
166
175
|
* Scan files for open source matches.
|
|
176
|
+
*
|
|
177
|
+
* @param params - Scan parameters including path, filters, and optional progress callback
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* // Scan with progress reporting
|
|
181
|
+
* const result = await scanoss.scan({
|
|
182
|
+
* path: './src',
|
|
183
|
+
* batchSize: 50,
|
|
184
|
+
* onProgress: (progress) => {
|
|
185
|
+
* console.log(`Scanned ${progress.filesScanned}/${progress.totalFiles} files`);
|
|
186
|
+
* }
|
|
187
|
+
* });
|
|
188
|
+
* ```
|
|
167
189
|
*/
|
|
168
190
|
async scan(params) {
|
|
169
191
|
const id = ++this.requestId;
|
|
@@ -174,13 +196,14 @@ var Scanoss = class {
|
|
|
174
196
|
include: params.include ?? [],
|
|
175
197
|
exclude: params.exclude ?? [],
|
|
176
198
|
apiUrl: params.apiUrl,
|
|
177
|
-
apiKey: params.apiKey
|
|
199
|
+
apiKey: params.apiKey,
|
|
200
|
+
batchSize: params.batchSize ?? 0
|
|
178
201
|
});
|
|
179
202
|
const request = create(RequestSchema, {
|
|
180
203
|
id,
|
|
181
204
|
command: { case: "scan", value: scanCmd }
|
|
182
205
|
});
|
|
183
|
-
const response = await this.send(request);
|
|
206
|
+
const response = await this.send(request, params.onProgress);
|
|
184
207
|
if (response.result.case !== "scan") {
|
|
185
208
|
throw new Error("Unexpected response type");
|
|
186
209
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scanoss_test/sdk",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "SCANOSS SDK for Software Composition Analysis",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
"@bufbuild/protobuf": "^2.10.2"
|
|
59
59
|
},
|
|
60
60
|
"optionalDependencies": {
|
|
61
|
-
"@scanoss_test/darwin-arm64": "2.0.
|
|
62
|
-
"@scanoss_test/darwin-x64": "2.0.
|
|
63
|
-
"@scanoss_test/linux-arm64": "2.0.
|
|
64
|
-
"@scanoss_test/linux-x64": "2.0.
|
|
65
|
-
"@scanoss_test/win32-x64": "2.0.
|
|
61
|
+
"@scanoss_test/darwin-arm64": "2.0.8",
|
|
62
|
+
"@scanoss_test/darwin-x64": "2.0.8",
|
|
63
|
+
"@scanoss_test/linux-arm64": "2.0.8",
|
|
64
|
+
"@scanoss_test/linux-x64": "2.0.8",
|
|
65
|
+
"@scanoss_test/win32-x64": "2.0.8"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/src/client.ts
CHANGED
|
@@ -30,6 +30,7 @@ import type {
|
|
|
30
30
|
FilterFilesParams,
|
|
31
31
|
FingerprintParams,
|
|
32
32
|
GenerateSbomParams,
|
|
33
|
+
ProgressCallback,
|
|
33
34
|
} from './types';
|
|
34
35
|
|
|
35
36
|
/** Options for creating a Scanoss instance */
|
|
@@ -41,6 +42,7 @@ export interface ScanossOptions {
|
|
|
41
42
|
interface PendingRequest {
|
|
42
43
|
resolve: (value: Response) => void;
|
|
43
44
|
reject: (reason: Error) => void;
|
|
45
|
+
onProgress?: ProgressCallback;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
/**
|
|
@@ -133,10 +135,21 @@ export class Scanoss {
|
|
|
133
135
|
response.result.value.code,
|
|
134
136
|
response.result.value.message
|
|
135
137
|
));
|
|
136
|
-
|
|
138
|
+
this.pending.delete(response.id);
|
|
139
|
+
} else if (response.result.case === 'scanProgress' && pending.onProgress) {
|
|
140
|
+
// Handle progress update - don't resolve yet
|
|
141
|
+
const progress = response.result.value;
|
|
142
|
+
pending.onProgress({
|
|
143
|
+
filesScanned: progress.filesScanned,
|
|
144
|
+
totalFiles: progress.totalFiles,
|
|
145
|
+
currentFile: progress.currentFile,
|
|
146
|
+
matchesSoFar: progress.matchesSoFar,
|
|
147
|
+
});
|
|
148
|
+
} else if (response.isFinal || response.result.case !== 'scanProgress') {
|
|
149
|
+
// Final response or non-progress response
|
|
137
150
|
pending.resolve(response);
|
|
151
|
+
this.pending.delete(response.id);
|
|
138
152
|
}
|
|
139
|
-
this.pending.delete(response.id);
|
|
140
153
|
}
|
|
141
154
|
} catch (err) {
|
|
142
155
|
console.error('Failed to parse daemon response:', err);
|
|
@@ -151,14 +164,14 @@ export class Scanoss {
|
|
|
151
164
|
this.pending.clear();
|
|
152
165
|
}
|
|
153
166
|
|
|
154
|
-
private send(request: Request): Promise<Response> {
|
|
167
|
+
private send(request: Request, onProgress?: ProgressCallback): Promise<Response> {
|
|
155
168
|
return new Promise((resolve, reject) => {
|
|
156
169
|
if (!this.process || this.closed) {
|
|
157
170
|
reject(new Error('Daemon process is not running'));
|
|
158
171
|
return;
|
|
159
172
|
}
|
|
160
173
|
|
|
161
|
-
this.pending.set(request.id, { resolve, reject });
|
|
174
|
+
this.pending.set(request.id, { resolve, reject, onProgress });
|
|
162
175
|
|
|
163
176
|
// Serialize to binary
|
|
164
177
|
const data = toBinary(RequestSchema, request);
|
|
@@ -174,6 +187,19 @@ export class Scanoss {
|
|
|
174
187
|
|
|
175
188
|
/**
|
|
176
189
|
* Scan files for open source matches.
|
|
190
|
+
*
|
|
191
|
+
* @param params - Scan parameters including path, filters, and optional progress callback
|
|
192
|
+
* @example
|
|
193
|
+
* ```typescript
|
|
194
|
+
* // Scan with progress reporting
|
|
195
|
+
* const result = await scanoss.scan({
|
|
196
|
+
* path: './src',
|
|
197
|
+
* batchSize: 50,
|
|
198
|
+
* onProgress: (progress) => {
|
|
199
|
+
* console.log(`Scanned ${progress.filesScanned}/${progress.totalFiles} files`);
|
|
200
|
+
* }
|
|
201
|
+
* });
|
|
202
|
+
* ```
|
|
177
203
|
*/
|
|
178
204
|
async scan(params: ScanParams): Promise<ScanResult> {
|
|
179
205
|
const id = ++this.requestId;
|
|
@@ -186,6 +212,7 @@ export class Scanoss {
|
|
|
186
212
|
exclude: params.exclude ?? [],
|
|
187
213
|
apiUrl: params.apiUrl,
|
|
188
214
|
apiKey: params.apiKey,
|
|
215
|
+
batchSize: params.batchSize ?? 0,
|
|
189
216
|
});
|
|
190
217
|
|
|
191
218
|
const request = create(RequestSchema, {
|
|
@@ -193,7 +220,7 @@ export class Scanoss {
|
|
|
193
220
|
command: { case: 'scan', value: scanCmd },
|
|
194
221
|
});
|
|
195
222
|
|
|
196
|
-
const response = await this.send(request);
|
|
223
|
+
const response = await this.send(request, params.onProgress);
|
|
197
224
|
if (response.result.case !== 'scan') {
|
|
198
225
|
throw new Error('Unexpected response type');
|
|
199
226
|
}
|
|
@@ -14,7 +14,7 @@ import type { Message } from "@bufbuild/protobuf";
|
|
|
14
14
|
* Describes the file scanoss/v1/commands.proto.
|
|
15
15
|
*/
|
|
16
16
|
export const file_scanoss_v1_commands: GenFile = /*@__PURE__*/
|
|
17
|
-
fileDesc("
|
|
17
|
+
fileDesc("ChlzY2Fub3NzL3YxL2NvbW1hbmRzLnByb3RvEgpzY2Fub3NzLnYxIqECCgdSZXF1ZXN0EgoKAmlkGAEgASgFEicKBHNjYW4YAiABKAsyFy5zY2Fub3NzLnYxLlNjYW5Db21tYW5kSAASNgoMZmlsdGVyX2ZpbGVzGAMgASgLMh4uc2Nhbm9zcy52MS5GaWx0ZXJGaWxlc0NvbW1hbmRIABI1CgtmaW5nZXJwcmludBgEIAEoCzIeLnNjYW5vc3MudjEuRmluZ2VycHJpbnRDb21tYW5kSAASOAoNZ2VuZXJhdGVfc2JvbRgFIAEoCzIfLnNjYW5vc3MudjEuR2VuZXJhdGVTYm9tQ29tbWFuZEgAEi0KB3ZlcnNpb24YBiABKAsyGi5zY2Fub3NzLnYxLlZlcnNpb25Db21tYW5kSABCCQoHY29tbWFuZCKFAwoIUmVzcG9uc2USCgoCaWQYASABKAUSEAoIaXNfZmluYWwYByABKAgSJgoEc2NhbhgCI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lblABWjhnaXRodWIuY29tL3NjYW5vc3Mvc2Nhbm9zcy9jb3JlL2dlbi9zY2Fub3NzL3YxO3NjYW5vc3N2MWIGcHJvdG8z", [file_scanoss_v1_types, file_scanoss_v1_enums]);
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Request envelope - wraps all commands
|
|
@@ -81,6 +81,13 @@ export type Response = Message<"scanoss.v1.Response"> & {
|
|
|
81
81
|
*/
|
|
82
82
|
id: number;
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* True for final response (default behavior)
|
|
86
|
+
*
|
|
87
|
+
* @generated from field: bool is_final = 7;
|
|
88
|
+
*/
|
|
89
|
+
isFinal: boolean;
|
|
90
|
+
|
|
84
91
|
/**
|
|
85
92
|
* @generated from oneof scanoss.v1.Response.result
|
|
86
93
|
*/
|
|
@@ -114,6 +121,14 @@ export type Response = Message<"scanoss.v1.Response"> & {
|
|
|
114
121
|
*/
|
|
115
122
|
value: VersionResult;
|
|
116
123
|
case: "version";
|
|
124
|
+
} | {
|
|
125
|
+
/**
|
|
126
|
+
* Progress update during scan
|
|
127
|
+
*
|
|
128
|
+
* @generated from field: scanoss.v1.ScanProgress scan_progress = 8;
|
|
129
|
+
*/
|
|
130
|
+
value: ScanProgress;
|
|
131
|
+
case: "scanProgress";
|
|
117
132
|
} | {
|
|
118
133
|
/**
|
|
119
134
|
* @generated from field: scanoss.v1.Error error = 100;
|
|
@@ -198,6 +213,13 @@ export type ScanCommand = Message<"scanoss.v1.ScanCommand"> & {
|
|
|
198
213
|
* @generated from field: bool skip_hidden = 9;
|
|
199
214
|
*/
|
|
200
215
|
skipHidden: boolean;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Files per batch for progress (0 = no progress)
|
|
219
|
+
*
|
|
220
|
+
* @generated from field: int32 batch_size = 10;
|
|
221
|
+
*/
|
|
222
|
+
batchSize: number;
|
|
201
223
|
};
|
|
202
224
|
|
|
203
225
|
/**
|
|
@@ -207,6 +229,48 @@ export type ScanCommand = Message<"scanoss.v1.ScanCommand"> & {
|
|
|
207
229
|
export const ScanCommandSchema: GenMessage<ScanCommand> = /*@__PURE__*/
|
|
208
230
|
messageDesc(file_scanoss_v1_commands, 2);
|
|
209
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Progress update during scan
|
|
234
|
+
*
|
|
235
|
+
* @generated from message scanoss.v1.ScanProgress
|
|
236
|
+
*/
|
|
237
|
+
export type ScanProgress = Message<"scanoss.v1.ScanProgress"> & {
|
|
238
|
+
/**
|
|
239
|
+
* Number of files scanned so far
|
|
240
|
+
*
|
|
241
|
+
* @generated from field: int32 files_scanned = 1;
|
|
242
|
+
*/
|
|
243
|
+
filesScanned: number;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Total number of files to scan
|
|
247
|
+
*
|
|
248
|
+
* @generated from field: int32 total_files = 2;
|
|
249
|
+
*/
|
|
250
|
+
totalFiles: number;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Current file being processed
|
|
254
|
+
*
|
|
255
|
+
* @generated from field: string current_file = 3;
|
|
256
|
+
*/
|
|
257
|
+
currentFile: string;
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Matches found so far
|
|
261
|
+
*
|
|
262
|
+
* @generated from field: int32 matches_so_far = 4;
|
|
263
|
+
*/
|
|
264
|
+
matchesSoFar: number;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Describes the message scanoss.v1.ScanProgress.
|
|
269
|
+
* Use `create(ScanProgressSchema)` to create a new message.
|
|
270
|
+
*/
|
|
271
|
+
export const ScanProgressSchema: GenMessage<ScanProgress> = /*@__PURE__*/
|
|
272
|
+
messageDesc(file_scanoss_v1_commands, 3);
|
|
273
|
+
|
|
210
274
|
/**
|
|
211
275
|
* Scan result
|
|
212
276
|
*
|
|
@@ -232,6 +296,13 @@ export type ScanResult = Message<"scanoss.v1.ScanResult"> & {
|
|
|
232
296
|
* @generated from field: int32 total_matches = 4;
|
|
233
297
|
*/
|
|
234
298
|
totalMatches: number;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Raw JSON response from SCANOSS API
|
|
302
|
+
*
|
|
303
|
+
* @generated from field: string raw_json = 5;
|
|
304
|
+
*/
|
|
305
|
+
rawJson: string;
|
|
235
306
|
};
|
|
236
307
|
|
|
237
308
|
/**
|
|
@@ -239,7 +310,7 @@ export type ScanResult = Message<"scanoss.v1.ScanResult"> & {
|
|
|
239
310
|
* Use `create(ScanResultSchema)` to create a new message.
|
|
240
311
|
*/
|
|
241
312
|
export const ScanResultSchema: GenMessage<ScanResult> = /*@__PURE__*/
|
|
242
|
-
messageDesc(file_scanoss_v1_commands,
|
|
313
|
+
messageDesc(file_scanoss_v1_commands, 4);
|
|
243
314
|
|
|
244
315
|
/**
|
|
245
316
|
* List files that would be scanned (dry run)
|
|
@@ -288,7 +359,7 @@ export type FilterFilesCommand = Message<"scanoss.v1.FilterFilesCommand"> & {
|
|
|
288
359
|
* Use `create(FilterFilesCommandSchema)` to create a new message.
|
|
289
360
|
*/
|
|
290
361
|
export const FilterFilesCommandSchema: GenMessage<FilterFilesCommand> = /*@__PURE__*/
|
|
291
|
-
messageDesc(file_scanoss_v1_commands,
|
|
362
|
+
messageDesc(file_scanoss_v1_commands, 5);
|
|
292
363
|
|
|
293
364
|
/**
|
|
294
365
|
* Filter files result
|
|
@@ -317,7 +388,7 @@ export type FilterFilesResult = Message<"scanoss.v1.FilterFilesResult"> & {
|
|
|
317
388
|
* Use `create(FilterFilesResultSchema)` to create a new message.
|
|
318
389
|
*/
|
|
319
390
|
export const FilterFilesResultSchema: GenMessage<FilterFilesResult> = /*@__PURE__*/
|
|
320
|
-
messageDesc(file_scanoss_v1_commands,
|
|
391
|
+
messageDesc(file_scanoss_v1_commands, 6);
|
|
321
392
|
|
|
322
393
|
/**
|
|
323
394
|
* Generate WFP fingerprints without scanning
|
|
@@ -359,7 +430,7 @@ export type FingerprintCommand = Message<"scanoss.v1.FingerprintCommand"> & {
|
|
|
359
430
|
* Use `create(FingerprintCommandSchema)` to create a new message.
|
|
360
431
|
*/
|
|
361
432
|
export const FingerprintCommandSchema: GenMessage<FingerprintCommand> = /*@__PURE__*/
|
|
362
|
-
messageDesc(file_scanoss_v1_commands,
|
|
433
|
+
messageDesc(file_scanoss_v1_commands, 7);
|
|
363
434
|
|
|
364
435
|
/**
|
|
365
436
|
* Fingerprint result
|
|
@@ -397,7 +468,7 @@ export type FingerprintResult = Message<"scanoss.v1.FingerprintResult"> & {
|
|
|
397
468
|
* Use `create(FingerprintResultSchema)` to create a new message.
|
|
398
469
|
*/
|
|
399
470
|
export const FingerprintResultSchema: GenMessage<FingerprintResult> = /*@__PURE__*/
|
|
400
|
-
messageDesc(file_scanoss_v1_commands,
|
|
471
|
+
messageDesc(file_scanoss_v1_commands, 8);
|
|
401
472
|
|
|
402
473
|
/**
|
|
403
474
|
* Generate SBOM from scan results
|
|
@@ -446,7 +517,7 @@ export type GenerateSbomCommand = Message<"scanoss.v1.GenerateSbomCommand"> & {
|
|
|
446
517
|
* Use `create(GenerateSbomCommandSchema)` to create a new message.
|
|
447
518
|
*/
|
|
448
519
|
export const GenerateSbomCommandSchema: GenMessage<GenerateSbomCommand> = /*@__PURE__*/
|
|
449
|
-
messageDesc(file_scanoss_v1_commands,
|
|
520
|
+
messageDesc(file_scanoss_v1_commands, 9);
|
|
450
521
|
|
|
451
522
|
/**
|
|
452
523
|
* Generate SBOM result
|
|
@@ -484,7 +555,7 @@ export type GenerateSbomResult = Message<"scanoss.v1.GenerateSbomResult"> & {
|
|
|
484
555
|
* Use `create(GenerateSbomResultSchema)` to create a new message.
|
|
485
556
|
*/
|
|
486
557
|
export const GenerateSbomResultSchema: GenMessage<GenerateSbomResult> = /*@__PURE__*/
|
|
487
|
-
messageDesc(file_scanoss_v1_commands,
|
|
558
|
+
messageDesc(file_scanoss_v1_commands, 10);
|
|
488
559
|
|
|
489
560
|
/**
|
|
490
561
|
* Get version information
|
|
@@ -499,7 +570,7 @@ export type VersionCommand = Message<"scanoss.v1.VersionCommand"> & {
|
|
|
499
570
|
* Use `create(VersionCommandSchema)` to create a new message.
|
|
500
571
|
*/
|
|
501
572
|
export const VersionCommandSchema: GenMessage<VersionCommand> = /*@__PURE__*/
|
|
502
|
-
messageDesc(file_scanoss_v1_commands,
|
|
573
|
+
messageDesc(file_scanoss_v1_commands, 11);
|
|
503
574
|
|
|
504
575
|
/**
|
|
505
576
|
* Version result
|
|
@@ -533,5 +604,5 @@ export type VersionResult = Message<"scanoss.v1.VersionResult"> & {
|
|
|
533
604
|
* Use `create(VersionResultSchema)` to create a new message.
|
|
534
605
|
*/
|
|
535
606
|
export const VersionResultSchema: GenMessage<VersionResult> = /*@__PURE__*/
|
|
536
|
-
messageDesc(file_scanoss_v1_commands,
|
|
607
|
+
messageDesc(file_scanoss_v1_commands, 12);
|
|
537
608
|
|
package/src/types.ts
CHANGED
|
@@ -30,6 +30,17 @@ export interface FileResult {
|
|
|
30
30
|
matches: Match[];
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/** Progress information during scan */
|
|
34
|
+
export interface ScanProgress {
|
|
35
|
+
filesScanned: number;
|
|
36
|
+
totalFiles: number;
|
|
37
|
+
currentFile: string;
|
|
38
|
+
matchesSoFar: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Progress callback function */
|
|
42
|
+
export type ProgressCallback = (progress: ScanProgress) => void;
|
|
43
|
+
|
|
33
44
|
/** Scan command parameters */
|
|
34
45
|
export interface ScanParams {
|
|
35
46
|
path: string;
|
|
@@ -39,6 +50,10 @@ export interface ScanParams {
|
|
|
39
50
|
exclude?: string[];
|
|
40
51
|
apiUrl?: string;
|
|
41
52
|
apiKey?: string;
|
|
53
|
+
/** Number of files per batch for progress reporting (0 = no progress) */
|
|
54
|
+
batchSize?: number;
|
|
55
|
+
/** Callback function for progress updates */
|
|
56
|
+
onProgress?: ProgressCallback;
|
|
42
57
|
}
|
|
43
58
|
|
|
44
59
|
/** Scan result */
|