forge-fsql 1.0.3 → 1.0.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/README.md +20 -28
- package/dist/cjs/cli.d.ts +1 -0
- package/dist/cjs/client.d.ts +16 -0
- package/dist/cjs/commands.d.ts +12 -0
- package/dist/cjs/execute-sql.d.ts +12 -0
- package/dist/cjs/formatter.d.ts +9 -0
- package/dist/cjs/history.d.ts +10 -0
- package/dist/cjs/index.d.ts +18 -0
- package/dist/cli.d.ts +1 -0
- package/dist/client.d.ts +16 -0
- package/dist/commands.d.ts +12 -0
- package/dist/execute-sql.d.ts +12 -0
- package/dist/formatter.d.ts +9 -0
- package/dist/history.d.ts +10 -0
- package/dist/index.d.ts +18 -0
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -15,8 +15,17 @@ Interactive command-line interface for querying Atlassian Forge SQL databases vi
|
|
|
15
15
|
|
|
16
16
|
### In Your Forge Project
|
|
17
17
|
|
|
18
|
-
```
|
|
19
|
-
|
|
18
|
+
```sh
|
|
19
|
+
npm install -D forge-fsql
|
|
20
|
+
|
|
21
|
+
# add webtrigger to manifest.yml and a wrapper module for the corresponding function
|
|
22
|
+
node_modules/.bin/fsql-setup
|
|
23
|
+
|
|
24
|
+
# deploy with the webtrigger
|
|
25
|
+
forge deploy
|
|
26
|
+
|
|
27
|
+
# get trigger url:
|
|
28
|
+
forge webtrigger create --product Confluence --site <site>.atlassian.net --functionKey execute-sql
|
|
20
29
|
```
|
|
21
30
|
|
|
22
31
|
Add to your `package.json` scripts:
|
|
@@ -24,37 +33,20 @@ Add to your `package.json` scripts:
|
|
|
24
33
|
```json
|
|
25
34
|
{
|
|
26
35
|
"scripts": {
|
|
27
|
-
"
|
|
36
|
+
"fsql": "fsql"
|
|
28
37
|
}
|
|
29
38
|
}
|
|
30
39
|
```
|
|
31
40
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
pnpm add -g forge-fsql
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Configuration
|
|
39
|
-
|
|
40
|
-
Create a `.env` file in your project root:
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
FORGE_SQL_URL=https://your-trigger-url.forge.atlassian.com/sql
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Or pass via command line:
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
fsql --url https://your-trigger-url.com
|
|
50
|
-
```
|
|
41
|
+
## Run
|
|
51
42
|
|
|
52
|
-
|
|
43
|
+
```sh
|
|
44
|
+
# set URL using value from previous step
|
|
45
|
+
export FORGE_SQL_URL=https://your-trigger-url.com
|
|
53
46
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
pnpm sql
|
|
47
|
+
# run fsql!
|
|
48
|
+
npm run fsql
|
|
57
49
|
|
|
58
|
-
#
|
|
59
|
-
fsql
|
|
50
|
+
# or
|
|
51
|
+
npm run fsql --url https://your-trigger-url.com
|
|
60
52
|
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface SqlResult {
|
|
2
|
+
rows?: any[];
|
|
3
|
+
affectedRows?: number;
|
|
4
|
+
error?: string;
|
|
5
|
+
metadata?: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
export interface ClientConfig {
|
|
8
|
+
url: string;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class ForgeClient {
|
|
12
|
+
private config;
|
|
13
|
+
constructor(config: ClientConfig);
|
|
14
|
+
execute(sql: string): Promise<SqlResult>;
|
|
15
|
+
testConnection(): Promise<boolean>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ForgeClient } from "./client.js";
|
|
2
|
+
export interface Command {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
execute: (client: ForgeClient, args?: string) => Promise<string>;
|
|
6
|
+
}
|
|
7
|
+
export declare const specialCommands: Command[];
|
|
8
|
+
export declare function parseCommand(input: string): {
|
|
9
|
+
command?: Command;
|
|
10
|
+
args?: string;
|
|
11
|
+
isSpecial: boolean;
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const executeSql: (req: {
|
|
2
|
+
body: string;
|
|
3
|
+
}) => Promise<ReturnType<typeof getHttpResponse>>;
|
|
4
|
+
declare function getHttpResponse(statusCode: number, body: Record<string, unknown>): {
|
|
5
|
+
headers: {
|
|
6
|
+
"Content-Type": string[];
|
|
7
|
+
};
|
|
8
|
+
statusCode: number;
|
|
9
|
+
statusText: string;
|
|
10
|
+
body: string;
|
|
11
|
+
};
|
|
12
|
+
export { executeSql };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SqlResult } from "./client.js";
|
|
2
|
+
export declare class ResultFormatter {
|
|
3
|
+
static formatTable(rows: any[]): string;
|
|
4
|
+
static formatValue(value: any): string;
|
|
5
|
+
static formatError(error: string): string;
|
|
6
|
+
static formatSuccess(message: string): string;
|
|
7
|
+
static formatResult(result: SqlResult): string;
|
|
8
|
+
static formatQueryTime(ms: number): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { ForgeClient } from "./client.js";
|
|
2
|
+
export { executeSql } from "./execute-sql.js";
|
|
3
|
+
interface CliConfig {
|
|
4
|
+
url?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class ForgeSqlCli {
|
|
7
|
+
private client;
|
|
8
|
+
private rl;
|
|
9
|
+
private history;
|
|
10
|
+
private multilineBuffer;
|
|
11
|
+
private isMultiline;
|
|
12
|
+
constructor(config: CliConfig);
|
|
13
|
+
private setupHandlers;
|
|
14
|
+
private handleLine;
|
|
15
|
+
private executeCommand;
|
|
16
|
+
private handleClose;
|
|
17
|
+
start(): Promise<void>;
|
|
18
|
+
}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface SqlResult {
|
|
2
|
+
rows?: any[];
|
|
3
|
+
affectedRows?: number;
|
|
4
|
+
error?: string;
|
|
5
|
+
metadata?: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
export interface ClientConfig {
|
|
8
|
+
url: string;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class ForgeClient {
|
|
12
|
+
private config;
|
|
13
|
+
constructor(config: ClientConfig);
|
|
14
|
+
execute(sql: string): Promise<SqlResult>;
|
|
15
|
+
testConnection(): Promise<boolean>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ForgeClient } from "./client.js";
|
|
2
|
+
export interface Command {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
execute: (client: ForgeClient, args?: string) => Promise<string>;
|
|
6
|
+
}
|
|
7
|
+
export declare const specialCommands: Command[];
|
|
8
|
+
export declare function parseCommand(input: string): {
|
|
9
|
+
command?: Command;
|
|
10
|
+
args?: string;
|
|
11
|
+
isSpecial: boolean;
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const executeSql: (req: {
|
|
2
|
+
body: string;
|
|
3
|
+
}) => Promise<ReturnType<typeof getHttpResponse>>;
|
|
4
|
+
declare function getHttpResponse(statusCode: number, body: Record<string, unknown>): {
|
|
5
|
+
headers: {
|
|
6
|
+
"Content-Type": string[];
|
|
7
|
+
};
|
|
8
|
+
statusCode: number;
|
|
9
|
+
statusText: string;
|
|
10
|
+
body: string;
|
|
11
|
+
};
|
|
12
|
+
export { executeSql };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SqlResult } from "./client.js";
|
|
2
|
+
export declare class ResultFormatter {
|
|
3
|
+
static formatTable(rows: any[]): string;
|
|
4
|
+
static formatValue(value: any): string;
|
|
5
|
+
static formatError(error: string): string;
|
|
6
|
+
static formatSuccess(message: string): string;
|
|
7
|
+
static formatResult(result: SqlResult): string;
|
|
8
|
+
static formatQueryTime(ms: number): string;
|
|
9
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export { ForgeClient } from "./client.js";
|
|
2
|
+
export { executeSql } from "./execute-sql.js";
|
|
3
|
+
interface CliConfig {
|
|
4
|
+
url?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class ForgeSqlCli {
|
|
7
|
+
private client;
|
|
8
|
+
private rl;
|
|
9
|
+
private history;
|
|
10
|
+
private multilineBuffer;
|
|
11
|
+
private isMultiline;
|
|
12
|
+
constructor(config: CliConfig);
|
|
13
|
+
private setupHandlers;
|
|
14
|
+
private handleLine;
|
|
15
|
+
private executeCommand;
|
|
16
|
+
private handleClose;
|
|
17
|
+
start(): Promise<void>;
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "forge-fsql",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Interactive SQL CLI for Atlassian Forge SQL via web triggers",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -12,9 +12,14 @@
|
|
|
12
12
|
},
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
|
-
"import":
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
"import": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"require": {
|
|
20
|
+
"types": "./dist/cjs/index.d.ts",
|
|
21
|
+
"default": "./dist/cjs/index.js"
|
|
22
|
+
}
|
|
18
23
|
}
|
|
19
24
|
},
|
|
20
25
|
"files": [
|