postgresai 0.11.0-alpha.8 → 0.12.0-alpha.13
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 +149 -19
- package/bin/postgres-ai.ts +1095 -0
- package/dist/bin/postgres-ai.d.ts +3 -0
- package/dist/bin/postgres-ai.d.ts.map +1 -0
- package/dist/bin/postgres-ai.js +972 -0
- package/dist/bin/postgres-ai.js.map +1 -0
- package/dist/lib/auth-server.d.ts +31 -0
- package/dist/lib/auth-server.d.ts.map +1 -0
- package/dist/lib/auth-server.js +263 -0
- package/dist/lib/auth-server.js.map +1 -0
- package/dist/lib/config.d.ts +45 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +181 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/issues.d.ts +7 -0
- package/dist/lib/issues.d.ts.map +1 -0
- package/dist/lib/issues.js +105 -0
- package/dist/lib/issues.js.map +1 -0
- package/dist/lib/mcp-server.d.ts +9 -0
- package/dist/lib/mcp-server.d.ts.map +1 -0
- package/dist/lib/mcp-server.js +114 -0
- package/dist/lib/mcp-server.js.map +1 -0
- package/dist/lib/pkce.d.ts +32 -0
- package/dist/lib/pkce.d.ts.map +1 -0
- package/dist/lib/pkce.js +101 -0
- package/dist/lib/pkce.js.map +1 -0
- package/dist/lib/util.d.ts +27 -0
- package/dist/lib/util.d.ts.map +1 -0
- package/dist/lib/util.js +46 -0
- package/dist/lib/util.js.map +1 -0
- package/dist/package.json +43 -0
- package/lib/auth-server.ts +267 -0
- package/lib/config.ts +161 -0
- package/lib/issues.ts +83 -0
- package/lib/mcp-server.ts +98 -0
- package/lib/pkce.ts +79 -0
- package/lib/util.ts +60 -0
- package/package.json +18 -10
- package/tsconfig.json +28 -0
- package/bin/postgres-ai.js +0 -703
package/lib/util.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export function maskSecret(secret: string): string {
|
|
2
|
+
if (!secret) return "";
|
|
3
|
+
if (secret.length <= 8) return "****";
|
|
4
|
+
if (secret.length <= 16) return `${secret.slice(0, 4)}${"*".repeat(secret.length - 8)}${secret.slice(-4)}`;
|
|
5
|
+
return `${secret.slice(0, Math.min(12, secret.length - 8))}${"*".repeat(Math.max(4, secret.length - 16))}${secret.slice(-4)}`;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export interface RootOptsLike {
|
|
10
|
+
apiBaseUrl?: string;
|
|
11
|
+
uiBaseUrl?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ConfigLike {
|
|
15
|
+
baseUrl?: string | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ResolvedBaseUrls {
|
|
19
|
+
apiBaseUrl: string;
|
|
20
|
+
uiBaseUrl: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Normalize a base URL by trimming a single trailing slash and validating.
|
|
25
|
+
* @throws Error if the URL is invalid
|
|
26
|
+
*/
|
|
27
|
+
export function normalizeBaseUrl(value: string): string {
|
|
28
|
+
const trimmed = (value || "").replace(/\/$/, "");
|
|
29
|
+
try {
|
|
30
|
+
// Validate
|
|
31
|
+
// eslint-disable-next-line no-new
|
|
32
|
+
new URL(trimmed);
|
|
33
|
+
} catch {
|
|
34
|
+
throw new Error(`Invalid base URL: ${value}`);
|
|
35
|
+
}
|
|
36
|
+
return trimmed;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Resolve API and UI base URLs using precedence and normalize them.
|
|
41
|
+
* Precedence (API): opts.apiBaseUrl → env.PGAI_API_BASE_URL → cfg.baseUrl → default
|
|
42
|
+
* Precedence (UI): opts.uiBaseUrl → env.PGAI_UI_BASE_URL → default
|
|
43
|
+
*/
|
|
44
|
+
export function resolveBaseUrls(
|
|
45
|
+
opts?: RootOptsLike,
|
|
46
|
+
cfg?: ConfigLike,
|
|
47
|
+
defaults: { apiBaseUrl?: string; uiBaseUrl?: string } = {}
|
|
48
|
+
): ResolvedBaseUrls {
|
|
49
|
+
const defApi = defaults.apiBaseUrl || "https://postgres.ai/api/general/";
|
|
50
|
+
const defUi = defaults.uiBaseUrl || "https://console.postgres.ai";
|
|
51
|
+
|
|
52
|
+
const apiCandidate = (opts?.apiBaseUrl || process.env.PGAI_API_BASE_URL || cfg?.baseUrl || defApi) as string;
|
|
53
|
+
const uiCandidate = (opts?.uiBaseUrl || process.env.PGAI_UI_BASE_URL || defUi) as string;
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
apiBaseUrl: normalizeBaseUrl(apiCandidate),
|
|
57
|
+
uiBaseUrl: normalizeBaseUrl(uiCandidate),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postgresai",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"license": "
|
|
3
|
+
"version": "0.12.0-alpha.13",
|
|
4
|
+
"description": "postgres_ai CLI (Node.js)",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
6
|
"private": false,
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -13,23 +13,31 @@
|
|
|
13
13
|
"url": "https://gitlab.com/postgres-ai/postgres_ai/-/issues"
|
|
14
14
|
},
|
|
15
15
|
"bin": {
|
|
16
|
-
"postgres-ai": "./bin/postgres-ai.js",
|
|
17
|
-
"postgresai": "./bin/postgres-ai.js",
|
|
18
|
-
"pgai": "./bin/postgres-ai.js"
|
|
16
|
+
"postgres-ai": "./dist/bin/postgres-ai.js",
|
|
17
|
+
"postgresai": "./dist/bin/postgres-ai.js",
|
|
18
|
+
"pgai": "./dist/bin/postgres-ai.js"
|
|
19
19
|
},
|
|
20
20
|
"type": "commonjs",
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=18"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
-
"
|
|
25
|
+
"build": "tsc",
|
|
26
|
+
"prepare": "npm run build",
|
|
27
|
+
"start": "node ./dist/bin/postgres-ai.js --help",
|
|
28
|
+
"dev": "tsc --watch"
|
|
26
29
|
},
|
|
27
30
|
"dependencies": {
|
|
28
|
-
"commander": "^12.1.0"
|
|
31
|
+
"commander": "^12.1.0",
|
|
32
|
+
"js-yaml": "^4.1.0",
|
|
33
|
+
"@modelcontextprotocol/sdk": "^1.20.2"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/js-yaml": "^4.0.9",
|
|
37
|
+
"@types/node": "^18.19.0",
|
|
38
|
+
"typescript": "^5.3.3"
|
|
29
39
|
},
|
|
30
40
|
"publishConfig": {
|
|
31
41
|
"access": "public"
|
|
32
42
|
}
|
|
33
43
|
}
|
|
34
|
-
|
|
35
|
-
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "node16",
|
|
5
|
+
"lib": ["ES2020"],
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"moduleResolution": "node16",
|
|
17
|
+
"types": ["node"]
|
|
18
|
+
},
|
|
19
|
+
"include": [
|
|
20
|
+
"bin/**/*",
|
|
21
|
+
"lib/**/*"
|
|
22
|
+
],
|
|
23
|
+
"exclude": [
|
|
24
|
+
"node_modules",
|
|
25
|
+
"dist"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
|