@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.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +333 -0
  3. package/dist/commands/collections.d.ts +53 -0
  4. package/dist/commands/collections.d.ts.map +1 -0
  5. package/dist/commands/collections.js +145 -0
  6. package/dist/commands/collections.js.map +1 -0
  7. package/dist/commands/convert.d.ts +72 -0
  8. package/dist/commands/convert.d.ts.map +1 -0
  9. package/dist/commands/convert.js +340 -0
  10. package/dist/commands/convert.js.map +1 -0
  11. package/dist/commands/create.d.ts +48 -0
  12. package/dist/commands/create.d.ts.map +1 -0
  13. package/dist/commands/create.js +141 -0
  14. package/dist/commands/create.js.map +1 -0
  15. package/dist/commands/delete.d.ts +51 -0
  16. package/dist/commands/delete.d.ts.map +1 -0
  17. package/dist/commands/delete.js +122 -0
  18. package/dist/commands/delete.js.map +1 -0
  19. package/dist/commands/describe.d.ts +74 -0
  20. package/dist/commands/describe.d.ts.map +1 -0
  21. package/dist/commands/describe.js +206 -0
  22. package/dist/commands/describe.js.map +1 -0
  23. package/dist/commands/init.d.ts +37 -0
  24. package/dist/commands/init.d.ts.map +1 -0
  25. package/dist/commands/init.js +340 -0
  26. package/dist/commands/init.js.map +1 -0
  27. package/dist/commands/migrate.d.ts +65 -0
  28. package/dist/commands/migrate.d.ts.map +1 -0
  29. package/dist/commands/migrate.js +483 -0
  30. package/dist/commands/migrate.js.map +1 -0
  31. package/dist/commands/query.d.ts +56 -0
  32. package/dist/commands/query.d.ts.map +1 -0
  33. package/dist/commands/query.js +159 -0
  34. package/dist/commands/query.js.map +1 -0
  35. package/dist/commands/stats.d.ts +55 -0
  36. package/dist/commands/stats.d.ts.map +1 -0
  37. package/dist/commands/stats.js +188 -0
  38. package/dist/commands/stats.js.map +1 -0
  39. package/dist/commands/update.d.ts +50 -0
  40. package/dist/commands/update.d.ts.map +1 -0
  41. package/dist/commands/update.js +121 -0
  42. package/dist/commands/update.js.map +1 -0
  43. package/dist/config/discovery.d.ts +37 -0
  44. package/dist/config/discovery.d.ts.map +1 -0
  45. package/dist/config/discovery.js +171 -0
  46. package/dist/config/discovery.js.map +1 -0
  47. package/dist/config/loader.d.ts +49 -0
  48. package/dist/config/loader.d.ts.map +1 -0
  49. package/dist/config/loader.js +195 -0
  50. package/dist/config/loader.js.map +1 -0
  51. package/dist/index.d.ts +8 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +7 -0
  54. package/dist/index.js.map +1 -0
  55. package/dist/main.d.ts +66 -0
  56. package/dist/main.d.ts.map +1 -0
  57. package/dist/main.js +621 -0
  58. package/dist/main.js.map +1 -0
  59. package/dist/output/csv.d.ts +14 -0
  60. package/dist/output/csv.d.ts.map +1 -0
  61. package/dist/output/csv.js +54 -0
  62. package/dist/output/csv.js.map +1 -0
  63. package/dist/output/formatter.d.ts +18 -0
  64. package/dist/output/formatter.d.ts.map +1 -0
  65. package/dist/output/formatter.js +29 -0
  66. package/dist/output/formatter.js.map +1 -0
  67. package/dist/output/json.d.ts +13 -0
  68. package/dist/output/json.d.ts.map +1 -0
  69. package/dist/output/json.js +15 -0
  70. package/dist/output/json.js.map +1 -0
  71. package/dist/output/table.d.ts +18 -0
  72. package/dist/output/table.d.ts.map +1 -0
  73. package/dist/output/table.js +115 -0
  74. package/dist/output/table.js.map +1 -0
  75. package/dist/output/yaml.d.ts +13 -0
  76. package/dist/output/yaml.d.ts.map +1 -0
  77. package/dist/output/yaml.js +16 -0
  78. package/dist/output/yaml.js.map +1 -0
  79. package/dist/parsers/filter-parser.d.ts +65 -0
  80. package/dist/parsers/filter-parser.d.ts.map +1 -0
  81. package/dist/parsers/filter-parser.js +198 -0
  82. package/dist/parsers/filter-parser.js.map +1 -0
  83. package/dist/parsers/set-parser.d.ts +55 -0
  84. package/dist/parsers/set-parser.d.ts.map +1 -0
  85. package/dist/parsers/set-parser.js +198 -0
  86. package/dist/parsers/set-parser.js.map +1 -0
  87. package/dist/prompt.d.ts +58 -0
  88. package/dist/prompt.d.ts.map +1 -0
  89. package/dist/prompt.js +121 -0
  90. package/dist/prompt.js.map +1 -0
  91. package/package.json +59 -0
