postgresai 0.16.0-rc.4 → 0.16.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 +154 -0
- package/dist/bin/postgres-ai.js +2911 -255
- package/package.json +12 -3
- package/schemas/A002.schema.json +63 -0
- package/schemas/A003.schema.json +73 -0
- package/schemas/A004.schema.json +81 -0
- package/schemas/A007.schema.json +71 -0
- package/schemas/A013.schema.json +61 -0
- package/schemas/D001.schema.json +71 -0
- package/schemas/D004.schema.json +136 -0
- package/schemas/F001.schema.json +73 -0
- package/schemas/F002.schema.json +108 -0
- package/schemas/F003.schema.json +138 -0
- package/schemas/F004.schema.json +125 -0
- package/schemas/F005.schema.json +131 -0
- package/schemas/F009.schema.json +155 -0
- package/schemas/G001.schema.json +135 -0
- package/schemas/G003.schema.json +90 -0
- package/schemas/H001.schema.json +141 -0
- package/schemas/H002.schema.json +129 -0
- package/schemas/H004.schema.json +128 -0
- package/schemas/I001.schema.json +149 -0
- package/schemas/K001.schema.json +161 -0
- package/schemas/K003.schema.json +163 -0
- package/schemas/K004.schema.json +110 -0
- package/schemas/K005.schema.json +110 -0
- package/schemas/K006.schema.json +110 -0
- package/schemas/K007.schema.json +110 -0
- package/schemas/K008.schema.json +110 -0
- package/schemas/M001.schema.json +119 -0
- package/schemas/M002.schema.json +110 -0
- package/schemas/M003.schema.json +128 -0
- package/schemas/N001.schema.json +161 -0
- package/schemas/query.schema.json +62 -0
- package/CHANGELOG.md +0 -11
- package/bin/postgres-ai.ts +0 -5578
- package/bun.lock +0 -258
- package/bunfig.toml +0 -20
- package/lib/aas-onboard.ts +0 -251
- package/lib/auth-server.ts +0 -285
- package/lib/checkup-api.ts +0 -526
- package/lib/checkup-dictionary.ts +0 -103
- package/lib/checkup-summary.ts +0 -338
- package/lib/checkup.ts +0 -2261
- package/lib/config.ts +0 -171
- package/lib/init.ts +0 -1152
- package/lib/instances.ts +0 -245
- package/lib/issues.ts +0 -1060
- package/lib/mcp-server.ts +0 -667
- package/lib/metrics-loader.ts +0 -134
- package/lib/pkce.ts +0 -79
- package/lib/reports.ts +0 -373
- package/lib/storage.ts +0 -367
- package/lib/supabase.ts +0 -826
- package/lib/util.ts +0 -134
- package/packages/postgres-ai/README.md +0 -26
- package/packages/postgres-ai/bin/postgres-ai.js +0 -27
- package/packages/postgres-ai/package.json +0 -27
- package/scripts/embed-checkup-dictionary.ts +0 -115
- package/scripts/embed-metrics.ts +0 -160
- package/scripts/generate-release-notes.ts +0 -668
- package/test/PERMISSION_CHECK_TEST_SUMMARY.md +0 -139
- package/test/aas-onboard.test.ts +0 -301
- package/test/auth.test.ts +0 -287
- package/test/checkup.integration.test.ts +0 -413
- package/test/checkup.test.ts +0 -3626
- package/test/compose-cmd.test.ts +0 -120
- package/test/config-consistency.test.ts +0 -352
- package/test/init.integration.test.ts +0 -438
- package/test/init.test.ts +0 -1816
- package/test/issues.cli.test.ts +0 -1162
- package/test/issues.test.ts +0 -456
- package/test/mcp-server.test.ts +0 -2530
- package/test/monitoring.test.ts +0 -746
- package/test/permission-check-sql.test.ts +0 -116
- package/test/reports.cli.test.ts +0 -793
- package/test/reports.test.ts +0 -977
- package/test/schema-validation.test.ts +0 -231
- package/test/storage.test.ts +0 -935
- package/test/supabase.test.ts +0 -709
- package/test/targets-add-config.test.ts +0 -28
- package/test/test-utils.ts +0 -190
- package/test/upgrade.test.ts +0 -1056
- package/test/util.test.ts +0 -44
- package/tsconfig.json +0 -20
package/lib/config.ts
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import * as os from "os";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Configuration object structure
|
|
7
|
-
*/
|
|
8
|
-
export interface Config {
|
|
9
|
-
apiKey: string | null;
|
|
10
|
-
baseUrl: string | null;
|
|
11
|
-
storageBaseUrl: string | null;
|
|
12
|
-
orgId: number | null;
|
|
13
|
-
defaultProject: string | null;
|
|
14
|
-
/** Docker Compose project name for monitoring stack */
|
|
15
|
-
projectName: string | null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Get the user-level config directory path
|
|
20
|
-
* @returns Path to ~/.config/postgresai
|
|
21
|
-
*/
|
|
22
|
-
export function getConfigDir(): string {
|
|
23
|
-
const configHome = process.env.XDG_CONFIG_HOME || path.join(os.homedir(), ".config");
|
|
24
|
-
return path.join(configHome, "postgresai");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Get the user-level config file path
|
|
29
|
-
* @returns Path to ~/.config/postgresai/config.json
|
|
30
|
-
*/
|
|
31
|
-
export function getConfigPath(): string {
|
|
32
|
-
return path.join(getConfigDir(), "config.json");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Get the legacy project-local config file path
|
|
37
|
-
* @returns Path to .pgwatch-config in current directory
|
|
38
|
-
*/
|
|
39
|
-
export function getLegacyConfigPath(): string {
|
|
40
|
-
return path.resolve(process.cwd(), ".pgwatch-config");
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Read configuration from file
|
|
45
|
-
* Tries user-level config first, then falls back to legacy project-local config
|
|
46
|
-
* @returns Configuration object with apiKey, baseUrl, orgId
|
|
47
|
-
*/
|
|
48
|
-
export function readConfig(): Config {
|
|
49
|
-
const config: Config = {
|
|
50
|
-
apiKey: null,
|
|
51
|
-
baseUrl: null,
|
|
52
|
-
storageBaseUrl: null,
|
|
53
|
-
orgId: null,
|
|
54
|
-
defaultProject: null,
|
|
55
|
-
projectName: null,
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// Try user-level config first
|
|
59
|
-
const userConfigPath = getConfigPath();
|
|
60
|
-
if (fs.existsSync(userConfigPath)) {
|
|
61
|
-
try {
|
|
62
|
-
const content = fs.readFileSync(userConfigPath, "utf8");
|
|
63
|
-
const parsed = JSON.parse(content);
|
|
64
|
-
config.apiKey = parsed.apiKey ?? null;
|
|
65
|
-
config.baseUrl = parsed.baseUrl ?? null;
|
|
66
|
-
config.storageBaseUrl = parsed.storageBaseUrl ?? null;
|
|
67
|
-
config.orgId = parsed.orgId ?? null;
|
|
68
|
-
config.defaultProject = parsed.defaultProject ?? null;
|
|
69
|
-
config.projectName = parsed.projectName ?? null;
|
|
70
|
-
return config;
|
|
71
|
-
} catch (err) {
|
|
72
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
73
|
-
console.error(`Warning: Failed to read config from ${userConfigPath}: ${message}`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Fall back to legacy project-local config
|
|
78
|
-
const legacyPath = getLegacyConfigPath();
|
|
79
|
-
if (fs.existsSync(legacyPath)) {
|
|
80
|
-
try {
|
|
81
|
-
const stats = fs.statSync(legacyPath);
|
|
82
|
-
if (stats.isFile()) {
|
|
83
|
-
const content = fs.readFileSync(legacyPath, "utf8");
|
|
84
|
-
const lines = content.split(/\r?\n/);
|
|
85
|
-
for (const line of lines) {
|
|
86
|
-
const match = line.match(/^api_key=(.+)$/);
|
|
87
|
-
if (match) {
|
|
88
|
-
config.apiKey = match[1].trim();
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
} catch (err) {
|
|
94
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
95
|
-
console.error(`Warning: Failed to read legacy config from ${legacyPath}: ${message}`);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return config;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Write configuration to user-level config file
|
|
104
|
-
* @param config - Configuration object with apiKey, baseUrl, orgId
|
|
105
|
-
*/
|
|
106
|
-
export function writeConfig(config: Partial<Config>): void {
|
|
107
|
-
const configDir = getConfigDir();
|
|
108
|
-
const configPath = getConfigPath();
|
|
109
|
-
|
|
110
|
-
// Ensure config directory exists
|
|
111
|
-
if (!fs.existsSync(configDir)) {
|
|
112
|
-
fs.mkdirSync(configDir, { recursive: true, mode: 0o700 });
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Read existing config and merge
|
|
116
|
-
let existingConfig: Record<string, unknown> = {};
|
|
117
|
-
if (fs.existsSync(configPath)) {
|
|
118
|
-
try {
|
|
119
|
-
const content = fs.readFileSync(configPath, "utf8");
|
|
120
|
-
existingConfig = JSON.parse(content);
|
|
121
|
-
} catch (err) {
|
|
122
|
-
// Ignore parse errors, will overwrite
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const mergedConfig = {
|
|
127
|
-
...existingConfig,
|
|
128
|
-
...config,
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// Write config file with restricted permissions
|
|
132
|
-
fs.writeFileSync(configPath, JSON.stringify(mergedConfig, null, 2) + "\n", {
|
|
133
|
-
mode: 0o600,
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Delete specific keys from configuration
|
|
139
|
-
* @param keys - Array of keys to delete (e.g., ['apiKey'])
|
|
140
|
-
*/
|
|
141
|
-
export function deleteConfigKeys(keys: string[]): void {
|
|
142
|
-
const configPath = getConfigPath();
|
|
143
|
-
if (!fs.existsSync(configPath)) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
try {
|
|
148
|
-
const content = fs.readFileSync(configPath, "utf8");
|
|
149
|
-
const config: Record<string, unknown> = JSON.parse(content);
|
|
150
|
-
|
|
151
|
-
for (const key of keys) {
|
|
152
|
-
delete config[key];
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n", {
|
|
156
|
-
mode: 0o600,
|
|
157
|
-
});
|
|
158
|
-
} catch (err) {
|
|
159
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
160
|
-
console.error(`Warning: Failed to update config: ${message}`);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Check if config file exists
|
|
166
|
-
* @returns True if config exists
|
|
167
|
-
*/
|
|
168
|
-
export function configExists(): boolean {
|
|
169
|
-
return fs.existsSync(getConfigPath()) || fs.existsSync(getLegacyConfigPath());
|
|
170
|
-
}
|
|
171
|
-
|