lines-db 0.18.0 → 0.18.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 +6 -0
- package/bin/cli.mjs +31 -185
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @toiroakr/lines-db
|
|
2
2
|
|
|
3
|
+
## 0.18.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e06facb: `lines-db validate` now prints a warning on stderr when every table it loaded has zero records (for example when all `.jsonl` files are empty placeholders), so a run that checked nothing no longer looks like a plain success. The exit code stays 0.
|
|
8
|
+
|
|
3
9
|
## 0.18.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/bin/cli.mjs
CHANGED
|
@@ -2968,170 +2968,6 @@ async function loadDatasetConfig(path = "lines-db.config.json", options = {}) {
|
|
|
2968
2968
|
}
|
|
2969
2969
|
//#endregion
|
|
2970
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
|
-
}
|
|
3135
2971
|
register("amaro/transform", import.meta.url);
|
|
3136
2972
|
const originalEmitWarning = process.emitWarning;
|
|
3137
2973
|
process.emitWarning = (warning, ...args) => {
|
|
@@ -3165,11 +3001,11 @@ const generateCommand = defineCommand({
|
|
|
3165
3001
|
name: "generate",
|
|
3166
3002
|
description: "Generate TypeScript type definitions from schema files",
|
|
3167
3003
|
args: l.object({
|
|
3168
|
-
dataDir: arg(
|
|
3004
|
+
dataDir: arg(l.string(), {
|
|
3169
3005
|
positional: true,
|
|
3170
3006
|
description: "Directory containing JSONL and schema files"
|
|
3171
3007
|
}),
|
|
3172
|
-
output: arg(
|
|
3008
|
+
output: arg(l.string({ optional: true }), {
|
|
3173
3009
|
alias: "o",
|
|
3174
3010
|
description: "Output file path (default: db.ts in dataDir)"
|
|
3175
3011
|
})
|
|
@@ -3191,14 +3027,14 @@ const validateCommand = defineCommand({
|
|
|
3191
3027
|
name: "validate",
|
|
3192
3028
|
description: "Validate JSONL file(s) against schema",
|
|
3193
3029
|
args: l.object({
|
|
3194
|
-
path: arg(
|
|
3030
|
+
path: arg(l.string({ optional: true }), {
|
|
3195
3031
|
positional: true,
|
|
3196
3032
|
description: "File or directory path to validate (omit to use lines-db.config.json)"
|
|
3197
3033
|
}),
|
|
3198
|
-
config: arg(
|
|
3199
|
-
dataset: arg(l.array(
|
|
3200
|
-
allDatasets: arg(
|
|
3201
|
-
verbose: arg(
|
|
3034
|
+
config: arg(l.string({ optional: true }), { description: "Dataset configuration file (default: ./lines-db.config.json)" }),
|
|
3035
|
+
dataset: arg(l.array(l.string(), { optional: true }), { description: "Named datasets to validate together with base (repeat to select several)" }),
|
|
3036
|
+
allDatasets: arg(l.boolean({ default: false }), { description: "Validate base and all datasets together" }),
|
|
3037
|
+
verbose: arg(l.boolean({ default: false }), {
|
|
3202
3038
|
alias: "v",
|
|
3203
3039
|
description: "Show verbose error output"
|
|
3204
3040
|
})
|
|
@@ -3216,6 +3052,11 @@ const validateCommand = defineCommand({
|
|
|
3216
3052
|
} finally {
|
|
3217
3053
|
await db.close();
|
|
3218
3054
|
}
|
|
3055
|
+
if (result.tableResults.length > 0 && result.tableResults.every((r) => r.rowCount === 0)) {
|
|
3056
|
+
const dirs = [config.dataDir].flat().join(", ");
|
|
3057
|
+
const message = tableName ? `The selected file ${tableName}.jsonl in ${dirs} is empty (0 records), so none of its records were validated.` : `No records were validated: every JSONL file in ${dirs} is empty (0 records in total).`;
|
|
3058
|
+
console.warn(styleText("yellow", `⚠ ${message}`));
|
|
3059
|
+
}
|
|
3219
3060
|
if (!tableName) {
|
|
3220
3061
|
const formatter = new ErrorFormatter({ verbose: args.verbose });
|
|
3221
3062
|
for (const tableResult of result.tableResults) if (tableResult.valid && tableResult.warnings.length === 0) console.log(styleText("green", `✓ ${tableResult.tableName} (${tableResult.rowCount} records)`));
|
|
@@ -3294,24 +3135,24 @@ const migrateCommand = defineCommand({
|
|
|
3294
3135
|
name: "migrate",
|
|
3295
3136
|
description: "Migrate data with transformation function",
|
|
3296
3137
|
args: l.object({
|
|
3297
|
-
path: arg(
|
|
3138
|
+
path: arg(l.string(), {
|
|
3298
3139
|
positional: true,
|
|
3299
3140
|
description: "File or directory path to migrate"
|
|
3300
3141
|
}),
|
|
3301
|
-
transform: arg(
|
|
3142
|
+
transform: arg(l.string(), {
|
|
3302
3143
|
positional: true,
|
|
3303
3144
|
description: "Transform function (e.g., \"(row) => ({ ...row, age: row.age + 1 })\")"
|
|
3304
3145
|
}),
|
|
3305
|
-
filter: arg(
|
|
3146
|
+
filter: arg(l.string({ optional: true }), {
|
|
3306
3147
|
alias: "f",
|
|
3307
3148
|
description: "Filter expression"
|
|
3308
3149
|
}),
|
|
3309
|
-
fields: arg(
|
|
3310
|
-
errorOutput: arg(
|
|
3150
|
+
fields: arg(l.string({ optional: true }), { 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" }),
|
|
3151
|
+
errorOutput: arg(l.string({ optional: true }), {
|
|
3311
3152
|
alias: "e",
|
|
3312
3153
|
description: "Output file path for transformed data when migration fails"
|
|
3313
3154
|
}),
|
|
3314
|
-
verbose: arg(
|
|
3155
|
+
verbose: arg(l.boolean({ default: false }), {
|
|
3315
3156
|
alias: "v",
|
|
3316
3157
|
description: "Show verbose error output"
|
|
3317
3158
|
})
|
|
@@ -3347,12 +3188,12 @@ const fillCommand = defineCommand({
|
|
|
3347
3188
|
name: "fill",
|
|
3348
3189
|
description: "Fill the values each table computes into the JSONL rows that have none for the named fields",
|
|
3349
3190
|
args: l.object({
|
|
3350
|
-
path: arg(
|
|
3191
|
+
path: arg(l.array(l.string(), { min: 1 }), {
|
|
3351
3192
|
positional: true,
|
|
3352
3193
|
description: "One or more data directories or .jsonl files"
|
|
3353
3194
|
}),
|
|
3354
|
-
schemaDir: arg(
|
|
3355
|
-
fields: arg(
|
|
3195
|
+
schemaDir: arg(l.string({ optional: true }), { description: "Directory holding shared schemas (default: next to each JSONL file)" }),
|
|
3196
|
+
fields: arg(l.string({ optional: true }), {
|
|
3356
3197
|
alias: "f",
|
|
3357
3198
|
description: "Comma-separated fields to fill (default: each table's primary key)"
|
|
3358
3199
|
})
|
|
@@ -3389,17 +3230,22 @@ const studioCommand = defineCommand({
|
|
|
3389
3230
|
name: "studio",
|
|
3390
3231
|
description: "Browse and edit the tables of a data directory in the browser",
|
|
3391
3232
|
args: l.object({
|
|
3392
|
-
path: arg(
|
|
3233
|
+
path: arg(l.string({ optional: true }), {
|
|
3393
3234
|
positional: true,
|
|
3394
3235
|
description: "Directory containing JSONL files"
|
|
3395
3236
|
}),
|
|
3396
|
-
dataDir: arg(l.array(
|
|
3397
|
-
schemaDir: arg(
|
|
3398
|
-
port: arg(
|
|
3237
|
+
dataDir: arg(l.array(l.string(), { default: [] }), { description: "Directory containing JSONL files (repeatable)" }),
|
|
3238
|
+
schemaDir: arg(l.string({ optional: true }), { description: "Directory containing shared schema files (required for several data directories)" }),
|
|
3239
|
+
port: arg(l.number({
|
|
3240
|
+
integer: true,
|
|
3241
|
+
gte: 0,
|
|
3242
|
+
lte: 65535,
|
|
3243
|
+
default: 4848
|
|
3244
|
+
}), {
|
|
3399
3245
|
alias: "p",
|
|
3400
3246
|
description: "Port to listen on (0 picks a free one)"
|
|
3401
3247
|
}),
|
|
3402
|
-
open: arg(
|
|
3248
|
+
open: arg(l.boolean({ default: false }), { description: "Open the studio in the default browser" }),
|
|
3403
3249
|
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" })
|
|
3404
3250
|
}),
|
|
3405
3251
|
run: async (args) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lines-db",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.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",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
},
|
|
43
43
|
"homepage": "https://github.com/toiroakr/lines-db#readme",
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@loculus/rolldown": "^0.
|
|
45
|
+
"@loculus/rolldown": "^0.3.1",
|
|
46
46
|
"@types/node": "^24.19.2",
|
|
47
47
|
"publint": "^0.3.25",
|
|
48
48
|
"tsdown": "^0.23.1",
|
|
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.2.2",
|
|
64
64
|
"@standard-schema/spec": "^1.1.0",
|
|
65
|
-
"amaro": "^1.2.
|
|
66
|
-
"loculus": "^0.
|
|
67
|
-
"zod": "^4.6.
|
|
65
|
+
"amaro": "^1.2.2",
|
|
66
|
+
"loculus": "^0.4.1",
|
|
67
|
+
"zod": "^4.6.7"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build": "tsdown",
|