lines-db 0.15.0 → 0.18.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/bin/cli.mjs CHANGED
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire, register } from "node:module";
3
- import { access, chmod, link, mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
3
+ import { access, chmod, link, mkdir, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
4
4
  import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve } from "node:path";
5
5
  import { createHash, randomBytes } from "node:crypto";
6
6
  import { pathToFileURL } from "node:url";
7
7
  import { styleText } from "node:util";
8
- import { z } from "zod";
9
- import { arg, defineCommand, runMain } from "@politty/zod";
8
+ import * as l from "loculus";
9
+ import { arg, defineCommand, runMain } from "@politty/loculus";
10
10
  import { runInNewContext } from "node:vm";
11
11
  import { spawn } from "node:child_process";
12
+ import { z } from "zod";
12
13
  //#region \0rolldown/runtime.js
13
14
  var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
14
15
  //#endregion
@@ -2721,20 +2722,36 @@ async function fillFields(options) {
2721
2722
  }
2722
2723
  async function fillFieldsInternal(options) {
2723
2724
  if (options.fields && options.fields.length === 0) throw new Error("No fields to fill. Name at least one field.");
2724
- const { dataDir, tableNames } = await resolveTables(options.path);
2725
- const schemaDir = options.schemaDir ?? dataDir;
2725
+ const paths = typeof options.path === "string" ? [options.path] : options.path;
2726
+ if (paths.length === 0) throw new Error("No paths to fill. Name at least one path.");
2727
+ const sources = /* @__PURE__ */ new Map();
2728
+ for (const path of paths) {
2729
+ const { dataDir, tableNames } = await resolveTables(path);
2730
+ for (const table of tableNames) {
2731
+ const file = join(dataDir, `${table}.jsonl`);
2732
+ const key = await realpath(file);
2733
+ if (!sources.has(key)) sources.set(key, {
2734
+ table,
2735
+ file,
2736
+ target: key,
2737
+ schemaDir: options.schemaDir ?? dataDir
2738
+ });
2739
+ }
2740
+ }
2726
2741
  const loadFiller = options.loadFiller ?? fillerFromValidationSchema;
2727
2742
  const tablesWithoutSchema = [];
2728
2743
  const tables = [];
2729
- for (const table of tableNames) {
2744
+ for (const { table, file, target, schemaDir } of sources.values()) {
2730
2745
  const schemaPath = await findSchemaFile(schemaDir, table);
2731
2746
  if (!schemaPath) {
2732
- tablesWithoutSchema.push(table);
2747
+ if (!tablesWithoutSchema.includes(table)) tablesWithoutSchema.push(table);
2733
2748
  continue;
2734
2749
  }
2735
2750
  const schemaModule = await import(`${pathToFileURL(schemaPath).href}?t=${Date.now()}`);
2736
2751
  tables.push({
2737
2752
  table,
2753
+ file,
2754
+ target,
2738
2755
  fields: options.fields ?? [primaryKeyOf(schemaModule)],
2739
2756
  fill: loadFiller(schemaModule, {
2740
2757
  tableName: table,
@@ -2746,9 +2763,8 @@ async function fillFieldsInternal(options) {
2746
2763
  const unreadableLines = [];
2747
2764
  const filled = [];
2748
2765
  const writes = [];
2749
- for (const { table, fields, fill } of tables) {
2750
- const file = join(dataDir, `${table}.jsonl`);
2751
- const read = await readFile(file, "utf-8");
2766
+ for (const { table, file, target, fields, fill } of tables) {
2767
+ const read = await readFile(target, "utf-8");
2752
2768
  const bom = read.startsWith("") ? "" : "";
2753
2769
  const lines = splitLines(read.slice(bom.length));
2754
2770
  const written = /* @__PURE__ */ new Set();
@@ -2780,6 +2796,7 @@ async function fillFieldsInternal(options) {
2780
2796
  if (count === 0) continue;
2781
2797
  writes.push({
2782
2798
  file,
2799
+ target,
2783
2800
  read,
2784
2801
  content: bom + lines.map((line) => `${line.text}${line.eol}`).join("")
2785
2802
  });
@@ -2790,7 +2807,7 @@ async function fillFieldsInternal(options) {
2790
2807
  count
2791
2808
  });
2792
2809
  }
2793
- for (const { file, read } of writes) if (await readFile(file, "utf-8") !== read) {
2810
+ for (const { file, target, read } of writes) if (await readFile(target, "utf-8") !== read) {
2794
2811
  const error = /* @__PURE__ */ new Error(`JSONL file '${file}' was changed after it was read, so no file was filled. Run the fill again.`);
2795
2812
  error.name = "JsonlConflictError";
2796
2813
  error.file = file;
@@ -2802,7 +2819,7 @@ async function fillFieldsInternal(options) {
2802
2819
  filled,
2803
2820
  tablesWithoutSchema,
2804
2821
  unreadableLines,
2805
- unproducedFields: tableNames.length > 0 ? named.filter((field) => !produced.has(field)) : []
2822
+ unproducedFields: sources.size > 0 ? named.filter((field) => !produced.has(field)) : []
2806
2823
  };
2807
2824
  }
2808
2825
  /**
@@ -2812,21 +2829,21 @@ async function fillFieldsInternal(options) {
2812
2829
  async function replaceAll(writes) {
2813
2830
  const staged = writes.map((write) => ({
2814
2831
  ...write,
2815
- temporary: `${write.file}.${randomBytes(6).toString("hex")}.tmp`
2832
+ temporary: `${write.target}.${randomBytes(6).toString("hex")}.tmp`
2816
2833
  }));
2817
2834
  const replaced = [];
2818
2835
  try {
2819
- for (const { file, temporary, content } of staged) {
2836
+ for (const { target, temporary, content } of staged) {
2820
2837
  await writeFile(temporary, content, "utf-8");
2821
- await chmod(temporary, (await stat(file)).mode & 4095);
2838
+ await chmod(temporary, (await stat(target)).mode & 4095);
2822
2839
  }
2823
2840
  for (const write of staged) {
2824
- await rename(write.temporary, write.file);
2841
+ await rename(write.temporary, write.target);
2825
2842
  replaced.push(write);
2826
2843
  }
2827
2844
  } catch (error) {
2828
2845
  const notRestored = [];
2829
- for (const { file, read } of replaced) await writeFile(file, read, "utf-8").catch(() => notRestored.push(file));
2846
+ for (const { file, target, read } of replaced) await writeFile(target, read, "utf-8").catch(() => notRestored.push(file));
2830
2847
  await Promise.all(staged.map(({ temporary }) => rm(temporary, { force: true })));
2831
2848
  if (notRestored.length === 0) throw error;
2832
2849
  throw new Error(`${toError(error).message}\nThese files could not be put back and stay filled: ${notRestored.join(", ")}`, { cause: error });
@@ -2903,7 +2920,218 @@ function serializeRow(row, fieldOrder) {
2903
2920
  return JSON.stringify(out);
2904
2921
  }
2905
2922
  //#endregion
2923
+ //#region src/dataset-config.ts
2924
+ const directories = z.array(z.string().min(1)).min(1);
2925
+ const datasetConfigSchema = z.strictObject({
2926
+ schemaDir: z.string().min(1),
2927
+ base: directories,
2928
+ datasets: z.record(z.string().min(1), directories)
2929
+ });
2930
+ async function resolveValidationTarget(options) {
2931
+ if (options.dataset !== void 0 && options.allDatasets) throw new Error("Use either --dataset or --all-datasets, not both.");
2932
+ if (options.path !== void 0) {
2933
+ if (options.config !== void 0 || options.dataset !== void 0 || options.allDatasets) throw new Error("A file or directory path cannot be combined with dataset configuration options.");
2934
+ const stats = await stat(options.path);
2935
+ if (stats.isDirectory()) return { dataDir: options.path };
2936
+ if (stats.isFile() && options.path.endsWith(".jsonl")) return {
2937
+ dataDir: dirname(options.path),
2938
+ tableName: basename(options.path, ".jsonl")
2939
+ };
2940
+ throw new Error(`Invalid path: ${options.path}. Must be a directory or .jsonl file.`);
2941
+ }
2942
+ return loadDatasetConfig(options.config, { datasets: options.allDatasets ? "all" : options.dataset });
2943
+ }
2944
+ async function loadDatasetConfig(path = "lines-db.config.json", options = {}) {
2945
+ const configPath = resolve(path);
2946
+ let config;
2947
+ try {
2948
+ config = datasetConfigSchema.parse(JSON.parse(await readFile(configPath, "utf-8")));
2949
+ } catch (error) {
2950
+ throw new Error(`Failed to load dataset configuration ${configPath}: ${error instanceof Error ? error.message : String(error)}`);
2951
+ }
2952
+ const selected = (options.datasets === "all" ? Object.keys(config.datasets) : options.datasets ?? []).flatMap((name) => {
2953
+ if (!Object.hasOwn(config.datasets, name)) throw new Error(`Unknown dataset '${name}'. Available datasets: ${Object.keys(config.datasets).join(", ") || "(none)"}`);
2954
+ return config.datasets[name];
2955
+ });
2956
+ const configDir = dirname(configPath);
2957
+ const schemaDir = resolve(configDir, config.schemaDir);
2958
+ try {
2959
+ if (!(await stat(schemaDir)).isDirectory()) throw new Error("Expected a directory");
2960
+ } catch (error) {
2961
+ throw new Error(`Invalid schemaDir ${schemaDir}: ${error instanceof Error ? error.message : String(error)}`);
2962
+ }
2963
+ const dataDirs = await Promise.all([...config.base, ...selected].map((dir) => realpath(resolve(configDir, dir))));
2964
+ return {
2965
+ dataDir: [...new Set(dataDirs)],
2966
+ schemaDir
2967
+ };
2968
+ }
2969
+ //#endregion
2906
2970
  //#region src/cli.ts
2971
+ const __loculus_0 = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;
2972
+ function __loculus_15(message, code) {
2973
+ return { issues: [{
2974
+ message,
2975
+ code
2976
+ }] };
2977
+ }
2978
+ function __loculus_5(value) {
2979
+ if (typeof value !== "string") return __loculus_15("Expected a string", "invalid_type");
2980
+ return { value };
2981
+ }
2982
+ function __loculus_7(value) {
2983
+ if (value === void 0) return { value: void 0 };
2984
+ if (typeof value !== "string") return { issues: [{
2985
+ message: "Expected a string",
2986
+ code: "invalid_type"
2987
+ }] };
2988
+ return { value };
2989
+ }
2990
+ function __loculus_9(value) {
2991
+ if (value === void 0) return { value: false };
2992
+ if (value === true || value === "true" || value === "1") return { value: true };
2993
+ if (value === false || value === "false" || value === "0") return { value: false };
2994
+ return { issues: [{
2995
+ message: "Expected true, false, 1 or 0",
2996
+ code: "invalid_type"
2997
+ }] };
2998
+ }
2999
+ function __loculus_13(value) {
3000
+ if (value === void 0) return { value: 4848 };
3001
+ if (typeof value !== "number") {
3002
+ if (typeof value !== "string" || !__loculus_0.test(value)) return { issues: [{
3003
+ message: "Expected a decimal number",
3004
+ code: "invalid_type"
3005
+ }] };
3006
+ value = Number(value);
3007
+ }
3008
+ if (!Number.isFinite(value)) return { issues: [{
3009
+ message: "Expected a finite number",
3010
+ code: "invalid_value"
3011
+ }] };
3012
+ if (!Number.isSafeInteger(value)) return { issues: [{
3013
+ message: "Expected a safe integer",
3014
+ code: "invalid_value"
3015
+ }] };
3016
+ if (!(value >= 0)) return { issues: [{
3017
+ message: "Expected at least 0",
3018
+ code: "invalid_value"
3019
+ }] };
3020
+ if (!(value <= 65535)) return { issues: [{
3021
+ message: "Expected at most 65535",
3022
+ code: "invalid_value"
3023
+ }] };
3024
+ return { value };
3025
+ }
3026
+ /* @__NO_SIDE_EFFECTS__ */
3027
+ function __loculus_6() {
3028
+ return {
3029
+ meta: {
3030
+ kind: "string",
3031
+ description: void 0
3032
+ },
3033
+ "~standard": {
3034
+ version: 1,
3035
+ vendor: "loculus",
3036
+ validate: __loculus_5
3037
+ },
3038
+ field: true
3039
+ };
3040
+ }
3041
+ /* @__NO_SIDE_EFFECTS__ */
3042
+ function __loculus_8() {
3043
+ return {
3044
+ meta: {
3045
+ kind: "string",
3046
+ description: void 0,
3047
+ optional: true,
3048
+ nullable: false
3049
+ },
3050
+ "~standard": {
3051
+ version: 1,
3052
+ vendor: "loculus",
3053
+ validate: __loculus_7
3054
+ },
3055
+ field: true
3056
+ };
3057
+ }
3058
+ /* @__NO_SIDE_EFFECTS__ */
3059
+ function __loculus_10() {
3060
+ return {
3061
+ meta: {
3062
+ kind: "boolean",
3063
+ description: void 0,
3064
+ optional: true,
3065
+ nullable: false,
3066
+ defaultValue: false
3067
+ },
3068
+ "~standard": {
3069
+ version: 1,
3070
+ vendor: "loculus",
3071
+ validate: __loculus_9
3072
+ },
3073
+ field: true
3074
+ };
3075
+ }
3076
+ /* @__NO_SIDE_EFFECTS__ */
3077
+ function __loculus_14() {
3078
+ return {
3079
+ meta: {
3080
+ kind: "number",
3081
+ description: void 0,
3082
+ optional: true,
3083
+ nullable: false,
3084
+ defaultValue: 4848
3085
+ },
3086
+ "~standard": {
3087
+ version: 1,
3088
+ vendor: "loculus",
3089
+ validate: __loculus_13
3090
+ },
3091
+ field: true
3092
+ };
3093
+ }
3094
+ function __loculus_12(value) {
3095
+ if (!Array.isArray(value)) return { issues: [{
3096
+ message: "Expected an array",
3097
+ code: "invalid_type"
3098
+ }] };
3099
+ const inputs = Array.isArray(value) ? value : [value];
3100
+ const output = [];
3101
+ let issues;
3102
+ for (let i = 0; i < inputs.length; i++) {
3103
+ const result = __loculus_5(inputs[i]);
3104
+ if (result.issues) for (const issue of result.issues) (issues ??= []).push({
3105
+ ...issue,
3106
+ path: issue.path ? [i, ...issue.path] : [i]
3107
+ });
3108
+ else output.push(result.value);
3109
+ }
3110
+ if (issues) return { issues };
3111
+ if (inputs.length < 1) return { issues: [{
3112
+ message: "Expected at least 1 items",
3113
+ code: "invalid_value"
3114
+ }] };
3115
+ return { value: output };
3116
+ }
3117
+ /* @__NO_SIDE_EFFECTS__ */
3118
+ function __loculus_11(inner) {
3119
+ return {
3120
+ meta: {
3121
+ kind: "array",
3122
+ inner,
3123
+ enumValues: inner.meta.enumValues,
3124
+ ...inner.meta.literalValues ? { literalValues: inner.meta.literalValues } : {},
3125
+ description: void 0
3126
+ },
3127
+ "~standard": {
3128
+ version: 1,
3129
+ vendor: "loculus",
3130
+ validate: __loculus_12
3131
+ },
3132
+ field: true
3133
+ };
3134
+ }
2907
3135
  register("amaro/transform", import.meta.url);
2908
3136
  const originalEmitWarning = process.emitWarning;
2909
3137
  process.emitWarning = (warning, ...args) => {
@@ -2936,12 +3164,12 @@ function runInSandbox(expression, context = {}) {
2936
3164
  const generateCommand = defineCommand({
2937
3165
  name: "generate",
2938
3166
  description: "Generate TypeScript type definitions from schema files",
2939
- args: z.object({
2940
- dataDir: arg(z.string(), {
3167
+ args: l.object({
3168
+ dataDir: arg(/* @__PURE__ */ __loculus_6(), {
2941
3169
  positional: true,
2942
3170
  description: "Directory containing JSONL and schema files"
2943
3171
  }),
2944
- output: arg(z.string().optional(), {
3172
+ output: arg(/* @__PURE__ */ __loculus_8(), {
2945
3173
  alias: "o",
2946
3174
  description: "Output file path (default: db.ts in dataDir)"
2947
3175
  })
@@ -2962,27 +3190,23 @@ const generateCommand = defineCommand({
2962
3190
  const validateCommand = defineCommand({
2963
3191
  name: "validate",
2964
3192
  description: "Validate JSONL file(s) against schema",
2965
- args: z.object({
2966
- path: arg(z.string(), {
3193
+ args: l.object({
3194
+ path: arg(/* @__PURE__ */ __loculus_8(), {
2967
3195
  positional: true,
2968
- description: "File or directory path to validate"
3196
+ description: "File or directory path to validate (omit to use lines-db.config.json)"
2969
3197
  }),
2970
- verbose: arg(z.boolean().default(false), {
3198
+ config: arg(/* @__PURE__ */ __loculus_8(), { description: "Dataset configuration file (default: ./lines-db.config.json)" }),
3199
+ dataset: arg(l.array(/* @__PURE__ */ __loculus_6(), { optional: true }), { description: "Named datasets to validate together with base (repeat to select several)" }),
3200
+ allDatasets: arg(/* @__PURE__ */ __loculus_10(), { description: "Validate base and all datasets together" }),
3201
+ verbose: arg(/* @__PURE__ */ __loculus_10(), {
2971
3202
  alias: "v",
2972
3203
  description: "Show verbose error output"
2973
3204
  })
2974
3205
  }),
2975
3206
  run: async (args) => {
2976
3207
  try {
2977
- const stats = await stat(args.path);
2978
- let dataDir;
2979
- let tableName;
2980
- if (stats.isDirectory()) dataDir = args.path;
2981
- else if (stats.isFile() && args.path.endsWith(".jsonl")) {
2982
- dataDir = dirname(args.path);
2983
- tableName = basename(args.path, ".jsonl");
2984
- } else throw new Error(`Invalid path: ${args.path}. Must be a directory or .jsonl file.`);
2985
- const db = LinesDB.create({ dataDir });
3208
+ const { tableName, ...config } = await resolveValidationTarget(args);
3209
+ const db = LinesDB.create(config);
2986
3210
  let result;
2987
3211
  try {
2988
3212
  result = unwrap(await db.initialize({
@@ -3069,25 +3293,25 @@ const validateCommand = defineCommand({
3069
3293
  const migrateCommand = defineCommand({
3070
3294
  name: "migrate",
3071
3295
  description: "Migrate data with transformation function",
3072
- args: z.object({
3073
- path: arg(z.string(), {
3296
+ args: l.object({
3297
+ path: arg(/* @__PURE__ */ __loculus_6(), {
3074
3298
  positional: true,
3075
3299
  description: "File or directory path to migrate"
3076
3300
  }),
3077
- transform: arg(z.string(), {
3301
+ transform: arg(/* @__PURE__ */ __loculus_6(), {
3078
3302
  positional: true,
3079
3303
  description: "Transform function (e.g., \"(row) => ({ ...row, age: row.age + 1 })\")"
3080
3304
  }),
3081
- filter: arg(z.string().optional(), {
3305
+ filter: arg(/* @__PURE__ */ __loculus_8(), {
3082
3306
  alias: "f",
3083
3307
  description: "Filter expression"
3084
3308
  }),
3085
- fields: arg(z.string().optional(), { description: "Comma-separated fields to write back (e.g. \"id\"). Every other field keeps the value the JSONL file already had. Default: write every field" }),
3086
- errorOutput: arg(z.string().optional(), {
3309
+ fields: arg(/* @__PURE__ */ __loculus_8(), { description: "Comma-separated fields to write back (e.g. \"id\"). Every other field keeps the value the JSONL file already had. Default: write every field" }),
3310
+ errorOutput: arg(/* @__PURE__ */ __loculus_8(), {
3087
3311
  alias: "e",
3088
3312
  description: "Output file path for transformed data when migration fails"
3089
3313
  }),
3090
- verbose: arg(z.boolean().default(false), {
3314
+ verbose: arg(/* @__PURE__ */ __loculus_10(), {
3091
3315
  alias: "v",
3092
3316
  description: "Show verbose error output"
3093
3317
  })
@@ -3122,12 +3346,13 @@ const migrateCommand = defineCommand({
3122
3346
  const fillCommand = defineCommand({
3123
3347
  name: "fill",
3124
3348
  description: "Fill the values each table computes into the JSONL rows that have none for the named fields",
3125
- args: z.object({
3126
- path: arg(z.string(), {
3349
+ args: l.object({
3350
+ path: arg(/* @__PURE__ */ __loculus_11(/* @__PURE__ */ __loculus_6()), {
3127
3351
  positional: true,
3128
- description: "Data directory, or one .jsonl file in it"
3352
+ description: "One or more data directories or .jsonl files"
3129
3353
  }),
3130
- fields: arg(z.string().optional(), {
3354
+ schemaDir: arg(/* @__PURE__ */ __loculus_8(), { description: "Directory holding shared schemas (default: next to each JSONL file)" }),
3355
+ fields: arg(/* @__PURE__ */ __loculus_8(), {
3131
3356
  alias: "f",
3132
3357
  description: "Comma-separated fields to fill (default: each table's primary key)"
3133
3358
  })
@@ -3136,6 +3361,7 @@ const fillCommand = defineCommand({
3136
3361
  const fields = args.fields?.split(",").map((field) => field.trim()).filter(Boolean);
3137
3362
  const result = await fillFields({
3138
3363
  path: args.path,
3364
+ schemaDir: args.schemaDir,
3139
3365
  fields
3140
3366
  });
3141
3367
  if (!result.ok) {
@@ -3162,19 +3388,19 @@ let studio;
3162
3388
  const studioCommand = defineCommand({
3163
3389
  name: "studio",
3164
3390
  description: "Browse and edit the tables of a data directory in the browser",
3165
- args: z.object({
3166
- path: arg(z.string().optional(), {
3391
+ args: l.object({
3392
+ path: arg(/* @__PURE__ */ __loculus_8(), {
3167
3393
  positional: true,
3168
3394
  description: "Directory containing JSONL files"
3169
3395
  }),
3170
- dataDir: arg(z.array(z.string()).default([]), { description: "Directory containing JSONL files (repeatable)" }),
3171
- schemaDir: arg(z.string().optional(), { description: "Directory containing shared schema files (required for several data directories)" }),
3172
- port: arg(z.coerce.number().int().min(0).max(65535).default(4848), {
3396
+ dataDir: arg(l.array(/* @__PURE__ */ __loculus_6(), { default: [] }), { description: "Directory containing JSONL files (repeatable)" }),
3397
+ schemaDir: arg(/* @__PURE__ */ __loculus_8(), { description: "Directory containing shared schema files (required for several data directories)" }),
3398
+ port: arg(/* @__PURE__ */ __loculus_14(), {
3173
3399
  alias: "p",
3174
3400
  description: "Port to listen on (0 picks a free one)"
3175
3401
  }),
3176
- open: arg(z.boolean().default(false), { description: "Open the studio in the default browser" }),
3177
- writeFilledValues: arg(z.enum(["all", "primaryKey"]).default("primaryKey"), { description: "Values the schema fills in that a save writes: all of them, or only a generated primary key" })
3402
+ open: arg(/* @__PURE__ */ __loculus_10(), { description: "Open the studio in the default browser" }),
3403
+ writeFilledValues: arg(l.enum(["all", "primaryKey"], { default: "primaryKey" }), { description: "Values the schema fills in that a save writes: all of them, or only a generated primary key" })
3178
3404
  }),
3179
3405
  run: async (args) => {
3180
3406
  try {
package/dist/index.d.mts CHANGED
@@ -571,11 +571,11 @@ export declare function mergeFields(line: JsonObject, computed: Record<string, J
571
571
  /** Computes the values a row gets, from the row as its line holds it */
572
572
  type RowFiller = (row: JsonObject) => Record<string, unknown>;
573
573
  interface FillFieldsOptions {
574
- /** A data directory, or one `.jsonl` file in it */
575
- path: string;
574
+ /** One or more data directories or `.jsonl` files */
575
+ path: string | readonly string[];
576
576
  /** Fields to fill. Defaults to each table's primary key: `primaryKey` in its schema file, or `id` */
577
577
  fields?: readonly string[];
578
- /** Directory the `<Table>.schema.{ts,mts,cts}` files are looked up in. Defaults to the data directory */
578
+ /** Directory the `<Table>.schema.{ts,mts,cts}` files are looked up in. Defaults to each file's data directory */
579
579
  schemaDir?: string;
580
580
  /**
581
581
  * Builds the function that computes a table's row values from its schema module. Defaults to the
@@ -870,5 +870,11 @@ type RuntimeEnvironment = 'node' | 'unknown';
870
870
  export declare function detectRuntime(): RuntimeEnvironment;
871
871
  export declare const RUNTIME: RuntimeEnvironment;
872
872
  //#endregion
873
- export { type BiDirectionalSchema, type ColumnDefinition, type DatabaseConfig, type ErrorFormatterOptions, type FillFieldsOptions, type FillFieldsResult, type FilledFile, type ForeignKeyDefinition, type ForeignKeyErrorInfo, type IndexDefinition, type InferInput, type InferOutput, type JsonArray, type JsonObject, type JsonValue, type JsonlConflictError, type JsonlParseError, JsonlReader, type JsonlSnapshot, type MergeFieldsOptions, type Result, type RowFiller, type RuntimeEnvironment, type SQLiteDatabase, type SQLiteStatement, type SchemaExtension, type SchemaOptions, type StandardSchema, type StandardSchemaIssue, type StandardSchemaResult, type SyncOptions, type Table, type TableConfig, type TableDefs, type TableSchema, type TableValidationOptions, type TableValidationResult, type TypeGeneratorOptions, type UpdateOptions, type ValidationError, type ValidationErrorDetail, type ValidationErrorInfo, type ValidationResult, type WriteFilledValues, err, ok, unwrap };
873
+ //#region src/dataset-config.d.ts
874
+ interface DatasetConfigOptions {
875
+ datasets?: string[] | 'all';
876
+ }
877
+ export declare function loadDatasetConfig(path?: string, options?: DatasetConfigOptions): Promise<DatabaseConfig>;
878
+ //#endregion
879
+ export { type BiDirectionalSchema, type ColumnDefinition, type DatabaseConfig, type DatasetConfigOptions, type ErrorFormatterOptions, type FillFieldsOptions, type FillFieldsResult, type FilledFile, type ForeignKeyDefinition, type ForeignKeyErrorInfo, type IndexDefinition, type InferInput, type InferOutput, type JsonArray, type JsonObject, type JsonValue, type JsonlConflictError, type JsonlParseError, JsonlReader, type JsonlSnapshot, type MergeFieldsOptions, type Result, type RowFiller, type RuntimeEnvironment, type SQLiteDatabase, type SQLiteStatement, type SchemaExtension, type SchemaOptions, type StandardSchema, type StandardSchemaIssue, type StandardSchemaResult, type SyncOptions, type Table, type TableConfig, type TableDefs, type TableSchema, type TableValidationOptions, type TableValidationResult, type TypeGeneratorOptions, type UpdateOptions, type ValidationError, type ValidationErrorDetail, type ValidationErrorInfo, type ValidationResult, type WriteFilledValues, err, ok, unwrap };
874
880
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/sqlite-adapter.ts","../src/database.ts","../src/jsonl-writer.ts","../src/merge-fields.ts","../src/fill.ts","../src/schema-loader.ts","../src/directory-scanner.ts","../src/schema.ts","../src/type-generator.ts","../src/jsonl-migration.ts","../src/schema-extensions.ts","../src/error-formatter.ts","../src/runtime.ts"],"mappings":";;;;;;;;UASiB;EACf,QAAQ,cAAc;EACtB,KAAK;EACL;;UAGe;EACf,OAAO;IAAkB;IAAiB;;EAC1C,OAAO;EACP,OAAO;;;;;;;UCkBQ;;EAEf;;;;;EAKA;;;;;UAMe;;;;;;;;;EASf;;;;;EAKA,oBAAoB;;qBAmET,QAAQ,eAAe;UAC1B;mBACS;UACT;UACA;UACA;UACA;UACA;UACA;;UAEA;;UAEA;;;;;UAKA;;;;;UAKA;;UAEA;;;;;UAKA;;UAEA;;UAEA;;UAEA;;UAEA;;UAEA;;UAEA;;;;;UAKA;;UAEA;;UAEA;UAED;SAKA,OAAO,eAAe,WAAW,QAAQ,eAAe,SAAS,kBAAkB,QAAQ;;;;;;;;;;EAa5F,WAAW;IACf;IACA;IACA,aAAa,KAAK,eAAe;MAC/B,QAAQ,OAAO,kBAAkB;UAQvB;UAsBA;;;;UAyGA;;;;UA8KA;;;;;UAQA;;;;UAgRN;;;;UAsFA;;;;UAOA;;;;;;UASA;;;;;UAmCA;;;;UA4CA;;;;;UA+DA;;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AuB,QAAQ;;;;EAU/B,sBAAsB,OAAO;;;;UAUrB;;;;UAiBA;;;;UAqCA;;;;UAOA;;;;UAoBA;;;;EAkBR,kBAAkB,eAAe;;;;EAQjC;;;;;;;KC9JU;wBAEI,iBAAiB;qBASpB,SAAO"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/sqlite-adapter.ts","../src/database.ts","../src/jsonl-writer.ts","../src/merge-fields.ts","../src/fill.ts","../src/schema-loader.ts","../src/directory-scanner.ts","../src/schema.ts","../src/type-generator.ts","../src/jsonl-migration.ts","../src/schema-extensions.ts","../src/error-formatter.ts","../src/runtime.ts","../src/dataset-config.ts"],"mappings":";;;;;;;;UASiB;EACf,QAAQ,cAAc;EACtB,KAAK;EACL;;UAGe;EACf,OAAO;IAAkB;IAAiB;;EAC1C,OAAO;EACP,OAAO;;;;;;;UCkBQ;;EAEf;;;;;EAKA;;;;;UAMe;;;;;;;;;EASf;;;;;EAKA,oBAAoB;;qBAmET,QAAQ,eAAe;UAC1B;mBACS;UACT;UACA;UACA;UACA;UACA;UACA;;UAEA;;UAEA;;;;;UAKA;;;;;UAKA;;UAEA;;;;;UAKA;;UAEA;;UAEA;;UAEA;;UAEA;;UAEA;;UAEA;;;;;UAKA;;UAEA;;UAEA;UAED;SAKA,OAAO,eAAe,WAAW,QAAQ,eAAe,SAAS,kBAAkB,QAAQ;;;;;;;;;;EAa5F,WAAW;IACf;IACA;IACA,aAAa,KAAK,eAAe;MAC/B,QAAQ,OAAO,kBAAkB;UAQvB;UAsBA;;;;UAyGA;;;;UA8KA;;;;;UAQA;;;;UAgRN;;;;UAsFA;;;;UAOA;;;;;;UASA;;;;;UAmCA;;;;UA4CA;;;;;UA+DA;;;;EAyCR,MAAM,aAAa,aAAa,4CAA2C,gBAAqB,OAAO,KAAK;UAUpG;;;;EAQR,SAAS,aACP,aACA,4CAA2C,gBAC1C,OAAO,UAAU;UAYZ;;;;EAYR,QACE,aACA,4CAA2C,gBAC1C;IAAS;IAA0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