lines-db 0.18.0 → 0.19.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/CHANGELOG.md +21 -0
- package/README.md +2 -0
- package/bin/cli.mjs +320 -139
- package/dist/index.d.mts +26 -29
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +185 -63
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.mts +1 -3
- package/dist/internal.d.mts.map +1 -1
- package/dist/internal.mjs +1 -1
- package/dist/{jsonl-reader-CoYEJ9pg.d.mts → jsonl-reader-aQqE1pe5.d.mts} +10 -7
- package/dist/jsonl-reader-aQqE1pe5.d.mts.map +1 -0
- package/dist/{replace-file-AWLIm7aN.mjs → replace-file-fStWc0ej.mjs} +4 -7
- package/dist/{replace-file-AWLIm7aN.mjs.map → replace-file-fStWc0ej.mjs.map} +1 -1
- package/package.json +9 -9
- package/dist/jsonl-reader-CoYEJ9pg.d.mts.map +0 -1
package/dist/internal.d.mts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { r as hashJsonlContent } from "./jsonl-reader-
|
|
2
|
-
//#region src/replace-file.d.ts
|
|
1
|
+
import { r as hashJsonlContent } from "./jsonl-reader-aQqE1pe5.mjs";
|
|
3
2
|
export declare function replaceFile(file: string, write: ((temporary: string) => Promise<void>) | undefined, expected: string | undefined): Promise<void>;
|
|
4
|
-
//#endregion
|
|
5
3
|
export { hashJsonlContent };
|
|
6
4
|
//# sourceMappingURL=internal.d.mts.map
|
package/dist/internal.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.mts","names":[],"sources":["../src/replace-file.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"internal.d.mts","names":[],"sources":["../src/replace-file.ts"],"mappings":";wBAIsB,YACpB,cACA,SAAS,sBAAsB,4BAC/B,+BACC"}
|
package/dist/internal.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { r as hashJsonlContent, t as replaceFile } from "./replace-file-
|
|
1
|
+
export { r as hashJsonlContent, t as replaceFile } from "./replace-file-fStWc0ej.mjs";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
2
|
-
//#region src/types.d.ts
|
|
3
2
|
type Table = Record<string, unknown>;
|
|
4
3
|
type StandardSchema<Input extends Table = Table, Output extends Table = Input> = StandardSchemaV1<Input, Output>;
|
|
5
4
|
type StandardSchemaResult<Output> = StandardSchemaV1.Result<Output>;
|
|
@@ -75,6 +74,15 @@ interface DatabaseConfig<_Tables extends TableDefs = TableDefs> {
|
|
|
75
74
|
* discovering foreign keys. Defaults to the directory of each table's JSONL file.
|
|
76
75
|
*/
|
|
77
76
|
schemaDir?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Columns of a table whose JSONL files have no rows. They cannot be inferred from rows, so such a
|
|
79
|
+
* table is left out of the database unless this returns them. It is given the table's name and its
|
|
80
|
+
* schema file, if it has one; returning nothing, or no columns, leaves the table out.
|
|
81
|
+
*/
|
|
82
|
+
schemaOfEmptyTable?: (table: {
|
|
83
|
+
tableName: string;
|
|
84
|
+
schemaPath: string | undefined;
|
|
85
|
+
}) => TableSchema | undefined | Promise<TableSchema | undefined>;
|
|
78
86
|
writeDataSets?: boolean;
|
|
79
87
|
/**
|
|
80
88
|
* Fields written back to the JSONL files on sync.
|
|
@@ -130,8 +138,6 @@ type WhereValue<T> = T | ((value: T) => boolean);
|
|
|
130
138
|
type WhereObject<T extends Table> = { [K in keyof T]?: WhereValue<T[K]>; };
|
|
131
139
|
type WhereCondition<T extends Table> = WhereObject<T> | WhereConditionArray<T>;
|
|
132
140
|
type WhereConditionArray<T extends Table> = Array<WhereObject<T> | WhereConditionArray<T>>;
|
|
133
|
-
//#endregion
|
|
134
|
-
//#region src/result.d.ts
|
|
135
141
|
/**
|
|
136
142
|
* A discriminated union for operations that can fail without throwing.
|
|
137
143
|
* Used throughout the JS programmatic API (`LinesDB`, `JsonlReader`) so callers get a typed
|
|
@@ -148,8 +154,6 @@ declare function ok<T>(value: T): Result<T, never>;
|
|
|
148
154
|
declare function err<E>(error: E): Result<never, E>;
|
|
149
155
|
/** Unwrap a Result, throwing its error when it is not ok. */
|
|
150
156
|
declare function unwrap<T, E>(result: Result<T, E>): T;
|
|
151
|
-
//#endregion
|
|
152
|
-
//#region src/jsonl-reader.d.ts
|
|
153
157
|
/** Fingerprint of a JSONL file's content, to tell whether the file changed since it was read */
|
|
154
158
|
declare function hashJsonlContent(content: string): string;
|
|
155
159
|
interface JsonlSnapshot {
|
|
@@ -181,6 +185,5 @@ declare class JsonlReader {
|
|
|
181
185
|
static inferSchema(tableName: string, data: JsonObject[]): Result<TableSchema, Error>;
|
|
182
186
|
private static inferType;
|
|
183
187
|
}
|
|
184
|
-
//#endregion
|
|
185
188
|
export { WhereCondition as A, TableConfig as C, ValidationError as D, TableValidationResult as E, ValidationErrorDetail as O, Table as S, TableSchema as T, JsonlConflictError as _, err as a, StandardSchemaIssue as b, ColumnDefinition as c, IndexDefinition as d, InferInput as f, JsonValue as g, JsonObject as h, Result as i, WriteFilledValues as j, ValidationResult as k, DatabaseConfig as l, JsonArray as m, JsonlSnapshot as n, ok as o, InferOutput as p, hashJsonlContent as r, unwrap as s, JsonlReader as t, ForeignKeyDefinition as u, JsonlParseError as v, TableDefs as w, StandardSchemaResult as x, StandardSchema as y };
|
|
186
|
-
//# sourceMappingURL=jsonl-reader-
|
|
189
|
+
//# sourceMappingURL=jsonl-reader-aQqE1pe5.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonl-reader-aQqE1pe5.d.mts","names":[],"sources":["../src/types.ts","../src/result.ts","../src/jsonl-reader.ts"],"mappings":";KAGY,QAAQ;KACR,eAAe,cAAc,QAAQ,OAAO,eAAe,QAAQ,SAAS,iBAAiB,OAAO;KACpG,qBAAqB,UAAU,iBAAiB,OAAO;KACvD,sBAAs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3B;;cAGW;iBACI;;;;;SAMF,cAAc,GAAG,WAAW,YAAY,eAAe,UAAU,QAAQ,KAAK,QAAQ;;;;SAmBtF,KAAK,mBAAmB,QAAQ,OAAO,cAAc,kBAAkB;;;;;SASvE,aAAa,mBAAmB,QAAQ,OAAO,eAAe;iBAoB5D;;;;SAiCR,YAAY,mBAAmB,MAAM,eAAe,OAAO,aAAa;iBAsEhE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash, randomBytes } from "node:crypto";
|
|
2
2
|
import { chmod, link, readFile, rename, rm, stat } from "node:fs/promises";
|
|
3
3
|
import { normalize } from "node:path";
|
|
4
|
-
|
|
4
|
+
// src/result.ts
|
|
5
5
|
function ok(value) {
|
|
6
6
|
return {
|
|
7
7
|
ok: true,
|
|
@@ -23,8 +23,7 @@ function unwrap(result) {
|
|
|
23
23
|
if (result.ok) return result.value;
|
|
24
24
|
throw result.error;
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
//#region src/jsonl-reader.ts
|
|
26
|
+
// src/jsonl-reader.ts
|
|
28
27
|
/** Fingerprint of a JSONL file's content, to tell whether the file changed since it was read */
|
|
29
28
|
function hashJsonlContent(content) {
|
|
30
29
|
return createHash("sha256").update(content).digest("hex");
|
|
@@ -146,8 +145,7 @@ var JsonlReader = class {
|
|
|
146
145
|
return "TEXT";
|
|
147
146
|
}
|
|
148
147
|
};
|
|
149
|
-
|
|
150
|
-
//#region src/replace-file.ts
|
|
148
|
+
// src/replace-file.ts
|
|
151
149
|
async function replaceFile(file, write, expected) {
|
|
152
150
|
const suffix = randomBytes(12).toString("hex");
|
|
153
151
|
const temporary = `${file}.${suffix}.tmp`;
|
|
@@ -197,7 +195,6 @@ async function replaceFile(file, write, expected) {
|
|
|
197
195
|
if (!moved) await rm(temporary, { force: true }).catch(() => {});
|
|
198
196
|
}
|
|
199
197
|
}
|
|
200
|
-
//#endregion
|
|
201
198
|
export { ok as a, err as i, JsonlReader as n, toError as o, hashJsonlContent as r, unwrap as s, replaceFile as t };
|
|
202
199
|
|
|
203
|
-
//# sourceMappingURL=replace-file-
|
|
200
|
+
//# sourceMappingURL=replace-file-fStWc0ej.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replace-file-AWLIm7aN.mjs","names":[],"sources":["../src/result.ts","../src/jsonl-reader.ts","../src/replace-file.ts"],"sourcesContent":["/**\n * A discriminated union for operations that can fail without throwing.\n * Used throughout the JS programmatic API (`LinesDB`, `JsonlReader`) so callers get a typed\n * error back instead of having to wrap every call in try/catch.\n */\nexport type Result<T, E = Error> = { ok: true; value: T } | { ok: false; error: E };\n\nexport function ok<T>(value: T): Result<T, never> {\n return { ok: true, value };\n}\n\nexport function err<E>(error: E): Result<never, E> {\n return { ok: false, error };\n}\n\n/** Normalize a thrown value (which may not be an Error) into an Error. */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value));\n}\n\n/** Unwrap a Result, throwing its error when it is not ok. */\nexport function unwrap<T, E>(result: Result<T, E>): T {\n if (result.ok) return result.value;\n throw result.error;\n}\n","import { createHash } from 'node:crypto';\nimport { readFile } from 'node:fs/promises';\nimport { normalize } from 'node:path';\nimport type { JsonObject, ColumnDefinition, TableSchema, JsonlParseError } from './types.js';\nimport { type Result, ok, err, toError } from './result.js';\n\n/** Fingerprint of a JSONL file's content, to tell whether the file changed since it was read */\nexport function hashJsonlContent(content: string): string {\n return createHash('sha256').update(content).digest('hex');\n}\n\nexport interface JsonlSnapshot {\n /** The rows the content parses into, or why it does not parse */\n rows: Result<JsonObject[], JsonlParseError>;\n /** Undefined when the rows come from an override rather than the file */\n contentHash: string | undefined;\n}\n\nexport class JsonlReader {\n private static overrides: Map<string, JsonObject[]> | null = null;\n\n /**\n * Temporarily override the data returned for specific JSONL files.\n * Useful for scenarios like migration validation where in-memory data should be used.\n */\n static async withOverrides<T>(overrides: Map<string, JsonObject[]>, fn: () => Promise<T>): Promise<T> {\n const normalized = new Map<string, JsonObject[]>();\n for (const [filePath, rows] of overrides) {\n normalized.set(normalize(filePath), rows);\n }\n\n const previousOverrides = this.overrides;\n this.overrides = normalized;\n\n try {\n return await fn();\n } finally {\n this.overrides = previousOverrides;\n }\n }\n\n /**\n * Read JSONL file and parse each line as JSON\n */\n static async read(filePath: string): Promise<Result<JsonObject[], JsonlParseError | Error>> {\n const result = await this.readSnapshot(filePath);\n return result.ok ? result.value.rows : result;\n }\n\n /**\n * Read JSONL file like {@link read}, along with a hash of the content the rows were parsed from.\n * The hash is there even when the content does not parse.\n */\n static async readSnapshot(filePath: string): Promise<Result<JsonlSnapshot, Error>> {\n const overrideRows = this.overrides?.get(normalize(filePath));\n if (overrideRows) {\n // Return clones to avoid accidental mutations from consumers\n return ok({\n rows: ok(overrideRows.map((row) => JSON.parse(JSON.stringify(row)) as JsonObject)),\n contentHash: undefined,\n });\n }\n\n let content: string;\n try {\n content = await readFile(filePath, 'utf-8');\n } catch (error) {\n return err(toError(error));\n }\n\n return ok({ rows: this.parse(filePath, content), contentHash: hashJsonlContent(content) });\n }\n\n private static parse(filePath: string, content: string): Result<JsonObject[], JsonlParseError> {\n const rawLines = (content.startsWith('\\u{feff}') ? content.slice(1) : content).split('\\n');\n\n const rows: JsonObject[] = [];\n for (let i = 0; i < rawLines.length; i++) {\n const line = rawLines[i].endsWith('\\r') ? rawLines[i].slice(0, -1) : rawLines[i];\n if (line.trim().length === 0) continue;\n\n const fail = (message: string, cause?: unknown) => {\n const parseError = new Error(message, { cause }) as JsonlParseError;\n parseError.name = 'JsonlParseError';\n parseError.file = filePath;\n parseError.line = i + 1;\n return err(parseError);\n };\n let value: unknown;\n try {\n value = JSON.parse(line);\n } catch (error) {\n return fail(`Failed to parse JSON line: ${line}`, error);\n }\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return fail(`A JSONL line holds a row, which is a JSON object: ${line}`);\n }\n rows.push(value as JsonObject);\n }\n\n return ok(rows);\n }\n\n /**\n * Infer schema from JSONL data\n */\n static inferSchema(tableName: string, data: JsonObject[]): Result<TableSchema, Error> {\n if (data.length === 0) {\n return err(new Error('Cannot infer schema from empty data'));\n }\n\n const columnTypes = new Map<string, Set<string>>();\n const presence = new Map<string, number>();\n const booleanColumns = new Set<string>();\n const nonBooleanColumns = new Set<string>();\n\n // Collect all column names and their types\n for (const row of data) {\n for (const [key, value] of Object.entries(row)) {\n if (!columnTypes.has(key)) {\n columnTypes.set(key, new Set());\n }\n columnTypes.get(key)!.add(this.inferType(value));\n presence.set(key, (presence.get(key) ?? 0) + 1);\n\n if (typeof value === 'boolean') {\n booleanColumns.add(key);\n } else if (value !== null) {\n nonBooleanColumns.add(key);\n }\n }\n }\n\n // Convert to column definitions\n const columns: ColumnDefinition[] = [];\n for (const [columnName, types] of columnTypes.entries()) {\n const typeArray = Array.from(types);\n\n // If multiple types exist, prefer TEXT as a safe fallback\n let sqlType: ColumnDefinition['type'] = 'TEXT';\n\n if (typeArray.length === 1) {\n sqlType = typeArray[0] as ColumnDefinition['type'];\n } else if (typeArray.every((t) => t === 'INTEGER' || t === 'REAL')) {\n sqlType = 'REAL'; // Use REAL if we have mixed numeric types\n } else if (!typeArray.includes('NULL')) {\n // If there are multiple non-null types, use TEXT\n sqlType = 'TEXT';\n } else if (typeArray.length === 2 && typeArray.includes('NULL')) {\n // If one type + NULL, use the non-null type\n sqlType = typeArray.find((t) => t !== 'NULL') as ColumnDefinition['type'];\n }\n\n const isBooleanColumn = booleanColumns.has(columnName) && !nonBooleanColumns.has(columnName);\n\n columns.push({\n name: columnName,\n type: sqlType,\n // A row without the field stores null for it, so the field is nullable unless every row has it\n notNull: !typeArray.includes('NULL') && presence.get(columnName) === data.length,\n valueType: isBooleanColumn ? 'boolean' : undefined,\n });\n }\n\n // If there's an 'id' column, make it primary key\n const idColumn = columns.find((col) => col.name === 'id');\n if (idColumn) {\n idColumn.primaryKey = true;\n }\n\n return ok({\n name: tableName,\n columns,\n });\n }\n\n private static inferType(value: unknown): string {\n if (value === null || value === undefined) return 'NULL';\n if (typeof value === 'number') {\n return Number.isInteger(value) ? 'INTEGER' : 'REAL';\n }\n if (typeof value === 'string') return 'TEXT';\n if (typeof value === 'boolean') return 'INTEGER'; // SQLite stores booleans as integers\n if (typeof value === 'object') return 'JSON'; // Store objects/arrays as JSON\n return 'TEXT';\n }\n}\n","import { randomBytes } from 'node:crypto';\nimport { chmod, link, readFile, rename, rm, stat } from 'node:fs/promises';\nimport type { JsonlConflictError } from './types.js';\n\nexport async function replaceFile(\n file: string,\n write: ((temporary: string) => Promise<void>) | undefined,\n expected: string | undefined,\n): Promise<void> {\n const suffix = randomBytes(12).toString('hex');\n const temporary = `${file}.${suffix}.tmp`;\n const backup = `${file}.${suffix}.backup`;\n let moved = false;\n const conflict = () =>\n Object.assign(new Error(`JSONL file '${file}' changed during the write`), {\n name: 'JsonlConflictError',\n file,\n }) as JsonlConflictError;\n try {\n if (write) {\n await write(temporary);\n const mode = await stat(file).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n if (mode) await chmod(temporary, mode.mode & 0o7777);\n }\n if (expected !== undefined) {\n await rename(file, backup).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') throw conflict();\n throw error;\n });\n moved = true;\n if ((await readFile(backup, 'utf8')) !== expected) throw conflict();\n }\n if (write) {\n await link(temporary, file).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'EEXIST') throw conflict();\n throw error;\n });\n }\n const cleanBackup = moved;\n moved = false;\n if (cleanBackup) await rm(backup).catch(() => {});\n } catch (error) {\n if (moved) {\n try {\n await link(backup, file);\n moved = false;\n await rm(backup).catch(() => {});\n } catch (restoreError) {\n if (error instanceof Error) {\n error.message += `; original content remains in '${backup}' because it could not be restored`;\n if (write) error.message += `; staged content remains in '${temporary}'`;\n } else {\n throw new Error(`Original content remains in '${backup}' because it could not be restored`, {\n cause: restoreError,\n });\n }\n }\n }\n throw error;\n } finally {\n if (!moved) await rm(temporary, { force: true }).catch(()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MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;EACjC,SAAS,cAAc;GACrB,IAAI,iBAAiB,OAAO;IAC1B,MAAM,WAAW,kCAAkC,OAAO;IAC1D,IAAI,OAAO,MAAM,WAAW,gCAAgC,UAAU;GACxE,OACE,MAAM,IAAI,MAAM,gCAAgC,OAAO,qCAAqC,EAC1F,OAAO,aACT,CAAC;EAEL;EAEF,MAAM;CACR,UAAU;EACR,IAAI,CAAC,OAAO,MAAM,GAAG,WAAW,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;CACjE;AACF"}
|
|
1
|
+
{"version":3,"file":"replace-file-fStWc0ej.mjs","names":[],"sources":["../src/result.ts","../src/jsonl-reader.ts","../src/replace-file.ts"],"sourcesContent":["/**\n * A discriminated union for operations that can fail without throwing.\n * Used throughout the JS programmatic API (`LinesDB`, `JsonlReader`) so callers get a typed\n * error back instead of having to wrap every call in try/catch.\n */\nexport type Result<T, E = Error> = { ok: true; value: T } | { ok: false; error: E };\n\nexport function ok<T>(value: T): Result<T, never> {\n return { ok: true, value };\n}\n\nexport function err<E>(error: E): Result<never, E> {\n return { ok: false, error };\n}\n\n/** Normalize a thrown value (which may not be an Error) into an Error. */\nexport function toError(value: unknown): Error {\n return value instanceof Error ? value : new Error(String(value));\n}\n\n/** Unwrap a Result, throwing its error when it is not ok. */\nexport function unwrap<T, E>(result: Result<T, E>): T {\n if (result.ok) return result.value;\n throw result.error;\n}\n","import { createHash } from 'node:crypto';\nimport { readFile } from 'node:fs/promises';\nimport { normalize } from 'node:path';\nimport type { JsonObject, ColumnDefinition, TableSchema, JsonlParseError } from './types.js';\nimport { type Result, ok, err, toError } from './result.js';\n\n/** Fingerprint of a JSONL file's content, to tell whether the file changed since it was read */\nexport function hashJsonlContent(content: string): string {\n return createHash('sha256').update(content).digest('hex');\n}\n\nexport interface JsonlSnapshot {\n /** The rows the content parses into, or why it does not parse */\n rows: Result<JsonObject[], JsonlParseError>;\n /** Undefined when the rows come from an override rather than the file */\n contentHash: string | undefined;\n}\n\nexport class JsonlReader {\n private static overrides: Map<string, JsonObject[]> | null = null;\n\n /**\n * Temporarily override the data returned for specific JSONL files.\n * Useful for scenarios like migration validation where in-memory data should be used.\n */\n static async withOverrides<T>(overrides: Map<string, JsonObject[]>, fn: () => Promise<T>): Promise<T> {\n const normalized = new Map<string, JsonObject[]>();\n for (const [filePath, rows] of overrides) {\n normalized.set(normalize(filePath), rows);\n }\n\n const previousOverrides = this.overrides;\n this.overrides = normalized;\n\n try {\n return await fn();\n } finally {\n this.overrides = previousOverrides;\n }\n }\n\n /**\n * Read JSONL file and parse each line as JSON\n */\n static async read(filePath: string): Promise<Result<JsonObject[], JsonlParseError | Error>> {\n const result = await this.readSnapshot(filePath);\n return result.ok ? result.value.rows : result;\n }\n\n /**\n * Read JSONL file like {@link read}, along with a hash of the content the rows were parsed from.\n * The hash is there even when the content does not parse.\n */\n static async readSnapshot(filePath: string): Promise<Result<JsonlSnapshot, Error>> {\n const overrideRows = this.overrides?.get(normalize(filePath));\n if (overrideRows) {\n // Return clones to avoid accidental mutations from consumers\n return ok({\n rows: ok(overrideRows.map((row) => JSON.parse(JSON.stringify(row)) as JsonObject)),\n contentHash: undefined,\n });\n }\n\n let content: string;\n try {\n content = await readFile(filePath, 'utf-8');\n } catch (error) {\n return err(toError(error));\n }\n\n return ok({ rows: this.parse(filePath, content), contentHash: hashJsonlContent(content) });\n }\n\n private static parse(filePath: string, content: string): Result<JsonObject[], JsonlParseError> {\n const rawLines = (content.startsWith('\\u{feff}') ? content.slice(1) : content).split('\\n');\n\n const rows: JsonObject[] = [];\n for (let i = 0; i < rawLines.length; i++) {\n const line = rawLines[i].endsWith('\\r') ? rawLines[i].slice(0, -1) : rawLines[i];\n if (line.trim().length === 0) continue;\n\n const fail = (message: string, cause?: unknown) => {\n const parseError = new Error(message, { cause }) as JsonlParseError;\n parseError.name = 'JsonlParseError';\n parseError.file = filePath;\n parseError.line = i + 1;\n return err(parseError);\n };\n let value: unknown;\n try {\n value = JSON.parse(line);\n } catch (error) {\n return fail(`Failed to parse JSON line: ${line}`, error);\n }\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return fail(`A JSONL line holds a row, which is a JSON object: ${line}`);\n }\n rows.push(value as JsonObject);\n }\n\n return ok(rows);\n }\n\n /**\n * Infer schema from JSONL data\n */\n static inferSchema(tableName: string, data: JsonObject[]): Result<TableSchema, Error> {\n if (data.length === 0) {\n return err(new Error('Cannot infer schema from empty data'));\n }\n\n const columnTypes = new Map<string, Set<string>>();\n const presence = new Map<string, number>();\n const booleanColumns = new Set<string>();\n const nonBooleanColumns = new Set<string>();\n\n // Collect all column names and their types\n for (const row of data) {\n for (const [key, value] of Object.entries(row)) {\n if (!columnTypes.has(key)) {\n columnTypes.set(key, new Set());\n }\n columnTypes.get(key)!.add(this.inferType(value));\n presence.set(key, (presence.get(key) ?? 0) + 1);\n\n if (typeof value === 'boolean') {\n booleanColumns.add(key);\n } else if (value !== null) {\n nonBooleanColumns.add(key);\n }\n }\n }\n\n // Convert to column definitions\n const columns: ColumnDefinition[] = [];\n for (const [columnName, types] of columnTypes.entries()) {\n const typeArray = Array.from(types);\n\n // If multiple types exist, prefer TEXT as a safe fallback\n let sqlType: ColumnDefinition['type'] = 'TEXT';\n\n if (typeArray.length === 1) {\n sqlType = typeArray[0] as ColumnDefinition['type'];\n } else if (typeArray.every((t) => t === 'INTEGER' || t === 'REAL')) {\n sqlType = 'REAL'; // Use REAL if we have mixed numeric types\n } else if (!typeArray.includes('NULL')) {\n // If there are multiple non-null types, use TEXT\n sqlType = 'TEXT';\n } else if (typeArray.length === 2 && typeArray.includes('NULL')) {\n // If one type + NULL, use the non-null type\n sqlType = typeArray.find((t) => t !== 'NULL') as ColumnDefinition['type'];\n }\n\n const isBooleanColumn = booleanColumns.has(columnName) && !nonBooleanColumns.has(columnName);\n\n columns.push({\n name: columnName,\n type: sqlType,\n // A row without the field stores null for it, so the field is nullable unless every row has it\n notNull: !typeArray.includes('NULL') && presence.get(columnName) === data.length,\n valueType: isBooleanColumn ? 'boolean' : undefined,\n });\n }\n\n // If there's an 'id' column, make it primary key\n const idColumn = columns.find((col) => col.name === 'id');\n if (idColumn) {\n idColumn.primaryKey = true;\n }\n\n return ok({\n name: tableName,\n columns,\n });\n }\n\n private static inferType(value: unknown): string {\n if (value === null || value === undefined) return 'NULL';\n if (typeof value === 'number') {\n return Number.isInteger(value) ? 'INTEGER' : 'REAL';\n }\n if (typeof value === 'string') return 'TEXT';\n if (typeof value === 'boolean') return 'INTEGER'; // SQLite stores booleans as integers\n if (typeof value === 'object') return 'JSON'; // Store objects/arrays as JSON\n return 'TEXT';\n }\n}\n","import { randomBytes } from 'node:crypto';\nimport { chmod, link, readFile, rename, rm, stat } from 'node:fs/promises';\nimport type { JsonlConflictError } from './types.js';\n\nexport async function replaceFile(\n file: string,\n write: ((temporary: string) => Promise<void>) | undefined,\n expected: string | undefined,\n): Promise<void> {\n const suffix = randomBytes(12).toString('hex');\n const temporary = `${file}.${suffix}.tmp`;\n const backup = `${file}.${suffix}.backup`;\n let moved = false;\n const conflict = () =>\n Object.assign(new Error(`JSONL file '${file}' changed during the write`), {\n name: 'JsonlConflictError',\n file,\n }) as JsonlConflictError;\n try {\n if (write) {\n await write(temporary);\n const mode = await stat(file).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') return undefined;\n throw error;\n });\n if (mode) await chmod(temporary, mode.mode & 0o7777);\n }\n if (expected !== undefined) {\n await rename(file, backup).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'ENOENT') throw conflict();\n throw error;\n });\n moved = true;\n if ((await readFile(backup, 'utf8')) !== expected) throw conflict();\n }\n if (write) {\n await link(temporary, file).catch((error: NodeJS.ErrnoException) => {\n if (error.code === 'EEXIST') throw conflict();\n throw error;\n });\n }\n const cleanBackup = moved;\n moved = false;\n if (cleanBackup) await rm(backup).catch(() => {});\n } catch (error) {\n if (moved) {\n try {\n await link(backup, file);\n moved = false;\n await rm(backup).catch(() => {});\n } catch (restoreError) {\n if (error instanceof Error) {\n error.message += `; original content remains in '${backup}' because it could not be restored`;\n if (write) error.message += `; staged content remains in '${temporary}'`;\n } else {\n throw new Error(`Original content remains in '${backup}' because it could not be restored`, {\n cause: restoreError,\n });\n }\n }\n }\n throw error;\n } finally {\n if (!moved) await rm(temporary, { force: true }).catch(() => {});\n }\n}\n"],"mappings":";;;;AAOA,SAAgB,GAAM,OAA4B;CAChD,OAAO;EAAE,IAAI;EAAM;CAAM;AAC3B;AAEA,SAAgB,IAAO,OAA4B;CACjD,OAAO;EAAE,IAAI;EAAO;CAAM;AAC5B;;AAGA,SAAgB,QAAQ,OAAuB;CAC7C,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AACjE;;AAGA,SAAgB,OAAa,QAAyB;CACpD,IAAI,OAAO,IAAI,OAAO,OAAO;CAC7B,MAAM,OAAO;AACf;;;ACjBA,SAAgB,iBAAiB,SAAyB;CACxD,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,OAAO,KAAK;AAC1D;AASA,IAAa,cAAb,MAAyB;CACvB,OAAe,YAA8C;;;;;CAM7D,aAAa,cAAiB,WAAsC,IAAkC;EACpG,MAAM,6BAAa,IAAI,IAA0B;EACjD,KAAK,MAAM,CAAC,UAAU,SAAS,WAC7B,WAAW,IAAI,UAAU,QAAQ,GAAG,IAAI;EAG1C,MAAM,oBAAoB,KAAK;EAC/B,KAAK,YAAY;EAEjB,IAAI;GACF,OAAO,MAAM,GAAG;EAClB,UAAU;GACR,KAAK,YAAY;EACnB;CACF;;;;CAKA,aAAa,KAAK,UAA0E;EAC1F,MAAM,SAAS,MAAM,KAAK,aAAa,QAAQ;EAC/C,OAAO,OAAO,KAAK,OAAO,MAAM,OAAO;CACzC;;;;;CAMA,aAAa,aAAa,UAAyD;EACjF,MAAM,eAAe,KAAK,WAAW,IAAI,UAAU,QAAQ,CAAC;E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,MAAM,SAAS;GAC5C,MAAM;EACR,CAAC;EAEH,MAAM,cAAc;EACpB,QAAQ;EACR,IAAI,aAAa,MAAM,GAAG,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;CAClD,SAAS,OAAO;EACd,IAAI,OACF,IAAI;GACF,MAAM,KAAK,QAAQ,IAAI;GACvB,QAAQ;GACR,MAAM,GAAG,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;EACjC,SAAS,cAAc;GACrB,IAAI,iBAAiB,OAAO;IAC1B,MAAM,WAAW,kCAAkC,OAAO;IAC1D,IAAI,OAAO,MAAM,WAAW,gCAAgC,UAAU;GACxE,OACE,MAAM,IAAI,MAAM,gCAAgC,OAAO,qCAAqC,EAC1F,OAAO,aACT,CAAC;EAEL;EAEF,MAAM;CACR,UAAU;EACR,IAAI,CAAC,OAAO,MAAM,GAAG,WAAW,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC;CACjE;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lines-db",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "A database implementation that treats JSONL files as tables using SQLite",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.mts",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
},
|
|
43
43
|
"homepage": "https://github.com/toiroakr/lines-db#readme",
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@loculus/rolldown": "^0.
|
|
46
|
-
"@types/node": "^
|
|
45
|
+
"@loculus/rolldown": "^0.3.1",
|
|
46
|
+
"@types/node": "^26.6.6",
|
|
47
47
|
"publint": "^0.3.25",
|
|
48
|
-
"tsdown": "^0.23.
|
|
48
|
+
"tsdown": "^0.23.4",
|
|
49
49
|
"type-fest": "^5.10.0",
|
|
50
50
|
"typescript": "^6.0.3",
|
|
51
51
|
"valibot": "^1.5.0",
|
|
52
|
-
"vitest": "^5.0.
|
|
52
|
+
"vitest": "^5.0.5"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"typescript": ">=5 <7 || >=7.1.0-0"
|
|
@@ -60,11 +60,11 @@
|
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@politty/loculus": "^0.
|
|
63
|
+
"@politty/loculus": "^0.4.0",
|
|
64
64
|
"@standard-schema/spec": "^1.1.0",
|
|
65
|
-
"amaro": "^1.
|
|
66
|
-
"loculus": "^0.
|
|
67
|
-
"zod": "^4.6.
|
|
65
|
+
"amaro": "^1.3.0",
|
|
66
|
+
"loculus": "^0.4.1",
|
|
67
|
+
"zod": "^4.6.7"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build": "tsdown",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl-reader-CoYEJ9pg.d.mts","names":[],"sources":["../src/types.ts","../src/result.ts","../src/jsonl-reader.ts"],"mappings":";;KAGY,QAAQ;KACR,eAAe,cAAc,QAAQ,OAAO,eAAe,QAAQ,SAAS,iBAAiB,OAAO;KACpG,qBAAqB,UAAU,iBAAiB,OAAO;KACvD,sBAAsB,iBAAiB;KAOvC,WAAW,KAAK,UAAU,uBAAuB,cAAc;KAC/D,YAAY,KAAK,UAAU,gCAAgC,KAAK;UAG3D;EACf;EACA;EACA;EACA,QAAQ;EACR;;UAGe;EACf;EACA,QAAQ;EACR;EACA,cAAc;;UAGC;EACf;EACA;EACA;EACA,QAAQ,cAAc;EACtB;EACA;IACE;IACA;IACA;IACA;;;UAIa;EACf;EACA;IACE;IACA;;EAEF;EACA;;UAGe;EACf;EACA;EACA;;UAGe;EACf;EACA,SAAS;EACT,cAAc;;EAEd,sBAAsB;EACtB,UAAU;;UAGK;EACf;EACA;EACA;EACA;EACA;EACA;;KAGU,YAAY,eAAe;cAClB;UAEJ,eAAe,gBAAgB,YAAY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