@proseql/cli 0.2.4
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/LICENSE +21 -0
- package/README.md +333 -0
- package/dist/commands/collections.d.ts +53 -0
- package/dist/commands/collections.d.ts.map +1 -0
- package/dist/commands/collections.js +145 -0
- package/dist/commands/collections.js.map +1 -0
- package/dist/commands/convert.d.ts +72 -0
- package/dist/commands/convert.d.ts.map +1 -0
- package/dist/commands/convert.js +340 -0
- package/dist/commands/convert.js.map +1 -0
- package/dist/commands/create.d.ts +48 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +141 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/delete.d.ts +51 -0
- package/dist/commands/delete.d.ts.map +1 -0
- package/dist/commands/delete.js +122 -0
- package/dist/commands/delete.js.map +1 -0
- package/dist/commands/describe.d.ts +74 -0
- package/dist/commands/describe.d.ts.map +1 -0
- package/dist/commands/describe.js +206 -0
- package/dist/commands/describe.js.map +1 -0
- package/dist/commands/init.d.ts +37 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +340 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/migrate.d.ts +65 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +483 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/query.d.ts +56 -0
- package/dist/commands/query.d.ts.map +1 -0
- package/dist/commands/query.js +159 -0
- package/dist/commands/query.js.map +1 -0
- package/dist/commands/stats.d.ts +55 -0
- package/dist/commands/stats.d.ts.map +1 -0
- package/dist/commands/stats.js +188 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/update.d.ts +50 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +121 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/config/discovery.d.ts +37 -0
- package/dist/config/discovery.d.ts.map +1 -0
- package/dist/config/discovery.js +171 -0
- package/dist/config/discovery.js.map +1 -0
- package/dist/config/loader.d.ts +49 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +195 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/main.d.ts +66 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +621 -0
- package/dist/main.js.map +1 -0
- package/dist/output/csv.d.ts +14 -0
- package/dist/output/csv.d.ts.map +1 -0
- package/dist/output/csv.js +54 -0
- package/dist/output/csv.js.map +1 -0
- package/dist/output/formatter.d.ts +18 -0
- package/dist/output/formatter.d.ts.map +1 -0
- package/dist/output/formatter.js +29 -0
- package/dist/output/formatter.js.map +1 -0
- package/dist/output/json.d.ts +13 -0
- package/dist/output/json.d.ts.map +1 -0
- package/dist/output/json.js +15 -0
- package/dist/output/json.js.map +1 -0
- package/dist/output/table.d.ts +18 -0
- package/dist/output/table.d.ts.map +1 -0
- package/dist/output/table.js +115 -0
- package/dist/output/table.js.map +1 -0
- package/dist/output/yaml.d.ts +13 -0
- package/dist/output/yaml.d.ts.map +1 -0
- package/dist/output/yaml.js +16 -0
- package/dist/output/yaml.js.map +1 -0
- package/dist/parsers/filter-parser.d.ts +65 -0
- package/dist/parsers/filter-parser.d.ts.map +1 -0
- package/dist/parsers/filter-parser.js +198 -0
- package/dist/parsers/filter-parser.js.map +1 -0
- package/dist/parsers/set-parser.d.ts +55 -0
- package/dist/parsers/set-parser.d.ts.map +1 -0
- package/dist/parsers/set-parser.js +198 -0
- package/dist/parsers/set-parser.js.map +1 -0
- package/dist/prompt.d.ts +58 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +121 -0
- package/dist/prompt.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { Data, Effect } from "effect";
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// Config Discovery Error
|
|
6
|
+
// ============================================================================
|
|
7
|
+
/**
|
|
8
|
+
* Error thrown when no config file can be found.
|
|
9
|
+
*/
|
|
10
|
+
export class ConfigNotFoundError extends Data.TaggedError("ConfigNotFoundError") {
|
|
11
|
+
}
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Config File Names (in priority order)
|
|
14
|
+
// ============================================================================
|
|
15
|
+
const CONFIG_FILE_NAMES = [
|
|
16
|
+
"proseql.config.ts",
|
|
17
|
+
"proseql.config.js",
|
|
18
|
+
"proseql.config.json",
|
|
19
|
+
];
|
|
20
|
+
// ============================================================================
|
|
21
|
+
// Discovery Functions
|
|
22
|
+
// ============================================================================
|
|
23
|
+
/**
|
|
24
|
+
* Check if a file exists at the given path.
|
|
25
|
+
*/
|
|
26
|
+
function fileExists(filePath) {
|
|
27
|
+
try {
|
|
28
|
+
return fs.existsSync(filePath) && fs.statSync(filePath).isFile();
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Check if a directory exists at the given path.
|
|
36
|
+
*/
|
|
37
|
+
function directoryExists(dirPath) {
|
|
38
|
+
try {
|
|
39
|
+
return fs.existsSync(dirPath) && fs.statSync(dirPath).isDirectory();
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get the parent directory of a path.
|
|
47
|
+
* Returns null if at filesystem root.
|
|
48
|
+
*/
|
|
49
|
+
function getParentDirectory(dirPath) {
|
|
50
|
+
const parent = path.dirname(dirPath);
|
|
51
|
+
// If dirname returns the same path, we're at the root
|
|
52
|
+
return parent === dirPath ? null : parent;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Search for a config file in a single directory.
|
|
56
|
+
* Returns the first matching config file path, or null if none found.
|
|
57
|
+
*/
|
|
58
|
+
function findConfigInDirectory(dirPath) {
|
|
59
|
+
for (const configName of CONFIG_FILE_NAMES) {
|
|
60
|
+
const configPath = path.join(dirPath, configName);
|
|
61
|
+
if (fileExists(configPath)) {
|
|
62
|
+
return configPath;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Walk from the start directory upward to the filesystem root,
|
|
69
|
+
* collecting all directories searched.
|
|
70
|
+
*/
|
|
71
|
+
function* walkUpward(startDir) {
|
|
72
|
+
let currentDir = startDir;
|
|
73
|
+
while (currentDir !== null) {
|
|
74
|
+
yield currentDir;
|
|
75
|
+
currentDir = getParentDirectory(currentDir);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Discover a proseql config file.
|
|
80
|
+
*
|
|
81
|
+
* If `overridePath` is provided, it is validated and returned directly.
|
|
82
|
+
* Otherwise, the function walks from `cwd` upward, checking for:
|
|
83
|
+
* - `proseql.config.ts`
|
|
84
|
+
* - `proseql.config.js`
|
|
85
|
+
* - `proseql.config.json`
|
|
86
|
+
*
|
|
87
|
+
* Returns the absolute path to the config file.
|
|
88
|
+
* Fails with ConfigNotFoundError if no config file is found.
|
|
89
|
+
*
|
|
90
|
+
* @param cwd - The directory to start searching from
|
|
91
|
+
* @param overridePath - Optional explicit path to a config file
|
|
92
|
+
*/
|
|
93
|
+
export function discoverConfig(cwd, overridePath) {
|
|
94
|
+
return Effect.gen(function* () {
|
|
95
|
+
// If an override path is provided, validate and return it
|
|
96
|
+
if (overridePath !== undefined) {
|
|
97
|
+
const absoluteOverridePath = path.isAbsolute(overridePath)
|
|
98
|
+
? overridePath
|
|
99
|
+
: path.resolve(cwd, overridePath);
|
|
100
|
+
if (fileExists(absoluteOverridePath)) {
|
|
101
|
+
return absoluteOverridePath;
|
|
102
|
+
}
|
|
103
|
+
// Override path was specified but doesn't exist
|
|
104
|
+
return yield* Effect.fail(new ConfigNotFoundError({
|
|
105
|
+
searchedPaths: [absoluteOverridePath],
|
|
106
|
+
message: `Config file not found: ${absoluteOverridePath}`,
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
// Normalize and resolve the starting directory
|
|
110
|
+
const startDir = path.resolve(cwd);
|
|
111
|
+
// Validate that the starting directory exists
|
|
112
|
+
if (!directoryExists(startDir)) {
|
|
113
|
+
return yield* Effect.fail(new ConfigNotFoundError({
|
|
114
|
+
searchedPaths: [],
|
|
115
|
+
message: `Starting directory does not exist: ${startDir}`,
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
// Track all directories searched for error reporting
|
|
119
|
+
const searchedPaths = [];
|
|
120
|
+
// Walk upward from cwd to filesystem root
|
|
121
|
+
for (const dir of walkUpward(startDir)) {
|
|
122
|
+
const configPath = findConfigInDirectory(dir);
|
|
123
|
+
if (configPath !== null) {
|
|
124
|
+
return configPath;
|
|
125
|
+
}
|
|
126
|
+
// Track all config file paths that were checked in this directory
|
|
127
|
+
for (const configName of CONFIG_FILE_NAMES) {
|
|
128
|
+
searchedPaths.push(path.join(dir, configName));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// No config file found anywhere
|
|
132
|
+
return yield* Effect.fail(new ConfigNotFoundError({
|
|
133
|
+
searchedPaths,
|
|
134
|
+
message: `No proseql config file found. Searched from ${startDir} to filesystem root.\nLooking for: ${CONFIG_FILE_NAMES.join(", ")}`,
|
|
135
|
+
}));
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Synchronous version of discoverConfig for use in contexts
|
|
140
|
+
* where Effect is not available.
|
|
141
|
+
*
|
|
142
|
+
* @throws Error if no config file is found
|
|
143
|
+
*/
|
|
144
|
+
export function discoverConfigSync(cwd, overridePath) {
|
|
145
|
+
// If an override path is provided, validate and return it
|
|
146
|
+
if (overridePath !== undefined) {
|
|
147
|
+
const absoluteOverridePath = path.isAbsolute(overridePath)
|
|
148
|
+
? overridePath
|
|
149
|
+
: path.resolve(cwd, overridePath);
|
|
150
|
+
if (fileExists(absoluteOverridePath)) {
|
|
151
|
+
return absoluteOverridePath;
|
|
152
|
+
}
|
|
153
|
+
throw new Error(`Config file not found: ${absoluteOverridePath}`);
|
|
154
|
+
}
|
|
155
|
+
// Normalize and resolve the starting directory
|
|
156
|
+
const startDir = path.resolve(cwd);
|
|
157
|
+
// Validate that the starting directory exists
|
|
158
|
+
if (!directoryExists(startDir)) {
|
|
159
|
+
throw new Error(`Starting directory does not exist: ${startDir}`);
|
|
160
|
+
}
|
|
161
|
+
// Walk upward from cwd to filesystem root
|
|
162
|
+
for (const dir of walkUpward(startDir)) {
|
|
163
|
+
const configPath = findConfigInDirectory(dir);
|
|
164
|
+
if (configPath !== null) {
|
|
165
|
+
return configPath;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// No config file found anywhere
|
|
169
|
+
throw new Error(`No proseql config file found. Searched from ${startDir} to filesystem root.\nLooking for: ${CONFIG_FILE_NAMES.join(", ")}`);
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../../src/config/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtC,+EAA+E;AAC/E,yBAAyB;AACzB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,IAAI,CAAC,WAAW,CACxD,qBAAqB,CAIpB;CAAG;AAEL,+EAA+E;AAC/E,wCAAwC;AACxC,+EAA+E;AAE/E,MAAM,iBAAiB,GAAG;IACzB,mBAAmB;IACnB,mBAAmB;IACnB,qBAAqB;CACZ,CAAC;AAEX,+EAA+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C,QAAQ,CAAC,EAAE,CAAC;QACxC,MAAM,UAAU,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;YACzB,OAAO,UAAU,CAAC;QACnB,CAAC;IACF,CAAC;IAED,gCAAgC;IAChC,MAAM,IAAI,KAAK,CACd,+CAA+C,QAAQ,sCAAsC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC3H,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { DatabaseConfig } from "@proseql/core";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
declare const ConfigLoadError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
4
|
+
readonly _tag: "ConfigLoadError";
|
|
5
|
+
} & Readonly<A>;
|
|
6
|
+
/**
|
|
7
|
+
* Error thrown when a config file cannot be loaded.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ConfigLoadError extends ConfigLoadError_base<{
|
|
10
|
+
readonly configPath: string;
|
|
11
|
+
readonly reason: string;
|
|
12
|
+
readonly message: string;
|
|
13
|
+
}> {
|
|
14
|
+
}
|
|
15
|
+
declare const ConfigValidationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
16
|
+
readonly _tag: "ConfigValidationError";
|
|
17
|
+
} & Readonly<A>;
|
|
18
|
+
/**
|
|
19
|
+
* Error thrown when a config file has an invalid structure.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ConfigValidationError extends ConfigValidationError_base<{
|
|
22
|
+
readonly configPath: string;
|
|
23
|
+
readonly reason: string;
|
|
24
|
+
readonly message: string;
|
|
25
|
+
}> {
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Load a proseql configuration file.
|
|
29
|
+
*
|
|
30
|
+
* Supports three file formats:
|
|
31
|
+
* - `.ts` - TypeScript (imported via Bun)
|
|
32
|
+
* - `.js` - JavaScript (dynamic import)
|
|
33
|
+
* - `.json` - JSON (parsed with JSON.parse)
|
|
34
|
+
*
|
|
35
|
+
* The config file should export a DatabaseConfig object as its default export.
|
|
36
|
+
*
|
|
37
|
+
* @param configPath - Absolute path to the config file
|
|
38
|
+
* @returns The validated DatabaseConfig
|
|
39
|
+
*/
|
|
40
|
+
export declare function loadConfig(configPath: string): Effect.Effect<DatabaseConfig, ConfigLoadError | ConfigValidationError>;
|
|
41
|
+
/**
|
|
42
|
+
* Synchronous version of loadConfig for use in contexts
|
|
43
|
+
* where Effect is not available.
|
|
44
|
+
*
|
|
45
|
+
* @throws Error if config cannot be loaded or is invalid
|
|
46
|
+
*/
|
|
47
|
+
export declare function loadConfigAsync(configPath: string): Promise<DatabaseConfig>;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAQ,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;AAMtC;;GAEG;AACH,qBAAa,eAAgB,SAAQ,qBAAoC;IACxE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB,CAAC;CAAG;;;;AAEL;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,2BAEzC;IACD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB,CAAC;CAAG;AAqLL;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CACzB,UAAU,EAAE,MAAM,GAChB,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,eAAe,GAAG,qBAAqB,CAAC,CAmCxE;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACpC,UAAU,EAAE,MAAM,GAChB,OAAO,CAAC,cAAc,CAAC,CAEzB"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import { Data, Effect } from "effect";
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// Config Loading Errors
|
|
6
|
+
// ============================================================================
|
|
7
|
+
/**
|
|
8
|
+
* Error thrown when a config file cannot be loaded.
|
|
9
|
+
*/
|
|
10
|
+
export class ConfigLoadError extends Data.TaggedError("ConfigLoadError") {
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Error thrown when a config file has an invalid structure.
|
|
14
|
+
*/
|
|
15
|
+
export class ConfigValidationError extends Data.TaggedError("ConfigValidationError") {
|
|
16
|
+
}
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Supported Extensions
|
|
19
|
+
// ============================================================================
|
|
20
|
+
const SUPPORTED_EXTENSIONS = [".ts", ".js", ".json"];
|
|
21
|
+
/**
|
|
22
|
+
* Check if a file extension is supported.
|
|
23
|
+
*/
|
|
24
|
+
function isSupportedExtension(ext) {
|
|
25
|
+
return SUPPORTED_EXTENSIONS.includes(ext);
|
|
26
|
+
}
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// Config Loading Functions
|
|
29
|
+
// ============================================================================
|
|
30
|
+
/**
|
|
31
|
+
* Load a JSON config file.
|
|
32
|
+
*/
|
|
33
|
+
function loadJsonConfig(configPath) {
|
|
34
|
+
return Effect.gen(function* () {
|
|
35
|
+
try {
|
|
36
|
+
const content = fs.readFileSync(configPath, "utf-8");
|
|
37
|
+
return JSON.parse(content);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
41
|
+
return yield* Effect.fail(new ConfigLoadError({
|
|
42
|
+
configPath,
|
|
43
|
+
reason: `Failed to parse JSON config: ${errorMessage}`,
|
|
44
|
+
message: `Failed to load config from ${configPath}: ${errorMessage}`,
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Load a TypeScript or JavaScript config file using dynamic import.
|
|
51
|
+
* Bun handles TypeScript natively, so this works for both .ts and .js.
|
|
52
|
+
*/
|
|
53
|
+
function loadModuleConfig(configPath) {
|
|
54
|
+
// Use file:// URL for dynamic import to work correctly
|
|
55
|
+
const fileUrl = `file://${configPath}`;
|
|
56
|
+
return Effect.tryPromise({
|
|
57
|
+
try: async () => {
|
|
58
|
+
const module = (await import(fileUrl));
|
|
59
|
+
// Config should be the default export
|
|
60
|
+
if ("default" in module) {
|
|
61
|
+
return module.default;
|
|
62
|
+
}
|
|
63
|
+
// If no default export, try to use the module itself
|
|
64
|
+
// (in case the config is exported as module.exports = {...})
|
|
65
|
+
return module;
|
|
66
|
+
},
|
|
67
|
+
catch: (error) => {
|
|
68
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
69
|
+
return new ConfigLoadError({
|
|
70
|
+
configPath,
|
|
71
|
+
reason: `Failed to import config module: ${errorMessage}`,
|
|
72
|
+
message: `Failed to load config from ${configPath}: ${errorMessage}`,
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Validate that a loaded config object has the correct structure.
|
|
79
|
+
* A valid DatabaseConfig is a Record<string, CollectionConfig> where
|
|
80
|
+
* each CollectionConfig has at least a `schema` and `relationships` field.
|
|
81
|
+
*/
|
|
82
|
+
function validateConfigStructure(config, configPath) {
|
|
83
|
+
return Effect.gen(function* () {
|
|
84
|
+
// Must be a non-null object
|
|
85
|
+
if (config === null || typeof config !== "object") {
|
|
86
|
+
return yield* Effect.fail(new ConfigValidationError({
|
|
87
|
+
configPath,
|
|
88
|
+
reason: "Config must be an object",
|
|
89
|
+
message: `Invalid config in ${configPath}: Config must be an object, got ${typeof config}`,
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
// Must be a plain object (not an array)
|
|
93
|
+
if (Array.isArray(config)) {
|
|
94
|
+
return yield* Effect.fail(new ConfigValidationError({
|
|
95
|
+
configPath,
|
|
96
|
+
reason: "Config must be an object, not an array",
|
|
97
|
+
message: `Invalid config in ${configPath}: Config must be an object, got array`,
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
const configObj = config;
|
|
101
|
+
// Check each collection
|
|
102
|
+
for (const [collectionName, collectionConfig] of Object.entries(configObj)) {
|
|
103
|
+
// Each collection config must be an object
|
|
104
|
+
if (collectionConfig === null ||
|
|
105
|
+
typeof collectionConfig !== "object" ||
|
|
106
|
+
Array.isArray(collectionConfig)) {
|
|
107
|
+
return yield* Effect.fail(new ConfigValidationError({
|
|
108
|
+
configPath,
|
|
109
|
+
reason: `Collection '${collectionName}' must be an object`,
|
|
110
|
+
message: `Invalid config in ${configPath}: Collection '${collectionName}' must be an object`,
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
const collection = collectionConfig;
|
|
114
|
+
// Must have a schema field
|
|
115
|
+
if (!("schema" in collection)) {
|
|
116
|
+
return yield* Effect.fail(new ConfigValidationError({
|
|
117
|
+
configPath,
|
|
118
|
+
reason: `Collection '${collectionName}' is missing required field 'schema'`,
|
|
119
|
+
message: `Invalid config in ${configPath}: Collection '${collectionName}' is missing required field 'schema'`,
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
// Must have a relationships field
|
|
123
|
+
if (!("relationships" in collection)) {
|
|
124
|
+
return yield* Effect.fail(new ConfigValidationError({
|
|
125
|
+
configPath,
|
|
126
|
+
reason: `Collection '${collectionName}' is missing required field 'relationships'`,
|
|
127
|
+
message: `Invalid config in ${configPath}: Collection '${collectionName}' is missing required field 'relationships'`,
|
|
128
|
+
}));
|
|
129
|
+
}
|
|
130
|
+
// Relationships must be an object
|
|
131
|
+
if (collection.relationships === null ||
|
|
132
|
+
typeof collection.relationships !== "object" ||
|
|
133
|
+
Array.isArray(collection.relationships)) {
|
|
134
|
+
return yield* Effect.fail(new ConfigValidationError({
|
|
135
|
+
configPath,
|
|
136
|
+
reason: `Collection '${collectionName}' field 'relationships' must be an object`,
|
|
137
|
+
message: `Invalid config in ${configPath}: Collection '${collectionName}' field 'relationships' must be an object`,
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// Config is valid
|
|
142
|
+
return configObj;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
// ============================================================================
|
|
146
|
+
// Main Export
|
|
147
|
+
// ============================================================================
|
|
148
|
+
/**
|
|
149
|
+
* Load a proseql configuration file.
|
|
150
|
+
*
|
|
151
|
+
* Supports three file formats:
|
|
152
|
+
* - `.ts` - TypeScript (imported via Bun)
|
|
153
|
+
* - `.js` - JavaScript (dynamic import)
|
|
154
|
+
* - `.json` - JSON (parsed with JSON.parse)
|
|
155
|
+
*
|
|
156
|
+
* The config file should export a DatabaseConfig object as its default export.
|
|
157
|
+
*
|
|
158
|
+
* @param configPath - Absolute path to the config file
|
|
159
|
+
* @returns The validated DatabaseConfig
|
|
160
|
+
*/
|
|
161
|
+
export function loadConfig(configPath) {
|
|
162
|
+
return Effect.gen(function* () {
|
|
163
|
+
// Ensure the path is absolute
|
|
164
|
+
const absolutePath = path.isAbsolute(configPath)
|
|
165
|
+
? configPath
|
|
166
|
+
: path.resolve(process.cwd(), configPath);
|
|
167
|
+
// Get file extension
|
|
168
|
+
const ext = path.extname(absolutePath).toLowerCase();
|
|
169
|
+
// Validate extension
|
|
170
|
+
if (!isSupportedExtension(ext)) {
|
|
171
|
+
return yield* Effect.fail(new ConfigLoadError({
|
|
172
|
+
configPath: absolutePath,
|
|
173
|
+
reason: `Unsupported config file extension: ${ext}`,
|
|
174
|
+
message: `Cannot load config from ${absolutePath}: Unsupported extension '${ext}'. Use .ts, .js, or .json`,
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
// Load the raw config based on extension
|
|
178
|
+
const rawConfig = ext === ".json"
|
|
179
|
+
? yield* loadJsonConfig(absolutePath)
|
|
180
|
+
: yield* loadModuleConfig(absolutePath);
|
|
181
|
+
// Validate the config structure
|
|
182
|
+
const validatedConfig = yield* validateConfigStructure(rawConfig, absolutePath);
|
|
183
|
+
return validatedConfig;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Synchronous version of loadConfig for use in contexts
|
|
188
|
+
* where Effect is not available.
|
|
189
|
+
*
|
|
190
|
+
* @throws Error if config cannot be loaded or is invalid
|
|
191
|
+
*/
|
|
192
|
+
export async function loadConfigAsync(configPath) {
|
|
193
|
+
return Effect.runPromise(loadConfig(configPath));
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEtC,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAIrE;CAAG;AAEL;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,IAAI,CAAC,WAAW,CAC1D,uBAAuB,CAKtB;CAAG;AAEL,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E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,KAAK,CAAC,CAAC,uBAAuB,CACrD,SAAS,EACT,YAAY,CACZ,CAAC;QAEF,OAAO,eAAe,CAAC;IACxB,CAAC,CAAC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACpC,UAAkB;IAElB,OAAO,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @proseql/cli - Programmatic API
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the CLI's public API for programmatic use.
|
|
5
|
+
*/
|
|
6
|
+
export type { OutputFormat, ParsedArgs } from "./main.js";
|
|
7
|
+
export { getOutputFormat, parseArgs, resolveConfig } from "./main.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* ProseQL CLI - Command line interface for proseql databases
|
|
4
|
+
*
|
|
5
|
+
* Entry point: parses top-level flags and dispatches to command handlers.
|
|
6
|
+
*/
|
|
7
|
+
import type { DatabaseConfig } from "@proseql/core";
|
|
8
|
+
import { type OutputFormat } from "./output/formatter.js";
|
|
9
|
+
/**
|
|
10
|
+
* Parsed CLI arguments
|
|
11
|
+
*/
|
|
12
|
+
interface ParsedArgs {
|
|
13
|
+
readonly command: string | undefined;
|
|
14
|
+
readonly positionalArgs: readonly string[];
|
|
15
|
+
readonly flags: {
|
|
16
|
+
readonly help: boolean;
|
|
17
|
+
readonly version: boolean;
|
|
18
|
+
readonly config: string | undefined;
|
|
19
|
+
readonly json: boolean;
|
|
20
|
+
readonly yaml: boolean;
|
|
21
|
+
readonly csv: boolean;
|
|
22
|
+
readonly force: boolean;
|
|
23
|
+
readonly where: readonly string[];
|
|
24
|
+
readonly select: string | undefined;
|
|
25
|
+
readonly sort: string | undefined;
|
|
26
|
+
readonly limit: number | undefined;
|
|
27
|
+
readonly data: string | undefined;
|
|
28
|
+
readonly set: string | undefined;
|
|
29
|
+
readonly to: string | undefined;
|
|
30
|
+
readonly format: string | undefined;
|
|
31
|
+
readonly dryRun: boolean;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Determine output format from flags
|
|
36
|
+
*/
|
|
37
|
+
declare function getOutputFormat(flags: ParsedArgs["flags"]): OutputFormat;
|
|
38
|
+
/**
|
|
39
|
+
* Parse command line arguments
|
|
40
|
+
*/
|
|
41
|
+
declare function parseArgs(argv: readonly string[]): ParsedArgs;
|
|
42
|
+
/**
|
|
43
|
+
* Print help message
|
|
44
|
+
*/
|
|
45
|
+
declare function printHelp(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Print version
|
|
48
|
+
*/
|
|
49
|
+
declare function printVersion(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Resolved config result including both the config and its path.
|
|
52
|
+
*/
|
|
53
|
+
interface ResolvedConfig {
|
|
54
|
+
readonly config: DatabaseConfig;
|
|
55
|
+
readonly configPath: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Resolve and load the database config.
|
|
59
|
+
* Uses the --config flag if provided, otherwise discovers the config file.
|
|
60
|
+
* Returns both the config and its path (needed for resolving relative file paths).
|
|
61
|
+
*/
|
|
62
|
+
declare function resolveConfig(configOverride: string | undefined): Promise<ResolvedConfig>;
|
|
63
|
+
export { parseArgs, getOutputFormat, printHelp, printVersion, resolveConfig };
|
|
64
|
+
export type { ParsedArgs };
|
|
65
|
+
export type { OutputFormat } from "./output/formatter.js";
|
|
66
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAqBpD,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAIlE;;GAEG;AACH,UAAU,UAAU;IACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE;QACf,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;QACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;QAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QACpC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;QACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;QACvB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;QACtB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;QAExB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;QAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;QACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS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