csvms 0.9.6 ā 0.9.8
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/README.md +143 -0
- package/dist/cli.js +0 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -0
- package/dist/config/index.js.map +1 -1
- package/dist/config/validator.d.ts +21 -0
- package/dist/config/validator.d.ts.map +1 -0
- package/dist/config/validator.js +309 -0
- package/dist/config/validator.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/README.md
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# CSVMS
|
|
2
|
+
|
|
3
|
+
Edit local CSV files with a **CMS-like UI** (list view + detail form).
|
|
4
|
+
|
|
5
|
+
CSV files are normalized on save (column order, newlines, quoting, sorting) to ensure clean and stable Git diffs.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- š„ļø **CMS-like UI** - Edit CSV files with intuitive list and detail form views
|
|
12
|
+
- š **Schema Definition** - Define forms, validation, and normalization rules in YAML/JSON
|
|
13
|
+
- š **Stable Git Diffs** - CSV normalization minimizes unnecessary changes
|
|
14
|
+
- š **Security** - Workspace boundary enforcement, path traversal protection
|
|
15
|
+
- ā” **Easy Start** - Single `npx` command (no clone required)
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Run in the directory containing your CSV files
|
|
21
|
+
npx csvms
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
That's it! A browser will open with the CMS-like UI.
|
|
25
|
+
|
|
26
|
+
## Screenshots
|
|
27
|
+
|
|
28
|
+
### Home Screen
|
|
29
|
+
|
|
30
|
+

|
|
31
|
+
|
|
32
|
+
### Dataset Editor
|
|
33
|
+
|
|
34
|
+
Table/tile view with detail form. Supports drag-and-drop reordering and keyboard navigation.
|
|
35
|
+
|
|
36
|
+

