@senticor/hive 1.51.3 → 1.52.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/chive.cjs +16 -3
- package/hive.cjs +35 -16
- package/package.json +1 -1
package/chive.cjs
CHANGED
|
@@ -866,12 +866,15 @@ var ChiveHttpError = class extends Error {
|
|
|
866
866
|
code;
|
|
867
867
|
status;
|
|
868
868
|
body;
|
|
869
|
+
/** RFC 9457 primary machine identity; never dereferenced. */
|
|
870
|
+
problemType;
|
|
869
871
|
constructor(message, opts = {}) {
|
|
870
872
|
super(message);
|
|
871
873
|
this.name = "ChiveHttpError";
|
|
872
874
|
this.code = opts.code || "http_error";
|
|
873
875
|
this.status = opts.status || null;
|
|
874
876
|
this.body = opts.body || null;
|
|
877
|
+
this.problemType = opts.problemType || null;
|
|
875
878
|
}
|
|
876
879
|
};
|
|
877
880
|
function assertFlagRecord(flags2) {
|
|
@@ -900,10 +903,18 @@ function errorMessage(error) {
|
|
|
900
903
|
function extractResponseMessage(parsed) {
|
|
901
904
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
902
905
|
const obj = parsed;
|
|
906
|
+
if (typeof obj.type === "string" && typeof obj.title === "string" && typeof obj.status === "number") {
|
|
907
|
+
return typeof obj.detail === "string" && obj.detail ? obj.detail : obj.title;
|
|
908
|
+
}
|
|
903
909
|
if (typeof obj.error === "string" && obj.error) return obj.error;
|
|
904
910
|
if (typeof obj.message === "string" && obj.message) return obj.message;
|
|
905
911
|
return null;
|
|
906
912
|
}
|
|
913
|
+
function extractProblemType(parsed) {
|
|
914
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
915
|
+
const body = parsed;
|
|
916
|
+
return typeof body.type === "string" && typeof body.title === "string" && typeof body.status === "number" ? body.type : null;
|
|
917
|
+
}
|
|
907
918
|
function normalizeHeaders(headers) {
|
|
908
919
|
if (headers === void 0) return {};
|
|
909
920
|
if (!headers || typeof headers !== "object" || Array.isArray(headers)) {
|
|
@@ -964,10 +975,11 @@ function resolveToken(flags2) {
|
|
|
964
975
|
}
|
|
965
976
|
async function httpJson(options) {
|
|
966
977
|
const { method, url, body, token, headers, timeoutMs } = normalizeHttpOptions(options);
|
|
978
|
+
const explicitAccept = Object.keys(headers).some((name) => name.toLowerCase() === "accept");
|
|
967
979
|
const requestInit = {
|
|
968
980
|
method,
|
|
969
981
|
headers: {
|
|
970
|
-
accept: "application/json",
|
|
982
|
+
...!explicitAccept ? { accept: "application/json, application/problem+json" } : {},
|
|
971
983
|
...body !== void 0 ? { "content-type": "application/json" } : {},
|
|
972
984
|
...token ? { authorization: `Bearer ${token}` } : {},
|
|
973
985
|
...headers
|
|
@@ -990,14 +1002,15 @@ async function httpJson(options) {
|
|
|
990
1002
|
try {
|
|
991
1003
|
parsed = text ? JSON.parse(text) : null;
|
|
992
1004
|
} catch {
|
|
993
|
-
parsed = { raw: text };
|
|
1005
|
+
parsed = res.ok ? { raw: text } : null;
|
|
994
1006
|
}
|
|
995
1007
|
if (!res.ok) {
|
|
996
1008
|
const message = extractResponseMessage(parsed) || `HTTP ${res.status}`;
|
|
997
1009
|
throw new ChiveHttpError(`${method} ${url} \u2192 ${res.status}: ${message}`, {
|
|
998
1010
|
code: `http_${res.status}`,
|
|
999
1011
|
status: res.status,
|
|
1000
|
-
body: parsed
|
|
1012
|
+
body: parsed,
|
|
1013
|
+
problemType: extractProblemType(parsed)
|
|
1001
1014
|
});
|
|
1002
1015
|
}
|
|
1003
1016
|
return parsed;
|
package/hive.cjs
CHANGED
|
@@ -9386,7 +9386,7 @@ var HiveClient = class {
|
|
|
9386
9386
|
async _request(method, path10, body) {
|
|
9387
9387
|
const url2 = new import_node_url2.URL(path10, this.baseUrl);
|
|
9388
9388
|
const mod = url2.protocol === "https:" ? import_node_https2.default : import_node_http2.default;
|
|
9389
|
-
const headers = await this._baseHeaders("application/json");
|
|
9389
|
+
const headers = await this._baseHeaders("application/json, application/problem+json");
|
|
9390
9390
|
let payload = null;
|
|
9391
9391
|
if (body !== void 0 && body !== null) {
|
|
9392
9392
|
payload = typeof body === "string" ? body : JSON.stringify(body);
|
|
@@ -9433,7 +9433,7 @@ var HiveClient = class {
|
|
|
9433
9433
|
async getRaw(path10) {
|
|
9434
9434
|
const url2 = new import_node_url2.URL(path10, this.baseUrl);
|
|
9435
9435
|
const mod = url2.protocol === "https:" ? import_node_https2.default : import_node_http2.default;
|
|
9436
|
-
const headers = await this._baseHeaders("
|
|
9436
|
+
const headers = await this._baseHeaders("*/*, application/problem+json");
|
|
9437
9437
|
if (this.verbose) process.stderr.write(`\u2192 GET ${url2.href} (stream)
|
|
9438
9438
|
`);
|
|
9439
9439
|
return new Promise((resolve3, reject) => {
|
|
@@ -9613,7 +9613,7 @@ async function resolveSetting(opts) {
|
|
|
9613
9613
|
async function fetchAuthConfig(apiUrl) {
|
|
9614
9614
|
try {
|
|
9615
9615
|
const base = apiUrl.replace(/\/+$/, "");
|
|
9616
|
-
const res = await fetch(`${base}/api/auth/config`, { headers: { accept: "application/json" } });
|
|
9616
|
+
const res = await fetch(`${base}/api/auth/config`, { headers: { accept: "application/json, application/problem+json" } });
|
|
9617
9617
|
if (!res.ok) return null;
|
|
9618
9618
|
const body = await res.json();
|
|
9619
9619
|
const issuerUrl = typeof body.issuerUrl === "string" ? body.issuerUrl : void 0;
|
|
@@ -9653,6 +9653,7 @@ var CliCommandError = class extends Error {
|
|
|
9653
9653
|
symbolicCode;
|
|
9654
9654
|
remediation;
|
|
9655
9655
|
tenant;
|
|
9656
|
+
problemType;
|
|
9656
9657
|
constructor(symbolicCode, exitCode, message, options) {
|
|
9657
9658
|
super(message, options);
|
|
9658
9659
|
this.name = "CliCommandError";
|
|
@@ -9660,6 +9661,7 @@ var CliCommandError = class extends Error {
|
|
|
9660
9661
|
this.symbolicCode = symbolicCode;
|
|
9661
9662
|
this.remediation = options?.remediation;
|
|
9662
9663
|
this.tenant = options?.tenant;
|
|
9664
|
+
this.problemType = options?.problemType;
|
|
9663
9665
|
}
|
|
9664
9666
|
};
|
|
9665
9667
|
function commandError(symbolicCode, exitCode, message, options) {
|
|
@@ -9667,6 +9669,12 @@ function commandError(symbolicCode, exitCode, message, options) {
|
|
|
9667
9669
|
}
|
|
9668
9670
|
function remoteErrorFields(data) {
|
|
9669
9671
|
const body = data ?? {};
|
|
9672
|
+
if (typeof body.type === "string" && typeof body.title === "string" && typeof body.status === "number") {
|
|
9673
|
+
return {
|
|
9674
|
+
code: typeof body.code === "string" ? body.code.trim() : "",
|
|
9675
|
+
message: typeof body.detail === "string" ? body.detail.trim() : body.title.trim()
|
|
9676
|
+
};
|
|
9677
|
+
}
|
|
9670
9678
|
const raw = body.error;
|
|
9671
9679
|
if (raw && typeof raw === "object") {
|
|
9672
9680
|
const nested = raw;
|
|
@@ -9680,6 +9688,11 @@ function remoteErrorFields(data) {
|
|
|
9680
9688
|
message: String(body.message || "").trim()
|
|
9681
9689
|
};
|
|
9682
9690
|
}
|
|
9691
|
+
function remoteProblemType(data) {
|
|
9692
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) return void 0;
|
|
9693
|
+
const body = data;
|
|
9694
|
+
return typeof body.type === "string" && typeof body.title === "string" && typeof body.status === "number" ? body.type : void 0;
|
|
9695
|
+
}
|
|
9683
9696
|
function fieldText(value) {
|
|
9684
9697
|
if (value === null || value === void 0) return "";
|
|
9685
9698
|
if (typeof value === "object") {
|
|
@@ -9723,18 +9736,20 @@ function remoteFailureTenant(data) {
|
|
|
9723
9736
|
function remoteFailureError(status2, data, action, exitCode = exitCodeForStatus(status2)) {
|
|
9724
9737
|
const remediation = remoteFailureRemediation(data);
|
|
9725
9738
|
const tenant = remoteFailureTenant(data);
|
|
9739
|
+
const problemType = remoteProblemType(data);
|
|
9726
9740
|
return commandError(
|
|
9727
9741
|
"REMOTE_FAILED",
|
|
9728
9742
|
exitCode,
|
|
9729
9743
|
`${action} failed${status2 ? ` (HTTP ${status2})` : ""}: ${remoteFailureText(data)}${remediation ? ` \u2014 ${remediation}` : ""}`,
|
|
9730
|
-
remediation || tenant ? { ...remediation ? { remediation } : {}, ...tenant ? { tenant } : {} } : void 0
|
|
9744
|
+
remediation || tenant || problemType ? { ...remediation ? { remediation } : {}, ...tenant ? { tenant } : {}, ...problemType ? { problemType } : {} } : void 0
|
|
9731
9745
|
);
|
|
9732
9746
|
}
|
|
9733
9747
|
function remoteFailureText(data) {
|
|
9734
9748
|
const body = data;
|
|
9735
9749
|
const { code, message } = remoteErrorFields(data);
|
|
9736
|
-
const
|
|
9737
|
-
const
|
|
9750
|
+
const isProblem = typeof body?.type === "string" && typeof body?.title === "string" && typeof body?.status === "number";
|
|
9751
|
+
const parts = [code, message, ...isProblem ? [] : [fieldText(body?.detail)]].filter(Boolean);
|
|
9752
|
+
const fields = isProblem ? [] : schemaErrorFields(data);
|
|
9738
9753
|
if (fields.length) parts.push(`(offending field${fields.length > 1 ? "s" : ""}: ${fields.join(", ")})`);
|
|
9739
9754
|
return [...new Set(parts)].join(": ") || "unexpected response";
|
|
9740
9755
|
}
|
|
@@ -9748,6 +9763,7 @@ function toStructuredError(err) {
|
|
|
9748
9763
|
code,
|
|
9749
9764
|
message,
|
|
9750
9765
|
...e?.remediation ? { remediation: e.remediation } : {},
|
|
9766
|
+
...e?.problemType ? { type: e.problemType } : {},
|
|
9751
9767
|
...e?.tenant ? { tenant: e.tenant } : {}
|
|
9752
9768
|
}
|
|
9753
9769
|
};
|
|
@@ -9798,11 +9814,12 @@ function installRemoteFailureExit() {
|
|
|
9798
9814
|
const symbolic = remoteErrorFields(failure.body).code || remoteFailureCode(failure.status);
|
|
9799
9815
|
const remediation = remoteFailureRemediation(failure.body) ?? (failure.status === 401 ? "Run 'hive login' to authenticate, or set HIVE_TOKEN." : void 0);
|
|
9800
9816
|
const tenant = remoteFailureTenant(failure.body);
|
|
9817
|
+
const problemType = remoteProblemType(failure.body);
|
|
9801
9818
|
const message = `${failure.method} ${failure.path} failed${failure.status ? ` (HTTP ${failure.status})` : ""}: ${remoteFailureText(failure.body)}`;
|
|
9802
9819
|
if (isJsonMode()) {
|
|
9803
9820
|
console.error(JSON.stringify({
|
|
9804
9821
|
ok: false,
|
|
9805
|
-
error: { code: symbolic, message, ...remediation ? { remediation } : {}, ...tenant ? { tenant } : {} }
|
|
9822
|
+
error: { code: symbolic, message, ...problemType ? { type: problemType } : {}, ...remediation ? { remediation } : {}, ...tenant ? { tenant } : {} }
|
|
9806
9823
|
}));
|
|
9807
9824
|
} else {
|
|
9808
9825
|
console.error(`\x1B[31mError:\x1B[0m ${symbolic}: ${message}`);
|
|
@@ -10359,22 +10376,22 @@ var artifactName = injectedString(
|
|
|
10359
10376
|
true ? "hive-cli" : void 0
|
|
10360
10377
|
) || String(process.env.HIVE_CLI_ARTIFACT_NAME || "hive-cli").trim() || "hive-cli";
|
|
10361
10378
|
var packageVersion = injectedString(
|
|
10362
|
-
true ? "1.
|
|
10379
|
+
true ? "1.52.0" : void 0
|
|
10363
10380
|
) || String(process.env.HIVE_CLI_PACKAGE_VERSION || "").trim() || readPackageVersion();
|
|
10364
10381
|
var releaseVersion = injectedString(
|
|
10365
|
-
true ? "1.
|
|
10382
|
+
true ? "1.52.0" : void 0
|
|
10366
10383
|
) || String(process.env.HIVE_CLI_RELEASE_VERSION || "").trim() || packageVersion || "dev";
|
|
10367
10384
|
var releaseChannel = injectedString(
|
|
10368
10385
|
true ? "final" : void 0
|
|
10369
10386
|
) || String(process.env.HIVE_CLI_RELEASE_CHANNEL || "").trim() || (releaseVersion.includes("-rc.") ? "rc" : releaseVersion === "dev" ? "dev" : "final");
|
|
10370
10387
|
var buildCommit = injectedString(
|
|
10371
|
-
true ? "
|
|
10388
|
+
true ? "2047a1cb03ab5e27f6e9aa1d7dc9cfa8be75d50d" : void 0
|
|
10372
10389
|
) || String(process.env.HIVE_CLI_BUILD_COMMIT || "").trim() || "unknown";
|
|
10373
10390
|
var buildTimestamp = injectedString(
|
|
10374
|
-
true ? "2026-10-
|
|
10391
|
+
true ? "2026-10-06T22:12:24Z" : void 0
|
|
10375
10392
|
) || String(process.env.HIVE_CLI_BUILD_TIMESTAMP || "").trim() || "unknown";
|
|
10376
10393
|
var ociRef = injectedString(
|
|
10377
|
-
true ? "registry.onstackit.cloud/senticor/hive-cli:1.
|
|
10394
|
+
true ? "registry.onstackit.cloud/senticor/hive-cli:1.52.0" : void 0
|
|
10378
10395
|
) || String(process.env.HIVE_CLI_OCI_REF || "").trim() || `registry.onstackit.cloud/senticor/${artifactName}:${releaseVersion}`;
|
|
10379
10396
|
var RELEASE_INFO = Object.freeze({
|
|
10380
10397
|
packageVersion,
|
|
@@ -26468,7 +26485,7 @@ function createHttpClient(baseUrl, token, fetchImpl = fetch) {
|
|
|
26468
26485
|
async request(method, path10, opts = {}) {
|
|
26469
26486
|
const headers = {
|
|
26470
26487
|
Authorization: `Bearer ${token}`,
|
|
26471
|
-
Accept: "application/json"
|
|
26488
|
+
Accept: "application/json, application/problem+json"
|
|
26472
26489
|
};
|
|
26473
26490
|
if (opts.tenant) headers["X-Hive-Tenant"] = opts.tenant;
|
|
26474
26491
|
let body;
|
|
@@ -26477,15 +26494,17 @@ function createHttpClient(baseUrl, token, fetchImpl = fetch) {
|
|
|
26477
26494
|
body = JSON.stringify(opts.body);
|
|
26478
26495
|
}
|
|
26479
26496
|
const res = await fetchImpl(`${base}${path10}`, { method, headers, body });
|
|
26480
|
-
const
|
|
26497
|
+
const rawText = await res.text().catch(() => "");
|
|
26481
26498
|
let json2 = null;
|
|
26482
|
-
if (
|
|
26499
|
+
if (rawText) {
|
|
26483
26500
|
try {
|
|
26484
|
-
json2 = JSON.parse(
|
|
26501
|
+
json2 = JSON.parse(rawText);
|
|
26485
26502
|
} catch {
|
|
26486
26503
|
json2 = null;
|
|
26487
26504
|
}
|
|
26488
26505
|
}
|
|
26506
|
+
const isProblem = !res.ok && (res.headers.get("content-type") || "").toLowerCase().includes("application/problem+json");
|
|
26507
|
+
const text = isProblem ? json2 && typeof json2.type === "string" && typeof json2.title === "string" && typeof json2.status === "number" ? [typeof json2.code === "string" ? json2.code : "", typeof json2.detail === "string" ? json2.detail : json2.title].filter(Boolean).join(": ") : `HTTP ${res.status}` : rawText;
|
|
26489
26508
|
return { status: res.status, ok: res.ok, json: json2, text };
|
|
26490
26509
|
}
|
|
26491
26510
|
};
|