@xylex-group/athena 2.12.0 → 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 -46
- 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 -46
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +150 -48
- 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 -49
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-QUbAs7E8.d.ts → client-BJjUwDSg.d.cts} +109 -1448
- package/dist/{client-C3x75Zgn.d.cts → 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 -46
- 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 -47
- package/dist/index.js.map +1 -1
- package/dist/{model-form-CD1uhWSh.d.cts → model-form-Dw4zEL5a.d.cts} +2 -2
- package/dist/{model-form-Dm69I-oO.d.ts → model-form-yRg71q3H.d.ts} +2 -2
- package/dist/{module-CW3tWJ10.d.ts → module-DBteUIob.d.ts} +12 -9
- package/dist/{module-Cxcurfes.d.cts → module-yoX49uQC.d.cts} +12 -9
- package/dist/next/client.cjs +452 -46
- 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 -47
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +292 -46
- 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 -47
- 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-BAwb6Vzm.d.ts → pipeline-Bj6RWt1A.d.ts} +1 -1
- package/dist/{pipeline-B14jVK7J.d.cts → pipeline-Dwck-wZO.d.cts} +1 -1
- package/dist/react.cjs +2 -10
- 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 -10
- 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-Cq4-NoB4.d.ts → types-BRP7sfSF.d.ts} +50 -2
- package/dist/{types-Dr849HD6.d.cts → types-BU8uJH_b.d.cts} +50 -2
- package/dist/{types-CwJCPpLD.d.ts → types-CH78O90i.d.cts} +2 -2
- package/dist/{types-CwJCPpLD.d.cts → types-CH78O90i.d.ts} +2 -2
- package/dist/{types-DMOoYnPS.d.cts → types-CjC9_5ZQ.d.cts} +3 -3
- package/dist/{types-BcVmPBP-.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 -12
- 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 -13
- package/dist/utils.js.map +1 -1
- package/package.json +49 -22
- package/dist/shared-0Kdc74lu.d.ts +0 -35
- package/dist/shared-C0wVICRv.d.cts +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", "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,14 +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 (!hasHeaderIgnoreCase(headers, "x-api-key")) {
|
|
2112
|
-
headers["x-api-key"] = apiKey;
|
|
2113
|
-
}
|
|
2114
|
-
}
|
|
2115
2107
|
const resolvedAthenaKey = normalizeHeaderValue(athenaKey) ?? normalizeHeaderValue(apiKey);
|
|
2116
2108
|
if (resolvedAthenaKey && !hasHeaderIgnoreCase(headers, "X-Athena-Key")) {
|
|
2117
2109
|
headers["X-Athena-Key"] = resolvedAthenaKey;
|
|
@@ -2237,7 +2229,7 @@ function buildAthenaRequestHeaders(input) {
|
|
|
2237
2229
|
|
|
2238
2230
|
// package.json
|
|
2239
2231
|
var package_default = {
|
|
2240
|
-
version: "2.
|
|
2232
|
+
version: "2.13.0"
|
|
2241
2233
|
};
|
|
2242
2234
|
|
|
2243
2235
|
// src/sdk-version.ts
|
|
@@ -4330,38 +4322,6 @@ function createAuthClient(config = {}) {
|
|
|
4330
4322
|
};
|
|
4331
4323
|
}
|
|
4332
4324
|
|
|
4333
|
-
// src/db/module.ts
|
|
4334
|
-
function createDbModule(input) {
|
|
4335
|
-
const db = {
|
|
4336
|
-
from: input.from,
|
|
4337
|
-
select(table, first, second) {
|
|
4338
|
-
if (first && typeof first === "object" && !Array.isArray(first)) {
|
|
4339
|
-
return input.from(table).select(void 0, first);
|
|
4340
|
-
}
|
|
4341
|
-
return input.from(table).select(first, second);
|
|
4342
|
-
},
|
|
4343
|
-
insert(table, values, options) {
|
|
4344
|
-
return Array.isArray(values) ? input.from(table).insert(values, options) : input.from(table).insert(values, options);
|
|
4345
|
-
},
|
|
4346
|
-
upsert(table, values, options) {
|
|
4347
|
-
return Array.isArray(values) ? input.from(table).upsert(values, options) : input.from(table).upsert(values, options);
|
|
4348
|
-
},
|
|
4349
|
-
update(table, values, options) {
|
|
4350
|
-
return input.from(table).update(values, options);
|
|
4351
|
-
},
|
|
4352
|
-
delete(table, options) {
|
|
4353
|
-
return input.from(table).delete(options);
|
|
4354
|
-
},
|
|
4355
|
-
rpc(fn, args, options) {
|
|
4356
|
-
return input.rpc(fn, args, options);
|
|
4357
|
-
},
|
|
4358
|
-
query(query, options) {
|
|
4359
|
-
return input.query(query, options);
|
|
4360
|
-
}
|
|
4361
|
-
};
|
|
4362
|
-
return db;
|
|
4363
|
-
}
|
|
4364
|
-
|
|
4365
4325
|
// src/storage/file.ts
|
|
4366
4326
|
function createStorageFileModule(base, config = {}) {
|
|
4367
4327
|
const upload = async (input, options) => {
|
|
@@ -9709,7 +9669,30 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9709
9669
|
config.experimental,
|
|
9710
9670
|
queryTracer
|
|
9711
9671
|
);
|
|
9712
|
-
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
|
+
};
|
|
9713
9696
|
const chat = createChatModule({
|
|
9714
9697
|
baseUrl: config.chatUrl,
|
|
9715
9698
|
apiKey: config.apiKey,
|
|
@@ -9857,7 +9840,8 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
9857
9840
|
}
|
|
9858
9841
|
return sdkClient;
|
|
9859
9842
|
}
|
|
9860
|
-
function createClient(
|
|
9843
|
+
function createClient(...args) {
|
|
9844
|
+
const [configOrUrl, apiKey, options] = args;
|
|
9861
9845
|
if (typeof configOrUrl === "string" || configOrUrl === null || configOrUrl === void 0) {
|
|
9862
9846
|
return createClientFromInput({
|
|
9863
9847
|
url: configOrUrl,
|
|
@@ -10464,6 +10448,10 @@ async function runSchemaGenerator(options = {}) {
|
|
|
10464
10448
|
}
|
|
10465
10449
|
|
|
10466
10450
|
// src/cli/index.ts
|
|
10451
|
+
function isDebugEnabled() {
|
|
10452
|
+
const value = globalThis.process?.env?.ATHENA_JS_DEBUG;
|
|
10453
|
+
return value === "1" || value === "true";
|
|
10454
|
+
}
|
|
10467
10455
|
function rootUsage() {
|
|
10468
10456
|
return [
|
|
10469
10457
|
"athena-js CLI",
|
|
@@ -10627,7 +10615,61 @@ function extractMissingDatabaseName(message) {
|
|
|
10627
10615
|
function isErrorWithCode(error) {
|
|
10628
10616
|
return typeof error === "object" && error !== null && "code" in error;
|
|
10629
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
|
+
}
|
|
10630
10670
|
function formatGeneratorError(error, configPath) {
|
|
10671
|
+
const diagnostics = collectErrorDiagnostics(error);
|
|
10672
|
+
const diagnosticsBlock = diagnostics.length > 0 ? ["", "Diagnostics:", ...diagnostics] : [];
|
|
10631
10673
|
if (isErrorWithCode(error) && error.code === "3D000") {
|
|
10632
10674
|
const message = normalizeErrorMessage(error);
|
|
10633
10675
|
const databaseName = extractMissingDatabaseName(message);
|
|
@@ -10636,15 +10678,58 @@ function formatGeneratorError(error, configPath) {
|
|
|
10636
10678
|
return new Error(
|
|
10637
10679
|
[
|
|
10638
10680
|
`${databaseLabel} (code 3D000).`,
|
|
10639
|
-
`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"
|
|
10640
10705
|
].join("\n")
|
|
10641
10706
|
);
|
|
10642
10707
|
}
|
|
10643
10708
|
if (error instanceof Error) {
|
|
10644
|
-
|
|
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
|
+
);
|
|
10645
10720
|
}
|
|
10646
10721
|
return new Error(normalizeErrorMessage(error));
|
|
10647
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
|
+
}
|
|
10648
10733
|
function formatSkippedArtifactLine(artifact) {
|
|
10649
10734
|
if (artifact.reason === "protected-existing-file") {
|
|
10650
10735
|
return ` [skip] ${artifact.path} (existing ${artifact.kind} artifacts are protected from overwrite; delete or retarget the file to regenerate it)`;
|
|
@@ -10653,20 +10738,36 @@ function formatSkippedArtifactLine(artifact) {
|
|
|
10653
10738
|
}
|
|
10654
10739
|
async function runCLI(argv, runtime = {}) {
|
|
10655
10740
|
const log = runtime.log ?? console.log;
|
|
10741
|
+
const errorLog = runtime.errorLog ?? console.error;
|
|
10656
10742
|
const runGenerator = runtime.runGenerator ?? runSchemaGenerator;
|
|
10657
|
-
|
|
10743
|
+
let parsed;
|
|
10744
|
+
try {
|
|
10745
|
+
parsed = parseCommand(argv);
|
|
10746
|
+
} catch (error) {
|
|
10747
|
+
logCliError(formatGeneratorError(error), errorLog);
|
|
10748
|
+
process.exitCode = 1;
|
|
10749
|
+
return;
|
|
10750
|
+
}
|
|
10658
10751
|
if (parsed.command === "help") {
|
|
10659
10752
|
log(usage(parsed.topic));
|
|
10660
10753
|
return;
|
|
10661
10754
|
}
|
|
10662
10755
|
let result;
|
|
10663
10756
|
try {
|
|
10757
|
+
if (isDebugEnabled()) {
|
|
10758
|
+
errorLog(
|
|
10759
|
+
`[athena-js] generate starting (dryRun=${parsed.dryRun}${parsed.configPath ? ` config=${parsed.configPath}` : ""})`
|
|
10760
|
+
);
|
|
10761
|
+
}
|
|
10664
10762
|
result = await runGenerator({
|
|
10665
10763
|
configPath: parsed.configPath,
|
|
10666
10764
|
dryRun: parsed.dryRun
|
|
10667
10765
|
});
|
|
10668
10766
|
} catch (error) {
|
|
10669
|
-
|
|
10767
|
+
const formatted = formatGeneratorError(error, parsed.configPath);
|
|
10768
|
+
logCliError(formatted, errorLog);
|
|
10769
|
+
process.exitCode = 1;
|
|
10770
|
+
return;
|
|
10670
10771
|
}
|
|
10671
10772
|
if (parsed.dryRun) {
|
|
10672
10773
|
log(`[dry-run] Generated ${result.files.length} files from ${result.configPath}`);
|
|
@@ -10690,6 +10791,6 @@ async function runCLI(argv, runtime = {}) {
|
|
|
10690
10791
|
}
|
|
10691
10792
|
}
|
|
10692
10793
|
|
|
10693
|
-
export { parseCommand, runCLI, usage };
|
|
10794
|
+
export { logCliError, parseCommand, runCLI, usage };
|
|
10694
10795
|
//# sourceMappingURL=index.js.map
|
|
10695
10796
|
//# sourceMappingURL=index.js.map
|