@xylex-group/athena 3.0.3 → 3.3.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/README.md +1 -1
- package/dist/admin.cjs +55 -1
- package/dist/admin.cjs.map +1 -1
- package/dist/admin.d.cts +32 -8
- package/dist/admin.d.ts +32 -8
- package/dist/admin.js +54 -2
- package/dist/admin.js.map +1 -1
- package/dist/athena-auth-url-C1FbVmN6.d.cts +200 -0
- package/dist/athena-auth-url-C1FbVmN6.d.ts +200 -0
- package/dist/{athena-request-headers-C7Jy-c_D.d.ts → athena-request-headers-DzimbvOA.d.ts} +48 -200
- package/dist/{athena-request-headers-DujFFyMU.d.cts → athena-request-headers-Lr_m8xCV.d.cts} +48 -200
- package/dist/billing.cjs +1 -1
- package/dist/billing.cjs.map +1 -1
- package/dist/billing.js +1 -1
- package/dist/billing.js.map +1 -1
- package/dist/browser.cjs +912 -5
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +8 -7
- package/dist/browser.d.ts +8 -7
- package/dist/browser.js +881 -6
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +7909 -7061
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +17 -10
- package/dist/cli/index.d.ts +17 -10
- package/dist/cli/index.js +7911 -7063
- package/dist/cli/index.js.map +1 -1
- package/dist/env.cjs +130 -0
- package/dist/env.cjs.map +1 -0
- package/dist/env.d.cts +70 -0
- package/dist/env.d.ts +70 -0
- package/dist/env.js +122 -0
- package/dist/env.js.map +1 -0
- package/dist/index.cjs +1570 -98
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -8
- package/dist/index.d.ts +31 -8
- package/dist/index.js +1532 -100
- package/dist/index.js.map +1 -1
- package/dist/model-form-3Gr8rkdT.d.cts +281 -0
- package/dist/model-form-CotpEL7z.d.ts +281 -0
- package/dist/{module-CPG3ULxQ.d.cts → module-CQmOaDzP.d.cts} +4 -4
- package/dist/{module-BruTcxe0.d.ts → module-CWkUTcUc.d.ts} +4 -4
- package/dist/next/client.cjs +123 -7
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.cts +4 -3
- package/dist/next/client.d.ts +4 -3
- package/dist/next/client.js +123 -7
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +1130 -364
- package/dist/next/server.cjs.map +1 -1
- package/dist/next/server.d.cts +121 -8
- package/dist/next/server.d.ts +121 -8
- package/dist/next/server.js +1120 -365
- package/dist/next/server.js.map +1 -1
- package/dist/pipeline-BnRKO_Pd.d.cts +93 -0
- package/dist/pipeline-sWCmlFqu.d.ts +93 -0
- package/dist/{proxy-request-headers-m4D2Tduy.d.ts → proxy-request-headers-CttlcuRb.d.ts} +1 -1
- package/dist/{proxy-request-headers-DGxdoyA0.d.cts → proxy-request-headers-pIBSn1Fw.d.cts} +1 -1
- package/dist/react.cjs +672 -16
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +123 -8
- package/dist/react.d.ts +123 -8
- package/dist/react.js +671 -17
- package/dist/react.js.map +1 -1
- package/dist/schema-handlers-BtT_IQFi.d.cts +138 -0
- package/dist/schema-handlers-VjFDhIMw.d.ts +138 -0
- package/dist/social-providers.d.cts +1 -1
- package/dist/social-providers.d.ts +1 -1
- package/dist/{types-D6tZ9aoq.d.ts → types-BDX8zS7w.d.ts} +40 -1
- package/dist/{types-AOY-GLu8.d.cts → types-BVKpQmfY.d.cts} +11 -0
- package/dist/{types-AOY-GLu8.d.ts → types-BVKpQmfY.d.ts} +11 -0
- package/dist/{types-DFr2cL1N.d.cts → types-D-Am7YSd.d.cts} +40 -1
- package/dist/utils.cjs +30 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +3 -2
- package/dist/utils.d.ts +3 -2
- package/dist/utils.js +30 -1
- package/dist/utils.js.map +1 -1
- package/dist/{v3-client-CWfZHcKL.d.cts → v3-client-G1SLeHRa.d.cts} +23 -1
- package/dist/{v3-client-DZp2NEhK.d.ts → v3-client-ao8BWQ8v.d.ts} +23 -1
- package/package.json +16 -2
- package/dist/model-form-Dh0sisdL.d.ts +0 -97
- package/dist/model-form-oOAJUVd4.d.cts +0 -97
- package/dist/pipeline-CIzV9f7b.d.cts +0 -8
- package/dist/pipeline-DNlc8Ayn.d.ts +0 -8
package/dist/index.cjs
CHANGED
|
@@ -573,8 +573,8 @@ function computeDelayMs(attempt, error, config) {
|
|
|
573
573
|
}
|
|
574
574
|
function sleep(ms) {
|
|
575
575
|
if (ms <= 0) return Promise.resolve();
|
|
576
|
-
return new Promise((
|
|
577
|
-
setTimeout(
|
|
576
|
+
return new Promise((resolve4) => {
|
|
577
|
+
setTimeout(resolve4, ms);
|
|
578
578
|
});
|
|
579
579
|
}
|
|
580
580
|
async function withRetry(config, fn) {
|
|
@@ -2009,7 +2009,7 @@ function buildAthenaGatewayUrl(baseUrl, path) {
|
|
|
2009
2009
|
|
|
2010
2010
|
// package.json
|
|
2011
2011
|
var package_default = {
|
|
2012
|
-
version: "3.0
|
|
2012
|
+
version: "3.3.0"
|
|
2013
2013
|
};
|
|
2014
2014
|
|
|
2015
2015
|
// src/sdk-version.ts
|
|
@@ -4769,6 +4769,14 @@ function createAuthModule(config = {}, runtimeOptions = {}) {
|
|
|
4769
4769
|
changeEmailVerify: (input, options) => getWithQuery("/change-email/verify", input, options),
|
|
4770
4770
|
deleteUserVerify: (input, options) => getWithQuery("/delete-user/verify", input, options),
|
|
4771
4771
|
changePassword: (input, options) => postGeneric("/change-password", input, options),
|
|
4772
|
+
// Better Auth UI flat method aliases (also nested under session/account/social/user).
|
|
4773
|
+
listSessions: (input, options) => getGeneric("/list-sessions", input, options),
|
|
4774
|
+
revokeSession: sessionRevokeBinding,
|
|
4775
|
+
revokeOtherSessions,
|
|
4776
|
+
listAccounts: (input, options) => getGeneric("/list-accounts", input, options),
|
|
4777
|
+
unlinkAccount: (input, options) => postGeneric("/unlink-account", input, options),
|
|
4778
|
+
linkSocial: (input, options) => postGeneric("/link-social", input, options),
|
|
4779
|
+
updateUser: (input, options) => postGeneric("/update-user", input, options),
|
|
4772
4780
|
user: {
|
|
4773
4781
|
update: (input, options) => postGeneric("/update-user", input, options),
|
|
4774
4782
|
delete: (input, options) => postGeneric("/delete-user", input, options),
|
|
@@ -5228,7 +5236,7 @@ async function putWithXhr(url, signed, body, signal, onProgress) {
|
|
|
5228
5236
|
if (Xhr === void 0) {
|
|
5229
5237
|
return Promise.reject(new Error("athena.storage.file.upload direct mode requires XMLHttpRequest in this runtime"));
|
|
5230
5238
|
}
|
|
5231
|
-
return new Promise((
|
|
5239
|
+
return new Promise((resolve4, reject) => {
|
|
5232
5240
|
const xhr = new Xhr();
|
|
5233
5241
|
const abort = () => xhr.abort();
|
|
5234
5242
|
xhr.open("PUT", url);
|
|
@@ -5241,7 +5249,7 @@ async function putWithXhr(url, signed, body, signal, onProgress) {
|
|
|
5241
5249
|
return;
|
|
5242
5250
|
}
|
|
5243
5251
|
onProgress({ loaded: bodySize(body) });
|
|
5244
|
-
|
|
5252
|
+
resolve4(new Response(xhr.response, {
|
|
5245
5253
|
status: xhr.status,
|
|
5246
5254
|
statusText: xhr.statusText,
|
|
5247
5255
|
headers: parseXhrHeaders(xhr.getAllResponseHeaders())
|
|
@@ -5694,7 +5702,7 @@ function putUploadBodyWithXhr(url, source, headers, options, onProgress) {
|
|
|
5694
5702
|
if (Xhr === void 0) {
|
|
5695
5703
|
return Promise.reject(new Error("athena.storage.file.upload requires XMLHttpRequest in this runtime"));
|
|
5696
5704
|
}
|
|
5697
|
-
return new Promise((
|
|
5705
|
+
return new Promise((resolve4, reject) => {
|
|
5698
5706
|
const xhr = new Xhr();
|
|
5699
5707
|
const abort = () => xhr.abort();
|
|
5700
5708
|
xhr.open("PUT", url);
|
|
@@ -5711,7 +5719,7 @@ function putUploadBodyWithXhr(url, source, headers, options, onProgress) {
|
|
|
5711
5719
|
return;
|
|
5712
5720
|
}
|
|
5713
5721
|
onProgress({ loaded: source.sizeBytes });
|
|
5714
|
-
|
|
5722
|
+
resolve4(new Response(xhr.response, {
|
|
5715
5723
|
status: xhr.status,
|
|
5716
5724
|
statusText: xhr.statusText,
|
|
5717
5725
|
headers: parseXhrHeaders2(xhr.getAllResponseHeaders())
|
|
@@ -10578,6 +10586,82 @@ function mergeAthenaRequestContexts(base, override) {
|
|
|
10578
10586
|
};
|
|
10579
10587
|
}
|
|
10580
10588
|
|
|
10589
|
+
// src/diagnostics.ts
|
|
10590
|
+
function readProcessEnv2() {
|
|
10591
|
+
try {
|
|
10592
|
+
return globalThis.process?.env ?? {};
|
|
10593
|
+
} catch {
|
|
10594
|
+
return {};
|
|
10595
|
+
}
|
|
10596
|
+
}
|
|
10597
|
+
function isTruthyEnv(value) {
|
|
10598
|
+
if (!value) return false;
|
|
10599
|
+
const normalized = value.trim().toLowerCase();
|
|
10600
|
+
return normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on";
|
|
10601
|
+
}
|
|
10602
|
+
function isQuietAthenaDiagnosticsEnvironment(env = readProcessEnv2()) {
|
|
10603
|
+
const nodeEnv = env.NODE_ENV?.trim().toLowerCase();
|
|
10604
|
+
if (nodeEnv === "production") {
|
|
10605
|
+
return true;
|
|
10606
|
+
}
|
|
10607
|
+
if (isTruthyEnv(env.OPENNEXT_BUILD)) {
|
|
10608
|
+
return true;
|
|
10609
|
+
}
|
|
10610
|
+
const nextPhase = env.NEXT_PHASE?.trim();
|
|
10611
|
+
if (nextPhase === "phase-production-build") {
|
|
10612
|
+
return true;
|
|
10613
|
+
}
|
|
10614
|
+
if (isTruthyEnv(env.CI) && nodeEnv !== "test") {
|
|
10615
|
+
if (nodeEnv === "production" || isTruthyEnv(env.OPENNEXT_BUILD)) {
|
|
10616
|
+
return true;
|
|
10617
|
+
}
|
|
10618
|
+
}
|
|
10619
|
+
return false;
|
|
10620
|
+
}
|
|
10621
|
+
function resolveBooleanFlag(explicit, mode, quiet) {
|
|
10622
|
+
if (typeof explicit === "boolean") {
|
|
10623
|
+
return explicit;
|
|
10624
|
+
}
|
|
10625
|
+
if (mode === true) {
|
|
10626
|
+
return true;
|
|
10627
|
+
}
|
|
10628
|
+
if (mode === false) {
|
|
10629
|
+
return false;
|
|
10630
|
+
}
|
|
10631
|
+
if (mode === "auto") {
|
|
10632
|
+
return false;
|
|
10633
|
+
}
|
|
10634
|
+
return false;
|
|
10635
|
+
}
|
|
10636
|
+
function resolveAthenaClientDiagnostics(input) {
|
|
10637
|
+
const env = input.env ?? readProcessEnv2();
|
|
10638
|
+
const quiet = isQuietAthenaDiagnosticsEnvironment(env);
|
|
10639
|
+
const mode = input.diagnostics;
|
|
10640
|
+
const effectiveMode = mode === "auto" && quiet ? false : mode;
|
|
10641
|
+
const debugAst = resolveBooleanFlag(input.debugAst, effectiveMode);
|
|
10642
|
+
const findManyAst = resolveBooleanFlag(input.findManyAst, effectiveMode);
|
|
10643
|
+
let traceQueries;
|
|
10644
|
+
if (input.traceQueries !== void 0) {
|
|
10645
|
+
if (typeof input.traceQueries === "boolean") {
|
|
10646
|
+
traceQueries = input.traceQueries;
|
|
10647
|
+
} else if (effectiveMode === false || mode === "auto" && quiet) {
|
|
10648
|
+
const enabled = input.traceQueries.enabled;
|
|
10649
|
+
traceQueries = typeof enabled === "boolean" ? enabled ? input.traceQueries : false : false;
|
|
10650
|
+
} else {
|
|
10651
|
+
traceQueries = input.traceQueries;
|
|
10652
|
+
}
|
|
10653
|
+
} else if (effectiveMode === true) {
|
|
10654
|
+
traceQueries = true;
|
|
10655
|
+
} else {
|
|
10656
|
+
traceQueries = false;
|
|
10657
|
+
}
|
|
10658
|
+
return {
|
|
10659
|
+
debugAst,
|
|
10660
|
+
findManyAst,
|
|
10661
|
+
traceQueries
|
|
10662
|
+
};
|
|
10663
|
+
}
|
|
10664
|
+
|
|
10581
10665
|
// src/v3-client.ts
|
|
10582
10666
|
var ENV_URL_KEYS = ["ATHENA_URL", "NEXT_PUBLIC_ATHENA_URL"];
|
|
10583
10667
|
var ENV_DB_URL_KEYS = ["ATHENA_DB_URL", "ATHENA_GATEWAY_URL", "NEXT_PUBLIC_ATHENA_DB_API_URL"];
|
|
@@ -10586,7 +10670,13 @@ var ENV_CHAT_URL_KEYS = ["ATHENA_CHAT_URL", "NEXT_PUBLIC_ATHENA_CHAT_URL"];
|
|
|
10586
10670
|
var ENV_CHAT_WS_URL_KEYS = ["ATHENA_CHAT_WS_URL", "NEXT_PUBLIC_ATHENA_CHAT_WS_URL"];
|
|
10587
10671
|
var ENV_STORAGE_URL_KEYS = ["ATHENA_STORAGE_URL", "NEXT_PUBLIC_ATHENA_STORAGE_URL"];
|
|
10588
10672
|
var ENV_KEY_KEYS = ["ATHENA_API_KEY", "NEXT_PUBLIC_ATHENA_API_KEY", "ATHENA_GATEWAY_API_KEY", "X_API_KEY"];
|
|
10589
|
-
var ENV_CLIENT_KEYS = [
|
|
10673
|
+
var ENV_CLIENT_KEYS = [
|
|
10674
|
+
"ATHENA_CLIENT",
|
|
10675
|
+
"ATHENA_GATEWAY_CLIENT",
|
|
10676
|
+
"ATHENA_GENERATOR_CLIENT",
|
|
10677
|
+
"NEXT_PUBLIC_ATHENA_CLIENT",
|
|
10678
|
+
"NEXT_PUBLIC_ATHENA_GATEWAY_CLIENT"
|
|
10679
|
+
];
|
|
10590
10680
|
var MISSING_DB_SENTINEL = "https://athena.invalid/db";
|
|
10591
10681
|
function readFirstEnv(env, keys) {
|
|
10592
10682
|
for (const key of keys) {
|
|
@@ -10661,6 +10751,13 @@ function createInternalConfig(core) {
|
|
|
10661
10751
|
const { config, urls } = core;
|
|
10662
10752
|
const { url: _authUrl, ...authOptions } = config.auth ?? {};
|
|
10663
10753
|
const { url: _storageUrl, directUpload, ...storageOptions } = config.storage ?? {};
|
|
10754
|
+
const diagnostics = resolveAthenaClientDiagnostics({
|
|
10755
|
+
diagnostics: config.diagnostics,
|
|
10756
|
+
debugAst: config.debugAst,
|
|
10757
|
+
findManyAst: config.findManyAst,
|
|
10758
|
+
traceQueries: config.traceQueries,
|
|
10759
|
+
env: config.env
|
|
10760
|
+
});
|
|
10664
10761
|
return {
|
|
10665
10762
|
baseUrl: urls.db ?? MISSING_DB_SENTINEL,
|
|
10666
10763
|
apiKey: core.key,
|
|
@@ -10677,9 +10774,9 @@ function createInternalConfig(core) {
|
|
|
10677
10774
|
models: config.models,
|
|
10678
10775
|
behavior: {
|
|
10679
10776
|
retryReads: config.retryReads,
|
|
10680
|
-
traceQueries:
|
|
10681
|
-
debugAst:
|
|
10682
|
-
findManyAst:
|
|
10777
|
+
traceQueries: diagnostics.traceQueries,
|
|
10778
|
+
debugAst: diagnostics.debugAst,
|
|
10779
|
+
findManyAst: diagnostics.findManyAst
|
|
10683
10780
|
},
|
|
10684
10781
|
storage: {
|
|
10685
10782
|
...storageOptions,
|
|
@@ -10753,11 +10850,30 @@ function createClientView(core, viewContext) {
|
|
|
10753
10850
|
return resolved.verifyConnection(options);
|
|
10754
10851
|
},
|
|
10755
10852
|
withContext(context) {
|
|
10853
|
+
warnIfEmptyRequestContext(context);
|
|
10756
10854
|
return createClientView(core, mergeAthenaRequestContexts(viewContext, context));
|
|
10757
10855
|
}
|
|
10758
10856
|
};
|
|
10759
10857
|
return Object.freeze(client);
|
|
10760
10858
|
}
|
|
10859
|
+
function isEmptyAthenaRequestContext(context) {
|
|
10860
|
+
if (!context) return true;
|
|
10861
|
+
const hasHeaders = context.headers != null && Object.keys(context.headers).length > 0;
|
|
10862
|
+
return context.userId == null && context.organizationId == null && !normalizeOptionalContextString(context.cookie) && !normalizeOptionalContextString(context.bearerToken) && !normalizeOptionalContextString(context.sessionToken) && !context.forceNoCache && !hasHeaders;
|
|
10863
|
+
}
|
|
10864
|
+
function normalizeOptionalContextString(value) {
|
|
10865
|
+
const trimmed = value?.trim();
|
|
10866
|
+
return trimmed || void 0;
|
|
10867
|
+
}
|
|
10868
|
+
function warnIfEmptyRequestContext(context) {
|
|
10869
|
+
if (!isEmptyAthenaRequestContext(context)) return;
|
|
10870
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") {
|
|
10871
|
+
return;
|
|
10872
|
+
}
|
|
10873
|
+
console.warn(
|
|
10874
|
+
"[athena] withContext({}) has no userId, organizationId, cookie, bearerToken, sessionToken, headers, or forceNoCache. Gateway scope headers will not change. Pass identity fields, or use createAthenaServerClient({ session, scope })."
|
|
10875
|
+
);
|
|
10876
|
+
}
|
|
10761
10877
|
function createClient(config) {
|
|
10762
10878
|
return createClientView(resolveCore(config));
|
|
10763
10879
|
}
|
|
@@ -10770,6 +10886,339 @@ var Backend = {
|
|
|
10770
10886
|
ScyllaDB: { type: "scylladb" }
|
|
10771
10887
|
};
|
|
10772
10888
|
|
|
10889
|
+
// src/query/read-query.ts
|
|
10890
|
+
function normalizeAthenaReadQueryOrderBy(orderBy) {
|
|
10891
|
+
if (!orderBy) {
|
|
10892
|
+
return [];
|
|
10893
|
+
}
|
|
10894
|
+
const list = Array.isArray(orderBy) ? orderBy : [orderBy];
|
|
10895
|
+
return list.filter(
|
|
10896
|
+
(entry) => entry && typeof entry.column === "string" && entry.column.trim().length > 0
|
|
10897
|
+
);
|
|
10898
|
+
}
|
|
10899
|
+
function isRecord12(value) {
|
|
10900
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10901
|
+
}
|
|
10902
|
+
function flattenAthenaRowValue(row, column) {
|
|
10903
|
+
if (!column.relation) {
|
|
10904
|
+
return row[column.column];
|
|
10905
|
+
}
|
|
10906
|
+
const relationValue = row[column.relation.name];
|
|
10907
|
+
if (Array.isArray(relationValue)) {
|
|
10908
|
+
return relationValue.map((entry) => isRecord12(entry) ? entry[column.column] : void 0).filter((entry) => entry !== void 0);
|
|
10909
|
+
}
|
|
10910
|
+
if (isRecord12(relationValue)) {
|
|
10911
|
+
return relationValue[column.column];
|
|
10912
|
+
}
|
|
10913
|
+
return void 0;
|
|
10914
|
+
}
|
|
10915
|
+
function resolveFlatRowKey(row, index, preferredKey) {
|
|
10916
|
+
const preferredValue = preferredKey && preferredKey in row ? row[preferredKey] : void 0;
|
|
10917
|
+
if (preferredValue !== void 0 && preferredValue !== null && `${preferredValue}`.trim().length > 0) {
|
|
10918
|
+
return String(preferredValue);
|
|
10919
|
+
}
|
|
10920
|
+
for (const [key, value] of Object.entries(row)) {
|
|
10921
|
+
if (key === "__rowKey") {
|
|
10922
|
+
continue;
|
|
10923
|
+
}
|
|
10924
|
+
if (value === void 0 || value === null) {
|
|
10925
|
+
continue;
|
|
10926
|
+
}
|
|
10927
|
+
if (Array.isArray(value)) {
|
|
10928
|
+
if (value.length > 0) {
|
|
10929
|
+
return `${key}-${value.join("-")}`;
|
|
10930
|
+
}
|
|
10931
|
+
continue;
|
|
10932
|
+
}
|
|
10933
|
+
const nextValue = String(value).trim();
|
|
10934
|
+
if (nextValue.length > 0) {
|
|
10935
|
+
return nextValue;
|
|
10936
|
+
}
|
|
10937
|
+
}
|
|
10938
|
+
return `row-${index + 1}`;
|
|
10939
|
+
}
|
|
10940
|
+
function flattenAthenaReadQueryRows(rows, columns, preferredKey) {
|
|
10941
|
+
return rows.map((entry, index) => {
|
|
10942
|
+
const sourceRow = isRecord12(entry) ? entry : {};
|
|
10943
|
+
const flatRow = columns.reduce(
|
|
10944
|
+
(currentRow, column) => {
|
|
10945
|
+
currentRow[column.key] = flattenAthenaRowValue(sourceRow, column);
|
|
10946
|
+
return currentRow;
|
|
10947
|
+
},
|
|
10948
|
+
{ __rowKey: "" }
|
|
10949
|
+
);
|
|
10950
|
+
flatRow.__rowKey = resolveFlatRowKey(flatRow, index, preferredKey);
|
|
10951
|
+
return flatRow;
|
|
10952
|
+
});
|
|
10953
|
+
}
|
|
10954
|
+
var flattenAthenaRows = flattenAthenaReadQueryRows;
|
|
10955
|
+
function buildAthenaReadQuerySelectString(columns) {
|
|
10956
|
+
const baseColumns = columns.filter((column) => !column.relation).map((column) => column.column);
|
|
10957
|
+
const relationGroups = /* @__PURE__ */ new Map();
|
|
10958
|
+
for (const column of columns) {
|
|
10959
|
+
if (!column.relation) {
|
|
10960
|
+
continue;
|
|
10961
|
+
}
|
|
10962
|
+
const groupKey = [
|
|
10963
|
+
column.relation.name,
|
|
10964
|
+
column.relation.schema ?? "",
|
|
10965
|
+
column.relation.table
|
|
10966
|
+
].join(":");
|
|
10967
|
+
const existingGroup = relationGroups.get(groupKey);
|
|
10968
|
+
if (existingGroup) {
|
|
10969
|
+
if (!existingGroup.columns.includes(column.column)) {
|
|
10970
|
+
existingGroup.columns.push(column.column);
|
|
10971
|
+
}
|
|
10972
|
+
continue;
|
|
10973
|
+
}
|
|
10974
|
+
relationGroups.set(groupKey, {
|
|
10975
|
+
columns: [column.column],
|
|
10976
|
+
relation: column.relation
|
|
10977
|
+
});
|
|
10978
|
+
}
|
|
10979
|
+
const relationColumns = [...relationGroups.values()].map(
|
|
10980
|
+
({ columns: relationColumns2, relation }) => {
|
|
10981
|
+
const relationTarget = relation.schema ? `${relation.schema}.${relation.table}` : relation.table;
|
|
10982
|
+
return `${relation.name}:${relationTarget}(${relationColumns2.join(",")})`;
|
|
10983
|
+
}
|
|
10984
|
+
);
|
|
10985
|
+
return [...baseColumns, ...relationColumns].join(",");
|
|
10986
|
+
}
|
|
10987
|
+
var buildAthenaTableSelectString = buildAthenaReadQuerySelectString;
|
|
10988
|
+
function buildAthenaReadQueryFindManySelect(columns) {
|
|
10989
|
+
const select = {};
|
|
10990
|
+
for (const column of columns) {
|
|
10991
|
+
if (!column.relation) {
|
|
10992
|
+
select[column.column] = true;
|
|
10993
|
+
continue;
|
|
10994
|
+
}
|
|
10995
|
+
const existingRelation = select[column.relation.name];
|
|
10996
|
+
if (existingRelation && existingRelation !== true && isRecord12(existingRelation.select)) {
|
|
10997
|
+
existingRelation.select[column.column] = true;
|
|
10998
|
+
continue;
|
|
10999
|
+
}
|
|
11000
|
+
select[column.relation.name] = {
|
|
11001
|
+
...column.relation.schema ? { schema: column.relation.schema } : {},
|
|
11002
|
+
select: {
|
|
11003
|
+
[column.column]: true
|
|
11004
|
+
}
|
|
11005
|
+
};
|
|
11006
|
+
}
|
|
11007
|
+
return select;
|
|
11008
|
+
}
|
|
11009
|
+
var buildAthenaTableFindManySelect = buildAthenaReadQueryFindManySelect;
|
|
11010
|
+
function buildAthenaReadQueryFindManyWhere(filters) {
|
|
11011
|
+
if (!filters?.length) {
|
|
11012
|
+
return;
|
|
11013
|
+
}
|
|
11014
|
+
return filters.reduce(
|
|
11015
|
+
(where, filter) => {
|
|
11016
|
+
const operator = filter.operator ?? "eq";
|
|
11017
|
+
where[filter.column] = operator === "eq" ? filter.value : { [operator]: filter.value };
|
|
11018
|
+
return where;
|
|
11019
|
+
},
|
|
11020
|
+
{}
|
|
11021
|
+
);
|
|
11022
|
+
}
|
|
11023
|
+
var buildAthenaTableFindManyWhere = buildAthenaReadQueryFindManyWhere;
|
|
11024
|
+
function buildAthenaReadQueryFindManyOrderBy(orderBy) {
|
|
11025
|
+
const normalized = normalizeAthenaReadQueryOrderBy(orderBy);
|
|
11026
|
+
if (normalized.length === 0) {
|
|
11027
|
+
return;
|
|
11028
|
+
}
|
|
11029
|
+
if (normalized.length === 1) {
|
|
11030
|
+
const primary = normalized[0];
|
|
11031
|
+
if (!primary) {
|
|
11032
|
+
return;
|
|
11033
|
+
}
|
|
11034
|
+
return {
|
|
11035
|
+
ascending: primary.direction !== "desc",
|
|
11036
|
+
column: primary.column
|
|
11037
|
+
};
|
|
11038
|
+
}
|
|
11039
|
+
return Object.fromEntries(
|
|
11040
|
+
normalized.map((entry) => [
|
|
11041
|
+
entry.column,
|
|
11042
|
+
entry.direction === "desc" ? "desc" : "asc"
|
|
11043
|
+
])
|
|
11044
|
+
);
|
|
11045
|
+
}
|
|
11046
|
+
var buildAthenaTableFindManyOrderBy = buildAthenaReadQueryFindManyOrderBy;
|
|
11047
|
+
var normalizeAthenaTableOrderBy = normalizeAthenaReadQueryOrderBy;
|
|
11048
|
+
function applyAthenaReadQueryFilters(queryBuilder, filters) {
|
|
11049
|
+
if (!filters?.length) {
|
|
11050
|
+
return queryBuilder;
|
|
11051
|
+
}
|
|
11052
|
+
return filters.reduce((currentBuilder, filter) => {
|
|
11053
|
+
const operator = filter.operator ?? "eq";
|
|
11054
|
+
const builderMethod = currentBuilder[operator];
|
|
11055
|
+
if (typeof builderMethod !== "function") {
|
|
11056
|
+
return currentBuilder;
|
|
11057
|
+
}
|
|
11058
|
+
return builderMethod.call(currentBuilder, filter.column, filter.value);
|
|
11059
|
+
}, queryBuilder);
|
|
11060
|
+
}
|
|
11061
|
+
var applyAthenaTableFilters = applyAthenaReadQueryFilters;
|
|
11062
|
+
function applyAthenaReadQuerySelectOrder(queryBuilder, orderBy) {
|
|
11063
|
+
const normalized = normalizeAthenaReadQueryOrderBy(orderBy);
|
|
11064
|
+
if (normalized.length === 0) {
|
|
11065
|
+
return queryBuilder;
|
|
11066
|
+
}
|
|
11067
|
+
return normalized.reduce(
|
|
11068
|
+
(builder, entry) => builder.order(entry.column, {
|
|
11069
|
+
ascending: entry.direction !== "desc"
|
|
11070
|
+
}),
|
|
11071
|
+
queryBuilder
|
|
11072
|
+
);
|
|
11073
|
+
}
|
|
11074
|
+
var applyAthenaTableSelectOrder = applyAthenaReadQuerySelectOrder;
|
|
11075
|
+
function applyAthenaReadQuerySelectLimit(queryBuilder, limit) {
|
|
11076
|
+
if (!limit || limit < 1) {
|
|
11077
|
+
return queryBuilder;
|
|
11078
|
+
}
|
|
11079
|
+
return queryBuilder.limit(limit);
|
|
11080
|
+
}
|
|
11081
|
+
var applyAthenaTableSelectLimit = applyAthenaReadQuerySelectLimit;
|
|
11082
|
+
function clampAthenaReadQueryTotalItems(totalItems, limit) {
|
|
11083
|
+
if (!limit || limit < 1) {
|
|
11084
|
+
return totalItems;
|
|
11085
|
+
}
|
|
11086
|
+
return Math.min(totalItems, limit);
|
|
11087
|
+
}
|
|
11088
|
+
var clampAthenaTableTotalItems = clampAthenaReadQueryTotalItems;
|
|
11089
|
+
function resolveCountValue(...candidates) {
|
|
11090
|
+
for (const candidate of candidates) {
|
|
11091
|
+
if (typeof candidate === "number" && Number.isFinite(candidate)) {
|
|
11092
|
+
return Math.max(0, Math.trunc(candidate));
|
|
11093
|
+
}
|
|
11094
|
+
}
|
|
11095
|
+
return 0;
|
|
11096
|
+
}
|
|
11097
|
+
function resolveTotalItemsFromPage({
|
|
11098
|
+
countCandidates,
|
|
11099
|
+
limit,
|
|
11100
|
+
page,
|
|
11101
|
+
pageSize,
|
|
11102
|
+
rowCount
|
|
11103
|
+
}) {
|
|
11104
|
+
const exactCount = resolveCountValue(...countCandidates);
|
|
11105
|
+
if (exactCount > 0) {
|
|
11106
|
+
return clampAthenaReadQueryTotalItems(exactCount, limit);
|
|
11107
|
+
}
|
|
11108
|
+
if (rowCount > 0) {
|
|
11109
|
+
const base = (page - 1) * pageSize + rowCount;
|
|
11110
|
+
const synthetic = rowCount >= pageSize ? base + 1 : base;
|
|
11111
|
+
return clampAthenaReadQueryTotalItems(synthetic, limit);
|
|
11112
|
+
}
|
|
11113
|
+
return clampAthenaReadQueryTotalItems(exactCount, limit);
|
|
11114
|
+
}
|
|
11115
|
+
function resolveAthenaReadQueryPageFetch({
|
|
11116
|
+
page,
|
|
11117
|
+
pageSize,
|
|
11118
|
+
limit
|
|
11119
|
+
}) {
|
|
11120
|
+
const safePage = Math.max(1, Math.trunc(page) || 1);
|
|
11121
|
+
const safePageSize = Math.max(1, Math.trunc(pageSize) || 1);
|
|
11122
|
+
if (!limit || limit < 1) {
|
|
11123
|
+
return { page: safePage, pageSize: safePageSize, shouldFetch: true };
|
|
11124
|
+
}
|
|
11125
|
+
const totalCap = Math.trunc(limit);
|
|
11126
|
+
const offset = (safePage - 1) * safePageSize;
|
|
11127
|
+
if (offset >= totalCap) {
|
|
11128
|
+
return { page: safePage, pageSize: safePageSize, shouldFetch: false };
|
|
11129
|
+
}
|
|
11130
|
+
return {
|
|
11131
|
+
page: safePage,
|
|
11132
|
+
pageSize: Math.min(safePageSize, totalCap - offset),
|
|
11133
|
+
shouldFetch: true
|
|
11134
|
+
};
|
|
11135
|
+
}
|
|
11136
|
+
async function executeAthenaReadQuery({
|
|
11137
|
+
client,
|
|
11138
|
+
page,
|
|
11139
|
+
pageSize,
|
|
11140
|
+
query
|
|
11141
|
+
}) {
|
|
11142
|
+
const db = client.db;
|
|
11143
|
+
const baseBuilder = db.from(query.table, {
|
|
11144
|
+
schema: query.schema
|
|
11145
|
+
});
|
|
11146
|
+
const countBuilder = applyAthenaReadQueryFilters(
|
|
11147
|
+
db.from(query.table, { schema: query.schema }),
|
|
11148
|
+
query.filters
|
|
11149
|
+
);
|
|
11150
|
+
const countResult = await countBuilder.select(query.countColumn, {
|
|
11151
|
+
count: "exact",
|
|
11152
|
+
head: true
|
|
11153
|
+
});
|
|
11154
|
+
const pageFetch = resolveAthenaReadQueryPageFetch({
|
|
11155
|
+
limit: query.limit,
|
|
11156
|
+
page,
|
|
11157
|
+
pageSize
|
|
11158
|
+
});
|
|
11159
|
+
if (!pageFetch.shouldFetch) {
|
|
11160
|
+
return {
|
|
11161
|
+
rows: [],
|
|
11162
|
+
totalItems: resolveTotalItemsFromPage({
|
|
11163
|
+
countCandidates: [countResult.count],
|
|
11164
|
+
limit: query.limit,
|
|
11165
|
+
page: pageFetch.page,
|
|
11166
|
+
pageSize,
|
|
11167
|
+
rowCount: 0
|
|
11168
|
+
})
|
|
11169
|
+
};
|
|
11170
|
+
}
|
|
11171
|
+
if ((query.mode ?? "findMany") === "select") {
|
|
11172
|
+
const selectBuilder = applyAthenaReadQuerySelectOrder(
|
|
11173
|
+
applyAthenaReadQueryFilters(baseBuilder, query.filters),
|
|
11174
|
+
query.orderBy
|
|
11175
|
+
);
|
|
11176
|
+
const result2 = await selectBuilder.currentPage(pageFetch.page).pageSize(pageFetch.pageSize).select(buildAthenaReadQuerySelectString(query.columns), {
|
|
11177
|
+
count: "exact"
|
|
11178
|
+
});
|
|
11179
|
+
const rows2 = flattenAthenaReadQueryRows(
|
|
11180
|
+
Array.isArray(result2.data) ? result2.data : [],
|
|
11181
|
+
query.columns,
|
|
11182
|
+
query.rowKey
|
|
11183
|
+
);
|
|
11184
|
+
return {
|
|
11185
|
+
debugAst: getAthenaDebugAst(result2) ?? void 0,
|
|
11186
|
+
rows: rows2,
|
|
11187
|
+
totalItems: resolveTotalItemsFromPage({
|
|
11188
|
+
countCandidates: [countResult.count, result2.count],
|
|
11189
|
+
limit: query.limit,
|
|
11190
|
+
page: pageFetch.page,
|
|
11191
|
+
pageSize,
|
|
11192
|
+
rowCount: rows2.length
|
|
11193
|
+
})
|
|
11194
|
+
};
|
|
11195
|
+
}
|
|
11196
|
+
const findManyOrderBy = buildAthenaReadQueryFindManyOrderBy(query.orderBy);
|
|
11197
|
+
const findManyOptions = {
|
|
11198
|
+
...findManyOrderBy ? { orderBy: findManyOrderBy } : {},
|
|
11199
|
+
select: buildAthenaReadQueryFindManySelect(query.columns),
|
|
11200
|
+
...query.filters?.length ? { where: buildAthenaReadQueryFindManyWhere(query.filters) } : {}
|
|
11201
|
+
};
|
|
11202
|
+
const result = await baseBuilder.currentPage(pageFetch.page).pageSize(pageFetch.pageSize).findMany(findManyOptions);
|
|
11203
|
+
const rows = flattenAthenaReadQueryRows(
|
|
11204
|
+
Array.isArray(result.data) ? result.data : [],
|
|
11205
|
+
query.columns,
|
|
11206
|
+
query.rowKey
|
|
11207
|
+
);
|
|
11208
|
+
return {
|
|
11209
|
+
debugAst: getAthenaDebugAst(result) ?? void 0,
|
|
11210
|
+
rows,
|
|
11211
|
+
totalItems: resolveTotalItemsFromPage({
|
|
11212
|
+
countCandidates: [countResult.count, result.count],
|
|
11213
|
+
limit: query.limit,
|
|
11214
|
+
page: pageFetch.page,
|
|
11215
|
+
pageSize,
|
|
11216
|
+
rowCount: rows.length
|
|
11217
|
+
})
|
|
11218
|
+
};
|
|
11219
|
+
}
|
|
11220
|
+
var executeAthenaTableQuery = executeAthenaReadQuery;
|
|
11221
|
+
|
|
10773
11222
|
// src/schema/definitions.ts
|
|
10774
11223
|
function defineModel(input) {
|
|
10775
11224
|
return input;
|
|
@@ -10790,7 +11239,7 @@ function resolveNullishValue(mode) {
|
|
|
10790
11239
|
if (mode === "null") return null;
|
|
10791
11240
|
return "";
|
|
10792
11241
|
}
|
|
10793
|
-
function
|
|
11242
|
+
function isRecord13(value) {
|
|
10794
11243
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
10795
11244
|
}
|
|
10796
11245
|
function isNullableColumn(model, key) {
|
|
@@ -10799,7 +11248,7 @@ function isNullableColumn(model, key) {
|
|
|
10799
11248
|
}
|
|
10800
11249
|
function toModelFormDefaults(model, values, options) {
|
|
10801
11250
|
const source = values;
|
|
10802
|
-
if (!
|
|
11251
|
+
if (!isRecord13(source)) {
|
|
10803
11252
|
return {};
|
|
10804
11253
|
}
|
|
10805
11254
|
const mode = options?.nullishMode ?? "empty-string";
|
|
@@ -11763,6 +12212,13 @@ var GATEWAY_API_KEY_ENV_KEYS = [
|
|
|
11763
12212
|
"ATHENA_GATEWAY_API_KEY",
|
|
11764
12213
|
"ATHENA_GENERATOR_API_KEY"
|
|
11765
12214
|
];
|
|
12215
|
+
var GATEWAY_CLIENT_ENV_KEYS = [
|
|
12216
|
+
"ATHENA_CLIENT",
|
|
12217
|
+
"ATHENA_GATEWAY_CLIENT",
|
|
12218
|
+
"ATHENA_GENERATOR_CLIENT",
|
|
12219
|
+
"NEXT_PUBLIC_ATHENA_CLIENT",
|
|
12220
|
+
"NEXT_PUBLIC_ATHENA_GATEWAY_CLIENT"
|
|
12221
|
+
];
|
|
11766
12222
|
var GENERATOR_SCHEMA_ENV_KEYS = ["ATHENA_GENERATOR_SCHEMAS"];
|
|
11767
12223
|
var OUTPUT_FORMAT_ENV_KEYS = ["ATHENA_GENERATOR_OUTPUT_FORMAT"];
|
|
11768
12224
|
var OUTPUT_PRESET_ENV_KEYS = ["ATHENA_GENERATOR_OUTPUT_PRESET"];
|
|
@@ -12063,11 +12519,13 @@ function normalizeProviderConfig(provider) {
|
|
|
12063
12519
|
GATEWAY_API_KEY_ENV_KEYS
|
|
12064
12520
|
);
|
|
12065
12521
|
const database = normalizeOptionalString(provider.database, POSTGRES_DATABASE_ENV_KEYS) ?? "postgres";
|
|
12522
|
+
const client = normalizeOptionalString(provider.client, GATEWAY_CLIENT_ENV_KEYS);
|
|
12066
12523
|
return {
|
|
12067
12524
|
...provider,
|
|
12068
12525
|
gatewayUrl,
|
|
12069
12526
|
apiKey,
|
|
12070
12527
|
database,
|
|
12528
|
+
...client ? { client } : {},
|
|
12071
12529
|
schemas: normalizeSchemaSelection(provider.schemas)
|
|
12072
12530
|
};
|
|
12073
12531
|
}
|
|
@@ -12261,6 +12719,7 @@ function buildEnvironmentProviderConfig() {
|
|
|
12261
12719
|
const apiKey = resolveFallbackValue(GATEWAY_API_KEY_ENV_KEYS);
|
|
12262
12720
|
if (gatewayUrl && apiKey) {
|
|
12263
12721
|
const backend = resolveOptionalOneOf(GATEWAY_BACKEND_ENV_KEYS, BACKEND_TYPE_VALUES);
|
|
12722
|
+
const client = resolveFallbackValue(GATEWAY_CLIENT_ENV_KEYS);
|
|
12264
12723
|
return {
|
|
12265
12724
|
kind: "postgres",
|
|
12266
12725
|
mode: "gateway",
|
|
@@ -12268,7 +12727,8 @@ function buildEnvironmentProviderConfig() {
|
|
|
12268
12727
|
apiKey,
|
|
12269
12728
|
database: normalizeOptionalString(void 0, POSTGRES_DATABASE_ENV_KEYS),
|
|
12270
12729
|
schemas: normalizeSchemaSelection(resolveFallbackValue(GENERATOR_SCHEMA_ENV_KEYS)),
|
|
12271
|
-
backend
|
|
12730
|
+
backend,
|
|
12731
|
+
...client ? { client } : {}
|
|
12272
12732
|
};
|
|
12273
12733
|
}
|
|
12274
12734
|
return void 0;
|
|
@@ -12316,93 +12776,576 @@ async function loadGeneratorConfig(options = {}) {
|
|
|
12316
12776
|
}
|
|
12317
12777
|
}
|
|
12318
12778
|
|
|
12319
|
-
// src/generator/
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12325
|
-
|
|
12326
|
-
|
|
12779
|
+
// src/generator/schema-discovery.ts
|
|
12780
|
+
var DISCOVER_POSTGRES_SCHEMAS_SQL = `
|
|
12781
|
+
SELECT DISTINCT n.nspname AS schema_name
|
|
12782
|
+
FROM pg_namespace n
|
|
12783
|
+
JOIN pg_class c ON c.relnamespace = n.oid
|
|
12784
|
+
WHERE c.relkind IN ('r', 'p')
|
|
12785
|
+
AND n.nspname NOT IN ('pg_catalog', 'information_schema')
|
|
12786
|
+
AND n.nspname NOT LIKE 'pg_toast%'
|
|
12787
|
+
AND n.nspname NOT LIKE 'pg_temp_%'
|
|
12788
|
+
AND n.nspname NOT LIKE 'pg_toast_temp_%'
|
|
12789
|
+
ORDER BY n.nspname;
|
|
12790
|
+
`.trim();
|
|
12791
|
+
var SYSTEM_SCHEMA_PREFIXES = ["pg_"];
|
|
12792
|
+
var SYSTEM_SCHEMAS = /* @__PURE__ */ new Set(["pg_catalog", "information_schema"]);
|
|
12793
|
+
function normalizeDiscoveredSchemas(input) {
|
|
12794
|
+
const schemas = [];
|
|
12795
|
+
const seen = /* @__PURE__ */ new Set();
|
|
12796
|
+
for (const value of input) {
|
|
12797
|
+
const schema = value.trim();
|
|
12798
|
+
if (!schema || seen.has(schema)) {
|
|
12799
|
+
continue;
|
|
12800
|
+
}
|
|
12801
|
+
if (SYSTEM_SCHEMAS.has(schema)) {
|
|
12802
|
+
continue;
|
|
12803
|
+
}
|
|
12804
|
+
if (SYSTEM_SCHEMA_PREFIXES.some((prefix) => schema.startsWith(prefix))) {
|
|
12805
|
+
continue;
|
|
12806
|
+
}
|
|
12807
|
+
seen.add(schema);
|
|
12808
|
+
schemas.push(schema);
|
|
12327
12809
|
}
|
|
12328
|
-
|
|
12329
|
-
return trimmed.length > 0 ? trimmed : void 0;
|
|
12330
|
-
}
|
|
12331
|
-
function throwMissingEnvVar(key) {
|
|
12332
|
-
throw new Error(
|
|
12333
|
-
`Generator config env var ${key} is missing or empty. Set ${key} or provide a default value.`
|
|
12334
|
-
);
|
|
12810
|
+
return schemas;
|
|
12335
12811
|
}
|
|
12336
|
-
function
|
|
12337
|
-
const
|
|
12338
|
-
|
|
12339
|
-
|
|
12340
|
-
|
|
12812
|
+
function mergeSchemaSelections(configured, discovered) {
|
|
12813
|
+
const result = [];
|
|
12814
|
+
const seen = /* @__PURE__ */ new Set();
|
|
12815
|
+
for (const value of configured ?? []) {
|
|
12816
|
+
const schema = value.trim();
|
|
12817
|
+
if (!schema || seen.has(schema)) {
|
|
12818
|
+
continue;
|
|
12341
12819
|
}
|
|
12342
|
-
|
|
12343
|
-
|
|
12820
|
+
seen.add(schema);
|
|
12821
|
+
result.push(schema);
|
|
12822
|
+
}
|
|
12823
|
+
for (const value of discovered) {
|
|
12824
|
+
const schema = value.trim();
|
|
12825
|
+
if (!schema || seen.has(schema)) {
|
|
12826
|
+
continue;
|
|
12344
12827
|
}
|
|
12345
|
-
|
|
12828
|
+
seen.add(schema);
|
|
12829
|
+
result.push(schema);
|
|
12346
12830
|
}
|
|
12347
|
-
return
|
|
12831
|
+
return result.length > 0 ? result : ["public"];
|
|
12348
12832
|
}
|
|
12349
|
-
function
|
|
12350
|
-
|
|
12833
|
+
function schemasEqual(left, right) {
|
|
12834
|
+
const a = normalizeDiscoveredSchemas(left ?? []);
|
|
12835
|
+
const b = normalizeDiscoveredSchemas(right ?? []);
|
|
12836
|
+
if (a.length !== b.length) {
|
|
12837
|
+
return false;
|
|
12838
|
+
}
|
|
12839
|
+
const set = new Set(a);
|
|
12840
|
+
return b.every((schema) => set.has(schema));
|
|
12351
12841
|
}
|
|
12352
|
-
function
|
|
12353
|
-
|
|
12842
|
+
function coerceSchemaName(row) {
|
|
12843
|
+
const raw = row.schema_name ?? row.schemaName ?? row.nspname;
|
|
12844
|
+
if (typeof raw !== "string") {
|
|
12845
|
+
return void 0;
|
|
12846
|
+
}
|
|
12847
|
+
const trimmed = raw.trim();
|
|
12848
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
12354
12849
|
}
|
|
12355
|
-
function
|
|
12356
|
-
|
|
12357
|
-
|
|
12358
|
-
|
|
12359
|
-
|
|
12850
|
+
async function loadPgPoolConstructor2() {
|
|
12851
|
+
const module = await import('pg');
|
|
12852
|
+
const poolConstructor = module.Pool ?? module.default?.Pool;
|
|
12853
|
+
if (!poolConstructor) {
|
|
12854
|
+
throw new Error(
|
|
12855
|
+
'@xylex-group/athena: Unable to load the PostgreSQL driver for schema discovery. Ensure "pg" is installed and this API runs in a Node.js server runtime.'
|
|
12856
|
+
);
|
|
12857
|
+
}
|
|
12858
|
+
return poolConstructor;
|
|
12360
12859
|
}
|
|
12361
|
-
function
|
|
12362
|
-
|
|
12363
|
-
|
|
12364
|
-
|
|
12365
|
-
|
|
12366
|
-
|
|
12367
|
-
|
|
12368
|
-
|
|
12369
|
-
|
|
12860
|
+
async function discoverDirectSchemas(config) {
|
|
12861
|
+
const PoolConstructor = await loadPgPoolConstructor2();
|
|
12862
|
+
const pool = new PoolConstructor({ connectionString: config.connectionString });
|
|
12863
|
+
try {
|
|
12864
|
+
const result = await pool.query(DISCOVER_POSTGRES_SCHEMAS_SQL);
|
|
12865
|
+
const names = result.rows.map(coerceSchemaName).filter((value) => Boolean(value));
|
|
12866
|
+
return normalizeDiscoveredSchemas(names);
|
|
12867
|
+
} finally {
|
|
12868
|
+
await pool.end();
|
|
12869
|
+
}
|
|
12370
12870
|
}
|
|
12371
|
-
function
|
|
12372
|
-
|
|
12373
|
-
|
|
12374
|
-
|
|
12871
|
+
async function discoverGatewaySchemas(config) {
|
|
12872
|
+
const client = createClient({
|
|
12873
|
+
db: { url: config.gatewayUrl },
|
|
12874
|
+
key: config.apiKey,
|
|
12875
|
+
client: config.client,
|
|
12876
|
+
env: typeof process !== "undefined" ? process.env : void 0,
|
|
12877
|
+
backend: {
|
|
12878
|
+
type: config.backend ?? "postgresql"
|
|
12375
12879
|
}
|
|
12880
|
+
});
|
|
12881
|
+
const result = await client.query(DISCOVER_POSTGRES_SCHEMAS_SQL);
|
|
12882
|
+
if (result.error || result.status < 200 || result.status >= 300) {
|
|
12376
12883
|
throw new Error(
|
|
12377
|
-
|
|
12884
|
+
result.error?.message ?? `Gateway schema discovery failed with status ${result.status}`
|
|
12378
12885
|
);
|
|
12379
|
-
}
|
|
12380
|
-
|
|
12381
|
-
|
|
12382
|
-
return resolveStringEnv(key, options);
|
|
12383
|
-
}
|
|
12384
|
-
function generatorEnvBoolean(key, options) {
|
|
12385
|
-
return resolveBooleanEnv(key, options);
|
|
12386
|
-
}
|
|
12387
|
-
function generatorEnvList(key, options) {
|
|
12388
|
-
return resolveListEnv(key, options);
|
|
12389
|
-
}
|
|
12390
|
-
function generatorEnvJson(key, options) {
|
|
12391
|
-
return resolveJsonEnv(key, options);
|
|
12392
|
-
}
|
|
12393
|
-
function generatorEnvOneOf(key, allowedValues, options) {
|
|
12394
|
-
return resolveOneOfEnv(key, allowedValues, options);
|
|
12886
|
+
}
|
|
12887
|
+
const names = (result.data ?? []).map(coerceSchemaName).filter((value) => Boolean(value));
|
|
12888
|
+
return normalizeDiscoveredSchemas(names);
|
|
12395
12889
|
}
|
|
12396
|
-
|
|
12397
|
-
|
|
12398
|
-
|
|
12399
|
-
|
|
12400
|
-
|
|
12401
|
-
|
|
12402
|
-
|
|
12403
|
-
|
|
12404
|
-
|
|
12405
|
-
|
|
12890
|
+
async function discoverPostgresSchemas(provider) {
|
|
12891
|
+
if (provider.kind === "postgres" && provider.mode === "direct") {
|
|
12892
|
+
return discoverDirectSchemas(provider);
|
|
12893
|
+
}
|
|
12894
|
+
if (provider.kind === "postgres" && provider.mode === "gateway") {
|
|
12895
|
+
return discoverGatewaySchemas(provider);
|
|
12896
|
+
}
|
|
12897
|
+
throw new Error(
|
|
12898
|
+
`Schema discovery is only implemented for postgres direct/gateway providers (received ${provider.kind}/${"mode" in provider ? provider.mode : "unknown"}).`
|
|
12899
|
+
);
|
|
12900
|
+
}
|
|
12901
|
+
|
|
12902
|
+
// src/generator/config-file.ts
|
|
12903
|
+
function hasEnv(keys) {
|
|
12904
|
+
for (const key of keys) {
|
|
12905
|
+
const value = process.env[key];
|
|
12906
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
12907
|
+
return true;
|
|
12908
|
+
}
|
|
12909
|
+
}
|
|
12910
|
+
return false;
|
|
12911
|
+
}
|
|
12912
|
+
var DIRECT_CONNECTION_KEYS = [
|
|
12913
|
+
"ATHENA_GENERATOR_PG_URL",
|
|
12914
|
+
"DATABASE_URL",
|
|
12915
|
+
"PG_URL",
|
|
12916
|
+
"POSTGRES_URL",
|
|
12917
|
+
"POSTGRESQL_URL"
|
|
12918
|
+
];
|
|
12919
|
+
var GATEWAY_URL_KEYS = ["ATHENA_URL", "ATHENA_GATEWAY_URL", "ATHENA_GENERATOR_URL"];
|
|
12920
|
+
var GATEWAY_KEY_KEYS = [
|
|
12921
|
+
"ATHENA_API_KEY",
|
|
12922
|
+
"ATHENA_GATEWAY_API_KEY",
|
|
12923
|
+
"ATHENA_GENERATOR_API_KEY"
|
|
12924
|
+
];
|
|
12925
|
+
function detectGeneratorProviderMode(preferred = "auto") {
|
|
12926
|
+
if (preferred === "direct" || preferred === "gateway") {
|
|
12927
|
+
return preferred;
|
|
12928
|
+
}
|
|
12929
|
+
const hasDirect = hasEnv(DIRECT_CONNECTION_KEYS);
|
|
12930
|
+
const hasGateway = hasEnv(GATEWAY_URL_KEYS) && hasEnv(GATEWAY_KEY_KEYS);
|
|
12931
|
+
if (hasDirect) {
|
|
12932
|
+
return "direct";
|
|
12933
|
+
}
|
|
12934
|
+
if (hasGateway) {
|
|
12935
|
+
return "gateway";
|
|
12936
|
+
}
|
|
12937
|
+
return "direct";
|
|
12938
|
+
}
|
|
12939
|
+
function formatStringArray(values, indent) {
|
|
12940
|
+
if (values.length === 0) {
|
|
12941
|
+
return "[]";
|
|
12942
|
+
}
|
|
12943
|
+
const inner = values.map((value) => `${indent} ${JSON.stringify(value)}`).join(",\n");
|
|
12944
|
+
return `[
|
|
12945
|
+
${inner},
|
|
12946
|
+
${indent}]`;
|
|
12947
|
+
}
|
|
12948
|
+
function buildDirectProviderBlock(schemas) {
|
|
12949
|
+
return ` provider: {
|
|
12950
|
+
kind: "postgres",
|
|
12951
|
+
mode: "direct",
|
|
12952
|
+
connectionString: generatorEnv("DATABASE_URL"),
|
|
12953
|
+
database: generatorEnv("ATHENA_GENERATOR_DB", { optional: true }),
|
|
12954
|
+
schemas: ${formatStringArray(schemas, " ")},
|
|
12955
|
+
}`;
|
|
12956
|
+
}
|
|
12957
|
+
function buildGatewayProviderBlock(schemas) {
|
|
12958
|
+
return ` provider: {
|
|
12959
|
+
kind: "postgres",
|
|
12960
|
+
mode: "gateway",
|
|
12961
|
+
gatewayUrl: generatorEnv("ATHENA_URL"),
|
|
12962
|
+
apiKey: generatorEnv("ATHENA_API_KEY"),
|
|
12963
|
+
client: generatorEnv("ATHENA_CLIENT", { optional: true }),
|
|
12964
|
+
database: generatorEnv("ATHENA_GENERATOR_DB", { default: "postgres" }),
|
|
12965
|
+
schemas: ${formatStringArray(schemas, " ")},
|
|
12966
|
+
}`;
|
|
12967
|
+
}
|
|
12968
|
+
function renderGeneratorConfigFile(options) {
|
|
12969
|
+
const schemas = options.schemas && options.schemas.length > 0 ? [...options.schemas] : [...DEFAULT_POSTGRES_SCHEMAS];
|
|
12970
|
+
const providerBlock = options.mode === "gateway" ? buildGatewayProviderBlock(schemas) : buildDirectProviderBlock(schemas);
|
|
12971
|
+
return `import { defineGeneratorConfig, generatorEnv } from "@xylex-group/athena";
|
|
12972
|
+
|
|
12973
|
+
export default defineGeneratorConfig({
|
|
12974
|
+
${providerBlock},
|
|
12975
|
+
output: {
|
|
12976
|
+
format: "table-builder",
|
|
12977
|
+
preset: "athena-direct",
|
|
12978
|
+
targets: {
|
|
12979
|
+
model: "athena/models/{schema_kebab}/{model_kebab}.ts",
|
|
12980
|
+
schema: "athena/schemas/{schema_kebab}.ts",
|
|
12981
|
+
database: "athena/relations.ts",
|
|
12982
|
+
registry: "athena/registry.generated.ts",
|
|
12983
|
+
},
|
|
12984
|
+
placeholderMap: {
|
|
12985
|
+
namespace: "athena",
|
|
12986
|
+
},
|
|
12987
|
+
},
|
|
12988
|
+
naming: {
|
|
12989
|
+
modelType: "pascal",
|
|
12990
|
+
modelConst: "camel",
|
|
12991
|
+
schemaConst: "camel",
|
|
12992
|
+
databaseConst: "camel",
|
|
12993
|
+
registryConst: "camel",
|
|
12994
|
+
},
|
|
12995
|
+
features: {
|
|
12996
|
+
emitRelations: true,
|
|
12997
|
+
emitRegistry: true,
|
|
12998
|
+
},
|
|
12999
|
+
experimental: {
|
|
13000
|
+
postgresGatewayIntrospection: false,
|
|
13001
|
+
scyllaProviderContracts: true,
|
|
13002
|
+
},
|
|
13003
|
+
});
|
|
13004
|
+
`;
|
|
13005
|
+
}
|
|
13006
|
+
function resolveConfigPath(cwd, configPath) {
|
|
13007
|
+
if (configPath) {
|
|
13008
|
+
const absolutePath2 = path.resolve(cwd, configPath);
|
|
13009
|
+
return {
|
|
13010
|
+
absolutePath: absolutePath2,
|
|
13011
|
+
relativePath: configPath.replace(/\\/g, "/"),
|
|
13012
|
+
exists: fs.existsSync(absolutePath2)
|
|
13013
|
+
};
|
|
13014
|
+
}
|
|
13015
|
+
const discovered = findGeneratorConfigPath(cwd);
|
|
13016
|
+
if (discovered) {
|
|
13017
|
+
const relativePath = discovered.startsWith(cwd) ? discovered.slice(cwd.length).replace(/^[/\\]/, "").replace(/\\/g, "/") : "athena.config.ts";
|
|
13018
|
+
return {
|
|
13019
|
+
absolutePath: discovered,
|
|
13020
|
+
relativePath,
|
|
13021
|
+
exists: true
|
|
13022
|
+
};
|
|
13023
|
+
}
|
|
13024
|
+
const absolutePath = path.resolve(cwd, "athena.config.ts");
|
|
13025
|
+
return {
|
|
13026
|
+
absolutePath,
|
|
13027
|
+
relativePath: "athena.config.ts",
|
|
13028
|
+
exists: false
|
|
13029
|
+
};
|
|
13030
|
+
}
|
|
13031
|
+
function providerModeFromConfig(provider, preferred) {
|
|
13032
|
+
if (provider && provider.kind === "postgres") {
|
|
13033
|
+
if (provider.mode === "gateway") {
|
|
13034
|
+
return "gateway";
|
|
13035
|
+
}
|
|
13036
|
+
if (provider.mode === "direct") {
|
|
13037
|
+
return "direct";
|
|
13038
|
+
}
|
|
13039
|
+
}
|
|
13040
|
+
return detectGeneratorProviderMode(preferred);
|
|
13041
|
+
}
|
|
13042
|
+
function schemasFromNormalized(config) {
|
|
13043
|
+
if (config.provider.kind !== "postgres") {
|
|
13044
|
+
return [...DEFAULT_POSTGRES_SCHEMAS];
|
|
13045
|
+
}
|
|
13046
|
+
return normalizeSchemaSelection(config.provider.schemas);
|
|
13047
|
+
}
|
|
13048
|
+
function patchSchemasInConfigSource(source, schemas) {
|
|
13049
|
+
const formattedInline = `[${schemas.map((value) => JSON.stringify(value)).join(", ")}]`;
|
|
13050
|
+
const formattedMultiline = formatStringArray(schemas, " ");
|
|
13051
|
+
const listDefaultPattern = /(schemas\s*:\s*generatorEnv\.list\s*\(\s*['"][^'"]+['"]\s*,\s*\{[\s\S]*?default\s*:\s*)(\[[^\]]*\])/m;
|
|
13052
|
+
if (listDefaultPattern.test(source)) {
|
|
13053
|
+
return source.replace(listDefaultPattern, `$1${formattedInline}`);
|
|
13054
|
+
}
|
|
13055
|
+
const literalPattern = /(schemas\s*:\s*)(\[[^\]]*\])/m;
|
|
13056
|
+
if (literalPattern.test(source)) {
|
|
13057
|
+
const usesMultiline = /schemas\s*:\s*\[\s*\n/.test(source);
|
|
13058
|
+
return source.replace(
|
|
13059
|
+
literalPattern,
|
|
13060
|
+
`$1${usesMultiline ? formattedMultiline : formattedInline}`
|
|
13061
|
+
);
|
|
13062
|
+
}
|
|
13063
|
+
const modeLine = /(mode\s*:\s*["'](?:direct|gateway)["']\s*,)/m;
|
|
13064
|
+
if (modeLine.test(source)) {
|
|
13065
|
+
return source.replace(
|
|
13066
|
+
modeLine,
|
|
13067
|
+
`$1
|
|
13068
|
+
schemas: ${formattedInline},`
|
|
13069
|
+
);
|
|
13070
|
+
}
|
|
13071
|
+
return void 0;
|
|
13072
|
+
}
|
|
13073
|
+
function extractLiteralSchemas(source) {
|
|
13074
|
+
const listDefaultMatch = source.match(
|
|
13075
|
+
/schemas\s*:\s*generatorEnv\.list\s*\(\s*['"][^'"]+['"]\s*,\s*\{[\s\S]*?default\s*:\s*(\[[^\]]*\])/m
|
|
13076
|
+
);
|
|
13077
|
+
const literalMatch = listDefaultMatch ?? source.match(/schemas\s*:\s*(\[[^\]]*\])/m);
|
|
13078
|
+
if (!literalMatch) {
|
|
13079
|
+
return void 0;
|
|
13080
|
+
}
|
|
13081
|
+
try {
|
|
13082
|
+
const parsed = JSON.parse(literalMatch[1].replace(/'/g, '"'));
|
|
13083
|
+
if (!Array.isArray(parsed)) {
|
|
13084
|
+
return void 0;
|
|
13085
|
+
}
|
|
13086
|
+
return parsed.map((value) => typeof value === "string" ? value.trim() : "").filter((value) => value.length > 0);
|
|
13087
|
+
} catch {
|
|
13088
|
+
return void 0;
|
|
13089
|
+
}
|
|
13090
|
+
}
|
|
13091
|
+
async function resolveDiscoveredSchemas(options) {
|
|
13092
|
+
if (options.explicit && options.explicit.length > 0) {
|
|
13093
|
+
return {
|
|
13094
|
+
schemas: normalizeSchemaSelection(options.explicit),
|
|
13095
|
+
discovered: false
|
|
13096
|
+
};
|
|
13097
|
+
}
|
|
13098
|
+
if (!options.discoverSchemas) {
|
|
13099
|
+
if (options.loaded) {
|
|
13100
|
+
return {
|
|
13101
|
+
schemas: schemasFromNormalized(options.loaded.config),
|
|
13102
|
+
discovered: false
|
|
13103
|
+
};
|
|
13104
|
+
}
|
|
13105
|
+
return {
|
|
13106
|
+
schemas: [...DEFAULT_POSTGRES_SCHEMAS],
|
|
13107
|
+
discovered: false
|
|
13108
|
+
};
|
|
13109
|
+
}
|
|
13110
|
+
try {
|
|
13111
|
+
let provider = options.provider;
|
|
13112
|
+
if (!provider && options.loaded) {
|
|
13113
|
+
provider = options.loaded.config.provider;
|
|
13114
|
+
}
|
|
13115
|
+
if (!provider) {
|
|
13116
|
+
const probeConfig = {
|
|
13117
|
+
provider: options.mode === "gateway" ? { kind: "postgres", mode: "gateway" } : { kind: "postgres", mode: "direct" }
|
|
13118
|
+
};
|
|
13119
|
+
const normalized = normalizeGeneratorConfig(probeConfig);
|
|
13120
|
+
provider = normalized.provider;
|
|
13121
|
+
}
|
|
13122
|
+
const discovered = await discoverPostgresSchemas(provider);
|
|
13123
|
+
if (discovered.length === 0) {
|
|
13124
|
+
const fallback = options.loaded ? schemasFromNormalized(options.loaded.config) : [...DEFAULT_POSTGRES_SCHEMAS];
|
|
13125
|
+
return { schemas: fallback, discovered: true };
|
|
13126
|
+
}
|
|
13127
|
+
if (options.loaded) {
|
|
13128
|
+
return {
|
|
13129
|
+
schemas: mergeSchemaSelections(schemasFromNormalized(options.loaded.config), discovered),
|
|
13130
|
+
discovered: true
|
|
13131
|
+
};
|
|
13132
|
+
}
|
|
13133
|
+
return { schemas: discovered, discovered: true };
|
|
13134
|
+
} catch (error) {
|
|
13135
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
13136
|
+
const fallback = options.loaded ? schemasFromNormalized(options.loaded.config) : [...DEFAULT_POSTGRES_SCHEMAS];
|
|
13137
|
+
return {
|
|
13138
|
+
schemas: fallback,
|
|
13139
|
+
discovered: false,
|
|
13140
|
+
discoveryError: message
|
|
13141
|
+
};
|
|
13142
|
+
}
|
|
13143
|
+
}
|
|
13144
|
+
async function ensureGeneratorConfigFile(options = {}) {
|
|
13145
|
+
const cwd = options.cwd ?? process.cwd();
|
|
13146
|
+
const dryRun = options.dryRun === true;
|
|
13147
|
+
const discoverSchemas = options.discoverSchemas !== false;
|
|
13148
|
+
const force = options.force === true;
|
|
13149
|
+
const preferredMode = options.mode ?? "auto";
|
|
13150
|
+
const pathInfo = resolveConfigPath(cwd, options.configPath);
|
|
13151
|
+
const changes = [];
|
|
13152
|
+
let loaded = options.loaded;
|
|
13153
|
+
if (!loaded && pathInfo.exists && !force) {
|
|
13154
|
+
try {
|
|
13155
|
+
loaded = await loadGeneratorConfig({
|
|
13156
|
+
cwd,
|
|
13157
|
+
configPath: pathInfo.absolutePath
|
|
13158
|
+
});
|
|
13159
|
+
} catch {
|
|
13160
|
+
}
|
|
13161
|
+
}
|
|
13162
|
+
const mode = providerModeFromConfig(loaded?.config.provider ?? options.provider, preferredMode);
|
|
13163
|
+
const schemaResolution = await resolveDiscoveredSchemas({
|
|
13164
|
+
discoverSchemas,
|
|
13165
|
+
provider: options.provider ?? loaded?.config.provider,
|
|
13166
|
+
loaded,
|
|
13167
|
+
explicit: options.schemas,
|
|
13168
|
+
mode
|
|
13169
|
+
});
|
|
13170
|
+
if (schemaResolution.discoveryError) {
|
|
13171
|
+
changes.push(`schema-discovery-failed: ${schemaResolution.discoveryError}`);
|
|
13172
|
+
} else if (schemaResolution.discovered) {
|
|
13173
|
+
changes.push(`schemas-discovered: ${schemaResolution.schemas.join(",")}`);
|
|
13174
|
+
}
|
|
13175
|
+
if (!pathInfo.exists || force) {
|
|
13176
|
+
const content = renderGeneratorConfigFile({
|
|
13177
|
+
mode,
|
|
13178
|
+
schemas: schemaResolution.schemas
|
|
13179
|
+
});
|
|
13180
|
+
if (!pathInfo.exists) {
|
|
13181
|
+
changes.push("created-modern-config");
|
|
13182
|
+
} else {
|
|
13183
|
+
changes.push("force-rewrote-config");
|
|
13184
|
+
}
|
|
13185
|
+
if (!dryRun) {
|
|
13186
|
+
await promises.mkdir(path.dirname(pathInfo.absolutePath), { recursive: true });
|
|
13187
|
+
await promises.writeFile(pathInfo.absolutePath, content, "utf8");
|
|
13188
|
+
}
|
|
13189
|
+
return {
|
|
13190
|
+
action: pathInfo.exists ? "updated" : "created",
|
|
13191
|
+
path: pathInfo.relativePath,
|
|
13192
|
+
absolutePath: pathInfo.absolutePath,
|
|
13193
|
+
content,
|
|
13194
|
+
schemas: schemaResolution.schemas,
|
|
13195
|
+
changes,
|
|
13196
|
+
mode,
|
|
13197
|
+
reason: pathInfo.exists ? "force rewrite" : "config file missing"
|
|
13198
|
+
};
|
|
13199
|
+
}
|
|
13200
|
+
const existingSource = await promises.readFile(pathInfo.absolutePath, "utf8");
|
|
13201
|
+
const existingLiteralSchemas = extractLiteralSchemas(existingSource);
|
|
13202
|
+
const existingSchemas = existingLiteralSchemas ?? (loaded ? schemasFromNormalized(loaded.config) : [...DEFAULT_POSTGRES_SCHEMAS]);
|
|
13203
|
+
if (schemasEqual(existingSchemas, schemaResolution.schemas)) {
|
|
13204
|
+
return {
|
|
13205
|
+
action: "unchanged",
|
|
13206
|
+
path: pathInfo.relativePath,
|
|
13207
|
+
absolutePath: pathInfo.absolutePath,
|
|
13208
|
+
content: existingSource,
|
|
13209
|
+
schemas: existingSchemas,
|
|
13210
|
+
changes: changes.length > 0 ? changes : ["schemas-already-current"],
|
|
13211
|
+
mode,
|
|
13212
|
+
reason: "schemas already match discovered/configured set"
|
|
13213
|
+
};
|
|
13214
|
+
}
|
|
13215
|
+
const patched = patchSchemasInConfigSource(existingSource, schemaResolution.schemas);
|
|
13216
|
+
if (!patched) {
|
|
13217
|
+
return {
|
|
13218
|
+
action: "skipped",
|
|
13219
|
+
path: pathInfo.relativePath,
|
|
13220
|
+
absolutePath: pathInfo.absolutePath,
|
|
13221
|
+
content: existingSource,
|
|
13222
|
+
schemas: existingSchemas,
|
|
13223
|
+
changes: [
|
|
13224
|
+
...changes,
|
|
13225
|
+
"could-not-patch-schemas-surgically",
|
|
13226
|
+
"re-run with force=true to rewrite full template"
|
|
13227
|
+
],
|
|
13228
|
+
mode,
|
|
13229
|
+
reason: "existing config schemas could not be updated surgically without risking a destructive rewrite"
|
|
13230
|
+
};
|
|
13231
|
+
}
|
|
13232
|
+
if (patched === existingSource) {
|
|
13233
|
+
return {
|
|
13234
|
+
action: "unchanged",
|
|
13235
|
+
path: pathInfo.relativePath,
|
|
13236
|
+
absolutePath: pathInfo.absolutePath,
|
|
13237
|
+
content: existingSource,
|
|
13238
|
+
schemas: existingSchemas,
|
|
13239
|
+
changes: [...changes, "patch-noop"],
|
|
13240
|
+
mode,
|
|
13241
|
+
reason: "patch produced identical content"
|
|
13242
|
+
};
|
|
13243
|
+
}
|
|
13244
|
+
changes.push(
|
|
13245
|
+
`schemas-updated: ${existingSchemas.join(",")} -> ${schemaResolution.schemas.join(",")}`
|
|
13246
|
+
);
|
|
13247
|
+
if (!dryRun) {
|
|
13248
|
+
await promises.writeFile(pathInfo.absolutePath, patched, "utf8");
|
|
13249
|
+
}
|
|
13250
|
+
return {
|
|
13251
|
+
action: "updated",
|
|
13252
|
+
path: pathInfo.relativePath,
|
|
13253
|
+
absolutePath: pathInfo.absolutePath,
|
|
13254
|
+
content: patched,
|
|
13255
|
+
schemas: schemaResolution.schemas,
|
|
13256
|
+
changes,
|
|
13257
|
+
mode,
|
|
13258
|
+
reason: "auto-filled provider.schemas"
|
|
13259
|
+
};
|
|
13260
|
+
}
|
|
13261
|
+
|
|
13262
|
+
// src/generator/env.ts
|
|
13263
|
+
function readEnvStringValue2(key) {
|
|
13264
|
+
if (typeof process === "undefined" || !process.env) {
|
|
13265
|
+
return void 0;
|
|
13266
|
+
}
|
|
13267
|
+
const value = process.env[key];
|
|
13268
|
+
if (typeof value !== "string") {
|
|
13269
|
+
return void 0;
|
|
13270
|
+
}
|
|
13271
|
+
const trimmed = value.trim();
|
|
13272
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
13273
|
+
}
|
|
13274
|
+
function throwMissingEnvVar(key) {
|
|
13275
|
+
throw new Error(
|
|
13276
|
+
`Generator config env var ${key} is missing or empty. Set ${key} or provide a default value.`
|
|
13277
|
+
);
|
|
13278
|
+
}
|
|
13279
|
+
function resolveEnvValue(key, options, resolver) {
|
|
13280
|
+
const rawValue = readEnvStringValue2(key);
|
|
13281
|
+
if (rawValue === void 0) {
|
|
13282
|
+
if (options?.default !== void 0) {
|
|
13283
|
+
return options.default;
|
|
13284
|
+
}
|
|
13285
|
+
if (options?.optional) {
|
|
13286
|
+
return void 0;
|
|
13287
|
+
}
|
|
13288
|
+
return throwMissingEnvVar(key);
|
|
13289
|
+
}
|
|
13290
|
+
return resolver(rawValue);
|
|
13291
|
+
}
|
|
13292
|
+
function resolveStringEnv(key, options) {
|
|
13293
|
+
return resolveEnvValue(key, options, (value) => value);
|
|
13294
|
+
}
|
|
13295
|
+
function resolveBooleanEnv(key, options) {
|
|
13296
|
+
return resolveEnvValue(key, options, (value) => parseBooleanFlag2(value, false));
|
|
13297
|
+
}
|
|
13298
|
+
function resolveListEnv(key, options) {
|
|
13299
|
+
return resolveEnvValue(key, options, (value) => {
|
|
13300
|
+
const separator = options?.separator ?? ",";
|
|
13301
|
+
return value.split(separator).map((entry) => entry.trim()).filter((entry, index, entries) => entry.length > 0 && entries.indexOf(entry) === index);
|
|
13302
|
+
})?.slice();
|
|
13303
|
+
}
|
|
13304
|
+
function resolveJsonEnv(key, options) {
|
|
13305
|
+
return resolveEnvValue(key, options, (value) => {
|
|
13306
|
+
try {
|
|
13307
|
+
return JSON.parse(value);
|
|
13308
|
+
} catch (error) {
|
|
13309
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
13310
|
+
throw new Error(`Generator config env var ${key} must contain valid JSON. ${message}`);
|
|
13311
|
+
}
|
|
13312
|
+
});
|
|
13313
|
+
}
|
|
13314
|
+
function resolveOneOfEnv(key, allowedValues, options) {
|
|
13315
|
+
return resolveEnvValue(key, options, (value) => {
|
|
13316
|
+
if (allowedValues.includes(value)) {
|
|
13317
|
+
return value;
|
|
13318
|
+
}
|
|
13319
|
+
throw new Error(
|
|
13320
|
+
`Generator config env var ${key} must be one of: ${allowedValues.join(", ")}. Received: ${value}.`
|
|
13321
|
+
);
|
|
13322
|
+
});
|
|
13323
|
+
}
|
|
13324
|
+
function generatorEnvString(key, options) {
|
|
13325
|
+
return resolveStringEnv(key, options);
|
|
13326
|
+
}
|
|
13327
|
+
function generatorEnvBoolean(key, options) {
|
|
13328
|
+
return resolveBooleanEnv(key, options);
|
|
13329
|
+
}
|
|
13330
|
+
function generatorEnvList(key, options) {
|
|
13331
|
+
return resolveListEnv(key, options);
|
|
13332
|
+
}
|
|
13333
|
+
function generatorEnvJson(key, options) {
|
|
13334
|
+
return resolveJsonEnv(key, options);
|
|
13335
|
+
}
|
|
13336
|
+
function generatorEnvOneOf(key, allowedValues, options) {
|
|
13337
|
+
return resolveOneOfEnv(key, allowedValues, options);
|
|
13338
|
+
}
|
|
13339
|
+
var generatorEnv = Object.assign(generatorEnvString, {
|
|
13340
|
+
boolean: generatorEnvBoolean,
|
|
13341
|
+
list: generatorEnvList,
|
|
13342
|
+
json: generatorEnvJson,
|
|
13343
|
+
oneOf: generatorEnvOneOf
|
|
13344
|
+
});
|
|
13345
|
+
|
|
13346
|
+
// src/utils/slugify.ts
|
|
13347
|
+
function slugify(input) {
|
|
13348
|
+
return input.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64);
|
|
12406
13349
|
}
|
|
12407
13350
|
|
|
12408
13351
|
// src/generator/naming.ts
|
|
@@ -13041,7 +13984,7 @@ function renderModelArtifact(descriptor, config) {
|
|
|
13041
13984
|
const relationsAssignment = config.features.emitRelations && relationEntries.length > 0 ? `
|
|
13042
13985
|
Object.assign(${descriptor.tableConstName}.meta, {
|
|
13043
13986
|
relations: {
|
|
13044
|
-
${relationEntries.map(([
|
|
13987
|
+
${relationEntries.map(([relationKey3, relationValue]) => ` ${renderObjectKey(relationKey3)}: ${renderRelationLiteral(relationValue)}`).join(",\n")}
|
|
13045
13988
|
}
|
|
13046
13989
|
})
|
|
13047
13990
|
` : "";
|
|
@@ -13118,7 +14061,7 @@ function renderModelArtifact2(databaseName, descriptor, config) {
|
|
|
13118
14061
|
const relationEntries = Object.entries(descriptor.table.relations);
|
|
13119
14062
|
const relationBlock = config.features.emitRelations && relationEntries.length > 0 ? `,
|
|
13120
14063
|
relations: {
|
|
13121
|
-
${relationEntries.map(([
|
|
14064
|
+
${relationEntries.map(([relationKey3, relationValue]) => ` ${renderObjectKey(relationKey3)}: ${renderRelationLiteral(relationValue)}`).join(",\n")}
|
|
13122
14065
|
}` : "";
|
|
13123
14066
|
const content = `import { defineModel } from '@xylex-group/athena'
|
|
13124
14067
|
|
|
@@ -13227,6 +14170,11 @@ var AthenaGatewayPostgresIntrospectionProvider = class {
|
|
|
13227
14170
|
this.client = createClient({
|
|
13228
14171
|
db: { url: this.config.gatewayUrl },
|
|
13229
14172
|
key: this.config.apiKey,
|
|
14173
|
+
// Multi-tenant gateways reject DEFAULT_CLIENT; prefer explicit config.
|
|
14174
|
+
// Also pass process.env so ATHENA_CLIENT / ATHENA_GATEWAY_CLIENT still resolve
|
|
14175
|
+
// when the field was not normalized into provider config.
|
|
14176
|
+
client: this.config.client,
|
|
14177
|
+
env: typeof process !== "undefined" ? process.env : void 0,
|
|
13230
14178
|
backend: {
|
|
13231
14179
|
type: this.config.backend ?? "postgresql"
|
|
13232
14180
|
}
|
|
@@ -14127,23 +15075,80 @@ async function writeArtifacts(files, cwd, config, dryRun) {
|
|
|
14127
15075
|
skippedFiles
|
|
14128
15076
|
};
|
|
14129
15077
|
}
|
|
15078
|
+
function withPostgresSchemas(config, schemas) {
|
|
15079
|
+
if (config.provider.kind !== "postgres") {
|
|
15080
|
+
return config;
|
|
15081
|
+
}
|
|
15082
|
+
return {
|
|
15083
|
+
...config,
|
|
15084
|
+
provider: {
|
|
15085
|
+
...config.provider,
|
|
15086
|
+
schemas
|
|
15087
|
+
}
|
|
15088
|
+
};
|
|
15089
|
+
}
|
|
14130
15090
|
async function runSchemaGenerator(options = {}) {
|
|
14131
15091
|
const cwd = options.cwd ?? process.cwd();
|
|
15092
|
+
const dryRun = options.dryRun === true;
|
|
15093
|
+
const writeConfig = options.writeConfig !== false;
|
|
15094
|
+
const discoverSchemas = options.discoverSchemas !== false;
|
|
14132
15095
|
const configOptions = {
|
|
14133
15096
|
cwd,
|
|
14134
15097
|
configPath: options.configPath
|
|
14135
15098
|
};
|
|
14136
|
-
const
|
|
15099
|
+
const loaded = await loadGeneratorConfig(configOptions);
|
|
15100
|
+
let { configPath, config } = loaded;
|
|
15101
|
+
let configEnsure;
|
|
15102
|
+
let effectiveSchemas = resolveProviderSchemas(config.provider);
|
|
15103
|
+
const canDiscoverLive = discoverSchemas && config.provider.kind === "postgres" && !options.provider;
|
|
15104
|
+
if (canDiscoverLive) {
|
|
15105
|
+
try {
|
|
15106
|
+
const discovered = await discoverPostgresSchemas(config.provider);
|
|
15107
|
+
if (discovered.length > 0) {
|
|
15108
|
+
effectiveSchemas = mergeSchemaSelections(effectiveSchemas, discovered);
|
|
15109
|
+
}
|
|
15110
|
+
} catch {
|
|
15111
|
+
}
|
|
15112
|
+
}
|
|
15113
|
+
config = withPostgresSchemas(config, effectiveSchemas);
|
|
15114
|
+
const shouldEnsureConfig = writeConfig && config.provider.kind === "postgres" && !options.provider;
|
|
15115
|
+
if (shouldEnsureConfig) {
|
|
15116
|
+
const ensureResult = await ensureGeneratorConfigFile({
|
|
15117
|
+
cwd,
|
|
15118
|
+
configPath: options.configPath,
|
|
15119
|
+
dryRun,
|
|
15120
|
+
// Schemas already resolved above — avoid a second discovery round-trip.
|
|
15121
|
+
discoverSchemas: false,
|
|
15122
|
+
provider: config.provider,
|
|
15123
|
+
loaded: { configPath, config },
|
|
15124
|
+
schemas: effectiveSchemas,
|
|
15125
|
+
mode: config.provider.mode
|
|
15126
|
+
});
|
|
15127
|
+
configEnsure = {
|
|
15128
|
+
action: ensureResult.action,
|
|
15129
|
+
path: ensureResult.path,
|
|
15130
|
+
schemas: ensureResult.schemas,
|
|
15131
|
+
changes: ensureResult.changes,
|
|
15132
|
+
reason: ensureResult.reason
|
|
15133
|
+
};
|
|
15134
|
+
if (ensureResult.action === "created" || ensureResult.action === "updated" || ensureResult.action === "unchanged" && configPath === "[environment defaults]") {
|
|
15135
|
+
configPath = ensureResult.absolutePath;
|
|
15136
|
+
if (ensureResult.schemas.length > 0) {
|
|
15137
|
+
effectiveSchemas = ensureResult.schemas;
|
|
15138
|
+
config = withPostgresSchemas(config, effectiveSchemas);
|
|
15139
|
+
}
|
|
15140
|
+
}
|
|
15141
|
+
}
|
|
14137
15142
|
const provider = options.provider ?? resolveGeneratorProvider(config.provider, config.experimental);
|
|
14138
15143
|
const snapshot = await provider.inspect({
|
|
14139
|
-
schemas:
|
|
15144
|
+
schemas: effectiveSchemas
|
|
14140
15145
|
});
|
|
14141
15146
|
const generated = generateArtifactsFromSnapshot(snapshot, config);
|
|
14142
15147
|
const writeResult = await writeArtifacts(
|
|
14143
15148
|
generated.files,
|
|
14144
15149
|
cwd,
|
|
14145
15150
|
config,
|
|
14146
|
-
|
|
15151
|
+
dryRun
|
|
14147
15152
|
);
|
|
14148
15153
|
return {
|
|
14149
15154
|
...generated,
|
|
@@ -14151,7 +15156,8 @@ async function runSchemaGenerator(options = {}) {
|
|
|
14151
15156
|
config,
|
|
14152
15157
|
writtenFiles: writeResult.writtenFiles,
|
|
14153
15158
|
writtenDetails: writeResult.writtenDetails,
|
|
14154
|
-
skippedFiles: writeResult.skippedFiles
|
|
15159
|
+
skippedFiles: writeResult.skippedFiles,
|
|
15160
|
+
configEnsure
|
|
14155
15161
|
};
|
|
14156
15162
|
}
|
|
14157
15163
|
|
|
@@ -14220,15 +15226,15 @@ function readCookieFromHeaders(headers, name) {
|
|
|
14220
15226
|
}
|
|
14221
15227
|
return parseCookies(cookieHeader).get(name);
|
|
14222
15228
|
}
|
|
14223
|
-
function
|
|
15229
|
+
function isRecord14(value) {
|
|
14224
15230
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
14225
15231
|
}
|
|
14226
15232
|
function resolveSessionCandidate(value) {
|
|
14227
|
-
if (!
|
|
15233
|
+
if (!isRecord14(value)) {
|
|
14228
15234
|
return null;
|
|
14229
15235
|
}
|
|
14230
|
-
const session =
|
|
14231
|
-
const user =
|
|
15236
|
+
const session = isRecord14(value.session) ? value.session : void 0;
|
|
15237
|
+
const user = isRecord14(value.user) ? value.user : void 0;
|
|
14232
15238
|
if (session && typeof session.token === "string" && session.token.length > 0 && user) {
|
|
14233
15239
|
return {
|
|
14234
15240
|
session,
|
|
@@ -14238,7 +15244,7 @@ function resolveSessionCandidate(value) {
|
|
|
14238
15244
|
return null;
|
|
14239
15245
|
}
|
|
14240
15246
|
function inferSessionPair(returned) {
|
|
14241
|
-
return resolveSessionCandidate(returned) ?? (
|
|
15247
|
+
return resolveSessionCandidate(returned) ?? (isRecord14(returned) ? resolveSessionCandidate(returned.data) : null) ?? (isRecord14(returned) ? resolveSessionCandidate(returned.session) : null);
|
|
14242
15248
|
}
|
|
14243
15249
|
function resolveResponseHeaders(ctx) {
|
|
14244
15250
|
if (ctx.context.responseHeaders instanceof Headers) {
|
|
@@ -14649,12 +15655,439 @@ async function ensureActiveOrganization(options) {
|
|
|
14649
15655
|
}
|
|
14650
15656
|
}
|
|
14651
15657
|
|
|
15658
|
+
// src/tables/catalog.ts
|
|
15659
|
+
var POSTGRES_CATALOG_SQL2 = {
|
|
15660
|
+
columns: `
|
|
15661
|
+
SELECT
|
|
15662
|
+
n.nspname AS schema_name,
|
|
15663
|
+
c.relname AS table_name,
|
|
15664
|
+
a.attname AS column_name,
|
|
15665
|
+
format_type(a.atttypid, a.atttypmod) AS data_type,
|
|
15666
|
+
NOT a.attnotnull AS is_nullable
|
|
15667
|
+
FROM pg_attribute a
|
|
15668
|
+
JOIN pg_class c ON c.oid = a.attrelid
|
|
15669
|
+
JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
15670
|
+
WHERE c.relkind IN ('r', 'p')
|
|
15671
|
+
AND a.attnum > 0
|
|
15672
|
+
AND NOT a.attisdropped
|
|
15673
|
+
AND n.nspname = ANY($1::text[])
|
|
15674
|
+
ORDER BY n.nspname, c.relname, a.attnum;
|
|
15675
|
+
`,
|
|
15676
|
+
foreignKeys: `
|
|
15677
|
+
SELECT
|
|
15678
|
+
sn.nspname AS source_schema,
|
|
15679
|
+
sc.relname AS source_table,
|
|
15680
|
+
con.conname AS constraint_name,
|
|
15681
|
+
ARRAY_AGG(sa.attname ORDER BY cols.ordinality) AS source_columns,
|
|
15682
|
+
tn.nspname AS target_schema,
|
|
15683
|
+
tc.relname AS target_table,
|
|
15684
|
+
ARRAY_AGG(ta.attname ORDER BY cols.ordinality) AS target_columns,
|
|
15685
|
+
EXISTS (
|
|
15686
|
+
SELECT 1
|
|
15687
|
+
FROM pg_constraint uq
|
|
15688
|
+
WHERE uq.conrelid = con.conrelid
|
|
15689
|
+
AND uq.contype IN ('p', 'u')
|
|
15690
|
+
AND uq.conkey = con.conkey
|
|
15691
|
+
) AS source_is_unique
|
|
15692
|
+
FROM pg_constraint con
|
|
15693
|
+
JOIN pg_class sc ON sc.oid = con.conrelid
|
|
15694
|
+
JOIN pg_namespace sn ON sn.oid = sc.relnamespace
|
|
15695
|
+
JOIN pg_class tc ON tc.oid = con.confrelid
|
|
15696
|
+
JOIN pg_namespace tn ON tn.oid = tc.relnamespace
|
|
15697
|
+
JOIN unnest(con.conkey, con.confkey) WITH ORDINALITY AS cols(source_attnum, target_attnum, ordinality) ON TRUE
|
|
15698
|
+
JOIN pg_attribute sa ON sa.attrelid = con.conrelid AND sa.attnum = cols.source_attnum
|
|
15699
|
+
JOIN pg_attribute ta ON ta.attrelid = con.confrelid AND ta.attnum = cols.target_attnum
|
|
15700
|
+
WHERE con.contype = 'f'
|
|
15701
|
+
AND sn.nspname = ANY($1::text[])
|
|
15702
|
+
AND tn.nspname = ANY($1::text[])
|
|
15703
|
+
GROUP BY
|
|
15704
|
+
sn.nspname,
|
|
15705
|
+
sc.relname,
|
|
15706
|
+
con.conname,
|
|
15707
|
+
tn.nspname,
|
|
15708
|
+
tc.relname,
|
|
15709
|
+
con.conkey,
|
|
15710
|
+
con.conrelid
|
|
15711
|
+
ORDER BY sn.nspname, sc.relname, con.conname;
|
|
15712
|
+
`,
|
|
15713
|
+
primaryKeys: `
|
|
15714
|
+
SELECT
|
|
15715
|
+
n.nspname AS schema_name,
|
|
15716
|
+
c.relname AS table_name,
|
|
15717
|
+
ARRAY_AGG(a.attname ORDER BY ck.ordinality) AS columns
|
|
15718
|
+
FROM pg_constraint con
|
|
15719
|
+
JOIN pg_class c ON c.oid = con.conrelid
|
|
15720
|
+
JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
15721
|
+
JOIN unnest(con.conkey) WITH ORDINALITY AS ck(attnum, ordinality) ON TRUE
|
|
15722
|
+
JOIN pg_attribute a ON a.attrelid = c.oid AND a.attnum = ck.attnum
|
|
15723
|
+
WHERE con.contype = 'p'
|
|
15724
|
+
AND n.nspname = ANY($1::text[])
|
|
15725
|
+
GROUP BY n.nspname, c.relname
|
|
15726
|
+
ORDER BY n.nspname, c.relname;
|
|
15727
|
+
`
|
|
15728
|
+
};
|
|
15729
|
+
function parseAthenaTableSchemaScope(value) {
|
|
15730
|
+
return value.split(",").map((entry) => entry.trim()).filter(
|
|
15731
|
+
(entry, index, values) => entry.length > 0 && values.indexOf(entry) === index
|
|
15732
|
+
);
|
|
15733
|
+
}
|
|
15734
|
+
function escapeSqlLiteral2(value) {
|
|
15735
|
+
return value.replace(/'/g, "''");
|
|
15736
|
+
}
|
|
15737
|
+
function buildSchemaArrayLiteral2(schemas) {
|
|
15738
|
+
const literals = schemas.map((schema) => `'${escapeSqlLiteral2(schema)}'`).join(", ");
|
|
15739
|
+
return `ARRAY[${literals}]`;
|
|
15740
|
+
}
|
|
15741
|
+
function inlineSchemaLiteral2(sql, schemas) {
|
|
15742
|
+
return sql.replace(
|
|
15743
|
+
/\$1::text\[\]/g,
|
|
15744
|
+
`${buildSchemaArrayLiteral2(schemas)}::text[]`
|
|
15745
|
+
);
|
|
15746
|
+
}
|
|
15747
|
+
function buildAthenaTableCatalogQueries(schemas) {
|
|
15748
|
+
return {
|
|
15749
|
+
columns: inlineSchemaLiteral2(POSTGRES_CATALOG_SQL2.columns, schemas),
|
|
15750
|
+
foreignKeys: inlineSchemaLiteral2(POSTGRES_CATALOG_SQL2.foreignKeys, schemas),
|
|
15751
|
+
primaryKeys: inlineSchemaLiteral2(POSTGRES_CATALOG_SQL2.primaryKeys, schemas)
|
|
15752
|
+
};
|
|
15753
|
+
}
|
|
15754
|
+
function tableKey2(schema, table2) {
|
|
15755
|
+
return `${schema}.${table2}`;
|
|
15756
|
+
}
|
|
15757
|
+
function relationKey2(...parts) {
|
|
15758
|
+
const base = parts.join("_").replace(/[^A-Za-z0-9_]+/g, "_").replace(/^_+|_+$/g, "");
|
|
15759
|
+
return base.length > 0 ? base : "relation";
|
|
15760
|
+
}
|
|
15761
|
+
function parsePostgresArrayLiteral2(text) {
|
|
15762
|
+
const body = text.slice(1, -1).trim();
|
|
15763
|
+
if (!body) {
|
|
15764
|
+
return [];
|
|
15765
|
+
}
|
|
15766
|
+
const values = [];
|
|
15767
|
+
let current = "";
|
|
15768
|
+
let inQuotes = false;
|
|
15769
|
+
let escaped = false;
|
|
15770
|
+
for (const char of body) {
|
|
15771
|
+
if (escaped) {
|
|
15772
|
+
current += char;
|
|
15773
|
+
escaped = false;
|
|
15774
|
+
continue;
|
|
15775
|
+
}
|
|
15776
|
+
if (char === "\\") {
|
|
15777
|
+
escaped = true;
|
|
15778
|
+
continue;
|
|
15779
|
+
}
|
|
15780
|
+
if (char === '"') {
|
|
15781
|
+
inQuotes = !inQuotes;
|
|
15782
|
+
continue;
|
|
15783
|
+
}
|
|
15784
|
+
if (char === "," && !inQuotes) {
|
|
15785
|
+
values.push(current);
|
|
15786
|
+
current = "";
|
|
15787
|
+
continue;
|
|
15788
|
+
}
|
|
15789
|
+
current += char;
|
|
15790
|
+
}
|
|
15791
|
+
values.push(current);
|
|
15792
|
+
return values.map((value) => value.trim()).filter((value) => value.length > 0);
|
|
15793
|
+
}
|
|
15794
|
+
function coerceStringArray2(value) {
|
|
15795
|
+
if (value == null) {
|
|
15796
|
+
return [];
|
|
15797
|
+
}
|
|
15798
|
+
if (Array.isArray(value)) {
|
|
15799
|
+
return value.map((entry) => entry.trim()).filter(Boolean);
|
|
15800
|
+
}
|
|
15801
|
+
if (typeof value !== "string") {
|
|
15802
|
+
return [];
|
|
15803
|
+
}
|
|
15804
|
+
const trimmedValue = value.trim();
|
|
15805
|
+
if (!trimmedValue) {
|
|
15806
|
+
return [];
|
|
15807
|
+
}
|
|
15808
|
+
if (trimmedValue.startsWith("{") && trimmedValue.endsWith("}")) {
|
|
15809
|
+
return parsePostgresArrayLiteral2(trimmedValue);
|
|
15810
|
+
}
|
|
15811
|
+
return trimmedValue.split(",").map((entry) => entry.trim()).filter(Boolean);
|
|
15812
|
+
}
|
|
15813
|
+
function createTableCatalog() {
|
|
15814
|
+
const tables = /* @__PURE__ */ new Map();
|
|
15815
|
+
const ensureTable = (schema, name) => {
|
|
15816
|
+
const id = tableKey2(schema, name);
|
|
15817
|
+
const existingTable = tables.get(id);
|
|
15818
|
+
if (existingTable) {
|
|
15819
|
+
return existingTable;
|
|
15820
|
+
}
|
|
15821
|
+
const nextTable = {
|
|
15822
|
+
columns: [],
|
|
15823
|
+
id,
|
|
15824
|
+
name,
|
|
15825
|
+
primaryKey: [],
|
|
15826
|
+
relationMap: /* @__PURE__ */ new Map(),
|
|
15827
|
+
schema
|
|
15828
|
+
};
|
|
15829
|
+
tables.set(id, nextTable);
|
|
15830
|
+
return nextTable;
|
|
15831
|
+
};
|
|
15832
|
+
const upsertRelation = (table2, key, relation) => {
|
|
15833
|
+
table2.relationMap.set(key, relation);
|
|
15834
|
+
};
|
|
15835
|
+
return {
|
|
15836
|
+
addColumnRows(columnRows) {
|
|
15837
|
+
for (const row of columnRows) {
|
|
15838
|
+
const table2 = ensureTable(row.schema_name, row.table_name);
|
|
15839
|
+
table2.columns.push({
|
|
15840
|
+
dataType: row.data_type,
|
|
15841
|
+
isNullable: row.is_nullable,
|
|
15842
|
+
isPrimaryKey: false,
|
|
15843
|
+
name: row.column_name
|
|
15844
|
+
});
|
|
15845
|
+
}
|
|
15846
|
+
},
|
|
15847
|
+
addForeignKeyRows(foreignKeyRows) {
|
|
15848
|
+
for (const row of foreignKeyRows) {
|
|
15849
|
+
const sourceTable = ensureTable(row.source_schema, row.source_table);
|
|
15850
|
+
const targetTable = ensureTable(row.target_schema, row.target_table);
|
|
15851
|
+
upsertRelation(
|
|
15852
|
+
sourceTable,
|
|
15853
|
+
relationKey2(row.constraint_name, row.target_table),
|
|
15854
|
+
{
|
|
15855
|
+
name: row.constraint_name,
|
|
15856
|
+
targetSchema: row.target_schema,
|
|
15857
|
+
targetTable: row.target_table
|
|
15858
|
+
}
|
|
15859
|
+
);
|
|
15860
|
+
upsertRelation(targetTable, relationKey2(row.source_table), {
|
|
15861
|
+
name: relationKey2(row.source_table, row.constraint_name),
|
|
15862
|
+
targetSchema: row.source_schema,
|
|
15863
|
+
targetTable: row.source_table
|
|
15864
|
+
});
|
|
15865
|
+
}
|
|
15866
|
+
},
|
|
15867
|
+
addManyToManyRows(foreignKeyRows) {
|
|
15868
|
+
const foreignKeysBySourceTable = /* @__PURE__ */ new Map();
|
|
15869
|
+
for (const foreignKey of foreignKeyRows) {
|
|
15870
|
+
const key = tableKey2(foreignKey.source_schema, foreignKey.source_table);
|
|
15871
|
+
const current = foreignKeysBySourceTable.get(key) ?? {
|
|
15872
|
+
foreignKeys: [],
|
|
15873
|
+
schema: foreignKey.source_schema,
|
|
15874
|
+
table: foreignKey.source_table
|
|
15875
|
+
};
|
|
15876
|
+
current.foreignKeys.push(foreignKey);
|
|
15877
|
+
foreignKeysBySourceTable.set(key, current);
|
|
15878
|
+
}
|
|
15879
|
+
for (const candidate of foreignKeysBySourceTable.values()) {
|
|
15880
|
+
const bridgeTable = tables.get(
|
|
15881
|
+
tableKey2(candidate.schema, candidate.table)
|
|
15882
|
+
);
|
|
15883
|
+
if (!bridgeTable || candidate.foreignKeys.length !== 2) {
|
|
15884
|
+
continue;
|
|
15885
|
+
}
|
|
15886
|
+
const combinedForeignColumns = Array.from(
|
|
15887
|
+
new Set(
|
|
15888
|
+
candidate.foreignKeys.flatMap(
|
|
15889
|
+
(foreignKey) => coerceStringArray2(foreignKey.source_columns)
|
|
15890
|
+
)
|
|
15891
|
+
)
|
|
15892
|
+
);
|
|
15893
|
+
if (bridgeTable.primaryKey.length === 0 || combinedForeignColumns.length !== bridgeTable.primaryKey.length || !bridgeTable.primaryKey.every(
|
|
15894
|
+
(column) => combinedForeignColumns.includes(column)
|
|
15895
|
+
)) {
|
|
15896
|
+
continue;
|
|
15897
|
+
}
|
|
15898
|
+
const [firstForeignKey, secondForeignKey] = candidate.foreignKeys;
|
|
15899
|
+
const firstTarget = tables.get(
|
|
15900
|
+
tableKey2(firstForeignKey.target_schema, firstForeignKey.target_table)
|
|
15901
|
+
);
|
|
15902
|
+
const secondTarget = tables.get(
|
|
15903
|
+
tableKey2(
|
|
15904
|
+
secondForeignKey.target_schema,
|
|
15905
|
+
secondForeignKey.target_table
|
|
15906
|
+
)
|
|
15907
|
+
);
|
|
15908
|
+
if (!(firstTarget && secondTarget)) {
|
|
15909
|
+
continue;
|
|
15910
|
+
}
|
|
15911
|
+
upsertRelation(
|
|
15912
|
+
firstTarget,
|
|
15913
|
+
relationKey2(candidate.table, secondForeignKey.target_table),
|
|
15914
|
+
{
|
|
15915
|
+
name: relationKey2(
|
|
15916
|
+
candidate.table,
|
|
15917
|
+
secondForeignKey.constraint_name
|
|
15918
|
+
),
|
|
15919
|
+
targetSchema: secondForeignKey.target_schema,
|
|
15920
|
+
targetTable: secondForeignKey.target_table
|
|
15921
|
+
}
|
|
15922
|
+
);
|
|
15923
|
+
upsertRelation(
|
|
15924
|
+
secondTarget,
|
|
15925
|
+
relationKey2(candidate.table, firstForeignKey.target_table),
|
|
15926
|
+
{
|
|
15927
|
+
name: relationKey2(candidate.table, firstForeignKey.constraint_name),
|
|
15928
|
+
targetSchema: firstForeignKey.target_schema,
|
|
15929
|
+
targetTable: firstForeignKey.target_table
|
|
15930
|
+
}
|
|
15931
|
+
);
|
|
15932
|
+
}
|
|
15933
|
+
},
|
|
15934
|
+
addPrimaryKeyRows(primaryKeyRows) {
|
|
15935
|
+
for (const row of primaryKeyRows) {
|
|
15936
|
+
const table2 = ensureTable(row.schema_name, row.table_name);
|
|
15937
|
+
const primaryKey = coerceStringArray2(row.columns);
|
|
15938
|
+
table2.primaryKey = primaryKey;
|
|
15939
|
+
for (const columnName of primaryKey) {
|
|
15940
|
+
const column = table2.columns.find(
|
|
15941
|
+
(candidate) => candidate.name === columnName
|
|
15942
|
+
);
|
|
15943
|
+
if (column) {
|
|
15944
|
+
column.isPrimaryKey = true;
|
|
15945
|
+
}
|
|
15946
|
+
}
|
|
15947
|
+
}
|
|
15948
|
+
},
|
|
15949
|
+
toResponse(database) {
|
|
15950
|
+
return {
|
|
15951
|
+
database,
|
|
15952
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
15953
|
+
tables: [...tables.values()].map((table2) => ({
|
|
15954
|
+
columns: [...table2.columns].sort(
|
|
15955
|
+
(left, right) => left.name.localeCompare(right.name)
|
|
15956
|
+
),
|
|
15957
|
+
id: table2.id,
|
|
15958
|
+
name: table2.name,
|
|
15959
|
+
primaryKey: [...table2.primaryKey],
|
|
15960
|
+
relations: [...table2.relationMap.values()].map((relation) => ({
|
|
15961
|
+
columns: tables.get(
|
|
15962
|
+
tableKey2(relation.targetSchema, relation.targetTable)
|
|
15963
|
+
)?.columns ?? [],
|
|
15964
|
+
name: relation.name,
|
|
15965
|
+
targetSchema: relation.targetSchema,
|
|
15966
|
+
targetTable: relation.targetTable
|
|
15967
|
+
})).sort(
|
|
15968
|
+
(left, right) => left.name.localeCompare(right.name)
|
|
15969
|
+
),
|
|
15970
|
+
schema: table2.schema
|
|
15971
|
+
})).sort(
|
|
15972
|
+
(left, right) => left.id.localeCompare(right.id)
|
|
15973
|
+
)
|
|
15974
|
+
};
|
|
15975
|
+
}
|
|
15976
|
+
};
|
|
15977
|
+
}
|
|
15978
|
+
async function queryRows(client, query) {
|
|
15979
|
+
const result = await client.query(query);
|
|
15980
|
+
if (result.error || result.status < 200 || result.status >= 300) {
|
|
15981
|
+
const errorMessage = typeof result.error === "string" ? result.error : result.error && typeof result.error === "object" && "message" in result.error && typeof result.error.message === "string" ? result.error.message : `Athena gateway query failed with status ${result.status}.`;
|
|
15982
|
+
throw new Error(errorMessage);
|
|
15983
|
+
}
|
|
15984
|
+
return Array.isArray(result.data) ? result.data : [];
|
|
15985
|
+
}
|
|
15986
|
+
function isAthenaTableSchemaConfig(value) {
|
|
15987
|
+
if (typeof value !== "object" || value === null) {
|
|
15988
|
+
return false;
|
|
15989
|
+
}
|
|
15990
|
+
const config = value;
|
|
15991
|
+
return typeof config.gatewayUrl === "string" && typeof config.gatewayKey === "string" && typeof config.gatewayDatabase === "string" && typeof config.schemaScope === "string" && typeof config.clientName === "string";
|
|
15992
|
+
}
|
|
15993
|
+
function hasAthenaTableSchemaCredentials(config) {
|
|
15994
|
+
return config.gatewayUrl.trim().length > 0 && config.gatewayKey.trim().length > 0 && config.gatewayDatabase.trim().length > 0;
|
|
15995
|
+
}
|
|
15996
|
+
async function fetchAthenaTableCatalog(config, options = {}) {
|
|
15997
|
+
const schemas = parseAthenaTableSchemaScope(config.schemaScope);
|
|
15998
|
+
if (schemas.length === 0) {
|
|
15999
|
+
return {
|
|
16000
|
+
database: config.gatewayDatabase,
|
|
16001
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
16002
|
+
tables: []
|
|
16003
|
+
};
|
|
16004
|
+
}
|
|
16005
|
+
const queries = buildAthenaTableCatalogQueries(schemas);
|
|
16006
|
+
const client = options.client ?? createClient({
|
|
16007
|
+
url: config.gatewayUrl.trim(),
|
|
16008
|
+
key: config.gatewayKey.trim(),
|
|
16009
|
+
client: config.clientName.trim() || void 0
|
|
16010
|
+
});
|
|
16011
|
+
const [columnRows, primaryKeyRows, foreignKeyRows] = await Promise.all([
|
|
16012
|
+
queryRows(client, queries.columns),
|
|
16013
|
+
queryRows(client, queries.primaryKeys),
|
|
16014
|
+
queryRows(client, queries.foreignKeys)
|
|
16015
|
+
]);
|
|
16016
|
+
const catalog = createTableCatalog();
|
|
16017
|
+
catalog.addColumnRows(columnRows);
|
|
16018
|
+
catalog.addPrimaryKeyRows(primaryKeyRows);
|
|
16019
|
+
catalog.addForeignKeyRows(foreignKeyRows);
|
|
16020
|
+
catalog.addManyToManyRows(foreignKeyRows);
|
|
16021
|
+
return catalog.toResponse(config.gatewayDatabase);
|
|
16022
|
+
}
|
|
16023
|
+
var fetchTableCatalog = fetchAthenaTableCatalog;
|
|
16024
|
+
|
|
16025
|
+
// src/tables/schema-handlers.ts
|
|
16026
|
+
var ATHENA_TABLE_SCHEMA_ROUTE = "/api/tables/schema";
|
|
16027
|
+
function json2(body, init) {
|
|
16028
|
+
const headers = new Headers(init?.headers);
|
|
16029
|
+
if (!headers.has("content-type")) {
|
|
16030
|
+
headers.set("content-type", "application/json; charset=utf-8");
|
|
16031
|
+
}
|
|
16032
|
+
return new Response(JSON.stringify(body), {
|
|
16033
|
+
status: init?.status ?? 200,
|
|
16034
|
+
headers
|
|
16035
|
+
});
|
|
16036
|
+
}
|
|
16037
|
+
async function handleAthenaTableSchemaPost(request2, options) {
|
|
16038
|
+
const payload = await request2.json().catch(() => null);
|
|
16039
|
+
let config = isAthenaTableSchemaConfig(
|
|
16040
|
+
payload?.config
|
|
16041
|
+
) ? payload.config : null;
|
|
16042
|
+
if (config && options?.resolveConfig) {
|
|
16043
|
+
config = await options.resolveConfig(config, request2);
|
|
16044
|
+
}
|
|
16045
|
+
if (!config || !isAthenaTableSchemaConfig(config)) {
|
|
16046
|
+
return json2(
|
|
16047
|
+
{
|
|
16048
|
+
error: "The Athena tables showcase config is invalid."
|
|
16049
|
+
},
|
|
16050
|
+
{ status: 400 }
|
|
16051
|
+
);
|
|
16052
|
+
}
|
|
16053
|
+
if (!hasAthenaTableSchemaCredentials(config)) {
|
|
16054
|
+
return json2(
|
|
16055
|
+
{
|
|
16056
|
+
error: "Gateway URL, API key, and database are required for schema introspection."
|
|
16057
|
+
},
|
|
16058
|
+
{ status: 400 }
|
|
16059
|
+
);
|
|
16060
|
+
}
|
|
16061
|
+
try {
|
|
16062
|
+
const response = await fetchAthenaTableCatalog(
|
|
16063
|
+
config,
|
|
16064
|
+
{
|
|
16065
|
+
client: options?.client
|
|
16066
|
+
}
|
|
16067
|
+
);
|
|
16068
|
+
return json2(response);
|
|
16069
|
+
} catch (error) {
|
|
16070
|
+
return json2(
|
|
16071
|
+
{
|
|
16072
|
+
error: error instanceof Error ? error.message : "Athena schema introspection failed."
|
|
16073
|
+
},
|
|
16074
|
+
{ status: 500 }
|
|
16075
|
+
);
|
|
16076
|
+
}
|
|
16077
|
+
}
|
|
16078
|
+
function createAthenaTableSchemaHandlers(options) {
|
|
16079
|
+
return {
|
|
16080
|
+
POST: (request2) => handleAthenaTableSchemaPost(request2, options)
|
|
16081
|
+
};
|
|
16082
|
+
}
|
|
16083
|
+
|
|
14652
16084
|
exports.ATHENA_AUTH_ADMIN_LIMITS = ATHENA_AUTH_ADMIN_LIMITS;
|
|
14653
16085
|
exports.ATHENA_AUTH_BASE_ERROR_CODES = ATHENA_AUTH_BASE_ERROR_CODES;
|
|
14654
16086
|
exports.ATHENA_AUTH_MAX_ADMIN_JSON_BYTES = ATHENA_AUTH_MAX_ADMIN_JSON_BYTES;
|
|
14655
16087
|
exports.ATHENA_AUTH_MAX_ADMIN_JSON_DEPTH = ATHENA_AUTH_MAX_ADMIN_JSON_DEPTH;
|
|
14656
16088
|
exports.ATHENA_AUTH_MAX_TEMPLATE_VARIABLES = ATHENA_AUTH_MAX_TEMPLATE_VARIABLES;
|
|
14657
16089
|
exports.ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH = ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH;
|
|
16090
|
+
exports.ATHENA_TABLE_SCHEMA_ROUTE = ATHENA_TABLE_SCHEMA_ROUTE;
|
|
14658
16091
|
exports.AthenaBillingError = AthenaBillingError;
|
|
14659
16092
|
exports.AthenaChatError = AthenaChatError;
|
|
14660
16093
|
exports.AthenaConfigurationError = AthenaConfigurationError;
|
|
@@ -14669,13 +16102,31 @@ exports.Backend = Backend;
|
|
|
14669
16102
|
exports.DEFAULT_MULTIPART_PART_SIZE_BYTES = DEFAULT_MULTIPART_PART_SIZE_BYTES;
|
|
14670
16103
|
exports.DEFAULT_MULTIPART_THRESHOLD_BYTES = DEFAULT_MULTIPART_THRESHOLD_BYTES;
|
|
14671
16104
|
exports.DEFAULT_POSTGRES_SCHEMAS = DEFAULT_POSTGRES_SCHEMAS;
|
|
16105
|
+
exports.applyAthenaReadQueryFilters = applyAthenaReadQueryFilters;
|
|
16106
|
+
exports.applyAthenaReadQuerySelectLimit = applyAthenaReadQuerySelectLimit;
|
|
16107
|
+
exports.applyAthenaReadQuerySelectOrder = applyAthenaReadQuerySelectOrder;
|
|
16108
|
+
exports.applyAthenaTableFilters = applyAthenaTableFilters;
|
|
16109
|
+
exports.applyAthenaTableSelectLimit = applyAthenaTableSelectLimit;
|
|
16110
|
+
exports.applyAthenaTableSelectOrder = applyAthenaTableSelectOrder;
|
|
14672
16111
|
exports.assertInt = assertInt;
|
|
14673
16112
|
exports.athenaAuth = athenaAuth;
|
|
14674
16113
|
exports.billingSdkManifest = billingSdkManifest;
|
|
14675
16114
|
exports.boolean = boolean;
|
|
16115
|
+
exports.buildAthenaReadQueryFindManyOrderBy = buildAthenaReadQueryFindManyOrderBy;
|
|
16116
|
+
exports.buildAthenaReadQueryFindManySelect = buildAthenaReadQueryFindManySelect;
|
|
16117
|
+
exports.buildAthenaReadQueryFindManyWhere = buildAthenaReadQueryFindManyWhere;
|
|
16118
|
+
exports.buildAthenaReadQuerySelectString = buildAthenaReadQuerySelectString;
|
|
16119
|
+
exports.buildAthenaTableCatalogQueries = buildAthenaTableCatalogQueries;
|
|
16120
|
+
exports.buildAthenaTableFindManyOrderBy = buildAthenaTableFindManyOrderBy;
|
|
16121
|
+
exports.buildAthenaTableFindManySelect = buildAthenaTableFindManySelect;
|
|
16122
|
+
exports.buildAthenaTableFindManyWhere = buildAthenaTableFindManyWhere;
|
|
16123
|
+
exports.buildAthenaTableSelectString = buildAthenaTableSelectString;
|
|
14676
16124
|
exports.chatSdkManifest = chatSdkManifest;
|
|
16125
|
+
exports.clampAthenaReadQueryTotalItems = clampAthenaReadQueryTotalItems;
|
|
16126
|
+
exports.clampAthenaTableTotalItems = clampAthenaTableTotalItems;
|
|
14677
16127
|
exports.coerceInt = coerceInt;
|
|
14678
16128
|
exports.createAthenaStorageError = createAthenaStorageError;
|
|
16129
|
+
exports.createAthenaTableSchemaHandlers = createAthenaTableSchemaHandlers;
|
|
14679
16130
|
exports.createAuthReactEmailInput = createAuthReactEmailInput;
|
|
14680
16131
|
exports.createBillingModule = createBillingModule;
|
|
14681
16132
|
exports.createClient = createClient;
|
|
@@ -14689,33 +16140,54 @@ exports.defineGeneratorConfig = defineGeneratorConfig;
|
|
|
14689
16140
|
exports.defineModel = defineModel;
|
|
14690
16141
|
exports.defineRegistry = defineRegistry;
|
|
14691
16142
|
exports.defineSchema = defineSchema;
|
|
16143
|
+
exports.detectGeneratorProviderMode = detectGeneratorProviderMode;
|
|
16144
|
+
exports.discoverPostgresSchemas = discoverPostgresSchemas;
|
|
14692
16145
|
exports.ensureActiveOrganization = ensureActiveOrganization;
|
|
16146
|
+
exports.ensureGeneratorConfigFile = ensureGeneratorConfigFile;
|
|
14693
16147
|
exports.enumeration = enumeration;
|
|
16148
|
+
exports.executeAthenaReadQuery = executeAthenaReadQuery;
|
|
16149
|
+
exports.executeAthenaTableQuery = executeAthenaTableQuery;
|
|
16150
|
+
exports.fetchAthenaTableCatalog = fetchAthenaTableCatalog;
|
|
16151
|
+
exports.fetchTableCatalog = fetchTableCatalog;
|
|
14694
16152
|
exports.filterIntrospectionSnapshot = filterIntrospectionSnapshot;
|
|
14695
16153
|
exports.findGeneratorConfigPath = findGeneratorConfigPath;
|
|
16154
|
+
exports.flattenAthenaReadQueryRows = flattenAthenaReadQueryRows;
|
|
16155
|
+
exports.flattenAthenaRows = flattenAthenaRows;
|
|
14696
16156
|
exports.generateArtifactsFromSnapshot = generateArtifactsFromSnapshot;
|
|
14697
16157
|
exports.generatorEnv = generatorEnv;
|
|
14698
16158
|
exports.getAthenaDebugAst = getAthenaDebugAst;
|
|
16159
|
+
exports.handleAthenaTableSchemaPost = handleAthenaTableSchemaPost;
|
|
16160
|
+
exports.hasAthenaTableSchemaCredentials = hasAthenaTableSchemaCredentials;
|
|
14699
16161
|
exports.identifier = identifier;
|
|
14700
16162
|
exports.isAthenaGatewayError = isAthenaGatewayError;
|
|
16163
|
+
exports.isAthenaTableSchemaConfig = isAthenaTableSchemaConfig;
|
|
14701
16164
|
exports.isOk = isOk;
|
|
14702
16165
|
exports.json = json;
|
|
14703
16166
|
exports.loadGeneratorConfig = loadGeneratorConfig;
|
|
16167
|
+
exports.mergeSchemaSelections = mergeSchemaSelections;
|
|
14704
16168
|
exports.normalizeAthenaError = normalizeAthenaError;
|
|
14705
16169
|
exports.normalizeAthenaGatewayBaseUrl = normalizeAthenaGatewayBaseUrl;
|
|
16170
|
+
exports.normalizeAthenaReadQueryOrderBy = normalizeAthenaReadQueryOrderBy;
|
|
16171
|
+
exports.normalizeAthenaTableOrderBy = normalizeAthenaTableOrderBy;
|
|
16172
|
+
exports.normalizeDiscoveredSchemas = normalizeDiscoveredSchemas;
|
|
14706
16173
|
exports.normalizeGeneratorConfig = normalizeGeneratorConfig;
|
|
14707
16174
|
exports.normalizeSchemaSelection = normalizeSchemaSelection;
|
|
14708
16175
|
exports.normalizeTableSelection = normalizeTableSelection;
|
|
14709
16176
|
exports.number = number;
|
|
16177
|
+
exports.parseAthenaTableSchemaScope = parseAthenaTableSchemaScope;
|
|
14710
16178
|
exports.parseBooleanFlag = parseBooleanFlag2;
|
|
16179
|
+
exports.patchSchemasInConfigSource = patchSchemasInConfigSource;
|
|
14711
16180
|
exports.renderAthenaReactEmail = renderAthenaReactEmail;
|
|
16181
|
+
exports.renderGeneratorConfigFile = renderGeneratorConfigFile;
|
|
14712
16182
|
exports.requireAffected = requireAffected;
|
|
14713
16183
|
exports.requireSuccess = requireSuccess;
|
|
16184
|
+
exports.resolveAthenaReadQueryPageFetch = resolveAthenaReadQueryPageFetch;
|
|
14714
16185
|
exports.resolveGeneratorProvider = resolveGeneratorProvider;
|
|
14715
16186
|
exports.resolvePostgresColumnType = resolvePostgresColumnType;
|
|
14716
16187
|
exports.resolveProviderSchemas = resolveProviderSchemas;
|
|
14717
16188
|
exports.resolveStoragePath = resolveStoragePath;
|
|
14718
16189
|
exports.runSchemaGenerator = runSchemaGenerator;
|
|
16190
|
+
exports.schemasEqual = schemasEqual;
|
|
14719
16191
|
exports.storageSdkManifest = storageSdkManifest;
|
|
14720
16192
|
exports.string = string;
|
|
14721
16193
|
exports.table = table;
|