@wemush/wols 0.1.0
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/LICENSE +201 -0
- package/README.md +294 -0
- package/dist/cjs/compact-url.js +272 -0
- package/dist/cjs/compact-url.js.map +1 -0
- package/dist/cjs/crypto/decrypt.js +125 -0
- package/dist/cjs/crypto/decrypt.js.map +1 -0
- package/dist/cjs/crypto/encrypt.js +151 -0
- package/dist/cjs/crypto/encrypt.js.map +1 -0
- package/dist/cjs/crypto/index.js +16 -0
- package/dist/cjs/crypto/index.js.map +1 -0
- package/dist/cjs/errors.js +188 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/index.js +81 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/parser.js +148 -0
- package/dist/cjs/parser.js.map +1 -0
- package/dist/cjs/qr/generate.js +275 -0
- package/dist/cjs/qr/generate.js.map +1 -0
- package/dist/cjs/qr/index.js +18 -0
- package/dist/cjs/qr/index.js.map +1 -0
- package/dist/cjs/specimen.js +163 -0
- package/dist/cjs/specimen.js.map +1 -0
- package/dist/cjs/types.js +78 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils/cuid.js +150 -0
- package/dist/cjs/utils/cuid.js.map +1 -0
- package/dist/cjs/utils/iso8601.js +131 -0
- package/dist/cjs/utils/iso8601.js.map +1 -0
- package/dist/cjs/validator.js +307 -0
- package/dist/cjs/validator.js.map +1 -0
- package/dist/esm/compact-url.js +264 -0
- package/dist/esm/compact-url.js.map +1 -0
- package/dist/esm/crypto/decrypt.js +122 -0
- package/dist/esm/crypto/decrypt.js.map +1 -0
- package/dist/esm/crypto/encrypt.js +147 -0
- package/dist/esm/crypto/encrypt.js.map +1 -0
- package/dist/esm/crypto/index.js +10 -0
- package/dist/esm/crypto/index.js.map +1 -0
- package/dist/esm/errors.js +178 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/index.js +47 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/parser.js +145 -0
- package/dist/esm/parser.js.map +1 -0
- package/dist/esm/qr/generate.js +235 -0
- package/dist/esm/qr/generate.js.map +1 -0
- package/dist/esm/qr/index.js +10 -0
- package/dist/esm/qr/index.js.map +1 -0
- package/dist/esm/specimen.js +159 -0
- package/dist/esm/specimen.js.map +1 -0
- package/dist/esm/types.js +71 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/cuid.js +145 -0
- package/dist/esm/utils/cuid.js.map +1 -0
- package/dist/esm/utils/iso8601.js +122 -0
- package/dist/esm/utils/iso8601.js.map +1 -0
- package/dist/esm/validator.js +304 -0
- package/dist/esm/validator.js.map +1 -0
- package/dist/types/compact-url.d.ts +104 -0
- package/dist/types/compact-url.d.ts.map +1 -0
- package/dist/types/crypto/decrypt.d.ts +33 -0
- package/dist/types/crypto/decrypt.d.ts.map +1 -0
- package/dist/types/crypto/encrypt.d.ts +32 -0
- package/dist/types/crypto/encrypt.d.ts.map +1 -0
- package/dist/types/crypto/index.d.ts +10 -0
- package/dist/types/crypto/index.d.ts.map +1 -0
- package/dist/types/errors.d.ts +103 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/parser.d.ts +30 -0
- package/dist/types/parser.d.ts.map +1 -0
- package/dist/types/qr/generate.d.ts +62 -0
- package/dist/types/qr/generate.d.ts.map +1 -0
- package/dist/types/qr/index.d.ts +10 -0
- package/dist/types/qr/index.d.ts.map +1 -0
- package/dist/types/specimen.d.ts +71 -0
- package/dist/types/specimen.d.ts.map +1 -0
- package/dist/types/types.d.ts +269 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils/cuid.d.ts +44 -0
- package/dist/types/utils/cuid.d.ts.map +1 -0
- package/dist/types/utils/iso8601.d.ts +79 -0
- package/dist/types/utils/iso8601.d.ts.map +1 -0
- package/dist/types/validator.d.ts +25 -0
- package/dist/types/validator.d.ts.map +1 -0
- package/package.json +95 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WOLS Specimen Parser
|
|
3
|
+
*
|
|
4
|
+
* This module provides parsing functionality for WOLS specimen JSON.
|
|
5
|
+
*
|
|
6
|
+
* @module parser
|
|
7
|
+
*/
|
|
8
|
+
import { type ParseResult, type Specimen } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Parse a JSON string into a validated Specimen object.
|
|
11
|
+
*
|
|
12
|
+
* This function performs both JSON parsing and WOLS validation.
|
|
13
|
+
* If the JSON is invalid or the parsed object doesn't conform to WOLS,
|
|
14
|
+
* it returns a failure result with a detailed error.
|
|
15
|
+
*
|
|
16
|
+
* @param json - The JSON string to parse
|
|
17
|
+
* @returns ParseResult with either the parsed Specimen or an error
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const result = parseSpecimen('{"@context": "https://wemush.com/wols/v1", ...}');
|
|
22
|
+
* if (result.success) {
|
|
23
|
+
* console.log('Specimen ID:', result.data.id);
|
|
24
|
+
* } else {
|
|
25
|
+
* console.error('Parse error:', result.error.message);
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseSpecimen(json: string): ParseResult<Specimen>;
|
|
30
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,QAAQ,EAId,MAAM,YAAY,CAAC;AAyCpB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,QAAQ,CAAC,CAoGjE"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR Code Generation Module
|
|
3
|
+
*
|
|
4
|
+
* This module provides QR code generation functionality for WOLS specimens.
|
|
5
|
+
* Requires the 'qrcode' package as an optional peer dependency.
|
|
6
|
+
*
|
|
7
|
+
* @module qr/generate
|
|
8
|
+
*/
|
|
9
|
+
import type { Specimen, QRCodeOptions } from '../types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Check if QR code generation is available.
|
|
12
|
+
* Returns true if the qrcode library is installed.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isQRAvailable(): Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Synchronous check if QR code generation is available.
|
|
17
|
+
* Note: Only accurate after first async call to any QR function.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isQRAvailableSync(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Generate QR code as PNG buffer.
|
|
22
|
+
*
|
|
23
|
+
* @param specimen - The specimen to encode
|
|
24
|
+
* @param options - QR code generation options
|
|
25
|
+
* @returns PNG buffer containing the QR code
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const buffer = await toQRCode(specimen, { size: 400 });
|
|
30
|
+
* fs.writeFileSync('specimen-qr.png', buffer);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function toQRCode(specimen: Specimen, options?: QRCodeOptions): Promise<Buffer>;
|
|
34
|
+
/**
|
|
35
|
+
* Generate QR code as data URL (base64 encoded PNG).
|
|
36
|
+
*
|
|
37
|
+
* @param specimen - The specimen to encode
|
|
38
|
+
* @param options - QR code generation options
|
|
39
|
+
* @returns Data URL string (data:image/png;base64,...)
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const dataUrl = await toQRCodeDataURL(specimen);
|
|
44
|
+
* // Use in HTML: <img src={dataUrl} />
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare function toQRCodeDataURL(specimen: Specimen, options?: QRCodeOptions): Promise<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Generate QR code as SVG string.
|
|
50
|
+
*
|
|
51
|
+
* @param specimen - The specimen to encode
|
|
52
|
+
* @param options - QR code generation options
|
|
53
|
+
* @returns SVG string
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const svg = await toQRCodeSVG(specimen, { color: { dark: '#000', light: '#fff' } });
|
|
58
|
+
* fs.writeFileSync('specimen-qr.svg', svg);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function toQRCodeSVG(specimen: Specimen, options?: QRCodeOptions): Promise<string>;
|
|
62
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/qr/generate.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAwK3D;;;GAGG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAGtD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAa/F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,QAAQ,EAClB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAajB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,QAAQ,EAClB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAmBjB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QR Code Submodule
|
|
3
|
+
*
|
|
4
|
+
* This module provides QR code generation functionality for WOLS specimens.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
* @module @wemush/wols/qr
|
|
8
|
+
*/
|
|
9
|
+
export { toQRCode, toQRCodeDataURL, toQRCodeSVG, isQRAvailable, isQRAvailableSync, } from './generate.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/qr/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,QAAQ,EACR,eAAe,EACf,WAAW,EACX,aAAa,EACb,iBAAiB,GAClB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Specimen Creation and Serialization
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions to create and serialize
|
|
5
|
+
* WOLS v1.1.0 compliant specimen objects.
|
|
6
|
+
*
|
|
7
|
+
* @module specimen
|
|
8
|
+
*/
|
|
9
|
+
import type { Specimen, SpecimenInput } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Create a new specimen with auto-generated ID and JSON-LD fields.
|
|
12
|
+
*
|
|
13
|
+
* This function creates a fully-formed WOLS v1.1.0 compliant Specimen
|
|
14
|
+
* with automatic ID generation, version assignment, and JSON-LD context.
|
|
15
|
+
*
|
|
16
|
+
* @param input - Specimen creation parameters
|
|
17
|
+
* @returns Fully-formed Specimen with JSON-LD fields
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Minimal specimen
|
|
22
|
+
* const culture = createSpecimen({
|
|
23
|
+
* type: 'CULTURE',
|
|
24
|
+
* species: 'Pleurotus ostreatus',
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Full specimen with strain info
|
|
28
|
+
* const substrate = createSpecimen({
|
|
29
|
+
* type: 'SUBSTRATE',
|
|
30
|
+
* species: 'Hericium erinaceus',
|
|
31
|
+
* strain: {
|
|
32
|
+
* name: "Lion's Mane Premium",
|
|
33
|
+
* generation: 'F2',
|
|
34
|
+
* clonalGeneration: 3,
|
|
35
|
+
* },
|
|
36
|
+
* stage: 'COLONIZATION',
|
|
37
|
+
* batch: 'batch_2025_12_001',
|
|
38
|
+
* organization: 'org_mushoh',
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* // String strain shorthand
|
|
42
|
+
* const spawn = createSpecimen({
|
|
43
|
+
* type: 'SPAWN',
|
|
44
|
+
* species: 'Ganoderma lucidum',
|
|
45
|
+
* strain: 'Reishi Red', // Auto-expands to { name: 'Reishi Red' }
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare function createSpecimen(input: SpecimenInput): Specimen;
|
|
50
|
+
/**
|
|
51
|
+
* Serialize a specimen to JSON-LD string.
|
|
52
|
+
*
|
|
53
|
+
* The output is formatted with JSON-LD fields (@context, @type) first,
|
|
54
|
+
* followed by id, version, and remaining fields. Undefined fields are omitted.
|
|
55
|
+
*
|
|
56
|
+
* @param specimen - Specimen to serialize
|
|
57
|
+
* @returns JSON string suitable for QR encoding
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const specimen = createSpecimen({
|
|
62
|
+
* type: 'CULTURE',
|
|
63
|
+
* species: 'Pleurotus ostreatus',
|
|
64
|
+
* });
|
|
65
|
+
*
|
|
66
|
+
* const json = serializeSpecimen(specimen);
|
|
67
|
+
* // Returns: '{"@context":"https://wemush.com/wols/v1","@type":"Specimen",...}'
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function serializeSpecimen(specimen: Specimen): string;
|
|
71
|
+
//# sourceMappingURL=specimen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specimen.d.ts","sourceRoot":"","sources":["../../src/specimen.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAU,MAAM,YAAY,CAAC;AA2BlE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,aAAa,GAAG,QAAQ,CAwC7D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CA6C5D"}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WOLS TypeScript Library - Core Types
|
|
3
|
+
*
|
|
4
|
+
* This module defines all the core types, interfaces, and enums
|
|
5
|
+
* for the WeMush Open Labeling Standard (WOLS) v1.1.0.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
* @module @wemush/wols
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* WOLS specification version implemented by this library.
|
|
12
|
+
*/
|
|
13
|
+
export declare const WOLS_VERSION = "1.1.0";
|
|
14
|
+
/**
|
|
15
|
+
* JSON-LD context URL for WOLS specimens.
|
|
16
|
+
*/
|
|
17
|
+
export declare const WOLS_CONTEXT = "https://wemush.com/wols/v1";
|
|
18
|
+
/**
|
|
19
|
+
* Branded type pattern for nominal typing.
|
|
20
|
+
* Creates a compile-time unique type that is runtime-compatible with the base type.
|
|
21
|
+
*/
|
|
22
|
+
export type Brand<K, T> = K & {
|
|
23
|
+
readonly __brand: T;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Specimen ID type (format: "wemush:{cuid}").
|
|
27
|
+
* This is a branded string type for type safety.
|
|
28
|
+
*/
|
|
29
|
+
export type SpecimenId = Brand<string, 'SpecimenId'>;
|
|
30
|
+
/**
|
|
31
|
+
* Create a SpecimenId from a string.
|
|
32
|
+
* Does not validate the format - use isValidSpecimenId for validation.
|
|
33
|
+
*/
|
|
34
|
+
export declare function asSpecimenId(id: string): SpecimenId;
|
|
35
|
+
/**
|
|
36
|
+
* Specimen type enum representing cultivation stages.
|
|
37
|
+
*/
|
|
38
|
+
export type SpecimenType = 'CULTURE' | 'SPAWN' | 'SUBSTRATE' | 'FRUITING' | 'HARVEST';
|
|
39
|
+
/**
|
|
40
|
+
* Array of valid specimen types for validation.
|
|
41
|
+
*/
|
|
42
|
+
export declare const SPECIMEN_TYPES: readonly SpecimenType[];
|
|
43
|
+
/**
|
|
44
|
+
* Growth stage enum representing specimen lifecycle.
|
|
45
|
+
*/
|
|
46
|
+
export type GrowthStage = 'INOCULATION' | 'COLONIZATION' | 'FRUITING' | 'HARVEST';
|
|
47
|
+
/**
|
|
48
|
+
* Array of valid growth stages for validation.
|
|
49
|
+
*/
|
|
50
|
+
export declare const GROWTH_STAGES: readonly GrowthStage[];
|
|
51
|
+
/**
|
|
52
|
+
* Strain information for a specimen.
|
|
53
|
+
*/
|
|
54
|
+
export interface Strain {
|
|
55
|
+
/** Strain name or identifier */
|
|
56
|
+
name: string;
|
|
57
|
+
/** Filial generation (e.g., "F1", "F2", "P") */
|
|
58
|
+
generation?: string;
|
|
59
|
+
/** Subculture/clone count (1, 2, 3...) */
|
|
60
|
+
clonalGeneration?: number;
|
|
61
|
+
/** Parent specimen ID reference */
|
|
62
|
+
lineage?: string;
|
|
63
|
+
/** Origin: "spore", "tissue", "agar", "liquid" */
|
|
64
|
+
source?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Primary specimen entity following WOLS v1.1.0 JSON-LD schema.
|
|
68
|
+
*/
|
|
69
|
+
export interface Specimen {
|
|
70
|
+
/** JSON-LD context URL */
|
|
71
|
+
'@context': typeof WOLS_CONTEXT;
|
|
72
|
+
/** JSON-LD entity type */
|
|
73
|
+
'@type': 'Specimen';
|
|
74
|
+
/** Unique specimen ID (format: wemush:{cuid}) */
|
|
75
|
+
id: SpecimenId;
|
|
76
|
+
/** WOLS specification version */
|
|
77
|
+
version: string;
|
|
78
|
+
/** Cultivation stage type */
|
|
79
|
+
type: SpecimenType;
|
|
80
|
+
/** Scientific species name */
|
|
81
|
+
species: string;
|
|
82
|
+
/** Strain/genetic information */
|
|
83
|
+
strain?: Strain;
|
|
84
|
+
/** Current growth stage */
|
|
85
|
+
stage?: GrowthStage;
|
|
86
|
+
/** Creation timestamp (ISO 8601) */
|
|
87
|
+
created?: string;
|
|
88
|
+
/** Batch identifier */
|
|
89
|
+
batch?: string;
|
|
90
|
+
/** Organization ID */
|
|
91
|
+
organization?: string;
|
|
92
|
+
/** Creator user ID */
|
|
93
|
+
creator?: string;
|
|
94
|
+
/** Custom vendor-specific fields */
|
|
95
|
+
custom?: Record<string, unknown>;
|
|
96
|
+
/** Cryptographic signature */
|
|
97
|
+
signature?: string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Input type for createSpecimen().
|
|
101
|
+
* Strain can be a string (auto-expanded) or full Strain object.
|
|
102
|
+
*/
|
|
103
|
+
export interface SpecimenInput {
|
|
104
|
+
/** Cultivation stage type */
|
|
105
|
+
type: SpecimenType;
|
|
106
|
+
/** Scientific species name */
|
|
107
|
+
species: string;
|
|
108
|
+
/** String shorthand expands to { name: string } */
|
|
109
|
+
strain?: string | Strain;
|
|
110
|
+
/** Current growth stage */
|
|
111
|
+
stage?: GrowthStage;
|
|
112
|
+
/** Batch identifier */
|
|
113
|
+
batch?: string;
|
|
114
|
+
/** Organization ID */
|
|
115
|
+
organization?: string;
|
|
116
|
+
/** Creator user ID */
|
|
117
|
+
creator?: string;
|
|
118
|
+
/** Custom vendor-specific fields */
|
|
119
|
+
custom?: Record<string, unknown>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Import error types for use in ParseResult.
|
|
123
|
+
* Circular dependency avoided by using forward reference.
|
|
124
|
+
*/
|
|
125
|
+
import type { WolsError } from './errors.js';
|
|
126
|
+
/**
|
|
127
|
+
* Parse result discriminated union.
|
|
128
|
+
* @template T The type of data on success
|
|
129
|
+
*/
|
|
130
|
+
export type ParseResult<T> = {
|
|
131
|
+
success: true;
|
|
132
|
+
data: T;
|
|
133
|
+
} | {
|
|
134
|
+
success: false;
|
|
135
|
+
error: WolsError;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Validation error detail.
|
|
139
|
+
*/
|
|
140
|
+
export interface ValidationError {
|
|
141
|
+
/** JSON path to invalid field (e.g., "strain.name") */
|
|
142
|
+
path: string;
|
|
143
|
+
/** Stable error code */
|
|
144
|
+
code: string;
|
|
145
|
+
/** Human-readable error message */
|
|
146
|
+
message: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Validation warning detail.
|
|
150
|
+
*/
|
|
151
|
+
export interface ValidationWarning {
|
|
152
|
+
/** JSON path to field */
|
|
153
|
+
path: string;
|
|
154
|
+
/** Warning code */
|
|
155
|
+
code: string;
|
|
156
|
+
/** Human-readable warning message */
|
|
157
|
+
message: string;
|
|
158
|
+
/** Suggested fix */
|
|
159
|
+
suggestion?: string;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Validation result with errors and warnings.
|
|
163
|
+
*/
|
|
164
|
+
export interface ValidationResult {
|
|
165
|
+
/** Whether validation passed */
|
|
166
|
+
valid: boolean;
|
|
167
|
+
/** Validation errors (causes valid: false) */
|
|
168
|
+
errors: ValidationError[];
|
|
169
|
+
/** Validation warnings (informational) */
|
|
170
|
+
warnings: ValidationWarning[];
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Validation options.
|
|
174
|
+
*/
|
|
175
|
+
export interface ValidationOptions {
|
|
176
|
+
/** Allow unknown fields in custom namespace */
|
|
177
|
+
allowUnknownFields?: boolean;
|
|
178
|
+
/** Validation strictness level */
|
|
179
|
+
level?: 'strict' | 'lenient';
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Reference data extracted from a compact URL.
|
|
183
|
+
*
|
|
184
|
+
* Contains the minimal information encoded in the compact format.
|
|
185
|
+
* Full specimen data must be retrieved via API lookup using the id.
|
|
186
|
+
*/
|
|
187
|
+
export interface SpecimenRef {
|
|
188
|
+
/** Full specimen ID with wemush: prefix */
|
|
189
|
+
id: string;
|
|
190
|
+
/** Species name (resolved from code if known) */
|
|
191
|
+
species: string;
|
|
192
|
+
/** Specimen type (CULTURE, SPAWN, etc.) */
|
|
193
|
+
type?: SpecimenType;
|
|
194
|
+
/** Growth stage */
|
|
195
|
+
stage?: GrowthStage;
|
|
196
|
+
/** Unix timestamp of creation */
|
|
197
|
+
timestamp?: number;
|
|
198
|
+
/** Batch identifier */
|
|
199
|
+
batch?: string;
|
|
200
|
+
/** Strain information */
|
|
201
|
+
strain?: {
|
|
202
|
+
name: string;
|
|
203
|
+
generation?: string;
|
|
204
|
+
};
|
|
205
|
+
/** Version (from URL path) */
|
|
206
|
+
version: string;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* QR code generation options.
|
|
210
|
+
*/
|
|
211
|
+
export interface QRCodeOptions {
|
|
212
|
+
/** Width/height in pixels (default: 300) */
|
|
213
|
+
size?: number;
|
|
214
|
+
/** Error correction level (default: 'M') */
|
|
215
|
+
errorCorrection?: 'L' | 'M' | 'Q' | 'H';
|
|
216
|
+
/** Encoding format (default: 'embedded') */
|
|
217
|
+
format?: 'embedded' | 'compact';
|
|
218
|
+
/** Quiet zone modules (default: 1) */
|
|
219
|
+
margin?: number;
|
|
220
|
+
/** QR code colors */
|
|
221
|
+
color?: {
|
|
222
|
+
dark?: string;
|
|
223
|
+
light?: string;
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Encryption options.
|
|
228
|
+
*/
|
|
229
|
+
export interface EncryptionOptions {
|
|
230
|
+
/** CryptoKey or password string for PBKDF2 */
|
|
231
|
+
key: CryptoKey | string;
|
|
232
|
+
/** Fields to encrypt (partial encryption) */
|
|
233
|
+
fields?: string[];
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Encrypted specimen wrapper.
|
|
237
|
+
*/
|
|
238
|
+
export interface EncryptedSpecimen {
|
|
239
|
+
/** Flag indicating this is encrypted */
|
|
240
|
+
encrypted: true;
|
|
241
|
+
/** Base64url encoded ciphertext */
|
|
242
|
+
payload: string;
|
|
243
|
+
/** Base64url encoded initialization vector */
|
|
244
|
+
iv: string;
|
|
245
|
+
/** Encryption algorithm used */
|
|
246
|
+
algorithm: 'AES-256-GCM';
|
|
247
|
+
/** Authentication tag (for GCM) */
|
|
248
|
+
tag?: string;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Decryption options.
|
|
252
|
+
*/
|
|
253
|
+
export interface DecryptionOptions {
|
|
254
|
+
/** CryptoKey or password string for PBKDF2 */
|
|
255
|
+
key: CryptoKey | string;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Type guard to check if a value is a valid SpecimenType.
|
|
259
|
+
*/
|
|
260
|
+
export declare function isSpecimenType(value: unknown): value is SpecimenType;
|
|
261
|
+
/**
|
|
262
|
+
* Type guard to check if a value is a valid GrowthStage.
|
|
263
|
+
*/
|
|
264
|
+
export declare function isGrowthStage(value: unknown): value is GrowthStage;
|
|
265
|
+
/**
|
|
266
|
+
* Type guard to check if a value is a Strain object.
|
|
267
|
+
*/
|
|
268
|
+
export declare function isStrain(value: unknown): value is Strain;
|
|
269
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH;;GAEG;AACH,eAAO,MAAM,YAAY,UAAU,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,YAAY,+BAA+B,CAAC;AAMzD;;;GAGG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC;AAEtD;;;GAGG;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AAG,CAAC;IACxC,4CAA4C;IAC5C,MAAM,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAChC,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAMD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,8CAA8C;IAC9C,GAAG,EAAE,SAAS,GAAG,MAAM,CAAC;IACxB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,wCAAwC;IACxC,SAAS,EAAE,IAAI,CAAC;IAChB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,gCAAgC;IAChC,SAAS,EAAE,aAAa,CAAC;IACzB,mCAAmC;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,8CAA8C;IAC9C,GAAG,EAAE,SAAS,GAAG,MAAM,CAAC;CACzB;AAMD;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAOxD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CUID2 Generator - Zero-dependency implementation
|
|
3
|
+
*
|
|
4
|
+
* Generates collision-resistant unique identifiers following the CUID2 algorithm.
|
|
5
|
+
* This is a minimal implementation focused on the needs of WOLS specimen IDs.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/cuid
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Generate a CUID2-style identifier.
|
|
11
|
+
*
|
|
12
|
+
* The ID format is: [random][timestamp][counter][fingerprint][random]
|
|
13
|
+
* All components are base36 encoded for URL safety.
|
|
14
|
+
*
|
|
15
|
+
* @param length - Length of the generated ID (default: 24)
|
|
16
|
+
* @returns A unique, URL-safe identifier
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const id = createId();
|
|
21
|
+
* // Returns something like: "clx1a2b3c4d5e6f7g8h9i0j1"
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function createId(length?: number): string;
|
|
25
|
+
/**
|
|
26
|
+
* Generate a specimen ID with the WOLS prefix.
|
|
27
|
+
*
|
|
28
|
+
* @returns A specimen ID in format "wemush:{cuid}"
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const specimenId = createSpecimenId();
|
|
33
|
+
* // Returns: "wemush:clx1a2b3c4d5e6f7g8h9i0j1"
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function createSpecimenId(): string;
|
|
37
|
+
/**
|
|
38
|
+
* Validate a specimen ID format.
|
|
39
|
+
*
|
|
40
|
+
* @param id - The ID to validate
|
|
41
|
+
* @returns true if the ID matches the expected format
|
|
42
|
+
*/
|
|
43
|
+
export declare function isValidSpecimenId(id: string): boolean;
|
|
44
|
+
//# sourceMappingURL=cuid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cuid.d.ts","sourceRoot":"","sources":["../../../src/utils/cuid.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAuGH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,MAAM,GAAE,MAAuB,GAAG,MAAM,CAiBhE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAErD"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ISO 8601 Date Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides parsing and formatting for ISO 8601 date strings
|
|
5
|
+
* as used in WOLS specimens.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/iso8601
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Check if a string is a valid ISO 8601 date.
|
|
11
|
+
*
|
|
12
|
+
* @param value - The string to validate
|
|
13
|
+
* @returns true if valid ISO 8601 format
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* isValidISO8601('2025-12-16T10:30:00Z'); // true
|
|
18
|
+
* isValidISO8601('2025-12-16'); // false (date-only)
|
|
19
|
+
* isValidISO8601('invalid'); // false
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function isValidISO8601(value: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Check if a string is a valid date-only format (YYYY-MM-DD).
|
|
25
|
+
*
|
|
26
|
+
* @param value - The string to validate
|
|
27
|
+
* @returns true if valid date-only format
|
|
28
|
+
*/
|
|
29
|
+
export declare function isValidDateOnly(value: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Get the current timestamp in ISO 8601 format.
|
|
32
|
+
*
|
|
33
|
+
* @returns Current time as ISO 8601 string
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const now = getCurrentISO8601();
|
|
38
|
+
* // Returns: "2025-12-16T10:30:00.000Z"
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function getCurrentISO8601(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Parse an ISO 8601 date string to a Date object.
|
|
44
|
+
*
|
|
45
|
+
* @param value - The ISO 8601 string to parse
|
|
46
|
+
* @returns The parsed Date, or null if invalid
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const date = parseISO8601('2025-12-16T10:30:00Z');
|
|
51
|
+
* // Returns: Date object
|
|
52
|
+
*
|
|
53
|
+
* const invalid = parseISO8601('invalid');
|
|
54
|
+
* // Returns: null
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function parseISO8601(value: string): Date | null;
|
|
58
|
+
/**
|
|
59
|
+
* Format a Date object to ISO 8601 string.
|
|
60
|
+
*
|
|
61
|
+
* @param date - The Date to format
|
|
62
|
+
* @returns ISO 8601 string
|
|
63
|
+
*/
|
|
64
|
+
export declare function formatISO8601(date: Date): string;
|
|
65
|
+
/**
|
|
66
|
+
* Get Unix timestamp (seconds since epoch) from ISO 8601 string.
|
|
67
|
+
*
|
|
68
|
+
* @param value - The ISO 8601 string
|
|
69
|
+
* @returns Unix timestamp in seconds, or null if invalid
|
|
70
|
+
*/
|
|
71
|
+
export declare function toUnixTimestamp(value: string): number | null;
|
|
72
|
+
/**
|
|
73
|
+
* Convert Unix timestamp to ISO 8601 string.
|
|
74
|
+
*
|
|
75
|
+
* @param timestamp - Unix timestamp in seconds
|
|
76
|
+
* @returns ISO 8601 string
|
|
77
|
+
*/
|
|
78
|
+
export declare function fromUnixTimestamp(timestamp: number): string;
|
|
79
|
+
//# sourceMappingURL=iso8601.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iso8601.d.ts","sourceRoot":"","sources":["../../../src/utils/iso8601.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAQrD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAOtD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAKvD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEhD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM5D;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE3D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WOLS Specimen Validator
|
|
3
|
+
*
|
|
4
|
+
* This module provides validation functionality for WOLS specimen objects.
|
|
5
|
+
*
|
|
6
|
+
* @module validator
|
|
7
|
+
*/
|
|
8
|
+
import { type Specimen, type ValidationOptions, type ValidationResult } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Validate a specimen object against the WOLS v1.1.0 schema.
|
|
11
|
+
*
|
|
12
|
+
* @param specimen - The specimen object to validate
|
|
13
|
+
* @param options - Validation options
|
|
14
|
+
* @returns ValidationResult with errors and warnings
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const result = validateSpecimen(specimen);
|
|
19
|
+
* if (!result.valid) {
|
|
20
|
+
* console.error('Validation errors:', result.errors);
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function validateSpecimen(specimen: Specimen | unknown, options?: ValidationOptions): ValidationResult;
|
|
25
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/validator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAGL,KAAK,QAAQ,EAGb,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EAGtB,MAAM,YAAY,CAAC;AAmZpB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,QAAQ,GAAG,OAAO,EAC5B,OAAO,GAAE,iBAAsB,GAC9B,gBAAgB,CA+ClB"}
|