@xylex-group/athena 2.12.1 → 2.13.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/LICENSE +21 -21
- package/README.md +1190 -1184
- package/bin/athena-js.js +104 -76
- package/dist/admin.cjs +45 -0
- package/dist/admin.cjs.map +1 -0
- package/dist/admin.d.cts +64 -0
- package/dist/admin.d.ts +64 -0
- package/dist/admin.js +41 -0
- package/dist/admin.js.map +1 -0
- package/dist/athena-auth-url-oLux_57a.d.cts +377 -0
- package/dist/athena-auth-url-oLux_57a.d.ts +377 -0
- package/dist/browser.cjs +33 -49
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +12 -10
- package/dist/browser.d.ts +12 -10
- package/dist/browser.js +33 -49
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +150 -51
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +14 -5
- package/dist/cli/index.d.ts +14 -5
- package/dist/cli/index.js +150 -52
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-CMtx5P4D.d.cts → client-BJjUwDSg.d.cts} +109 -1448
- package/dist/{client-Dre8H24u.d.ts → client-DVOKSYDI.d.ts} +109 -1448
- package/dist/cookies.cjs +18 -0
- package/dist/cookies.cjs.map +1 -1
- package/dist/cookies.d.cts +2 -1
- package/dist/cookies.d.ts +2 -1
- package/dist/cookies.js +17 -1
- package/dist/cookies.js.map +1 -1
- package/dist/{index-CVcQCGyG.d.ts → index-CFL9xbFR.d.cts} +2 -0
- package/dist/{index-CVcQCGyG.d.cts → index-UKJpunc6.d.ts} +2 -0
- package/dist/index.cjs +101 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -10
- package/dist/index.d.ts +13 -10
- package/dist/index.js +101 -50
- package/dist/index.js.map +1 -1
- package/dist/{model-form-DfTi8-D1.d.cts → model-form-Dw4zEL5a.d.cts} +2 -2
- package/dist/{model-form-CU0mWrF9.d.ts → model-form-yRg71q3H.d.ts} +2 -2
- package/dist/{module-DBGmbIuh.d.ts → module-DBteUIob.d.ts} +12 -9
- package/dist/{module-GoijrBXV.d.cts → module-yoX49uQC.d.cts} +12 -9
- package/dist/next/client.cjs +452 -49
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.cts +7 -4
- package/dist/next/client.d.ts +7 -4
- package/dist/next/client.js +430 -50
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +292 -49
- package/dist/next/server.cjs.map +1 -1
- package/dist/next/server.d.cts +81 -5
- package/dist/next/server.d.ts +81 -5
- package/dist/next/server.js +280 -50
- package/dist/next/server.js.map +1 -1
- package/dist/organization.cjs +72 -0
- package/dist/organization.cjs.map +1 -0
- package/dist/organization.d.cts +43 -0
- package/dist/organization.d.ts +43 -0
- package/dist/organization.js +70 -0
- package/dist/organization.js.map +1 -0
- package/dist/payload-BzVbUgY_.d.cts +219 -0
- package/dist/payload-DEOWN_oo.d.ts +219 -0
- package/dist/{pipeline-DrjU2vNA.d.ts → pipeline-Bj6RWt1A.d.ts} +1 -1
- package/dist/{pipeline-c7Gdm0qv.d.cts → pipeline-Dwck-wZO.d.cts} +1 -1
- package/dist/react.cjs +2 -13
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +26 -7
- package/dist/react.d.ts +26 -7
- package/dist/react.js +2 -13
- package/dist/react.js.map +1 -1
- package/dist/session-cookie-detection-BqOp9mO6.d.cts +46 -0
- package/dist/session-cookie-detection-BqOp9mO6.d.ts +46 -0
- package/dist/social-providers.cjs +4189 -0
- package/dist/social-providers.cjs.map +1 -0
- package/dist/social-providers.d.cts +4948 -0
- package/dist/social-providers.d.ts +4948 -0
- package/dist/social-providers.js +4117 -0
- package/dist/social-providers.js.map +1 -0
- package/dist/{types-Bez4HSbI.d.cts → types-BRP7sfSF.d.ts} +50 -2
- package/dist/{types-kPaHUqUa.d.ts → types-BU8uJH_b.d.cts} +50 -2
- package/dist/{types-BRUHGXo2.d.ts → types-CH78O90i.d.cts} +2 -2
- package/dist/{types-BRUHGXo2.d.cts → types-CH78O90i.d.ts} +2 -2
- package/dist/{types-BLizCLd1.d.cts → types-CjC9_5ZQ.d.cts} +3 -3
- package/dist/{types-DRRb0Fd0.d.ts → types-DPgejxYC.d.ts} +3 -3
- package/dist/types-eAKAh71s.d.cts +1476 -0
- package/dist/types-eAKAh71s.d.ts +1476 -0
- package/dist/utils.cjs +438 -15
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +76 -11
- package/dist/utils.d.ts +76 -11
- package/dist/utils.js +390 -16
- package/dist/utils.js.map +1 -1
- package/package.json +49 -22
- package/dist/shared-DZSGAmXs.d.cts +0 -35
- package/dist/shared-MMnVBBfy.d.ts +0 -35
package/dist/cli/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as runSchemaGenerator } from '../pipeline-
|
|
2
|
-
import '../types-
|
|
3
|
-
import '../types-
|
|
4
|
-
import '../types-
|
|
1
|
+
import { r as runSchemaGenerator } from '../pipeline-Dwck-wZO.cjs';
|
|
2
|
+
import '../types-CjC9_5ZQ.cjs';
|
|
3
|
+
import '../types-CH78O90i.cjs';
|
|
4
|
+
import '../types-BU8uJH_b.cjs';
|
|
5
5
|
|
|
6
6
|
interface GenerateCommand {
|
|
7
7
|
command: 'generate';
|
|
@@ -16,12 +16,21 @@ type CliCommand = GenerateCommand | HelpCommand;
|
|
|
16
16
|
interface CliRuntime {
|
|
17
17
|
runGenerator?: typeof runSchemaGenerator;
|
|
18
18
|
log?: (message: string) => void;
|
|
19
|
+
/** Defaults to `console.error`. */
|
|
20
|
+
errorLog?: (message: string) => void;
|
|
19
21
|
}
|
|
20
22
|
declare function usage(topic?: HelpCommand['topic']): string;
|
|
21
23
|
declare function parseCommand(argv: string[]): CliCommand;
|
|
24
|
+
/**
|
|
25
|
+
* Print a CLI error to stderr with optional stack when `ATHENA_JS_DEBUG=1`.
|
|
26
|
+
*/
|
|
27
|
+
declare function logCliError(error: unknown, errorLog?: (message: string) => void): void;
|
|
22
28
|
/**
|
|
23
29
|
* CLI entrypoint used by `bin/athena-js.js`.
|
|
30
|
+
*
|
|
31
|
+
* Generator failures are logged with diagnostics (code, remote, cause chain)
|
|
32
|
+
* and exit with code `1` instead of only throwing a bare message.
|
|
24
33
|
*/
|
|
25
34
|
declare function runCLI(argv: string[], runtime?: CliRuntime): Promise<void>;
|
|
26
35
|
|
|
27
|
-
export { type CliRuntime, parseCommand, runCLI, usage };
|
|
36
|
+
export { type CliRuntime, logCliError, parseCommand, runCLI, usage };
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as runSchemaGenerator } from '../pipeline-
|
|
2
|
-
import '../types-
|
|
3
|
-
import '../types-
|
|
4
|
-
import '../types-
|
|
1
|
+
import { r as runSchemaGenerator } from '../pipeline-Bj6RWt1A.js';
|
|
2
|
+
import '../types-DPgejxYC.js';
|
|
3
|
+
import '../types-CH78O90i.js';
|
|
4
|
+
import '../types-BRP7sfSF.js';
|
|
5
5
|
|
|
6
6
|
interface GenerateCommand {
|
|
7
7
|
command: 'generate';
|
|
@@ -16,12 +16,21 @@ type CliCommand = GenerateCommand | HelpCommand;
|
|
|
16
16
|
interface CliRuntime {
|
|
17
17
|
runGenerator?: typeof runSchemaGenerator;
|
|
18
18
|
log?: (message: string) => void;
|
|
19
|
+
/** Defaults to `console.error`. */
|
|
20
|
+
errorLog?: (message: string) => void;
|
|
19
21
|
}
|
|
20
22
|
declare function usage(topic?: HelpCommand['topic']): string;
|
|
21
23
|
declare function parseCommand(argv: string[]): CliCommand;
|
|
24
|
+
/**
|
|
25
|
+
* Print a CLI error to stderr with optional stack when `ATHENA_JS_DEBUG=1`.
|
|
26
|
+
*/
|
|
27
|
+
declare function logCliError(error: unknown, errorLog?: (message: string) => void): void;
|
|
22
28
|
/**
|
|
23
29
|
* CLI entrypoint used by `bin/athena-js.js`.
|
|
30
|
+
*
|
|
31
|
+
* Generator failures are logged with diagnostics (code, remote, cause chain)
|
|
32
|
+
* and exit with code `1` instead of only throwing a bare message.
|
|
24
33
|
*/
|
|
25
34
|
declare function runCLI(argv: string[], runtime?: CliRuntime): Promise<void>;
|
|
26
35
|
|
|
27
|
-
export { type CliRuntime, parseCommand, runCLI, usage };
|
|
36
|
+
export { type CliRuntime, logCliError, parseCommand, runCLI, usage };
|
package/dist/cli/index.js
CHANGED
|
@@ -2002,7 +2002,7 @@ var getSessionCookie = (request2, config) => {
|
|
|
2002
2002
|
|
|
2003
2003
|
// src/utils/athena-request-headers.ts
|
|
2004
2004
|
var NO_CACHE_HEADER_VALUE = "no-cache";
|
|
2005
|
-
var API_KEY_HEADER_CANDIDATES = ["X-Api-Key", "x-api-key", "apikey"];
|
|
2005
|
+
var API_KEY_HEADER_CANDIDATES = ["X-Athena-Key", "x-athena-key", "X-Api-Key", "x-api-key", "apikey"];
|
|
2006
2006
|
var ATHENA_KEY_HEADER_CANDIDATES = ["X-Athena-Key", "x-athena-key"];
|
|
2007
2007
|
var SESSION_TOKEN_HEADER_CANDIDATES = ["X-Athena-Auth-Session-Token"];
|
|
2008
2008
|
var BEARER_MIRROR_HEADER_CANDIDATES = ["X-Athena-Auth-Bearer-Token"];
|
|
@@ -2104,17 +2104,6 @@ function buildServiceRequestHeaders(profile, sdkHeaderValue, config, options, ex
|
|
|
2104
2104
|
});
|
|
2105
2105
|
}
|
|
2106
2106
|
function applyAthenaApiKeyHeaders(headers, apiKey, athenaKey) {
|
|
2107
|
-
if (apiKey) {
|
|
2108
|
-
if (!hasHeaderIgnoreCase(headers, "apikey")) {
|
|
2109
|
-
headers.apikey = apiKey;
|
|
2110
|
-
}
|
|
2111
|
-
if (!Object.hasOwn(headers, "x-api-key")) {
|
|
2112
|
-
headers["x-api-key"] = apiKey;
|
|
2113
|
-
}
|
|
2114
|
-
if (!Object.hasOwn(headers, "X-Api-Key")) {
|
|
2115
|
-
headers["X-Api-Key"] = apiKey;
|
|
2116
|
-
}
|
|
2117
|
-
}
|
|
2118
2107
|
const resolvedAthenaKey = normalizeHeaderValue(athenaKey) ?? normalizeHeaderValue(apiKey);
|
|
2119
2108
|
if (resolvedAthenaKey && !hasHeaderIgnoreCase(headers, "X-Athena-Key")) {
|
|
2120
2109
|
headers["X-Athena-Key"] = resolvedAthenaKey;
|
|
@@ -2240,7 +2229,7 @@ function buildAthenaRequestHeaders(input) {
|
|
|
2240
2229
|
|
|
2241
2230
|
// package.json
|
|
2242
2231
|
var package_default = {
|
|
2243
|
-
version: "2.
|
|
2232
|
+
version: "2.13.0"
|
|
2244
2233
|
};
|
|
2245
2234
|
|
|
2246
2235
|
// src/sdk-version.ts
|
|
@@ -4333,38 +4322,6 @@ function createAuthClient(config = {}) {
|
|
|
4333
4322
|
};
|
|
4334
4323
|
}
|
|
4335
4324
|
|
|
4336
|
-
// src/db/module.ts
|
|
4337
|
-
function createDbModule(input) {
|
|
4338
|
-
const db = {
|
|
4339
|
-
from: input.from,
|
|
4340
|
-
select(table, first, second) {
|
|
4341
|
-
if (first && typeof first === "object" && !Array.isArray(first)) {
|
|
4342
|
-
return input.from(table).select(void 0, first);
|
|
4343
|
-
}
|
|
4344
|
-
return input.from(table).select(first, second);
|
|
4345
|
-
},
|
|
4346
|
-
insert(table, values, options) {
|
|
4347
|
-
return Array.isArray(values) ? input.from(table).insert(values, options) : input.from(table).insert(values, options);
|
|
4348
|
-
},
|
|
4349
|
-
upsert(table, values, options) {
|
|
4350
|
-
return Array.isArray(values) ? input.from(table).upsert(values, options) : input.from(table).upsert(values, options);
|
|
4351
|
-
},
|
|
4352
|
-
update(table, values, options) {
|
|
4353
|
-
return input.from(table).update(values, options);
|
|
4354
|
-
},
|
|
4355
|
-
delete(table, options) {
|
|
4356
|
-
return input.from(table).delete(options);
|
|
4357
|
-
},
|
|
4358
|
-
rpc(fn, args, options) {
|
|
4359
|
-
return input.rpc(fn, args, options);
|
|
4360
|
-
},
|
|
4361
|
-
query(query, options) {
|
|
4362
|
-
return input.query(query, options);
|
|
4363
|
-
}
|
|
4364
|
-
};
|
|
4365
|
-
return db;
|
|
4366
|
-
}
|
|
4367
|
-
|
|
4368
4325
|
// src/storage/file.ts
|
|
4369
4326
|
function createStorageFileModule(base, config = {}) {
|
|
4370
4327
|
const upload = async (input, options) => {
|
|
@@ -9712,7 +9669,30 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9712
9669
|
config.experimental,
|
|
9713
9670
|
queryTracer
|
|
9714
9671
|
);
|
|
9715
|
-
const
|
|
9672
|
+
const untypedDbFrom = from;
|
|
9673
|
+
const db = {
|
|
9674
|
+
from,
|
|
9675
|
+
select(table, first, second) {
|
|
9676
|
+
if (first && typeof first === "object" && !Array.isArray(first)) {
|
|
9677
|
+
return untypedDbFrom(table).select(void 0, first);
|
|
9678
|
+
}
|
|
9679
|
+
return untypedDbFrom(table).select(first, second);
|
|
9680
|
+
},
|
|
9681
|
+
insert(table, values, options) {
|
|
9682
|
+
return Array.isArray(values) ? untypedDbFrom(table).insert(values, options) : untypedDbFrom(table).insert(values, options);
|
|
9683
|
+
},
|
|
9684
|
+
upsert(table, values, options) {
|
|
9685
|
+
return Array.isArray(values) ? untypedDbFrom(table).upsert(values, options) : untypedDbFrom(table).upsert(values, options);
|
|
9686
|
+
},
|
|
9687
|
+
update(table, values, options) {
|
|
9688
|
+
return untypedDbFrom(table).update(values, options);
|
|
9689
|
+
},
|
|
9690
|
+
delete(table, options) {
|
|
9691
|
+
return untypedDbFrom(table).delete(options);
|
|
9692
|
+
},
|
|
9693
|
+
rpc,
|
|
9694
|
+
query
|
|
9695
|
+
};
|
|
9716
9696
|
const chat = createChatModule({
|
|
9717
9697
|
baseUrl: config.chatUrl,
|
|
9718
9698
|
apiKey: config.apiKey,
|
|
@@ -9860,7 +9840,8 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9860
9840
|
}
|
|
9861
9841
|
return sdkClient;
|
|
9862
9842
|
}
|
|
9863
|
-
function createClient(
|
|
9843
|
+
function createClient(...args) {
|
|
9844
|
+
const [configOrUrl, apiKey, options] = args;
|
|
9864
9845
|
if (typeof configOrUrl === "string" || configOrUrl === null || configOrUrl === void 0) {
|
|
9865
9846
|
return createClientFromInput({
|
|
9866
9847
|
url: configOrUrl,
|
|
@@ -10467,6 +10448,10 @@ async function runSchemaGenerator(options = {}) {
|
|
|
10467
10448
|
}
|
|
10468
10449
|
|
|
10469
10450
|
// src/cli/index.ts
|
|
10451
|
+
function isDebugEnabled() {
|
|
10452
|
+
const value = globalThis.process?.env?.ATHENA_JS_DEBUG;
|
|
10453
|
+
return value === "1" || value === "true";
|
|
10454
|
+
}
|
|
10470
10455
|
function rootUsage() {
|
|
10471
10456
|
return [
|
|
10472
10457
|
"athena-js CLI",
|
|
@@ -10630,7 +10615,61 @@ function extractMissingDatabaseName(message) {
|
|
|
10630
10615
|
function isErrorWithCode(error) {
|
|
10631
10616
|
return typeof error === "object" && error !== null && "code" in error;
|
|
10632
10617
|
}
|
|
10618
|
+
function isNetworkConnectionError(error) {
|
|
10619
|
+
if (!isErrorWithCode(error)) {
|
|
10620
|
+
return false;
|
|
10621
|
+
}
|
|
10622
|
+
const code = typeof error.code === "string" ? error.code : "";
|
|
10623
|
+
if (code === "ECONNRESET" || code === "ECONNREFUSED" || code === "ETIMEDOUT" || code === "ENOTFOUND" || code === "EAI_AGAIN" || code === "EPIPE" || code === "EHOSTUNREACH" || code === "ENETUNREACH") {
|
|
10624
|
+
return true;
|
|
10625
|
+
}
|
|
10626
|
+
const message = normalizeErrorMessage(error).toLowerCase();
|
|
10627
|
+
return message.includes("econnreset") || message.includes("econnrefused") || message.includes("etimedout") || message.includes("connection terminated") || message.includes("connection refused") || message.includes("timeout expired");
|
|
10628
|
+
}
|
|
10629
|
+
function collectErrorDiagnostics(error) {
|
|
10630
|
+
const lines = [];
|
|
10631
|
+
if (!isErrorWithCode(error) && !(error instanceof Error)) {
|
|
10632
|
+
return lines;
|
|
10633
|
+
}
|
|
10634
|
+
const code = isErrorWithCode(error) && error.code !== void 0 ? String(error.code) : void 0;
|
|
10635
|
+
if (code) {
|
|
10636
|
+
lines.push(` code: ${code}`);
|
|
10637
|
+
}
|
|
10638
|
+
const errno = isErrorWithCode(error) && error.errno !== void 0 ? String(error.errno) : void 0;
|
|
10639
|
+
if (errno) {
|
|
10640
|
+
lines.push(` errno: ${errno}`);
|
|
10641
|
+
}
|
|
10642
|
+
const syscall = isErrorWithCode(error) && typeof error.syscall === "string" ? error.syscall : void 0;
|
|
10643
|
+
if (syscall) {
|
|
10644
|
+
lines.push(` syscall: ${syscall}`);
|
|
10645
|
+
}
|
|
10646
|
+
const address = isErrorWithCode(error) && typeof error.address === "string" ? error.address : void 0;
|
|
10647
|
+
const port = isErrorWithCode(error) && error.port !== void 0 ? String(error.port) : void 0;
|
|
10648
|
+
if (address || port) {
|
|
10649
|
+
lines.push(
|
|
10650
|
+
` remote: ${address ?? "?"}${port ? `:${port}` : ""}`
|
|
10651
|
+
);
|
|
10652
|
+
}
|
|
10653
|
+
const hostname = isErrorWithCode(error) && typeof error.hostname === "string" ? error.hostname : void 0;
|
|
10654
|
+
if (hostname) {
|
|
10655
|
+
lines.push(` hostname: ${hostname}`);
|
|
10656
|
+
}
|
|
10657
|
+
let cause = error instanceof Error ? error.cause : isErrorWithCode(error) ? error.cause : void 0;
|
|
10658
|
+
let depth = 0;
|
|
10659
|
+
while (cause && depth < 4) {
|
|
10660
|
+
const causeMessage = normalizeErrorMessage(cause);
|
|
10661
|
+
const causeCode = isErrorWithCode(cause) && cause.code !== void 0 ? String(cause.code) : void 0;
|
|
10662
|
+
lines.push(
|
|
10663
|
+
` cause[${depth}]: ${causeCode ? `${causeCode} \u2014 ` : ""}${causeMessage}`
|
|
10664
|
+
);
|
|
10665
|
+
cause = cause instanceof Error ? cause.cause : isErrorWithCode(cause) ? cause.cause : void 0;
|
|
10666
|
+
depth += 1;
|
|
10667
|
+
}
|
|
10668
|
+
return lines;
|
|
10669
|
+
}
|
|
10633
10670
|
function formatGeneratorError(error, configPath) {
|
|
10671
|
+
const diagnostics = collectErrorDiagnostics(error);
|
|
10672
|
+
const diagnosticsBlock = diagnostics.length > 0 ? ["", "Diagnostics:", ...diagnostics] : [];
|
|
10634
10673
|
if (isErrorWithCode(error) && error.code === "3D000") {
|
|
10635
10674
|
const message = normalizeErrorMessage(error);
|
|
10636
10675
|
const databaseName = extractMissingDatabaseName(message);
|
|
@@ -10639,15 +10678,58 @@ function formatGeneratorError(error, configPath) {
|
|
|
10639
10678
|
return new Error(
|
|
10640
10679
|
[
|
|
10641
10680
|
`${databaseLabel} (code 3D000).`,
|
|
10642
|
-
`Update provider.connectionString (and provider.database, if set) in ${configLabel}, or create that database before running generate
|
|
10681
|
+
`Update provider.connectionString (and provider.database, if set) in ${configLabel}, or create that database before running generate.`,
|
|
10682
|
+
...diagnosticsBlock,
|
|
10683
|
+
"",
|
|
10684
|
+
"Hint: ATHENA_JS_DEBUG=1 pnpm exec athena-js generate"
|
|
10685
|
+
].join("\n")
|
|
10686
|
+
);
|
|
10687
|
+
}
|
|
10688
|
+
if (isNetworkConnectionError(error)) {
|
|
10689
|
+
const message = normalizeErrorMessage(error);
|
|
10690
|
+
const configLabel = configPath ? `config "${configPath}"` : "the resolved athena config";
|
|
10691
|
+
const code = isErrorWithCode(error) && typeof error.code === "string" ? error.code : "network";
|
|
10692
|
+
return new Error(
|
|
10693
|
+
[
|
|
10694
|
+
`Schema introspection failed: database connection was reset or unreachable (${code}: ${message}).`,
|
|
10695
|
+
`The CLI started correctly; generate could not finish talking to Postgres for ${configLabel}.`,
|
|
10696
|
+
...diagnosticsBlock,
|
|
10697
|
+
"",
|
|
10698
|
+
"Check:",
|
|
10699
|
+
" 1. DATABASE_URL / provider.connectionString is reachable from this machine (VPN, Railway proxy, firewall).",
|
|
10700
|
+
' 2. The database is running and accepts connections (try `psql "$DATABASE_URL" -c "select 1"`).',
|
|
10701
|
+
" 3. SSL settings match the host (Railway/public proxy often needs `?sslmode=require`).",
|
|
10702
|
+
" 4. Retry once \u2014 ECONNRESET is often a transient proxy drop mid-introspection.",
|
|
10703
|
+
"",
|
|
10704
|
+
"For a full stack: ATHENA_JS_DEBUG=1 pnpm exec athena-js generate"
|
|
10643
10705
|
].join("\n")
|
|
10644
10706
|
);
|
|
10645
10707
|
}
|
|
10646
10708
|
if (error instanceof Error) {
|
|
10647
|
-
|
|
10709
|
+
if (diagnostics.length === 0 && !isDebugEnabled()) {
|
|
10710
|
+
return error;
|
|
10711
|
+
}
|
|
10712
|
+
const base = error.message || normalizeErrorMessage(error);
|
|
10713
|
+
return new Error(
|
|
10714
|
+
[
|
|
10715
|
+
base,
|
|
10716
|
+
...diagnosticsBlock,
|
|
10717
|
+
...isDebugEnabled() && error.stack ? ["", "Stack:", error.stack] : ["", "Hint: ATHENA_JS_DEBUG=1 pnpm exec athena-js generate"]
|
|
10718
|
+
].join("\n")
|
|
10719
|
+
);
|
|
10648
10720
|
}
|
|
10649
10721
|
return new Error(normalizeErrorMessage(error));
|
|
10650
10722
|
}
|
|
10723
|
+
function logCliError(error, errorLog = console.error) {
|
|
10724
|
+
const message = error instanceof Error ? error.message : normalizeErrorMessage(error);
|
|
10725
|
+
errorLog(message);
|
|
10726
|
+
if (isDebugEnabled() && error instanceof Error && error.stack) {
|
|
10727
|
+
const stackOnly = error.stack.startsWith(error.message) ? error.stack.slice(error.message.length).replace(/^\n/, "") : error.stack;
|
|
10728
|
+
if (stackOnly) {
|
|
10729
|
+
errorLog(stackOnly);
|
|
10730
|
+
}
|
|
10731
|
+
}
|
|
10732
|
+
}
|
|
10651
10733
|
function formatSkippedArtifactLine(artifact) {
|
|
10652
10734
|
if (artifact.reason === "protected-existing-file") {
|
|
10653
10735
|
return ` [skip] ${artifact.path} (existing ${artifact.kind} artifacts are protected from overwrite; delete or retarget the file to regenerate it)`;
|
|
@@ -10656,20 +10738,36 @@ function formatSkippedArtifactLine(artifact) {
|
|
|
10656
10738
|
}
|
|
10657
10739
|
async function runCLI(argv, runtime = {}) {
|
|
10658
10740
|
const log = runtime.log ?? console.log;
|
|
10741
|
+
const errorLog = runtime.errorLog ?? console.error;
|
|
10659
10742
|
const runGenerator = runtime.runGenerator ?? runSchemaGenerator;
|
|
10660
|
-
|
|
10743
|
+
let parsed;
|
|
10744
|
+
try {
|
|
10745
|
+
parsed = parseCommand(argv);
|
|
10746
|
+
} catch (error) {
|
|
10747
|
+
logCliError(formatGeneratorError(error), errorLog);
|
|
10748
|
+
process.exitCode = 1;
|
|
10749
|
+
return;
|
|
10750
|
+
}
|
|
10661
10751
|
if (parsed.command === "help") {
|
|
10662
10752
|
log(usage(parsed.topic));
|
|
10663
10753
|
return;
|
|
10664
10754
|
}
|
|
10665
10755
|
let result;
|
|
10666
10756
|
try {
|
|
10757
|
+
if (isDebugEnabled()) {
|
|
10758
|
+
errorLog(
|
|
10759
|
+
`[athena-js] generate starting (dryRun=${parsed.dryRun}${parsed.configPath ? ` config=${parsed.configPath}` : ""})`
|
|
10760
|
+
);
|
|
10761
|
+
}
|
|
10667
10762
|
result = await runGenerator({
|
|
10668
10763
|
configPath: parsed.configPath,
|
|
10669
10764
|
dryRun: parsed.dryRun
|
|
10670
10765
|
});
|
|
10671
10766
|
} catch (error) {
|
|
10672
|
-
|
|
10767
|
+
const formatted = formatGeneratorError(error, parsed.configPath);
|
|
10768
|
+
logCliError(formatted, errorLog);
|
|
10769
|
+
process.exitCode = 1;
|
|
10770
|
+
return;
|
|
10673
10771
|
}
|
|
10674
10772
|
if (parsed.dryRun) {
|
|
10675
10773
|
log(`[dry-run] Generated ${result.files.length} files from ${result.configPath}`);
|
|
@@ -10693,6 +10791,6 @@ async function runCLI(argv, runtime = {}) {
|
|
|
10693
10791
|
}
|
|
10694
10792
|
}
|
|
10695
10793
|
|
|
10696
|
-
export { parseCommand, runCLI, usage };
|
|
10794
|
+
export { logCliError, parseCommand, runCLI, usage };
|
|
10697
10795
|
//# sourceMappingURL=index.js.map
|
|
10698
10796
|
//# sourceMappingURL=index.js.map
|