|
|
37
|
+
|
|
38
|
+
### Single Dataset Mode
|
|
39
|
+
|
|
40
|
+
Use `--schema` option for editing a single dataset without a config file.
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npx csvms --schema schemas/product.schema.yaml --allow-write
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
## CLI Options
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
csvms [options]
|
|
52
|
+
|
|
53
|
+
Options:
|
|
54
|
+
--config <path> Config file path (default: search in CWD)
|
|
55
|
+
--port <number> Port number (default: auto)
|
|
56
|
+
--host <host> Bind host (default: 127.0.0.1)
|
|
57
|
+
--no-open Don't open browser automatically
|
|
58
|
+
--read-only Read-only mode
|
|
59
|
+
--allow-write Allow write operations
|
|
60
|
+
--workspace <path> Workspace root path (default: CWD)
|
|
61
|
+
--log-level <level> Log level (debug|info|warn|error)
|
|
62
|
+
--schema <path> Single dataset mode with schema file
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Configuration
|
|
66
|
+
|
|
67
|
+
Create `csvms.config.yaml` in your project root:
|
|
68
|
+
|
|
69
|
+
```yaml
|
|
70
|
+
version: 1
|
|
71
|
+
workspace:
|
|
72
|
+
root: "."
|
|
73
|
+
allowWrite: true
|
|
74
|
+
|
|
75
|
+
datasets:
|
|
76
|
+
- id: "product_master"
|
|
77
|
+
title: "Product Master"
|
|
78
|
+
csvPath: "data/products.csv"
|
|
79
|
+
schemaPath: "schemas/product.schema.yaml"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Schema Definition
|
|
83
|
+
|
|
84
|
+
Example `schemas/product.schema.yaml`:
|
|
85
|
+
|
|
86
|
+
```yaml
|
|
87
|
+
schemaVersion: 1
|
|
88
|
+
id: product_master
|
|
89
|
+
title: Product Master
|
|
90
|
+
|
|
91
|
+
csv:
|
|
92
|
+
delimiter: ","
|
|
93
|
+
header: true
|
|
94
|
+
primaryKey: "product_id"
|
|
95
|
+
normalize:
|
|
96
|
+
quotePolicy: "minimal"
|
|
97
|
+
newline: "lf"
|
|
98
|
+
|
|
99
|
+
columns:
|
|
100
|
+
- key: product_id
|
|
101
|
+
label: Product ID
|
|
102
|
+
type: string
|
|
103
|
+
required: true
|
|
104
|
+
unique: true
|
|
105
|
+
ui: { widget: text, readonlyOnEdit: true }
|
|
106
|
+
|
|
107
|
+
- key: name
|
|
108
|
+
label: Product Name
|
|
109
|
+
type: string
|
|
110
|
+
required: true
|
|
111
|
+
ui: { widget: text }
|
|
112
|
+
|
|
113
|
+
- key: price
|
|
114
|
+
label: Price
|
|
115
|
+
type: integer
|
|
116
|
+
required: true
|
|
117
|
+
min: 0
|
|
118
|
+
ui: { widget: number }
|
|
119
|
+
|
|
120
|
+
ui:
|
|
121
|
+
list:
|
|
122
|
+
columns:
|
|
123
|
+
- { key: product_id, width: 160 }
|
|
124
|
+
- { key: name, width: 280 }
|
|
125
|
+
- { key: price, width: 120, align: right }
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Documentation
|
|
129
|
+
|
|
130
|
+
- [Configuration Guide](https://github.com/foo-ogawa/csvms/blob/main/docs/CONFIGURATION.md) - Full schema and config reference
|
|
131
|
+
- [API Reference](https://github.com/foo-ogawa/csvms/blob/main/docs/API.md) - REST API documentation
|
|
132
|
+
|
|
133
|
+
## Requirements
|
|
134
|
+
|
|
135
|
+
- Node.js >= 20.0.0
|
|
136
|
+
|
|
137
|
+
## License
|
|
138
|
+
|
|
139
|
+
MIT
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
package/dist/cli.js
CHANGED
|
File without changes
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { loadConfig } from './loader.js';
|
|
2
2
|
export type { Config, ServerOptions, ResolvedConfig, DatasetConfig, WorkspaceConfig } from './types.js';
|
|
3
3
|
export { ConfigSchema, DatasetConfigSchema, WorkspaceConfigSchema } from './schema.js';
|
|
4
|
+
export { validateStartupConfig, printValidationResult, type ValidationIssue, type StartupValidationResult, } from './validator.js';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,KAAK,eAAe,EACpB,KAAK,uBAAuB,GAC7B,MAAM,gBAAgB,CAAC"}
|
package/dist/config/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// čØå®ćØćÆć¹ćć¼ć
|
|
2
2
|
export { loadConfig } from './loader.js';
|
|
3
3
|
export { ConfigSchema, DatasetConfigSchema, WorkspaceConfigSchema } from './schema.js';
|
|
4
|
+
export { validateStartupConfig, printValidationResult, } from './validator.js';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
package/dist/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,WAAW;AAEX,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,WAAW;AAEX,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GAGtB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ResolvedConfig } from './types.js';
|
|
2
|
+
export interface ValidationIssue {
|
|
3
|
+
type: 'error' | 'warning';
|
|
4
|
+
dataset?: string;
|
|
5
|
+
file?: string;
|
|
6
|
+
message: string;
|
|
7
|
+
hint?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface StartupValidationResult {
|
|
10
|
+
valid: boolean;
|
|
11
|
+
issues: ValidationIssue[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* čµ·åęć®å
ę¬ēććŖćć¼ć·ć§ć³ćå®č”
|
|
15
|
+
*/
|
|
16
|
+
export declare function validateStartupConfig(config: ResolvedConfig): Promise<StartupValidationResult>;
|
|
17
|
+
/**
|
|
18
|
+
* ććŖćć¼ć·ć§ć³ēµęćć³ć³ć½ć¼ć«ć«åŗå
|
|
19
|
+
*/
|
|
20
|
+
export declare function printValidationResult(result: StartupValidationResult): void;
|
|
21
|
+
//# sourceMappingURL=validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/config/validator.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,YAAY,CAAC;AAGhE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAID;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAoCpG;AAmOD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,uBAAuB,GAAG,IAAI,CA+B3E"}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
// čµ·åęććŖćć¼ć·ć§ć³
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import YAML from 'yaml';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import { SchemaService } from '../services/SchemaService.js';
|
|
7
|
+
import { parseCSVContent } from '../lib/csv/parser.js';
|
|
8
|
+
const schemaService = new SchemaService();
|
|
9
|
+
/**
|
|
10
|
+
* čµ·åęć®å
ę¬ēććŖćć¼ć·ć§ć³ćå®č”
|
|
11
|
+
*/
|
|
12
|
+
export async function validateStartupConfig(config) {
|
|
13
|
+
const issues = [];
|
|
14
|
+
// ćÆć¼ćÆć¹ćć¼ć¹ćć£ć¬ćÆććŖć®ååØē¢ŗčŖ
|
|
15
|
+
const workspaceExists = await checkPathExists(config.workspace.root);
|
|
16
|
+
if (!workspaceExists) {
|
|
17
|
+
issues.push({
|
|
18
|
+
type: 'error',
|
|
19
|
+
message: `Workspace directory not found: ${config.workspace.root}`,
|
|
20
|
+
hint: `Create the directory or update the workspace.root setting in the config file.`,
|
|
21
|
+
});
|
|
22
|
+
// ćÆć¼ćÆć¹ćć¼ć¹ććŖćå “åćä»ć®ćć§ććÆćÆęå³ććŖćć®ć§ę©ęćŖćæć¼ć³
|
|
23
|
+
return { valid: false, issues };
|
|
24
|
+
}
|
|
25
|
+
// åćć¼ćæć»ććć®ććŖćć¼ć·ć§ć³
|
|
26
|
+
for (const dataset of config.datasets) {
|
|
27
|
+
const datasetIssues = await validateDataset(dataset, config.workspace.root);
|
|
28
|
+
issues.push(...datasetIssues);
|
|
29
|
+
}
|
|
30
|
+
// ćć¼ćæć»ććIDéč¤ćć§ććÆ
|
|
31
|
+
const datasetIds = config.datasets.map((d) => d.id);
|
|
32
|
+
const duplicateIds = datasetIds.filter((id, index) => datasetIds.indexOf(id) !== index);
|
|
33
|
+
if (duplicateIds.length > 0) {
|
|
34
|
+
issues.push({
|
|
35
|
+
type: 'error',
|
|
36
|
+
message: `Duplicate dataset IDs found: ${[...new Set(duplicateIds)].join(', ')}`,
|
|
37
|
+
hint: `Each dataset must have a unique ID. Update the duplicate IDs in the config file.`,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
valid: issues.filter((i) => i.type === 'error').length === 0,
|
|
42
|
+
issues,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* åäøćć¼ćæć»ććć®ććŖćć¼ć·ć§ć³
|
|
47
|
+
*/
|
|
48
|
+
async function validateDataset(dataset, workspaceRoot) {
|
|
49
|
+
const issues = [];
|
|
50
|
+
const schemaPath = path.resolve(workspaceRoot, dataset.schemaPath);
|
|
51
|
+
const csvPath = path.resolve(workspaceRoot, dataset.csvPath);
|
|
52
|
+
// 1. ć¹ćć¼ććć”ć¤ć«ć®ååØē¢ŗčŖ
|
|
53
|
+
const schemaExists = await checkPathExists(schemaPath);
|
|
54
|
+
if (!schemaExists) {
|
|
55
|
+
issues.push({
|
|
56
|
+
type: 'error',
|
|
57
|
+
dataset: dataset.id,
|
|
58
|
+
file: dataset.schemaPath,
|
|
59
|
+
message: `Schema file not found: ${dataset.schemaPath}`,
|
|
60
|
+
hint: `Create the schema file at: ${schemaPath}\nExample schema structure:\n schemaVersion: 1\n id: ${dataset.id}\n title: ${dataset.title}\n csv:\n delimiter: ","\n header: true\n primaryKey: "id"\n columns:\n - key: id\n label: ID\n type: string\n required: true`,
|
|
61
|
+
});
|
|
62
|
+
// ć¹ćć¼ćććŖććć°ćć仄äøćć§ććÆć§ććŖć
|
|
63
|
+
return issues;
|
|
64
|
+
}
|
|
65
|
+
// 2. ć¹ćć¼ććć”ć¤ć«ć®å½¢å¼ćć§ććÆ
|
|
66
|
+
let schema = null;
|
|
67
|
+
try {
|
|
68
|
+
const schemaContent = await fs.readFile(schemaPath, 'utf-8');
|
|
69
|
+
let rawSchema;
|
|
70
|
+
// YAML/JSONćć¼ć¹
|
|
71
|
+
try {
|
|
72
|
+
rawSchema = YAML.parse(schemaContent);
|
|
73
|
+
}
|
|
74
|
+
catch (parseErr) {
|
|
75
|
+
issues.push({
|
|
76
|
+
type: 'error',
|
|
77
|
+
dataset: dataset.id,
|
|
78
|
+
file: dataset.schemaPath,
|
|
79
|
+
message: `Schema file is not valid YAML/JSON: ${parseErr.message}`,
|
|
80
|
+
hint: `Check the YAML syntax in: ${schemaPath}\nCommon issues:\n - Incorrect indentation (use spaces, not tabs)\n - Missing colons after keys\n - Unquoted special characters`,
|
|
81
|
+
});
|
|
82
|
+
return issues;
|
|
83
|
+
}
|
|
84
|
+
// ć¹ćć¼ćććŖćć¼ć·ć§ć³
|
|
85
|
+
schema = schemaService.validate(rawSchema);
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
const errorMessage = err.message;
|
|
89
|
+
issues.push({
|
|
90
|
+
type: 'error',
|
|
91
|
+
dataset: dataset.id,
|
|
92
|
+
file: dataset.schemaPath,
|
|
93
|
+
message: `Schema validation failed: ${errorMessage}`,
|
|
94
|
+
hint: formatSchemaValidationHint(errorMessage),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// 3. CSVćć”ć¤ć«ć®ååØē¢ŗčŖ
|
|
98
|
+
const csvExists = await checkPathExists(csvPath);
|
|
99
|
+
if (!csvExists) {
|
|
100
|
+
issues.push({
|
|
101
|
+
type: 'error',
|
|
102
|
+
dataset: dataset.id,
|
|
103
|
+
file: dataset.csvPath,
|
|
104
|
+
message: `CSV file not found: ${dataset.csvPath}`,
|
|
105
|
+
hint: `Create the CSV file at: ${csvPath}\n${schema ? generateCsvTemplate(schema) : 'Create a CSV file with headers matching the schema columns.'}`,
|
|
106
|
+
});
|
|
107
|
+
return issues;
|
|
108
|
+
}
|
|
109
|
+
// 4. CSVćć”ć¤ć«ć®å½¢å¼ćć§ććÆļ¼ć¹ćć¼ććęå¹ćŖå “åć®ćæļ¼
|
|
110
|
+
if (schema) {
|
|
111
|
+
try {
|
|
112
|
+
const csvContent = await fs.readFile(csvPath, 'utf-8');
|
|
113
|
+
const parseResult = parseCSVContent(csvContent, schema);
|
|
114
|
+
// ćć¼ć¹ćØć©ć¼
|
|
115
|
+
if (parseResult.errors.length > 0) {
|
|
116
|
+
for (const error of parseResult.errors) {
|
|
117
|
+
issues.push({
|
|
118
|
+
type: 'error',
|
|
119
|
+
dataset: dataset.id,
|
|
120
|
+
file: dataset.csvPath,
|
|
121
|
+
message: `CSV parse error (row ${error.row + 1}): ${error.message}`,
|
|
122
|
+
hint: `Check the CSV format at: ${csvPath}`,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// ćććć¼ćØć¹ćć¼ćć®ę“åę§ćć§ććÆ
|
|
127
|
+
const headerIssues = validateCsvHeaders(parseResult.headers, schema, dataset, csvPath);
|
|
128
|
+
issues.push(...headerIssues);
|
|
129
|
+
// primaryKeyć®ååØē¢ŗčŖ
|
|
130
|
+
if (!parseResult.headers.includes(schema.csv.primaryKey)) {
|
|
131
|
+
issues.push({
|
|
132
|
+
type: 'error',
|
|
133
|
+
dataset: dataset.id,
|
|
134
|
+
file: dataset.csvPath,
|
|
135
|
+
message: `Primary key column "${schema.csv.primaryKey}" not found in CSV headers`,
|
|
136
|
+
hint: `Add a column "${schema.csv.primaryKey}" to the CSV file, or update csv.primaryKey in the schema.`,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
// primaryKeyć®éč¤ćć§ććÆļ¼č¦åļ¼
|
|
140
|
+
if (parseResult.rows.length > 0 && parseResult.headers.includes(schema.csv.primaryKey)) {
|
|
141
|
+
const pkValues = parseResult.rows.map((row) => row[schema.csv.primaryKey]);
|
|
142
|
+
const duplicates = pkValues.filter((v, i) => pkValues.indexOf(v) !== i);
|
|
143
|
+
if (duplicates.length > 0) {
|
|
144
|
+
const uniqueDuplicates = [...new Set(duplicates)].slice(0, 5);
|
|
145
|
+
issues.push({
|
|
146
|
+
type: 'warning',
|
|
147
|
+
dataset: dataset.id,
|
|
148
|
+
file: dataset.csvPath,
|
|
149
|
+
message: `Duplicate primary key values found: ${uniqueDuplicates.join(', ')}${duplicates.length > 5 ? ` and ${duplicates.length - 5} more` : ''}`,
|
|
150
|
+
hint: `Primary key should be unique. Check for duplicate values in the "${schema.csv.primaryKey}" column.`,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
issues.push({
|
|
157
|
+
type: 'error',
|
|
158
|
+
dataset: dataset.id,
|
|
159
|
+
file: dataset.csvPath,
|
|
160
|
+
message: `Failed to read CSV file: ${err.message}`,
|
|
161
|
+
hint: `Check file permissions and encoding (UTF-8 is expected).`,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return issues;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* CSVćććć¼ćØć¹ćć¼ćć®ę“åę§ćć§ććÆ
|
|
169
|
+
*/
|
|
170
|
+
function validateCsvHeaders(headers, schema, dataset, csvPath) {
|
|
171
|
+
const issues = [];
|
|
172
|
+
const schemaColumns = schema.columns.map((c) => c.key);
|
|
173
|
+
// ć¹ćć¼ćć«ćććCSVć«ćŖćå
|
|
174
|
+
const missingInCsv = schemaColumns.filter((col) => !headers.includes(col));
|
|
175
|
+
if (missingInCsv.length > 0) {
|
|
176
|
+
issues.push({
|
|
177
|
+
type: 'warning',
|
|
178
|
+
dataset: dataset.id,
|
|
179
|
+
file: dataset.csvPath,
|
|
180
|
+
message: `Columns defined in schema but missing in CSV: ${missingInCsv.join(', ')}`,
|
|
181
|
+
hint: `Add these columns to the CSV file, or remove them from the schema if not needed.\nExpected columns: ${schemaColumns.join(', ')}`,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
// CSVć«ćććć¹ćć¼ćć«ćŖćåļ¼č¦åļ¼
|
|
185
|
+
const extraInCsv = headers.filter((h) => !schemaColumns.includes(h));
|
|
186
|
+
if (extraInCsv.length > 0) {
|
|
187
|
+
issues.push({
|
|
188
|
+
type: 'warning',
|
|
189
|
+
dataset: dataset.id,
|
|
190
|
+
file: dataset.csvPath,
|
|
191
|
+
message: `Columns in CSV but not defined in schema: ${extraInCsv.join(', ')}`,
|
|
192
|
+
hint: `These columns will be ignored. Add them to the schema if needed, or remove from CSV.`,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
return issues;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* ćć¹ć®ååØē¢ŗčŖ
|
|
199
|
+
*/
|
|
200
|
+
async function checkPathExists(filePath) {
|
|
201
|
+
try {
|
|
202
|
+
await fs.access(filePath);
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* ć¹ćć¼ćććŖćć¼ć·ć§ć³ćØć©ć¼ć®ćć³ććēę
|
|
211
|
+
*/
|
|
212
|
+
function formatSchemaValidationHint(errorMessage) {
|
|
213
|
+
const hints = ['Check the schema file structure:'];
|
|
214
|
+
if (errorMessage.includes('csv.primaryKey')) {
|
|
215
|
+
hints.push(' - csv.primaryKey is required: specify which column is the primary key');
|
|
216
|
+
}
|
|
217
|
+
if (errorMessage.includes('columns')) {
|
|
218
|
+
hints.push(' - columns array is required: define at least one column');
|
|
219
|
+
}
|
|
220
|
+
if (errorMessage.includes('type')) {
|
|
221
|
+
hints.push(' - column.type must be one of: string, integer, number, boolean, date, datetime, enum');
|
|
222
|
+
}
|
|
223
|
+
if (errorMessage.includes('id') || errorMessage.includes('title')) {
|
|
224
|
+
hints.push(' - id and title are required fields');
|
|
225
|
+
}
|
|
226
|
+
hints.push('\nExample minimal schema:');
|
|
227
|
+
hints.push(' schemaVersion: 1');
|
|
228
|
+
hints.push(' id: my_dataset');
|
|
229
|
+
hints.push(' title: My Dataset');
|
|
230
|
+
hints.push(' csv:');
|
|
231
|
+
hints.push(' delimiter: ","');
|
|
232
|
+
hints.push(' header: true');
|
|
233
|
+
hints.push(' primaryKey: "id"');
|
|
234
|
+
hints.push(' columns:');
|
|
235
|
+
hints.push(' - key: id');
|
|
236
|
+
hints.push(' label: ID');
|
|
237
|
+
hints.push(' type: string');
|
|
238
|
+
return hints.join('\n');
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* ć¹ćć¼ćććCSVćć³ćć¬ć¼ććēę
|
|
242
|
+
*/
|
|
243
|
+
function generateCsvTemplate(schema) {
|
|
244
|
+
const headers = schema.columns.map((c) => c.key).join(',');
|
|
245
|
+
return `Example CSV structure:\n ${headers}\n (add your data rows here)`;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* ććŖćć¼ć·ć§ć³ēµęćć³ć³ć½ć¼ć«ć«åŗå
|
|
249
|
+
*/
|
|
250
|
+
export function printValidationResult(result) {
|
|
251
|
+
if (result.valid && result.issues.length === 0) {
|
|
252
|
+
console.log(chalk.green('\nā All configuration files validated successfully.\n'));
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const errors = result.issues.filter((i) => i.type === 'error');
|
|
256
|
+
const warnings = result.issues.filter((i) => i.type === 'warning');
|
|
257
|
+
console.log('');
|
|
258
|
+
// ćØć©ć¼åŗå
|
|
259
|
+
if (errors.length > 0) {
|
|
260
|
+
console.log(chalk.red.bold(`ā ${errors.length} error(s) found:\n`));
|
|
261
|
+
for (const issue of errors) {
|
|
262
|
+
printIssue(issue, 'error');
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
// č¦ååŗå
|
|
266
|
+
if (warnings.length > 0) {
|
|
267
|
+
console.log(chalk.yellow.bold(`ā ${warnings.length} warning(s):\n`));
|
|
268
|
+
for (const issue of warnings) {
|
|
269
|
+
printIssue(issue, 'warning');
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (!result.valid) {
|
|
273
|
+
console.log(chalk.red.bold('\nā Server startup aborted due to configuration errors.'));
|
|
274
|
+
console.log(chalk.dim(' Fix the errors above and try again.\n'));
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* åäøć®åé”ćåŗå
|
|
279
|
+
*/
|
|
280
|
+
function printIssue(issue, type) {
|
|
281
|
+
const icon = type === 'error' ? chalk.red('ā') : chalk.yellow('ā ');
|
|
282
|
+
const color = type === 'error' ? chalk.red : chalk.yellow;
|
|
283
|
+
// ćććć¼č”
|
|
284
|
+
let header = '';
|
|
285
|
+
if (issue.dataset) {
|
|
286
|
+
header += chalk.cyan(`[${issue.dataset}]`);
|
|
287
|
+
}
|
|
288
|
+
if (issue.file) {
|
|
289
|
+
header += header ? ' ' : '';
|
|
290
|
+
header += chalk.dim(issue.file);
|
|
291
|
+
}
|
|
292
|
+
if (header) {
|
|
293
|
+
console.log(`${icon} ${header}`);
|
|
294
|
+
console.log(` ${color(issue.message)}`);
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
console.log(`${icon} ${color(issue.message)}`);
|
|
298
|
+
}
|
|
299
|
+
// ćć³ć
|
|
300
|
+
if (issue.hint) {
|
|
301
|
+
const hintLines = issue.hint.split('\n');
|
|
302
|
+
console.log(chalk.dim(' Hint:'));
|
|
303
|
+
for (const line of hintLines) {
|
|
304
|
+
console.log(chalk.dim(` ${line}`));
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
console.log('');
|
|
308
|
+
}
|
|
309
|
+
//# sourceMappingURL=validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../src/config/validator.ts"],"names":[],"mappings":"AAAA,aAAa;AAEb,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAiBvD,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,MAAsB;IAChE,MAAM,MAAM,GAAsB,EAAE,CAAC;IAErC,qBAAqB;IACrB,MAAM,eAAe,GAAG,MAAM,eAAe,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACrE,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,kCAAkC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE;YAClE,IAAI,EAAE,+EAA+E;SACtF,CAAC,CAAC;QACH,oCAAoC;QACpC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAClC,CAAC;IAED,kBAAkB;IAClB,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACtC,MAAM,aAAa,GAAG,MAAM,eAAe,CAAC,OAAO,E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AAC,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,MAAM;IACN,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC;QAClC,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAG3B,wBAAsB,WAAW,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyD5E;AAID,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import getPort from 'get-port';
|
|
3
3
|
import open from 'open';
|
|
4
4
|
import { createApp } from './app.js';
|
|
5
|
-
import { loadConfig } from './config/index.js';
|
|
5
|
+
import { loadConfig, validateStartupConfig, printValidationResult, } from './config/index.js';
|
|
6
6
|
import { logger, setLogLevel } from './lib/utils/logger.js';
|
|
7
7
|
export async function startServer(options = {}) {
|
|
8
8
|
try {
|
|
@@ -11,6 +11,13 @@ export async function startServer(options = {}) {
|
|
|
11
11
|
logger.info({ configPath: config.configPath }, 'Configuration loaded');
|
|
12
12
|
// ćć°ć¬ćć«čØå®
|
|
13
13
|
setLogLevel(config.serverOptions.logLevel);
|
|
14
|
+
// čµ·ååććŖćć¼ć·ć§ć³
|
|
15
|
+
console.log('Validating configuration...');
|
|
16
|
+
const validationResult = await validateStartupConfig(config);
|
|
17
|
+
printValidationResult(validationResult);
|
|
18
|
+
if (!validationResult.valid) {
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
14
21
|
// ć¢ććŖć±ć¼ć·ć§ć³ä½ę
|
|
15
22
|
const app = createApp(config);
|
|
16
23
|
// ćć¼ćåå¾
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AAEd,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AAEd,OAAO,OAAO,MAAM,UAAU,CAAC;AAC/B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,qBAAqB,GAGtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,UAAyB,EAAE;IAC3D,IAAI,CAAC;QACH,SAAS;QACT,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,OAAO,CA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gBAC9B,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;oBACnB,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;gBACzC,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,eAAe;QACf,MAAM,QAAQ,GAAG,GAAG,EAAE;YACpB,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;YACvC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;gBAChB,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;gBAC7B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,wBAAwB,CAAC,CAAC;QAChD,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAG,GAAa,CAAC,OAAO,CAAC,CAAC;QAChD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,0CAA0C;AAE1C,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "csvms",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.8",
|
|
4
4
|
"description": "CSVMS - Edit CSV files with a CMS-like UI",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"csvms": "./dist/cli.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
|
-
"dist"
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md"
|
|
12
13
|
],
|
|
13
14
|
"scripts": {
|
|
14
15
|
"dev": "tsx watch src/cli.ts",
|
|
@@ -39,6 +40,7 @@
|
|
|
39
40
|
"url": "git+https://github.com/foo-ogawa/csvms.git"
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
43
|
+
"chalk": "^5.3.0",
|
|
42
44
|
"commander": "^12.1.0",
|
|
43
45
|
"express": "^4.21.0",
|
|
44
46
|
"expr-eval": "^2.0.2",
|