@xylex-group/athena 2.9.0 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/browser.cjs +828 -74
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +3 -3
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +825 -75
- package/dist/browser.js.map +1 -1
- package/dist/cli/index.cjs +748 -40
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +748 -40
- package/dist/cli/index.js.map +1 -1
- package/dist/{client-CfAE_QOj.d.cts → client-B7EQ_hPV.d.cts} +506 -22
- package/dist/{client-D6EIJdQS.d.ts → client-BYii6dU9.d.ts} +506 -22
- package/dist/index.cjs +828 -74
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +825 -75
- package/dist/index.js.map +1 -1
- package/dist/{react-email-BvJ3fj_F.d.cts → module-DC96HJa3.d.cts} +97 -2
- package/dist/{react-email-PLAJuZuO.d.ts → module-DbHlxpeR.d.ts} +97 -2
- package/dist/next/client.cjs +756 -40
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.d.cts +3 -4
- package/dist/next/client.d.ts +3 -4
- package/dist/next/client.js +756 -40
- package/dist/next/client.js.map +1 -1
- package/dist/next/server.cjs +756 -40
- package/dist/next/server.cjs.map +1 -1
- package/dist/next/server.d.cts +2 -2
- package/dist/next/server.d.ts +2 -2
- package/dist/next/server.js +756 -40
- package/dist/next/server.js.map +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +2 -3
- package/dist/react.d.ts +2 -3
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/{shared-BW6hoLBY.d.cts → shared-BMVGMnti.d.cts} +3 -1
- package/dist/{shared-BiJvoURI.d.ts → shared-DRptGBWP.d.ts} +3 -1
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -660,8 +660,8 @@ function deleteSessionCookie(ctx, skipDontRememberMe) {
|
|
|
660
660
|
expireCookie(ctx, ctx.context.authCookies.dontRememberToken);
|
|
661
661
|
}
|
|
662
662
|
}
|
|
663
|
-
var getSessionCookie = (
|
|
664
|
-
const cookies = (
|
|
663
|
+
var getSessionCookie = (request2, config) => {
|
|
664
|
+
const cookies = (request2 instanceof Headers || !("headers" in request2) ? request2 : request2.headers).get("cookie");
|
|
665
665
|
if (!cookies) {
|
|
666
666
|
return null;
|
|
667
667
|
}
|
|
@@ -681,8 +681,8 @@ var getSessionCookie = (request, config) => {
|
|
|
681
681
|
}
|
|
682
682
|
return null;
|
|
683
683
|
};
|
|
684
|
-
var getCookieCache = async (
|
|
685
|
-
const headers =
|
|
684
|
+
var getCookieCache = async (request2, config) => {
|
|
685
|
+
const headers = request2 instanceof Headers || !("headers" in request2) ? request2 : request2.headers;
|
|
686
686
|
const cookieHeader = headers.get("cookie");
|
|
687
687
|
if (!cookieHeader) {
|
|
688
688
|
return null;
|
|
@@ -800,7 +800,7 @@ var getCookieCache = async (request, config) => {
|
|
|
800
800
|
|
|
801
801
|
// package.json
|
|
802
802
|
var package_default = {
|
|
803
|
-
version: "2.
|
|
803
|
+
version: "2.10.0"
|
|
804
804
|
};
|
|
805
805
|
|
|
806
806
|
// src/sdk-version.ts
|
|
@@ -1852,6 +1852,50 @@ function mergeCallOptions(base, override) {
|
|
|
1852
1852
|
}
|
|
1853
1853
|
};
|
|
1854
1854
|
}
|
|
1855
|
+
function copyDefinedField(target, source, targetKey, sourceKey) {
|
|
1856
|
+
if (!(sourceKey in source)) {
|
|
1857
|
+
return;
|
|
1858
|
+
}
|
|
1859
|
+
const value = source[sourceKey];
|
|
1860
|
+
if (value !== void 0) {
|
|
1861
|
+
target[targetKey] = value;
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
function normalizeAdminEmailTemplatePayload(payload) {
|
|
1865
|
+
const normalized = { ...payload };
|
|
1866
|
+
copyDefinedField(normalized, payload, "template_key", "templateKey");
|
|
1867
|
+
copyDefinedField(normalized, payload, "event_type", "eventType");
|
|
1868
|
+
copyDefinedField(normalized, payload, "subject_template", "subjectTemplate");
|
|
1869
|
+
copyDefinedField(normalized, payload, "text_template", "textTemplate");
|
|
1870
|
+
copyDefinedField(normalized, payload, "html_template", "htmlTemplate");
|
|
1871
|
+
copyDefinedField(normalized, payload, "variable_bindings", "variableBindings");
|
|
1872
|
+
copyDefinedField(normalized, payload, "attachment_failure_mode", "attachmentFailureMode");
|
|
1873
|
+
copyDefinedField(normalized, payload, "is_active", "isActive");
|
|
1874
|
+
return normalized;
|
|
1875
|
+
}
|
|
1876
|
+
function toReactEmailTemplateCompatibilityInput(input) {
|
|
1877
|
+
const payload = input;
|
|
1878
|
+
const compatibility = { ...payload };
|
|
1879
|
+
copyDefinedField(compatibility, payload, "templateKey", "template_key");
|
|
1880
|
+
copyDefinedField(compatibility, payload, "eventType", "event_type");
|
|
1881
|
+
copyDefinedField(compatibility, payload, "subjectTemplate", "subject_template");
|
|
1882
|
+
copyDefinedField(compatibility, payload, "textTemplate", "text_template");
|
|
1883
|
+
copyDefinedField(compatibility, payload, "htmlTemplate", "html_template");
|
|
1884
|
+
copyDefinedField(compatibility, payload, "variableBindings", "variable_bindings");
|
|
1885
|
+
copyDefinedField(compatibility, payload, "attachmentFailureMode", "attachment_failure_mode");
|
|
1886
|
+
copyDefinedField(compatibility, payload, "isActive", "is_active");
|
|
1887
|
+
return compatibility;
|
|
1888
|
+
}
|
|
1889
|
+
function normalizeAdminEmailTemplateSendPayload(payload) {
|
|
1890
|
+
const normalized = { ...payload };
|
|
1891
|
+
copyDefinedField(normalized, payload, "template_id", "templateId");
|
|
1892
|
+
copyDefinedField(normalized, payload, "recipient_email", "recipientEmail");
|
|
1893
|
+
copyDefinedField(normalized, payload, "render_variables", "renderVariables");
|
|
1894
|
+
copyDefinedField(normalized, payload, "user_id", "userId");
|
|
1895
|
+
copyDefinedField(normalized, payload, "organization_id", "organizationId");
|
|
1896
|
+
copyDefinedField(normalized, payload, "session_token", "sessionToken");
|
|
1897
|
+
return normalized;
|
|
1898
|
+
}
|
|
1855
1899
|
function toSessionGuardFailure(sessionResult) {
|
|
1856
1900
|
if (sessionResult.status === 401 || sessionResult.data == null) {
|
|
1857
1901
|
return {
|
|
@@ -2158,7 +2202,7 @@ function createAuthClient(config = {}) {
|
|
|
2158
2202
|
...config,
|
|
2159
2203
|
baseUrl: normalizedBaseUrl
|
|
2160
2204
|
};
|
|
2161
|
-
const
|
|
2205
|
+
const request2 = (input, options) => {
|
|
2162
2206
|
const method = input.method ?? (input.body !== void 0 ? "POST" : inferDefaultMethod(input.endpoint));
|
|
2163
2207
|
const mergedOptions = mergeCallOptions(input.fetchOptions, options);
|
|
2164
2208
|
return callAuthEndpoint(
|
|
@@ -2171,7 +2215,7 @@ function createAuthClient(config = {}) {
|
|
|
2171
2215
|
};
|
|
2172
2216
|
const postGeneric = (endpoint, input, options) => {
|
|
2173
2217
|
const { payload, fetchOptions } = extractFetchOptions(input);
|
|
2174
|
-
return
|
|
2218
|
+
return request2(
|
|
2175
2219
|
{
|
|
2176
2220
|
endpoint,
|
|
2177
2221
|
method: "POST",
|
|
@@ -2183,7 +2227,7 @@ function createAuthClient(config = {}) {
|
|
|
2183
2227
|
};
|
|
2184
2228
|
const getGeneric = (endpoint, input, options) => {
|
|
2185
2229
|
const { fetchOptions } = extractFetchOptions(input);
|
|
2186
|
-
return
|
|
2230
|
+
return request2(
|
|
2187
2231
|
{
|
|
2188
2232
|
endpoint,
|
|
2189
2233
|
method: "GET",
|
|
@@ -2195,7 +2239,7 @@ function createAuthClient(config = {}) {
|
|
|
2195
2239
|
const getWithQuery = (endpoint, input, options) => {
|
|
2196
2240
|
const { payload, fetchOptions } = extractFetchOptions(input);
|
|
2197
2241
|
const query = payload?.query;
|
|
2198
|
-
return
|
|
2242
|
+
return request2(
|
|
2199
2243
|
{
|
|
2200
2244
|
endpoint,
|
|
2201
2245
|
method: "GET",
|
|
@@ -2213,18 +2257,19 @@ function createAuthClient(config = {}) {
|
|
|
2213
2257
|
htmlField: "htmlBody",
|
|
2214
2258
|
textField: "textBody"
|
|
2215
2259
|
}, withReactEmailRoute(route));
|
|
2216
|
-
const resolveAdminEmailTemplatePayload = (route, input) => resolveReactEmailPayloadFields(input, {
|
|
2260
|
+
const resolveAdminEmailTemplatePayload = (route, input) => resolveReactEmailPayloadFields(toReactEmailTemplateCompatibilityInput(input), {
|
|
2217
2261
|
htmlField: "htmlTemplate",
|
|
2218
2262
|
textField: "textTemplate",
|
|
2219
2263
|
variablesField: "variables"
|
|
2220
2264
|
}, withReactEmailRoute(route)).then((payload) => {
|
|
2265
|
+
const normalizedPayload = normalizeAdminEmailTemplatePayload(payload);
|
|
2221
2266
|
if ("variables" in payload && payload.variables !== void 0 && payload.variables !== null) {
|
|
2222
2267
|
assertAthenaAuthTemplateVariables(
|
|
2223
2268
|
payload.variables,
|
|
2224
2269
|
`${route} variables`
|
|
2225
2270
|
);
|
|
2226
2271
|
}
|
|
2227
|
-
return
|
|
2272
|
+
return normalizedPayload;
|
|
2228
2273
|
});
|
|
2229
2274
|
const requireSession = async (input, options) => {
|
|
2230
2275
|
const sessionInput = input?.fetchOptions ? { fetchOptions: input.fetchOptions } : void 0;
|
|
@@ -2800,7 +2845,15 @@ function createAuthClient(config = {}) {
|
|
|
2800
2845
|
await resolveAdminEmailTemplatePayload("/admin/email-template/update", input),
|
|
2801
2846
|
options
|
|
2802
2847
|
),
|
|
2803
|
-
delete: (input, options) => postGeneric("/admin/email-template/delete", input, options)
|
|
2848
|
+
delete: (input, options) => postGeneric("/admin/email-template/delete", input, options),
|
|
2849
|
+
send: (input, options) => postGeneric(
|
|
2850
|
+
"/admin/email-template/send",
|
|
2851
|
+
normalizeAdminEmailTemplateSendPayload(extractFetchOptions(input).payload),
|
|
2852
|
+
options
|
|
2853
|
+
)
|
|
2854
|
+
},
|
|
2855
|
+
eventType: {
|
|
2856
|
+
list: (input, options) => getWithQuery("/admin/email-event-type/list", input, options)
|
|
2804
2857
|
}
|
|
2805
2858
|
},
|
|
2806
2859
|
emailTemplate: {
|
|
@@ -2816,7 +2869,15 @@ function createAuthClient(config = {}) {
|
|
|
2816
2869
|
"/admin/email-template/update",
|
|
2817
2870
|
await resolveAdminEmailTemplatePayload("/admin/email-template/update", input),
|
|
2818
2871
|
options
|
|
2872
|
+
),
|
|
2873
|
+
send: (input, options) => postGeneric(
|
|
2874
|
+
"/admin/email-template/send",
|
|
2875
|
+
normalizeAdminEmailTemplateSendPayload(extractFetchOptions(input).payload),
|
|
2876
|
+
options
|
|
2819
2877
|
)
|
|
2878
|
+
},
|
|
2879
|
+
emailEventType: {
|
|
2880
|
+
list: (input, options) => getWithQuery("/admin/email-event-type/list", input, options)
|
|
2820
2881
|
}
|
|
2821
2882
|
},
|
|
2822
2883
|
apiKey: {
|
|
@@ -2856,7 +2917,7 @@ function createAuthClient(config = {}) {
|
|
|
2856
2917
|
throw new Error("callback.provider requires non-empty code and state values");
|
|
2857
2918
|
}
|
|
2858
2919
|
const endpoint = `/callback/${encodeURIComponent(provider)}`;
|
|
2859
|
-
return
|
|
2920
|
+
return request2({
|
|
2860
2921
|
endpoint,
|
|
2861
2922
|
method: "GET",
|
|
2862
2923
|
query: {
|
|
@@ -2870,7 +2931,7 @@ function createAuthClient(config = {}) {
|
|
|
2870
2931
|
};
|
|
2871
2932
|
return {
|
|
2872
2933
|
baseUrl: normalizedBaseUrl,
|
|
2873
|
-
request,
|
|
2934
|
+
request: request2,
|
|
2874
2935
|
signIn: {
|
|
2875
2936
|
email: (input, options) => executePostWithCompatibleInput(
|
|
2876
2937
|
resolvedConfig,
|
|
@@ -3611,16 +3672,16 @@ function createStorageFileModule(base, config = {}) {
|
|
|
3611
3672
|
};
|
|
3612
3673
|
});
|
|
3613
3674
|
input.onProgress?.(createProgressSnapshot("preparing", sources, 0, 0, 0));
|
|
3614
|
-
const uploadUrls = uploadRequests.length === 1 ? [await base.createStorageUploadUrl(uploadRequests[0].uploadRequest, options)] : (await base.createStorageUploadUrls({ files: uploadRequests.map((
|
|
3675
|
+
const uploadUrls = uploadRequests.length === 1 ? [await base.createStorageUploadUrl(uploadRequests[0].uploadRequest, options)] : (await base.createStorageUploadUrls({ files: uploadRequests.map((request2) => request2.uploadRequest) }, options)).files;
|
|
3615
3676
|
const aggregateLoaded = new Array(uploadRequests.length).fill(0);
|
|
3616
3677
|
const uploaded = [];
|
|
3617
3678
|
for (let index = 0; index < uploadRequests.length; index += 1) {
|
|
3618
|
-
const
|
|
3679
|
+
const request2 = uploadRequests[index];
|
|
3619
3680
|
const uploadUrl = uploadUrls[index];
|
|
3620
3681
|
const response = await putUploadBody(
|
|
3621
3682
|
uploadUrl.upload.url,
|
|
3622
3683
|
uploadUrl.upload.headers ?? {},
|
|
3623
|
-
|
|
3684
|
+
request2.source,
|
|
3624
3685
|
input,
|
|
3625
3686
|
options,
|
|
3626
3687
|
(progress) => {
|
|
@@ -3631,13 +3692,13 @@ function createStorageFileModule(base, config = {}) {
|
|
|
3631
3692
|
uploaded.push({
|
|
3632
3693
|
file: uploadUrl.file,
|
|
3633
3694
|
upload: uploadUrl.upload,
|
|
3634
|
-
source:
|
|
3635
|
-
fileName:
|
|
3636
|
-
storage_key:
|
|
3695
|
+
source: request2.source.source,
|
|
3696
|
+
fileName: request2.source.fileName,
|
|
3697
|
+
storage_key: request2.uploadRequest.storage_key,
|
|
3637
3698
|
response
|
|
3638
3699
|
});
|
|
3639
|
-
aggregateLoaded[index] =
|
|
3640
|
-
input.onProgress?.(createProgressSnapshot("complete", sources, index,
|
|
3700
|
+
aggregateLoaded[index] = request2.source.sizeBytes;
|
|
3701
|
+
input.onProgress?.(createProgressSnapshot("complete", sources, index, request2.source.sizeBytes, sum(aggregateLoaded)));
|
|
3641
3702
|
}
|
|
3642
3703
|
return {
|
|
3643
3704
|
files: uploaded,
|
|
@@ -5612,6 +5673,517 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5612
5673
|
};
|
|
5613
5674
|
}
|
|
5614
5675
|
|
|
5676
|
+
// src/chat/module.ts
|
|
5677
|
+
var SDK_NAME3 = "xylex-group/athena-chat";
|
|
5678
|
+
var SDK_HEADER_VALUE3 = buildSdkHeaderValue(SDK_NAME3);
|
|
5679
|
+
var NO_CACHE_HEADER_VALUE3 = "no-cache";
|
|
5680
|
+
var AthenaChatError = class extends Error {
|
|
5681
|
+
status;
|
|
5682
|
+
endpoint;
|
|
5683
|
+
method;
|
|
5684
|
+
requestId;
|
|
5685
|
+
body;
|
|
5686
|
+
constructor(input) {
|
|
5687
|
+
super(input.message);
|
|
5688
|
+
this.name = "AthenaChatError";
|
|
5689
|
+
this.status = input.status;
|
|
5690
|
+
this.endpoint = input.endpoint;
|
|
5691
|
+
this.method = input.method;
|
|
5692
|
+
this.requestId = input.requestId;
|
|
5693
|
+
this.body = input.body;
|
|
5694
|
+
}
|
|
5695
|
+
};
|
|
5696
|
+
function deriveRealtimeInfoUrl(wsUrl) {
|
|
5697
|
+
if (!wsUrl) {
|
|
5698
|
+
return void 0;
|
|
5699
|
+
}
|
|
5700
|
+
const parsed = new URL(normalizeWsUrl(wsUrl, "Athena chat WebSocket URL"));
|
|
5701
|
+
parsed.protocol = parsed.protocol === "wss:" ? "https:" : "http:";
|
|
5702
|
+
parsed.pathname = parsed.pathname.replace(/\/wss\/gateway$/, "/wss/info");
|
|
5703
|
+
return parsed.toString();
|
|
5704
|
+
}
|
|
5705
|
+
function normalizeWsUrl(value, label) {
|
|
5706
|
+
const normalized = value.trim();
|
|
5707
|
+
if (!normalized) {
|
|
5708
|
+
throw new Error(`${label} is required.`);
|
|
5709
|
+
}
|
|
5710
|
+
let parsed;
|
|
5711
|
+
try {
|
|
5712
|
+
parsed = new URL(normalized);
|
|
5713
|
+
} catch {
|
|
5714
|
+
throw new Error(`${label} must be a valid absolute ws(s) URL.`);
|
|
5715
|
+
}
|
|
5716
|
+
if (parsed.protocol !== "ws:" && parsed.protocol !== "wss:") {
|
|
5717
|
+
throw new Error(`${label} must use ws or wss.`);
|
|
5718
|
+
}
|
|
5719
|
+
parsed.pathname = parsed.pathname.replace(/\/+$/, "");
|
|
5720
|
+
return parsed.toString().replace(/\/$/, "");
|
|
5721
|
+
}
|
|
5722
|
+
function isRecord7(value) {
|
|
5723
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
5724
|
+
}
|
|
5725
|
+
function normalizeHeaderValue3(value) {
|
|
5726
|
+
return value ? value : void 0;
|
|
5727
|
+
}
|
|
5728
|
+
function parseResponseBody4(rawText, contentType) {
|
|
5729
|
+
if (!rawText) {
|
|
5730
|
+
return { parsed: null, parseFailed: false };
|
|
5731
|
+
}
|
|
5732
|
+
const contentTypeSuggestsJson = contentType?.toLowerCase().includes("application/json") ?? false;
|
|
5733
|
+
const looksJson = contentTypeSuggestsJson || rawText.startsWith("{") || rawText.startsWith("[");
|
|
5734
|
+
if (!looksJson) {
|
|
5735
|
+
return { parsed: rawText, parseFailed: false };
|
|
5736
|
+
}
|
|
5737
|
+
try {
|
|
5738
|
+
return { parsed: JSON.parse(rawText), parseFailed: false };
|
|
5739
|
+
} catch {
|
|
5740
|
+
return { parsed: rawText, parseFailed: true };
|
|
5741
|
+
}
|
|
5742
|
+
}
|
|
5743
|
+
function resolveRequestId3(headers) {
|
|
5744
|
+
return headers.get("x-request-id") ?? headers.get("x-correlation-id") ?? headers.get("x-athena-request-id") ?? void 0;
|
|
5745
|
+
}
|
|
5746
|
+
function resolveErrorMessage4(payload, fallback) {
|
|
5747
|
+
if (isRecord7(payload)) {
|
|
5748
|
+
for (const candidate of [payload.error, payload.message, payload.details]) {
|
|
5749
|
+
if (typeof candidate === "string" && candidate.trim().length > 0) {
|
|
5750
|
+
return candidate.trim();
|
|
5751
|
+
}
|
|
5752
|
+
}
|
|
5753
|
+
}
|
|
5754
|
+
if (typeof payload === "string" && payload.trim().length > 0) {
|
|
5755
|
+
return payload.trim();
|
|
5756
|
+
}
|
|
5757
|
+
return fallback;
|
|
5758
|
+
}
|
|
5759
|
+
function encodePathSegment(value, label) {
|
|
5760
|
+
const normalized = value.trim();
|
|
5761
|
+
if (!normalized) {
|
|
5762
|
+
throw new Error(`${label} is required.`);
|
|
5763
|
+
}
|
|
5764
|
+
return encodeURIComponent(normalized);
|
|
5765
|
+
}
|
|
5766
|
+
function encodeQuery(query) {
|
|
5767
|
+
if (!query) {
|
|
5768
|
+
return "";
|
|
5769
|
+
}
|
|
5770
|
+
const params = new URLSearchParams();
|
|
5771
|
+
for (const [key, value] of Object.entries(query)) {
|
|
5772
|
+
if (value === void 0 || value === null) {
|
|
5773
|
+
continue;
|
|
5774
|
+
}
|
|
5775
|
+
if (Array.isArray(value)) {
|
|
5776
|
+
for (const item of value) {
|
|
5777
|
+
if (item !== void 0 && item !== null) {
|
|
5778
|
+
params.append(key, String(item));
|
|
5779
|
+
}
|
|
5780
|
+
}
|
|
5781
|
+
continue;
|
|
5782
|
+
}
|
|
5783
|
+
params.set(key, String(value));
|
|
5784
|
+
}
|
|
5785
|
+
const encoded = params.toString();
|
|
5786
|
+
return encoded ? `?${encoded}` : "";
|
|
5787
|
+
}
|
|
5788
|
+
function createSocket(factory, url, protocols) {
|
|
5789
|
+
try {
|
|
5790
|
+
return new factory(url, protocols);
|
|
5791
|
+
} catch (error) {
|
|
5792
|
+
if (error instanceof TypeError) {
|
|
5793
|
+
return factory(url, protocols);
|
|
5794
|
+
}
|
|
5795
|
+
throw error;
|
|
5796
|
+
}
|
|
5797
|
+
}
|
|
5798
|
+
function buildHeaders3(config, options) {
|
|
5799
|
+
const headers = {
|
|
5800
|
+
Accept: "application/json",
|
|
5801
|
+
apikey: config.apiKey,
|
|
5802
|
+
"x-api-key": config.apiKey,
|
|
5803
|
+
"X-Athena-Sdk": SDK_HEADER_VALUE3
|
|
5804
|
+
};
|
|
5805
|
+
if (config.client || options?.client) {
|
|
5806
|
+
headers["X-Athena-Client"] = options?.client ?? config.client ?? "";
|
|
5807
|
+
}
|
|
5808
|
+
const bearerToken = options?.bearerToken ?? config.bearerToken;
|
|
5809
|
+
if (typeof bearerToken === "string" && bearerToken.trim()) {
|
|
5810
|
+
headers.Authorization = bearerToken.startsWith("Bearer ") ? bearerToken : `Bearer ${bearerToken}`;
|
|
5811
|
+
}
|
|
5812
|
+
const cookie = options?.cookie ?? config.cookie;
|
|
5813
|
+
if (typeof cookie === "string" && cookie.trim()) {
|
|
5814
|
+
headers.Cookie = cookie;
|
|
5815
|
+
}
|
|
5816
|
+
const sessionToken = options?.sessionToken ?? config.sessionToken;
|
|
5817
|
+
if (typeof sessionToken === "string" && sessionToken.trim()) {
|
|
5818
|
+
headers["X-Athena-Auth-Session-Token"] = sessionToken;
|
|
5819
|
+
}
|
|
5820
|
+
if (config.forceNoCache || options?.forceNoCache) {
|
|
5821
|
+
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE3;
|
|
5822
|
+
}
|
|
5823
|
+
for (const source of [config.headers, options?.headers]) {
|
|
5824
|
+
for (const [key, value] of Object.entries(source ?? {})) {
|
|
5825
|
+
const normalized = normalizeHeaderValue3(value);
|
|
5826
|
+
if (normalized) {
|
|
5827
|
+
headers[key] = normalized;
|
|
5828
|
+
}
|
|
5829
|
+
}
|
|
5830
|
+
}
|
|
5831
|
+
return headers;
|
|
5832
|
+
}
|
|
5833
|
+
function withJsonBody(init, body) {
|
|
5834
|
+
return {
|
|
5835
|
+
...init,
|
|
5836
|
+
body: body === void 0 ? void 0 : JSON.stringify(body),
|
|
5837
|
+
headers: {
|
|
5838
|
+
"Content-Type": "application/json",
|
|
5839
|
+
...init.headers
|
|
5840
|
+
}
|
|
5841
|
+
};
|
|
5842
|
+
}
|
|
5843
|
+
async function request(config, method, endpoint, options, body) {
|
|
5844
|
+
if (!config.baseUrl) {
|
|
5845
|
+
throw new Error(
|
|
5846
|
+
"Athena chat base URL is not configured. Pass createClient({ url }) for unified routing or set chat.url / chatUrl explicitly."
|
|
5847
|
+
);
|
|
5848
|
+
}
|
|
5849
|
+
const url = `${config.baseUrl}${endpoint}`;
|
|
5850
|
+
const init = {
|
|
5851
|
+
method,
|
|
5852
|
+
headers: buildHeaders3(config, options),
|
|
5853
|
+
signal: options?.signal
|
|
5854
|
+
};
|
|
5855
|
+
const finalInit = body === void 0 || method === "GET" ? init : withJsonBody(init, body);
|
|
5856
|
+
const response = await fetch(url, finalInit);
|
|
5857
|
+
const rawText = await response.text();
|
|
5858
|
+
const { parsed } = parseResponseBody4(rawText, response.headers.get("content-type"));
|
|
5859
|
+
if (!response.ok) {
|
|
5860
|
+
throw new AthenaChatError({
|
|
5861
|
+
message: resolveErrorMessage4(parsed, `Athena chat ${method} ${endpoint} failed with ${response.status}`),
|
|
5862
|
+
status: response.status,
|
|
5863
|
+
endpoint,
|
|
5864
|
+
method,
|
|
5865
|
+
requestId: resolveRequestId3(response.headers),
|
|
5866
|
+
body: parsed
|
|
5867
|
+
});
|
|
5868
|
+
}
|
|
5869
|
+
return parsed;
|
|
5870
|
+
}
|
|
5871
|
+
function unwrapEnvelopeData(payload) {
|
|
5872
|
+
return payload.data;
|
|
5873
|
+
}
|
|
5874
|
+
function createRealtimeConnection(config, options) {
|
|
5875
|
+
if (!config.wsUrl) {
|
|
5876
|
+
throw new Error(
|
|
5877
|
+
"Athena chat WebSocket URL is not configured. Pass createClient({ url }) for unified routing or set chat.wsUrl / chatWsUrl explicitly."
|
|
5878
|
+
);
|
|
5879
|
+
}
|
|
5880
|
+
const wsFactory = config.webSocketFactory ?? globalThis.WebSocket;
|
|
5881
|
+
if (!wsFactory) {
|
|
5882
|
+
throw new Error(
|
|
5883
|
+
"No WebSocket implementation is available. Provide chat.webSocketFactory in createClient(...) or run in a runtime with global WebSocket support."
|
|
5884
|
+
);
|
|
5885
|
+
}
|
|
5886
|
+
const socket = createSocket(wsFactory, config.wsUrl, options?.protocols);
|
|
5887
|
+
const send = (command) => {
|
|
5888
|
+
socket.send(JSON.stringify(command));
|
|
5889
|
+
};
|
|
5890
|
+
if (options?.onMessage) {
|
|
5891
|
+
const listener = (event) => {
|
|
5892
|
+
const messageEvent = event;
|
|
5893
|
+
const raw = messageEvent?.data;
|
|
5894
|
+
if (typeof raw !== "string") {
|
|
5895
|
+
return;
|
|
5896
|
+
}
|
|
5897
|
+
try {
|
|
5898
|
+
options.onMessage?.(JSON.parse(raw));
|
|
5899
|
+
} catch {
|
|
5900
|
+
options.onMessage?.({ type: "error", error: "Invalid JSON message from Athena chat realtime gateway." });
|
|
5901
|
+
}
|
|
5902
|
+
};
|
|
5903
|
+
if (typeof socket.addEventListener === "function") {
|
|
5904
|
+
socket.addEventListener("message", listener);
|
|
5905
|
+
} else {
|
|
5906
|
+
socket.onmessage = listener;
|
|
5907
|
+
}
|
|
5908
|
+
}
|
|
5909
|
+
const hello = (command) => {
|
|
5910
|
+
send({
|
|
5911
|
+
type: "auth.hello",
|
|
5912
|
+
token: command?.token,
|
|
5913
|
+
room_subscriptions: command?.room_subscriptions
|
|
5914
|
+
});
|
|
5915
|
+
};
|
|
5916
|
+
if (options?.hello) {
|
|
5917
|
+
const onOpen = () => hello({
|
|
5918
|
+
token: options.hello?.token ?? void 0,
|
|
5919
|
+
room_subscriptions: options.hello?.room_subscriptions ?? void 0
|
|
5920
|
+
});
|
|
5921
|
+
if (typeof socket.addEventListener === "function") {
|
|
5922
|
+
socket.addEventListener("open", onOpen);
|
|
5923
|
+
} else {
|
|
5924
|
+
socket.onopen = onOpen;
|
|
5925
|
+
}
|
|
5926
|
+
}
|
|
5927
|
+
return {
|
|
5928
|
+
socket,
|
|
5929
|
+
send,
|
|
5930
|
+
hello,
|
|
5931
|
+
subscribe(roomId, fromSeq) {
|
|
5932
|
+
send({
|
|
5933
|
+
type: "chat.subscribe",
|
|
5934
|
+
room_id: roomId,
|
|
5935
|
+
from_seq: fromSeq ?? void 0
|
|
5936
|
+
});
|
|
5937
|
+
},
|
|
5938
|
+
unsubscribe(roomId) {
|
|
5939
|
+
send({
|
|
5940
|
+
type: "chat.unsubscribe",
|
|
5941
|
+
room_id: roomId
|
|
5942
|
+
});
|
|
5943
|
+
},
|
|
5944
|
+
resume(rooms) {
|
|
5945
|
+
send({
|
|
5946
|
+
type: "chat.resume",
|
|
5947
|
+
rooms
|
|
5948
|
+
});
|
|
5949
|
+
},
|
|
5950
|
+
typingStart(roomId) {
|
|
5951
|
+
send({
|
|
5952
|
+
type: "chat.typing.start",
|
|
5953
|
+
room_id: roomId
|
|
5954
|
+
});
|
|
5955
|
+
},
|
|
5956
|
+
typingStop(roomId) {
|
|
5957
|
+
send({
|
|
5958
|
+
type: "chat.typing.stop",
|
|
5959
|
+
room_id: roomId
|
|
5960
|
+
});
|
|
5961
|
+
},
|
|
5962
|
+
presenceHeartbeat(activeRoomId) {
|
|
5963
|
+
send({
|
|
5964
|
+
type: "chat.presence.heartbeat",
|
|
5965
|
+
active_room_id: activeRoomId ?? void 0
|
|
5966
|
+
});
|
|
5967
|
+
},
|
|
5968
|
+
readUpTo(roomId, input) {
|
|
5969
|
+
send({
|
|
5970
|
+
type: "chat.read.up_to",
|
|
5971
|
+
room_id: roomId,
|
|
5972
|
+
message_id: input?.message_id ?? void 0,
|
|
5973
|
+
seq: input?.seq ?? void 0
|
|
5974
|
+
});
|
|
5975
|
+
},
|
|
5976
|
+
ping(at = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
5977
|
+
send({
|
|
5978
|
+
type: "ping",
|
|
5979
|
+
at
|
|
5980
|
+
});
|
|
5981
|
+
},
|
|
5982
|
+
close(code, reason) {
|
|
5983
|
+
socket.close(code, reason);
|
|
5984
|
+
}
|
|
5985
|
+
};
|
|
5986
|
+
}
|
|
5987
|
+
function createChatModule(config) {
|
|
5988
|
+
const realtime = {
|
|
5989
|
+
info(options) {
|
|
5990
|
+
const realtimeInfoUrl = config.realtimeInfoUrl ?? deriveRealtimeInfoUrl(config.wsUrl);
|
|
5991
|
+
if (!realtimeInfoUrl) {
|
|
5992
|
+
throw new Error(
|
|
5993
|
+
"Athena chat realtime info URL is not configured. Pass createClient({ url }) for unified routing or set chat.wsUrl / chatWsUrl explicitly."
|
|
5994
|
+
);
|
|
5995
|
+
}
|
|
5996
|
+
return request(
|
|
5997
|
+
{
|
|
5998
|
+
...config,
|
|
5999
|
+
baseUrl: realtimeInfoUrl
|
|
6000
|
+
},
|
|
6001
|
+
"GET",
|
|
6002
|
+
"",
|
|
6003
|
+
options
|
|
6004
|
+
);
|
|
6005
|
+
},
|
|
6006
|
+
connect(options) {
|
|
6007
|
+
return createRealtimeConnection(config, options);
|
|
6008
|
+
}
|
|
6009
|
+
};
|
|
6010
|
+
return {
|
|
6011
|
+
room: {
|
|
6012
|
+
list(query, options) {
|
|
6013
|
+
return request(
|
|
6014
|
+
config,
|
|
6015
|
+
"GET",
|
|
6016
|
+
`/rooms${encodeQuery(query)}`,
|
|
6017
|
+
options
|
|
6018
|
+
);
|
|
6019
|
+
},
|
|
6020
|
+
create(input, options) {
|
|
6021
|
+
return request(config, "POST", "/rooms", options, input);
|
|
6022
|
+
},
|
|
6023
|
+
get(roomId, options) {
|
|
6024
|
+
return request(
|
|
6025
|
+
config,
|
|
6026
|
+
"GET",
|
|
6027
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}`,
|
|
6028
|
+
options
|
|
6029
|
+
);
|
|
6030
|
+
},
|
|
6031
|
+
update(roomId, input, options) {
|
|
6032
|
+
return request(
|
|
6033
|
+
config,
|
|
6034
|
+
"PATCH",
|
|
6035
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}`,
|
|
6036
|
+
options,
|
|
6037
|
+
input
|
|
6038
|
+
);
|
|
6039
|
+
},
|
|
6040
|
+
archive(roomId, options) {
|
|
6041
|
+
return request(
|
|
6042
|
+
config,
|
|
6043
|
+
"POST",
|
|
6044
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/archive`,
|
|
6045
|
+
options
|
|
6046
|
+
);
|
|
6047
|
+
},
|
|
6048
|
+
readCursor: {
|
|
6049
|
+
upTo(roomId, input, options) {
|
|
6050
|
+
return request(
|
|
6051
|
+
config,
|
|
6052
|
+
"POST",
|
|
6053
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/read-cursor`,
|
|
6054
|
+
options,
|
|
6055
|
+
input ?? {}
|
|
6056
|
+
);
|
|
6057
|
+
}
|
|
6058
|
+
},
|
|
6059
|
+
member: {
|
|
6060
|
+
list(roomId, options) {
|
|
6061
|
+
return request(
|
|
6062
|
+
config,
|
|
6063
|
+
"GET",
|
|
6064
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/members`,
|
|
6065
|
+
options
|
|
6066
|
+
);
|
|
6067
|
+
},
|
|
6068
|
+
add(roomId, input, options) {
|
|
6069
|
+
return request(
|
|
6070
|
+
config,
|
|
6071
|
+
"POST",
|
|
6072
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/members`,
|
|
6073
|
+
options,
|
|
6074
|
+
input
|
|
6075
|
+
);
|
|
6076
|
+
},
|
|
6077
|
+
remove(roomId, userId, options) {
|
|
6078
|
+
return request(
|
|
6079
|
+
config,
|
|
6080
|
+
"DELETE",
|
|
6081
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/members/${encodePathSegment(userId, "chat user ID")}`,
|
|
6082
|
+
options
|
|
6083
|
+
);
|
|
6084
|
+
}
|
|
6085
|
+
},
|
|
6086
|
+
message: {
|
|
6087
|
+
list(roomId, query, options) {
|
|
6088
|
+
return request(
|
|
6089
|
+
config,
|
|
6090
|
+
"GET",
|
|
6091
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/messages${encodeQuery(query)}`,
|
|
6092
|
+
options
|
|
6093
|
+
);
|
|
6094
|
+
},
|
|
6095
|
+
send(roomId, input, options) {
|
|
6096
|
+
return request(
|
|
6097
|
+
config,
|
|
6098
|
+
"POST",
|
|
6099
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/messages`,
|
|
6100
|
+
options,
|
|
6101
|
+
input
|
|
6102
|
+
);
|
|
6103
|
+
},
|
|
6104
|
+
update(roomId, messageId, input, options) {
|
|
6105
|
+
return request(
|
|
6106
|
+
config,
|
|
6107
|
+
"PATCH",
|
|
6108
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/messages/${encodePathSegment(messageId, "chat message ID")}`,
|
|
6109
|
+
options,
|
|
6110
|
+
input
|
|
6111
|
+
);
|
|
6112
|
+
},
|
|
6113
|
+
delete(roomId, messageId, options) {
|
|
6114
|
+
return request(
|
|
6115
|
+
config,
|
|
6116
|
+
"DELETE",
|
|
6117
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/messages/${encodePathSegment(messageId, "chat message ID")}`,
|
|
6118
|
+
options
|
|
6119
|
+
);
|
|
6120
|
+
}
|
|
6121
|
+
}
|
|
6122
|
+
},
|
|
6123
|
+
message: {
|
|
6124
|
+
reaction: {
|
|
6125
|
+
add(messageId, input, options) {
|
|
6126
|
+
return request(
|
|
6127
|
+
config,
|
|
6128
|
+
"POST",
|
|
6129
|
+
`/messages/${encodePathSegment(messageId, "chat message ID")}/reactions`,
|
|
6130
|
+
options,
|
|
6131
|
+
input
|
|
6132
|
+
);
|
|
6133
|
+
},
|
|
6134
|
+
remove(messageId, emoji, options) {
|
|
6135
|
+
return request(
|
|
6136
|
+
config,
|
|
6137
|
+
"DELETE",
|
|
6138
|
+
`/messages/${encodePathSegment(messageId, "chat message ID")}/reactions/${encodePathSegment(emoji, "reaction emoji")}`,
|
|
6139
|
+
options
|
|
6140
|
+
);
|
|
6141
|
+
}
|
|
6142
|
+
},
|
|
6143
|
+
search(input, options) {
|
|
6144
|
+
return request(
|
|
6145
|
+
config,
|
|
6146
|
+
"POST",
|
|
6147
|
+
"/messages/search",
|
|
6148
|
+
options,
|
|
6149
|
+
input
|
|
6150
|
+
);
|
|
6151
|
+
}
|
|
6152
|
+
},
|
|
6153
|
+
realtime
|
|
6154
|
+
};
|
|
6155
|
+
}
|
|
6156
|
+
var chatSdkManifest = {
|
|
6157
|
+
namespace: "chat",
|
|
6158
|
+
basePath: "/chat",
|
|
6159
|
+
methods: [
|
|
6160
|
+
{ name: "listRooms", method: "GET", path: "/chat/rooms" },
|
|
6161
|
+
{ name: "createRoom", method: "POST", path: "/chat/rooms" },
|
|
6162
|
+
{ name: "getRoom", method: "GET", path: "/chat/rooms/{room_id}" },
|
|
6163
|
+
{ name: "updateRoom", method: "PATCH", path: "/chat/rooms/{room_id}" },
|
|
6164
|
+
{ name: "archiveRoom", method: "POST", path: "/chat/rooms/{room_id}/archive" },
|
|
6165
|
+
{ name: "listRoomMessages", method: "GET", path: "/chat/rooms/{room_id}/messages" },
|
|
6166
|
+
{ name: "sendRoomMessage", method: "POST", path: "/chat/rooms/{room_id}/messages" },
|
|
6167
|
+
{ name: "updateRoomMessage", method: "PATCH", path: "/chat/rooms/{room_id}/messages/{message_id}" },
|
|
6168
|
+
{ name: "deleteRoomMessage", method: "DELETE", path: "/chat/rooms/{room_id}/messages/{message_id}" },
|
|
6169
|
+
{ name: "advanceReadCursor", method: "POST", path: "/chat/rooms/{room_id}/read-cursor" },
|
|
6170
|
+
{ name: "listRoomMembers", method: "GET", path: "/chat/rooms/{room_id}/members" },
|
|
6171
|
+
{ name: "addRoomMembers", method: "POST", path: "/chat/rooms/{room_id}/members" },
|
|
6172
|
+
{ name: "removeRoomMember", method: "DELETE", path: "/chat/rooms/{room_id}/members/{user_id}" },
|
|
6173
|
+
{ name: "addReaction", method: "POST", path: "/chat/messages/{message_id}/reactions" },
|
|
6174
|
+
{ name: "removeReaction", method: "DELETE", path: "/chat/messages/{message_id}/reactions/{emoji}" },
|
|
6175
|
+
{ name: "searchMessages", method: "POST", path: "/chat/messages/search" },
|
|
6176
|
+
{ name: "getRealtimeInfo", method: "GET", path: "/wss/info" },
|
|
6177
|
+
{ name: "connectRealtime", method: "GET", path: "/wss/gateway" }
|
|
6178
|
+
]
|
|
6179
|
+
};
|
|
6180
|
+
function unwrapChatRoom(payload) {
|
|
6181
|
+
return unwrapEnvelopeData(payload);
|
|
6182
|
+
}
|
|
6183
|
+
function unwrapChatMessage(payload) {
|
|
6184
|
+
return unwrapEnvelopeData(payload);
|
|
6185
|
+
}
|
|
6186
|
+
|
|
5615
6187
|
// src/client-builder.ts
|
|
5616
6188
|
var DEFAULT_BACKEND = { type: "athena" };
|
|
5617
6189
|
function toBackendConfig(value) {
|
|
@@ -5824,7 +6396,7 @@ var BOOLEAN_SAFE_OPERATORS = /* @__PURE__ */ new Set([
|
|
|
5824
6396
|
"ilike",
|
|
5825
6397
|
"is"
|
|
5826
6398
|
]);
|
|
5827
|
-
function
|
|
6399
|
+
function isRecord8(value) {
|
|
5828
6400
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
5829
6401
|
}
|
|
5830
6402
|
function isUuidString(value) {
|
|
@@ -5837,7 +6409,7 @@ function shouldUseUuidTextComparison(column, value) {
|
|
|
5837
6409
|
return typeof value === "string" && isUuidString(value) && isUuidIdentifierColumn(column);
|
|
5838
6410
|
}
|
|
5839
6411
|
function isRelationSelectNode(value) {
|
|
5840
|
-
return
|
|
6412
|
+
return isRecord8(value) && isRecord8(value.select);
|
|
5841
6413
|
}
|
|
5842
6414
|
function normalizeIdentifier(value, label) {
|
|
5843
6415
|
const normalized = value.trim();
|
|
@@ -5893,7 +6465,7 @@ function compileRelationToken(key, node) {
|
|
|
5893
6465
|
return `${prefix}${relationToken}(${nested})`;
|
|
5894
6466
|
}
|
|
5895
6467
|
function compileSelectShape(select) {
|
|
5896
|
-
if (!
|
|
6468
|
+
if (!isRecord8(select)) {
|
|
5897
6469
|
throw new Error("findMany select must be an object");
|
|
5898
6470
|
}
|
|
5899
6471
|
const tokens = [];
|
|
@@ -5917,7 +6489,7 @@ function compileSelectShape(select) {
|
|
|
5917
6489
|
return tokens.join(",");
|
|
5918
6490
|
}
|
|
5919
6491
|
function selectShapeUsesRelationSchema(select) {
|
|
5920
|
-
if (!
|
|
6492
|
+
if (!isRecord8(select)) {
|
|
5921
6493
|
return false;
|
|
5922
6494
|
}
|
|
5923
6495
|
for (const rawValue of Object.values(select)) {
|
|
@@ -5935,7 +6507,7 @@ function selectShapeUsesRelationSchema(select) {
|
|
|
5935
6507
|
}
|
|
5936
6508
|
function compileColumnWhere(column, input) {
|
|
5937
6509
|
const normalizedColumn = normalizeIdentifier(column, "where column");
|
|
5938
|
-
if (!
|
|
6510
|
+
if (!isRecord8(input)) {
|
|
5939
6511
|
return [buildGatewayCondition("eq", normalizedColumn, input)];
|
|
5940
6512
|
}
|
|
5941
6513
|
const conditions = [];
|
|
@@ -5963,7 +6535,7 @@ function compileColumnWhere(column, input) {
|
|
|
5963
6535
|
return conditions;
|
|
5964
6536
|
}
|
|
5965
6537
|
function compileBooleanExpressionTerms(clause, label) {
|
|
5966
|
-
if (!
|
|
6538
|
+
if (!isRecord8(clause)) {
|
|
5967
6539
|
throw new Error(`findMany where.${label} clauses must be objects`);
|
|
5968
6540
|
}
|
|
5969
6541
|
const entries = Object.entries(clause).filter(([, value]) => value !== void 0);
|
|
@@ -5972,7 +6544,7 @@ function compileBooleanExpressionTerms(clause, label) {
|
|
|
5972
6544
|
}
|
|
5973
6545
|
const [rawColumn, rawValue] = entries[0];
|
|
5974
6546
|
const column = normalizeIdentifier(rawColumn, `where.${label} column`);
|
|
5975
|
-
if (!
|
|
6547
|
+
if (!isRecord8(rawValue)) {
|
|
5976
6548
|
return [`${column}.eq.${stringifyFilterValue(rawValue)}`];
|
|
5977
6549
|
}
|
|
5978
6550
|
const operatorEntries = Object.entries(rawValue).filter(([, value]) => value !== void 0);
|
|
@@ -5996,7 +6568,7 @@ function compileWhere(where) {
|
|
|
5996
6568
|
if (where === void 0) {
|
|
5997
6569
|
return void 0;
|
|
5998
6570
|
}
|
|
5999
|
-
if (!
|
|
6571
|
+
if (!isRecord8(where)) {
|
|
6000
6572
|
throw new Error("findMany where must be an object");
|
|
6001
6573
|
}
|
|
6002
6574
|
const conditions = [];
|
|
@@ -6046,7 +6618,7 @@ function compileOrderBy(orderBy) {
|
|
|
6046
6618
|
if (orderBy === void 0) {
|
|
6047
6619
|
return void 0;
|
|
6048
6620
|
}
|
|
6049
|
-
if (!
|
|
6621
|
+
if (!isRecord8(orderBy)) {
|
|
6050
6622
|
throw new Error("findMany orderBy must be an object");
|
|
6051
6623
|
}
|
|
6052
6624
|
if ("column" in orderBy) {
|
|
@@ -6221,11 +6793,11 @@ function toFindManyAstOrder(order) {
|
|
|
6221
6793
|
ascending: order.direction !== "descending"
|
|
6222
6794
|
};
|
|
6223
6795
|
}
|
|
6224
|
-
function
|
|
6796
|
+
function isRecord9(value) {
|
|
6225
6797
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6226
6798
|
}
|
|
6227
6799
|
function normalizeFindManyAstColumnPredicate(value) {
|
|
6228
|
-
if (!
|
|
6800
|
+
if (!isRecord9(value)) {
|
|
6229
6801
|
return {
|
|
6230
6802
|
eq: value
|
|
6231
6803
|
};
|
|
@@ -6249,7 +6821,7 @@ function normalizeFindManyAstBooleanOperand(clause) {
|
|
|
6249
6821
|
return normalized;
|
|
6250
6822
|
}
|
|
6251
6823
|
function normalizeFindManyAstWhere(where) {
|
|
6252
|
-
if (!where || !
|
|
6824
|
+
if (!where || !isRecord9(where)) {
|
|
6253
6825
|
return where;
|
|
6254
6826
|
}
|
|
6255
6827
|
const normalized = {};
|
|
@@ -6263,7 +6835,7 @@ function normalizeFindManyAstWhere(where) {
|
|
|
6263
6835
|
);
|
|
6264
6836
|
continue;
|
|
6265
6837
|
}
|
|
6266
|
-
if (key === "not" &&
|
|
6838
|
+
if (key === "not" && isRecord9(value)) {
|
|
6267
6839
|
normalized.not = normalizeFindManyAstBooleanOperand(
|
|
6268
6840
|
value
|
|
6269
6841
|
);
|
|
@@ -6274,7 +6846,7 @@ function normalizeFindManyAstWhere(where) {
|
|
|
6274
6846
|
return normalized;
|
|
6275
6847
|
}
|
|
6276
6848
|
function predicateRequiresUuidQueryFallback(column, value) {
|
|
6277
|
-
if (!
|
|
6849
|
+
if (!isRecord9(value)) {
|
|
6278
6850
|
return shouldUseUuidTextComparison(column, value);
|
|
6279
6851
|
}
|
|
6280
6852
|
const eqValue = value.eq;
|
|
@@ -6292,7 +6864,7 @@ function booleanOperandRequiresUuidQueryFallback(clause) {
|
|
|
6292
6864
|
return false;
|
|
6293
6865
|
}
|
|
6294
6866
|
function findManyAstWhereRequiresLegacyTransport(where) {
|
|
6295
|
-
if (!where || !
|
|
6867
|
+
if (!where || !isRecord9(where)) {
|
|
6296
6868
|
return false;
|
|
6297
6869
|
}
|
|
6298
6870
|
for (const [key, value] of Object.entries(where)) {
|
|
@@ -6307,7 +6879,7 @@ function findManyAstWhereRequiresLegacyTransport(where) {
|
|
|
6307
6879
|
}
|
|
6308
6880
|
continue;
|
|
6309
6881
|
}
|
|
6310
|
-
if (key === "not" &&
|
|
6882
|
+
if (key === "not" && isRecord9(value)) {
|
|
6311
6883
|
if (booleanOperandRequiresUuidQueryFallback(value)) {
|
|
6312
6884
|
return true;
|
|
6313
6885
|
}
|
|
@@ -6856,6 +7428,7 @@ function resolveAthenaModelTargetTableName(target, options = {}) {
|
|
|
6856
7428
|
var DEFAULT_COLUMNS = "*";
|
|
6857
7429
|
var SAFE_CAST_PATTERN = /^[a-z_][a-z0-9_]*(?:\[\])?$/i;
|
|
6858
7430
|
var ATHENA_NORMALIZED_ERROR_KEY = "__athenaNormalizedError";
|
|
7431
|
+
var SDK_NAME4 = "xylex-group/athena";
|
|
6859
7432
|
function formatResult(response) {
|
|
6860
7433
|
const result = {
|
|
6861
7434
|
data: response.data ?? null,
|
|
@@ -6932,7 +7505,7 @@ async function executeExperimentalRead(experimental, runner) {
|
|
|
6932
7505
|
throw error;
|
|
6933
7506
|
}
|
|
6934
7507
|
}
|
|
6935
|
-
function
|
|
7508
|
+
function isRecord10(value) {
|
|
6936
7509
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6937
7510
|
}
|
|
6938
7511
|
function firstNonEmptyString2(...values) {
|
|
@@ -6944,8 +7517,8 @@ function firstNonEmptyString2(...values) {
|
|
|
6944
7517
|
return void 0;
|
|
6945
7518
|
}
|
|
6946
7519
|
function resolveStructuredErrorPayload2(raw) {
|
|
6947
|
-
if (!
|
|
6948
|
-
return
|
|
7520
|
+
if (!isRecord10(raw)) return null;
|
|
7521
|
+
return isRecord10(raw.error) ? raw.error : raw;
|
|
6949
7522
|
}
|
|
6950
7523
|
function resolveStructuredErrorDetails(payload, message) {
|
|
6951
7524
|
if (!payload || !("details" in payload)) {
|
|
@@ -6961,7 +7534,7 @@ function resolveStructuredErrorDetails(payload, message) {
|
|
|
6961
7534
|
return details;
|
|
6962
7535
|
}
|
|
6963
7536
|
function createResultError(response, result, normalized) {
|
|
6964
|
-
const rawRecord =
|
|
7537
|
+
const rawRecord = isRecord10(response.raw) ? response.raw : null;
|
|
6965
7538
|
const payload = resolveStructuredErrorPayload2(response.raw);
|
|
6966
7539
|
const message = firstNonEmptyString2(
|
|
6967
7540
|
response.error,
|
|
@@ -7024,6 +7597,43 @@ function asAthenaJsonObject(value) {
|
|
|
7024
7597
|
function asAthenaJsonObjectArray(values) {
|
|
7025
7598
|
return values;
|
|
7026
7599
|
}
|
|
7600
|
+
function parseArbitraryResponseBody(rawText, contentType) {
|
|
7601
|
+
if (!rawText) {
|
|
7602
|
+
return null;
|
|
7603
|
+
}
|
|
7604
|
+
const contentTypeSuggestsJson = contentType?.toLowerCase().includes("application/json") ?? false;
|
|
7605
|
+
const looksJson = contentTypeSuggestsJson || rawText.startsWith("{") || rawText.startsWith("[");
|
|
7606
|
+
if (!looksJson) {
|
|
7607
|
+
return rawText;
|
|
7608
|
+
}
|
|
7609
|
+
try {
|
|
7610
|
+
return JSON.parse(rawText);
|
|
7611
|
+
} catch {
|
|
7612
|
+
return rawText;
|
|
7613
|
+
}
|
|
7614
|
+
}
|
|
7615
|
+
function toRequestQueryString(query) {
|
|
7616
|
+
if (!query) {
|
|
7617
|
+
return "";
|
|
7618
|
+
}
|
|
7619
|
+
const params = new URLSearchParams();
|
|
7620
|
+
for (const [key, value] of Object.entries(query)) {
|
|
7621
|
+
if (value === void 0 || value === null) {
|
|
7622
|
+
continue;
|
|
7623
|
+
}
|
|
7624
|
+
if (Array.isArray(value)) {
|
|
7625
|
+
for (const item of value) {
|
|
7626
|
+
if (item !== void 0 && item !== null) {
|
|
7627
|
+
params.append(key, String(item));
|
|
7628
|
+
}
|
|
7629
|
+
}
|
|
7630
|
+
continue;
|
|
7631
|
+
}
|
|
7632
|
+
params.set(key, String(value));
|
|
7633
|
+
}
|
|
7634
|
+
const encoded = params.toString();
|
|
7635
|
+
return encoded ? `?${encoded}` : "";
|
|
7636
|
+
}
|
|
7027
7637
|
function normalizeSelectColumnsInput(columns) {
|
|
7028
7638
|
if (columns === void 0) {
|
|
7029
7639
|
return void 0;
|
|
@@ -8330,6 +8940,8 @@ var ATHENA_ENV_GATEWAY_URL_KEYS = [
|
|
|
8330
8940
|
"NEXT_PUBLIC_ATHENA_DB_API_URL"
|
|
8331
8941
|
];
|
|
8332
8942
|
var ATHENA_ENV_AUTH_URL_KEYS = ["ATHENA_AUTH_URL", "NEXT_PUBLIC_ATHENA_AUTH_URL"];
|
|
8943
|
+
var ATHENA_ENV_CHAT_URL_KEYS = ["ATHENA_CHAT_URL", "NEXT_PUBLIC_ATHENA_CHAT_URL"];
|
|
8944
|
+
var ATHENA_ENV_CHAT_WS_URL_KEYS = ["ATHENA_CHAT_WS_URL", "NEXT_PUBLIC_ATHENA_CHAT_WS_URL"];
|
|
8333
8945
|
var ATHENA_ENV_STORAGE_URL_KEYS = ["ATHENA_STORAGE_URL", "NEXT_PUBLIC_ATHENA_STORAGE_URL"];
|
|
8334
8946
|
var ATHENA_ENV_KEY_KEYS = [
|
|
8335
8947
|
"ATHENA_API_KEY",
|
|
@@ -8410,6 +9022,15 @@ function appendServicePath(baseUrl, segment) {
|
|
|
8410
9022
|
const normalizedBaseUrl = normalizeAthenaGatewayBaseUrl(baseUrl, { label: "Athena public base URL" });
|
|
8411
9023
|
return `${normalizedBaseUrl}/${segment.replace(/^\/+/, "")}`;
|
|
8412
9024
|
}
|
|
9025
|
+
function appendRealtimeGatewayPath(baseUrl) {
|
|
9026
|
+
const normalizedBaseUrl = normalizeAthenaGatewayBaseUrl(baseUrl, { label: "Athena public base URL" });
|
|
9027
|
+
const wsUrl = new URL(normalizedBaseUrl);
|
|
9028
|
+
wsUrl.protocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
9029
|
+
wsUrl.pathname = `${wsUrl.pathname.replace(/\/+$/, "")}/wss/gateway`;
|
|
9030
|
+
wsUrl.search = "";
|
|
9031
|
+
wsUrl.hash = "";
|
|
9032
|
+
return wsUrl.toString();
|
|
9033
|
+
}
|
|
8413
9034
|
function resolveServiceUrlOverride(value, label) {
|
|
8414
9035
|
return resolveClientServiceBaseUrl(value, label);
|
|
8415
9036
|
}
|
|
@@ -8418,6 +9039,8 @@ function resolveServiceUrls(config) {
|
|
|
8418
9039
|
return {
|
|
8419
9040
|
dbUrl: resolveServiceUrlOverride(config.db?.url, "Athena DB base URL") ?? resolveServiceUrlOverride(config.gateway?.url, "Athena gateway base URL") ?? resolveServiceUrlOverride(config.dbUrl, "Athena DB base URL") ?? resolveServiceUrlOverride(config.gatewayUrl, "Athena gateway base URL") ?? (baseUrl ? appendServicePath(baseUrl, "db") : void 0),
|
|
8420
9041
|
authUrl: resolveServiceUrlOverride(config.auth?.url, "Athena auth base URL") ?? resolveServiceUrlOverride(config.auth?.baseUrl, "Athena auth base URL") ?? resolveServiceUrlOverride(config.authUrl, "Athena auth base URL") ?? (baseUrl ? appendServicePath(baseUrl, "auth") : void 0),
|
|
9042
|
+
chatUrl: resolveServiceUrlOverride(config.chat?.url, "Athena chat base URL") ?? resolveServiceUrlOverride(config.chatUrl, "Athena chat base URL") ?? (baseUrl ? appendServicePath(baseUrl, "chat") : void 0),
|
|
9043
|
+
chatWsUrl: normalizeOptionalString(config.chat?.wsUrl) ?? normalizeOptionalString(config.chatWsUrl) ?? (baseUrl ? appendRealtimeGatewayPath(baseUrl) : void 0),
|
|
8421
9044
|
storageUrl: resolveServiceUrlOverride(config.storage?.url, "Athena storage base URL") ?? resolveServiceUrlOverride(config.storageUrl, "Athena storage base URL") ?? (baseUrl ? appendServicePath(baseUrl, "storage") : void 0)
|
|
8422
9045
|
};
|
|
8423
9046
|
}
|
|
@@ -8510,6 +9133,7 @@ function mergeClientOverrideOptions(base, overrides) {
|
|
|
8510
9133
|
} : void 0,
|
|
8511
9134
|
db: base.db ? { ...base.db } : void 0,
|
|
8512
9135
|
gateway: base.gateway ? { ...base.gateway } : void 0,
|
|
9136
|
+
chat: base.chat ? { ...base.chat } : void 0,
|
|
8513
9137
|
storage: base.storage ? { ...base.storage } : void 0
|
|
8514
9138
|
};
|
|
8515
9139
|
}
|
|
@@ -8520,6 +9144,7 @@ function mergeClientOverrideOptions(base, overrides) {
|
|
|
8520
9144
|
auth: mergeAuthClientOptions(base.auth, overrides.auth),
|
|
8521
9145
|
db: mergeServiceUrlOverrides(base.db, overrides.db),
|
|
8522
9146
|
gateway: mergeServiceUrlOverrides(base.gateway, overrides.gateway),
|
|
9147
|
+
chat: mergeServiceUrlOverrides(base.chat, overrides.chat),
|
|
8523
9148
|
storage: mergeServiceUrlOverrides(base.storage, overrides.storage)
|
|
8524
9149
|
};
|
|
8525
9150
|
}
|
|
@@ -8578,6 +9203,9 @@ function resolveCreateClientConfig(config) {
|
|
|
8578
9203
|
headers: config.headers,
|
|
8579
9204
|
auth: config.auth,
|
|
8580
9205
|
authUrl: resolvedUrls.authUrl,
|
|
9206
|
+
chat: config.chat,
|
|
9207
|
+
chatUrl: resolvedUrls.chatUrl,
|
|
9208
|
+
chatWsUrl: resolvedUrls.chatWsUrl,
|
|
8581
9209
|
storageUrl: resolvedUrls.storageUrl,
|
|
8582
9210
|
experimental: config.experimental
|
|
8583
9211
|
};
|
|
@@ -8662,6 +9290,119 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
8662
9290
|
queryTracer
|
|
8663
9291
|
);
|
|
8664
9292
|
const db = createDbModule({ from, rpc, query });
|
|
9293
|
+
const chat = createChatModule({
|
|
9294
|
+
baseUrl: config.chatUrl,
|
|
9295
|
+
apiKey: config.apiKey,
|
|
9296
|
+
client: config.client,
|
|
9297
|
+
headers: config.headers,
|
|
9298
|
+
bearerToken: normalizedAuthConfig?.bearerToken,
|
|
9299
|
+
cookie: normalizedAuthConfig?.cookie,
|
|
9300
|
+
sessionToken: normalizedAuthConfig?.sessionToken,
|
|
9301
|
+
forceNoCache: config.forceNoCache,
|
|
9302
|
+
wsUrl: config.chatWsUrl,
|
|
9303
|
+
webSocketFactory: config.chat?.webSocketFactory ?? void 0
|
|
9304
|
+
});
|
|
9305
|
+
const request2 = async (options) => {
|
|
9306
|
+
const method = options.method ?? "GET";
|
|
9307
|
+
const responseType = options.responseType ?? "json";
|
|
9308
|
+
const service = options.service ?? "db";
|
|
9309
|
+
const baseUrlByService = {
|
|
9310
|
+
db: config.baseUrl,
|
|
9311
|
+
auth: config.authUrl,
|
|
9312
|
+
chat: config.chatUrl,
|
|
9313
|
+
storage: config.storageUrl
|
|
9314
|
+
};
|
|
9315
|
+
const resolvedBaseUrl = options.url ?? baseUrlByService[service];
|
|
9316
|
+
if (!resolvedBaseUrl) {
|
|
9317
|
+
throw new Error(
|
|
9318
|
+
`Athena ${service} base URL is not configured. Pass createClient({ url }) for unified routing or set the service-specific URL first.`
|
|
9319
|
+
);
|
|
9320
|
+
}
|
|
9321
|
+
const normalizedBaseUrl = normalizeAthenaGatewayBaseUrl(resolvedBaseUrl, {
|
|
9322
|
+
label: `Athena ${service} base URL`
|
|
9323
|
+
});
|
|
9324
|
+
const normalizedPath = options.url ? "" : (() => {
|
|
9325
|
+
const path = options.path?.trim();
|
|
9326
|
+
if (!path) {
|
|
9327
|
+
throw new Error("client.request(...) requires either an absolute url or a non-empty path.");
|
|
9328
|
+
}
|
|
9329
|
+
return path.startsWith("/") ? path : `/${path}`;
|
|
9330
|
+
})();
|
|
9331
|
+
const targetUrl = options.url ? `${normalizedBaseUrl}${toRequestQueryString(options.query)}` : `${normalizedBaseUrl}${normalizedPath}${toRequestQueryString(options.query)}`;
|
|
9332
|
+
const headers = {
|
|
9333
|
+
"X-Athena-Sdk": buildSdkHeaderValue(SDK_NAME4),
|
|
9334
|
+
...config.headers ?? {},
|
|
9335
|
+
...options.headers ?? {}
|
|
9336
|
+
};
|
|
9337
|
+
if (service !== "auth") {
|
|
9338
|
+
headers.apikey = headers.apikey ?? config.apiKey;
|
|
9339
|
+
headers["x-api-key"] = headers["x-api-key"] ?? config.apiKey;
|
|
9340
|
+
if (config.client && !hasHeaderIgnoreCase(headers, "X-Athena-Client")) {
|
|
9341
|
+
headers["X-Athena-Client"] = config.client;
|
|
9342
|
+
}
|
|
9343
|
+
if (config.userId && !hasHeaderIgnoreCase(headers, "X-User-Id")) {
|
|
9344
|
+
headers["X-User-Id"] = config.userId;
|
|
9345
|
+
}
|
|
9346
|
+
if (config.organizationId && !hasHeaderIgnoreCase(headers, "X-Organization-Id")) {
|
|
9347
|
+
headers["X-Organization-Id"] = config.organizationId;
|
|
9348
|
+
}
|
|
9349
|
+
if (normalizedAuthConfig?.sessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
9350
|
+
headers["X-Athena-Auth-Session-Token"] = normalizedAuthConfig.sessionToken;
|
|
9351
|
+
}
|
|
9352
|
+
if (normalizedAuthConfig?.bearerToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Bearer-Token")) {
|
|
9353
|
+
headers["X-Athena-Auth-Bearer-Token"] = normalizedAuthConfig.bearerToken;
|
|
9354
|
+
}
|
|
9355
|
+
if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
9356
|
+
headers.Cookie = normalizedAuthConfig.cookie;
|
|
9357
|
+
}
|
|
9358
|
+
} else {
|
|
9359
|
+
const authApiKey = normalizedAuthConfig?.apiKey ?? config.apiKey;
|
|
9360
|
+
if (authApiKey && !hasHeaderIgnoreCase(headers, "x-api-key")) {
|
|
9361
|
+
headers.apikey = headers.apikey ?? authApiKey;
|
|
9362
|
+
headers["x-api-key"] = headers["x-api-key"] ?? authApiKey;
|
|
9363
|
+
}
|
|
9364
|
+
if (normalizedAuthConfig?.bearerToken && !hasHeaderIgnoreCase(headers, "Authorization")) {
|
|
9365
|
+
headers.Authorization = `Bearer ${normalizedAuthConfig.bearerToken}`;
|
|
9366
|
+
}
|
|
9367
|
+
if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
9368
|
+
headers.Cookie = normalizedAuthConfig.cookie;
|
|
9369
|
+
}
|
|
9370
|
+
if (normalizedAuthConfig?.sessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
9371
|
+
headers["X-Athena-Auth-Session-Token"] = normalizedAuthConfig.sessionToken;
|
|
9372
|
+
}
|
|
9373
|
+
}
|
|
9374
|
+
const shouldSendJsonBody = options.body !== void 0 && options.body !== null && !(options.body instanceof FormData) && !(options.body instanceof Blob) && !(options.body instanceof URLSearchParams) && !(options.body instanceof ArrayBuffer) && !ArrayBuffer.isView(options.body) && typeof options.body !== "string";
|
|
9375
|
+
if (shouldSendJsonBody && !hasHeaderIgnoreCase(headers, "Content-Type")) {
|
|
9376
|
+
headers["Content-Type"] = "application/json";
|
|
9377
|
+
}
|
|
9378
|
+
const response = await fetch(targetUrl, {
|
|
9379
|
+
method,
|
|
9380
|
+
headers,
|
|
9381
|
+
body: options.body === void 0 || options.body === null ? void 0 : shouldSendJsonBody ? JSON.stringify(options.body) : options.body,
|
|
9382
|
+
signal: options.signal,
|
|
9383
|
+
credentials: options.credentials
|
|
9384
|
+
});
|
|
9385
|
+
if (responseType === "response") {
|
|
9386
|
+
return {
|
|
9387
|
+
ok: response.ok,
|
|
9388
|
+
status: response.status,
|
|
9389
|
+
statusText: response.statusText,
|
|
9390
|
+
headers: response.headers,
|
|
9391
|
+
data: null,
|
|
9392
|
+
raw: response
|
|
9393
|
+
};
|
|
9394
|
+
}
|
|
9395
|
+
const rawText = await response.text();
|
|
9396
|
+
const parsed = responseType === "text" ? rawText : parseArbitraryResponseBody(rawText, response.headers.get("content-type"));
|
|
9397
|
+
return {
|
|
9398
|
+
ok: response.ok,
|
|
9399
|
+
status: response.status,
|
|
9400
|
+
statusText: response.statusText,
|
|
9401
|
+
headers: response.headers,
|
|
9402
|
+
data: parsed,
|
|
9403
|
+
raw: response
|
|
9404
|
+
};
|
|
9405
|
+
};
|
|
8665
9406
|
const withContext = (context) => createClientFromInput(
|
|
8666
9407
|
mergeClientOverrideOptions(sourceConfig, toClientContextOverrides(context))
|
|
8667
9408
|
);
|
|
@@ -8677,8 +9418,10 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
8677
9418
|
db,
|
|
8678
9419
|
rpc,
|
|
8679
9420
|
query,
|
|
9421
|
+
request: request2,
|
|
8680
9422
|
verifyConnection: gateway.verifyConnection,
|
|
8681
9423
|
auth: auth.auth,
|
|
9424
|
+
chat,
|
|
8682
9425
|
withContext,
|
|
8683
9426
|
withSession,
|
|
8684
9427
|
withOptions: authWithOptions
|
|
@@ -8723,6 +9466,8 @@ var AthenaClient = class {
|
|
|
8723
9466
|
const url = options.url ?? readFirstEnvValue(env, ATHENA_ENV_URL_KEYS);
|
|
8724
9467
|
const gatewayUrl = options.gatewayUrl ?? readFirstEnvValue(env, ATHENA_ENV_GATEWAY_URL_KEYS);
|
|
8725
9468
|
const authUrl = options.authUrl ?? readFirstEnvValue(env, ATHENA_ENV_AUTH_URL_KEYS);
|
|
9469
|
+
const chatUrl = options.chatUrl ?? readFirstEnvValue(env, ATHENA_ENV_CHAT_URL_KEYS);
|
|
9470
|
+
const chatWsUrl = options.chatWsUrl ?? readFirstEnvValue(env, ATHENA_ENV_CHAT_WS_URL_KEYS);
|
|
8726
9471
|
const storageUrl = options.storageUrl ?? readFirstEnvValue(env, ATHENA_ENV_STORAGE_URL_KEYS);
|
|
8727
9472
|
const key = options.key ?? readFirstEnvValue(env, ATHENA_ENV_KEY_KEYS);
|
|
8728
9473
|
const client = options.client ?? readFirstEnvValue(env, ATHENA_ENV_CLIENT_KEYS);
|
|
@@ -8737,6 +9482,8 @@ var AthenaClient = class {
|
|
|
8737
9482
|
url,
|
|
8738
9483
|
gatewayUrl,
|
|
8739
9484
|
authUrl,
|
|
9485
|
+
chatUrl,
|
|
9486
|
+
chatWsUrl,
|
|
8740
9487
|
storageUrl,
|
|
8741
9488
|
key,
|
|
8742
9489
|
client
|
|
@@ -8782,7 +9529,7 @@ function resolveNullishValue(mode) {
|
|
|
8782
9529
|
if (mode === "null") return null;
|
|
8783
9530
|
return "";
|
|
8784
9531
|
}
|
|
8785
|
-
function
|
|
9532
|
+
function isRecord11(value) {
|
|
8786
9533
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
8787
9534
|
}
|
|
8788
9535
|
function isNullableColumn(model, key) {
|
|
@@ -8791,7 +9538,7 @@ function isNullableColumn(model, key) {
|
|
|
8791
9538
|
}
|
|
8792
9539
|
function toModelFormDefaults(model, values, options) {
|
|
8793
9540
|
const source = values;
|
|
8794
|
-
if (!
|
|
9541
|
+
if (!isRecord11(source)) {
|
|
8795
9542
|
return {};
|
|
8796
9543
|
}
|
|
8797
9544
|
const mode = options?.nullishMode ?? "empty-string";
|
|
@@ -9305,6 +10052,9 @@ var TypedAthenaClientImpl = class _TypedAthenaClientImpl {
|
|
|
9305
10052
|
query(query, options) {
|
|
9306
10053
|
return this.baseClient.query(query, options);
|
|
9307
10054
|
}
|
|
10055
|
+
request(options) {
|
|
10056
|
+
return this.baseClient.request(options);
|
|
10057
|
+
}
|
|
9308
10058
|
verifyConnection(options) {
|
|
9309
10059
|
return this.baseClient.verifyConnection(options);
|
|
9310
10060
|
}
|
|
@@ -9738,15 +10488,15 @@ function readCookieFromHeaders(headers, name) {
|
|
|
9738
10488
|
}
|
|
9739
10489
|
return parseCookies(cookieHeader).get(name);
|
|
9740
10490
|
}
|
|
9741
|
-
function
|
|
10491
|
+
function isRecord12(value) {
|
|
9742
10492
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
9743
10493
|
}
|
|
9744
10494
|
function resolveSessionCandidate(value) {
|
|
9745
|
-
if (!
|
|
10495
|
+
if (!isRecord12(value)) {
|
|
9746
10496
|
return null;
|
|
9747
10497
|
}
|
|
9748
|
-
const session =
|
|
9749
|
-
const user =
|
|
10498
|
+
const session = isRecord12(value.session) ? value.session : void 0;
|
|
10499
|
+
const user = isRecord12(value.user) ? value.user : void 0;
|
|
9750
10500
|
if (session && typeof session.token === "string" && session.token.length > 0 && user) {
|
|
9751
10501
|
return {
|
|
9752
10502
|
session,
|
|
@@ -9756,7 +10506,7 @@ function resolveSessionCandidate(value) {
|
|
|
9756
10506
|
return null;
|
|
9757
10507
|
}
|
|
9758
10508
|
function inferSessionPair(returned) {
|
|
9759
|
-
return resolveSessionCandidate(returned) ?? (
|
|
10509
|
+
return resolveSessionCandidate(returned) ?? (isRecord12(returned) ? resolveSessionCandidate(returned.data) : null) ?? (isRecord12(returned) ? resolveSessionCandidate(returned.session) : null);
|
|
9760
10510
|
}
|
|
9761
10511
|
function resolveResponseHeaders(ctx) {
|
|
9762
10512
|
if (ctx.context.responseHeaders instanceof Headers) {
|
|
@@ -9779,23 +10529,23 @@ function normalizeBasePath(basePath) {
|
|
|
9779
10529
|
function isDynamicBaseURLConfig2(baseURL) {
|
|
9780
10530
|
return typeof baseURL === "object" && baseURL !== null && "allowedHosts" in baseURL && Array.isArray(baseURL.allowedHosts);
|
|
9781
10531
|
}
|
|
9782
|
-
function getRequestUrl(
|
|
10532
|
+
function getRequestUrl(request2) {
|
|
9783
10533
|
try {
|
|
9784
|
-
return new URL(
|
|
10534
|
+
return new URL(request2.url);
|
|
9785
10535
|
} catch {
|
|
9786
10536
|
return new URL("http://localhost");
|
|
9787
10537
|
}
|
|
9788
10538
|
}
|
|
9789
|
-
function getRequestHost(
|
|
9790
|
-
const forwardedHost =
|
|
9791
|
-
const host = forwardedHost ||
|
|
10539
|
+
function getRequestHost(request2, url) {
|
|
10540
|
+
const forwardedHost = request2.headers.get("x-forwarded-host")?.split(",")[0]?.trim();
|
|
10541
|
+
const host = forwardedHost || request2.headers.get("host") || url.host;
|
|
9792
10542
|
return host || null;
|
|
9793
10543
|
}
|
|
9794
|
-
function getRequestProtocol(
|
|
10544
|
+
function getRequestProtocol(request2, configuredProtocol, url) {
|
|
9795
10545
|
if (configuredProtocol === "http" || configuredProtocol === "https") {
|
|
9796
10546
|
return configuredProtocol;
|
|
9797
10547
|
}
|
|
9798
|
-
const forwardedProto =
|
|
10548
|
+
const forwardedProto = request2.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();
|
|
9799
10549
|
if (forwardedProto === "http" || forwardedProto === "https") {
|
|
9800
10550
|
return forwardedProto;
|
|
9801
10551
|
}
|
|
@@ -9804,12 +10554,12 @@ function getRequestProtocol(request, configuredProtocol, url) {
|
|
|
9804
10554
|
}
|
|
9805
10555
|
return "http";
|
|
9806
10556
|
}
|
|
9807
|
-
function resolveRequestBaseURL(baseURL,
|
|
10557
|
+
function resolveRequestBaseURL(baseURL, request2) {
|
|
9808
10558
|
if (typeof baseURL === "string") {
|
|
9809
10559
|
return normalizeBaseURL(baseURL);
|
|
9810
10560
|
}
|
|
9811
|
-
const requestUrl = getRequestUrl(
|
|
9812
|
-
const host = getRequestHost(
|
|
10561
|
+
const requestUrl = getRequestUrl(request2);
|
|
10562
|
+
const host = getRequestHost(request2, requestUrl);
|
|
9813
10563
|
if (!host) {
|
|
9814
10564
|
return null;
|
|
9815
10565
|
}
|
|
@@ -9819,7 +10569,7 @@ function resolveRequestBaseURL(baseURL, request) {
|
|
|
9819
10569
|
return null;
|
|
9820
10570
|
}
|
|
9821
10571
|
}
|
|
9822
|
-
const protocol = typeof baseURL === "object" && baseURL !== null ? getRequestProtocol(
|
|
10572
|
+
const protocol = typeof baseURL === "object" && baseURL !== null ? getRequestProtocol(request2, baseURL.protocol, requestUrl) : getRequestProtocol(request2, void 0, requestUrl);
|
|
9823
10573
|
return `${protocol}://${host}`;
|
|
9824
10574
|
}
|
|
9825
10575
|
function getOrigin(baseURL) {
|
|
@@ -9832,16 +10582,16 @@ function getOrigin(baseURL) {
|
|
|
9832
10582
|
return void 0;
|
|
9833
10583
|
}
|
|
9834
10584
|
}
|
|
9835
|
-
async function resolveTrustedOrigins(config, baseURL,
|
|
9836
|
-
const resolved = typeof config.trustedOrigins === "function" ? await config.trustedOrigins(
|
|
10585
|
+
async function resolveTrustedOrigins(config, baseURL, request2) {
|
|
10586
|
+
const resolved = typeof config.trustedOrigins === "function" ? await config.trustedOrigins(request2) : config.trustedOrigins ?? [];
|
|
9837
10587
|
const values = [
|
|
9838
10588
|
getOrigin(baseURL),
|
|
9839
10589
|
...resolved
|
|
9840
10590
|
];
|
|
9841
10591
|
return Array.from(new Set(values.filter((value) => typeof value === "string" && value.length > 0)));
|
|
9842
10592
|
}
|
|
9843
|
-
async function resolveTrustedProviders(config,
|
|
9844
|
-
const configured = typeof config.trustedProviders === "function" ? await config.trustedProviders(
|
|
10593
|
+
async function resolveTrustedProviders(config, request2) {
|
|
10594
|
+
const configured = typeof config.trustedProviders === "function" ? await config.trustedProviders(request2) : config.trustedProviders ?? [];
|
|
9845
10595
|
const values = [
|
|
9846
10596
|
...Object.keys(config.socialProviders ?? {}),
|
|
9847
10597
|
...configured
|
|
@@ -9966,9 +10716,9 @@ function athenaAuth(config) {
|
|
|
9966
10716
|
}
|
|
9967
10717
|
return ctx;
|
|
9968
10718
|
};
|
|
9969
|
-
const resolveRequestContext = async (
|
|
9970
|
-
const requestUrl = getRequestUrl(
|
|
9971
|
-
const resolvedBaseURL = resolveRequestBaseURL(config.baseURL,
|
|
10719
|
+
const resolveRequestContext = async (request2) => {
|
|
10720
|
+
const requestUrl = getRequestUrl(request2);
|
|
10721
|
+
const resolvedBaseURL = resolveRequestBaseURL(config.baseURL, request2);
|
|
9972
10722
|
if (!resolvedBaseURL) {
|
|
9973
10723
|
throw new Error(
|
|
9974
10724
|
isDynamicBaseURLConfig2(config.baseURL) ? "Could not resolve base URL from request. Check allowedHosts/baseURL." : "Could not resolve base URL from request."
|
|
@@ -9979,17 +10729,17 @@ function athenaAuth(config) {
|
|
|
9979
10729
|
session: config.session,
|
|
9980
10730
|
advanced: config.advanced
|
|
9981
10731
|
});
|
|
9982
|
-
const trustedOrigins = await resolveTrustedOrigins(config, resolvedBaseURL,
|
|
9983
|
-
const trustedProviders = await resolveTrustedProviders(config,
|
|
10732
|
+
const trustedOrigins = await resolveTrustedOrigins(config, resolvedBaseURL, request2);
|
|
10733
|
+
const trustedProviders = await resolveTrustedProviders(config, request2);
|
|
9984
10734
|
return {
|
|
9985
10735
|
auth,
|
|
9986
|
-
request,
|
|
10736
|
+
request: request2,
|
|
9987
10737
|
url: requestUrl,
|
|
9988
10738
|
path: requestUrl.pathname,
|
|
9989
10739
|
basePath: normalizedBasePath,
|
|
9990
10740
|
baseURL: resolvedBaseURL,
|
|
9991
10741
|
origin: getOrigin(resolvedBaseURL) ?? resolvedBaseURL,
|
|
9992
|
-
headers:
|
|
10742
|
+
headers: request2.headers,
|
|
9993
10743
|
cookies: requestCookies,
|
|
9994
10744
|
trustedOrigins,
|
|
9995
10745
|
trustedProviders,
|
|
@@ -10002,8 +10752,8 @@ function athenaAuth(config) {
|
|
|
10002
10752
|
socialProviders: auth.socialProviders
|
|
10003
10753
|
};
|
|
10004
10754
|
};
|
|
10005
|
-
const handler = async (
|
|
10006
|
-
const requestContext = await resolveRequestContext(
|
|
10755
|
+
const handler = async (request2) => {
|
|
10756
|
+
const requestContext = await resolveRequestContext(request2);
|
|
10007
10757
|
if (typeof config.handler !== "function") {
|
|
10008
10758
|
return createJsonResponse(
|
|
10009
10759
|
{
|
|
@@ -10024,7 +10774,7 @@ function athenaAuth(config) {
|
|
|
10024
10774
|
const responseHeaders = new Headers(response.headers);
|
|
10025
10775
|
await runAfterHooks({
|
|
10026
10776
|
path: requestContext.path,
|
|
10027
|
-
headers:
|
|
10777
|
+
headers: request2.headers,
|
|
10028
10778
|
context: {
|
|
10029
10779
|
responseHeaders,
|
|
10030
10780
|
returned: result.returned,
|
|
@@ -10131,6 +10881,6 @@ async function runSchemaGenerator(options = {}) {
|
|
|
10131
10881
|
return throwBrowserUnsupported("runSchemaGenerator");
|
|
10132
10882
|
}
|
|
10133
10883
|
|
|
10134
|
-
export { ATHENA_AUTH_ADMIN_LIMITS, ATHENA_AUTH_BASE_ERROR_CODES, ATHENA_AUTH_MAX_ADMIN_JSON_BYTES, ATHENA_AUTH_MAX_ADMIN_JSON_DEPTH, ATHENA_AUTH_MAX_TEMPLATE_VARIABLES, ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH, AthenaClient, AthenaError, AthenaErrorCategory, AthenaErrorCode, AthenaErrorKind, AthenaGatewayError, AthenaStorageError, AthenaStorageErrorCode, Backend, DEFAULT_POSTGRES_SCHEMAS, assertInt, athenaAuth, boolean, coerceInt, createAthenaStorageError, createAuthClient, createAuthReactEmailInput, createClient, createModelFormAdapter, createPostgresIntrospectionProvider, createTypedClient, defineAthenaAuthConfig, defineAuthEmailTemplate, defineDatabase, defineGeneratorConfig, defineModel, defineRegistry, defineSchema, enumeration, filterIntrospectionSnapshot, findGeneratorConfigPath, generateArtifactsFromSnapshot, generatorEnv, getAthenaDebugAst, identifier, isAthenaGatewayError, isOk, json, loadGeneratorConfig, normalizeAthenaError, normalizeAthenaGatewayBaseUrl, normalizeGeneratorConfig, normalizeSchemaSelection, normalizeTableSelection, number, parseBooleanFlag2 as parseBooleanFlag, renderAthenaReactEmail, requireAffected, requireSuccess, resolveGeneratorProvider, resolvePostgresColumnType, resolveProviderSchemas, runSchemaGenerator, storageSdkManifest, string, table, toModelFormDefaults, toModelPayload, unwrap, unwrapOne, unwrapRows, verifyAthenaGatewayUrl, withRetry };
|
|
10884
|
+
export { ATHENA_AUTH_ADMIN_LIMITS, ATHENA_AUTH_BASE_ERROR_CODES, ATHENA_AUTH_MAX_ADMIN_JSON_BYTES, ATHENA_AUTH_MAX_ADMIN_JSON_DEPTH, ATHENA_AUTH_MAX_TEMPLATE_VARIABLES, ATHENA_AUTH_MAX_TEMPLATE_VARIABLE_LENGTH, AthenaChatError, AthenaClient, AthenaError, AthenaErrorCategory, AthenaErrorCode, AthenaErrorKind, AthenaGatewayError, AthenaStorageError, AthenaStorageErrorCode, Backend, DEFAULT_POSTGRES_SCHEMAS, assertInt, athenaAuth, boolean, chatSdkManifest, coerceInt, createAthenaStorageError, createAuthClient, createAuthReactEmailInput, createClient, createModelFormAdapter, createPostgresIntrospectionProvider, createTypedClient, defineAthenaAuthConfig, defineAuthEmailTemplate, defineDatabase, defineGeneratorConfig, defineModel, defineRegistry, defineSchema, enumeration, filterIntrospectionSnapshot, findGeneratorConfigPath, generateArtifactsFromSnapshot, generatorEnv, getAthenaDebugAst, identifier, isAthenaGatewayError, isOk, json, loadGeneratorConfig, normalizeAthenaError, normalizeAthenaGatewayBaseUrl, normalizeGeneratorConfig, normalizeSchemaSelection, normalizeTableSelection, number, parseBooleanFlag2 as parseBooleanFlag, renderAthenaReactEmail, requireAffected, requireSuccess, resolveGeneratorProvider, resolvePostgresColumnType, resolveProviderSchemas, runSchemaGenerator, storageSdkManifest, string, table, toModelFormDefaults, toModelPayload, unwrap, unwrapChatMessage, unwrapChatRoom, unwrapOne, unwrapRows, verifyAthenaGatewayUrl, withRetry };
|
|
10135
10885
|
//# sourceMappingURL=browser.js.map
|
|
10136
10886
|
//# sourceMappingURL=browser.js.map
|