postgresai 0.18.0-rc.1 → 0.18.0-rc.3
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 +16 -5
- package/dist/bin/postgres-ai.js +143 -149
- package/package.json +1 -1
- package/schemas/A014.schema.json +391 -0
package/README.md
CHANGED
|
@@ -787,6 +787,17 @@ pgai orgs create --name "My team" --alias my-team --json
|
|
|
787
787
|
- You become the owner and an Admin member. No organization selection is sent, and your saved configuration does not change. Use the returned alias with `--org` afterwards.
|
|
788
788
|
- Requires the Platform change https://gitlab.com/postgres-ai/platform-all/-/merge_requests/1157 to be deployed.
|
|
789
789
|
|
|
790
|
+
### Check for a payment method on file
|
|
791
|
+
|
|
792
|
+
```bash
|
|
793
|
+
pgai billing status --org my-team # Payment method on file for my-team.
|
|
794
|
+
pgai billing status --org my-team --json # {"org", "has_payment_method", "billing_url"}
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
- Exit 0: a payment method is on file. Exit 3: none; add one at `billing_url`. Exit 1: an error, or it could not be checked just now.
|
|
798
|
+
- It is the check `pgai mon deploy` and `pgai dblab deploy` make before they create anything. Any member of the organization can run it.
|
|
799
|
+
- Read-only and safe to repeat, so a script or an agent can wait for the card while you add it. It checks no promo code: a coupon is checked only by the deploy.
|
|
800
|
+
|
|
790
801
|
## Configuration
|
|
791
802
|
|
|
792
803
|
The CLI stores configuration in `~/.config/postgresai/config.json` including:
|
|
@@ -953,16 +964,16 @@ provider-specific behavior.
|
|
|
953
964
|
| Schema-valid JSON reports | Local (CLI) | Yes |
|
|
954
965
|
| Severity summaries (`summary`: `status` + `message`) | Local (CLI) | Yes |
|
|
955
966
|
| Local conclusions/recommendations for the checks that implement them (e.g. F003, H001) | Local (CLI) | Yes |
|
|
956
|
-
|
|
|
967
|
+
| Issues with findings and recommendations | **Server-side** (PostgresAI) | No — requires an API key |
|
|
957
968
|
|
|
958
969
|
In short: the local embed gives you structured JSON, per-check severity, and
|
|
959
|
-
the conclusions each check implements today.
|
|
960
|
-
|
|
970
|
+
the conclusions each check implements today. Issues with findings are a
|
|
971
|
+
PostgresAI capability on the server side. Embedders that only need structured findings and severity
|
|
961
972
|
never have to call the API.
|
|
962
973
|
|
|
963
974
|
For every new or updated check, local JSON must include `conclusions` and
|
|
964
|
-
`recommendations`. Server-side
|
|
965
|
-
|
|
975
|
+
`recommendations`. Server-side issues can enrich those verdicts, but must never
|
|
976
|
+
be their only source. The coverage checklist in
|
|
966
977
|
[work item #285](https://gitlab.com/postgres-ai/postgresai/-/work_items/285)
|
|
967
978
|
tracks which existing checks have completed this migration.
|
|
968
979
|
|
package/dist/bin/postgres-ai.js
CHANGED
|
@@ -13538,7 +13538,7 @@ var {
|
|
|
13538
13538
|
// package.json
|
|
13539
13539
|
var package_default = {
|
|
13540
13540
|
name: "postgresai",
|
|
13541
|
-
version: "0.18.0-rc.
|
|
13541
|
+
version: "0.18.0-rc.3",
|
|
13542
13542
|
description: "postgres_ai CLI",
|
|
13543
13543
|
license: "Apache-2.0",
|
|
13544
13544
|
private: false,
|
|
@@ -16898,7 +16898,7 @@ var Result = import_lib.default.Result;
|
|
|
16898
16898
|
var TypeOverrides = import_lib.default.TypeOverrides;
|
|
16899
16899
|
var defaults = import_lib.default.defaults;
|
|
16900
16900
|
// package.json
|
|
16901
|
-
var version = "0.18.0-rc.
|
|
16901
|
+
var version = "0.18.0-rc.3";
|
|
16902
16902
|
var package_default2 = {
|
|
16903
16903
|
name: "postgresai",
|
|
16904
16904
|
version,
|
|
@@ -24160,6 +24160,19 @@ var VERIFY_FAILED = {
|
|
|
24160
24160
|
auth_failed: `The monitoring box reached the database, but ${DEFAULT_MONITORING_USER} could not log in with the password this deploy's SQL set: the SQL did not run there, or another setup ran its SQL after it.`,
|
|
24161
24161
|
nonce_mismatch: "The database's newest PostgresAI setup is not this deploy's: its SQL did not run in this database, or a newer one ran after it (another deploy, or the Console), so monitoring does not start."
|
|
24162
24162
|
};
|
|
24163
|
+
async function privateLinkOf(d, rdsStatus) {
|
|
24164
|
+
if (disconnecting(d.status))
|
|
24165
|
+
return;
|
|
24166
|
+
if (d.privatelink !== undefined)
|
|
24167
|
+
return d.privatelink ? { id: d.id, instance_status: d.status, dashboard_url: d.dashboard_url, ...d.privatelink } : undefined;
|
|
24168
|
+
if (!rdsStatus)
|
|
24169
|
+
return;
|
|
24170
|
+
if (d.cluster && d.provider !== "rds" && d.provider !== "aurora")
|
|
24171
|
+
return;
|
|
24172
|
+
return rdsStatus(d.id).catch(() => {
|
|
24173
|
+
return;
|
|
24174
|
+
});
|
|
24175
|
+
}
|
|
24163
24176
|
var utc = (iso) => {
|
|
24164
24177
|
const d = new Date(iso);
|
|
24165
24178
|
return Number.isNaN(d.getTime()) ? iso : `${d.toISOString().slice(0, 19).replace("T", " ")} UTC`;
|
|
@@ -24200,10 +24213,8 @@ async function deployPrivateLink(url, route, opts, deps, progress) {
|
|
|
24200
24213
|
}
|
|
24201
24214
|
const rows = await deps.list();
|
|
24202
24215
|
const live = rows.filter((d) => !disconnecting(d.status));
|
|
24203
|
-
const onServer = live.filter((d) => d.cluster && serverOf(d.cluster) === cluster);
|
|
24204
|
-
const verify = async (row) => VERIFY_FAILED[(await deps.rdsStatus
|
|
24205
|
-
return;
|
|
24206
|
-
}))?.verified_status ?? ""];
|
|
24216
|
+
const onServer = live.filter((d) => d.cluster && serverOf(d.cluster) === cluster || d.privatelink?.rds_endpoint.toLowerCase().replace(/\.$/, "") === ep.host);
|
|
24217
|
+
const verify = async (row) => VERIFY_FAILED[(await privateLinkOf(row, deps.rdsStatus))?.verified_status ?? ""];
|
|
24207
24218
|
const own = onServer.find((d) => (d.provider === "rds" || d.provider === "aurora") && d.database != null && decodeURIComponent(d.database) === db);
|
|
24208
24219
|
if (own) {
|
|
24209
24220
|
const note = opts.vpceService || opts.hostStatsRole ? "; the flags for a new box were not used: it exists" : "";
|
|
@@ -24214,8 +24225,8 @@ async function deployPrivateLink(url, route, opts, deps, progress) {
|
|
|
24214
24225
|
return stop(`${ep.id} is already monitored ${how} (instance ${d.name}). Setting up another instance would change ${DEFAULT_MONITORING_USER}'s password, which that instance logs in with. ${instead}, delete that instance first (pgai mon instances delete ${deleteRef(d, rows)})`);
|
|
24215
24226
|
};
|
|
24216
24227
|
if (onServer.length)
|
|
24217
|
-
return already(onServer[0], onServer[0].provider === "rds" ? `over ${PL}, database ${decodeURIComponent(onServer[0].database ?? "?")}` : "directly");
|
|
24218
|
-
const candidates = live.filter((r) => !r.cluster || r.provider === "rds" || r.provider === "aurora");
|
|
24228
|
+
return already(onServer[0], onServer[0].privatelink || onServer[0].provider === "rds" ? `over ${PL}, database ${decodeURIComponent(onServer[0].database ?? "?")}` : "directly");
|
|
24229
|
+
const candidates = live.filter((r) => r.privatelink === undefined && (!r.cluster || r.provider === "rds" || r.provider === "aurora"));
|
|
24219
24230
|
let routes;
|
|
24220
24231
|
try {
|
|
24221
24232
|
routes = await Promise.all(candidates.map((d) => deps.rdsStatus?.(d.id).catch((err) => {
|
|
@@ -24285,6 +24296,7 @@ async function deployPrivateLink(url, route, opts, deps, progress) {
|
|
|
24285
24296
|
rds_port: port,
|
|
24286
24297
|
rds_database: db,
|
|
24287
24298
|
region: ep.region,
|
|
24299
|
+
nonce: role.nonce,
|
|
24288
24300
|
...b.accepted ? { accept_price: true } : {},
|
|
24289
24301
|
...opts.coupon ? { promo_code: opts.coupon } : {},
|
|
24290
24302
|
...stack.roleArn ? { host_stats_role_arn: stack.roleArn } : {},
|
|
@@ -24953,7 +24965,7 @@ function grafanaOAuthUrl(dashboardUrl) {
|
|
|
24953
24965
|
return `${u.origin}/login/generic_oauth?redirectTo=${encodeURIComponent(`${u.pathname}${u.search}`)}`;
|
|
24954
24966
|
}
|
|
24955
24967
|
function platformDeps(p) {
|
|
24956
|
-
const rpc = (fn, body = {}, timeoutMs) => callRpc({
|
|
24968
|
+
const rpc = (fn, body = {}, timeoutMs, fallbackBody) => callRpc({
|
|
24957
24969
|
apiKey: p.apiKey,
|
|
24958
24970
|
apiBaseUrl: p.apiBaseUrl,
|
|
24959
24971
|
fn,
|
|
@@ -24961,7 +24973,8 @@ function platformDeps(p) {
|
|
|
24961
24973
|
operation: fn.replace(/_/g, " "),
|
|
24962
24974
|
debug: p.debug,
|
|
24963
24975
|
orgScope: p.orgScope,
|
|
24964
|
-
...timeoutMs ? { timeoutMs, timeoutCeilingMs: timeoutMs } : {}
|
|
24976
|
+
...timeoutMs ? { timeoutMs, timeoutCeilingMs: timeoutMs } : {},
|
|
24977
|
+
...fallbackBody ? { fallbackBody } : {}
|
|
24965
24978
|
});
|
|
24966
24979
|
let orgAlias;
|
|
24967
24980
|
let projects;
|
|
@@ -25032,7 +25045,10 @@ function platformDeps(p) {
|
|
|
25032
25045
|
deployOptions: (args) => rpc("monitoring_deploy_options", args),
|
|
25033
25046
|
rdsExternalId: async () => (await rpc("cloud_monitoring_rds_external_id")).external_id,
|
|
25034
25047
|
rdsPrepareSql: (dbName) => rpc("cloud_monitoring_rds_prepare_sql", { db_name: dbName }),
|
|
25035
|
-
rdsProvision: (body) =>
|
|
25048
|
+
rdsProvision: (body) => {
|
|
25049
|
+
const { nonce: _nonce, ...older } = body;
|
|
25050
|
+
return rpc("cloud_monitoring_rds_provision", body, p.agent ? AGENT_CONNECT_TIMEOUT_MS : CONNECT_TIMEOUT_MS, older);
|
|
25051
|
+
},
|
|
25036
25052
|
rdsStatus: (id) => rpc("cloud_monitoring_rds_status", { instance_id: id }),
|
|
25037
25053
|
aws: awsRunner,
|
|
25038
25054
|
awsProfiles: () => new Promise((resolve) => execFile2("aws", ["configure", "list-profiles"], { timeout: 1e4 }, (err, stdout) => resolve(err ? [] : stdout.split(`
|
|
@@ -32080,7 +32096,7 @@ async function handleToolCall(req, rootOpts, extra) {
|
|
|
32080
32096
|
if (reportId !== undefined && isNaN(reportId)) {
|
|
32081
32097
|
return { content: [{ type: "text", text: "report_id must be a number" }], isError: true };
|
|
32082
32098
|
}
|
|
32083
|
-
const type = args.type ? String(args.type) :
|
|
32099
|
+
const type = args.type ? String(args.type) : "json";
|
|
32084
32100
|
const checkId = args.check_id ? String(args.check_id) : undefined;
|
|
32085
32101
|
if (reportId === undefined && !checkId) {
|
|
32086
32102
|
return { content: [{ type: "text", text: "Either report_id or check_id is required" }], isError: true };
|
|
@@ -32096,7 +32112,7 @@ async function handleToolCall(req, rootOpts, extra) {
|
|
|
32096
32112
|
if (reportId !== undefined && isNaN(reportId)) {
|
|
32097
32113
|
return { content: [{ type: "text", text: "report_id must be a number" }], isError: true };
|
|
32098
32114
|
}
|
|
32099
|
-
const type = args.type ? String(args.type) :
|
|
32115
|
+
const type = args.type ? String(args.type) : "json";
|
|
32100
32116
|
const checkId = args.check_id ? String(args.check_id) : undefined;
|
|
32101
32117
|
if (reportId === undefined && !checkId) {
|
|
32102
32118
|
return { content: [{ type: "text", text: "Either report_id or check_id is required" }], isError: true };
|
|
@@ -32405,13 +32421,13 @@ async function startMcpServer(rootOpts, extra) {
|
|
|
32405
32421
|
},
|
|
32406
32422
|
{
|
|
32407
32423
|
name: "list_report_files",
|
|
32408
|
-
description: "List files in a checkup report (metadata only, no content).
|
|
32424
|
+
description: "List files in a checkup report (metadata only, no content). Checkup reports are JSON, one file per check. Either report_id or check_id must be provided. For findings and recommendations, use the issues tools (list_issues, view_issue).",
|
|
32409
32425
|
inputSchema: {
|
|
32410
32426
|
type: "object",
|
|
32411
32427
|
properties: {
|
|
32412
32428
|
...ORG_ID_TOOL_PROPERTY,
|
|
32413
32429
|
report_id: { type: "number", description: "Checkup report ID (optional if check_id is provided)" },
|
|
32414
|
-
type: { type: "string",
|
|
32430
|
+
type: { type: "string", enum: ["json", "md"], description: "File type: 'json' (default), or 'md' for markdown that the legacy postgres-checkup tool uploaded" },
|
|
32415
32431
|
check_id: { type: "string", description: "Filter by check ID (e.g., 'H002', 'F004')" },
|
|
32416
32432
|
debug: { type: "boolean", description: "Enable verbose debug logs" }
|
|
32417
32433
|
},
|
|
@@ -32420,13 +32436,13 @@ async function startMcpServer(rootOpts, extra) {
|
|
|
32420
32436
|
},
|
|
32421
32437
|
{
|
|
32422
32438
|
name: "get_report_data",
|
|
32423
|
-
description: "Get checkup report file content
|
|
32439
|
+
description: "Get checkup report file content: the JSON data of each check, in a 'data' field. Either report_id or check_id must be provided. For findings and recommendations, use the issues tools (list_issues, view_issue).",
|
|
32424
32440
|
inputSchema: {
|
|
32425
32441
|
type: "object",
|
|
32426
32442
|
properties: {
|
|
32427
32443
|
...ORG_ID_TOOL_PROPERTY,
|
|
32428
32444
|
report_id: { type: "number", description: "Checkup report ID (optional if check_id is provided)" },
|
|
32429
|
-
type: { type: "string",
|
|
32445
|
+
type: { type: "string", enum: ["json", "md"], description: "File type: 'json' (default), or 'md' for markdown that the legacy postgres-checkup tool uploaded" },
|
|
32430
32446
|
check_id: { type: "string", description: "Filter by check ID (e.g., 'H002', 'F004')" },
|
|
32431
32447
|
debug: { type: "boolean", description: "Enable verbose debug logs" }
|
|
32432
32448
|
},
|
|
@@ -34581,8 +34597,12 @@ var VERIFY_FAILED2 = {
|
|
|
34581
34597
|
auth_failed: `The monitoring box reached the database, but ${DEFAULT_MONITORING_USER} could not log in with the password this deploy's SQL set: the SQL did not run there, or another setup ran its SQL after it.`,
|
|
34582
34598
|
nonce_mismatch: "The database's newest PostgresAI setup is not this deploy's: its SQL did not run in this database, or a newer one ran after it (another deploy, or the Console), so monitoring does not start."
|
|
34583
34599
|
};
|
|
34584
|
-
async function
|
|
34585
|
-
if (
|
|
34600
|
+
async function privateLinkOf2(d, rdsStatus) {
|
|
34601
|
+
if (disconnecting2(d.status))
|
|
34602
|
+
return;
|
|
34603
|
+
if (d.privatelink !== undefined)
|
|
34604
|
+
return d.privatelink ? { id: d.id, instance_status: d.status, dashboard_url: d.dashboard_url, ...d.privatelink } : undefined;
|
|
34605
|
+
if (!rdsStatus)
|
|
34586
34606
|
return;
|
|
34587
34607
|
if (d.cluster && d.provider !== "rds" && d.provider !== "aurora")
|
|
34588
34608
|
return;
|
|
@@ -34640,10 +34660,8 @@ async function deployPrivateLink2(url, route, opts, deps, progress) {
|
|
|
34640
34660
|
}
|
|
34641
34661
|
const rows = await deps.list();
|
|
34642
34662
|
const live = rows.filter((d) => !disconnecting2(d.status));
|
|
34643
|
-
const onServer = live.filter((d) => d.cluster && serverOf2(d.cluster) === cluster);
|
|
34644
|
-
const verify = async (row) => VERIFY_FAILED2[(await deps.rdsStatus
|
|
34645
|
-
return;
|
|
34646
|
-
}))?.verified_status ?? ""];
|
|
34663
|
+
const onServer = live.filter((d) => d.cluster && serverOf2(d.cluster) === cluster || d.privatelink?.rds_endpoint.toLowerCase().replace(/\.$/, "") === ep.host);
|
|
34664
|
+
const verify = async (row) => VERIFY_FAILED2[(await privateLinkOf2(row, deps.rdsStatus))?.verified_status ?? ""];
|
|
34647
34665
|
const own = onServer.find((d) => (d.provider === "rds" || d.provider === "aurora") && d.database != null && decodeURIComponent(d.database) === db);
|
|
34648
34666
|
if (own) {
|
|
34649
34667
|
const note = opts.vpceService || opts.hostStatsRole ? "; the flags for a new box were not used: it exists" : "";
|
|
@@ -34654,8 +34672,8 @@ async function deployPrivateLink2(url, route, opts, deps, progress) {
|
|
|
34654
34672
|
return stop(`${ep.id} is already monitored ${how} (instance ${d.name}). Setting up another instance would change ${DEFAULT_MONITORING_USER}'s password, which that instance logs in with. ${instead}, delete that instance first (pgai mon instances delete ${deleteRef2(d, rows)})`);
|
|
34655
34673
|
};
|
|
34656
34674
|
if (onServer.length)
|
|
34657
|
-
return already(onServer[0], onServer[0].provider === "rds" ? `over ${PL2}, database ${decodeURIComponent(onServer[0].database ?? "?")}` : "directly");
|
|
34658
|
-
const candidates = live.filter((r) => !r.cluster || r.provider === "rds" || r.provider === "aurora");
|
|
34675
|
+
return already(onServer[0], onServer[0].privatelink || onServer[0].provider === "rds" ? `over ${PL2}, database ${decodeURIComponent(onServer[0].database ?? "?")}` : "directly");
|
|
34676
|
+
const candidates = live.filter((r) => r.privatelink === undefined && (!r.cluster || r.provider === "rds" || r.provider === "aurora"));
|
|
34659
34677
|
let routes;
|
|
34660
34678
|
try {
|
|
34661
34679
|
routes = await Promise.all(candidates.map((d) => deps.rdsStatus?.(d.id).catch((err) => {
|
|
@@ -34725,6 +34743,7 @@ async function deployPrivateLink2(url, route, opts, deps, progress) {
|
|
|
34725
34743
|
rds_port: port,
|
|
34726
34744
|
rds_database: db,
|
|
34727
34745
|
region: ep.region,
|
|
34746
|
+
nonce: role.nonce,
|
|
34728
34747
|
...b.accepted ? { accept_price: true } : {},
|
|
34729
34748
|
...opts.coupon ? { promo_code: opts.coupon } : {},
|
|
34730
34749
|
...stack.roleArn ? { host_stats_role_arn: stack.roleArn } : {},
|
|
@@ -35409,7 +35428,7 @@ function grafanaOAuthUrl2(dashboardUrl) {
|
|
|
35409
35428
|
return `${u.origin}/login/generic_oauth?redirectTo=${encodeURIComponent(`${u.pathname}${u.search}`)}`;
|
|
35410
35429
|
}
|
|
35411
35430
|
function platformDeps2(p) {
|
|
35412
|
-
const rpc = (fn, body = {}, timeoutMs) => callRpc({
|
|
35431
|
+
const rpc = (fn, body = {}, timeoutMs, fallbackBody) => callRpc({
|
|
35413
35432
|
apiKey: p.apiKey,
|
|
35414
35433
|
apiBaseUrl: p.apiBaseUrl,
|
|
35415
35434
|
fn,
|
|
@@ -35417,7 +35436,8 @@ function platformDeps2(p) {
|
|
|
35417
35436
|
operation: fn.replace(/_/g, " "),
|
|
35418
35437
|
debug: p.debug,
|
|
35419
35438
|
orgScope: p.orgScope,
|
|
35420
|
-
...timeoutMs ? { timeoutMs, timeoutCeilingMs: timeoutMs } : {}
|
|
35439
|
+
...timeoutMs ? { timeoutMs, timeoutCeilingMs: timeoutMs } : {},
|
|
35440
|
+
...fallbackBody ? { fallbackBody } : {}
|
|
35421
35441
|
});
|
|
35422
35442
|
let orgAlias;
|
|
35423
35443
|
let projects;
|
|
@@ -35488,7 +35508,10 @@ function platformDeps2(p) {
|
|
|
35488
35508
|
deployOptions: (args) => rpc("monitoring_deploy_options", args),
|
|
35489
35509
|
rdsExternalId: async () => (await rpc("cloud_monitoring_rds_external_id")).external_id,
|
|
35490
35510
|
rdsPrepareSql: (dbName) => rpc("cloud_monitoring_rds_prepare_sql", { db_name: dbName }),
|
|
35491
|
-
rdsProvision: (body) =>
|
|
35511
|
+
rdsProvision: (body) => {
|
|
35512
|
+
const { nonce: _nonce, ...older } = body;
|
|
35513
|
+
return rpc("cloud_monitoring_rds_provision", body, p.agent ? AGENT_CONNECT_TIMEOUT_MS2 : CONNECT_TIMEOUT_MS2, older);
|
|
35514
|
+
},
|
|
35492
35515
|
rdsStatus: (id) => rpc("cloud_monitoring_rds_status", { instance_id: id }),
|
|
35493
35516
|
aws: awsRunner,
|
|
35494
35517
|
awsProfiles: () => new Promise((resolve) => execFile3("aws", ["configure", "list-profiles"], { timeout: 1e4 }, (err, stdout) => resolve(err ? [] : stdout.split(`
|
|
@@ -37197,6 +37220,51 @@ function registerDblabAccessCommands(dblab, deps) {
|
|
|
37197
37220
|
});
|
|
37198
37221
|
}
|
|
37199
37222
|
|
|
37223
|
+
// lib/billing.ts
|
|
37224
|
+
function billingExit(s) {
|
|
37225
|
+
if (s.has_payment_method === true)
|
|
37226
|
+
return 0;
|
|
37227
|
+
if (s.has_payment_method === false)
|
|
37228
|
+
return 3;
|
|
37229
|
+
return 1;
|
|
37230
|
+
}
|
|
37231
|
+
async function billingStatus(api, uiBaseUrl) {
|
|
37232
|
+
const options = await callDeployRpc(api, "dblab_cloud_deploy_options", {}, "Payment method check");
|
|
37233
|
+
const org = options.org_alias ?? null;
|
|
37234
|
+
const has = options.has_payment_method;
|
|
37235
|
+
return {
|
|
37236
|
+
org,
|
|
37237
|
+
has_payment_method: typeof has === "boolean" ? has : null,
|
|
37238
|
+
billing_url: org ? billingPage(uiBaseUrl, org) : null
|
|
37239
|
+
};
|
|
37240
|
+
}
|
|
37241
|
+
function billingStatusLine(s, uiBaseUrl) {
|
|
37242
|
+
const org = s.org ?? "this organization";
|
|
37243
|
+
const page = s.billing_url ?? billingPage(uiBaseUrl, null);
|
|
37244
|
+
if (s.has_payment_method === true)
|
|
37245
|
+
return `Payment method on file for ${org}.`;
|
|
37246
|
+
if (s.has_payment_method === false)
|
|
37247
|
+
return `No payment method on file for ${org}. Add one at ${page}`;
|
|
37248
|
+
return `Could not check whether ${org} has a payment method on file. Try again in a minute; ` + `if this keeps happening, open ${page} or contact support@postgres.ai.`;
|
|
37249
|
+
}
|
|
37250
|
+
function registerBillingCommands(program, deps) {
|
|
37251
|
+
const billing = program.command("billing").description("check whether the organization has a payment method on file (billing status)");
|
|
37252
|
+
deps.withOrgOptions(billing.command("status")).description("whether the organization has a payment method on file (read-only; exit 0 yes, 3 no, 1 error or could not check)").option("--json", "JSON output").option("--debug", "print HTTP requests (secrets masked)").action(async (opts) => {
|
|
37253
|
+
try {
|
|
37254
|
+
const ui = deps.uiBaseUrl?.();
|
|
37255
|
+
const status = await billingStatus(deps.resolveApi(!!opts.debug), ui);
|
|
37256
|
+
if (jsonOutput(opts.json))
|
|
37257
|
+
deps.printResult(status, true);
|
|
37258
|
+
else
|
|
37259
|
+
console.log(billingStatusLine(status, ui));
|
|
37260
|
+
process.exitCode = billingExit(status);
|
|
37261
|
+
} catch (err) {
|
|
37262
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
37263
|
+
process.exitCode = 1;
|
|
37264
|
+
}
|
|
37265
|
+
});
|
|
37266
|
+
}
|
|
37267
|
+
|
|
37200
37268
|
// lib/deploy.ts
|
|
37201
37269
|
var MONITORING_STEPS = [
|
|
37202
37270
|
{ key: "preparing", label: "Prepare the database" },
|
|
@@ -42916,6 +42984,14 @@ var CHECKUP_DICTIONARY_DATA = [
|
|
|
42916
42984
|
category: "vacuum",
|
|
42917
42985
|
sort_order: null,
|
|
42918
42986
|
is_system_report: false
|
|
42987
|
+
},
|
|
42988
|
+
{
|
|
42989
|
+
code: "A014",
|
|
42990
|
+
title: "Resource sizing",
|
|
42991
|
+
description: "CPU, memory, disk I/O and connections against the compute tier",
|
|
42992
|
+
category: "system",
|
|
42993
|
+
sort_order: null,
|
|
42994
|
+
is_system_report: false
|
|
42919
42995
|
}
|
|
42920
42996
|
];
|
|
42921
42997
|
|
|
@@ -45675,8 +45751,7 @@ async function uploadCheckupReportJson(rpc, params) {
|
|
|
45675
45751
|
filename: params.filename,
|
|
45676
45752
|
check_id: params.checkId,
|
|
45677
45753
|
data: params.jsonText,
|
|
45678
|
-
type: "json"
|
|
45679
|
-
generate_issue: true
|
|
45754
|
+
type: "json"
|
|
45680
45755
|
});
|
|
45681
45756
|
return { reportChunkId: responseId(fn, response, "report_chunck_id", "report_chunk_id") };
|
|
45682
45757
|
}
|
|
@@ -45780,6 +45855,9 @@ function unwrapRpcResponse(parsed) {
|
|
|
45780
45855
|
var HTTP_TIMEOUT_MS = 30000;
|
|
45781
45856
|
async function postRpc(params) {
|
|
45782
45857
|
const { apiKey, apiBaseUrl, rpcName, bodyObj, timeoutMs = HTTP_TIMEOUT_MS } = params;
|
|
45858
|
+
if (!apiKey) {
|
|
45859
|
+
throw new Error("API key is required");
|
|
45860
|
+
}
|
|
45783
45861
|
const base = normalizeBaseUrl(apiBaseUrl);
|
|
45784
45862
|
const url = new URL4(`${base}/rpc/${rpcName}`);
|
|
45785
45863
|
const body = JSON.stringify(bodyObj);
|
|
@@ -45930,24 +46008,6 @@ async function createCheckupReport2(params) {
|
|
|
45930
46008
|
async function uploadCheckupReportJson2(params) {
|
|
45931
46009
|
return uploadCheckupReportJson((rpcName, bodyObj) => postRpc({ ...params, rpcName, bodyObj }), params);
|
|
45932
46010
|
}
|
|
45933
|
-
async function convertCheckupReportJsonToMarkdown(params) {
|
|
45934
|
-
const { apiKey, apiBaseUrl, checkId, jsonPayload, reportType } = params;
|
|
45935
|
-
const bodyObj = {
|
|
45936
|
-
check_id: checkId,
|
|
45937
|
-
json_payload: jsonPayload,
|
|
45938
|
-
access_token: apiKey
|
|
45939
|
-
};
|
|
45940
|
-
if (reportType) {
|
|
45941
|
-
bodyObj.report_type = reportType;
|
|
45942
|
-
}
|
|
45943
|
-
const resp = await postRpc({
|
|
45944
|
-
apiKey,
|
|
45945
|
-
apiBaseUrl,
|
|
45946
|
-
rpcName: "checkup_report_json_to_markdown",
|
|
45947
|
-
bodyObj
|
|
45948
|
-
});
|
|
45949
|
-
return resp;
|
|
45950
|
-
}
|
|
45951
46011
|
|
|
45952
46012
|
// lib/checkup-summary.ts
|
|
45953
46013
|
function generateCheckSummary2(checkId, report) {
|
|
@@ -46989,15 +47049,9 @@ function prepareUploadConfig(opts, rootOpts, shouldUpload, uploadExplicitlyReque
|
|
|
46989
47049
|
console.error("Tip: run 'postgresai auth' or pass --api-key / set PGAI_API_KEY");
|
|
46990
47050
|
return null;
|
|
46991
47051
|
}
|
|
46992
|
-
|
|
46993
|
-
|
|
46994
|
-
|
|
46995
|
-
console.error(" To avoid sending report data, replace --markdown with --no-upload and --json or --output.");
|
|
46996
|
-
} else {
|
|
46997
|
-
console.error("Notice: no API key configured \u2014 results will NOT be uploaded to PostgresAI.");
|
|
46998
|
-
console.error(" To upload: run 'postgresai auth login' or pass --api-key / set PGAI_API_KEY.");
|
|
46999
|
-
console.error(" To run locally without this notice, pass --no-upload.");
|
|
47000
|
-
}
|
|
47052
|
+
console.error("Notice: no API key configured \u2014 results will NOT be uploaded to PostgresAI.");
|
|
47053
|
+
console.error(" To upload: run 'postgresai auth login' or pass --api-key / set PGAI_API_KEY.");
|
|
47054
|
+
console.error(" To run locally without this notice, pass --no-upload.");
|
|
47001
47055
|
return;
|
|
47002
47056
|
}
|
|
47003
47057
|
const cfg = readConfig();
|
|
@@ -48384,7 +48438,7 @@ program2.command("unprepare-db [conn]").description("remove monitoring setup: dr
|
|
|
48384
48438
|
closeReadline();
|
|
48385
48439
|
}
|
|
48386
48440
|
});
|
|
48387
|
-
withOrgOptions(program2.command("checkup [checkIdOrConn] [conn]")).description("generate health check reports directly from PostgreSQL (express mode)").option("--check-id <id>", `specific check to run (see list below), or ALL`).option("--node-name <name>", "node name for reports", "node-01").option("--output <path>", "output directory for JSON files").option("--upload", "upload JSON results to PostgresAI (requires API key)").option("--no-upload", "disable upload to PostgresAI").option("--project <project>", "project name or ID for remote upload (used with --upload; defaults to config defaultProject; auto-generated on first run)").option("--json", "output JSON to stdout").
|
|
48441
|
+
withOrgOptions(program2.command("checkup [checkIdOrConn] [conn]")).description("generate health check reports directly from PostgreSQL (express mode)").option("--check-id <id>", `specific check to run (see list below), or ALL`).option("--node-name <name>", "node name for reports", "node-01").option("--output <path>", "output directory for JSON files").option("--upload", "upload JSON results to PostgresAI (requires API key)").option("--no-upload", "disable upload to PostgresAI").option("--project <project>", "project name or ID for remote upload (used with --upload; defaults to config defaultProject; auto-generated on first run)").option("--json", "output JSON to stdout").addOption(new Option2("--markdown").hideHelp()).addHelpText("after", [
|
|
48388
48442
|
"",
|
|
48389
48443
|
"Available checks:",
|
|
48390
48444
|
...Object.entries(CHECK_INFO).map(([id, title]) => ` ${id}: ${title}`),
|
|
@@ -48394,10 +48448,16 @@ withOrgOptions(program2.command("checkup [checkIdOrConn] [conn]")).description("
|
|
|
48394
48448
|
" postgresai checkup H002 postgresql://user:pass@host:5432/db",
|
|
48395
48449
|
" postgresai checkup postgresql://user:pass@host:5432/db --check-id H002",
|
|
48396
48450
|
" postgresai checkup postgresql://user:pass@host:5432/db --output ./reports",
|
|
48397
|
-
" postgresai checkup postgresql://user:pass@host:5432/db --no-upload --json"
|
|
48398
|
-
" postgresai checkup postgresql://user:pass@host:5432/db --markdown"
|
|
48451
|
+
" postgresai checkup postgresql://user:pass@host:5432/db --no-upload --json"
|
|
48399
48452
|
].join(`
|
|
48400
48453
|
`)).action(async (checkIdOrConn, connArg, opts, cmd) => {
|
|
48454
|
+
if (opts.markdown) {
|
|
48455
|
+
console.error("Error: --markdown is no longer available: checkup reports are JSON.");
|
|
48456
|
+
console.error("Use --json to print them, or --output <dir> to save them.");
|
|
48457
|
+
console.error("Uploaded reports appear in the PostgresAI Console.");
|
|
48458
|
+
process.exitCode = 1;
|
|
48459
|
+
return;
|
|
48460
|
+
}
|
|
48401
48461
|
const checkIdPattern = /^[A-Z]\d{3}$/i;
|
|
48402
48462
|
let conn;
|
|
48403
48463
|
let checkId;
|
|
@@ -48427,21 +48487,8 @@ Usage: postgresai checkup ${checkId} postgresql://user@host:5432/dbname
|
|
|
48427
48487
|
return;
|
|
48428
48488
|
}
|
|
48429
48489
|
const shouldPrintJson = !!opts.json;
|
|
48430
|
-
const shouldConvertMarkdown = !!opts.markdown;
|
|
48431
48490
|
const uploadExplicitlyRequested = opts.upload === true;
|
|
48432
|
-
if (shouldPrintJson && shouldConvertMarkdown) {
|
|
48433
|
-
console.error("Error: --json and --markdown are mutually exclusive");
|
|
48434
|
-
process.exitCode = 1;
|
|
48435
|
-
return;
|
|
48436
|
-
}
|
|
48437
48491
|
const uploadExplicitlyDisabled = opts.upload === false;
|
|
48438
|
-
if (uploadExplicitlyDisabled && shouldConvertMarkdown) {
|
|
48439
|
-
console.error("Error: --no-upload and --markdown are mutually exclusive");
|
|
48440
|
-
console.error("Markdown conversion is performed by the PostgresAI API and transmits the full report JSON.");
|
|
48441
|
-
console.error("Drop --no-upload to allow transmission, or use --json or --output for local-only output.");
|
|
48442
|
-
process.exitCode = 1;
|
|
48443
|
-
return;
|
|
48444
|
-
}
|
|
48445
48492
|
let shouldUpload = !uploadExplicitlyDisabled;
|
|
48446
48493
|
const outputPath = prepareOutputDirectory(opts.output);
|
|
48447
48494
|
if (outputPath === null) {
|
|
@@ -48546,67 +48593,7 @@ Usage: postgresai checkup ${checkId} postgresql://user@host:5432/dbname
|
|
|
48546
48593
|
writeReportFiles(reports, outputPath);
|
|
48547
48594
|
}
|
|
48548
48595
|
if (uploadSummary) {
|
|
48549
|
-
printUploadSummary(uploadSummary, projectWasGenerated, shouldPrintJson
|
|
48550
|
-
}
|
|
48551
|
-
if (shouldConvertMarkdown) {
|
|
48552
|
-
let apiKey;
|
|
48553
|
-
let apiBaseUrl;
|
|
48554
|
-
try {
|
|
48555
|
-
const configResult = getConfig(rootOpts);
|
|
48556
|
-
apiKey = configResult.apiKey;
|
|
48557
|
-
const cfg = readConfig();
|
|
48558
|
-
apiBaseUrl = resolveBaseUrls2(rootOpts, cfg).apiBaseUrl;
|
|
48559
|
-
} catch (error) {
|
|
48560
|
-
spinner.stop();
|
|
48561
|
-
console.error("Error: Failed to read configuration for markdown conversion");
|
|
48562
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
48563
|
-
process.exitCode = 1;
|
|
48564
|
-
return;
|
|
48565
|
-
}
|
|
48566
|
-
const markdownResults = [];
|
|
48567
|
-
for (const [checkId, report] of Object.entries(reports)) {
|
|
48568
|
-
try {
|
|
48569
|
-
spinner.update(`Converting ${checkId} to markdown`);
|
|
48570
|
-
const markdownResult = await convertCheckupReportJsonToMarkdown({
|
|
48571
|
-
apiKey,
|
|
48572
|
-
apiBaseUrl,
|
|
48573
|
-
checkId,
|
|
48574
|
-
jsonPayload: report,
|
|
48575
|
-
reportType: checkId
|
|
48576
|
-
});
|
|
48577
|
-
const markdown = markdownResult?.reports?.[0]?.markdown || markdownResult?.markdown;
|
|
48578
|
-
markdownResults.push({
|
|
48579
|
-
checkId,
|
|
48580
|
-
markdown
|
|
48581
|
-
});
|
|
48582
|
-
} catch (error) {
|
|
48583
|
-
markdownResults.push({
|
|
48584
|
-
checkId,
|
|
48585
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
48586
|
-
});
|
|
48587
|
-
}
|
|
48588
|
-
}
|
|
48589
|
-
spinner.stop();
|
|
48590
|
-
for (const result of markdownResults) {
|
|
48591
|
-
if (result.error) {
|
|
48592
|
-
if (result.error instanceof RpcError) {
|
|
48593
|
-
console.error(`Error converting ${result.checkId} to markdown:`);
|
|
48594
|
-
for (const line of formatRpcErrorForDisplay(result.error)) {
|
|
48595
|
-
console.error(line);
|
|
48596
|
-
}
|
|
48597
|
-
} else {
|
|
48598
|
-
console.error(`Error converting ${result.checkId} to markdown: ${result.error.message}`);
|
|
48599
|
-
}
|
|
48600
|
-
} else if (result.markdown) {
|
|
48601
|
-
console.log(result.markdown);
|
|
48602
|
-
if (!result.markdown.endsWith(`
|
|
48603
|
-
`)) {
|
|
48604
|
-
console.log();
|
|
48605
|
-
}
|
|
48606
|
-
} else {
|
|
48607
|
-
console.error(`Warning: No markdown content returned for ${result.checkId}`);
|
|
48608
|
-
}
|
|
48609
|
-
}
|
|
48596
|
+
printUploadSummary(uploadSummary, projectWasGenerated, shouldPrintJson, reports);
|
|
48610
48597
|
}
|
|
48611
48598
|
if (shouldPrintJson && !outputPath) {
|
|
48612
48599
|
try {
|
|
@@ -48618,7 +48605,7 @@ Usage: postgresai checkup ${checkId} postgresql://user@host:5432/dbname
|
|
|
48618
48605
|
throw err;
|
|
48619
48606
|
}
|
|
48620
48607
|
}
|
|
48621
|
-
const hadOutput = shouldPrintJson ||
|
|
48608
|
+
const hadOutput = shouldPrintJson || outputPath || uploadSummary;
|
|
48622
48609
|
if (!hadOutput) {
|
|
48623
48610
|
const checkCount = Object.keys(reports).length;
|
|
48624
48611
|
console.log(`Checkup completed: ${checkCount} check${checkCount > 1 ? "s" : ""}
|
|
@@ -48644,9 +48631,6 @@ Usage: postgresai checkup ${checkId} postgresql://user@host:5432/dbname
|
|
|
48644
48631
|
console.log(`
|
|
48645
48632
|
For details:`);
|
|
48646
48633
|
console.log(" --json Output JSON");
|
|
48647
|
-
if (!uploadExplicitlyDisabled) {
|
|
48648
|
-
console.log(" --markdown Output markdown via PostgresAI API");
|
|
48649
|
-
}
|
|
48650
48634
|
console.log(" --output <dir> Save to directory");
|
|
48651
48635
|
}
|
|
48652
48636
|
if (failedChecks.length > 0) {
|
|
@@ -49839,8 +49823,9 @@ async function cloudInstance(opts, ref, live = false) {
|
|
|
49839
49823
|
async function linkedDatabases(opts) {
|
|
49840
49824
|
const api = cloudApi(opts.debug);
|
|
49841
49825
|
return Promise.all((await api.list()).map(async (d) => {
|
|
49842
|
-
const [linked, pl] = await Promise.all([api.links(d),
|
|
49843
|
-
|
|
49826
|
+
const [linked, pl] = await Promise.all([api.links(d), privateLinkOf2(d, api.rdsStatus)]);
|
|
49827
|
+
const { privatelink: _route, ...row } = listedDatabase(linked);
|
|
49828
|
+
return pl ? { ...row, privatelink: { region: pl.region, vpce_service_name: pl.vpce_service_name, verified: verifiedWords(pl.verified_status) } } : row;
|
|
49844
49829
|
}));
|
|
49845
49830
|
}
|
|
49846
49831
|
var monPollMs = () => {
|
|
@@ -49850,7 +49835,7 @@ var monPollMs = () => {
|
|
|
49850
49835
|
var monInstances = mon.command("instances").description("monitoring instances in PostgresAI Cloud (pgai mon deploy)");
|
|
49851
49836
|
withOrgOptions(monInstances.command("list")).description("list the organization's monitoring instances").option("--json", "JSON output").option("--debug", "print HTTP requests (secrets masked)").action(async (opts) => {
|
|
49852
49837
|
try {
|
|
49853
|
-
printResult(
|
|
49838
|
+
printResult(await linkedDatabases(opts), opts.json);
|
|
49854
49839
|
} catch (err) {
|
|
49855
49840
|
failCloud(err, opts.json);
|
|
49856
49841
|
}
|
|
@@ -49872,7 +49857,7 @@ withOrgOptions(monInstances.command("watch <id-or-name>")).alias("status").descr
|
|
|
49872
49857
|
} finally {
|
|
49873
49858
|
undetach();
|
|
49874
49859
|
}
|
|
49875
|
-
const pl = await
|
|
49860
|
+
const pl = await privateLinkOf2(row, cloudApi(opts.debug).rdsStatus);
|
|
49876
49861
|
const status = connectStatus2(await cloudApi(opts.debug).links(row));
|
|
49877
49862
|
emitConnect(pl ? overPrivateLink2(status, privateLinkFailure(pl)) : status, opts.json);
|
|
49878
49863
|
} catch (err) {
|
|
@@ -49885,7 +49870,7 @@ withOrgOptions(monInstances.command("delete <id-or-name>")).description("stop mo
|
|
|
49885
49870
|
if (!opts.yes && !(interactive(opts.json) && /^y/i.test(await question(`Stop monitoring ${row.name} and delete its monitoring box? (y/N): `)))) {
|
|
49886
49871
|
return emitConnect({ status: "action_required", provider: row.provider, name: row.name, id: row.id, next: `pgai mon instances delete ${row.id} --yes` }, opts.json);
|
|
49887
49872
|
}
|
|
49888
|
-
const pl = await
|
|
49873
|
+
const pl = await privateLinkOf2(row, cloudApi(opts.debug).rdsStatus);
|
|
49889
49874
|
const billing = disconnectBilling(await cloudApi(opts.debug).disconnect(row.id));
|
|
49890
49875
|
emitConnect({
|
|
49891
49876
|
status: "deleting",
|
|
@@ -52435,7 +52420,12 @@ withOrgOptions(reports.command("list")).description("list checkup reports").opti
|
|
|
52435
52420
|
process.exitCode = 1;
|
|
52436
52421
|
}
|
|
52437
52422
|
});
|
|
52438
|
-
|
|
52423
|
+
function warnNoMarkdown(type, count) {
|
|
52424
|
+
if (type === "md" && count === 0) {
|
|
52425
|
+
console.error("No markdown files: checkup reports are JSON. Markdown exists only for reports uploaded by the legacy postgres-checkup tool.");
|
|
52426
|
+
}
|
|
52427
|
+
}
|
|
52428
|
+
withOrgOptions(reports.command("files [reportId]")).description("list files of a checkup report (metadata only, no content)").addOption(new Option2("--type <type>", "file type: json (default), md (uploaded by the legacy postgres-checkup tool)").choices(["json", "md"])).option("--check-id <id>", "filter by check ID (e.g., H002)").addOption(new Option2("--debug", "enable debug output").hideHelp()).option("--json", "output raw JSON").action(async (reportId, opts) => {
|
|
52439
52429
|
const spinner = createTtySpinner(process.stdout.isTTY ?? false, "Fetching report files...");
|
|
52440
52430
|
try {
|
|
52441
52431
|
const rootOpts = program2.opts();
|
|
@@ -52468,11 +52458,12 @@ withOrgOptions(reports.command("files [reportId]")).description("list files of a
|
|
|
52468
52458
|
apiKey,
|
|
52469
52459
|
apiBaseUrl,
|
|
52470
52460
|
reportId: numericId,
|
|
52471
|
-
type: opts.type,
|
|
52461
|
+
type: opts.type ?? "json",
|
|
52472
52462
|
checkId: opts.checkId,
|
|
52473
52463
|
debug: !!opts.debug
|
|
52474
52464
|
});
|
|
52475
52465
|
spinner.stop();
|
|
52466
|
+
warnNoMarkdown(opts.type, result.length);
|
|
52476
52467
|
printResult(result, opts.json);
|
|
52477
52468
|
} catch (err) {
|
|
52478
52469
|
spinner.stop();
|
|
@@ -52481,7 +52472,7 @@ withOrgOptions(reports.command("files [reportId]")).description("list files of a
|
|
|
52481
52472
|
process.exitCode = 1;
|
|
52482
52473
|
}
|
|
52483
52474
|
});
|
|
52484
|
-
withOrgOptions(reports.command("data [reportId]")).description("get checkup report file data (includes content)").
|
|
52475
|
+
withOrgOptions(reports.command("data [reportId]")).description("get checkup report file data (includes content)").addOption(new Option2("--type <type>", "file type: json (default), md (uploaded by the legacy postgres-checkup tool)").choices(["json", "md"])).option("--check-id <id>", "filter by check ID (e.g., H002)").option("--formatted", "render md files with ANSI styling in a terminal (experimental); JSON is indented in a terminal anyway").option("-o, --output <dir>", "save files to directory (uses original filenames)").addOption(new Option2("--debug", "enable debug output").hideHelp()).option("--json", "print files and metadata as one JSON array (for scripts / jq)").action(async (reportId, opts) => {
|
|
52485
52476
|
const spinner = createTtySpinner(process.stdout.isTTY ?? false, "Fetching report data...");
|
|
52486
52477
|
try {
|
|
52487
52478
|
const rootOpts = program2.opts();
|
|
@@ -52510,16 +52501,16 @@ withOrgOptions(reports.command("data [reportId]")).description("get checkup repo
|
|
|
52510
52501
|
return;
|
|
52511
52502
|
}
|
|
52512
52503
|
const { apiBaseUrl } = resolveBaseUrls2(rootOpts, cfg);
|
|
52513
|
-
const effectiveType = opts.type ?? (!opts.json && !opts.output ? "md" : undefined);
|
|
52514
52504
|
const result = await fetchReportFileData2({
|
|
52515
52505
|
apiKey,
|
|
52516
52506
|
apiBaseUrl,
|
|
52517
52507
|
reportId: numericId,
|
|
52518
|
-
type:
|
|
52508
|
+
type: opts.type ?? "json",
|
|
52519
52509
|
checkId: opts.checkId,
|
|
52520
52510
|
debug: !!opts.debug
|
|
52521
52511
|
});
|
|
52522
52512
|
spinner.stop();
|
|
52513
|
+
warnNoMarkdown(opts.type, result.length);
|
|
52523
52514
|
if (opts.output) {
|
|
52524
52515
|
const dir = path10.resolve(opts.output);
|
|
52525
52516
|
fs12.mkdirSync(dir, { recursive: true });
|
|
@@ -52551,11 +52542,13 @@ withOrgOptions(reports.command("data [reportId]")).description("get checkup repo
|
|
|
52551
52542
|
}
|
|
52552
52543
|
}
|
|
52553
52544
|
} else {
|
|
52545
|
+
const pretty = process.stdout.isTTY ?? false;
|
|
52554
52546
|
for (const f of result) {
|
|
52555
52547
|
if (result.length > 1) {
|
|
52556
52548
|
console.log(`--- ${f.filename} (${f.check_id}, ${f.type}) ---`);
|
|
52557
52549
|
}
|
|
52558
|
-
|
|
52550
|
+
const parsed = pretty && f.type === "json" ? tryParseJson(f.data) : f.data;
|
|
52551
|
+
console.log(typeof parsed === "string" ? parsed : JSON.stringify(parsed, null, 2));
|
|
52559
52552
|
}
|
|
52560
52553
|
}
|
|
52561
52554
|
} catch (err) {
|
|
@@ -52774,6 +52767,7 @@ var deployDeps = {
|
|
|
52774
52767
|
uiBaseUrl: () => resolveBaseUrls2(program2.opts(), readConfig()).uiBaseUrl
|
|
52775
52768
|
};
|
|
52776
52769
|
registerDblabDeployCommands(dblab, deployDeps);
|
|
52770
|
+
registerBillingCommands(program2, deployDeps);
|
|
52777
52771
|
var clone2 = dblab.command("clone").description("DBLab thin-clone management (proxies the Platform DBLab API)");
|
|
52778
52772
|
withOrgOptions(clone2.command("create")).description("create a thin clone of the project's database").requiredOption("--project <id|alias>", "project id or alias").option("--branch <branch>", "branch to clone from").option("--snapshot <id>", "snapshot id to clone from").option("--id <id>", "clone id (DBLab generates one when omitted)").option("--db-user <user>", "clone DB user (required; set its password in PGAI_CLONE_DB_PASSWORD)").option("--protected", "protect the clone from auto-deletion").option("--debug", "enable debug output").option("--json", "output raw JSON").action(async (opts) => {
|
|
52779
52773
|
try {
|
package/package.json
CHANGED
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"title": "A014 report schema",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"required": [
|
|
7
|
+
"checkId",
|
|
8
|
+
"checkTitle",
|
|
9
|
+
"timestamptz",
|
|
10
|
+
"nodes",
|
|
11
|
+
"results"
|
|
12
|
+
],
|
|
13
|
+
"properties": {
|
|
14
|
+
"contract_version": {
|
|
15
|
+
"type": [
|
|
16
|
+
"string",
|
|
17
|
+
"null"
|
|
18
|
+
]
|
|
19
|
+
},
|
|
20
|
+
"summary": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"additionalProperties": false,
|
|
23
|
+
"required": [
|
|
24
|
+
"status",
|
|
25
|
+
"message"
|
|
26
|
+
],
|
|
27
|
+
"properties": {
|
|
28
|
+
"status": {
|
|
29
|
+
"enum": [
|
|
30
|
+
"ok",
|
|
31
|
+
"warning",
|
|
32
|
+
"info"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"message": {
|
|
36
|
+
"type": "string"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"version": {
|
|
41
|
+
"type": [
|
|
42
|
+
"string",
|
|
43
|
+
"null"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"build_ts": {
|
|
47
|
+
"type": [
|
|
48
|
+
"string",
|
|
49
|
+
"null"
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
"generation_mode": {
|
|
53
|
+
"type": [
|
|
54
|
+
"string",
|
|
55
|
+
"null"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
"checkId": {
|
|
59
|
+
"const": "A014"
|
|
60
|
+
},
|
|
61
|
+
"checkTitle": {
|
|
62
|
+
"const": "Resource sizing"
|
|
63
|
+
},
|
|
64
|
+
"timestamptz": {
|
|
65
|
+
"type": "string"
|
|
66
|
+
},
|
|
67
|
+
"nodes": {
|
|
68
|
+
"$ref": "#/$defs/nodes"
|
|
69
|
+
},
|
|
70
|
+
"results": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"minProperties": 1,
|
|
73
|
+
"additionalProperties": {
|
|
74
|
+
"$ref": "#/$defs/nodeResult"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"$defs": {
|
|
79
|
+
"nodes": {
|
|
80
|
+
"type": "object",
|
|
81
|
+
"additionalProperties": false,
|
|
82
|
+
"required": [
|
|
83
|
+
"primary",
|
|
84
|
+
"standbys"
|
|
85
|
+
],
|
|
86
|
+
"properties": {
|
|
87
|
+
"primary": {
|
|
88
|
+
"type": "string"
|
|
89
|
+
},
|
|
90
|
+
"standbys": {
|
|
91
|
+
"type": "array",
|
|
92
|
+
"items": {
|
|
93
|
+
"type": "string"
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"postgresVersion": {
|
|
99
|
+
"type": "object",
|
|
100
|
+
"additionalProperties": false,
|
|
101
|
+
"required": [
|
|
102
|
+
"version",
|
|
103
|
+
"server_version_num",
|
|
104
|
+
"server_major_ver",
|
|
105
|
+
"server_minor_ver"
|
|
106
|
+
],
|
|
107
|
+
"properties": {
|
|
108
|
+
"version": {
|
|
109
|
+
"type": "string"
|
|
110
|
+
},
|
|
111
|
+
"server_version_num": {
|
|
112
|
+
"type": "string"
|
|
113
|
+
},
|
|
114
|
+
"server_major_ver": {
|
|
115
|
+
"type": "string"
|
|
116
|
+
},
|
|
117
|
+
"server_minor_ver": {
|
|
118
|
+
"type": "string"
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"clusterMetric": {
|
|
123
|
+
"type": "object",
|
|
124
|
+
"additionalProperties": false,
|
|
125
|
+
"required": [
|
|
126
|
+
"value",
|
|
127
|
+
"unit",
|
|
128
|
+
"description"
|
|
129
|
+
],
|
|
130
|
+
"properties": {
|
|
131
|
+
"value": {
|
|
132
|
+
"type": "string"
|
|
133
|
+
},
|
|
134
|
+
"unit": {
|
|
135
|
+
"type": "string"
|
|
136
|
+
},
|
|
137
|
+
"description": {
|
|
138
|
+
"type": "string"
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"data": {
|
|
143
|
+
"type": "object",
|
|
144
|
+
"additionalProperties": false,
|
|
145
|
+
"required": [
|
|
146
|
+
"window_hours",
|
|
147
|
+
"host_metrics",
|
|
148
|
+
"cpu",
|
|
149
|
+
"memory",
|
|
150
|
+
"disk",
|
|
151
|
+
"connections",
|
|
152
|
+
"db_size_bytes",
|
|
153
|
+
"series"
|
|
154
|
+
],
|
|
155
|
+
"properties": {
|
|
156
|
+
"window_hours": {
|
|
157
|
+
"type": "number",
|
|
158
|
+
"minimum": 0
|
|
159
|
+
},
|
|
160
|
+
"host_metrics": {
|
|
161
|
+
"type": "boolean"
|
|
162
|
+
},
|
|
163
|
+
"cpu": {
|
|
164
|
+
"type": "object",
|
|
165
|
+
"additionalProperties": false,
|
|
166
|
+
"required": [
|
|
167
|
+
"cores",
|
|
168
|
+
"p95_pct",
|
|
169
|
+
"max_pct"
|
|
170
|
+
],
|
|
171
|
+
"properties": {
|
|
172
|
+
"cores": {
|
|
173
|
+
"type": [
|
|
174
|
+
"integer",
|
|
175
|
+
"null"
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
"p95_pct": {
|
|
179
|
+
"type": [
|
|
180
|
+
"number",
|
|
181
|
+
"null"
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
"max_pct": {
|
|
185
|
+
"type": [
|
|
186
|
+
"number",
|
|
187
|
+
"null"
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"memory": {
|
|
193
|
+
"type": "object",
|
|
194
|
+
"additionalProperties": false,
|
|
195
|
+
"required": [
|
|
196
|
+
"total_bytes",
|
|
197
|
+
"available_min_pct",
|
|
198
|
+
"available_p5_pct"
|
|
199
|
+
],
|
|
200
|
+
"properties": {
|
|
201
|
+
"total_bytes": {
|
|
202
|
+
"type": [
|
|
203
|
+
"integer",
|
|
204
|
+
"null"
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
"available_min_pct": {
|
|
208
|
+
"type": [
|
|
209
|
+
"number",
|
|
210
|
+
"null"
|
|
211
|
+
]
|
|
212
|
+
},
|
|
213
|
+
"available_p5_pct": {
|
|
214
|
+
"type": [
|
|
215
|
+
"number",
|
|
216
|
+
"null"
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
},
|
|
221
|
+
"disk": {
|
|
222
|
+
"type": "object",
|
|
223
|
+
"additionalProperties": false,
|
|
224
|
+
"required": [
|
|
225
|
+
"mbps_p95",
|
|
226
|
+
"mbps_max",
|
|
227
|
+
"iops_p95",
|
|
228
|
+
"iops_max",
|
|
229
|
+
"free_bytes"
|
|
230
|
+
],
|
|
231
|
+
"properties": {
|
|
232
|
+
"mbps_p95": {
|
|
233
|
+
"type": [
|
|
234
|
+
"number",
|
|
235
|
+
"null"
|
|
236
|
+
]
|
|
237
|
+
},
|
|
238
|
+
"mbps_max": {
|
|
239
|
+
"type": [
|
|
240
|
+
"number",
|
|
241
|
+
"null"
|
|
242
|
+
]
|
|
243
|
+
},
|
|
244
|
+
"iops_p95": {
|
|
245
|
+
"type": [
|
|
246
|
+
"number",
|
|
247
|
+
"null"
|
|
248
|
+
],
|
|
249
|
+
"description": "95th percentile of the 5-minute averages of read + write IOPS (Supabase: all block devices, root disk included)."
|
|
250
|
+
},
|
|
251
|
+
"iops_max": {
|
|
252
|
+
"type": [
|
|
253
|
+
"number",
|
|
254
|
+
"null"
|
|
255
|
+
],
|
|
256
|
+
"description": "The highest 5-minute average of read + write IOPS, not the busiest minute."
|
|
257
|
+
},
|
|
258
|
+
"free_bytes": {
|
|
259
|
+
"type": [
|
|
260
|
+
"integer",
|
|
261
|
+
"null"
|
|
262
|
+
]
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
"connections": {
|
|
267
|
+
"type": "object",
|
|
268
|
+
"additionalProperties": false,
|
|
269
|
+
"required": [
|
|
270
|
+
"backends_p95",
|
|
271
|
+
"backends_max",
|
|
272
|
+
"max_connections"
|
|
273
|
+
],
|
|
274
|
+
"properties": {
|
|
275
|
+
"backends_p95": {
|
|
276
|
+
"type": [
|
|
277
|
+
"number",
|
|
278
|
+
"null"
|
|
279
|
+
]
|
|
280
|
+
},
|
|
281
|
+
"backends_max": {
|
|
282
|
+
"type": [
|
|
283
|
+
"number",
|
|
284
|
+
"null"
|
|
285
|
+
]
|
|
286
|
+
},
|
|
287
|
+
"max_connections": {
|
|
288
|
+
"type": [
|
|
289
|
+
"integer",
|
|
290
|
+
"null"
|
|
291
|
+
]
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
"db_size_bytes": {
|
|
296
|
+
"type": [
|
|
297
|
+
"integer",
|
|
298
|
+
"null"
|
|
299
|
+
]
|
|
300
|
+
},
|
|
301
|
+
"series": {
|
|
302
|
+
"type": "object",
|
|
303
|
+
"additionalProperties": false,
|
|
304
|
+
"required": [
|
|
305
|
+
"step_seconds",
|
|
306
|
+
"start_epoch",
|
|
307
|
+
"cpu_pct",
|
|
308
|
+
"mem_available_pct",
|
|
309
|
+
"disk_mbps",
|
|
310
|
+
"disk_iops"
|
|
311
|
+
],
|
|
312
|
+
"properties": {
|
|
313
|
+
"step_seconds": {
|
|
314
|
+
"type": "integer",
|
|
315
|
+
"minimum": 1
|
|
316
|
+
},
|
|
317
|
+
"start_epoch": {
|
|
318
|
+
"type": [
|
|
319
|
+
"integer",
|
|
320
|
+
"null"
|
|
321
|
+
]
|
|
322
|
+
},
|
|
323
|
+
"cpu_pct": {
|
|
324
|
+
"type": "array",
|
|
325
|
+
"maxItems": 2100,
|
|
326
|
+
"items": {
|
|
327
|
+
"type": [
|
|
328
|
+
"number",
|
|
329
|
+
"null"
|
|
330
|
+
]
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
"mem_available_pct": {
|
|
334
|
+
"type": "array",
|
|
335
|
+
"maxItems": 2100,
|
|
336
|
+
"items": {
|
|
337
|
+
"type": [
|
|
338
|
+
"number",
|
|
339
|
+
"null"
|
|
340
|
+
]
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
"disk_mbps": {
|
|
344
|
+
"type": "array",
|
|
345
|
+
"maxItems": 2100,
|
|
346
|
+
"items": {
|
|
347
|
+
"type": [
|
|
348
|
+
"number",
|
|
349
|
+
"null"
|
|
350
|
+
]
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
"disk_iops": {
|
|
354
|
+
"type": "array",
|
|
355
|
+
"maxItems": 2100,
|
|
356
|
+
"items": {
|
|
357
|
+
"type": [
|
|
358
|
+
"number",
|
|
359
|
+
"null"
|
|
360
|
+
]
|
|
361
|
+
},
|
|
362
|
+
"description": "Read + write IOPS, each point the average over its 5 minutes."
|
|
363
|
+
},
|
|
364
|
+
"disk_iops_kind": {
|
|
365
|
+
"type": "string",
|
|
366
|
+
"enum": [
|
|
367
|
+
"avg_5m"
|
|
368
|
+
],
|
|
369
|
+
"description": "What a disk_iops point is: avg_5m = the 5-minute average. Reports from older reporters omit it (their points were the busiest minute), and the platform does not judge their IOPS."
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
"nodeResult": {
|
|
376
|
+
"type": "object",
|
|
377
|
+
"additionalProperties": false,
|
|
378
|
+
"required": [
|
|
379
|
+
"data"
|
|
380
|
+
],
|
|
381
|
+
"properties": {
|
|
382
|
+
"data": {
|
|
383
|
+
"$ref": "#/$defs/data"
|
|
384
|
+
},
|
|
385
|
+
"postgres_version": {
|
|
386
|
+
"$ref": "#/$defs/postgresVersion"
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|