@gemmology/mineral-data 1.0.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/index.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @gemmology/mineral-data
3
+ *
4
+ * Pre-built SQLite database of 94+ mineral presets with CDL,
5
+ * gemmological properties, and pre-generated 3D models.
6
+ */
7
+
8
+ /**
9
+ * Absolute path to the minerals.db SQLite database file.
10
+ * Use this for Node.js SQLite libraries like better-sqlite3.
11
+ */
12
+ export const dbPath: string;
13
+
14
+ /**
15
+ * Load the database as an ArrayBuffer for use with sql.js in browsers.
16
+ *
17
+ * @returns Promise resolving to database file as ArrayBuffer
18
+ */
19
+ export function dbBuffer(): Promise<ArrayBuffer>;
20
+
21
+ /**
22
+ * Load the database synchronously as a Buffer.
23
+ *
24
+ * @returns Database file as Node.js Buffer
25
+ */
26
+ export function dbBufferSync(): Buffer;
27
+
28
+ /**
29
+ * Database schema interface for the minerals table.
30
+ */
31
+ export interface MineralRecord {
32
+ id: string;
33
+ name: string;
34
+ cdl: string;
35
+ system: string;
36
+ point_group: string;
37
+ chemistry: string;
38
+ hardness: string | null;
39
+ description: string | null;
40
+ sg: string | null;
41
+ ri: string | null;
42
+ birefringence: number | null;
43
+ optical_character: string | null;
44
+ dispersion: number | null;
45
+ lustre: string | null;
46
+ cleavage: string | null;
47
+ fracture: string | null;
48
+ pleochroism: string | null;
49
+ twin_law: string | null;
50
+ phenomenon: string | null;
51
+ note: string | null;
52
+ localities_json: string | null;
53
+ forms_json: string | null;
54
+ colors_json: string | null;
55
+ treatments_json: string | null;
56
+ inclusions_json: string | null;
57
+ /** Pre-generated SVG markup */
58
+ model_svg: string | null;
59
+ /** Pre-generated binary STL data */
60
+ model_stl: ArrayBuffer | null;
61
+ /** Pre-generated glTF JSON */
62
+ model_gltf: string | null;
63
+ /** ISO timestamp when models were generated */
64
+ models_generated_at: string | null;
65
+ }
package/index.js ADDED
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @gemmology/mineral-data
3
+ *
4
+ * Pre-built SQLite database of 94+ mineral presets with CDL (Crystal Description Language),
5
+ * gemmological properties, and pre-generated 3D models (SVG, STL, glTF).
6
+ *
7
+ * Usage:
8
+ * import { dbPath, dbBuffer } from '@gemmology/mineral-data';
9
+ *
10
+ * // For Node.js file-based access
11
+ * const db = new Database(dbPath);
12
+ *
13
+ * // For browser/sql.js usage
14
+ * const buffer = await dbBuffer();
15
+ * const db = new SQL.Database(new Uint8Array(buffer));
16
+ */
17
+
18
+ const path = require('path');
19
+ const fs = require('fs');
20
+
21
+ /**
22
+ * Absolute path to the minerals.db SQLite database file.
23
+ * Use this for Node.js SQLite libraries like better-sqlite3.
24
+ *
25
+ * @type {string}
26
+ */
27
+ const dbPath = path.join(__dirname, 'minerals.db');
28
+
29
+ /**
30
+ * Load the database as an ArrayBuffer for use with sql.js in browsers.
31
+ *
32
+ * @returns {Promise<ArrayBuffer>} Database file as ArrayBuffer
33
+ */
34
+ async function dbBuffer() {
35
+ return fs.promises.readFile(dbPath).then(buf => buf.buffer);
36
+ }
37
+
38
+ /**
39
+ * Load the database synchronously as a Buffer.
40
+ *
41
+ * @returns {Buffer} Database file as Node.js Buffer
42
+ */
43
+ function dbBufferSync() {
44
+ return fs.readFileSync(dbPath);
45
+ }
46
+
47
+ module.exports = {
48
+ dbPath,
49
+ dbBuffer,
50
+ dbBufferSync,
51
+ };
package/minerals.db ADDED
Binary file
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@gemmology/mineral-data",
3
+ "version": "1.0.0",
4
+ "description": "Pre-built SQLite database of 94+ mineral presets with CDL, properties, and 3D models for crystal visualization",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "files": [
8
+ "index.js",
9
+ "index.d.ts",
10
+ "minerals.db"
11
+ ],
12
+ "keywords": [
13
+ "crystal",
14
+ "mineralogy",
15
+ "gemmology",
16
+ "cdl",
17
+ "sqlite",
18
+ "3d-models",
19
+ "svg",
20
+ "stl",
21
+ "gltf"
22
+ ],
23
+ "author": "Fabian Schuh <fabian@gemmology.dev>",
24
+ "license": "MIT",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/gemmology-dev/mineral-database.git"
28
+ },
29
+ "homepage": "https://gemmology.dev",
30
+ "bugs": {
31
+ "url": "https://github.com/gemmology-dev/mineral-database/issues"
32
+ },
33
+ "engines": {
34
+ "node": ">=16"
35
+ }
36
+ }