forge-fsql 1.2.0 → 1.3.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.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Forge FSQL CLI
2
2
 
3
+ [![NPM Package](https://img.shields.io/npm/v/forge-fsql.svg?style=flat-square)](https://www.npmjs.org/package/forge-fsql)
4
+
3
5
  Interactive CLI for querying Atlassian Forge SQL databases via web triggers.
4
6
 
5
7
  ## Demo
@@ -15,6 +17,27 @@ Interactive CLI for querying Atlassian Forge SQL databases via web triggers.
15
17
  - ⏱️ Query timing
16
18
  - 📝 Multi-line SQL support
17
19
 
20
+ ## Built in Commands
21
+
22
+ ```sh
23
+ fsql> .help
24
+
25
+ Special Commands:
26
+ .schema Show database schema
27
+ .tables List all tables
28
+ .describe Describe a table (.describe table_name)
29
+ .indexes Show all indexes
30
+ .migrations List all migrations
31
+ .database Show the database name
32
+ .help Show available commands
33
+
34
+ Other:
35
+ exit, quit Exit the CLI
36
+ Ctrl+C Cancel current query
37
+ Ctrl+D Exit the CLI
38
+ ↑/↓ Navigate command history
39
+ ```
40
+
18
41
  ## Security
19
42
 
20
43
  - Disabled in Production - returns a 403 error if you attempt to call it
@@ -8,6 +8,14 @@ exports.parseCommand = parseCommand;
8
8
  const formatter_js_1 = require("./formatter.js");
9
9
  const chalk_1 = __importDefault(require("chalk"));
10
10
  exports.specialCommands = [
11
+ {
12
+ name: ".schema",
13
+ description: "Show database schema",
14
+ execute: async (client) => {
15
+ const result = await client.execute("SELECT table_name, column_name, data_type FROM information_schema.columns WHERE table_schema = DATABASE() ORDER BY table_name, ordinal_position");
16
+ return formatter_js_1.ResultFormatter.formatResult(result);
17
+ },
18
+ },
11
19
  {
12
20
  name: ".tables",
13
21
  description: "List all tables",
@@ -28,10 +36,26 @@ exports.specialCommands = [
28
36
  },
29
37
  },
30
38
  {
31
- name: ".schema",
32
- description: "Show database schema",
39
+ name: ".indexes",
40
+ description: "Show all indexes",
33
41
  execute: async (client) => {
34
- const result = await client.execute("SELECT table_name, column_name, data_type FROM information_schema.columns WHERE table_schema = DATABASE() ORDER BY table_name, ordinal_position");
42
+ const result = await client.execute("SELECT TABLE_NAME, INDEX_NAME, COLUMN_NAME, SEQ_IN_INDEX, NON_UNIQUE FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = DATABASE() ORDER BY CASE WHEN TABLE_NAME = '__migrations' THEN 1 ELSE 0 END, TABLE_NAME, INDEX_NAME, SEQ_IN_INDEX");
43
+ return formatter_js_1.ResultFormatter.formatResult(result);
44
+ },
45
+ },
46
+ {
47
+ name: ".migrations",
48
+ description: "List all migrations",
49
+ execute: async (client) => {
50
+ const result = await client.execute("SELECT * FROM __migrations");
51
+ return formatter_js_1.ResultFormatter.formatResult(result);
52
+ },
53
+ },
54
+ {
55
+ name: ".database",
56
+ description: "Show the database name",
57
+ execute: async (client) => {
58
+ const result = await client.execute("SHOW DATABASES");
35
59
  return formatter_js_1.ResultFormatter.formatResult(result);
36
60
  },
37
61
  },
package/dist/cjs/index.js CHANGED
@@ -56,7 +56,7 @@ class ForgeSqlCli {
56
56
  const url = config.url || process.env.FORGE_SQL_WEBTRIGGER;
57
57
  if (!url) {
58
58
  console.error(chalk_1.default.red("Error: FORGE_SQL_WEBTRIGGER not configured"));
59
- console.error(chalk_1.default.yellow("Set it via environment variable or .env file"));
59
+ console.error("Try rerunning 'fsql-setup'.\n\nSee the Installation docs at https://github.com/chatch/forge-fsql?tab=readme-ov-file#installation");
60
60
  process.exit(1);
61
61
  }
62
62
  this.client = new client_js_1.ForgeClient({
package/dist/commands.js CHANGED
@@ -1,6 +1,14 @@
1
1
  import { ResultFormatter } from "./formatter.js";
2
2
  import chalk from "chalk";
3
3
  export const specialCommands = [
4
+ {
5
+ name: ".schema",
6
+ description: "Show database schema",
7
+ execute: async (client) => {
8
+ const result = await client.execute("SELECT table_name, column_name, data_type FROM information_schema.columns WHERE table_schema = DATABASE() ORDER BY table_name, ordinal_position");
9
+ return ResultFormatter.formatResult(result);
10
+ },
11
+ },
4
12
  {
5
13
  name: ".tables",
6
14
  description: "List all tables",
@@ -21,10 +29,26 @@ export const specialCommands = [
21
29
  },
22
30
  },
23
31
  {
24
- name: ".schema",
25
- description: "Show database schema",
32
+ name: ".indexes",
33
+ description: "Show all indexes",
26
34
  execute: async (client) => {
27
- const result = await client.execute("SELECT table_name, column_name, data_type FROM information_schema.columns WHERE table_schema = DATABASE() ORDER BY table_name, ordinal_position");
35
+ const result = await client.execute("SELECT TABLE_NAME, INDEX_NAME, COLUMN_NAME, SEQ_IN_INDEX, NON_UNIQUE FROM information_schema.STATISTICS WHERE TABLE_SCHEMA = DATABASE() ORDER BY CASE WHEN TABLE_NAME = '__migrations' THEN 1 ELSE 0 END, TABLE_NAME, INDEX_NAME, SEQ_IN_INDEX");
36
+ return ResultFormatter.formatResult(result);
37
+ },
38
+ },
39
+ {
40
+ name: ".migrations",
41
+ description: "List all migrations",
42
+ execute: async (client) => {
43
+ const result = await client.execute("SELECT * FROM __migrations");
44
+ return ResultFormatter.formatResult(result);
45
+ },
46
+ },
47
+ {
48
+ name: ".database",
49
+ description: "Show the database name",
50
+ execute: async (client) => {
51
+ const result = await client.execute("SHOW DATABASES");
28
52
  return ResultFormatter.formatResult(result);
29
53
  },
30
54
  },
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ export class ForgeSqlCli {
15
15
  const url = config.url || process.env.FORGE_SQL_WEBTRIGGER;
16
16
  if (!url) {
17
17
  console.error(chalk.red("Error: FORGE_SQL_WEBTRIGGER not configured"));
18
- console.error(chalk.yellow("Set it via environment variable or .env file"));
18
+ console.error("Try rerunning 'fsql-setup'.\n\nSee the Installation docs at https://github.com/chatch/forge-fsql?tab=readme-ov-file#installation");
19
19
  process.exit(1);
20
20
  }
21
21
  this.client = new ForgeClient({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "forge-fsql",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "description": "Interactive SQL CLI for Atlassian Forge SQL via web triggers",
6
6
  "main": "dist/cjs/index.js",