package/dist/main.js ADDED
@@ -0,0 +1,621 @@
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 { Effect } from "effect";
8
+ import { handleCollections as handleCollectionsCommand } from "./commands/collections.js";
9
+ import { handleConvert as handleConvertCommand, isValidFormat, VALID_FORMATS, } from "./commands/convert.js";
10
+ import { handleCreate as handleCreateCommand } from "./commands/create.js";
11
+ import { handleDelete as handleDeleteCommand } from "./commands/delete.js";
12
+ import { handleDescribe as handleDescribeCommand } from "./commands/describe.js";
13
+ import { handleInit as handleInitCommand } from "./commands/init.js";
14
+ import { detectSubcommand, handleMigrate as handleMigrateCommand, } from "./commands/migrate.js";
15
+ import { handleQuery as handleQueryCommand } from "./commands/query.js";
16
+ import { handleStats as handleStatsCommand } from "./commands/stats.js";
17
+ import { handleUpdate as handleUpdateCommand } from "./commands/update.js";
18
+ import { discoverConfig } from "./config/discovery.js";
19
+ import { loadConfig } from "./config/loader.js";
20
+ import { format } from "./output/formatter.js";
21
+ const VERSION = "0.2.4";
22
+ /**
23
+ * Determine output format from flags
24
+ */
25
+ function getOutputFormat(flags) {
26
+ if (flags.json)
27
+ return "json";
28
+ if (flags.yaml)
29
+ return "yaml";
30
+ if (flags.csv)
31
+ return "csv";
32
+ return "table";
33
+ }
34
+ /**
35
+ * Parse command line arguments
36
+ */
37
+ function parseArgs(argv) {
38
+ // Skip first two args (bun and script path)
39
+ const args = argv.slice(2);
40
+ const flags = {
41
+ help: false,
42
+ version: false,
43
+ config: undefined,
44
+ json: false,
45
+ yaml: false,
46
+ csv: false,
47
+ force: false,
48
+ where: [],
49
+ select: undefined,
50
+ sort: undefined,
51
+ limit: undefined,
52
+ data: undefined,
53
+ set: undefined,
54
+ to: undefined,
55
+ format: undefined,
56
+ dryRun: false,
57
+ };
58
+ const positionalArgs = [];
59
+ let command;
60
+ let i = 0;
61
+ while (i < args.length) {
62
+ const arg = args[i];
63
+ if (arg === "--help" || arg === "-h") {
64
+ flags.help = true;
65
+ i++;
66
+ }
67
+ else if (arg === "--version" || arg === "-v") {
68
+ flags.version = true;
69
+ i++;
70
+ }
71
+ else if (arg === "--config" || arg === "-c") {
72
+ flags.config = args[i + 1];
73
+ i += 2;
74
+ }
75
+ else if (arg === "--json") {
76
+ flags.json = true;
77
+ i++;
78
+ }
79
+ else if (arg === "--yaml") {
80
+ flags.yaml = true;
81
+ i++;
82
+ }
83
+ else if (arg === "--csv") {
84
+ flags.csv = true;
85
+ i++;
86
+ }
87
+ else if (arg === "--force" || arg === "-f") {
88
+ flags.force = true;
89
+ i++;
90
+ }
91
+ else if (arg === "--where" || arg === "-w") {
92
+ flags.where.push(args[i + 1]);
93
+ i += 2;
94
+ }
95
+ else if (arg === "--select" || arg === "-s") {
96
+ flags.select = args[i + 1];
97
+ i += 2;
98
+ }
99
+ else if (arg === "--sort") {
100
+ flags.sort = args[i + 1];
101
+ i += 2;
102
+ }
103
+ else if (arg === "--limit" || arg === "-l") {
104
+ const limitValue = parseInt(args[i + 1], 10);
105
+ flags.limit = Number.isNaN(limitValue) ? undefined : limitValue;
106
+ i += 2;
107
+ }
108
+ else if (arg === "--data" || arg === "-d") {
109
+ flags.data = args[i + 1];
110
+ i += 2;
111
+ }
112
+ else if (arg === "--set") {
113
+ flags.set = args[i + 1];
114
+ i += 2;
115
+ }
116
+ else if (arg === "--to") {
117
+ flags.to = args[i + 1];
118
+ i += 2;
119
+ }
120
+ else if (arg === "--format") {
121
+ flags.format = args[i + 1];
122
+ i += 2;
123
+ }
124
+ else if (arg === "--dry-run") {
125
+ flags.dryRun = true;
126
+ i++;
127
+ }
128
+ else if (arg.startsWith("-")) {
129
+ // Unknown flag - skip (could be command-specific)
130
+ i++;
131
+ }
132
+ else {
133
+ // Positional argument
134
+ if (command === undefined) {
135
+ command = arg;
136
+ }
137
+ else {
138
+ positionalArgs.push(arg);
139
+ }
140
+ i++;
141
+ }
142
+ }
143
+ return {
144
+ command,
145
+ positionalArgs,
146
+ flags: {
147
+ ...flags,
148
+ where: flags.where,
149
+ },
150
+ };
151
+ }
152
+ /**
153
+ * Print help message
154
+ */
155
+ function printHelp() {
156
+ console.log(`proseql v${VERSION}
157
+
158
+ A command-line interface for proseql databases.
159
+
160
+ USAGE:
161
+ proseql <command> [options]
162
+
163
+ COMMANDS:
164
+ init Initialize a new proseql project
165
+ query <collection> Query a collection
166
+ collections List all collections
167
+ describe <collection> Show schema details for a collection
168
+ stats Show statistics for all collections
169
+ create <collection> Create a new entity
170
+ update <collection> <id> Update an entity
171
+ delete <collection> <id> Delete an entity
172
+ migrate Run pending migrations
173
+ convert <collection> Convert a collection to a different format
174
+
175
+ GLOBAL OPTIONS:
176
+ -h, --help Show this help message
177
+ -v, --version Show version
178
+ -c, --config <path> Path to config file (default: auto-discover)
179
+ --json Output as JSON
180
+ --yaml Output as YAML
181
+ --csv Output as CSV
182
+
183
+ QUERY OPTIONS:
184
+ -w, --where <expr> Filter expression (e.g., 'year > 1970')
185
+ -s, --select <fields> Comma-separated fields to include
186
+ --sort <field:dir> Sort by field (asc/desc)
187
+ -l, --limit <n> Limit number of results
188
+
189
+ CRUD OPTIONS:
190
+ -d, --data <json> JSON data for create
191
+ --set <assignments> Field assignments for update (e.g., 'year=2025,title=New')
192
+ -f, --force Skip confirmation prompts
193
+
194
+ INIT OPTIONS:
195
+ --format <fmt> Data file format (json, yaml, toml)
196
+
197
+ MIGRATE OPTIONS:
198
+ --dry-run Show what would be done without executing
199
+ status Show migration status
200
+
201
+ CONVERT OPTIONS:
202
+ --to <format> Target format (json, yaml, toml)
203
+
204
+ EXAMPLES:
205
+ proseql init
206
+ proseql query books --where 'year > 1970' --limit 10
207
+ proseql query books --json | jq '.[] | .title'
208
+ proseql create books --data '{"title":"New Book","year":2024}'
209
+ proseql update books abc123 --set 'year=2025'
210
+ proseql delete books abc123 --force
211
+ proseql migrate status
212
+ proseql convert books --to yaml
213
+ `);
214
+ }
215
+ /**
216
+ * Print version
217
+ */
218
+ function printVersion() {
219
+ console.log(`proseql v${VERSION}`);
220
+ }
221
+ /**
222
+ * Print error and exit
223
+ */
224
+ function exitWithError(message) {
225
+ console.error(`Error: ${message}`);
226
+ console.error(`Run 'proseql --help' for usage.`);
227
+ process.exit(1);
228
+ }
229
+ /**
230
+ * Resolve and load the database config.
231
+ * Uses the --config flag if provided, otherwise discovers the config file.
232
+ * Returns both the config and its path (needed for resolving relative file paths).
233
+ */
234
+ async function resolveConfig(configOverride) {
235
+ const program = Effect.gen(function* () {
236
+ const configPath = yield* discoverConfig(process.cwd(), configOverride);
237
+ const config = yield* loadConfig(configPath);
238
+ return { config, configPath };
239
+ });
240
+ const result = await Effect.runPromise(program.pipe(Effect.catchAll((error) => Effect.sync(() => exitWithError(error.message)))));
241
+ return result;
242
+ }
243
+ /**
244
+ * Placeholder for command handlers (to be implemented in separate files)
245
+ */
246
+ async function handleInit(args) {
247
+ // init does not need config - it creates one
248
+ await handleInitCommand({
249
+ format: args.flags.format,
250
+ });
251
+ }
252
+ async function handleQuery(args, resolvedConfig) {
253
+ const collectionName = args.positionalArgs[0];
254
+ const result = await handleQueryCommand({
255
+ collection: collectionName,
256
+ config: resolvedConfig.config,
257
+ configPath: resolvedConfig.configPath,
258
+ where: args.flags.where,
259
+ select: args.flags.select,
260
+ sort: args.flags.sort,
261
+ limit: args.flags.limit,
262
+ });
263
+ if (!result.success) {
264
+ exitWithError(result.message ?? "Query failed");
265
+ }
266
+ // Output the results using the appropriate formatter
267
+ const outputFormat = getOutputFormat(args.flags);
268
+ const output = format(outputFormat, result.data ?? []);
269
+ console.log(output);
270
+ }
271
+ async function handleCollections(args, resolvedConfig) {
272
+ const result = await handleCollectionsCommand({
273
+ config: resolvedConfig.config,
274
+ configPath: resolvedConfig.configPath,
275
+ });
276
+ if (!result.success) {
277
+ exitWithError(result.message ?? "Failed to list collections");
278
+ }
279
+ // Output the results using the appropriate formatter
280
+ const outputFormat = getOutputFormat(args.flags);
281
+ const output = format(outputFormat, (result.data ?? []));
282
+ console.log(output);
283
+ }
284
+ async function handleDescribe(args, resolvedConfig) {
285
+ const collectionName = args.positionalArgs[0];
286
+ const result = await handleDescribeCommand({
287
+ collection: collectionName,
288
+ config: resolvedConfig.config,
289
+ });
290
+ if (!result.success) {
291
+ exitWithError(result.message ?? "Failed to describe collection");
292
+ }
293
+ // Format output based on format flag
294
+ const outputFormat = getOutputFormat(args.flags);
295
+ if (outputFormat === "json" || outputFormat === "yaml") {
296
+ // For structured formats, output the full data object
297
+ const output = format(outputFormat, [
298
+ result.data,
299
+ ]);
300
+ console.log(output);
301
+ }
302
+ else {
303
+ // For table/csv, format a human-readable summary
304
+ // We know data exists here because result.success is true (guarded above)
305
+ if (!result.data) {
306
+ exitWithError("Unexpected: describe succeeded but returned no data");
307
+ return;
308
+ }
309
+ const data = result.data;
310
+ // Print collection header
311
+ console.log(`\nCollection: ${data.collection}`);
312
+ if (data.version !== undefined) {
313
+ console.log(`Version: ${data.version}`);
314
+ }
315
+ if (data.appendOnly) {
316
+ console.log(`Mode: append-only`);
317
+ }
318
+ console.log("");
319
+ // Print fields as a table
320
+ console.log("Fields:");
321
+ const fieldRecords = data.fields.map((f) => ({
322
+ name: f.name,
323
+ type: f.type,
324
+ required: f.required ? "yes" : "no",
325
+ indexed: f.indexed ? "yes" : "",
326
+ unique: f.unique ? "yes" : "",
327
+ }));
328
+ console.log(format("table", fieldRecords));
329
+ // Print relationships if any
330
+ if (data.relationships.length > 0) {
331
+ console.log("\nRelationships:");
332
+ const relRecords = data.relationships.map((r) => ({
333
+ name: r.name,
334
+ type: r.type,
335
+ target: r.target,
336
+ foreignKey: r.foreignKey ?? "",
337
+ }));
338
+ console.log(format("table", relRecords));
339
+ }
340
+ // Print indexes if any
341
+ if (data.indexes.length > 0) {
342
+ console.log("\nIndexes:");
343
+ for (const index of data.indexes) {
344
+ if (typeof index === "string") {
345
+ console.log(` - ${index}`);
346
+ }
347
+ else {
348
+ console.log(` - [${index.join(", ")}]`);
349
+ }
350
+ }
351
+ }
352
+ // Print unique constraints if any
353
+ if (data.uniqueConstraints.length > 0) {
354
+ console.log("\nUnique Constraints:");
355
+ for (const constraint of data.uniqueConstraints) {
356
+ if (typeof constraint === "string") {
357
+ console.log(` - ${constraint}`);
358
+ }
359
+ else {
360
+ console.log(` - [${constraint.join(", ")}]`);
361
+ }
362
+ }
363
+ }
364
+ // Print search index if configured
365
+ if (data.hasSearchIndex) {
366
+ console.log(`\nSearch Index: [${data.searchIndexFields.join(", ")}]`);
367
+ }
368
+ }
369
+ }
370
+ async function handleStats(args, resolvedConfig) {
371
+ const result = await handleStatsCommand({
372
+ config: resolvedConfig.config,
373
+ configPath: resolvedConfig.configPath,
374
+ });
375
+ if (!result.success) {
376
+ exitWithError(result.message ?? "Failed to get collection stats");
377
+ }
378
+ // Output the results using the appropriate formatter
379
+ const outputFormat = getOutputFormat(args.flags);
380
+ const output = format(outputFormat, (result.data ?? []));
381
+ console.log(output);
382
+ }
383
+ async function handleCreate(args, resolvedConfig) {
384
+ const collectionName = args.positionalArgs[0];
385
+ const dataArg = args.flags.data;
386
+ if (!dataArg) {
387
+ exitWithError("create command requires --data flag with JSON data");
388
+ }
389
+ const result = await handleCreateCommand({
390
+ collection: collectionName,
391
+ config: resolvedConfig.config,
392
+ configPath: resolvedConfig.configPath,
393
+ data: dataArg,
394
+ });
395
+ if (!result.success) {
396
+ exitWithError(result.message ?? "Create failed");
397
+ }
398
+ // Output the created entity using the appropriate formatter
399
+ const outputFormat = getOutputFormat(args.flags);
400
+ const output = format(outputFormat, [result.data]);
401
+ console.log(output);
402
+ }
403
+ async function handleUpdate(args, resolvedConfig) {
404
+ const collectionName = args.positionalArgs[0];
405
+ const entityId = args.positionalArgs[1];
406
+ const setArg = args.flags.set;
407
+ if (!setArg) {
408
+ exitWithError("update command requires --set flag with assignments (e.g., --set 'year=2025,title=New')");
409
+ }
410
+ const result = await handleUpdateCommand({
411
+ collection: collectionName,
412
+ id: entityId,
413
+ config: resolvedConfig.config,
414
+ configPath: resolvedConfig.configPath,
415
+ set: setArg,
416
+ });
417
+ if (!result.success) {
418
+ exitWithError(result.message ?? "Update failed");
419
+ }
420
+ // Output the updated entity using the appropriate formatter
421
+ const outputFormat = getOutputFormat(args.flags);
422
+ const output = format(outputFormat, [result.data]);
423
+ console.log(output);
424
+ }
425
+ async function handleDelete(args, resolvedConfig) {
426
+ const collectionName = args.positionalArgs[0];
427
+ const entityId = args.positionalArgs[1];
428
+ const result = await handleDeleteCommand({
429
+ collection: collectionName,
430
+ id: entityId,
431
+ config: resolvedConfig.config,
432
+ configPath: resolvedConfig.configPath,
433
+ force: args.flags.force,
434
+ });
435
+ if (!result.success) {
436
+ if (result.aborted) {
437
+ // User cancelled - just print the message, don't exit with error
438
+ console.log(result.message ?? "Operation cancelled.");
439
+ return;
440
+ }
441
+ exitWithError(result.message ?? "Delete failed");
442
+ }
443
+ // Print confirmation message
444
+ console.log(result.message);
445
+ }
446
+ async function handleMigrate(args, resolvedConfig) {
447
+ // Detect subcommand from positional args and flags
448
+ const subcommand = detectSubcommand(args.positionalArgs, args.flags.dryRun);
449
+ const result = await handleMigrateCommand({
450
+ config: resolvedConfig.config,
451
+ configPath: resolvedConfig.configPath,
452
+ subcommand,
453
+ force: args.flags.force,
454
+ });
455
+ if (!result.success) {
456
+ if (result.aborted) {
457
+ // User cancelled - just print the message, don't exit with error
458
+ console.log(result.message ?? "Operation cancelled.");
459
+ return;
460
+ }
461
+ exitWithError(result.message ?? "Migration failed");
462
+ }
463
+ // Output the results
464
+ if (result.data) {
465
+ // For status and dry-run, format the collection results
466
+ const outputFormat = getOutputFormat(args.flags);
467
+ // Transform collection data for output
468
+ const records = result.data.collections.map((c) => ({
469
+ collection: c.name,
470
+ file: c.filePath,
471
+ currentVersion: c.currentVersion,
472
+ targetVersion: c.targetVersion,
473
+ status: c.status,
474
+ migrations: c.migrationsToApply.length,
475
+ }));
476
+ const output = format(outputFormat, records);
477
+ console.log(output);
478
+ }
479
+ else if (result.message) {
480
+ console.log(result.message);
481
+ }
482
+ }
483
+ async function handleConvert(args, resolvedConfig) {
484
+ const collectionName = args.positionalArgs[0];
485
+ const targetFormat = args.flags.to;
486
+ if (!targetFormat) {
487
+ exitWithError("convert command requires --to flag with target format (e.g., --to yaml)");
488
+ }
489
+ if (!isValidFormat(targetFormat)) {
490
+ exitWithError(`Invalid target format '${targetFormat}'. Valid formats: ${VALID_FORMATS.join(", ")}`);
491
+ }
492
+ const result = await handleConvertCommand({
493
+ collection: collectionName,
494
+ config: resolvedConfig.config,
495
+ configPath: resolvedConfig.configPath,
496
+ targetFormat,
497
+ });
498
+ if (!result.success) {
499
+ exitWithError(result.message ?? "Convert failed");
500
+ }
501
+ // Output the conversion summary
502
+ const outputFormat = getOutputFormat(args.flags);
503
+ if (result.data) {
504
+ if (outputFormat === "table") {
505
+ console.log(`\nConversion complete:`);
506
+ console.log(` Collection: ${result.data.collection}`);
507
+ console.log(` Old file: ${result.data.oldFile} (${result.data.oldFormat})`);
508
+ console.log(` New file: ${result.data.newFile} (${result.data.newFormat})`);
509
+ if (result.data.configUpdated) {
510
+ console.log(` Config: updated`);
511
+ }
512
+ else {
513
+ console.log(` Config: not updated (manual update may be required)`);
514
+ }
515
+ }
516
+ else {
517
+ const output = format(outputFormat, [
518
+ result.data,
519
+ ]);
520
+ console.log(output);
521
+ }
522
+ }
523
+ }
524
+ /**
525
+ * Commands that do NOT require a loaded config.
526
+ */
527
+ const COMMANDS_WITHOUT_CONFIG = new Set(["init"]);
528
+ /**
529
+ * Main entry point
530
+ */
531
+ async function main() {
532
+ const args = parseArgs(process.argv);
533
+ // Handle global flags first
534
+ if (args.flags.version) {
535
+ printVersion();
536
+ return;
537
+ }
538
+ if (args.flags.help || args.command === undefined) {
539
+ printHelp();
540
+ return;
541
+ }
542
+ // Resolve config for commands that need it
543
+ const needsConfig = !COMMANDS_WITHOUT_CONFIG.has(args.command);
544
+ const resolvedConfig = needsConfig
545
+ ? await resolveConfig(args.flags.config)
546
+ : undefined;
547
+ /**
548
+ * Helper to ensure config is available for commands that need it.
549
+ * This is a type guard that narrows `resolvedConfig` from `ResolvedConfig | undefined`
550
+ * to `ResolvedConfig` for commands that require configuration.
551
+ */
552
+ function requireConfig() {
553
+ if (!resolvedConfig) {
554
+ exitWithError("Configuration is required for this command but was not loaded");
555
+ // TypeScript doesn't know exitWithError never returns, so we add this unreachable return
556
+ throw new Error("Unreachable");
557
+ }
558
+ return resolvedConfig;
559
+ }
560
+ // Dispatch to command handlers
561
+ switch (args.command) {
562
+ case "init":
563
+ await handleInit(args);
564
+ break;
565
+ case "query":
566
+ if (args.positionalArgs.length < 1) {
567
+ exitWithError("query command requires a collection name");
568
+ }
569
+ await handleQuery(args, requireConfig());
570
+ break;
571
+ case "collections":
572
+ await handleCollections(args, requireConfig());
573
+ break;
574
+ case "describe":
575
+ if (args.positionalArgs.length < 1) {
576
+ exitWithError("describe command requires a collection name");
577
+ }
578
+ await handleDescribe(args, requireConfig());
579
+ break;
580
+ case "stats":
581
+ await handleStats(args, requireConfig());
582
+ break;
583
+ case "create":
584
+ if (args.positionalArgs.length < 1) {
585
+ exitWithError("create command requires a collection name");
586
+ }
587
+ await handleCreate(args, requireConfig());
588
+ break;
589
+ case "update":
590
+ if (args.positionalArgs.length < 2) {
591
+ exitWithError("update command requires a collection name and entity ID");
592
+ }
593
+ await handleUpdate(args, requireConfig());
594
+ break;
595
+ case "delete":
596
+ if (args.positionalArgs.length < 2) {
597
+ exitWithError("delete command requires a collection name and entity ID");
598
+ }
599
+ await handleDelete(args, requireConfig());
600
+ break;
601
+ case "migrate":
602
+ await handleMigrate(args, requireConfig());
603
+ break;
604
+ case "convert":
605
+ if (args.positionalArgs.length < 1) {
606
+ exitWithError("convert command requires a collection name");
607
+ }
608
+ await handleConvert(args, requireConfig());
609
+ break;
610
+ default:
611
+ exitWithError(`Unknown command: ${args.command}`);
612
+ }
613
+ }
614
+ // Export for testing
615
+ export { parseArgs, getOutputFormat, printHelp, printVersion, resolveConfig };
616
+ // Run main
617
+ main().catch((error) => {
618
+ console.error("Fatal error:", error);
619
+ process.exit(1);
620
+ });
621
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,iBAAiB,IAAI,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EACN,aAAa,IAAI,oBAAoB,EACrC,aAAa,EACb,aAAa,GACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,cAAc,IAAI,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,EAAE,UAAU,IAAI,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EACN,gBAAgB,EAChB,aAAa,IAAI,oBAAoB,GACrC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,WAAW,IAAI,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAqB,MAAM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C;gBACpC,aAAa,CACZ,yDAAyD,CACzD,CAAC;YACH,CAAC;YACD,MAAM,YAAY,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;YAC1C,MAAM;QAEP,KAAK,SAAS;YACb,MAAM,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;YAC3C,MAAM;QAEP,KAAK,SAAS;YACb,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpC,aAAa,CAAC,4CAA4C,CAAC,CAAC;YAC7D,CAAC;YACD,MAAM,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;YAC3C,MAAM;QAEP;YACC,aAAa,CAAC,oBAAoB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IACpD,CAAC;AACF,CAAC;AAED,qBAAqB;AACrB,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC;AAI9E,WAAW;AACX,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACtB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * ProseQL CLI - CSV Output Formatter
3
+ *
4
+ * Formats records as CSV with proper quoting and comma escaping.
5
+ */
6
+ /**
7
+ * Format records as CSV.
8
+ * Writes header row with all unique field names, then data rows.
9
+ *
10
+ * @param records - Array of records to format
11
+ * @returns CSV string with header and data rows
12
+ */
13
+ export declare function formatAsCsv(records: ReadonlyArray<Record<string, unknown>>): string;
14
+ //# sourceMappingURL=csv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../../src/output/csv.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA+BH;;;;;;GAMG;AACH,wBAAgB,WAAW,CAC1B,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC7C,MAAM,CAuBR"}