@hesed/psql 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +293 -0
  3. package/bin/dev.cmd +3 -0
  4. package/bin/dev.js +5 -0
  5. package/bin/run.cmd +3 -0
  6. package/bin/run.js +5 -0
  7. package/dist/commands/psql/auth/add.d.ts +18 -0
  8. package/dist/commands/psql/auth/add.js +57 -0
  9. package/dist/commands/psql/auth/test.d.ts +12 -0
  10. package/dist/commands/psql/auth/test.js +41 -0
  11. package/dist/commands/psql/auth/update.d.ts +18 -0
  12. package/dist/commands/psql/auth/update.js +74 -0
  13. package/dist/commands/psql/databases.d.ts +9 -0
  14. package/dist/commands/psql/databases.js +31 -0
  15. package/dist/commands/psql/describe-table.d.ts +13 -0
  16. package/dist/commands/psql/describe-table.js +39 -0
  17. package/dist/commands/psql/explain-query.d.ts +13 -0
  18. package/dist/commands/psql/explain-query.js +39 -0
  19. package/dist/commands/psql/indexes.d.ts +13 -0
  20. package/dist/commands/psql/indexes.js +39 -0
  21. package/dist/commands/psql/query.d.ts +14 -0
  22. package/dist/commands/psql/query.js +47 -0
  23. package/dist/commands/psql/tables.d.ts +9 -0
  24. package/dist/commands/psql/tables.js +31 -0
  25. package/dist/config.d.ts +13 -0
  26. package/dist/config.js +18 -0
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.js +1 -0
  29. package/dist/psql/config-loader.d.ts +28 -0
  30. package/dist/psql/config-loader.js +26 -0
  31. package/dist/psql/database.d.ts +85 -0
  32. package/dist/psql/database.js +5 -0
  33. package/dist/psql/index.d.ts +3 -0
  34. package/dist/psql/index.js +1 -0
  35. package/dist/psql/postgres-client.d.ts +60 -0
  36. package/dist/psql/postgres-client.js +131 -0
  37. package/dist/psql/postgres-utils.d.ts +72 -0
  38. package/dist/psql/postgres-utils.js +364 -0
  39. package/dist/psql/query-validator.d.ts +38 -0
  40. package/dist/psql/query-validator.js +91 -0
  41. package/oclif.manifest.json +521 -0
  42. package/package.json +103 -0
