@xylex-group/athena 2.8.0 → 2.9.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 +165 -68
- package/dist/browser.cjs +1331 -70
- 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 +1325 -71
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +1354 -117
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.d.cts +3 -3
- package/dist/cli/index.d.ts +3 -3
- package/dist/cli/index.js +1354 -117
- package/dist/cli/index.js.map +1 -1
- package/dist/{model-form-DMed05gE.d.cts → client-CfAE_QOj.d.cts} +741 -132
- package/dist/{model-form-DXPlOnlI.d.ts → client-D6EIJdQS.d.ts} +741 -132
- package/dist/index.cjs +1391 -71
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +1385 -72
- package/dist/index.js.map +1 -1
- package/dist/model-form-ByvyyvxB.d.ts +96 -0
- package/dist/model-form-DACdBLYG.d.cts +96 -0
- package/dist/next/client.cjs +7875 -0
- package/dist/next/client.cjs.map +1 -0
- package/dist/next/client.d.cts +25 -0
- package/dist/next/client.d.ts +25 -0
- package/dist/next/client.js +7873 -0
- package/dist/next/client.js.map +1 -0
- package/dist/next/server.cjs +7993 -0
- package/dist/next/server.cjs.map +1 -0
- package/dist/next/server.d.cts +52 -0
- package/dist/next/server.d.ts +52 -0
- package/dist/next/server.js +7990 -0
- package/dist/next/server.js.map +1 -0
- package/dist/{pipeline-D4sJRKqN.d.cts → pipeline-CmUZsXsi.d.cts} +1 -1
- package/dist/{pipeline-CkMnhwPI.d.ts → pipeline-DZMsPxUg.d.ts} +1 -1
- package/dist/{react-email-DZhDDlEl.d.cts → react-email-BvJ3fj_F.d.cts} +35 -7
- package/dist/{react-email-Lrz9A-BW.d.ts → react-email-PLAJuZuO.d.ts} +35 -7
- package/dist/react.cjs +30 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +39 -10
- package/dist/react.d.ts +39 -10
- package/dist/react.js +30 -2
- package/dist/react.js.map +1 -1
- package/dist/shared-BW6hoLBY.d.cts +33 -0
- package/dist/shared-BiJvoURI.d.ts +33 -0
- package/dist/{types-vikz9YIO.d.cts → types-BeZIHduP.d.cts} +5 -1
- package/dist/{types-vikz9YIO.d.ts → types-BeZIHduP.d.ts} +5 -1
- package/dist/{types-CAtTGGoz.d.cts → types-C-YvfgYh.d.cts} +27 -2
- package/dist/{types-BzY6fETM.d.ts → types-CRjDwmtJ.d.ts} +27 -2
- package/package.json +37 -49
package/dist/index.cjs
CHANGED
|
@@ -806,7 +806,7 @@ var getCookieCache = async (request, config) => {
|
|
|
806
806
|
|
|
807
807
|
// package.json
|
|
808
808
|
var package_default = {
|
|
809
|
-
version: "2.
|
|
809
|
+
version: "2.9.0"
|
|
810
810
|
};
|
|
811
811
|
|
|
812
812
|
// src/sdk-version.ts
|
|
@@ -819,6 +819,7 @@ function buildSdkHeaderValue(sdkName) {
|
|
|
819
819
|
var DEFAULT_CLIENT = "railway_direct";
|
|
820
820
|
var SDK_NAME = "xylex-group/athena";
|
|
821
821
|
var SDK_HEADER_VALUE = buildSdkHeaderValue(SDK_NAME);
|
|
822
|
+
var NO_CACHE_HEADER_VALUE = "no-cache";
|
|
822
823
|
function parseResponseBody(rawText, contentType) {
|
|
823
824
|
if (!rawText) {
|
|
824
825
|
return { parsed: null, parseFailed: false };
|
|
@@ -837,6 +838,9 @@ function parseResponseBody(rawText, contentType) {
|
|
|
837
838
|
function normalizeHeaderValue(value) {
|
|
838
839
|
return value ? value : void 0;
|
|
839
840
|
}
|
|
841
|
+
function isCacheControlHeaderName(name) {
|
|
842
|
+
return name.toLowerCase() === "cache-control";
|
|
843
|
+
}
|
|
840
844
|
function resolveHeaderValue(headers, candidates) {
|
|
841
845
|
for (const candidate of candidates) {
|
|
842
846
|
const direct = normalizeHeaderValue(headers[candidate]);
|
|
@@ -995,6 +999,7 @@ function buildRpcGetEndpoint(payload) {
|
|
|
995
999
|
}
|
|
996
1000
|
function buildHeaders(config, options) {
|
|
997
1001
|
const mergedStripNulls = options?.stripNulls ?? true;
|
|
1002
|
+
const forceNoCache = Boolean(config.forceNoCache || options?.forceNoCache);
|
|
998
1003
|
const extraHeaders = {
|
|
999
1004
|
...config.headers ?? {},
|
|
1000
1005
|
...options?.headers ?? {}
|
|
@@ -1048,11 +1053,15 @@ function buildHeaders(config, options) {
|
|
|
1048
1053
|
const athenaClientKeys = ["x-athena-client", "X-Athena-Client"];
|
|
1049
1054
|
Object.entries(extraHeaders).forEach(([key, value]) => {
|
|
1050
1055
|
if (athenaClientKeys.includes(key)) return;
|
|
1056
|
+
if (forceNoCache && isCacheControlHeaderName(key)) return;
|
|
1051
1057
|
const normalized = normalizeHeaderValue(value);
|
|
1052
1058
|
if (normalized) {
|
|
1053
1059
|
headers[key] = normalized;
|
|
1054
1060
|
}
|
|
1055
1061
|
});
|
|
1062
|
+
if (forceNoCache) {
|
|
1063
|
+
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE;
|
|
1064
|
+
}
|
|
1056
1065
|
return headers;
|
|
1057
1066
|
}
|
|
1058
1067
|
function toInvalidUrlResponse(error, endpoint, method) {
|
|
@@ -1513,6 +1522,45 @@ function identifier(...segments) {
|
|
|
1513
1522
|
return new SqlIdentifierPath(expandedSegments);
|
|
1514
1523
|
}
|
|
1515
1524
|
|
|
1525
|
+
// src/auth/limits.ts
|
|
1526
|
+
var ATHENA_AUTH_MAX_ADMIN_JSON_BYTES = 32 * 1024;
|
|
1527
|
+
var ATHENA_AUTH_MAX_ADMIN_JSON_DEPTH = 8;
|
|
1528
|
+
var ATHENA_AUTH_MAX_TEMPLATE_VARIABLES = 64;
|
|
1529
|
+
var ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH = 128;
|
|
1530
|
+
var ATHENA_AUTH_ADMIN_LIMITS = {
|
|
1531
|
+
maxAdminJsonBytes: ATHENA_AUTH_MAX_ADMIN_JSON_BYTES,
|
|
1532
|
+
maxAdminJsonDepth: ATHENA_AUTH_MAX_ADMIN_JSON_DEPTH,
|
|
1533
|
+
maxTemplateVariables: ATHENA_AUTH_MAX_TEMPLATE_VARIABLES,
|
|
1534
|
+
maxTemplateVariableLength: ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH
|
|
1535
|
+
};
|
|
1536
|
+
function describeTemplateVariableTarget(target) {
|
|
1537
|
+
const normalized = target?.trim();
|
|
1538
|
+
return normalized && normalized.length > 0 ? normalized : "Athena auth admin email template variables";
|
|
1539
|
+
}
|
|
1540
|
+
function assertAthenaAuthTemplateVariables(variables, target) {
|
|
1541
|
+
const label = describeTemplateVariableTarget(target);
|
|
1542
|
+
if (!Array.isArray(variables)) {
|
|
1543
|
+
throw new Error(`${label} must be an array of strings.`);
|
|
1544
|
+
}
|
|
1545
|
+
if (variables.length > ATHENA_AUTH_MAX_TEMPLATE_VARIABLES) {
|
|
1546
|
+
throw new Error(
|
|
1547
|
+
`${label} cannot contain more than ${ATHENA_AUTH_MAX_TEMPLATE_VARIABLES} entries.`
|
|
1548
|
+
);
|
|
1549
|
+
}
|
|
1550
|
+
variables.forEach((variable, index) => {
|
|
1551
|
+
if (typeof variable !== "string") {
|
|
1552
|
+
throw new Error(
|
|
1553
|
+
`${label} must contain only strings. Received ${typeof variable} at index ${index}.`
|
|
1554
|
+
);
|
|
1555
|
+
}
|
|
1556
|
+
if (variable.length > ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH) {
|
|
1557
|
+
throw new Error(
|
|
1558
|
+
`${label} cannot contain entries longer than ${ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH} characters. Received ${variable.length} characters at index ${index}.`
|
|
1559
|
+
);
|
|
1560
|
+
}
|
|
1561
|
+
});
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1516
1564
|
// src/auth/react-email.ts
|
|
1517
1565
|
var reactEmailRenderModulePromise;
|
|
1518
1566
|
function isRecord2(value) {
|
|
@@ -1742,6 +1790,7 @@ async function resolveReactEmailPayloadFields(input, fields, options) {
|
|
|
1742
1790
|
var DEFAULT_AUTH_BASE_URL = "http://localhost:3001/api/auth";
|
|
1743
1791
|
var SDK_NAME2 = "xylex-group/athena-auth";
|
|
1744
1792
|
var SDK_HEADER_VALUE2 = buildSdkHeaderValue(SDK_NAME2);
|
|
1793
|
+
var NO_CACHE_HEADER_VALUE2 = "no-cache";
|
|
1745
1794
|
function normalizeBaseUrl(baseUrl) {
|
|
1746
1795
|
return (baseUrl ?? DEFAULT_AUTH_BASE_URL).replace(/\/$/, "");
|
|
1747
1796
|
}
|
|
@@ -1751,6 +1800,9 @@ function isRecord3(value) {
|
|
|
1751
1800
|
function normalizeHeaderValue2(value) {
|
|
1752
1801
|
return value ? value : void 0;
|
|
1753
1802
|
}
|
|
1803
|
+
function isCacheControlHeaderName2(name) {
|
|
1804
|
+
return name.toLowerCase() === "cache-control";
|
|
1805
|
+
}
|
|
1754
1806
|
function parseResponseBody2(rawText, contentType) {
|
|
1755
1807
|
if (!rawText) {
|
|
1756
1808
|
return { parsed: null, parseFailed: false };
|
|
@@ -1806,6 +1858,54 @@ function mergeCallOptions(base, override) {
|
|
|
1806
1858
|
}
|
|
1807
1859
|
};
|
|
1808
1860
|
}
|
|
1861
|
+
function toSessionGuardFailure(sessionResult) {
|
|
1862
|
+
if (sessionResult.status === 401 || sessionResult.data == null) {
|
|
1863
|
+
return {
|
|
1864
|
+
ok: false,
|
|
1865
|
+
reason: "unauthorized",
|
|
1866
|
+
status: 401,
|
|
1867
|
+
error: sessionResult.error ?? "Unauthorized",
|
|
1868
|
+
sessionResult
|
|
1869
|
+
};
|
|
1870
|
+
}
|
|
1871
|
+
return {
|
|
1872
|
+
ok: false,
|
|
1873
|
+
reason: "upstream_error",
|
|
1874
|
+
status: sessionResult.status,
|
|
1875
|
+
error: sessionResult.error ?? "Failed to resolve current session",
|
|
1876
|
+
sessionResult
|
|
1877
|
+
};
|
|
1878
|
+
}
|
|
1879
|
+
function toPermissionGuardFailure(permissionResult, sessionResult) {
|
|
1880
|
+
if (permissionResult.status === 401) {
|
|
1881
|
+
return {
|
|
1882
|
+
ok: false,
|
|
1883
|
+
reason: "unauthorized",
|
|
1884
|
+
status: 401,
|
|
1885
|
+
error: permissionResult.error ?? "Unauthorized",
|
|
1886
|
+
sessionResult,
|
|
1887
|
+
permissionResult
|
|
1888
|
+
};
|
|
1889
|
+
}
|
|
1890
|
+
if (permissionResult.status === 403) {
|
|
1891
|
+
return {
|
|
1892
|
+
ok: false,
|
|
1893
|
+
reason: "forbidden",
|
|
1894
|
+
status: 403,
|
|
1895
|
+
error: permissionResult.error ?? "Forbidden",
|
|
1896
|
+
sessionResult,
|
|
1897
|
+
permissionResult
|
|
1898
|
+
};
|
|
1899
|
+
}
|
|
1900
|
+
return {
|
|
1901
|
+
ok: false,
|
|
1902
|
+
reason: "upstream_error",
|
|
1903
|
+
status: permissionResult.status,
|
|
1904
|
+
error: permissionResult.error ?? "Failed to resolve permission check",
|
|
1905
|
+
sessionResult,
|
|
1906
|
+
permissionResult
|
|
1907
|
+
};
|
|
1908
|
+
}
|
|
1809
1909
|
function extractFetchOptions(input) {
|
|
1810
1910
|
if (!input) {
|
|
1811
1911
|
return {
|
|
@@ -1821,6 +1921,7 @@ function extractFetchOptions(input) {
|
|
|
1821
1921
|
};
|
|
1822
1922
|
}
|
|
1823
1923
|
function buildHeaders2(config, options) {
|
|
1924
|
+
const forceNoCache = Boolean(config.forceNoCache || options?.forceNoCache);
|
|
1824
1925
|
const headers = {
|
|
1825
1926
|
"Content-Type": "application/json",
|
|
1826
1927
|
"X-Athena-Sdk": SDK_HEADER_VALUE2
|
|
@@ -1834,16 +1935,30 @@ function buildHeaders2(config, options) {
|
|
|
1834
1935
|
if (bearerToken) {
|
|
1835
1936
|
headers.Authorization = `Bearer ${bearerToken}`;
|
|
1836
1937
|
}
|
|
1938
|
+
const cookie = options?.cookie ?? config.cookie;
|
|
1939
|
+
if (cookie) {
|
|
1940
|
+
headers.Cookie = cookie;
|
|
1941
|
+
}
|
|
1942
|
+
const sessionToken = options?.sessionToken ?? config.sessionToken;
|
|
1943
|
+
if (sessionToken) {
|
|
1944
|
+
headers["X-Athena-Auth-Session-Token"] = sessionToken;
|
|
1945
|
+
}
|
|
1837
1946
|
const mergedExtraHeaders = {
|
|
1838
1947
|
...config.headers ?? {},
|
|
1839
1948
|
...options?.headers ?? {}
|
|
1840
1949
|
};
|
|
1841
1950
|
Object.entries(mergedExtraHeaders).forEach(([key, value]) => {
|
|
1951
|
+
if (forceNoCache && isCacheControlHeaderName2(key)) {
|
|
1952
|
+
return;
|
|
1953
|
+
}
|
|
1842
1954
|
const normalized = normalizeHeaderValue2(value);
|
|
1843
1955
|
if (normalized) {
|
|
1844
1956
|
headers[key] = normalized;
|
|
1845
1957
|
}
|
|
1846
1958
|
});
|
|
1959
|
+
if (forceNoCache) {
|
|
1960
|
+
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE2;
|
|
1961
|
+
}
|
|
1847
1962
|
return headers;
|
|
1848
1963
|
}
|
|
1849
1964
|
function appendQueryParam(searchParams, key, value) {
|
|
@@ -2108,7 +2223,91 @@ function createAuthClient(config = {}) {
|
|
|
2108
2223
|
htmlField: "htmlTemplate",
|
|
2109
2224
|
textField: "textTemplate",
|
|
2110
2225
|
variablesField: "variables"
|
|
2111
|
-
}, withReactEmailRoute(route))
|
|
2226
|
+
}, withReactEmailRoute(route)).then((payload) => {
|
|
2227
|
+
if ("variables" in payload && payload.variables !== void 0 && payload.variables !== null) {
|
|
2228
|
+
assertAthenaAuthTemplateVariables(
|
|
2229
|
+
payload.variables,
|
|
2230
|
+
`${route} variables`
|
|
2231
|
+
);
|
|
2232
|
+
}
|
|
2233
|
+
return payload;
|
|
2234
|
+
});
|
|
2235
|
+
const requireSession = async (input, options) => {
|
|
2236
|
+
const sessionInput = input?.fetchOptions ? { fetchOptions: input.fetchOptions } : void 0;
|
|
2237
|
+
const sessionResult = await getGeneric(
|
|
2238
|
+
"/get-session",
|
|
2239
|
+
sessionInput,
|
|
2240
|
+
options
|
|
2241
|
+
);
|
|
2242
|
+
if (!sessionResult.ok || sessionResult.data == null) {
|
|
2243
|
+
return toSessionGuardFailure(sessionResult);
|
|
2244
|
+
}
|
|
2245
|
+
return {
|
|
2246
|
+
ok: true,
|
|
2247
|
+
session: sessionResult.data
|
|
2248
|
+
};
|
|
2249
|
+
};
|
|
2250
|
+
const getUser = async (input, options) => {
|
|
2251
|
+
const sessionResult = await getGeneric(
|
|
2252
|
+
"/get-session",
|
|
2253
|
+
input,
|
|
2254
|
+
options
|
|
2255
|
+
);
|
|
2256
|
+
if (!sessionResult.ok) {
|
|
2257
|
+
return {
|
|
2258
|
+
...sessionResult,
|
|
2259
|
+
data: null
|
|
2260
|
+
};
|
|
2261
|
+
}
|
|
2262
|
+
return {
|
|
2263
|
+
...sessionResult,
|
|
2264
|
+
data: {
|
|
2265
|
+
user: sessionResult.data?.user ?? null
|
|
2266
|
+
}
|
|
2267
|
+
};
|
|
2268
|
+
};
|
|
2269
|
+
const requirePermission = async (endpoint, input, options) => {
|
|
2270
|
+
const sessionGuard = await requireSession(
|
|
2271
|
+
input?.fetchOptions ? { fetchOptions: input.fetchOptions } : void 0,
|
|
2272
|
+
options
|
|
2273
|
+
);
|
|
2274
|
+
if (!sessionGuard.ok) {
|
|
2275
|
+
return sessionGuard;
|
|
2276
|
+
}
|
|
2277
|
+
const permissionResult = await postGeneric(
|
|
2278
|
+
endpoint,
|
|
2279
|
+
input,
|
|
2280
|
+
options
|
|
2281
|
+
);
|
|
2282
|
+
if (!permissionResult.ok) {
|
|
2283
|
+
return toPermissionGuardFailure(permissionResult, {
|
|
2284
|
+
ok: true,
|
|
2285
|
+
status: 200,
|
|
2286
|
+
data: sessionGuard.session,
|
|
2287
|
+
error: null,
|
|
2288
|
+
errorDetails: null,
|
|
2289
|
+
raw: sessionGuard.session
|
|
2290
|
+
});
|
|
2291
|
+
}
|
|
2292
|
+
if (!permissionResult.data?.success) {
|
|
2293
|
+
return {
|
|
2294
|
+
ok: false,
|
|
2295
|
+
reason: "forbidden",
|
|
2296
|
+
status: 403,
|
|
2297
|
+
error: permissionResult.data?.error ?? "Forbidden",
|
|
2298
|
+
sessionResult: {
|
|
2299
|
+
ok: true,
|
|
2300
|
+
status: 200,
|
|
2301
|
+
data: sessionGuard.session,
|
|
2302
|
+
error: null,
|
|
2303
|
+
errorDetails: null,
|
|
2304
|
+
raw: sessionGuard.session
|
|
2305
|
+
},
|
|
2306
|
+
permissionResult
|
|
2307
|
+
};
|
|
2308
|
+
}
|
|
2309
|
+
return sessionGuard;
|
|
2310
|
+
};
|
|
2112
2311
|
const listUserEmailsWithFallback = async (input, options) => {
|
|
2113
2312
|
const primary = await getWithQuery(
|
|
2114
2313
|
"/email/list",
|
|
@@ -2270,6 +2469,7 @@ function createAuthClient(config = {}) {
|
|
|
2270
2469
|
input,
|
|
2271
2470
|
options
|
|
2272
2471
|
),
|
|
2472
|
+
requirePermission: (input, options) => requirePermission("/organization/has-permission", input, options),
|
|
2273
2473
|
invitation: {
|
|
2274
2474
|
cancel: (input, options) => executePostWithCompatibleInput(
|
|
2275
2475
|
resolvedConfig,
|
|
@@ -2465,6 +2665,8 @@ function createAuthClient(config = {}) {
|
|
|
2465
2665
|
};
|
|
2466
2666
|
const auth = {
|
|
2467
2667
|
getSession: (input, options) => getGeneric("/get-session", input, options),
|
|
2668
|
+
getUser,
|
|
2669
|
+
requireSession,
|
|
2468
2670
|
signOut,
|
|
2469
2671
|
forgetPassword: (input, options) => postGeneric("/forget-password", input, options),
|
|
2470
2672
|
resetPassword: authResetPassword,
|
|
@@ -2559,6 +2761,7 @@ function createAuthClient(config = {}) {
|
|
|
2559
2761
|
}
|
|
2560
2762
|
},
|
|
2561
2763
|
hasPermission: (input, options) => postGeneric("/admin/has-permission", input, options),
|
|
2764
|
+
requirePermission: (input, options) => requirePermission("/admin/has-permission", input, options),
|
|
2562
2765
|
apiKey: {
|
|
2563
2766
|
create: (input, options) => postGeneric("/admin/api-key/create", input, options)
|
|
2564
2767
|
},
|
|
@@ -2710,6 +2913,8 @@ function createAuthClient(config = {}) {
|
|
|
2710
2913
|
input,
|
|
2711
2914
|
options
|
|
2712
2915
|
),
|
|
2916
|
+
getUser,
|
|
2917
|
+
requireSession,
|
|
2713
2918
|
listSessions: (input, options) => executeGetWithCompatibleInput(
|
|
2714
2919
|
resolvedConfig,
|
|
2715
2920
|
{ endpoint: "/list-sessions", method: "GET" },
|
|
@@ -3402,7 +3607,12 @@ function createStorageFileModule(base, config = {}) {
|
|
|
3402
3607
|
content_type: input.content_type ?? source.contentType,
|
|
3403
3608
|
size_bytes: source.sizeBytes,
|
|
3404
3609
|
public: input.public,
|
|
3405
|
-
metadata: input.metadata
|
|
3610
|
+
metadata: input.metadata,
|
|
3611
|
+
server_side_encryption: input.server_side_encryption,
|
|
3612
|
+
sse: input.sse,
|
|
3613
|
+
ssekms_key_id: input.ssekms_key_id,
|
|
3614
|
+
kms_key_id: input.kms_key_id,
|
|
3615
|
+
bucket_key_enabled: input.bucket_key_enabled
|
|
3406
3616
|
}
|
|
3407
3617
|
};
|
|
3408
3618
|
});
|
|
@@ -3413,10 +3623,17 @@ function createStorageFileModule(base, config = {}) {
|
|
|
3413
3623
|
for (let index = 0; index < uploadRequests.length; index += 1) {
|
|
3414
3624
|
const request = uploadRequests[index];
|
|
3415
3625
|
const uploadUrl = uploadUrls[index];
|
|
3416
|
-
const response = await putUploadBody(
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3626
|
+
const response = await putUploadBody(
|
|
3627
|
+
uploadUrl.upload.url,
|
|
3628
|
+
uploadUrl.upload.headers ?? {},
|
|
3629
|
+
request.source,
|
|
3630
|
+
input,
|
|
3631
|
+
options,
|
|
3632
|
+
(progress) => {
|
|
3633
|
+
aggregateLoaded[index] = progress.loaded;
|
|
3634
|
+
input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
|
|
3635
|
+
}
|
|
3636
|
+
);
|
|
3420
3637
|
uploaded.push({
|
|
3421
3638
|
file: uploadUrl.file,
|
|
3422
3639
|
upload: uploadUrl.upload,
|
|
@@ -3519,8 +3736,9 @@ function validateUploadConstraints(sources, input) {
|
|
|
3519
3736
|
}
|
|
3520
3737
|
}
|
|
3521
3738
|
}
|
|
3522
|
-
async function putUploadBody(url, source, input, options, onProgress) {
|
|
3523
|
-
const headers = new Headers(
|
|
3739
|
+
async function putUploadBody(url, uploadHeaders, source, input, options, onProgress) {
|
|
3740
|
+
const headers = new Headers(uploadHeaders);
|
|
3741
|
+
new Headers(input.uploadHeaders).forEach((value, key) => headers.set(key, value));
|
|
3524
3742
|
if (source.contentType && !headers.has("Content-Type")) {
|
|
3525
3743
|
headers.set("Content-Type", source.contentType);
|
|
3526
3744
|
}
|
|
@@ -3837,29 +4055,524 @@ var storageSdkManifest = {
|
|
|
3837
4055
|
responseType: "StorageFileMutationResponse"
|
|
3838
4056
|
},
|
|
3839
4057
|
{
|
|
3840
|
-
name: "setStorageFileVisibility",
|
|
3841
|
-
method: "PATCH",
|
|
3842
|
-
path: "/storage/files/{file_id}/visibility",
|
|
3843
|
-
pathParams: ["file_id"],
|
|
3844
|
-
requestType: "SetStorageFileVisibilityRequest",
|
|
4058
|
+
name: "setStorageFileVisibility",
|
|
4059
|
+
method: "PATCH",
|
|
4060
|
+
path: "/storage/files/{file_id}/visibility",
|
|
4061
|
+
pathParams: ["file_id"],
|
|
4062
|
+
requestType: "SetStorageFileVisibilityRequest",
|
|
4063
|
+
responseEnvelope: "athena",
|
|
4064
|
+
responseType: "StorageFileMutationResponse"
|
|
4065
|
+
},
|
|
4066
|
+
{
|
|
4067
|
+
name: "postStorageFileVisibility",
|
|
4068
|
+
method: "POST",
|
|
4069
|
+
path: "/storage/files/{file_id}/visibility",
|
|
4070
|
+
pathParams: ["file_id"],
|
|
4071
|
+
requestType: "SetStorageFileVisibilityRequest",
|
|
4072
|
+
responseEnvelope: "athena",
|
|
4073
|
+
responseType: "StorageFileMutationResponse"
|
|
4074
|
+
},
|
|
4075
|
+
{
|
|
4076
|
+
name: "setManyStorageFileVisibility",
|
|
4077
|
+
method: "POST",
|
|
4078
|
+
path: "/storage/files/visibility-many",
|
|
4079
|
+
requestType: "SetManyStorageFileVisibilityRequest",
|
|
4080
|
+
responseEnvelope: "athena",
|
|
4081
|
+
responseType: "StorageFileMutationManyResponse"
|
|
4082
|
+
},
|
|
4083
|
+
{
|
|
4084
|
+
name: "deleteStorageFolder",
|
|
4085
|
+
method: "POST",
|
|
4086
|
+
path: "/storage/folders/delete",
|
|
4087
|
+
requestType: "DeleteStorageFolderRequest",
|
|
4088
|
+
responseEnvelope: "athena",
|
|
4089
|
+
responseType: "StorageFolderMutationResponse"
|
|
4090
|
+
},
|
|
4091
|
+
{
|
|
4092
|
+
name: "moveStorageFolder",
|
|
4093
|
+
method: "POST",
|
|
4094
|
+
path: "/storage/folders/move",
|
|
4095
|
+
requestType: "MoveStorageFolderRequest",
|
|
4096
|
+
responseEnvelope: "athena",
|
|
4097
|
+
responseType: "StorageFolderMutationResponse"
|
|
4098
|
+
},
|
|
4099
|
+
{
|
|
4100
|
+
name: "searchStorageFiles",
|
|
4101
|
+
method: "POST",
|
|
4102
|
+
path: "/storage/files/search",
|
|
4103
|
+
requestType: "SearchStorageFilesRequest",
|
|
4104
|
+
responseEnvelope: "athena",
|
|
4105
|
+
responseType: "StorageListFilesResponse"
|
|
4106
|
+
},
|
|
4107
|
+
{
|
|
4108
|
+
name: "confirmStorageUpload",
|
|
4109
|
+
method: "POST",
|
|
4110
|
+
path: "/storage/files/{file_id}/confirm-upload",
|
|
4111
|
+
pathParams: ["file_id"],
|
|
4112
|
+
requestType: "ConfirmStorageUploadRequest",
|
|
4113
|
+
responseEnvelope: "athena",
|
|
4114
|
+
responseType: "StorageFileMutationResponse"
|
|
4115
|
+
},
|
|
4116
|
+
{
|
|
4117
|
+
name: "uploadStorageFileBinary",
|
|
4118
|
+
method: "PUT",
|
|
4119
|
+
path: "/storage/files/{file_id}/upload",
|
|
4120
|
+
pathParams: ["file_id"],
|
|
4121
|
+
responseEnvelope: "athena",
|
|
4122
|
+
responseType: "StorageFileMutationResponse",
|
|
4123
|
+
binary: true
|
|
4124
|
+
},
|
|
4125
|
+
{
|
|
4126
|
+
name: "copyStorageFile",
|
|
4127
|
+
method: "POST",
|
|
4128
|
+
path: "/storage/files/{file_id}/copy",
|
|
4129
|
+
pathParams: ["file_id"],
|
|
4130
|
+
requestType: "CopyStorageFileRequest",
|
|
4131
|
+
responseEnvelope: "athena",
|
|
4132
|
+
responseType: "StorageFileMutationResponse"
|
|
4133
|
+
},
|
|
4134
|
+
{
|
|
4135
|
+
name: "deleteManyStorageFiles",
|
|
4136
|
+
method: "POST",
|
|
4137
|
+
path: "/storage/files/delete-many",
|
|
4138
|
+
requestType: "DeleteManyStorageFilesRequest",
|
|
4139
|
+
responseEnvelope: "athena",
|
|
4140
|
+
responseType: "StorageFileMutationManyResponse"
|
|
4141
|
+
},
|
|
4142
|
+
{
|
|
4143
|
+
name: "updateManyStorageFiles",
|
|
4144
|
+
method: "POST",
|
|
4145
|
+
path: "/storage/files/update-many",
|
|
4146
|
+
requestType: "UpdateManyStorageFilesRequest",
|
|
4147
|
+
responseEnvelope: "athena",
|
|
4148
|
+
responseType: "StorageFileMutationManyResponse"
|
|
4149
|
+
},
|
|
4150
|
+
{
|
|
4151
|
+
name: "restoreStorageFile",
|
|
4152
|
+
method: "POST",
|
|
4153
|
+
path: "/storage/files/{file_id}/restore",
|
|
4154
|
+
pathParams: ["file_id"],
|
|
4155
|
+
responseEnvelope: "athena",
|
|
4156
|
+
responseType: "StorageFileMutationResponse"
|
|
4157
|
+
},
|
|
4158
|
+
{
|
|
4159
|
+
name: "purgeStorageFile",
|
|
4160
|
+
method: "DELETE",
|
|
4161
|
+
path: "/storage/files/{file_id}/purge",
|
|
4162
|
+
pathParams: ["file_id"],
|
|
4163
|
+
responseEnvelope: "athena",
|
|
4164
|
+
responseType: "StorageFileMutationResponse"
|
|
4165
|
+
},
|
|
4166
|
+
{
|
|
4167
|
+
name: "getStorageFilePublicUrl",
|
|
4168
|
+
method: "GET",
|
|
4169
|
+
path: "/storage/files/{file_id}/public-url",
|
|
4170
|
+
pathParams: ["file_id"],
|
|
4171
|
+
responseEnvelope: "athena",
|
|
4172
|
+
responseType: "Record<string, unknown>"
|
|
4173
|
+
},
|
|
4174
|
+
{
|
|
4175
|
+
name: "getStorageFileProxyUrl",
|
|
4176
|
+
method: "GET",
|
|
4177
|
+
path: "/storage/files/{file_id}/proxy-url",
|
|
4178
|
+
pathParams: ["file_id"],
|
|
4179
|
+
queryParams: ["purpose"],
|
|
4180
|
+
responseEnvelope: "athena",
|
|
4181
|
+
responseType: "Record<string, unknown>"
|
|
4182
|
+
},
|
|
4183
|
+
{
|
|
4184
|
+
name: "listStorageFileVersions",
|
|
4185
|
+
method: "GET",
|
|
4186
|
+
path: "/storage/files/{file_id}/versions",
|
|
4187
|
+
pathParams: ["file_id"],
|
|
4188
|
+
responseEnvelope: "athena",
|
|
4189
|
+
responseType: "Record<string, unknown>"
|
|
4190
|
+
},
|
|
4191
|
+
{
|
|
4192
|
+
name: "restoreStorageFileVersion",
|
|
4193
|
+
method: "POST",
|
|
4194
|
+
path: "/storage/files/{file_id}/versions/{version_id}/restore",
|
|
4195
|
+
pathParams: ["file_id", "version_id"],
|
|
4196
|
+
responseEnvelope: "athena",
|
|
4197
|
+
responseType: "Record<string, unknown>"
|
|
4198
|
+
},
|
|
4199
|
+
{
|
|
4200
|
+
name: "deleteStorageFileVersion",
|
|
4201
|
+
method: "DELETE",
|
|
4202
|
+
path: "/storage/files/{file_id}/versions/{version_id}",
|
|
4203
|
+
pathParams: ["file_id", "version_id"],
|
|
4204
|
+
responseEnvelope: "athena",
|
|
4205
|
+
responseType: "Record<string, unknown>"
|
|
4206
|
+
},
|
|
4207
|
+
{
|
|
4208
|
+
name: "getStorageFileRetention",
|
|
4209
|
+
method: "GET",
|
|
4210
|
+
path: "/storage/files/{file_id}/retention",
|
|
4211
|
+
pathParams: ["file_id"],
|
|
4212
|
+
queryParams: ["version_id"],
|
|
4213
|
+
responseEnvelope: "athena",
|
|
4214
|
+
responseType: "Record<string, unknown>"
|
|
4215
|
+
},
|
|
4216
|
+
{
|
|
4217
|
+
name: "setStorageFileRetention",
|
|
4218
|
+
method: "POST",
|
|
4219
|
+
path: "/storage/files/{file_id}/retention",
|
|
4220
|
+
pathParams: ["file_id"],
|
|
4221
|
+
requestType: "StorageFileRetentionRequest",
|
|
4222
|
+
responseEnvelope: "athena",
|
|
4223
|
+
responseType: "Record<string, unknown>"
|
|
4224
|
+
},
|
|
4225
|
+
{
|
|
4226
|
+
name: "listStorageFolders",
|
|
4227
|
+
method: "POST",
|
|
4228
|
+
path: "/storage/folders/list",
|
|
4229
|
+
requestType: "ListStorageFoldersRequest",
|
|
4230
|
+
responseEnvelope: "athena",
|
|
4231
|
+
responseType: "Record<string, unknown>"
|
|
4232
|
+
},
|
|
4233
|
+
{
|
|
4234
|
+
name: "treeStorageFolders",
|
|
4235
|
+
method: "POST",
|
|
4236
|
+
path: "/storage/folders/tree",
|
|
4237
|
+
requestType: "TreeStorageFoldersRequest",
|
|
4238
|
+
responseEnvelope: "athena",
|
|
4239
|
+
responseType: "Record<string, unknown>"
|
|
4240
|
+
},
|
|
4241
|
+
{
|
|
4242
|
+
name: "listStoragePermissions",
|
|
4243
|
+
method: "POST",
|
|
4244
|
+
path: "/storage/permissions/list",
|
|
4245
|
+
requestType: "StoragePermissionListRequest",
|
|
4246
|
+
responseEnvelope: "athena",
|
|
4247
|
+
responseType: "StoragePermissionListResponse"
|
|
4248
|
+
},
|
|
4249
|
+
{
|
|
4250
|
+
name: "grantStoragePermission",
|
|
4251
|
+
method: "POST",
|
|
4252
|
+
path: "/storage/permissions/grant",
|
|
4253
|
+
requestType: "StoragePermissionGrantRequest",
|
|
4254
|
+
responseEnvelope: "athena",
|
|
4255
|
+
responseType: "Record<string, unknown>"
|
|
4256
|
+
},
|
|
4257
|
+
{
|
|
4258
|
+
name: "revokeStoragePermission",
|
|
4259
|
+
method: "POST",
|
|
4260
|
+
path: "/storage/permissions/revoke",
|
|
4261
|
+
requestType: "StoragePermissionRevokeRequest",
|
|
4262
|
+
responseEnvelope: "athena",
|
|
4263
|
+
responseType: "Record<string, unknown>"
|
|
4264
|
+
},
|
|
4265
|
+
{
|
|
4266
|
+
name: "checkStoragePermission",
|
|
4267
|
+
method: "POST",
|
|
4268
|
+
path: "/storage/permissions/check",
|
|
4269
|
+
requestType: "StoragePermissionCheckRequest",
|
|
4270
|
+
responseEnvelope: "athena",
|
|
4271
|
+
responseType: "StoragePermissionCheckResponse"
|
|
4272
|
+
},
|
|
4273
|
+
{
|
|
4274
|
+
name: "listStorageObjects",
|
|
4275
|
+
method: "POST",
|
|
4276
|
+
path: "/storage/objects",
|
|
4277
|
+
requestType: "StorageListObjectsRequest",
|
|
4278
|
+
responseEnvelope: "athena",
|
|
4279
|
+
responseType: "Record<string, unknown>"
|
|
4280
|
+
},
|
|
4281
|
+
{
|
|
4282
|
+
name: "headStorageObject",
|
|
4283
|
+
method: "POST",
|
|
4284
|
+
path: "/storage/objects/head",
|
|
4285
|
+
requestType: "StorageObjectRequest",
|
|
4286
|
+
responseEnvelope: "athena",
|
|
4287
|
+
responseType: "Record<string, unknown>"
|
|
4288
|
+
},
|
|
4289
|
+
{
|
|
4290
|
+
name: "existsStorageObject",
|
|
4291
|
+
method: "POST",
|
|
4292
|
+
path: "/storage/objects/exists",
|
|
4293
|
+
requestType: "StorageObjectRequest",
|
|
4294
|
+
responseEnvelope: "athena",
|
|
4295
|
+
responseType: "Record<string, unknown>"
|
|
4296
|
+
},
|
|
4297
|
+
{
|
|
4298
|
+
name: "validateStorageObject",
|
|
4299
|
+
method: "POST",
|
|
4300
|
+
path: "/storage/objects/validate",
|
|
4301
|
+
requestType: "StorageObjectValidateRequest",
|
|
4302
|
+
responseEnvelope: "athena",
|
|
4303
|
+
responseType: "Record<string, unknown>"
|
|
4304
|
+
},
|
|
4305
|
+
{
|
|
4306
|
+
name: "updateStorageObject",
|
|
4307
|
+
method: "POST",
|
|
4308
|
+
path: "/storage/objects/update",
|
|
4309
|
+
requestType: "StorageUpdateObjectRequest",
|
|
4310
|
+
responseEnvelope: "athena",
|
|
4311
|
+
responseType: "Record<string, unknown>"
|
|
4312
|
+
},
|
|
4313
|
+
{
|
|
4314
|
+
name: "copyStorageObject",
|
|
4315
|
+
method: "POST",
|
|
4316
|
+
path: "/storage/objects/copy",
|
|
4317
|
+
requestType: "StorageObjectCopyRequest",
|
|
4318
|
+
responseEnvelope: "athena",
|
|
4319
|
+
responseType: "Record<string, unknown>"
|
|
4320
|
+
},
|
|
4321
|
+
{
|
|
4322
|
+
name: "getStorageObjectUrl",
|
|
4323
|
+
method: "POST",
|
|
4324
|
+
path: "/storage/objects/url",
|
|
4325
|
+
requestType: "StorageObjectRequest",
|
|
4326
|
+
responseEnvelope: "athena",
|
|
4327
|
+
responseType: "Record<string, unknown>"
|
|
4328
|
+
},
|
|
4329
|
+
{
|
|
4330
|
+
name: "getStorageObjectPublicUrl",
|
|
4331
|
+
method: "POST",
|
|
4332
|
+
path: "/storage/objects/public-url",
|
|
4333
|
+
requestType: "StorageObjectPublicUrlRequest",
|
|
4334
|
+
responseEnvelope: "athena",
|
|
4335
|
+
responseType: "Record<string, unknown>"
|
|
4336
|
+
},
|
|
4337
|
+
{
|
|
4338
|
+
name: "deleteStorageObject",
|
|
4339
|
+
method: "POST",
|
|
4340
|
+
path: "/storage/objects/delete",
|
|
4341
|
+
requestType: "StorageObjectRequest",
|
|
4342
|
+
responseEnvelope: "athena",
|
|
4343
|
+
responseType: "Record<string, unknown>"
|
|
4344
|
+
},
|
|
4345
|
+
{
|
|
4346
|
+
name: "createStorageObjectUploadUrl",
|
|
4347
|
+
method: "POST",
|
|
4348
|
+
path: "/storage/objects/upload-url",
|
|
4349
|
+
requestType: "StoragePresignUploadRequest",
|
|
4350
|
+
responseEnvelope: "athena",
|
|
4351
|
+
responseType: "Record<string, unknown>"
|
|
4352
|
+
},
|
|
4353
|
+
{
|
|
4354
|
+
name: "createStorageObjectPostPolicy",
|
|
4355
|
+
method: "POST",
|
|
4356
|
+
path: "/storage/objects/post-policy",
|
|
4357
|
+
requestType: "StorageSignedPostPolicyRequest",
|
|
4358
|
+
responseEnvelope: "athena",
|
|
4359
|
+
responseType: "Record<string, unknown>"
|
|
4360
|
+
},
|
|
4361
|
+
{
|
|
4362
|
+
name: "listStorageObjectVersions",
|
|
4363
|
+
method: "POST",
|
|
4364
|
+
path: "/storage/objects/versions",
|
|
4365
|
+
requestType: "StorageObjectVersionListRequest",
|
|
4366
|
+
responseEnvelope: "athena",
|
|
4367
|
+
responseType: "Record<string, unknown>"
|
|
4368
|
+
},
|
|
4369
|
+
{
|
|
4370
|
+
name: "restoreStorageObjectVersion",
|
|
4371
|
+
method: "POST",
|
|
4372
|
+
path: "/storage/objects/versions/restore",
|
|
4373
|
+
requestType: "StorageObjectVersionMutationRequest",
|
|
4374
|
+
responseEnvelope: "athena",
|
|
4375
|
+
responseType: "Record<string, unknown>"
|
|
4376
|
+
},
|
|
4377
|
+
{
|
|
4378
|
+
name: "deleteStorageObjectVersion",
|
|
4379
|
+
method: "POST",
|
|
4380
|
+
path: "/storage/objects/versions/delete",
|
|
4381
|
+
requestType: "StorageObjectVersionMutationRequest",
|
|
4382
|
+
responseEnvelope: "athena",
|
|
4383
|
+
responseType: "Record<string, unknown>"
|
|
4384
|
+
},
|
|
4385
|
+
{
|
|
4386
|
+
name: "createStorageObjectFolder",
|
|
4387
|
+
method: "POST",
|
|
4388
|
+
path: "/storage/objects/folder",
|
|
4389
|
+
requestType: "StorageObjectFolderCreateRequest",
|
|
4390
|
+
responseEnvelope: "athena",
|
|
4391
|
+
responseType: "Record<string, unknown>"
|
|
4392
|
+
},
|
|
4393
|
+
{
|
|
4394
|
+
name: "deleteStorageObjectFolder",
|
|
4395
|
+
method: "POST",
|
|
4396
|
+
path: "/storage/objects/folder/delete",
|
|
4397
|
+
requestType: "StorageObjectFolderDeleteRequest",
|
|
4398
|
+
responseEnvelope: "athena",
|
|
4399
|
+
responseType: "Record<string, unknown>"
|
|
4400
|
+
},
|
|
4401
|
+
{
|
|
4402
|
+
name: "renameStorageObjectFolder",
|
|
4403
|
+
method: "POST",
|
|
4404
|
+
path: "/storage/objects/folder/rename",
|
|
4405
|
+
requestType: "StorageObjectFolderRenameRequest",
|
|
4406
|
+
responseEnvelope: "athena",
|
|
4407
|
+
responseType: "Record<string, unknown>"
|
|
4408
|
+
},
|
|
4409
|
+
{
|
|
4410
|
+
name: "listStorageBuckets",
|
|
4411
|
+
method: "POST",
|
|
4412
|
+
path: "/storage/buckets/list",
|
|
4413
|
+
requestType: "Omit<StorageObjectBaseRequest, 'bucket'>",
|
|
4414
|
+
responseEnvelope: "athena",
|
|
4415
|
+
responseType: "Record<string, unknown>"
|
|
4416
|
+
},
|
|
4417
|
+
{
|
|
4418
|
+
name: "createStorageBucket",
|
|
4419
|
+
method: "POST",
|
|
4420
|
+
path: "/storage/buckets/create",
|
|
4421
|
+
requestType: "StorageObjectBaseRequest",
|
|
4422
|
+
responseEnvelope: "athena",
|
|
4423
|
+
responseType: "Record<string, unknown>"
|
|
4424
|
+
},
|
|
4425
|
+
{
|
|
4426
|
+
name: "deleteStorageBucket",
|
|
4427
|
+
method: "POST",
|
|
4428
|
+
path: "/storage/buckets/delete",
|
|
4429
|
+
requestType: "StorageObjectBaseRequest",
|
|
4430
|
+
responseEnvelope: "athena",
|
|
4431
|
+
responseType: "Record<string, unknown>"
|
|
4432
|
+
},
|
|
4433
|
+
{
|
|
4434
|
+
name: "getStorageBucketLifecycle",
|
|
4435
|
+
method: "POST",
|
|
4436
|
+
path: "/storage/buckets/lifecycle",
|
|
4437
|
+
requestType: "StorageBucketLifecycleRequest",
|
|
4438
|
+
responseEnvelope: "athena",
|
|
4439
|
+
responseType: "Record<string, unknown>"
|
|
4440
|
+
},
|
|
4441
|
+
{
|
|
4442
|
+
name: "setStorageBucketLifecycle",
|
|
4443
|
+
method: "POST",
|
|
4444
|
+
path: "/storage/buckets/lifecycle/set",
|
|
4445
|
+
requestType: "StorageSetBucketLifecycleRequest",
|
|
4446
|
+
responseEnvelope: "athena",
|
|
4447
|
+
responseType: "Record<string, unknown>"
|
|
4448
|
+
},
|
|
4449
|
+
{
|
|
4450
|
+
name: "deleteStorageBucketLifecycle",
|
|
4451
|
+
method: "POST",
|
|
4452
|
+
path: "/storage/buckets/lifecycle/delete",
|
|
4453
|
+
requestType: "StorageBucketLifecycleRequest",
|
|
4454
|
+
responseEnvelope: "athena",
|
|
4455
|
+
responseType: "Record<string, unknown>"
|
|
4456
|
+
},
|
|
4457
|
+
{
|
|
4458
|
+
name: "getStorageBucketPolicy",
|
|
4459
|
+
method: "POST",
|
|
4460
|
+
path: "/storage/buckets/policy",
|
|
4461
|
+
requestType: "StorageBucketPolicyRequest",
|
|
4462
|
+
responseEnvelope: "athena",
|
|
4463
|
+
responseType: "Record<string, unknown>"
|
|
4464
|
+
},
|
|
4465
|
+
{
|
|
4466
|
+
name: "setStorageBucketPolicy",
|
|
4467
|
+
method: "POST",
|
|
4468
|
+
path: "/storage/buckets/policy/set",
|
|
4469
|
+
requestType: "StorageSetBucketPolicyRequest",
|
|
4470
|
+
responseEnvelope: "athena",
|
|
4471
|
+
responseType: "Record<string, unknown>"
|
|
4472
|
+
},
|
|
4473
|
+
{
|
|
4474
|
+
name: "deleteStorageBucketPolicy",
|
|
4475
|
+
method: "POST",
|
|
4476
|
+
path: "/storage/buckets/policy/delete",
|
|
4477
|
+
requestType: "StorageBucketPolicyRequest",
|
|
4478
|
+
responseEnvelope: "athena",
|
|
4479
|
+
responseType: "Record<string, unknown>"
|
|
4480
|
+
},
|
|
4481
|
+
{
|
|
4482
|
+
name: "getStorageBucketPublicAccess",
|
|
4483
|
+
method: "POST",
|
|
4484
|
+
path: "/storage/buckets/public-access",
|
|
4485
|
+
requestType: "StoragePublicAccessBlockRequest",
|
|
4486
|
+
responseEnvelope: "athena",
|
|
4487
|
+
responseType: "Record<string, unknown>"
|
|
4488
|
+
},
|
|
4489
|
+
{
|
|
4490
|
+
name: "setStorageBucketPublicAccess",
|
|
4491
|
+
method: "POST",
|
|
4492
|
+
path: "/storage/buckets/public-access/set",
|
|
4493
|
+
requestType: "StorageSetPublicAccessBlockRequest",
|
|
4494
|
+
responseEnvelope: "athena",
|
|
4495
|
+
responseType: "Record<string, unknown>"
|
|
4496
|
+
},
|
|
4497
|
+
{
|
|
4498
|
+
name: "deleteStorageBucketPublicAccess",
|
|
4499
|
+
method: "POST",
|
|
4500
|
+
path: "/storage/buckets/public-access/delete",
|
|
4501
|
+
requestType: "StoragePublicAccessBlockRequest",
|
|
4502
|
+
responseEnvelope: "athena",
|
|
4503
|
+
responseType: "Record<string, unknown>"
|
|
4504
|
+
},
|
|
4505
|
+
{
|
|
4506
|
+
name: "getStorageBucketCors",
|
|
4507
|
+
method: "POST",
|
|
4508
|
+
path: "/storage/buckets/cors",
|
|
4509
|
+
requestType: "StorageBucketCorsRequest",
|
|
4510
|
+
responseEnvelope: "athena",
|
|
4511
|
+
responseType: "Record<string, unknown>"
|
|
4512
|
+
},
|
|
4513
|
+
{
|
|
4514
|
+
name: "setStorageBucketCors",
|
|
4515
|
+
method: "POST",
|
|
4516
|
+
path: "/storage/buckets/cors/set",
|
|
4517
|
+
requestType: "StorageSetBucketCorsRequest",
|
|
4518
|
+
responseEnvelope: "athena",
|
|
4519
|
+
responseType: "Record<string, unknown>"
|
|
4520
|
+
},
|
|
4521
|
+
{
|
|
4522
|
+
name: "deleteStorageBucketCors",
|
|
4523
|
+
method: "POST",
|
|
4524
|
+
path: "/storage/buckets/cors/delete",
|
|
4525
|
+
requestType: "StorageBucketCorsRequest",
|
|
4526
|
+
responseEnvelope: "athena",
|
|
4527
|
+
responseType: "Record<string, unknown>"
|
|
4528
|
+
},
|
|
4529
|
+
{
|
|
4530
|
+
name: "createStorageMultipartUpload",
|
|
4531
|
+
method: "POST",
|
|
4532
|
+
path: "/storage/multipart/create",
|
|
4533
|
+
requestType: "StorageMultipartCreateRequest",
|
|
4534
|
+
responseEnvelope: "athena",
|
|
4535
|
+
responseType: "Record<string, unknown>"
|
|
4536
|
+
},
|
|
4537
|
+
{
|
|
4538
|
+
name: "signStorageMultipartPart",
|
|
4539
|
+
method: "POST",
|
|
4540
|
+
path: "/storage/multipart/sign-part",
|
|
4541
|
+
requestType: "StorageMultipartSignPartRequest",
|
|
4542
|
+
responseEnvelope: "athena",
|
|
4543
|
+
responseType: "Record<string, unknown>"
|
|
4544
|
+
},
|
|
4545
|
+
{
|
|
4546
|
+
name: "completeStorageMultipartUpload",
|
|
4547
|
+
method: "POST",
|
|
4548
|
+
path: "/storage/multipart/complete",
|
|
4549
|
+
requestType: "StorageMultipartCompleteRequest",
|
|
4550
|
+
responseEnvelope: "athena",
|
|
4551
|
+
responseType: "StorageFileMutationResponse"
|
|
4552
|
+
},
|
|
4553
|
+
{
|
|
4554
|
+
name: "abortStorageMultipartUpload",
|
|
4555
|
+
method: "POST",
|
|
4556
|
+
path: "/storage/multipart/abort",
|
|
4557
|
+
requestType: "StorageMultipartAbortRequest",
|
|
3845
4558
|
responseEnvelope: "athena",
|
|
3846
|
-
responseType: "
|
|
4559
|
+
responseType: "Record<string, unknown>"
|
|
3847
4560
|
},
|
|
3848
4561
|
{
|
|
3849
|
-
name: "
|
|
4562
|
+
name: "listStorageMultipartParts",
|
|
3850
4563
|
method: "POST",
|
|
3851
|
-
path: "/storage/
|
|
3852
|
-
requestType: "
|
|
4564
|
+
path: "/storage/multipart/list-parts",
|
|
4565
|
+
requestType: "StorageMultipartListPartsRequest",
|
|
3853
4566
|
responseEnvelope: "athena",
|
|
3854
|
-
responseType: "
|
|
4567
|
+
responseType: "Record<string, unknown>"
|
|
3855
4568
|
},
|
|
3856
4569
|
{
|
|
3857
|
-
name: "
|
|
4570
|
+
name: "listStorageAuditEvents",
|
|
3858
4571
|
method: "POST",
|
|
3859
|
-
path: "/storage/
|
|
3860
|
-
requestType: "
|
|
4572
|
+
path: "/storage/audit/list",
|
|
4573
|
+
requestType: "StorageAuditQueryRequest",
|
|
3861
4574
|
responseEnvelope: "athena",
|
|
3862
|
-
responseType: "
|
|
4575
|
+
responseType: "StorageAuditListResponse"
|
|
3863
4576
|
}
|
|
3864
4577
|
]
|
|
3865
4578
|
};
|
|
@@ -4320,7 +5033,7 @@ async function putPresignedUploadBody(uploadUrl, uploadHeaders, body, options) {
|
|
|
4320
5033
|
return fetch(uploadUrl, init);
|
|
4321
5034
|
}
|
|
4322
5035
|
function attachManagedUpload(upload) {
|
|
4323
|
-
const headers = {};
|
|
5036
|
+
const headers = { ...upload.headers ?? {} };
|
|
4324
5037
|
return {
|
|
4325
5038
|
...upload,
|
|
4326
5039
|
method: "PUT",
|
|
@@ -4366,7 +5079,12 @@ function normalizeUploadUrlRequest(input) {
|
|
|
4366
5079
|
file_id: input.file_id ?? input.fileId,
|
|
4367
5080
|
public: input.public,
|
|
4368
5081
|
visibility: input.visibility,
|
|
4369
|
-
metadata: input.metadata
|
|
5082
|
+
metadata: input.metadata,
|
|
5083
|
+
server_side_encryption: input.server_side_encryption,
|
|
5084
|
+
sse: input.sse,
|
|
5085
|
+
ssekms_key_id: input.ssekms_key_id,
|
|
5086
|
+
kms_key_id: input.kms_key_id,
|
|
5087
|
+
bucket_key_enabled: input.bucket_key_enabled
|
|
4370
5088
|
};
|
|
4371
5089
|
}
|
|
4372
5090
|
async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options, runtimeOptions) {
|
|
@@ -4517,6 +5235,12 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
4517
5235
|
options,
|
|
4518
5236
|
resolvedRuntimeOptions
|
|
4519
5237
|
);
|
|
5238
|
+
const callStorageFileVisibility = (fileId, method, input, options) => callAthena2(
|
|
5239
|
+
withPathParam("/storage/files/{file_id}/visibility", "file_id", fileId),
|
|
5240
|
+
method,
|
|
5241
|
+
input,
|
|
5242
|
+
options
|
|
5243
|
+
);
|
|
4520
5244
|
const base = {
|
|
4521
5245
|
listStorageCatalogs(options) {
|
|
4522
5246
|
return callRaw("/storage/catalogs", "GET", void 0, options);
|
|
@@ -4566,7 +5290,7 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
4566
5290
|
return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "DELETE", void 0, options);
|
|
4567
5291
|
},
|
|
4568
5292
|
setStorageFileVisibility(fileId, input, options) {
|
|
4569
|
-
return
|
|
5293
|
+
return callStorageFileVisibility(fileId, "PATCH", input, options);
|
|
4570
5294
|
},
|
|
4571
5295
|
deleteStorageFolder(input, options) {
|
|
4572
5296
|
return callAthena2("/storage/folders/delete", "POST", input, options);
|
|
@@ -4638,13 +5362,62 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
4638
5362
|
publicUrl(fileId, options) {
|
|
4639
5363
|
return callAthena2(withPathParam("/storage/files/{file_id}/public-url", "file_id", fileId), "GET", void 0, options);
|
|
4640
5364
|
},
|
|
5365
|
+
proxyUrl(fileId, query, options) {
|
|
5366
|
+
const path = appendQuery(
|
|
5367
|
+
withPathParam("/storage/files/{file_id}/proxy-url", "file_id", fileId),
|
|
5368
|
+
query
|
|
5369
|
+
);
|
|
5370
|
+
return callAthena2(path, "GET", void 0, options);
|
|
5371
|
+
},
|
|
4641
5372
|
proxy(fileId, query, options) {
|
|
4642
5373
|
return base.getStorageFileProxy(fileId, query, options);
|
|
4643
5374
|
},
|
|
4644
|
-
|
|
5375
|
+
versions(fileId, options) {
|
|
5376
|
+
return callAthena2(withPathParam("/storage/files/{file_id}/versions", "file_id", fileId), "GET", void 0, options);
|
|
5377
|
+
},
|
|
5378
|
+
restoreVersion(fileId, versionId, options) {
|
|
5379
|
+
return callAthena2(
|
|
5380
|
+
withPathParam(
|
|
5381
|
+
withPathParam("/storage/files/{file_id}/versions/{version_id}/restore", "file_id", fileId),
|
|
5382
|
+
"version_id",
|
|
5383
|
+
versionId
|
|
5384
|
+
),
|
|
5385
|
+
"POST",
|
|
5386
|
+
{},
|
|
5387
|
+
options
|
|
5388
|
+
);
|
|
5389
|
+
},
|
|
5390
|
+
deleteVersion(fileId, versionId, options) {
|
|
5391
|
+
return callAthena2(
|
|
5392
|
+
withPathParam(
|
|
5393
|
+
withPathParam("/storage/files/{file_id}/versions/{version_id}", "file_id", fileId),
|
|
5394
|
+
"version_id",
|
|
5395
|
+
versionId
|
|
5396
|
+
),
|
|
5397
|
+
"DELETE",
|
|
5398
|
+
void 0,
|
|
5399
|
+
options
|
|
5400
|
+
);
|
|
5401
|
+
},
|
|
5402
|
+
retention: {
|
|
5403
|
+
get(fileId, query, options) {
|
|
5404
|
+
const path = appendQuery(
|
|
5405
|
+
withPathParam("/storage/files/{file_id}/retention", "file_id", fileId),
|
|
5406
|
+
query
|
|
5407
|
+
);
|
|
5408
|
+
return callAthena2(path, "GET", void 0, options);
|
|
5409
|
+
},
|
|
4645
5410
|
set(fileId, input, options) {
|
|
5411
|
+
return callAthena2(withPathParam("/storage/files/{file_id}/retention", "file_id", fileId), "POST", input, options);
|
|
5412
|
+
}
|
|
5413
|
+
},
|
|
5414
|
+
visibility: {
|
|
5415
|
+
update(fileId, input, options) {
|
|
4646
5416
|
return base.setStorageFileVisibility(fileId, input, options);
|
|
4647
5417
|
},
|
|
5418
|
+
set(fileId, input, options) {
|
|
5419
|
+
return callStorageFileVisibility(fileId, "POST", input, options);
|
|
5420
|
+
},
|
|
4648
5421
|
setMany(input, options) {
|
|
4649
5422
|
return callAthena2("/storage/files/visibility-many", "POST", input, options);
|
|
4650
5423
|
}
|
|
@@ -4739,6 +5512,18 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
4739
5512
|
uploadUrl(input, options) {
|
|
4740
5513
|
return callAthena2("/storage/objects/upload-url", "POST", input, options);
|
|
4741
5514
|
},
|
|
5515
|
+
versions(input, options) {
|
|
5516
|
+
return callAthena2("/storage/objects/versions", "POST", input, options);
|
|
5517
|
+
},
|
|
5518
|
+
restoreVersion(input, options) {
|
|
5519
|
+
return callAthena2("/storage/objects/versions/restore", "POST", input, options);
|
|
5520
|
+
},
|
|
5521
|
+
deleteVersion(input, options) {
|
|
5522
|
+
return callAthena2("/storage/objects/versions/delete", "POST", input, options);
|
|
5523
|
+
},
|
|
5524
|
+
postPolicy(input, options) {
|
|
5525
|
+
return callAthena2("/storage/objects/post-policy", "POST", input, options);
|
|
5526
|
+
},
|
|
4742
5527
|
folder: objectFolder
|
|
4743
5528
|
};
|
|
4744
5529
|
const bucket = {
|
|
@@ -4751,6 +5536,39 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
4751
5536
|
delete(input, options) {
|
|
4752
5537
|
return callAthena2("/storage/buckets/delete", "POST", input, options);
|
|
4753
5538
|
},
|
|
5539
|
+
lifecycle: {
|
|
5540
|
+
get(input, options) {
|
|
5541
|
+
return callAthena2("/storage/buckets/lifecycle", "POST", input, options);
|
|
5542
|
+
},
|
|
5543
|
+
set(input, options) {
|
|
5544
|
+
return callAthena2("/storage/buckets/lifecycle/set", "POST", input, options);
|
|
5545
|
+
},
|
|
5546
|
+
delete(input, options) {
|
|
5547
|
+
return callAthena2("/storage/buckets/lifecycle/delete", "POST", input, options);
|
|
5548
|
+
}
|
|
5549
|
+
},
|
|
5550
|
+
policy: {
|
|
5551
|
+
get(input, options) {
|
|
5552
|
+
return callAthena2("/storage/buckets/policy", "POST", input, options);
|
|
5553
|
+
},
|
|
5554
|
+
set(input, options) {
|
|
5555
|
+
return callAthena2("/storage/buckets/policy/set", "POST", input, options);
|
|
5556
|
+
},
|
|
5557
|
+
delete(input, options) {
|
|
5558
|
+
return callAthena2("/storage/buckets/policy/delete", "POST", input, options);
|
|
5559
|
+
}
|
|
5560
|
+
},
|
|
5561
|
+
publicAccess: {
|
|
5562
|
+
get(input, options) {
|
|
5563
|
+
return callAthena2("/storage/buckets/public-access", "POST", input, options);
|
|
5564
|
+
},
|
|
5565
|
+
set(input, options) {
|
|
5566
|
+
return callAthena2("/storage/buckets/public-access/set", "POST", input, options);
|
|
5567
|
+
},
|
|
5568
|
+
delete(input, options) {
|
|
5569
|
+
return callAthena2("/storage/buckets/public-access/delete", "POST", input, options);
|
|
5570
|
+
}
|
|
5571
|
+
},
|
|
4754
5572
|
cors: {
|
|
4755
5573
|
get(input, options) {
|
|
4756
5574
|
return callAthena2("/storage/buckets/cors", "POST", input, options);
|
|
@@ -4852,6 +5670,9 @@ var AthenaClientBuilderImpl = class {
|
|
|
4852
5670
|
apiKey;
|
|
4853
5671
|
backendConfig = DEFAULT_BACKEND;
|
|
4854
5672
|
clientName;
|
|
5673
|
+
defaultUserId;
|
|
5674
|
+
defaultOrganizationId;
|
|
5675
|
+
forceNoCacheEnabled = false;
|
|
4855
5676
|
defaultHeaders;
|
|
4856
5677
|
authConfig;
|
|
4857
5678
|
dbUrlOverride;
|
|
@@ -4900,6 +5721,15 @@ var AthenaClientBuilderImpl = class {
|
|
|
4900
5721
|
if (options.client !== void 0) {
|
|
4901
5722
|
this.clientName = options.client;
|
|
4902
5723
|
}
|
|
5724
|
+
if (options.userId !== void 0) {
|
|
5725
|
+
this.defaultUserId = options.userId;
|
|
5726
|
+
}
|
|
5727
|
+
if (options.organizationId !== void 0) {
|
|
5728
|
+
this.defaultOrganizationId = options.organizationId;
|
|
5729
|
+
}
|
|
5730
|
+
if (options.forceNoCache !== void 0) {
|
|
5731
|
+
this.forceNoCacheEnabled = options.forceNoCache;
|
|
5732
|
+
}
|
|
4903
5733
|
if (options.backend !== void 0) {
|
|
4904
5734
|
this.backendConfig = toBackendConfig(options.backend);
|
|
4905
5735
|
}
|
|
@@ -4954,6 +5784,9 @@ var AthenaClientBuilderImpl = class {
|
|
|
4954
5784
|
url: this.rootUrl,
|
|
4955
5785
|
key: this.apiKey,
|
|
4956
5786
|
client: this.clientName,
|
|
5787
|
+
userId: this.defaultUserId,
|
|
5788
|
+
organizationId: this.defaultOrganizationId,
|
|
5789
|
+
forceNoCache: this.forceNoCacheEnabled,
|
|
4957
5790
|
backend: this.backendConfig,
|
|
4958
5791
|
headers: this.defaultHeaders,
|
|
4959
5792
|
db: this.dbUrlOverride ? { url: this.dbUrlOverride } : void 0,
|
|
@@ -7496,6 +8329,83 @@ function createQueryBuilder(client, formatGatewayResult, experimental, tracer) {
|
|
|
7496
8329
|
);
|
|
7497
8330
|
};
|
|
7498
8331
|
}
|
|
8332
|
+
var ATHENA_ENV_URL_KEYS = ["ATHENA_URL", "NEXT_PUBLIC_ATHENA_URL"];
|
|
8333
|
+
var ATHENA_ENV_GATEWAY_URL_KEYS = [
|
|
8334
|
+
"ATHENA_DB_URL",
|
|
8335
|
+
"ATHENA_GATEWAY_URL",
|
|
8336
|
+
"NEXT_PUBLIC_ATHENA_DB_API_URL"
|
|
8337
|
+
];
|
|
8338
|
+
var ATHENA_ENV_AUTH_URL_KEYS = ["ATHENA_AUTH_URL", "NEXT_PUBLIC_ATHENA_AUTH_URL"];
|
|
8339
|
+
var ATHENA_ENV_STORAGE_URL_KEYS = ["ATHENA_STORAGE_URL", "NEXT_PUBLIC_ATHENA_STORAGE_URL"];
|
|
8340
|
+
var ATHENA_ENV_KEY_KEYS = [
|
|
8341
|
+
"ATHENA_API_KEY",
|
|
8342
|
+
"NEXT_PUBLIC_ATHENA_API_KEY",
|
|
8343
|
+
"ATHENA_GATEWAY_API_KEY",
|
|
8344
|
+
"X_API_KEY"
|
|
8345
|
+
];
|
|
8346
|
+
var ATHENA_ENV_CLIENT_KEYS = ["ATHENA_CLIENT", "NEXT_PUBLIC_ATHENA_CLIENT"];
|
|
8347
|
+
function normalizeOptionalString(value) {
|
|
8348
|
+
if (typeof value !== "string") {
|
|
8349
|
+
return void 0;
|
|
8350
|
+
}
|
|
8351
|
+
const normalizedValue = value.trim();
|
|
8352
|
+
return normalizedValue ? normalizedValue : void 0;
|
|
8353
|
+
}
|
|
8354
|
+
function readFirstEnvValue(env, keys) {
|
|
8355
|
+
for (const key of keys) {
|
|
8356
|
+
const value = normalizeOptionalString(env[key]);
|
|
8357
|
+
if (value) {
|
|
8358
|
+
return value;
|
|
8359
|
+
}
|
|
8360
|
+
}
|
|
8361
|
+
return void 0;
|
|
8362
|
+
}
|
|
8363
|
+
function readHeaderBagValue(headers, targetKey) {
|
|
8364
|
+
if (!headers) {
|
|
8365
|
+
return void 0;
|
|
8366
|
+
}
|
|
8367
|
+
if (typeof headers.get === "function") {
|
|
8368
|
+
return normalizeOptionalString(headers.get(targetKey));
|
|
8369
|
+
}
|
|
8370
|
+
const normalizedTargetKey = targetKey.toLowerCase();
|
|
8371
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
8372
|
+
if (key.toLowerCase() !== normalizedTargetKey) {
|
|
8373
|
+
continue;
|
|
8374
|
+
}
|
|
8375
|
+
if (typeof value === "string") {
|
|
8376
|
+
return normalizeOptionalString(value);
|
|
8377
|
+
}
|
|
8378
|
+
return void 0;
|
|
8379
|
+
}
|
|
8380
|
+
return void 0;
|
|
8381
|
+
}
|
|
8382
|
+
function resolveSessionContextOptions(session, options) {
|
|
8383
|
+
const sessionToken = normalizeOptionalString(session?.session?.token);
|
|
8384
|
+
const requestCookie = readHeaderBagValue(options?.requestHeaders, "cookie") ?? readHeaderBagValue(options?.headers, "cookie");
|
|
8385
|
+
const authInput = options?.auth;
|
|
8386
|
+
const resolvedUserId = options?.userId !== void 0 ? options.userId : session?.user?.id;
|
|
8387
|
+
const resolvedOrganizationId = options?.organizationId !== void 0 ? options.organizationId : session?.session?.activeOrganizationId;
|
|
8388
|
+
const resolvedBearerToken = authInput?.bearerToken !== void 0 ? authInput.bearerToken : sessionToken;
|
|
8389
|
+
const resolvedSessionToken = authInput?.sessionToken !== void 0 ? authInput.sessionToken : sessionToken;
|
|
8390
|
+
const resolvedCookie = authInput?.cookie !== void 0 ? authInput.cookie : requestCookie;
|
|
8391
|
+
const auth = authInput !== void 0 || resolvedBearerToken !== void 0 || resolvedSessionToken !== void 0 || resolvedCookie !== void 0 ? {
|
|
8392
|
+
...authInput ?? {},
|
|
8393
|
+
...resolvedBearerToken !== void 0 ? { bearerToken: resolvedBearerToken } : {},
|
|
8394
|
+
...resolvedSessionToken !== void 0 ? { sessionToken: resolvedSessionToken } : {},
|
|
8395
|
+
...resolvedCookie !== void 0 ? { cookie: resolvedCookie } : {},
|
|
8396
|
+
headers: authInput?.headers ? { ...authInput.headers } : void 0
|
|
8397
|
+
} : void 0;
|
|
8398
|
+
if (resolvedUserId === void 0 && resolvedOrganizationId === void 0 && options?.forceNoCache === void 0 && !options?.headers && !auth) {
|
|
8399
|
+
return void 0;
|
|
8400
|
+
}
|
|
8401
|
+
return {
|
|
8402
|
+
userId: resolvedUserId,
|
|
8403
|
+
organizationId: resolvedOrganizationId,
|
|
8404
|
+
forceNoCache: options?.forceNoCache,
|
|
8405
|
+
headers: options?.headers ? { ...options.headers } : void 0,
|
|
8406
|
+
auth
|
|
8407
|
+
};
|
|
8408
|
+
}
|
|
7499
8409
|
function resolveClientServiceBaseUrl(value, label) {
|
|
7500
8410
|
if (value === void 0 || value === null) {
|
|
7501
8411
|
return void 0;
|
|
@@ -7517,21 +8427,143 @@ function resolveServiceUrls(config) {
|
|
|
7517
8427
|
storageUrl: resolveServiceUrlOverride(config.storage?.url, "Athena storage base URL") ?? resolveServiceUrlOverride(config.storageUrl, "Athena storage base URL") ?? (baseUrl ? appendServicePath(baseUrl, "storage") : void 0)
|
|
7518
8428
|
};
|
|
7519
8429
|
}
|
|
8430
|
+
function resolveOptionalClientName(value) {
|
|
8431
|
+
if (value === void 0 || value === null) {
|
|
8432
|
+
return void 0;
|
|
8433
|
+
}
|
|
8434
|
+
const normalizedValue = value.trim();
|
|
8435
|
+
return normalizedValue ? normalizedValue : void 0;
|
|
8436
|
+
}
|
|
8437
|
+
function resolveRequiredClientApiKey(value) {
|
|
8438
|
+
if (value === void 0 || value === null) {
|
|
8439
|
+
throw new Error(
|
|
8440
|
+
"Athena API key is required. Pass createClient(url, key) with a real API key, or set key in the config object."
|
|
8441
|
+
);
|
|
8442
|
+
}
|
|
8443
|
+
const normalizedValue = value.trim();
|
|
8444
|
+
if (!normalizedValue) {
|
|
8445
|
+
throw new Error(
|
|
8446
|
+
"Athena API key is required. Pass createClient(url, key) with a real API key, or set key in the config object."
|
|
8447
|
+
);
|
|
8448
|
+
}
|
|
8449
|
+
return normalizedValue;
|
|
8450
|
+
}
|
|
8451
|
+
function hasHeaderIgnoreCase(headers, targetKey) {
|
|
8452
|
+
const normalizedTargetKey = targetKey.toLowerCase();
|
|
8453
|
+
return Object.keys(headers).some((key) => key.toLowerCase() === normalizedTargetKey);
|
|
8454
|
+
}
|
|
8455
|
+
function mergeClientHeaders(current, next) {
|
|
8456
|
+
if (!current && !next) {
|
|
8457
|
+
return void 0;
|
|
8458
|
+
}
|
|
8459
|
+
return {
|
|
8460
|
+
...current ?? {},
|
|
8461
|
+
...next ?? {}
|
|
8462
|
+
};
|
|
8463
|
+
}
|
|
8464
|
+
function mergeDefinedObject(current, next) {
|
|
8465
|
+
if (!current && !next) {
|
|
8466
|
+
return void 0;
|
|
8467
|
+
}
|
|
8468
|
+
const merged = {
|
|
8469
|
+
...current ?? {}
|
|
8470
|
+
};
|
|
8471
|
+
const mutableMerged = merged;
|
|
8472
|
+
for (const [key, value] of Object.entries(next ?? {})) {
|
|
8473
|
+
if (value !== void 0) {
|
|
8474
|
+
mutableMerged[key] = value;
|
|
8475
|
+
}
|
|
8476
|
+
}
|
|
8477
|
+
return merged;
|
|
8478
|
+
}
|
|
8479
|
+
function mergeAuthClientOptions(current, next) {
|
|
8480
|
+
const merged = mergeDefinedObject(current, next);
|
|
8481
|
+
if (!merged) {
|
|
8482
|
+
return void 0;
|
|
8483
|
+
}
|
|
8484
|
+
const mergedHeaders = mergeClientHeaders(current?.headers, next?.headers);
|
|
8485
|
+
if (mergedHeaders) {
|
|
8486
|
+
merged.headers = mergedHeaders;
|
|
8487
|
+
}
|
|
8488
|
+
return merged;
|
|
8489
|
+
}
|
|
8490
|
+
function mergeServiceUrlOverrides(current, next) {
|
|
8491
|
+
return mergeDefinedObject(current, next);
|
|
8492
|
+
}
|
|
8493
|
+
function toClientContextOverrides(context) {
|
|
8494
|
+
if (!context) {
|
|
8495
|
+
return void 0;
|
|
8496
|
+
}
|
|
8497
|
+
return {
|
|
8498
|
+
userId: context.userId,
|
|
8499
|
+
organizationId: context.organizationId,
|
|
8500
|
+
forceNoCache: context.forceNoCache,
|
|
8501
|
+
headers: context.headers,
|
|
8502
|
+
auth: context.auth ? {
|
|
8503
|
+
...context.auth,
|
|
8504
|
+
headers: context.auth.headers ? { ...context.auth.headers } : void 0
|
|
8505
|
+
} : void 0
|
|
8506
|
+
};
|
|
8507
|
+
}
|
|
8508
|
+
function mergeClientOverrideOptions(base, overrides) {
|
|
8509
|
+
if (!overrides) {
|
|
8510
|
+
return {
|
|
8511
|
+
...base,
|
|
8512
|
+
headers: base.headers ? { ...base.headers } : void 0,
|
|
8513
|
+
auth: base.auth ? {
|
|
8514
|
+
...base.auth,
|
|
8515
|
+
headers: base.auth.headers ? { ...base.auth.headers } : void 0
|
|
8516
|
+
} : void 0,
|
|
8517
|
+
db: base.db ? { ...base.db } : void 0,
|
|
8518
|
+
gateway: base.gateway ? { ...base.gateway } : void 0,
|
|
8519
|
+
storage: base.storage ? { ...base.storage } : void 0
|
|
8520
|
+
};
|
|
8521
|
+
}
|
|
8522
|
+
const merged = mergeDefinedObject(base, overrides) ?? { ...base };
|
|
8523
|
+
return {
|
|
8524
|
+
...merged,
|
|
8525
|
+
headers: mergeClientHeaders(base.headers, overrides.headers),
|
|
8526
|
+
auth: mergeAuthClientOptions(base.auth, overrides.auth),
|
|
8527
|
+
db: mergeServiceUrlOverrides(base.db, overrides.db),
|
|
8528
|
+
gateway: mergeServiceUrlOverrides(base.gateway, overrides.gateway),
|
|
8529
|
+
storage: mergeServiceUrlOverrides(base.storage, overrides.storage)
|
|
8530
|
+
};
|
|
8531
|
+
}
|
|
7520
8532
|
function normalizeAuthClientConfig(auth, defaultBaseUrl) {
|
|
7521
8533
|
if (!auth && defaultBaseUrl === void 0) {
|
|
7522
8534
|
return void 0;
|
|
7523
8535
|
}
|
|
7524
|
-
const {
|
|
8536
|
+
const {
|
|
8537
|
+
url,
|
|
8538
|
+
baseUrl,
|
|
8539
|
+
apiKey,
|
|
8540
|
+
bearerToken,
|
|
8541
|
+
cookie,
|
|
8542
|
+
sessionToken,
|
|
8543
|
+
...rest
|
|
8544
|
+
} = auth ?? {};
|
|
7525
8545
|
const normalized = {
|
|
7526
8546
|
...rest
|
|
7527
8547
|
};
|
|
7528
8548
|
const resolvedBaseUrl = resolveClientServiceBaseUrl(
|
|
7529
|
-
url ??
|
|
8549
|
+
url ?? baseUrl ?? defaultBaseUrl,
|
|
7530
8550
|
"Athena auth base URL"
|
|
7531
8551
|
);
|
|
7532
8552
|
if (resolvedBaseUrl !== void 0) {
|
|
7533
8553
|
normalized.baseUrl = resolvedBaseUrl;
|
|
7534
8554
|
}
|
|
8555
|
+
if (typeof apiKey === "string") {
|
|
8556
|
+
normalized.apiKey = apiKey;
|
|
8557
|
+
}
|
|
8558
|
+
if (typeof bearerToken === "string") {
|
|
8559
|
+
normalized.bearerToken = bearerToken;
|
|
8560
|
+
}
|
|
8561
|
+
if (typeof cookie === "string") {
|
|
8562
|
+
normalized.cookie = cookie;
|
|
8563
|
+
}
|
|
8564
|
+
if (typeof sessionToken === "string") {
|
|
8565
|
+
normalized.sessionToken = sessionToken;
|
|
8566
|
+
}
|
|
7535
8567
|
return normalized;
|
|
7536
8568
|
}
|
|
7537
8569
|
function resolveCreateClientConfig(config) {
|
|
@@ -7543,8 +8575,11 @@ function resolveCreateClientConfig(config) {
|
|
|
7543
8575
|
}
|
|
7544
8576
|
return {
|
|
7545
8577
|
baseUrl: resolvedUrls.dbUrl,
|
|
7546
|
-
apiKey: config.key,
|
|
7547
|
-
client: config.client,
|
|
8578
|
+
apiKey: resolveRequiredClientApiKey(config.key),
|
|
8579
|
+
client: resolveOptionalClientName(config.client),
|
|
8580
|
+
userId: config.userId,
|
|
8581
|
+
organizationId: config.organizationId,
|
|
8582
|
+
forceNoCache: config.forceNoCache,
|
|
7548
8583
|
backend: toBackendConfig(config.backend),
|
|
7549
8584
|
headers: config.headers,
|
|
7550
8585
|
auth: config.auth,
|
|
@@ -7553,23 +8588,39 @@ function resolveCreateClientConfig(config) {
|
|
|
7553
8588
|
experimental: config.experimental
|
|
7554
8589
|
};
|
|
7555
8590
|
}
|
|
7556
|
-
function
|
|
8591
|
+
function createClientFromInput(sourceConfig) {
|
|
8592
|
+
return createClientFromConfig(resolveCreateClientConfig(sourceConfig), sourceConfig);
|
|
8593
|
+
}
|
|
8594
|
+
function createClientFromConfig(config, sourceConfig) {
|
|
8595
|
+
const normalizedAuthConfig = normalizeAuthClientConfig(config.auth, config.authUrl);
|
|
7557
8596
|
const gatewayHeaders = {
|
|
7558
8597
|
...config.headers ?? {}
|
|
7559
8598
|
};
|
|
7560
|
-
if (
|
|
7561
|
-
gatewayHeaders["X-Athena-Auth-Bearer-Token"] =
|
|
8599
|
+
if (normalizedAuthConfig?.bearerToken && !hasHeaderIgnoreCase(gatewayHeaders, "X-Athena-Auth-Bearer-Token")) {
|
|
8600
|
+
gatewayHeaders["X-Athena-Auth-Bearer-Token"] = normalizedAuthConfig.bearerToken;
|
|
8601
|
+
}
|
|
8602
|
+
if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(gatewayHeaders, "Cookie")) {
|
|
8603
|
+
gatewayHeaders.Cookie = normalizedAuthConfig.cookie;
|
|
8604
|
+
}
|
|
8605
|
+
if (normalizedAuthConfig?.sessionToken && !hasHeaderIgnoreCase(gatewayHeaders, "X-Athena-Auth-Session-Token")) {
|
|
8606
|
+
gatewayHeaders["X-Athena-Auth-Session-Token"] = normalizedAuthConfig.sessionToken;
|
|
7562
8607
|
}
|
|
7563
8608
|
const gateway = createAthenaGatewayClient({
|
|
7564
8609
|
baseUrl: config.baseUrl,
|
|
7565
8610
|
apiKey: config.apiKey,
|
|
7566
8611
|
client: config.client,
|
|
8612
|
+
userId: config.userId,
|
|
8613
|
+
organizationId: config.organizationId,
|
|
8614
|
+
forceNoCache: config.forceNoCache,
|
|
7567
8615
|
backend: config.backend,
|
|
7568
8616
|
headers: gatewayHeaders
|
|
7569
8617
|
});
|
|
7570
8618
|
const formatGatewayResult = createResultFormatter(config.experimental);
|
|
7571
8619
|
const queryTracer = createQueryTracer(config.experimental);
|
|
7572
|
-
const auth = createAuthClient(
|
|
8620
|
+
const auth = createAuthClient({
|
|
8621
|
+
...normalizedAuthConfig ?? {},
|
|
8622
|
+
...config.forceNoCache ? { forceNoCache: true } : {}
|
|
8623
|
+
});
|
|
7573
8624
|
function from(tableOrModel, options) {
|
|
7574
8625
|
if (isAthenaModelTarget(tableOrModel)) {
|
|
7575
8626
|
if (options?.schema !== void 0) {
|
|
@@ -7617,17 +8668,45 @@ function createClientFromConfig(config) {
|
|
|
7617
8668
|
queryTracer
|
|
7618
8669
|
);
|
|
7619
8670
|
const db = createDbModule({ from, rpc, query });
|
|
8671
|
+
const withContext = (context) => createClientFromInput(
|
|
8672
|
+
mergeClientOverrideOptions(sourceConfig, toClientContextOverrides(context))
|
|
8673
|
+
);
|
|
8674
|
+
const withSession = (session, options) => createClientFromInput(
|
|
8675
|
+
mergeClientOverrideOptions(
|
|
8676
|
+
sourceConfig,
|
|
8677
|
+
toClientContextOverrides(resolveSessionContextOptions(session, options))
|
|
8678
|
+
)
|
|
8679
|
+
);
|
|
8680
|
+
const authWithOptions = (options) => createClientFromInput(mergeClientOverrideOptions(sourceConfig, options));
|
|
7620
8681
|
const sdkClient = {
|
|
7621
8682
|
from,
|
|
7622
8683
|
db,
|
|
7623
8684
|
rpc,
|
|
7624
8685
|
query,
|
|
7625
8686
|
verifyConnection: gateway.verifyConnection,
|
|
7626
|
-
auth: auth.auth
|
|
8687
|
+
auth: auth.auth,
|
|
8688
|
+
withContext,
|
|
8689
|
+
withSession,
|
|
8690
|
+
withOptions: authWithOptions
|
|
7627
8691
|
};
|
|
7628
8692
|
if (config.experimental?.athenaStorageBackend) {
|
|
8693
|
+
const storageWithContext = (context) => createClientFromInput(
|
|
8694
|
+
mergeClientOverrideOptions(sourceConfig, toClientContextOverrides(context))
|
|
8695
|
+
);
|
|
8696
|
+
const storageWithSession = (session, options) => createClientFromInput(
|
|
8697
|
+
mergeClientOverrideOptions(
|
|
8698
|
+
sourceConfig,
|
|
8699
|
+
toClientContextOverrides(resolveSessionContextOptions(session, options))
|
|
8700
|
+
)
|
|
8701
|
+
);
|
|
8702
|
+
const storageWithOptions = (options) => createClientFromInput(
|
|
8703
|
+
mergeClientOverrideOptions(sourceConfig, options)
|
|
8704
|
+
);
|
|
7629
8705
|
const storageClient = {
|
|
7630
8706
|
...sdkClient,
|
|
8707
|
+
withContext: storageWithContext,
|
|
8708
|
+
withSession: storageWithSession,
|
|
8709
|
+
withOptions: storageWithOptions,
|
|
7631
8710
|
storage: createStorageModule(gateway, {
|
|
7632
8711
|
...config.experimental.storage,
|
|
7633
8712
|
...config.storageUrl ? {
|
|
@@ -7643,38 +8722,42 @@ function createClientFromConfig(config) {
|
|
|
7643
8722
|
var AthenaClient = class {
|
|
7644
8723
|
/** Create a fluent builder for a strongly-typed Athena SDK client. */
|
|
7645
8724
|
static builder() {
|
|
7646
|
-
return createAthenaClientBuilder((config) =>
|
|
7647
|
-
}
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
const url =
|
|
7651
|
-
const gatewayUrl =
|
|
7652
|
-
const authUrl =
|
|
7653
|
-
const storageUrl =
|
|
7654
|
-
const key =
|
|
8725
|
+
return createAthenaClientBuilder((config) => createClientFromInput(config));
|
|
8726
|
+
}
|
|
8727
|
+
static fromEnvironment(options = {}) {
|
|
8728
|
+
const env = options.env ?? process.env;
|
|
8729
|
+
const url = options.url ?? readFirstEnvValue(env, ATHENA_ENV_URL_KEYS);
|
|
8730
|
+
const gatewayUrl = options.gatewayUrl ?? readFirstEnvValue(env, ATHENA_ENV_GATEWAY_URL_KEYS);
|
|
8731
|
+
const authUrl = options.authUrl ?? readFirstEnvValue(env, ATHENA_ENV_AUTH_URL_KEYS);
|
|
8732
|
+
const storageUrl = options.storageUrl ?? readFirstEnvValue(env, ATHENA_ENV_STORAGE_URL_KEYS);
|
|
8733
|
+
const key = options.key ?? readFirstEnvValue(env, ATHENA_ENV_KEY_KEYS);
|
|
8734
|
+
const client = options.client ?? readFirstEnvValue(env, ATHENA_ENV_CLIENT_KEYS);
|
|
7655
8735
|
if (!url && !gatewayUrl || !key) {
|
|
7656
8736
|
throw new Error(
|
|
7657
|
-
"
|
|
8737
|
+
"AthenaClient.fromEnvironment() requires an API key plus a public or gateway URL. Supported aliases include ATHENA_API_KEY, NEXT_PUBLIC_ATHENA_API_KEY, ATHENA_GATEWAY_API_KEY, X_API_KEY, ATHENA_URL, NEXT_PUBLIC_ATHENA_URL, ATHENA_GATEWAY_URL, and ATHENA_DB_URL."
|
|
7658
8738
|
);
|
|
7659
8739
|
}
|
|
8740
|
+
const { env: _env, ...clientOptions } = options;
|
|
7660
8741
|
return createClient({
|
|
8742
|
+
...clientOptions,
|
|
7661
8743
|
url,
|
|
7662
8744
|
gatewayUrl,
|
|
7663
8745
|
authUrl,
|
|
7664
8746
|
storageUrl,
|
|
7665
|
-
key
|
|
8747
|
+
key,
|
|
8748
|
+
client
|
|
7666
8749
|
});
|
|
7667
8750
|
}
|
|
7668
8751
|
};
|
|
7669
8752
|
function createClient(configOrUrl, apiKey, options) {
|
|
7670
|
-
if (typeof configOrUrl === "string") {
|
|
7671
|
-
return
|
|
8753
|
+
if (typeof configOrUrl === "string" || configOrUrl === null || configOrUrl === void 0) {
|
|
8754
|
+
return createClientFromInput({
|
|
7672
8755
|
url: configOrUrl,
|
|
7673
8756
|
key: apiKey ?? "",
|
|
7674
8757
|
...options
|
|
7675
|
-
})
|
|
8758
|
+
});
|
|
7676
8759
|
}
|
|
7677
|
-
return
|
|
8760
|
+
return createClientFromInput(configOrUrl);
|
|
7678
8761
|
}
|
|
7679
8762
|
|
|
7680
8763
|
// src/gateway/types.ts
|
|
@@ -8040,6 +9123,9 @@ function createColumnsBuilder(name, mappedName, schemaName, columns) {
|
|
|
8040
9123
|
resolveTableTarget(name, mappedName, normalizedSchemaName);
|
|
8041
9124
|
return createColumnsBuilder(name, mappedName, normalizedSchemaName, columns);
|
|
8042
9125
|
},
|
|
9126
|
+
withoutPrimaryKey() {
|
|
9127
|
+
return finalizeTable(name, mappedName, schemaName, columns, []);
|
|
9128
|
+
},
|
|
8043
9129
|
primaryKey(...keys) {
|
|
8044
9130
|
return finalizeTable(name, mappedName, schemaName, columns, keys);
|
|
8045
9131
|
}
|
|
@@ -8091,6 +9177,59 @@ var TenantHeaderMapper = class {
|
|
|
8091
9177
|
return Object.keys(headers).length > 0 ? headers : void 0;
|
|
8092
9178
|
}
|
|
8093
9179
|
};
|
|
9180
|
+
function normalizeOptionalString2(value) {
|
|
9181
|
+
if (typeof value !== "string") {
|
|
9182
|
+
return void 0;
|
|
9183
|
+
}
|
|
9184
|
+
const normalizedValue = value.trim();
|
|
9185
|
+
return normalizedValue ? normalizedValue : void 0;
|
|
9186
|
+
}
|
|
9187
|
+
function readHeaderBagValue2(headers, targetKey) {
|
|
9188
|
+
if (!headers) {
|
|
9189
|
+
return void 0;
|
|
9190
|
+
}
|
|
9191
|
+
if (typeof headers.get === "function") {
|
|
9192
|
+
return normalizeOptionalString2(headers.get(targetKey));
|
|
9193
|
+
}
|
|
9194
|
+
const normalizedTargetKey = targetKey.toLowerCase();
|
|
9195
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
9196
|
+
if (key.toLowerCase() !== normalizedTargetKey) {
|
|
9197
|
+
continue;
|
|
9198
|
+
}
|
|
9199
|
+
if (typeof value === "string") {
|
|
9200
|
+
return normalizeOptionalString2(value);
|
|
9201
|
+
}
|
|
9202
|
+
return void 0;
|
|
9203
|
+
}
|
|
9204
|
+
return void 0;
|
|
9205
|
+
}
|
|
9206
|
+
function resolveSessionContextOptions2(session, options) {
|
|
9207
|
+
const sessionToken = normalizeOptionalString2(session?.session?.token);
|
|
9208
|
+
const requestCookie = readHeaderBagValue2(options?.requestHeaders, "cookie") ?? readHeaderBagValue2(options?.headers, "cookie");
|
|
9209
|
+
const authInput = options?.auth;
|
|
9210
|
+
const resolvedUserId = options?.userId !== void 0 ? options.userId : session?.user?.id;
|
|
9211
|
+
const resolvedOrganizationId = options?.organizationId !== void 0 ? options.organizationId : session?.session?.activeOrganizationId;
|
|
9212
|
+
const resolvedBearerToken = authInput?.bearerToken !== void 0 ? authInput.bearerToken : sessionToken;
|
|
9213
|
+
const resolvedSessionToken = authInput?.sessionToken !== void 0 ? authInput.sessionToken : sessionToken;
|
|
9214
|
+
const resolvedCookie = authInput?.cookie !== void 0 ? authInput.cookie : requestCookie;
|
|
9215
|
+
const auth = authInput !== void 0 || resolvedBearerToken !== void 0 || resolvedSessionToken !== void 0 || resolvedCookie !== void 0 ? {
|
|
9216
|
+
...authInput ?? {},
|
|
9217
|
+
...resolvedBearerToken !== void 0 ? { bearerToken: resolvedBearerToken } : {},
|
|
9218
|
+
...resolvedSessionToken !== void 0 ? { sessionToken: resolvedSessionToken } : {},
|
|
9219
|
+
...resolvedCookie !== void 0 ? { cookie: resolvedCookie } : {},
|
|
9220
|
+
headers: authInput?.headers ? { ...authInput.headers } : void 0
|
|
9221
|
+
} : void 0;
|
|
9222
|
+
if (resolvedUserId === void 0 && resolvedOrganizationId === void 0 && options?.forceNoCache === void 0 && !options?.headers && !auth) {
|
|
9223
|
+
return void 0;
|
|
9224
|
+
}
|
|
9225
|
+
return {
|
|
9226
|
+
userId: resolvedUserId,
|
|
9227
|
+
organizationId: resolvedOrganizationId,
|
|
9228
|
+
forceNoCache: options?.forceNoCache,
|
|
9229
|
+
headers: options?.headers ? { ...options.headers } : void 0,
|
|
9230
|
+
auth
|
|
9231
|
+
};
|
|
9232
|
+
}
|
|
8094
9233
|
var RegistryNavigator = class {
|
|
8095
9234
|
constructor(registry) {
|
|
8096
9235
|
this.registry = registry;
|
|
@@ -8142,12 +9281,22 @@ var TypedAthenaClientImpl = class _TypedAthenaClientImpl {
|
|
|
8142
9281
|
backend: input.options?.backend,
|
|
8143
9282
|
client: input.options?.client,
|
|
8144
9283
|
headers: input.options?.headers,
|
|
9284
|
+
forceNoCache: input.options?.forceNoCache,
|
|
9285
|
+
userId: input.options?.userId,
|
|
9286
|
+
organizationId: input.options?.organizationId,
|
|
9287
|
+
auth: input.options?.auth,
|
|
9288
|
+
tenantKeyMap,
|
|
9289
|
+
tenantContext,
|
|
8145
9290
|
experimental: input.options?.experimental
|
|
8146
9291
|
};
|
|
8147
9292
|
this.baseClient = createClient(this.url, this.apiKey, {
|
|
8148
9293
|
backend: this.clientOptions.backend,
|
|
8149
9294
|
client: this.clientOptions.client,
|
|
8150
9295
|
headers: this.tenantHeaderMapper.apply(this.clientOptions.headers, tenantContext),
|
|
9296
|
+
forceNoCache: this.clientOptions.forceNoCache,
|
|
9297
|
+
userId: this.clientOptions.userId,
|
|
9298
|
+
organizationId: this.clientOptions.organizationId,
|
|
9299
|
+
auth: this.clientOptions.auth,
|
|
8151
9300
|
experimental: this.clientOptions.experimental
|
|
8152
9301
|
});
|
|
8153
9302
|
this.db = this.baseClient.db;
|
|
@@ -8165,6 +9314,40 @@ var TypedAthenaClientImpl = class _TypedAthenaClientImpl {
|
|
|
8165
9314
|
verifyConnection(options) {
|
|
8166
9315
|
return this.baseClient.verifyConnection(options);
|
|
8167
9316
|
}
|
|
9317
|
+
withContext(context) {
|
|
9318
|
+
const headers = {
|
|
9319
|
+
...this.clientOptions.headers ?? {},
|
|
9320
|
+
...context?.headers ?? {}
|
|
9321
|
+
};
|
|
9322
|
+
const auth = this.clientOptions.auth || context?.auth ? {
|
|
9323
|
+
...this.clientOptions.auth ?? {},
|
|
9324
|
+
...context?.auth ?? {},
|
|
9325
|
+
headers: this.clientOptions.auth?.headers || context?.auth?.headers ? {
|
|
9326
|
+
...this.clientOptions.auth?.headers ?? {},
|
|
9327
|
+
...context?.auth?.headers ?? {}
|
|
9328
|
+
} : void 0
|
|
9329
|
+
} : void 0;
|
|
9330
|
+
return new _TypedAthenaClientImpl({
|
|
9331
|
+
registry: this.registry,
|
|
9332
|
+
url: this.url,
|
|
9333
|
+
apiKey: this.apiKey,
|
|
9334
|
+
options: {
|
|
9335
|
+
...this.clientOptions,
|
|
9336
|
+
headers: Object.keys(headers).length > 0 ? headers : void 0,
|
|
9337
|
+
auth,
|
|
9338
|
+
tenantKeyMap: this.tenantKeyMap,
|
|
9339
|
+
tenantContext: {
|
|
9340
|
+
...this.tenantContext
|
|
9341
|
+
},
|
|
9342
|
+
...context?.userId !== void 0 ? { userId: context.userId } : {},
|
|
9343
|
+
...context?.organizationId !== void 0 ? { organizationId: context.organizationId } : {},
|
|
9344
|
+
...context?.forceNoCache !== void 0 ? { forceNoCache: context.forceNoCache } : {}
|
|
9345
|
+
}
|
|
9346
|
+
});
|
|
9347
|
+
}
|
|
9348
|
+
withSession(session, options) {
|
|
9349
|
+
return this.withContext(resolveSessionContextOptions2(session, options));
|
|
9350
|
+
}
|
|
8168
9351
|
withTenantContext(context) {
|
|
8169
9352
|
return new _TypedAthenaClientImpl({
|
|
8170
9353
|
registry: this.registry,
|
|
@@ -8660,6 +9843,77 @@ function resolveProviderSchemas(providerConfig) {
|
|
|
8660
9843
|
return [...DEFAULT_POSTGRES_SCHEMAS];
|
|
8661
9844
|
}
|
|
8662
9845
|
|
|
9846
|
+
// src/generator/table-selection.ts
|
|
9847
|
+
function normalizeTableSelector(value) {
|
|
9848
|
+
const trimmed = value.trim();
|
|
9849
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
9850
|
+
}
|
|
9851
|
+
function normalizeTableSelection(value) {
|
|
9852
|
+
if (typeof value === "string") {
|
|
9853
|
+
return Array.from(
|
|
9854
|
+
new Set(
|
|
9855
|
+
value.split(",").map(normalizeTableSelector).filter((entry) => Boolean(entry))
|
|
9856
|
+
)
|
|
9857
|
+
);
|
|
9858
|
+
}
|
|
9859
|
+
if (Array.isArray(value)) {
|
|
9860
|
+
return Array.from(
|
|
9861
|
+
new Set(
|
|
9862
|
+
value.map((entry) => typeof entry === "string" ? normalizeTableSelector(entry) : void 0).filter((entry) => Boolean(entry))
|
|
9863
|
+
)
|
|
9864
|
+
);
|
|
9865
|
+
}
|
|
9866
|
+
return [];
|
|
9867
|
+
}
|
|
9868
|
+
function matchesTableSelector(schemaName, tableName, selector) {
|
|
9869
|
+
const separatorIndex = selector.indexOf(".");
|
|
9870
|
+
if (separatorIndex < 0) {
|
|
9871
|
+
return tableName === selector;
|
|
9872
|
+
}
|
|
9873
|
+
const selectorSchema = selector.slice(0, separatorIndex).trim();
|
|
9874
|
+
const selectorTable = selector.slice(separatorIndex + 1).trim();
|
|
9875
|
+
return selectorSchema === schemaName && selectorTable === tableName;
|
|
9876
|
+
}
|
|
9877
|
+
function shouldKeepTable(schemaName, tableName, filter) {
|
|
9878
|
+
const included = filter.includeTables.length === 0 || filter.includeTables.some((selector) => matchesTableSelector(schemaName, tableName, selector));
|
|
9879
|
+
if (!included) {
|
|
9880
|
+
return false;
|
|
9881
|
+
}
|
|
9882
|
+
return !filter.excludeTables.some((selector) => matchesTableSelector(schemaName, tableName, selector));
|
|
9883
|
+
}
|
|
9884
|
+
function hasTableFilters(filter) {
|
|
9885
|
+
return filter.includeTables.length > 0 || filter.excludeTables.length > 0;
|
|
9886
|
+
}
|
|
9887
|
+
function filterIntrospectionSnapshot(snapshot, filter) {
|
|
9888
|
+
if (!hasTableFilters(filter)) {
|
|
9889
|
+
return snapshot;
|
|
9890
|
+
}
|
|
9891
|
+
const schemas = {};
|
|
9892
|
+
for (const [schemaName, schema] of Object.entries(snapshot.schemas)) {
|
|
9893
|
+
const tables = Object.fromEntries(
|
|
9894
|
+
Object.entries(schema.tables).filter(([tableName]) => shouldKeepTable(schemaName, tableName, filter))
|
|
9895
|
+
);
|
|
9896
|
+
if (Object.keys(tables).length === 0) {
|
|
9897
|
+
continue;
|
|
9898
|
+
}
|
|
9899
|
+
schemas[schemaName] = {
|
|
9900
|
+
...schema,
|
|
9901
|
+
tables
|
|
9902
|
+
};
|
|
9903
|
+
}
|
|
9904
|
+
if (Object.keys(schemas).length === 0) {
|
|
9905
|
+
const includeLabel = filter.includeTables.length > 0 ? ` includeTables=${filter.includeTables.join(", ")}` : "";
|
|
9906
|
+
const excludeLabel = filter.excludeTables.length > 0 ? ` excludeTables=${filter.excludeTables.join(", ")}` : "";
|
|
9907
|
+
throw new Error(
|
|
9908
|
+
`Generator table filters matched no tables after schema selection.${includeLabel}${excludeLabel}`
|
|
9909
|
+
);
|
|
9910
|
+
}
|
|
9911
|
+
return {
|
|
9912
|
+
...snapshot,
|
|
9913
|
+
schemas
|
|
9914
|
+
};
|
|
9915
|
+
}
|
|
9916
|
+
|
|
8663
9917
|
// src/generator/config.ts
|
|
8664
9918
|
var POSTGRES_PROTOCOLS = /* @__PURE__ */ new Set(["postgres:", "postgresql:"]);
|
|
8665
9919
|
var DEFAULT_CONFIG_CANDIDATES = [
|
|
@@ -8670,13 +9924,20 @@ var DEFAULT_CONFIG_CANDIDATES = [
|
|
|
8670
9924
|
".athena.config.ts",
|
|
8671
9925
|
".athena.config.js"
|
|
8672
9926
|
];
|
|
8673
|
-
var
|
|
9927
|
+
var LEGACY_DEFAULT_TARGETS = {
|
|
8674
9928
|
model: "athena/models/{schema_kebab}/{model_kebab}.ts",
|
|
8675
9929
|
schema: "athena/schemas/{schema_kebab}.ts",
|
|
8676
9930
|
database: "athena/relations.ts",
|
|
8677
9931
|
registry: "athena/config.ts"
|
|
8678
9932
|
};
|
|
8679
|
-
var
|
|
9933
|
+
var ATHENA_DIRECT_TARGETS = {
|
|
9934
|
+
model: "athena/models/{schema_kebab}/{model_kebab}.ts",
|
|
9935
|
+
schema: "athena/schemas/{schema_kebab}.ts",
|
|
9936
|
+
database: "athena/relations.ts",
|
|
9937
|
+
registry: "athena/registry.generated.ts"
|
|
9938
|
+
};
|
|
9939
|
+
var DEFAULT_OUTPUT_FORMAT = "table-builder";
|
|
9940
|
+
var DEFAULT_OUTPUT_PRESET = "athena-direct";
|
|
8680
9941
|
var DEFAULT_NAMING = {
|
|
8681
9942
|
modelType: "pascal",
|
|
8682
9943
|
modelConst: "camel",
|
|
@@ -8695,6 +9956,10 @@ var DEFAULT_EXPERIMENTAL_FLAGS = {
|
|
|
8695
9956
|
var DEFAULT_INTERNAL_CONFIG = {
|
|
8696
9957
|
schemaVersion: 1
|
|
8697
9958
|
};
|
|
9959
|
+
var DEFAULT_FILTER_CONFIG = {
|
|
9960
|
+
includeTables: [],
|
|
9961
|
+
excludeTables: []
|
|
9962
|
+
};
|
|
8698
9963
|
var PROJECT_ENV_FILENAMES = [".env", ".env.local"];
|
|
8699
9964
|
var DIRECT_CONNECTION_STRING_ENV_KEYS = [
|
|
8700
9965
|
"ATHENA_GENERATOR_PG_URL",
|
|
@@ -8713,10 +9978,13 @@ var GATEWAY_API_KEY_ENV_KEYS = [
|
|
|
8713
9978
|
];
|
|
8714
9979
|
var GENERATOR_SCHEMA_ENV_KEYS = ["ATHENA_GENERATOR_SCHEMAS"];
|
|
8715
9980
|
var OUTPUT_FORMAT_ENV_KEYS = ["ATHENA_GENERATOR_OUTPUT_FORMAT"];
|
|
9981
|
+
var OUTPUT_PRESET_ENV_KEYS = ["ATHENA_GENERATOR_OUTPUT_PRESET"];
|
|
8716
9982
|
var MODEL_TARGET_ENV_KEYS = ["ATHENA_GENERATOR_MODEL_TARGET"];
|
|
8717
9983
|
var SCHEMA_TARGET_ENV_KEYS = ["ATHENA_GENERATOR_SCHEMA_TARGET"];
|
|
8718
9984
|
var DATABASE_TARGET_ENV_KEYS = ["ATHENA_GENERATOR_DATABASE_TARGET"];
|
|
8719
9985
|
var REGISTRY_TARGET_ENV_KEYS = ["ATHENA_GENERATOR_REGISTRY_TARGET"];
|
|
9986
|
+
var TABLES_ENV_KEYS = ["ATHENA_GENERATOR_TABLES"];
|
|
9987
|
+
var EXCLUDE_TABLES_ENV_KEYS = ["ATHENA_GENERATOR_EXCLUDE_TABLES"];
|
|
8720
9988
|
var PLACEHOLDER_MAP_ENV_KEYS = ["ATHENA_GENERATOR_PLACEHOLDER_MAP"];
|
|
8721
9989
|
var MODEL_TYPE_ENV_KEYS = ["ATHENA_GENERATOR_MODEL_TYPE", "ATHENA_GENERATOR_MODEL_STYLE"];
|
|
8722
9990
|
var MODEL_CONST_ENV_KEYS = ["ATHENA_GENERATOR_MODEL_CONST"];
|
|
@@ -8731,7 +9999,12 @@ var SCYLLA_PROVIDER_CONTRACTS_ENV_KEYS = ["ATHENA_GENERATOR_SCYLLA_PROVIDER_CONT
|
|
|
8731
9999
|
var ENV_ONLY_CONFIG_PATH = "[environment defaults]";
|
|
8732
10000
|
var NAMING_STYLE_VALUES = ["preserve", "camel", "pascal", "snake", "kebab"];
|
|
8733
10001
|
var OUTPUT_FORMAT_VALUES = ["define-model", "table-builder"];
|
|
10002
|
+
var OUTPUT_PRESET_VALUES = ["legacy", "athena-direct"];
|
|
8734
10003
|
var BACKEND_TYPE_VALUES = ["athena", "postgrest", "postgresql", "scylladb"];
|
|
10004
|
+
var OUTPUT_PRESET_TARGETS = {
|
|
10005
|
+
legacy: LEGACY_DEFAULT_TARGETS,
|
|
10006
|
+
"athena-direct": ATHENA_DIRECT_TARGETS
|
|
10007
|
+
};
|
|
8735
10008
|
function normalizeRawEnvValue(rawValue) {
|
|
8736
10009
|
if (rawValue.startsWith('"') && rawValue.endsWith('"') && rawValue.length >= 2) {
|
|
8737
10010
|
const inner = rawValue.slice(1, -1);
|
|
@@ -8867,7 +10140,7 @@ function deriveDatabaseNameFromConnectionString(connectionString) {
|
|
|
8867
10140
|
return void 0;
|
|
8868
10141
|
}
|
|
8869
10142
|
}
|
|
8870
|
-
function
|
|
10143
|
+
function normalizeOptionalString3(value, fallbackKeys) {
|
|
8871
10144
|
if (typeof value === "string") {
|
|
8872
10145
|
const trimmed = value.trim();
|
|
8873
10146
|
if (trimmed.length > 0) {
|
|
@@ -8877,7 +10150,7 @@ function normalizeOptionalString(value, fallbackKeys) {
|
|
|
8877
10150
|
return resolveFallbackValue(fallbackKeys);
|
|
8878
10151
|
}
|
|
8879
10152
|
function normalizeRequiredString(value, fieldLabel, fallbackKeys) {
|
|
8880
|
-
const resolved =
|
|
10153
|
+
const resolved = normalizeOptionalString3(value, fallbackKeys);
|
|
8881
10154
|
if (resolved) {
|
|
8882
10155
|
return resolved;
|
|
8883
10156
|
}
|
|
@@ -8938,11 +10211,19 @@ function normalizeExperimentalFlags(input) {
|
|
|
8938
10211
|
)
|
|
8939
10212
|
};
|
|
8940
10213
|
}
|
|
10214
|
+
function normalizeFilterConfig(input) {
|
|
10215
|
+
return {
|
|
10216
|
+
includeTables: normalizeTableSelection(input?.includeTables),
|
|
10217
|
+
excludeTables: normalizeTableSelection(input?.excludeTables)
|
|
10218
|
+
};
|
|
10219
|
+
}
|
|
8941
10220
|
function normalizeOutputConfig(output) {
|
|
10221
|
+
const preset = output?.preset ?? DEFAULT_OUTPUT_PRESET;
|
|
8942
10222
|
return {
|
|
8943
10223
|
format: output?.format ?? DEFAULT_OUTPUT_FORMAT,
|
|
10224
|
+
preset,
|
|
8944
10225
|
targets: {
|
|
8945
|
-
...
|
|
10226
|
+
...OUTPUT_PRESET_TARGETS[preset],
|
|
8946
10227
|
...output?.targets ?? {}
|
|
8947
10228
|
},
|
|
8948
10229
|
placeholderMap: {
|
|
@@ -8957,7 +10238,7 @@ function normalizeProviderConfig(provider) {
|
|
|
8957
10238
|
"provider.connectionString",
|
|
8958
10239
|
DIRECT_CONNECTION_STRING_ENV_KEYS
|
|
8959
10240
|
);
|
|
8960
|
-
const database =
|
|
10241
|
+
const database = normalizeOptionalString3(provider.database, POSTGRES_DATABASE_ENV_KEYS) ?? deriveDatabaseNameFromConnectionString(connectionString);
|
|
8961
10242
|
return {
|
|
8962
10243
|
...provider,
|
|
8963
10244
|
connectionString: applyPostgresPasswordFallback(connectionString),
|
|
@@ -8976,7 +10257,7 @@ function normalizeProviderConfig(provider) {
|
|
|
8976
10257
|
"provider.apiKey",
|
|
8977
10258
|
GATEWAY_API_KEY_ENV_KEYS
|
|
8978
10259
|
);
|
|
8979
|
-
const database =
|
|
10260
|
+
const database = normalizeOptionalString3(provider.database, POSTGRES_DATABASE_ENV_KEYS) ?? "postgres";
|
|
8980
10261
|
return {
|
|
8981
10262
|
...provider,
|
|
8982
10263
|
gatewayUrl,
|
|
@@ -8991,7 +10272,7 @@ function normalizeProviderConfig(provider) {
|
|
|
8991
10272
|
"Generator config is missing provider.contactPoints for scylla direct mode."
|
|
8992
10273
|
);
|
|
8993
10274
|
}
|
|
8994
|
-
const keyspace =
|
|
10275
|
+
const keyspace = normalizeOptionalString3(provider.keyspace, []);
|
|
8995
10276
|
if (!keyspace) {
|
|
8996
10277
|
throw new Error(
|
|
8997
10278
|
"Generator config is missing provider.keyspace for scylla direct mode."
|
|
@@ -9002,7 +10283,7 @@ function normalizeProviderConfig(provider) {
|
|
|
9002
10283
|
mode: "direct",
|
|
9003
10284
|
contactPoints: provider.contactPoints.slice(),
|
|
9004
10285
|
keyspace,
|
|
9005
|
-
datacenter:
|
|
10286
|
+
datacenter: normalizeOptionalString3(provider.datacenter, [])
|
|
9006
10287
|
};
|
|
9007
10288
|
}
|
|
9008
10289
|
return provider;
|
|
@@ -9022,6 +10303,10 @@ function normalizeGeneratorConfig(input) {
|
|
|
9022
10303
|
...DEFAULT_NAMING,
|
|
9023
10304
|
...input.naming ?? {}
|
|
9024
10305
|
},
|
|
10306
|
+
filter: {
|
|
10307
|
+
...DEFAULT_FILTER_CONFIG,
|
|
10308
|
+
...normalizeFilterConfig(input.filter)
|
|
10309
|
+
},
|
|
9025
10310
|
features: normalizeFeatureFlags(input.features),
|
|
9026
10311
|
experimental: normalizeExperimentalFlags(input.experimental),
|
|
9027
10312
|
internal: {
|
|
@@ -9085,16 +10370,18 @@ function importConfigModule(moduleSpecifier) {
|
|
|
9085
10370
|
}
|
|
9086
10371
|
function buildEnvironmentOutputConfig() {
|
|
9087
10372
|
const format = resolveOptionalOneOf(OUTPUT_FORMAT_ENV_KEYS, OUTPUT_FORMAT_VALUES);
|
|
10373
|
+
const preset = resolveOptionalOneOf(OUTPUT_PRESET_ENV_KEYS, OUTPUT_PRESET_VALUES);
|
|
9088
10374
|
const modelTarget = resolveFallbackValue(MODEL_TARGET_ENV_KEYS);
|
|
9089
10375
|
const schemaTarget = resolveFallbackValue(SCHEMA_TARGET_ENV_KEYS);
|
|
9090
10376
|
const databaseTarget = resolveFallbackValue(DATABASE_TARGET_ENV_KEYS);
|
|
9091
10377
|
const registryTarget = resolveFallbackValue(REGISTRY_TARGET_ENV_KEYS);
|
|
9092
10378
|
const placeholderMap = resolveOptionalJson(PLACEHOLDER_MAP_ENV_KEYS);
|
|
9093
|
-
if (format === void 0 && modelTarget === void 0 && schemaTarget === void 0 && databaseTarget === void 0 && registryTarget === void 0 && placeholderMap === void 0) {
|
|
10379
|
+
if (format === void 0 && preset === void 0 && modelTarget === void 0 && schemaTarget === void 0 && databaseTarget === void 0 && registryTarget === void 0 && placeholderMap === void 0) {
|
|
9094
10380
|
return void 0;
|
|
9095
10381
|
}
|
|
9096
10382
|
return {
|
|
9097
10383
|
format,
|
|
10384
|
+
preset,
|
|
9098
10385
|
targets: {
|
|
9099
10386
|
...modelTarget ? { model: modelTarget } : {},
|
|
9100
10387
|
...schemaTarget ? { schema: schemaTarget } : {},
|
|
@@ -9104,6 +10391,17 @@ function buildEnvironmentOutputConfig() {
|
|
|
9104
10391
|
placeholderMap
|
|
9105
10392
|
};
|
|
9106
10393
|
}
|
|
10394
|
+
function buildEnvironmentFilterConfig() {
|
|
10395
|
+
const includeTables = resolveFallbackValue(TABLES_ENV_KEYS);
|
|
10396
|
+
const excludeTables = resolveFallbackValue(EXCLUDE_TABLES_ENV_KEYS);
|
|
10397
|
+
if (includeTables === void 0 && excludeTables === void 0) {
|
|
10398
|
+
return void 0;
|
|
10399
|
+
}
|
|
10400
|
+
return {
|
|
10401
|
+
...includeTables !== void 0 ? { includeTables } : {},
|
|
10402
|
+
...excludeTables !== void 0 ? { excludeTables } : {}
|
|
10403
|
+
};
|
|
10404
|
+
}
|
|
9107
10405
|
function buildEnvironmentNamingConfig() {
|
|
9108
10406
|
const modelType = resolveOptionalOneOf(MODEL_TYPE_ENV_KEYS, NAMING_STYLE_VALUES);
|
|
9109
10407
|
const modelConst = resolveOptionalOneOf(MODEL_CONST_ENV_KEYS, NAMING_STYLE_VALUES);
|
|
@@ -9150,7 +10448,7 @@ function buildEnvironmentProviderConfig() {
|
|
|
9150
10448
|
kind: "postgres",
|
|
9151
10449
|
mode: "direct",
|
|
9152
10450
|
connectionString: directConnectionString,
|
|
9153
|
-
database:
|
|
10451
|
+
database: normalizeOptionalString3(void 0, POSTGRES_DATABASE_ENV_KEYS),
|
|
9154
10452
|
schemas: normalizeSchemaSelection(resolveFallbackValue(GENERATOR_SCHEMA_ENV_KEYS))
|
|
9155
10453
|
};
|
|
9156
10454
|
}
|
|
@@ -9163,7 +10461,7 @@ function buildEnvironmentProviderConfig() {
|
|
|
9163
10461
|
mode: "gateway",
|
|
9164
10462
|
gatewayUrl,
|
|
9165
10463
|
apiKey,
|
|
9166
|
-
database:
|
|
10464
|
+
database: normalizeOptionalString3(void 0, POSTGRES_DATABASE_ENV_KEYS),
|
|
9167
10465
|
schemas: normalizeSchemaSelection(resolveFallbackValue(GENERATOR_SCHEMA_ENV_KEYS)),
|
|
9168
10466
|
backend
|
|
9169
10467
|
};
|
|
@@ -9179,6 +10477,7 @@ function createEnvironmentGeneratorConfig() {
|
|
|
9179
10477
|
provider,
|
|
9180
10478
|
output: buildEnvironmentOutputConfig(),
|
|
9181
10479
|
naming: buildEnvironmentNamingConfig(),
|
|
10480
|
+
filter: buildEnvironmentFilterConfig(),
|
|
9182
10481
|
features: buildEnvironmentFeatureFlags(),
|
|
9183
10482
|
experimental: buildEnvironmentExperimentalFlags()
|
|
9184
10483
|
};
|
|
@@ -9664,7 +10963,7 @@ ${schemaEntries}
|
|
|
9664
10963
|
content
|
|
9665
10964
|
};
|
|
9666
10965
|
}
|
|
9667
|
-
function renderRegistryArtifact(registryPath, databasePath, databaseConstName, registryConstName, databaseName, generatedAt, outputFormat, schemaVersion) {
|
|
10966
|
+
function renderRegistryArtifact(registryPath, databasePath, databaseConstName, registryConstName, databaseName, generatedAt, outputPreset, outputFormat, schemaVersion) {
|
|
9668
10967
|
const databaseImportPath = toModuleImportPath(registryPath, databasePath);
|
|
9669
10968
|
const content = `import { defineRegistry } from '@xylex-group/athena'
|
|
9670
10969
|
import { ${databaseConstName} } from '${databaseImportPath}'
|
|
@@ -9673,6 +10972,7 @@ export const __athena_schema_meta = {
|
|
|
9673
10972
|
schemaVersion: ${schemaVersion},
|
|
9674
10973
|
generatedAt: ${escapeStringLiteral(generatedAt)},
|
|
9675
10974
|
database: ${escapeStringLiteral(databaseName)},
|
|
10975
|
+
outputPreset: ${escapeStringLiteral(outputPreset)},
|
|
9676
10976
|
outputFormat: ${escapeStringLiteral(outputFormat)},
|
|
9677
10977
|
} as const
|
|
9678
10978
|
|
|
@@ -9842,6 +11142,7 @@ function composeGeneratorArtifacts(input) {
|
|
|
9842
11142
|
toSafeIdentifier("registry", config.naming.registryConst, "registry"),
|
|
9843
11143
|
databaseName,
|
|
9844
11144
|
snapshot.generatedAt,
|
|
11145
|
+
config.output.preset,
|
|
9845
11146
|
config.output.format,
|
|
9846
11147
|
config.internal.schemaVersion
|
|
9847
11148
|
)
|
|
@@ -9947,7 +11248,7 @@ export const ${descriptor.tableConstName} = table(${escapeStringLiteral(descript
|
|
|
9947
11248
|
.columns({
|
|
9948
11249
|
${columnLines}
|
|
9949
11250
|
})
|
|
9950
|
-
.primaryKey(${descriptor.table.primaryKey.map((value) => escapeStringLiteral(value)).join(", ")})
|
|
11251
|
+
${descriptor.table.primaryKey.length > 0 ? `.primaryKey(${descriptor.table.primaryKey.map((value) => escapeStringLiteral(value)).join(", ")})` : ".withoutPrimaryKey()"}
|
|
9951
11252
|
${relationsAssignment ? `${relationsAssignment}` : ""}
|
|
9952
11253
|
export type ${descriptor.rowTypeName} = RowOf<typeof ${descriptor.tableConstName}>
|
|
9953
11254
|
export type ${descriptor.insertTypeName} = InsertOf<typeof ${descriptor.tableConstName}>
|
|
@@ -10044,11 +11345,12 @@ ${nullableLines}
|
|
|
10044
11345
|
}
|
|
10045
11346
|
function generateArtifactsFromSnapshot(snapshot, config) {
|
|
10046
11347
|
const normalizedConfig = "internal" in config ? config : normalizeGeneratorConfig(config);
|
|
11348
|
+
const filteredSnapshot = filterIntrospectionSnapshot(snapshot, normalizedConfig.filter);
|
|
10047
11349
|
if (normalizedConfig.output.format === "table-builder") {
|
|
10048
|
-
return generateTableBuilderArtifactsFromSnapshot(
|
|
11350
|
+
return generateTableBuilderArtifactsFromSnapshot(filteredSnapshot, normalizedConfig);
|
|
10049
11351
|
}
|
|
10050
11352
|
return composeGeneratorArtifacts({
|
|
10051
|
-
snapshot,
|
|
11353
|
+
snapshot: filteredSnapshot,
|
|
10052
11354
|
config: normalizedConfig,
|
|
10053
11355
|
createModelDescriptor({ providerName, databaseName, schemaName, tableName, table: table2 }) {
|
|
10054
11356
|
const modelConstName = toSafeIdentifier(
|
|
@@ -10078,7 +11380,7 @@ function generateArtifactsFromSnapshot(snapshot, config) {
|
|
|
10078
11380
|
table: table2
|
|
10079
11381
|
};
|
|
10080
11382
|
},
|
|
10081
|
-
renderModelArtifact: (descriptor) => renderModelArtifact2(
|
|
11383
|
+
renderModelArtifact: (descriptor) => renderModelArtifact2(filteredSnapshot.database, descriptor, normalizedConfig)
|
|
10082
11384
|
});
|
|
10083
11385
|
}
|
|
10084
11386
|
|
|
@@ -10198,16 +11500,25 @@ async function fileExists(path) {
|
|
|
10198
11500
|
}
|
|
10199
11501
|
async function writeArtifacts(files, cwd) {
|
|
10200
11502
|
const writtenFiles = [];
|
|
11503
|
+
const skippedFiles = [];
|
|
10201
11504
|
for (const file of files) {
|
|
10202
11505
|
const absolutePath = path.resolve(cwd, file.path);
|
|
10203
11506
|
if (!canOverwriteArtifact(file) && await fileExists(absolutePath)) {
|
|
11507
|
+
skippedFiles.push({
|
|
11508
|
+
kind: file.kind,
|
|
11509
|
+
path: file.path,
|
|
11510
|
+
reason: "protected-existing-file"
|
|
11511
|
+
});
|
|
10204
11512
|
continue;
|
|
10205
11513
|
}
|
|
10206
11514
|
await promises.mkdir(path.dirname(absolutePath), { recursive: true });
|
|
10207
11515
|
await promises.writeFile(absolutePath, file.content, "utf8");
|
|
10208
11516
|
writtenFiles.push(file.path);
|
|
10209
11517
|
}
|
|
10210
|
-
return
|
|
11518
|
+
return {
|
|
11519
|
+
writtenFiles,
|
|
11520
|
+
skippedFiles
|
|
11521
|
+
};
|
|
10211
11522
|
}
|
|
10212
11523
|
async function runSchemaGenerator(options = {}) {
|
|
10213
11524
|
const cwd = options.cwd ?? process.cwd();
|
|
@@ -10221,11 +11532,13 @@ async function runSchemaGenerator(options = {}) {
|
|
|
10221
11532
|
schemas: resolveProviderSchemas(config.provider)
|
|
10222
11533
|
});
|
|
10223
11534
|
const generated = generateArtifactsFromSnapshot(snapshot, config);
|
|
10224
|
-
const
|
|
11535
|
+
const writeResult = options.dryRun ? { writtenFiles: [], skippedFiles: [] } : await writeArtifacts(generated.files, cwd);
|
|
10225
11536
|
return {
|
|
10226
11537
|
...generated,
|
|
10227
11538
|
configPath,
|
|
10228
|
-
|
|
11539
|
+
config,
|
|
11540
|
+
writtenFiles: writeResult.writtenFiles,
|
|
11541
|
+
skippedFiles: writeResult.skippedFiles
|
|
10229
11542
|
};
|
|
10230
11543
|
}
|
|
10231
11544
|
|
|
@@ -10656,7 +11969,12 @@ function athenaAuth(config) {
|
|
|
10656
11969
|
return auth;
|
|
10657
11970
|
}
|
|
10658
11971
|
|
|
11972
|
+
exports.ATHENA_AUTH_ADMIN_LIMITS = ATHENA_AUTH_ADMIN_LIMITS;
|
|
10659
11973
|
exports.ATHENA_AUTH_BASE_ERROR_CODES = ATHENA_AUTH_BASE_ERROR_CODES;
|
|
11974
|
+
exports.ATHENA_AUTH_MAX_ADMIN_JSON_BYTES = ATHENA_AUTH_MAX_ADMIN_JSON_BYTES;
|
|
11975
|
+
exports.ATHENA_AUTH_MAX_ADMIN_JSON_DEPTH = ATHENA_AUTH_MAX_ADMIN_JSON_DEPTH;
|
|
11976
|
+
exports.ATHENA_AUTH_MAX_TEMPLATE_VARIABLES = ATHENA_AUTH_MAX_TEMPLATE_VARIABLES;
|
|
11977
|
+
exports.ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH = ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH;
|
|
10660
11978
|
exports.AthenaClient = AthenaClient;
|
|
10661
11979
|
exports.AthenaError = AthenaError;
|
|
10662
11980
|
exports.AthenaErrorCategory = AthenaErrorCategory;
|
|
@@ -10686,6 +12004,7 @@ exports.defineModel = defineModel;
|
|
|
10686
12004
|
exports.defineRegistry = defineRegistry;
|
|
10687
12005
|
exports.defineSchema = defineSchema;
|
|
10688
12006
|
exports.enumeration = enumeration;
|
|
12007
|
+
exports.filterIntrospectionSnapshot = filterIntrospectionSnapshot;
|
|
10689
12008
|
exports.findGeneratorConfigPath = findGeneratorConfigPath;
|
|
10690
12009
|
exports.generateArtifactsFromSnapshot = generateArtifactsFromSnapshot;
|
|
10691
12010
|
exports.generatorEnv = generatorEnv;
|
|
@@ -10699,6 +12018,7 @@ exports.normalizeAthenaError = normalizeAthenaError;
|
|
|
10699
12018
|
exports.normalizeAthenaGatewayBaseUrl = normalizeAthenaGatewayBaseUrl;
|
|
10700
12019
|
exports.normalizeGeneratorConfig = normalizeGeneratorConfig;
|
|
10701
12020
|
exports.normalizeSchemaSelection = normalizeSchemaSelection;
|
|
12021
|
+
exports.normalizeTableSelection = normalizeTableSelection;
|
|
10702
12022
|
exports.number = number;
|
|
10703
12023
|
exports.parseBooleanFlag = parseBooleanFlag2;
|
|
10704
12024
|
exports.renderAthenaReactEmail = renderAthenaReactEmail;
|