lines-db 0.18.1 → 0.19.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/CHANGELOG.md +23 -0
- package/README.ja.md +1 -1
- package/README.md +3 -1
- package/bin/cli.mjs +688 -112
- package/dist/index.d.mts +39 -31
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +247 -80
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.mts +2 -4
- package/dist/internal.d.mts.map +1 -1
- package/dist/internal.mjs +1 -1
- package/dist/schema-module-D4j10w8_.mjs +396 -0
- package/dist/schema-module-D4j10w8_.mjs.map +1 -0
- package/dist/{jsonl-reader-CoYEJ9pg.d.mts → schema-module-Tb40gPyF.d.mts} +25 -8
- package/dist/schema-module-Tb40gPyF.d.mts.map +1 -0
- package/package.json +6 -6
- package/dist/jsonl-reader-CoYEJ9pg.d.mts.map +0 -1
- package/dist/replace-file-AWLIm7aN.mjs +0 -203
- package/dist/replace-file-AWLIm7aN.mjs.map +0 -1
package/dist/internal.d.mts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
//#region src/replace-file.d.ts
|
|
1
|
+
import { a as hashJsonlContent, n as createSchemaImports, t as SchemaImports } from "./schema-module-Tb40gPyF.mjs";
|
|
3
2
|
export declare function replaceFile(file: string, write: ((temporary: string) => Promise<void>) | undefined, expected: string | undefined): Promise<void>;
|
|
4
|
-
|
|
5
|
-
export { hashJsonlContent };
|
|
3
|
+
export { type SchemaImports, createSchemaImports, 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 {
|
|
1
|
+
export { n as createSchemaImports, o as hashJsonlContent, i as replaceFile } from "./schema-module-D4j10w8_.mjs";
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import * as nodeModule from "node:module";
|
|
2
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
3
|
+
import { chmod, link, readFile, rename, rm, stat } from "node:fs/promises";
|
|
4
|
+
import { dirname, join, normalize } from "node:path";
|
|
5
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
|
+
// src/result.ts
|
|
8
|
+
function ok(value) {
|
|
9
|
+
return {
|
|
10
|
+
ok: true,
|
|
11
|
+
value
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function err(error) {
|
|
15
|
+
return {
|
|
16
|
+
ok: false,
|
|
17
|
+
error
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** Normalize a thrown value (which may not be an Error) into an Error. */
|
|
21
|
+
function toError(value) {
|
|
22
|
+
return value instanceof Error ? value : new Error(String(value));
|
|
23
|
+
}
|
|
24
|
+
/** Unwrap a Result, throwing its error when it is not ok. */
|
|
25
|
+
function unwrap(result) {
|
|
26
|
+
if (result.ok) return result.value;
|
|
27
|
+
throw result.error;
|
|
28
|
+
}
|
|
29
|
+
// src/jsonl-reader.ts
|
|
30
|
+
/** Fingerprint of a JSONL file's content, to tell whether the file changed since it was read */
|
|
31
|
+
function hashJsonlContent(content) {
|
|
32
|
+
return createHash("sha256").update(content).digest("hex");
|
|
33
|
+
}
|
|
34
|
+
var JsonlReader = class {
|
|
35
|
+
static overrides = null;
|
|
36
|
+
/**
|
|
37
|
+
* Temporarily override the data returned for specific JSONL files.
|
|
38
|
+
* Useful for scenarios like migration validation where in-memory data should be used.
|
|
39
|
+
*/
|
|
40
|
+
static async withOverrides(overrides, fn) {
|
|
41
|
+
const normalized = /* @__PURE__ */ new Map();
|
|
42
|
+
for (const [filePath, rows] of overrides) normalized.set(normalize(filePath), rows);
|
|
43
|
+
const previousOverrides = this.overrides;
|
|
44
|
+
this.overrides = normalized;
|
|
45
|
+
try {
|
|
46
|
+
return await fn();
|
|
47
|
+
} finally {
|
|
48
|
+
this.overrides = previousOverrides;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Read JSONL file and parse each line as JSON
|
|
53
|
+
*/
|
|
54
|
+
static async read(filePath) {
|
|
55
|
+
const result = await this.readSnapshot(filePath);
|
|
56
|
+
return result.ok ? result.value.rows : result;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Read JSONL file like {@link read}, along with a hash of the content the rows were parsed from.
|
|
60
|
+
* The hash is there even when the content does not parse.
|
|
61
|
+
*/
|
|
62
|
+
static async readSnapshot(filePath) {
|
|
63
|
+
const overrideRows = this.overrides?.get(normalize(filePath));
|
|
64
|
+
if (overrideRows) return ok({
|
|
65
|
+
rows: ok(overrideRows.map((row) => JSON.parse(JSON.stringify(row)))),
|
|
66
|
+
contentHash: void 0
|
|
67
|
+
});
|
|
68
|
+
let content;
|
|
69
|
+
try {
|
|
70
|
+
content = await readFile(filePath, "utf-8");
|
|
71
|
+
} catch (error) {
|
|
72
|
+
return err(toError(error));
|
|
73
|
+
}
|
|
74
|
+
return ok({
|
|
75
|
+
rows: this.parse(filePath, content),
|
|
76
|
+
contentHash: hashJsonlContent(content)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
static parse(filePath, content) {
|
|
80
|
+
const rawLines = (content.startsWith("") ? content.slice(1) : content).split("\n");
|
|
81
|
+
const rows = [];
|
|
82
|
+
for (let i = 0; i < rawLines.length; i++) {
|
|
83
|
+
const line = rawLines[i].endsWith("\r") ? rawLines[i].slice(0, -1) : rawLines[i];
|
|
84
|
+
if (line.trim().length === 0) continue;
|
|
85
|
+
const fail = (message, cause) => {
|
|
86
|
+
const parseError = new Error(message, { cause });
|
|
87
|
+
parseError.name = "JsonlParseError";
|
|
88
|
+
parseError.file = filePath;
|
|
89
|
+
parseError.line = i + 1;
|
|
90
|
+
return err(parseError);
|
|
91
|
+
};
|
|
92
|
+
let value;
|
|
93
|
+
try {
|
|
94
|
+
value = JSON.parse(line);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
return fail(`Failed to parse JSON line: ${line}`, error);
|
|
97
|
+
}
|
|
98
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return fail(`A JSONL line holds a row, which is a JSON object: ${line}`);
|
|
99
|
+
rows.push(value);
|
|
100
|
+
}
|
|
101
|
+
return ok(rows);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Infer schema from JSONL data
|
|
105
|
+
*/
|
|
106
|
+
static inferSchema(tableName, data) {
|
|
107
|
+
if (data.length === 0) return err(/* @__PURE__ */ new Error("Cannot infer schema from empty data"));
|
|
108
|
+
const columnTypes = /* @__PURE__ */ new Map();
|
|
109
|
+
const presence = /* @__PURE__ */ new Map();
|
|
110
|
+
const booleanColumns = /* @__PURE__ */ new Set();
|
|
111
|
+
const nonBooleanColumns = /* @__PURE__ */ new Set();
|
|
112
|
+
for (const row of data) for (const [key, value] of Object.entries(row)) {
|
|
113
|
+
if (!columnTypes.has(key)) columnTypes.set(key, /* @__PURE__ */ new Set());
|
|
114
|
+
columnTypes.get(key).add(this.inferType(value));
|
|
115
|
+
presence.set(key, (presence.get(key) ?? 0) + 1);
|
|
116
|
+
if (typeof value === "boolean") booleanColumns.add(key);
|
|
117
|
+
else if (value !== null) nonBooleanColumns.add(key);
|
|
118
|
+
}
|
|
119
|
+
const columns = [];
|
|
120
|
+
for (const [columnName, types] of columnTypes.entries()) {
|
|
121
|
+
const typeArray = Array.from(types);
|
|
122
|
+
let sqlType = "TEXT";
|
|
123
|
+
if (typeArray.length === 1) sqlType = typeArray[0];
|
|
124
|
+
else if (typeArray.every((t) => t === "INTEGER" || t === "REAL")) sqlType = "REAL";
|
|
125
|
+
else if (!typeArray.includes("NULL")) sqlType = "TEXT";
|
|
126
|
+
else if (typeArray.length === 2 && typeArray.includes("NULL")) sqlType = typeArray.find((t) => t !== "NULL");
|
|
127
|
+
const isBooleanColumn = booleanColumns.has(columnName) && !nonBooleanColumns.has(columnName);
|
|
128
|
+
columns.push({
|
|
129
|
+
name: columnName,
|
|
130
|
+
type: sqlType,
|
|
131
|
+
notNull: !typeArray.includes("NULL") && presence.get(columnName) === data.length,
|
|
132
|
+
valueType: isBooleanColumn ? "boolean" : void 0
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
const idColumn = columns.find((col) => col.name === "id");
|
|
136
|
+
if (idColumn) idColumn.primaryKey = true;
|
|
137
|
+
return ok({
|
|
138
|
+
name: tableName,
|
|
139
|
+
columns
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
static inferType(value) {
|
|
143
|
+
if (value === null || value === void 0) return "NULL";
|
|
144
|
+
if (typeof value === "number") return Number.isInteger(value) ? "INTEGER" : "REAL";
|
|
145
|
+
if (typeof value === "string") return "TEXT";
|
|
146
|
+
if (typeof value === "boolean") return "INTEGER";
|
|
147
|
+
if (typeof value === "object") return "JSON";
|
|
148
|
+
return "TEXT";
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
// src/replace-file.ts
|
|
152
|
+
async function replaceFile(file, write, expected) {
|
|
153
|
+
const suffix = randomBytes(12).toString("hex");
|
|
154
|
+
const temporary = `${file}.${suffix}.tmp`;
|
|
155
|
+
const backup = `${file}.${suffix}.backup`;
|
|
156
|
+
let moved = false;
|
|
157
|
+
const conflict = () => Object.assign(/* @__PURE__ */ new Error(`JSONL file '${file}' changed during the write`), {
|
|
158
|
+
name: "JsonlConflictError",
|
|
159
|
+
file
|
|
160
|
+
});
|
|
161
|
+
try {
|
|
162
|
+
if (write) {
|
|
163
|
+
await write(temporary);
|
|
164
|
+
const mode = await stat(file).catch((error) => {
|
|
165
|
+
if (error.code === "ENOENT") return void 0;
|
|
166
|
+
throw error;
|
|
167
|
+
});
|
|
168
|
+
if (mode) await chmod(temporary, mode.mode & 4095);
|
|
169
|
+
}
|
|
170
|
+
if (expected !== void 0) {
|
|
171
|
+
await rename(file, backup).catch((error) => {
|
|
172
|
+
if (error.code === "ENOENT") throw conflict();
|
|
173
|
+
throw error;
|
|
174
|
+
});
|
|
175
|
+
moved = true;
|
|
176
|
+
if (await readFile(backup, "utf8") !== expected) throw conflict();
|
|
177
|
+
}
|
|
178
|
+
if (write) await link(temporary, file).catch((error) => {
|
|
179
|
+
if (error.code === "EEXIST") throw conflict();
|
|
180
|
+
throw error;
|
|
181
|
+
});
|
|
182
|
+
const cleanBackup = moved;
|
|
183
|
+
moved = false;
|
|
184
|
+
if (cleanBackup) await rm(backup).catch(() => {});
|
|
185
|
+
} catch (error) {
|
|
186
|
+
if (moved) try {
|
|
187
|
+
await link(backup, file);
|
|
188
|
+
moved = false;
|
|
189
|
+
await rm(backup).catch(() => {});
|
|
190
|
+
} catch (restoreError) {
|
|
191
|
+
if (error instanceof Error) {
|
|
192
|
+
error.message += `; original content remains in '${backup}' because it could not be restored`;
|
|
193
|
+
if (write) error.message += `; staged content remains in '${temporary}'`;
|
|
194
|
+
} else throw new Error(`Original content remains in '${backup}' because it could not be restored`, { cause: restoreError });
|
|
195
|
+
}
|
|
196
|
+
throw error;
|
|
197
|
+
} finally {
|
|
198
|
+
if (!moved) await rm(temporary, { force: true }).catch(() => {});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// src/schema-module.ts
|
|
202
|
+
const VERSION_PARAM = "linesDbV";
|
|
203
|
+
const SHARED = Symbol.for("lines-db:schema-imports:1");
|
|
204
|
+
let counter = 0;
|
|
205
|
+
const shared = globalThis[SHARED] ??= {
|
|
206
|
+
graph: /* @__PURE__ */ new Map(),
|
|
207
|
+
evaluated: /* @__PURE__ */ new Map(),
|
|
208
|
+
evaluatedUrls: /* @__PURE__ */ new Set(),
|
|
209
|
+
versions: /* @__PURE__ */ new Map(),
|
|
210
|
+
hashes: /* @__PURE__ */ new Map(),
|
|
211
|
+
salt: "",
|
|
212
|
+
hooked: false
|
|
213
|
+
};
|
|
214
|
+
shared.evaluated ??= /* @__PURE__ */ new Map();
|
|
215
|
+
shared.evaluatedUrls ??= /* @__PURE__ */ new Set();
|
|
216
|
+
const packageRoots = /* @__PURE__ */ new Map();
|
|
217
|
+
function hashOf(parts) {
|
|
218
|
+
const hash = createHash("sha1");
|
|
219
|
+
for (const part of parts) hash.update(part).update("\0");
|
|
220
|
+
return hash.digest("hex");
|
|
221
|
+
}
|
|
222
|
+
function contentOf(file) {
|
|
223
|
+
try {
|
|
224
|
+
return readFileSync(file);
|
|
225
|
+
} catch {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function hashContent(content) {
|
|
230
|
+
return createHash("sha1").update(content).digest("hex");
|
|
231
|
+
}
|
|
232
|
+
/** What a file that is not there holds: not a hash, so that no file can have it */
|
|
233
|
+
const MISSING_HASH = "missing";
|
|
234
|
+
function hashOfFile(file) {
|
|
235
|
+
const content = contentOf(file);
|
|
236
|
+
return content === void 0 ? MISSING_HASH : hashContent(content);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* What the file is, with what it imports: a file evaluated again only when it or a file it imports changed,
|
|
240
|
+
* as a URL that names the version is one module for as long as the version stays. An import not recorded
|
|
241
|
+
* yet is not in the version. A file importing itself through others is taken by its own content there, so
|
|
242
|
+
* a version that was cut by a cycle is kept only for the file the count started from, which holds all of it
|
|
243
|
+
*/
|
|
244
|
+
function versionOf(file, visiting = /* @__PURE__ */ new Set()) {
|
|
245
|
+
const known = shared.versions.get(file);
|
|
246
|
+
if (known) return {
|
|
247
|
+
version: known,
|
|
248
|
+
whole: true
|
|
249
|
+
};
|
|
250
|
+
const content = hashOfFile(file);
|
|
251
|
+
if (!shared.hashes.has(file)) shared.hashes.set(file, content);
|
|
252
|
+
if (visiting.has(file)) return {
|
|
253
|
+
version: hashOf([shared.salt, content]),
|
|
254
|
+
whole: false
|
|
255
|
+
};
|
|
256
|
+
visiting.add(file);
|
|
257
|
+
let whole = true;
|
|
258
|
+
const versions = [];
|
|
259
|
+
for (const imported of [...shared.graph.get(file) ?? []].sort()) {
|
|
260
|
+
const importedVersion = versionOf(imported, visiting);
|
|
261
|
+
versions.push(importedVersion.version);
|
|
262
|
+
whole &&= importedVersion.whole;
|
|
263
|
+
}
|
|
264
|
+
visiting.delete(file);
|
|
265
|
+
const version = hashOf([
|
|
266
|
+
shared.salt,
|
|
267
|
+
content,
|
|
268
|
+
...versions
|
|
269
|
+
]);
|
|
270
|
+
if (whole || visiting.size === 0) shared.versions.set(file, version);
|
|
271
|
+
return {
|
|
272
|
+
version,
|
|
273
|
+
whole
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
function packageRootOf(file) {
|
|
277
|
+
const start = dirname(file);
|
|
278
|
+
const cached = packageRoots.get(start);
|
|
279
|
+
if (cached !== void 0) return cached;
|
|
280
|
+
let dir = start;
|
|
281
|
+
let root = "";
|
|
282
|
+
for (;;) {
|
|
283
|
+
if (existsSync(join(dir, "package.json"))) {
|
|
284
|
+
root = dir;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
const parent = dirname(dir);
|
|
288
|
+
if (parent === dir) break;
|
|
289
|
+
dir = parent;
|
|
290
|
+
}
|
|
291
|
+
packageRoots.set(start, root);
|
|
292
|
+
return root;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* A file imported under a URL not seen before is evaluated, and imports again what it imports: what an earlier
|
|
296
|
+
* evaluation of it imported is dropped here, as a file that no longer imports anything resolves nothing to
|
|
297
|
+
* replace it. A URL seen before is a module already evaluated, whose imports stay
|
|
298
|
+
*/
|
|
299
|
+
function startEvaluation(file, url) {
|
|
300
|
+
if (shared.evaluatedUrls.has(url)) return;
|
|
301
|
+
shared.evaluatedUrls.add(url);
|
|
302
|
+
shared.graph.set(file, /* @__PURE__ */ new Set());
|
|
303
|
+
shared.evaluated.set(file, url);
|
|
304
|
+
}
|
|
305
|
+
/** Records the import of a file by a file that is read with versions; false for a file that is not one of the project */
|
|
306
|
+
function recordImport(parentURL, imported) {
|
|
307
|
+
if (!new URL(parentURL).searchParams.has(VERSION_PARAM)) return false;
|
|
308
|
+
const parent = fileURLToPath(parentURL);
|
|
309
|
+
if (packageRootOf(imported) !== packageRootOf(parent)) return false;
|
|
310
|
+
let imports = shared.graph.get(parent);
|
|
311
|
+
if (!imports || shared.evaluated.get(parent) !== parentURL) {
|
|
312
|
+
imports = /* @__PURE__ */ new Set();
|
|
313
|
+
shared.graph.set(parent, imports);
|
|
314
|
+
shared.evaluated.set(parent, parentURL);
|
|
315
|
+
}
|
|
316
|
+
imports.add(imported);
|
|
317
|
+
versionOf(imported);
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
function hookImports() {
|
|
321
|
+
if (shared.hooked) return true;
|
|
322
|
+
if (typeof nodeModule.registerHooks !== "function") return false;
|
|
323
|
+
nodeModule.registerHooks({ resolve(specifier, context, nextResolve) {
|
|
324
|
+
let resolved;
|
|
325
|
+
try {
|
|
326
|
+
resolved = nextResolve(specifier, context);
|
|
327
|
+
} catch (error) {
|
|
328
|
+
if (error.code === "ERR_MODULE_NOT_FOUND" && /^\.\.?\//.test(specifier)) {
|
|
329
|
+
const missing = context.parentURL?.startsWith("file:") ? new URL(specifier, context.parentURL) : void 0;
|
|
330
|
+
if (missing && !missing.href.includes("/node_modules/")) recordImport(context.parentURL, fileURLToPath(missing));
|
|
331
|
+
}
|
|
332
|
+
throw error;
|
|
333
|
+
}
|
|
334
|
+
if (!context.parentURL?.includes(VERSION_PARAM) || !resolved.url.startsWith("file:")) return resolved;
|
|
335
|
+
if (resolved.url.includes("/node_modules/")) return resolved;
|
|
336
|
+
const url = new URL(resolved.url);
|
|
337
|
+
if (url.searchParams.has(VERSION_PARAM)) return resolved;
|
|
338
|
+
const imported = fileURLToPath(url);
|
|
339
|
+
if (!recordImport(context.parentURL, imported)) return resolved;
|
|
340
|
+
url.searchParams.set(VERSION_PARAM, versionOf(imported).version);
|
|
341
|
+
startEvaluation(imported, url.href);
|
|
342
|
+
return {
|
|
343
|
+
...resolved,
|
|
344
|
+
url: url.href
|
|
345
|
+
};
|
|
346
|
+
} });
|
|
347
|
+
shared.hooked = true;
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
function realFile(file) {
|
|
351
|
+
try {
|
|
352
|
+
return realpathSync(file);
|
|
353
|
+
} catch {
|
|
354
|
+
return file;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function importedBy(entries) {
|
|
358
|
+
const files = /* @__PURE__ */ new Set();
|
|
359
|
+
const pending = [...entries].flatMap((entry) => [...shared.graph.get(entry) ?? []]);
|
|
360
|
+
for (let file = pending.pop(); file !== void 0; file = pending.pop()) {
|
|
361
|
+
if (files.has(file)) continue;
|
|
362
|
+
files.add(file);
|
|
363
|
+
pending.push(...shared.graph.get(file) ?? []);
|
|
364
|
+
}
|
|
365
|
+
return [...files].filter((file) => !entries.has(file));
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Imports of schema files in which a file imported by several of them, and by the same one again, is
|
|
369
|
+
* evaluated once: the versions are taken at the first import of a file and kept for the ones after it
|
|
370
|
+
*/
|
|
371
|
+
function createSchemaImports() {
|
|
372
|
+
const hooks = hookImports();
|
|
373
|
+
shared.versions.clear();
|
|
374
|
+
shared.hashes.clear();
|
|
375
|
+
const modules = /* @__PURE__ */ new Map();
|
|
376
|
+
return {
|
|
377
|
+
import(schemaPath) {
|
|
378
|
+
const file = realFile(schemaPath);
|
|
379
|
+
const known = modules.get(file);
|
|
380
|
+
if (known) return known;
|
|
381
|
+
const url = new URL(pathToFileURL(file).href);
|
|
382
|
+
url.searchParams.set(VERSION_PARAM, hooks ? versionOf(file).version : `${Date.now()}`);
|
|
383
|
+
if (hooks) startEvaluation(file, url.href);
|
|
384
|
+
const loaded = import(url.href);
|
|
385
|
+
loaded.catch(() => {
|
|
386
|
+
shared.salt = `${Date.now()}-${++counter}`;
|
|
387
|
+
});
|
|
388
|
+
modules.set(file, loaded);
|
|
389
|
+
return loaded;
|
|
390
|
+
},
|
|
391
|
+
dependencies: (schemaPath) => new Map(importedBy(new Set(schemaPath ? [realFile(schemaPath)] : modules.keys())).map((file) => [file, shared.hashes.get(file) ?? hashOfFile(file)]))
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
export { JsonlReader as a, ok as c, replaceFile as i, toError as l, createSchemaImports as n, hashJsonlContent as o, hashContent as r, err as s, MISSING_HASH as t, unwrap as u };
|
|
395
|
+
|
|
396
|
+
//# sourceMappingURL=schema-module-D4j10w8_.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-module-D4j10w8_.mjs","names":[],"sources":["../src/result.ts","../src/jsonl-reader.ts","../src/replace-file.ts","../src/schema-module.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","import { createHash } from 'node:crypto';\nimport { existsSync, readFileSync, realpathSync } from 'node:fs';\nimport * as nodeModule from 'node:module';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath, pathToFileURL } from 'node:url';\n\nconst VERSION_PARAM = 'linesDbV';\n// Not the shape of one copy of this package: another copy, of another version, shares the hook and the graph\nconst SHARED = Symbol.for('lines-db:schema-imports:1');\n\nexport interface SchemaImports {\n /** The module a schema file exports, with the project files it imports as they are now */\n import(schemaPath: string): Promise<Record<string, unknown>>;\n /**\n * The project files a schema file imports, with what each held when it was read; not the schema files\n * themselves. Of the schema files imported so far when none is given\n */\n dependencies(schemaPath?: string): Map<string, string>;\n}\n\ninterface Shared {\n /** The files a file imported when it was evaluated */\n graph: Map<string, Set<string>>;\n /** The URL of the evaluation of each file that `graph` records the imports of */\n evaluated: Map<string, string>;\n /** The URLs the files were imported under: one imported under a new URL is evaluated, and imports what it imports anew */\n evaluatedUrls: Set<string>;\n /** The version of each file, as of the import in progress */\n versions: Map<string, string>;\n /** What each file held when its version was taken, before it was evaluated */\n hashes: Map<string, string>;\n /** Changes after an import failed, so that every file is imported anew: Node.js 22 keeps a failed import under its URL */\n salt: string;\n hooked: boolean;\n}\n\nlet counter = 0;\n\nconst shared: Shared = ((globalThis as Record<symbol, unknown>)[SHARED] ??= {\n graph: new Map(),\n evaluated: new Map(),\n evaluatedUrls: new Set(),\n versions: new Map(),\n hashes: new Map(),\n salt: '',\n hooked: false,\n}) as Shared;\n\n// Not only in the initializer above: a copy of the package that ran before this one left the record without them\nshared.evaluated ??= new Map();\nshared.evaluatedUrls ??= new Set();\n\nconst packageRoots = new Map<string, string>();\n\nfunction hashOf(parts: Array<string | Buffer>): string {\n const hash = createHash('sha1');\n for (const part of parts) hash.update(part).update('\\0');\n return hash.digest('hex');\n}\n\nfunction contentOf(file: string): Buffer | undefined {\n try {\n return readFileSync(file);\n } catch {\n return undefined;\n }\n}\n\nexport function hashContent(content: Buffer | string): string {\n return createHash('sha1').update(content).digest('hex');\n}\n\n/** What a file that is not there holds: not a hash, so that no file can have it */\nexport const MISSING_HASH = 'missing';\n\nfunction hashOfFile(file: string): string {\n const content = contentOf(file);\n return content === undefined ? MISSING_HASH : hashContent(content);\n}\n\n/**\n * What the file is, with what it imports: a file evaluated again only when it or a file it imports changed,\n * as a URL that names the version is one module for as long as the version stays. An import not recorded\n * yet is not in the version. A file importing itself through others is taken by its own content there, so\n * a version that was cut by a cycle is kept only for the file the count started from, which holds all of it\n */\nfunction versionOf(file: string, visiting = new Set<string>()): { version: string; whole: boolean } {\n const known = shared.versions.get(file);\n if (known) return { version: known, whole: true };\n // Not the content itself: a file holding only the word `missing` would take the version of a file that is not there\n const content = hashOfFile(file);\n if (!shared.hashes.has(file)) shared.hashes.set(file, content);\n if (visiting.has(file)) return { version: hashOf([shared.salt, content]), whole: false };\n visiting.add(file);\n let whole = true;\n const versions: string[] = [];\n for (const imported of [...(shared.graph.get(file) ?? [])].sort()) {\n const importedVersion = versionOf(imported, visiting);\n versions.push(importedVersion.version);\n whole &&= importedVersion.whole;\n }\n visiting.delete(file);\n const version = hashOf([shared.salt, content, ...versions]);\n if (whole || visiting.size === 0) shared.versions.set(file, version);\n return { version, whole };\n}\n\nfunction packageRootOf(file: string): string {\n const start = dirname(file);\n const cached = packageRoots.get(start);\n if (cached !== undefined) return cached;\n let dir = start;\n let root = '';\n for (;;) {\n if (existsSync(join(dir, 'package.json'))) {\n root = dir;\n break;\n }\n const parent = dirname(dir);\n if (parent === dir) break;\n dir = parent;\n }\n packageRoots.set(start, root);\n return root;\n}\n\n/**\n * A file imported under a URL not seen before is evaluated, and imports again what it imports: what an earlier\n * evaluation of it imported is dropped here, as a file that no longer imports anything resolves nothing to\n * replace it. A URL seen before is a module already evaluated, whose imports stay\n */\nfunction startEvaluation(file: string, url: string): void {\n if (shared.evaluatedUrls.has(url)) return;\n shared.evaluatedUrls.add(url);\n shared.graph.set(file, new Set());\n shared.evaluated.set(file, url);\n}\n\n/** Records the import of a file by a file that is read with versions; false for a file that is not one of the project */\nfunction recordImport(parentURL: string, imported: string): boolean {\n if (!new URL(parentURL).searchParams.has(VERSION_PARAM)) return false;\n const parent = fileURLToPath(parentURL);\n // Not beyond the package of the importing file, whatever the specifier: a file of another package, such\n // as one linked from a workspace, is shared with the program and stays one module\n if (packageRootOf(imported) !== packageRootOf(parent)) return false;\n // Not added to what an earlier evaluation of the parent imported: a file it no longer imports is not a dependency\n let imports = shared.graph.get(parent);\n if (!imports || shared.evaluated.get(parent) !== parentURL) {\n imports = new Set<string>();\n shared.graph.set(parent, imports);\n shared.evaluated.set(parent, parentURL);\n }\n imports.add(imported);\n // Its hash taken now, before it is evaluated or added\n versionOf(imported);\n return true;\n}\n\nfunction hookImports(): boolean {\n if (shared.hooked) return true;\n // Without synchronous hooks (a runtime other than Node.js) only the schema file itself is read again\n if (typeof nodeModule.registerHooks !== 'function') return false;\n nodeModule.registerHooks({\n resolve(specifier, context, nextResolve) {\n let resolved;\n try {\n resolved = nextResolve(specifier, context);\n } catch (error) {\n // The file is imported again once it is added: a schema failing for it is then read anew\n if ((error as NodeJS.ErrnoException).code === 'ERR_MODULE_NOT_FOUND' && /^\\.\\.?\\//.test(specifier)) {\n const missing = context.parentURL?.startsWith('file:') ? new URL(specifier, context.parentURL) : undefined;\n // A package from node_modules is left out as it is when the file is there\n if (missing && !missing.href.includes('/node_modules/'))\n recordImport(context.parentURL!, fileURLToPath(missing));\n }\n throw error;\n }\n if (!context.parentURL?.includes(VERSION_PARAM) || !resolved.url.startsWith('file:')) return resolved;\n if (resolved.url.includes('/node_modules/')) return resolved;\n const url = new URL(resolved.url);\n if (url.searchParams.has(VERSION_PARAM)) return resolved;\n const imported = fileURLToPath(url);\n if (!recordImport(context.parentURL, imported)) return resolved;\n url.searchParams.set(VERSION_PARAM, versionOf(imported).version);\n startEvaluation(imported, url.href);\n return { ...resolved, url: url.href };\n },\n });\n shared.hooked = true;\n return true;\n}\n\nfunction realFile(file: string): string {\n try {\n return realpathSync(file);\n } catch {\n // The import reports a file that is not there\n return file;\n }\n}\n\nfunction importedBy(entries: Set<string>): string[] {\n const files = new Set<string>();\n const pending = [...entries].flatMap((entry) => [...(shared.graph.get(entry) ?? [])]);\n for (let file = pending.pop(); file !== undefined; file = pending.pop()) {\n if (files.has(file)) continue;\n files.add(file);\n pending.push(...(shared.graph.get(file) ?? []));\n }\n return [...files].filter((file) => !entries.has(file));\n}\n\n/**\n * Imports of schema files in which a file imported by several of them, and by the same one again, is\n * evaluated once: the versions are taken at the first import of a file and kept for the ones after it\n */\nexport function createSchemaImports(): SchemaImports {\n const hooks = hookImports();\n // Not kept from an earlier set of imports: a file is read as it is now, and one version of it serves them all\n shared.versions.clear();\n shared.hashes.clear();\n const modules = new Map<string, Promise<Record<string, unknown>>>();\n return {\n import(schemaPath) {\n const file = realFile(schemaPath);\n const known = modules.get(file);\n if (known) return known;\n const url = new URL(pathToFileURL(file).href);\n url.searchParams.set(VERSION_PARAM, hooks ? versionOf(file).version : `${Date.now()}`);\n if (hooks) startEvaluation(file, url.href);\n const loaded = import(url.href) as Promise<Record<string, unknown>>;\n // Not by the file that failed: a missing file added later does not change the version of the one importing it\n loaded.catch(() => {\n shared.salt = `${Date.now()}-${++counter}`;\n });\n modules.set(file, loaded);\n return loaded;\n },\n dependencies: (schemaPath) =>\n new Map(\n importedBy(new Set(schemaPath ? [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EACL,OAAO,YAAY;GACjB,MAAM,OAAO,SAAS,UAAU;GAChC,MAAM,QAAQ,QAAQ,IAAI,IAAI;GAC9B,IAAI,OAAO,OAAO;GAClB,MAAM,MAAM,IAAI,IAAI,cAAc,IAAI,CAAC,CAAC,IAAI;GAC5C,IAAI,aAAa,IAAI,eAAe,QAAQ,UAAU,IAAI,CAAC,CAAC,UAAU,GAAG,KAAK,IAAI,GAAG;GACrF,IAAI,OAAO,gBAAgB,MAAM,IAAI,IAAI;GACzC,MAAM,SAAS,OAAO,IAAI;GAE1B,OAAO,YAAY;IACjB,OAAO,OAAO,GAAG,KAAK,IAAI,EAAE,GAAG,EAAE;GACnC,CAAC;GACD,QAAQ,IAAI,MAAM,MAAM;GACxB,OAAO;EACT;EACA,eAAe,eACb,IAAI,IACF,WAAW,IAAI,IAAI,aAAa,CAAC,SAAS,UAAU,CAAC,IAAI,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CACtF,MACA,OAAO,OAAO,IAAI,IAAI,KAAK,WAAW,IAAI,CAC5C,CAAC,CACH;CACJ;AACF"}
|
|
@@ -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,19 @@ declare class JsonlReader {
|
|
|
181
185
|
static inferSchema(tableName: string, data: JsonObject[]): Result<TableSchema, Error>;
|
|
182
186
|
private static inferType;
|
|
183
187
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
188
|
+
interface SchemaImports {
|
|
189
|
+
/** The module a schema file exports, with the project files it imports as they are now */
|
|
190
|
+
import(schemaPath: string): Promise<Record<string, unknown>>;
|
|
191
|
+
/**
|
|
192
|
+
* The project files a schema file imports, with what each held when it was read; not the schema files
|
|
193
|
+
* themselves. Of the schema files imported so far when none is given
|
|
194
|
+
*/
|
|
195
|
+
dependencies(schemaPath?: string): Map<string, string>;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Imports of schema files in which a file imported by several of them, and by the same one again, is
|
|
199
|
+
* evaluated once: the versions are taken at the first import of a file and kept for the ones after it
|
|
200
|
+
*/
|
|
201
|
+
declare function createSchemaImports(): SchemaImports;
|
|
202
|
+
export { ValidationErrorDetail as A, StandardSchemaResult as C, TableSchema as D, TableDefs as E, WhereCondition as M, WriteFilledValues as N, TableValidationResult as O, StandardSchemaIssue as S, TableConfig as T, JsonObject as _, hashJsonlContent as a, JsonlParseError as b, ok as c, DatabaseConfig as d, ForeignKeyDefinition as f, JsonArray as g, InferOutput as h, JsonlSnapshot as i, ValidationResult as j, ValidationError as k, unwrap as l, InferInput as m, createSchemaImports as n, Result as o, IndexDefinition as p, JsonlReader as r, err as s, SchemaImports as t, ColumnDefinition as u, JsonValue as v, Table as w, StandardSchema as x, JsonlConflictError as y };
|
|
203
|
+
//# sourceMappingURL=schema-module-Tb40gPyF.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-module-Tb40gPyF.d.mts","names":[],"sources":["../src/types.ts","../src/result.ts","../src/jsonl-reader.ts","../src/schema-module.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,cAA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AY,mBAAmB,MAAM,eAAe,OAAO,aAAa;iBAsEhE;;UCtKA;;EAEf,OAAO,qBAAqB,QAAQ;;;;;EAKpC,aAAa,sBAAsB;;;;;;iBAuMrB,uBAAuB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lines-db",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.1",
|
|
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",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"homepage": "https://github.com/toiroakr/lines-db#readme",
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@loculus/rolldown": "^0.3.1",
|
|
46
|
-
"@types/node": "^
|
|
46
|
+
"@types/node": "^26.6.6",
|
|
47
47
|
"publint": "^0.3.25",
|
|
48
|
-
"tsdown": "^0.23.
|
|
48
|
+
"tsdown": "^0.23.5",
|
|
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.1.0"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"typescript": ">=5 <7 || >=7.1.0-0"
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@politty/loculus": "^0.
|
|
63
|
+
"@politty/loculus": "^0.4.2",
|
|
64
64
|
"@standard-schema/spec": "^1.1.0",
|
|
65
|
-
"amaro": "^1.
|
|
65
|
+
"amaro": "^1.3.0",
|
|
66
66
|
"loculus": "^0.4.1",
|
|
67
67
|
"zod": "^4.6.7"
|
|
68
68
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl-reader-CoYEJ9pg.d.mts","names":[],"sources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