@@ -0,0 +1,521 @@
1
+ {
2
+ "commands": {
3
+ "psql:databases": {
4
+ "aliases": [],
5
+ "args": {},
6
+ "description": "List all databases accessible on the PostgreSQL server",
7
+ "examples": [
8
+ "<%= config.bin %> <%= command.id %>",
9
+ "<%= config.bin %> <%= command.id %> --profile staging"
10
+ ],
11
+ "flags": {
12
+ "profile": {
13
+ "description": "Database profile name from config",
14
+ "name": "profile",
15
+ "required": false,
16
+ "hasDynamicHelp": false,
17
+ "multiple": false,
18
+ "type": "option"
19
+ }
20
+ },
21
+ "hasDynamicHelp": false,
22
+ "hiddenAliases": [],
23
+ "id": "psql:databases",
24
+ "pluginAlias": "@hesed/psql",
25
+ "pluginName": "@hesed/psql",
26
+ "pluginType": "core",
27
+ "strict": true,
28
+ "enableJsonFlag": false,
29
+ "isESM": true,
30
+ "relativePath": [
31
+ "dist",
32
+ "commands",
33
+ "psql",
34
+ "databases.js"
35
+ ]
36
+ },
37
+ "psql:describe-table": {
38
+ "aliases": [],
39
+ "args": {
40
+ "table": {
41
+ "description": "Table name to describe",
42
+ "name": "table",
43
+ "required": true
44
+ }
45
+ },
46
+ "description": "Describe the structure of a PostgreSQL table",
47
+ "examples": [
48
+ "<%= config.bin %> <%= command.id %> users",
49
+ "<%= config.bin %> <%= command.id %> orders --format json --profile prod"
50
+ ],
51
+ "flags": {
52
+ "format": {
53
+ "description": "Output format",
54
+ "name": "format",
55
+ "default": "table",
56
+ "hasDynamicHelp": false,
57
+ "multiple": false,
58
+ "options": [
59
+ "table",
60
+ "json",
61
+ "toon"
62
+ ],
63
+ "type": "option"
64
+ },
65
+ "profile": {
66
+ "description": "Database profile name from config",
67
+ "name": "profile",
68
+ "required": false,
69
+ "hasDynamicHelp": false,
70
+ "multiple": false,
71
+ "type": "option"
72
+ }
73
+ },
74
+ "hasDynamicHelp": false,
75
+ "hiddenAliases": [],
76
+ "id": "psql:describe-table",
77
+ "pluginAlias": "@hesed/psql",
78
+ "pluginName": "@hesed/psql",
79
+ "pluginType": "core",
80
+ "strict": true,
81
+ "enableJsonFlag": false,
82
+ "isESM": true,
83
+ "relativePath": [
84
+ "dist",
85
+ "commands",
86
+ "psql",
87
+ "describe-table.js"
88
+ ]
89
+ },
90
+ "psql:explain-query": {
91
+ "aliases": [],
92
+ "args": {
93
+ "query": {
94
+ "description": "SQL query to explain",
95
+ "name": "query",
96
+ "required": true
97
+ }
98
+ },
99
+ "description": "Show the execution plan for a PostgreSQL query",
100
+ "examples": [
101
+ "<%= config.bin %> <%= command.id %> \"SELECT * FROM users WHERE id = 1\"",
102
+ "<%= config.bin %> <%= command.id %> \"SELECT * FROM orders JOIN users ON orders.user_id = users.id\" --format json"
103
+ ],
104
+ "flags": {
105
+ "format": {
106
+ "description": "Output format",
107
+ "name": "format",
108
+ "default": "table",
109
+ "hasDynamicHelp": false,
110
+ "multiple": false,
111
+ "options": [
112
+ "table",
113
+ "json",
114
+ "toon"
115
+ ],
116
+ "type": "option"
117
+ },
118
+ "profile": {
119
+ "description": "Database profile name from config",
120
+ "name": "profile",
121
+ "required": false,
122
+ "hasDynamicHelp": false,
123
+ "multiple": false,
124
+ "type": "option"
125
+ }
126
+ },
127
+ "hasDynamicHelp": false,
128
+ "hiddenAliases": [],
129
+ "id": "psql:explain-query",
130
+ "pluginAlias": "@hesed/psql",
131
+ "pluginName": "@hesed/psql",
132
+ "pluginType": "core",
133
+ "strict": true,
134
+ "enableJsonFlag": false,
135
+ "isESM": true,
136
+ "relativePath": [
137
+ "dist",
138
+ "commands",
139
+ "psql",
140
+ "explain-query.js"
141
+ ]
142
+ },
143
+ "psql:indexes": {
144
+ "aliases": [],
145
+ "args": {
146
+ "table": {
147
+ "description": "Table name to show indexes for",
148
+ "name": "table",
149
+ "required": true
150
+ }
151
+ },
152
+ "description": "Show indexes for a PostgreSQL table",
153
+ "examples": [
154
+ "<%= config.bin %> <%= command.id %> users",
155
+ "<%= config.bin %> <%= command.id %> orders --format json --profile prod"
156
+ ],
157
+ "flags": {
158
+ "format": {
159
+ "description": "Output format",
160
+ "name": "format",
161
+ "default": "table",
162
+ "hasDynamicHelp": false,
163
+ "multiple": false,
164
+ "options": [
165
+ "table",
166
+ "json",
167
+ "toon"
168
+ ],
169
+ "type": "option"
170
+ },
171
+ "profile": {
172
+ "description": "Database profile name from config",
173
+ "name": "profile",
174
+ "required": false,
175
+ "hasDynamicHelp": false,
176
+ "multiple": false,
177
+ "type": "option"
178
+ }
179
+ },
180
+ "hasDynamicHelp": false,
181
+ "hiddenAliases": [],
182
+ "id": "psql:indexes",
183
+ "pluginAlias": "@hesed/psql",
184
+ "pluginName": "@hesed/psql",
185
+ "pluginType": "core",
186
+ "strict": true,
187
+ "enableJsonFlag": false,
188
+ "isESM": true,
189
+ "relativePath": [
190
+ "dist",
191
+ "commands",
192
+ "psql",
193
+ "indexes.js"
194
+ ]
195
+ },
196
+ "psql:query": {
197
+ "aliases": [],
198
+ "args": {
199
+ "query": {
200
+ "description": "SQL query to execute",
201
+ "name": "query",
202
+ "required": true
203
+ }
204
+ },
205
+ "description": "Execute a SQL query against a PostgreSQL database",
206
+ "examples": [
207
+ "<%= config.bin %> <%= command.id %> \"SELECT * FROM users LIMIT 10\"",
208
+ "<%= config.bin %> <%= command.id %> \"UPDATE users SET email = 'user@email.com' WHERE id = 999\" --format json",
209
+ "<%= config.bin %> <%= command.id %> \"DELETE FROM sessions\" --profile prod --skip-confirmation"
210
+ ],
211
+ "flags": {
212
+ "format": {
213
+ "description": "Output format",
214
+ "name": "format",
215
+ "default": "table",
216
+ "hasDynamicHelp": false,
217
+ "multiple": false,
218
+ "options": [
219
+ "table",
220
+ "json",
221
+ "csv",
222
+ "toon"
223
+ ],
224
+ "type": "option"
225
+ },
226
+ "profile": {
227
+ "description": "Database profile name from config",
228
+ "name": "profile",
229
+ "required": false,
230
+ "hasDynamicHelp": false,
231
+ "multiple": false,
232
+ "type": "option"
233
+ },
234
+ "skip-confirmation": {
235
+ "description": "Skip confirmation prompt for destructive operations",
236
+ "name": "skip-confirmation",
237
+ "allowNo": false,
238
+ "type": "boolean"
239
+ }
240
+ },
241
+ "hasDynamicHelp": false,
242
+ "hiddenAliases": [],
243
+ "id": "psql:query",
244
+ "pluginAlias": "@hesed/psql",
245
+ "pluginName": "@hesed/psql",
246
+ "pluginType": "core",
247
+ "strict": true,
248
+ "enableJsonFlag": false,
249
+ "isESM": true,
250
+ "relativePath": [
251
+ "dist",
252
+ "commands",
253
+ "psql",
254
+ "query.js"
255
+ ]
256
+ },
257
+ "psql:tables": {
258
+ "aliases": [],
259
+ "args": {},
260
+ "description": "List all tables in the current PostgreSQL database",
261
+ "examples": [
262
+ "<%= config.bin %> <%= command.id %>",
263
+ "<%= config.bin %> <%= command.id %> --profile local"
264
+ ],
265
+ "flags": {
266
+ "profile": {
267
+ "description": "Database profile name from config",
268
+ "name": "profile",
269
+ "required": false,
270
+ "hasDynamicHelp": false,
271
+ "multiple": false,
272
+ "type": "option"
273
+ }
274
+ },
275
+ "hasDynamicHelp": false,
276
+ "hiddenAliases": [],
277
+ "id": "psql:tables",
278
+ "pluginAlias": "@hesed/psql",
279
+ "pluginName": "@hesed/psql",
280
+ "pluginType": "core",
281
+ "strict": true,
282
+ "enableJsonFlag": false,
283
+ "isESM": true,
284
+ "relativePath": [
285
+ "dist",
286
+ "commands",
287
+ "psql",
288
+ "tables.js"
289
+ ]
290
+ },
291
+ "psql:auth:add": {
292
+ "aliases": [],
293
+ "args": {},
294
+ "description": "Add a PostgreSQL connection profile",
295
+ "examples": [
296
+ "<%= config.bin %> <%= command.id %>",
297
+ "<%= config.bin %> <%= command.id %> --no-ssl"
298
+ ],
299
+ "flags": {
300
+ "json": {
301
+ "description": "Format output as json.",
302
+ "helpGroup": "GLOBAL",
303
+ "name": "json",
304
+ "allowNo": false,
305
+ "type": "boolean"
306
+ },
307
+ "database": {
308
+ "char": "d",
309
+ "description": "Database name",
310
+ "name": "database",
311
+ "required": false,
312
+ "hasDynamicHelp": false,
313
+ "multiple": false,
314
+ "type": "option"
315
+ },
316
+ "host": {
317
+ "description": "PostgreSQL host",
318
+ "name": "host",
319
+ "required": false,
320
+ "hasDynamicHelp": false,
321
+ "multiple": false,
322
+ "type": "option"
323
+ },
324
+ "password": {
325
+ "char": "p",
326
+ "description": "Password",
327
+ "name": "password",
328
+ "required": false,
329
+ "hasDynamicHelp": false,
330
+ "multiple": false,
331
+ "type": "option"
332
+ },
333
+ "port": {
334
+ "char": "P",
335
+ "description": "PostgreSQL port",
336
+ "name": "port",
337
+ "required": false,
338
+ "hasDynamicHelp": false,
339
+ "multiple": false,
340
+ "type": "option"
341
+ },
342
+ "profile": {
343
+ "description": "Profile name",
344
+ "name": "profile",
345
+ "required": false,
346
+ "hasDynamicHelp": false,
347
+ "multiple": false,
348
+ "type": "option"
349
+ },
350
+ "ssl": {
351
+ "description": "Use SSL",
352
+ "name": "ssl",
353
+ "required": false,
354
+ "allowNo": true,
355
+ "type": "boolean"
356
+ },
357
+ "user": {
358
+ "char": "u",
359
+ "description": "Username",
360
+ "name": "user",
361
+ "required": false,
362
+ "hasDynamicHelp": false,
363
+ "multiple": false,
364
+ "type": "option"
365
+ }
366
+ },
367
+ "hasDynamicHelp": false,
368
+ "hiddenAliases": [],
369
+ "id": "psql:auth:add",
370
+ "pluginAlias": "@hesed/psql",
371
+ "pluginName": "@hesed/psql",
372
+ "pluginType": "core",
373
+ "strict": true,
374
+ "enableJsonFlag": true,
375
+ "isESM": true,
376
+ "relativePath": [
377
+ "dist",
378
+ "commands",
379
+ "psql",
380
+ "auth",
381
+ "add.js"
382
+ ]
383
+ },
384
+ "psql:auth:test": {
385
+ "aliases": [],
386
+ "args": {},
387
+ "description": "Test PostgreSQL database connection",
388
+ "examples": [
389
+ "<%= config.bin %> <%= command.id %>",
390
+ "<%= config.bin %> <%= command.id %> --profile staging"
391
+ ],
392
+ "flags": {
393
+ "json": {
394
+ "description": "Format output as json.",
395
+ "helpGroup": "GLOBAL",
396
+ "name": "json",
397
+ "allowNo": false,
398
+ "type": "boolean"
399
+ },
400
+ "profile": {
401
+ "description": "Profile name to test",
402
+ "name": "profile",
403
+ "required": false,
404
+ "hasDynamicHelp": false,
405
+ "multiple": false,
406
+ "type": "option"
407
+ }
408
+ },
409
+ "hasDynamicHelp": false,
410
+ "hiddenAliases": [],
411
+ "id": "psql:auth:test",
412
+ "pluginAlias": "@hesed/psql",
413
+ "pluginName": "@hesed/psql",
414
+ "pluginType": "core",
415
+ "strict": true,
416
+ "enableJsonFlag": true,
417
+ "isESM": true,
418
+ "relativePath": [
419
+ "dist",
420
+ "commands",
421
+ "psql",
422
+ "auth",
423
+ "test.js"
424
+ ]
425
+ },
426
+ "psql:auth:update": {
427
+ "aliases": [],
428
+ "args": {},
429
+ "description": "Update an existing PostgreSQL connection profile",
430
+ "examples": [
431
+ "<%= config.bin %> <%= command.id %> --ssl",
432
+ "<%= config.bin %> <%= command.id %> --profile staging"
433
+ ],
434
+ "flags": {
435
+ "json": {
436
+ "description": "Format output as json.",
437
+ "helpGroup": "GLOBAL",
438
+ "name": "json",
439
+ "allowNo": false,
440
+ "type": "boolean"
441
+ },
442
+ "database": {
443
+ "char": "d",
444
+ "description": "Database name",
445
+ "name": "database",
446
+ "required": false,
447
+ "hasDynamicHelp": false,
448
+ "multiple": false,
449
+ "type": "option"
450
+ },
451
+ "host": {
452
+ "description": "PostgreSQL host",
453
+ "name": "host",
454
+ "required": false,
455
+ "hasDynamicHelp": false,
456
+ "multiple": false,
457
+ "type": "option"
458
+ },
459
+ "password": {
460
+ "char": "p",
461
+ "description": "Password",
462
+ "name": "password",
463
+ "required": false,
464
+ "hasDynamicHelp": false,
465
+ "multiple": false,
466
+ "type": "option"
467
+ },
468
+ "port": {
469
+ "char": "P",
470
+ "description": "PostgreSQL port",
471
+ "name": "port",
472
+ "required": false,
473
+ "hasDynamicHelp": false,
474
+ "multiple": false,
475
+ "type": "option"
476
+ },
477
+ "profile": {
478
+ "description": "Profile name to update",
479
+ "name": "profile",
480
+ "required": false,
481
+ "hasDynamicHelp": false,
482
+ "multiple": false,
483
+ "type": "option"
484
+ },
485
+ "ssl": {
486
+ "description": "Use SSL",
487
+ "name": "ssl",
488
+ "required": false,
489
+ "allowNo": true,
490
+ "type": "boolean"
491
+ },
492
+ "user": {
493
+ "char": "u",
494
+ "description": "Username",
495
+ "name": "user",
496
+ "required": false,
497
+ "hasDynamicHelp": false,
498
+ "multiple": false,
499
+ "type": "option"
500
+ }
501
+ },
502
+ "hasDynamicHelp": false,
503
+ "hiddenAliases": [],
504
+ "id": "psql:auth:update",
505
+ "pluginAlias": "@hesed/psql",
506
+ "pluginName": "@hesed/psql",
507
+ "pluginType": "core",
508
+ "strict": true,
509
+ "enableJsonFlag": true,
510
+ "isESM": true,
511
+ "relativePath": [
512
+ "dist",
513
+ "commands",
514
+ "psql",
515
+ "auth",
516
+ "update.js"
517
+ ]
518
+ }
519
+ },
520
+ "version": "0.1.0"
521
+ }
package/package.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "@hesed/psql",
3
+ "description": "CLI for PostgreSQL database interaction",
4
+ "version": "0.1.0",
5
+ "author": "Hesed",
6
+ "bin": {
7
+ "pg": "./bin/run.js"
8
+ },
9
+ "bugs": "https://github.com/hesedcasa/psql/issues",
10
+ "dependencies": {
11
+ "@inquirer/prompts": "^8.3.0",
12
+ "@oclif/core": "^4",
13
+ "@toon-format/toon": "^2.1.0",
14
+ "fs-extra": "^11.3.3",
15
+ "pg": "^8.19.0",
16
+ "yaml": "^2.8.1"
17
+ },
18
+ "devDependencies": {
19
+ "@eslint/compat": "^2",
20
+ "@oclif/prettier-config": "^0.2.1",
21
+ "@types/chai": "^5",
22
+ "@types/fs-extra": "^11.0.4",
23
+ "@types/mocha": "^10",
24
+ "@types/node": "^25",
25
+ "@types/pg": "^8.18.0",
26
+ "@types/sinon": "^21.0.0",
27
+ "c8": "^11.0.0",
28
+ "chai": "^6",
29
+ "eslint": "^9",
30
+ "eslint-config-oclif": "^6",
31
+ "eslint-config-prettier": "^10",
32
+ "esmock": "^2.7.3",
33
+ "mocha": "^11",
34
+ "oclif": "^4",
35
+ "prettier": "^3.8.1",
36
+ "shx": "^0.4.0",
37
+ "sinon": "^21.0.1",
38
+ "ts-node": "^10",
39
+ "ts-prune": "^0.10.3",
40
+ "typescript": "^5"
41
+ },
42
+ "engines": {
43
+ "node": ">=18.0.0"
44
+ },
45
+ "files": [
46
+ "./bin",
47
+ "./dist",
48
+ "./oclif.manifest.json"
49
+ ],
50
+ "homepage": "https://github.com/hesedcasa/psql",
51
+ "keywords": [
52
+ "oclif"
53
+ ],
54
+ "license": "Apache-2.0",
55
+ "main": "dist/index.js",
56
+ "type": "module",
57
+ "oclif": {
58
+ "bin": "pg",
59
+ "dirname": "psql",
60
+ "commands": "./dist/commands",
61
+ "plugins": [
62
+ "@oclif/plugin-*"
63
+ ],
64
+ "topicSeparator": " ",
65
+ "topics": {}
66
+ },
67
+ "repository": "hesedcasa/psql",
68
+ "scripts": {
69
+ "build": "shx rm -rf dist tsconfig.tsbuildinfo && tsc -b",
70
+ "lint": "eslint",
71
+ "postpack": "shx rm -f oclif.manifest.json",
72
+ "posttest": "npm run lint",
73
+ "prepack": "oclif manifest && oclif readme",
74
+ "test": "mocha --forbid-only \"test/**/*.test.ts\"",
75
+ "test:coverage": "c8 npm test",
76
+ "test:coverage:report": "c8 --reporter=html --reporter=text npm test",
77
+ "version": "oclif readme && git add README.md",
78
+ "find-deadcode": "ts-prune --ignore '(run|default)'",
79
+ "format": "eslint --cache --fix --quiet . && prettier --write --cache .",
80
+ "pre-commit": "npm run format && npm run find-deadcode"
81
+ },
82
+ "types": "dist/index.d.ts",
83
+ "c8": {
84
+ "include": [
85
+ "src/**/*.ts"
86
+ ],
87
+ "exclude": [
88
+ "src/**/*.d.ts",
89
+ "test/**/*"
90
+ ],
91
+ "reporter": [
92
+ "text",
93
+ "lcov",
94
+ "html"
95
+ ],
96
+ "all": true,
97
+ "check-coverage": true,
98
+ "lines": 50,
99
+ "functions": 50,
100
+ "branches": 50,
101
+ "statements": 50
102
+ }
103
+ }