massbank 0.2.0 → 0.2.1
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/lib/validator/validator.d.ts +4 -3
- package/lib/validator/validator.d.ts.map +1 -1
- package/lib/validator/validator.js +6 -5
- package/lib/validator/validator.js.map +1 -1
- package/package.json +1 -1
- package/src/validator/validator.ts +6 -5
- package/lib/validator/file-utils.d.ts +0 -13
- package/lib/validator/file-utils.d.ts.map +0 -1
- package/lib/validator/file-utils.js +0 -24
- package/lib/validator/file-utils.js.map +0 -1
- package/src/validator/file-utils.ts +0 -25
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type { ValidationOptions, ValidationResult } from '../types.js';
|
|
2
2
|
/**
|
|
3
|
-
* Validate a single MassBank record file
|
|
3
|
+
* Validate a single MassBank record file (Node.js only)
|
|
4
|
+
* For browser usage, use validateContent() instead.
|
|
4
5
|
* @param filePath - Path to the .txt file
|
|
5
6
|
* @param options - Validation options (legacy mode, logger)
|
|
6
7
|
* @returns ValidationResult with errors, warnings, and accession
|
|
7
8
|
*/
|
|
8
9
|
export declare function validate(filePath: string, options?: ValidationOptions): Promise<ValidationResult>;
|
|
9
10
|
/**
|
|
10
|
-
* Validate in-memory MassBank record content
|
|
11
|
+
* Validate in-memory MassBank record content (browser-compatible)
|
|
11
12
|
* Useful for browser or API use-cases where the record content is not
|
|
12
|
-
* coming from the filesystem.
|
|
13
|
+
* coming from the filesystem. This function has no Node.js dependencies.
|
|
13
14
|
* @param content - Full record text to validate
|
|
14
15
|
* @param filename - Logical filename for error reporting (e.g. 'user-upload.txt')
|
|
15
16
|
* @param options - Validation options (legacy mode, logger)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/validator/validator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,iBAAiB,EACjB,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AAGrB
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/validator/validator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,iBAAiB,EACjB,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AAGrB;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,gBAAgB,CAAC,CAiG3B;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,gBAAgB,CAAC,CA0D3B"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ParseException, parseRecord } from '../parser/index.js';
|
|
2
2
|
import { RecordValidator } from '../validation/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Validate a single MassBank record file
|
|
4
|
+
* Validate a single MassBank record file (Node.js only)
|
|
5
|
+
* For browser usage, use validateContent() instead.
|
|
5
6
|
* @param filePath - Path to the .txt file
|
|
6
7
|
* @param options - Validation options (legacy mode, logger)
|
|
7
8
|
* @returns ValidationResult with errors, warnings, and accession
|
|
@@ -15,11 +16,11 @@ export async function validate(filePath, options = {}) {
|
|
|
15
16
|
options.logger.info(`Validating file: ${filePath}`);
|
|
16
17
|
}
|
|
17
18
|
// Dynamic import to avoid pulling node:fs/promises into browser bundles
|
|
18
|
-
const {
|
|
19
|
+
const { readFile } = await import('node:fs/promises');
|
|
19
20
|
// Read file
|
|
20
21
|
let fileContent;
|
|
21
22
|
try {
|
|
22
|
-
fileContent = await
|
|
23
|
+
fileContent = await readFile(filePath, 'utf8');
|
|
23
24
|
}
|
|
24
25
|
catch (error) {
|
|
25
26
|
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
@@ -95,9 +96,9 @@ export async function validate(filePath, options = {}) {
|
|
|
95
96
|
};
|
|
96
97
|
}
|
|
97
98
|
/**
|
|
98
|
-
* Validate in-memory MassBank record content
|
|
99
|
+
* Validate in-memory MassBank record content (browser-compatible)
|
|
99
100
|
* Useful for browser or API use-cases where the record content is not
|
|
100
|
-
* coming from the filesystem.
|
|
101
|
+
* coming from the filesystem. This function has no Node.js dependencies.
|
|
101
102
|
* @param content - Full record text to validate
|
|
102
103
|
* @param filename - Logical filename for error reporting (e.g. 'user-upload.txt')
|
|
103
104
|
* @param options - Validation options (legacy mode, logger)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/validator/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOjE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/validator/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAOjE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,QAAgB,EAChB,UAA6B,EAAE;IAE/B,MAAM,MAAM,GAAsB,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAwB,EAAE,CAAC;IACzC,MAAM,UAAU,GAAa,EAAE,CAAC;IAEhC,yBAAyB;IACzB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,QAAQ,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,wEAAwE;IACxE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;IAEtD,YAAY;IACZ,IAAI,WAAmB,CAAC;IACxB,IAAI,CAAC;QACH,WAAW,GAAG,MAAM,QAAQ,CAAC,QAAQ,E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,OAAO;QACL,OAAO;QACP,MAAM;QACN,QAAQ;QACR,UAAU;QACV,cAAc,EAAE,CAAC;KAClB,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -8,7 +8,8 @@ import type {
|
|
|
8
8
|
import { RecordValidator } from '../validation/index.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Validate a single MassBank record file
|
|
11
|
+
* Validate a single MassBank record file (Node.js only)
|
|
12
|
+
* For browser usage, use validateContent() instead.
|
|
12
13
|
* @param filePath - Path to the .txt file
|
|
13
14
|
* @param options - Validation options (legacy mode, logger)
|
|
14
15
|
* @returns ValidationResult with errors, warnings, and accession
|
|
@@ -27,12 +28,12 @@ export async function validate(
|
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
// Dynamic import to avoid pulling node:fs/promises into browser bundles
|
|
30
|
-
const {
|
|
31
|
+
const { readFile } = await import('node:fs/promises');
|
|
31
32
|
|
|
32
33
|
// Read file
|
|
33
34
|
let fileContent: string;
|
|
34
35
|
try {
|
|
35
|
-
fileContent = await
|
|
36
|
+
fileContent = await readFile(filePath, 'utf8');
|
|
36
37
|
} catch (error) {
|
|
37
38
|
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
38
39
|
return {
|
|
@@ -116,9 +117,9 @@ export async function validate(
|
|
|
116
117
|
}
|
|
117
118
|
|
|
118
119
|
/**
|
|
119
|
-
* Validate in-memory MassBank record content
|
|
120
|
+
* Validate in-memory MassBank record content (browser-compatible)
|
|
120
121
|
* Useful for browser or API use-cases where the record content is not
|
|
121
|
-
* coming from the filesystem.
|
|
122
|
+
* coming from the filesystem. This function has no Node.js dependencies.
|
|
122
123
|
* @param content - Full record text to validate
|
|
123
124
|
* @param filename - Logical filename for error reporting (e.g. 'user-upload.txt')
|
|
124
125
|
* @param options - Validation options (legacy mode, logger)
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions for file operations
|
|
3
|
-
* Simplified for single-file validation
|
|
4
|
-
*/
|
|
5
|
-
export declare const FileUtils: {
|
|
6
|
-
/**
|
|
7
|
-
* Read a file as UTF-8 text
|
|
8
|
-
* @param filePath - Absolute path to the file
|
|
9
|
-
* @returns File content as string
|
|
10
|
-
*/
|
|
11
|
-
readFile(filePath: string): Promise<string>;
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=file-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["../../src/validator/file-utils.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,SAAS;IACpB;;;;OAIG;uBACsB,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAYlD,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
/**
|
|
3
|
-
* Utility functions for file operations
|
|
4
|
-
* Simplified for single-file validation
|
|
5
|
-
*/
|
|
6
|
-
export const FileUtils = {
|
|
7
|
-
/**
|
|
8
|
-
* Read a file as UTF-8 text
|
|
9
|
-
* @param filePath - Absolute path to the file
|
|
10
|
-
* @returns File content as string
|
|
11
|
-
*/
|
|
12
|
-
async readFile(filePath) {
|
|
13
|
-
try {
|
|
14
|
-
return await readFile(filePath, 'utf8');
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
18
|
-
const wrappedError = new Error(`Error reading file ${filePath}: ${message}`);
|
|
19
|
-
wrappedError.cause = error;
|
|
20
|
-
throw wrappedError;
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=file-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-utils.js","sourceRoot":"","sources":["../../src/validator/file-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,QAAgB;QAC7B,IAAI,CAAC;YACH,OAAO,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YACzE,MAAM,YAAY,GAAG,IAAI,KAAK,CAC5B,sBAAsB,QAAQ,KAAK,OAAO,EAAE,CAC7C,CAAC;YACD,YAAoC,CAAC,KAAK,GAAG,KAAK,CAAC;YACpD,MAAM,YAAY,CAAC;QACrB,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Utility functions for file operations
|
|
5
|
-
* Simplified for single-file validation
|
|
6
|
-
*/
|
|
7
|
-
export const FileUtils = {
|
|
8
|
-
/**
|
|
9
|
-
* Read a file as UTF-8 text
|
|
10
|
-
* @param filePath - Absolute path to the file
|
|
11
|
-
* @returns File content as string
|
|
12
|
-
*/
|
|
13
|
-
async readFile(filePath: string): Promise<string> {
|
|
14
|
-
try {
|
|
15
|
-
return await readFile(filePath, 'utf8');
|
|
16
|
-
} catch (error) {
|
|
17
|
-
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
18
|
-
const wrappedError = new Error(
|
|
19
|
-
`Error reading file ${filePath}: ${message}`,
|
|
20
|
-
);
|
|
21
|
-
(wrappedError as { cause?: unknown }).cause = error;
|
|
22
|
-
throw wrappedError;
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
};
|