postgresai 0.17.0-dev.0 → 0.17.0-rc.1
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/dist/bin/postgres-ai.js +51 -11
- package/package.json +1 -1
package/dist/bin/postgres-ai.js
CHANGED
|
@@ -13524,7 +13524,7 @@ var {
|
|
|
13524
13524
|
// package.json
|
|
13525
13525
|
var package_default = {
|
|
13526
13526
|
name: "postgresai",
|
|
13527
|
-
version: "0.17.0-
|
|
13527
|
+
version: "0.17.0-rc.1",
|
|
13528
13528
|
description: "postgres_ai CLI",
|
|
13529
13529
|
license: "Apache-2.0",
|
|
13530
13530
|
private: false,
|
|
@@ -13721,6 +13721,23 @@ function deleteConfigKeys(keys) {
|
|
|
13721
13721
|
}
|
|
13722
13722
|
}
|
|
13723
13723
|
|
|
13724
|
+
// lib/stdout.ts
|
|
13725
|
+
function writeStdout(text) {
|
|
13726
|
+
return new Promise((resolve, reject) => {
|
|
13727
|
+
process.stdout.write(text, (err) => {
|
|
13728
|
+
if (err) {
|
|
13729
|
+
process.stdout.once("error", () => {});
|
|
13730
|
+
reject(err);
|
|
13731
|
+
return;
|
|
13732
|
+
}
|
|
13733
|
+
resolve();
|
|
13734
|
+
});
|
|
13735
|
+
});
|
|
13736
|
+
}
|
|
13737
|
+
function isEpipe(err) {
|
|
13738
|
+
return err?.code === "EPIPE";
|
|
13739
|
+
}
|
|
13740
|
+
|
|
13724
13741
|
// node_modules/js-yaml/dist/js-yaml.mjs
|
|
13725
13742
|
function getDefaultExportFromCjs(x) {
|
|
13726
13743
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -16867,7 +16884,7 @@ var Result = import_lib.default.Result;
|
|
|
16867
16884
|
var TypeOverrides = import_lib.default.TypeOverrides;
|
|
16868
16885
|
var defaults = import_lib.default.defaults;
|
|
16869
16886
|
// package.json
|
|
16870
|
-
var version = "0.17.0-
|
|
16887
|
+
var version = "0.17.0-rc.1";
|
|
16871
16888
|
var package_default2 = {
|
|
16872
16889
|
name: "postgresai",
|
|
16873
16890
|
version,
|
|
@@ -17228,9 +17245,9 @@ var ORG_ALIAS_HEADER = "x-pgai-org";
|
|
|
17228
17245
|
var ORG_ID_HEADER = "x-pgai-org-id";
|
|
17229
17246
|
class OrgScopeError extends Error {
|
|
17230
17247
|
}
|
|
17231
|
-
var activeOrgScope;
|
|
17248
|
+
var ACTIVE_ORG_SCOPE_KEY = Symbol.for("postgres-ai.cli.activeOrgScope");
|
|
17232
17249
|
function getActiveOrgScope() {
|
|
17233
|
-
return
|
|
17250
|
+
return globalThis[ACTIVE_ORG_SCOPE_KEY];
|
|
17234
17251
|
}
|
|
17235
17252
|
function orgScopeHeaders(scope) {
|
|
17236
17253
|
if (!scope)
|
|
@@ -17246,7 +17263,7 @@ function buildAuthHeaders(apiKey, scope, extra = {}) {
|
|
|
17246
17263
|
"access-token": apiKey,
|
|
17247
17264
|
"Content-Type": "application/json",
|
|
17248
17265
|
Connection: "close",
|
|
17249
|
-
...orgScopeHeaders(scope ??
|
|
17266
|
+
...orgScopeHeaders(scope ?? getActiveOrgScope()),
|
|
17250
17267
|
...extra
|
|
17251
17268
|
};
|
|
17252
17269
|
}
|
|
@@ -32145,12 +32162,12 @@ function requireOrgScope(opts = {}, apiKey) {
|
|
|
32145
32162
|
}
|
|
32146
32163
|
return { source: "token" };
|
|
32147
32164
|
}
|
|
32148
|
-
var
|
|
32165
|
+
var ACTIVE_ORG_SCOPE_KEY2 = Symbol.for("postgres-ai.cli.activeOrgScope");
|
|
32149
32166
|
function setActiveOrgScope(scope) {
|
|
32150
|
-
|
|
32167
|
+
globalThis[ACTIVE_ORG_SCOPE_KEY2] = scope;
|
|
32151
32168
|
}
|
|
32152
32169
|
function getActiveOrgScope2() {
|
|
32153
|
-
return
|
|
32170
|
+
return globalThis[ACTIVE_ORG_SCOPE_KEY2];
|
|
32154
32171
|
}
|
|
32155
32172
|
function configOrgIdForBody(apiKey, cfgOrgId) {
|
|
32156
32173
|
if (isGlobalTokenValue2(apiKey))
|
|
@@ -38522,16 +38539,32 @@ function addInstanceToFile(file, instance) {
|
|
|
38522
38539
|
throw new Error(`Monitoring target '${instance.name}' already exists`);
|
|
38523
38540
|
}
|
|
38524
38541
|
existing.push(instance);
|
|
38525
|
-
|
|
38542
|
+
writeInstancesFile(file, existing);
|
|
38526
38543
|
}
|
|
38527
38544
|
function removeInstanceFromFile(file, name) {
|
|
38528
38545
|
const instances = loadInstances2(file);
|
|
38529
38546
|
const filtered = instances.filter((i) => i.name !== name);
|
|
38530
38547
|
if (filtered.length === instances.length)
|
|
38531
38548
|
return false;
|
|
38532
|
-
|
|
38549
|
+
writeInstancesFile(file, filtered);
|
|
38533
38550
|
return true;
|
|
38534
38551
|
}
|
|
38552
|
+
function writeInstancesFile(file, instances) {
|
|
38553
|
+
const content = dump2(instances);
|
|
38554
|
+
const fd = fs8.openSync(file, "w", 384);
|
|
38555
|
+
try {
|
|
38556
|
+
try {
|
|
38557
|
+
fs8.fchmodSync(fd, 384);
|
|
38558
|
+
} catch (err) {
|
|
38559
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
38560
|
+
console.error(`Warning: could not restrict permissions on ${file}: ${message}`);
|
|
38561
|
+
console.error(" It may be readable by other users on this machine.");
|
|
38562
|
+
}
|
|
38563
|
+
fs8.writeFileSync(fd, content, "utf8");
|
|
38564
|
+
} finally {
|
|
38565
|
+
fs8.closeSync(fd);
|
|
38566
|
+
}
|
|
38567
|
+
}
|
|
38535
38568
|
function extractSslmode(connStr) {
|
|
38536
38569
|
try {
|
|
38537
38570
|
return (new URL(connStr).searchParams.get("sslmode") || "").toLowerCase();
|
|
@@ -40358,7 +40391,14 @@ Usage: postgresai checkup ${checkId} postgresql://user@host:5432/dbname
|
|
|
40358
40391
|
}
|
|
40359
40392
|
}
|
|
40360
40393
|
if (shouldPrintJson && !outputPath) {
|
|
40361
|
-
|
|
40394
|
+
try {
|
|
40395
|
+
await writeStdout(JSON.stringify(reports, null, 2) + `
|
|
40396
|
+
`);
|
|
40397
|
+
} catch (err) {
|
|
40398
|
+
if (isEpipe(err))
|
|
40399
|
+
return;
|
|
40400
|
+
throw err;
|
|
40401
|
+
}
|
|
40362
40402
|
}
|
|
40363
40403
|
const hadOutput = shouldPrintJson || shouldConvertMarkdown || outputPath || uploadSummary;
|
|
40364
40404
|
if (!hadOutput) {
|