@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/index.js
CHANGED
|
@@ -664,8 +664,8 @@ function deleteSessionCookie(ctx, skipDontRememberMe) {
|
|
|
664
664
|
expireCookie(ctx, ctx.context.authCookies.dontRememberToken);
|
|
665
665
|
}
|
|
666
666
|
}
|
|
667
|
-
var getSessionCookie = (
|
|
668
|
-
const cookies = (
|
|
667
|
+
var getSessionCookie = (request2, config) => {
|
|
668
|
+
const cookies = (request2 instanceof Headers || !("headers" in request2) ? request2 : request2.headers).get("cookie");
|
|
669
669
|
if (!cookies) {
|
|
670
670
|
return null;
|
|
671
671
|
}
|
|
@@ -685,8 +685,8 @@ var getSessionCookie = (request, config) => {
|
|
|
685
685
|
}
|
|
686
686
|
return null;
|
|
687
687
|
};
|
|
688
|
-
var getCookieCache = async (
|
|
689
|
-
const headers =
|
|
688
|
+
var getCookieCache = async (request2, config) => {
|
|
689
|
+
const headers = request2 instanceof Headers || !("headers" in request2) ? request2 : request2.headers;
|
|
690
690
|
const cookieHeader = headers.get("cookie");
|
|
691
691
|
if (!cookieHeader) {
|
|
692
692
|
return null;
|
|
@@ -804,7 +804,7 @@ var getCookieCache = async (request, config) => {
|
|
|
804
804
|
|
|
805
805
|
// package.json
|
|
806
806
|
var package_default = {
|
|
807
|
-
version: "2.
|
|
807
|
+
version: "2.10.0"
|
|
808
808
|
};
|
|
809
809
|
|
|
810
810
|
// src/sdk-version.ts
|
|
@@ -1856,6 +1856,50 @@ function mergeCallOptions(base, override) {
|
|
|
1856
1856
|
}
|
|
1857
1857
|
};
|
|
1858
1858
|
}
|
|
1859
|
+
function copyDefinedField(target, source, targetKey, sourceKey) {
|
|
1860
|
+
if (!(sourceKey in source)) {
|
|
1861
|
+
return;
|
|
1862
|
+
}
|
|
1863
|
+
const value = source[sourceKey];
|
|
1864
|
+
if (value !== void 0) {
|
|
1865
|
+
target[targetKey] = value;
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
function normalizeAdminEmailTemplatePayload(payload) {
|
|
1869
|
+
const normalized = { ...payload };
|
|
1870
|
+
copyDefinedField(normalized, payload, "template_key", "templateKey");
|
|
1871
|
+
copyDefinedField(normalized, payload, "event_type", "eventType");
|
|
1872
|
+
copyDefinedField(normalized, payload, "subject_template", "subjectTemplate");
|
|
1873
|
+
copyDefinedField(normalized, payload, "text_template", "textTemplate");
|
|
1874
|
+
copyDefinedField(normalized, payload, "html_template", "htmlTemplate");
|
|
1875
|
+
copyDefinedField(normalized, payload, "variable_bindings", "variableBindings");
|
|
1876
|
+
copyDefinedField(normalized, payload, "attachment_failure_mode", "attachmentFailureMode");
|
|
1877
|
+
copyDefinedField(normalized, payload, "is_active", "isActive");
|
|
1878
|
+
return normalized;
|
|
1879
|
+
}
|
|
1880
|
+
function toReactEmailTemplateCompatibilityInput(input) {
|
|
1881
|
+
const payload = input;
|
|
1882
|
+
const compatibility = { ...payload };
|
|
1883
|
+
copyDefinedField(compatibility, payload, "templateKey", "template_key");
|
|
1884
|
+
copyDefinedField(compatibility, payload, "eventType", "event_type");
|
|
1885
|
+
copyDefinedField(compatibility, payload, "subjectTemplate", "subject_template");
|
|
1886
|
+
copyDefinedField(compatibility, payload, "textTemplate", "text_template");
|
|
1887
|
+
copyDefinedField(compatibility, payload, "htmlTemplate", "html_template");
|
|
1888
|
+
copyDefinedField(compatibility, payload, "variableBindings", "variable_bindings");
|
|
1889
|
+
copyDefinedField(compatibility, payload, "attachmentFailureMode", "attachment_failure_mode");
|
|
1890
|
+
copyDefinedField(compatibility, payload, "isActive", "is_active");
|
|
1891
|
+
return compatibility;
|
|
1892
|
+
}
|
|
1893
|
+
function normalizeAdminEmailTemplateSendPayload(payload) {
|
|
1894
|
+
const normalized = { ...payload };
|
|
1895
|
+
copyDefinedField(normalized, payload, "template_id", "templateId");
|
|
1896
|
+
copyDefinedField(normalized, payload, "recipient_email", "recipientEmail");
|
|
1897
|
+
copyDefinedField(normalized, payload, "render_variables", "renderVariables");
|
|
1898
|
+
copyDefinedField(normalized, payload, "user_id", "userId");
|
|
1899
|
+
copyDefinedField(normalized, payload, "organization_id", "organizationId");
|
|
1900
|
+
copyDefinedField(normalized, payload, "session_token", "sessionToken");
|
|
1901
|
+
return normalized;
|
|
1902
|
+
}
|
|
1859
1903
|
function toSessionGuardFailure(sessionResult) {
|
|
1860
1904
|
if (sessionResult.status === 401 || sessionResult.data == null) {
|
|
1861
1905
|
return {
|
|
@@ -2162,7 +2206,7 @@ function createAuthClient(config = {}) {
|
|
|
2162
2206
|
...config,
|
|
2163
2207
|
baseUrl: normalizedBaseUrl
|
|
2164
2208
|
};
|
|
2165
|
-
const
|
|
2209
|
+
const request2 = (input, options) => {
|
|
2166
2210
|
const method = input.method ?? (input.body !== void 0 ? "POST" : inferDefaultMethod(input.endpoint));
|
|
2167
2211
|
const mergedOptions = mergeCallOptions(input.fetchOptions, options);
|
|
2168
2212
|
return callAuthEndpoint(
|
|
@@ -2175,7 +2219,7 @@ function createAuthClient(config = {}) {
|
|
|
2175
2219
|
};
|
|
2176
2220
|
const postGeneric = (endpoint, input, options) => {
|
|
2177
2221
|
const { payload, fetchOptions } = extractFetchOptions(input);
|
|
2178
|
-
return
|
|
2222
|
+
return request2(
|
|
2179
2223
|
{
|
|
2180
2224
|
endpoint,
|
|
2181
2225
|
method: "POST",
|
|
@@ -2187,7 +2231,7 @@ function createAuthClient(config = {}) {
|
|
|
2187
2231
|
};
|
|
2188
2232
|
const getGeneric = (endpoint, input, options) => {
|
|
2189
2233
|
const { fetchOptions } = extractFetchOptions(input);
|
|
2190
|
-
return
|
|
2234
|
+
return request2(
|
|
2191
2235
|
{
|
|
2192
2236
|
endpoint,
|
|
2193
2237
|
method: "GET",
|
|
@@ -2199,7 +2243,7 @@ function createAuthClient(config = {}) {
|
|
|
2199
2243
|
const getWithQuery = (endpoint, input, options) => {
|
|
2200
2244
|
const { payload, fetchOptions } = extractFetchOptions(input);
|
|
2201
2245
|
const query = payload?.query;
|
|
2202
|
-
return
|
|
2246
|
+
return request2(
|
|
2203
2247
|
{
|
|
2204
2248
|
endpoint,
|
|
2205
2249
|
method: "GET",
|
|
@@ -2217,18 +2261,19 @@ function createAuthClient(config = {}) {
|
|
|
2217
2261
|
htmlField: "htmlBody",
|
|
2218
2262
|
textField: "textBody"
|
|
2219
2263
|
}, withReactEmailRoute(route));
|
|
2220
|
-
const resolveAdminEmailTemplatePayload = (route, input) => resolveReactEmailPayloadFields(input, {
|
|
2264
|
+
const resolveAdminEmailTemplatePayload = (route, input) => resolveReactEmailPayloadFields(toReactEmailTemplateCompatibilityInput(input), {
|
|
2221
2265
|
htmlField: "htmlTemplate",
|
|
2222
2266
|
textField: "textTemplate",
|
|
2223
2267
|
variablesField: "variables"
|
|
2224
2268
|
}, withReactEmailRoute(route)).then((payload) => {
|
|
2269
|
+
const normalizedPayload = normalizeAdminEmailTemplatePayload(payload);
|
|
2225
2270
|
if ("variables" in payload && payload.variables !== void 0 && payload.variables !== null) {
|
|
2226
2271
|
assertAthenaAuthTemplateVariables(
|
|
2227
2272
|
payload.variables,
|
|
2228
2273
|
`${route} variables`
|
|
2229
2274
|
);
|
|
2230
2275
|
}
|
|
2231
|
-
return
|
|
2276
|
+
return normalizedPayload;
|
|
2232
2277
|
});
|
|
2233
2278
|
const requireSession = async (input, options) => {
|
|
2234
2279
|
const sessionInput = input?.fetchOptions ? { fetchOptions: input.fetchOptions } : void 0;
|
|
@@ -2804,7 +2849,15 @@ function createAuthClient(config = {}) {
|
|
|
2804
2849
|
await resolveAdminEmailTemplatePayload("/admin/email-template/update", input),
|
|
2805
2850
|
options
|
|
2806
2851
|
),
|
|
2807
|
-
delete: (input, options) => postGeneric("/admin/email-template/delete", input, options)
|
|
2852
|
+
delete: (input, options) => postGeneric("/admin/email-template/delete", input, options),
|
|
2853
|
+
send: (input, options) => postGeneric(
|
|
2854
|
+
"/admin/email-template/send",
|
|
2855
|
+
normalizeAdminEmailTemplateSendPayload(extractFetchOptions(input).payload),
|
|
2856
|
+
options
|
|
2857
|
+
)
|
|
2858
|
+
},
|
|
2859
|
+
eventType: {
|
|
2860
|
+
list: (input, options) => getWithQuery("/admin/email-event-type/list", input, options)
|
|
2808
2861
|
}
|
|
2809
2862
|
},
|
|
2810
2863
|
emailTemplate: {
|
|
@@ -2820,7 +2873,15 @@ function createAuthClient(config = {}) {
|
|
|
2820
2873
|
"/admin/email-template/update",
|
|
2821
2874
|
await resolveAdminEmailTemplatePayload("/admin/email-template/update", input),
|
|
2822
2875
|
options
|
|
2876
|
+
),
|
|
2877
|
+
send: (input, options) => postGeneric(
|
|
2878
|
+
"/admin/email-template/send",
|
|
2879
|
+
normalizeAdminEmailTemplateSendPayload(extractFetchOptions(input).payload),
|
|
2880
|
+
options
|
|
2823
2881
|
)
|
|
2882
|
+
},
|
|
2883
|
+
emailEventType: {
|
|
2884
|
+
list: (input, options) => getWithQuery("/admin/email-event-type/list", input, options)
|
|
2824
2885
|
}
|
|
2825
2886
|
},
|
|
2826
2887
|
apiKey: {
|
|
@@ -2860,7 +2921,7 @@ function createAuthClient(config = {}) {
|
|
|
2860
2921
|
throw new Error("callback.provider requires non-empty code and state values");
|
|
2861
2922
|
}
|
|
2862
2923
|
const endpoint = `/callback/${encodeURIComponent(provider)}`;
|
|
2863
|
-
return
|
|
2924
|
+
return request2({
|
|
2864
2925
|
endpoint,
|
|
2865
2926
|
method: "GET",
|
|
2866
2927
|
query: {
|
|
@@ -2874,7 +2935,7 @@ function createAuthClient(config = {}) {
|
|
|
2874
2935
|
};
|
|
2875
2936
|
return {
|
|
2876
2937
|
baseUrl: normalizedBaseUrl,
|
|
2877
|
-
request,
|
|
2938
|
+
request: request2,
|
|
2878
2939
|
signIn: {
|
|
2879
2940
|
email: (input, options) => executePostWithCompatibleInput(
|
|
2880
2941
|
resolvedConfig,
|
|
@@ -3615,16 +3676,16 @@ function createStorageFileModule(base, config = {}) {
|
|
|
3615
3676
|
};
|
|
3616
3677
|
});
|
|
3617
3678
|
input.onProgress?.(createProgressSnapshot("preparing", sources, 0, 0, 0));
|
|
3618
|
-
const uploadUrls = uploadRequests.length === 1 ? [await base.createStorageUploadUrl(uploadRequests[0].uploadRequest, options)] : (await base.createStorageUploadUrls({ files: uploadRequests.map((
|
|
3679
|
+
const uploadUrls = uploadRequests.length === 1 ? [await base.createStorageUploadUrl(uploadRequests[0].uploadRequest, options)] : (await base.createStorageUploadUrls({ files: uploadRequests.map((request2) => request2.uploadRequest) }, options)).files;
|
|
3619
3680
|
const aggregateLoaded = new Array(uploadRequests.length).fill(0);
|
|
3620
3681
|
const uploaded = [];
|
|
3621
3682
|
for (let index = 0; index < uploadRequests.length; index += 1) {
|
|
3622
|
-
const
|
|
3683
|
+
const request2 = uploadRequests[index];
|
|
3623
3684
|
const uploadUrl = uploadUrls[index];
|
|
3624
3685
|
const response = await putUploadBody(
|
|
3625
3686
|
uploadUrl.upload.url,
|
|
3626
3687
|
uploadUrl.upload.headers ?? {},
|
|
3627
|
-
|
|
3688
|
+
request2.source,
|
|
3628
3689
|
input,
|
|
3629
3690
|
options,
|
|
3630
3691
|
(progress) => {
|
|
@@ -3635,13 +3696,13 @@ function createStorageFileModule(base, config = {}) {
|
|
|
3635
3696
|
uploaded.push({
|
|
3636
3697
|
file: uploadUrl.file,
|
|
3637
3698
|
upload: uploadUrl.upload,
|
|
3638
|
-
source:
|
|
3639
|
-
fileName:
|
|
3640
|
-
storage_key:
|
|
3699
|
+
source: request2.source.source,
|
|
3700
|
+
fileName: request2.source.fileName,
|
|
3701
|
+
storage_key: request2.uploadRequest.storage_key,
|
|
3641
3702
|
response
|
|
3642
3703
|
});
|
|
3643
|
-
aggregateLoaded[index] =
|
|
3644
|
-
input.onProgress?.(createProgressSnapshot("complete", sources, index,
|
|
3704
|
+
aggregateLoaded[index] = request2.source.sizeBytes;
|
|
3705
|
+
input.onProgress?.(createProgressSnapshot("complete", sources, index, request2.source.sizeBytes, sum(aggregateLoaded)));
|
|
3645
3706
|
}
|
|
3646
3707
|
return {
|
|
3647
3708
|
files: uploaded,
|
|
@@ -5616,6 +5677,517 @@ function createStorageModule(gateway, runtimeOptions) {
|
|
|
5616
5677
|
};
|
|
5617
5678
|
}
|
|
5618
5679
|
|
|
5680
|
+
// src/chat/module.ts
|
|
5681
|
+
var SDK_NAME3 = "xylex-group/athena-chat";
|
|
5682
|
+
var SDK_HEADER_VALUE3 = buildSdkHeaderValue(SDK_NAME3);
|
|
5683
|
+
var NO_CACHE_HEADER_VALUE3 = "no-cache";
|
|
5684
|
+
var AthenaChatError = class extends Error {
|
|
5685
|
+
status;
|
|
5686
|
+
endpoint;
|
|
5687
|
+
method;
|
|
5688
|
+
requestId;
|
|
5689
|
+
body;
|
|
5690
|
+
constructor(input) {
|
|
5691
|
+
super(input.message);
|
|
5692
|
+
this.name = "AthenaChatError";
|
|
5693
|
+
this.status = input.status;
|
|
5694
|
+
this.endpoint = input.endpoint;
|
|
5695
|
+
this.method = input.method;
|
|
5696
|
+
this.requestId = input.requestId;
|
|
5697
|
+
this.body = input.body;
|
|
5698
|
+
}
|
|
5699
|
+
};
|
|
5700
|
+
function deriveRealtimeInfoUrl(wsUrl) {
|
|
5701
|
+
if (!wsUrl) {
|
|
5702
|
+
return void 0;
|
|
5703
|
+
}
|
|
5704
|
+
const parsed = new URL(normalizeWsUrl(wsUrl, "Athena chat WebSocket URL"));
|
|
5705
|
+
parsed.protocol = parsed.protocol === "wss:" ? "https:" : "http:";
|
|
5706
|
+
parsed.pathname = parsed.pathname.replace(/\/wss\/gateway$/, "/wss/info");
|
|
5707
|
+
return parsed.toString();
|
|
5708
|
+
}
|
|
5709
|
+
function normalizeWsUrl(value, label) {
|
|
5710
|
+
const normalized = value.trim();
|
|
5711
|
+
if (!normalized) {
|
|
5712
|
+
throw new Error(`${label} is required.`);
|
|
5713
|
+
}
|
|
5714
|
+
let parsed;
|
|
5715
|
+
try {
|
|
5716
|
+
parsed = new URL(normalized);
|
|
5717
|
+
} catch {
|
|
5718
|
+
throw new Error(`${label} must be a valid absolute ws(s) URL.`);
|
|
5719
|
+
}
|
|
5720
|
+
if (parsed.protocol !== "ws:" && parsed.protocol !== "wss:") {
|
|
5721
|
+
throw new Error(`${label} must use ws or wss.`);
|
|
5722
|
+
}
|
|
5723
|
+
parsed.pathname = parsed.pathname.replace(/\/+$/, "");
|
|
5724
|
+
return parsed.toString().replace(/\/$/, "");
|
|
5725
|
+
}
|
|
5726
|
+
function isRecord7(value) {
|
|
5727
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
5728
|
+
}
|
|
5729
|
+
function normalizeHeaderValue3(value) {
|
|
5730
|
+
return value ? value : void 0;
|
|
5731
|
+
}
|
|
5732
|
+
function parseResponseBody4(rawText, contentType) {
|
|
5733
|
+
if (!rawText) {
|
|
5734
|
+
return { parsed: null, parseFailed: false };
|
|
5735
|
+
}
|
|
5736
|
+
const contentTypeSuggestsJson = contentType?.toLowerCase().includes("application/json") ?? false;
|
|
5737
|
+
const looksJson = contentTypeSuggestsJson || rawText.startsWith("{") || rawText.startsWith("[");
|
|
5738
|
+
if (!looksJson) {
|
|
5739
|
+
return { parsed: rawText, parseFailed: false };
|
|
5740
|
+
}
|
|
5741
|
+
try {
|
|
5742
|
+
return { parsed: JSON.parse(rawText), parseFailed: false };
|
|
5743
|
+
} catch {
|
|
5744
|
+
return { parsed: rawText, parseFailed: true };
|
|
5745
|
+
}
|
|
5746
|
+
}
|
|
5747
|
+
function resolveRequestId3(headers) {
|
|
5748
|
+
return headers.get("x-request-id") ?? headers.get("x-correlation-id") ?? headers.get("x-athena-request-id") ?? void 0;
|
|
5749
|
+
}
|
|
5750
|
+
function resolveErrorMessage4(payload, fallback) {
|
|
5751
|
+
if (isRecord7(payload)) {
|
|
5752
|
+
for (const candidate of [payload.error, payload.message, payload.details]) {
|
|
5753
|
+
if (typeof candidate === "string" && candidate.trim().length > 0) {
|
|
5754
|
+
return candidate.trim();
|
|
5755
|
+
}
|
|
5756
|
+
}
|
|
5757
|
+
}
|
|
5758
|
+
if (typeof payload === "string" && payload.trim().length > 0) {
|
|
5759
|
+
return payload.trim();
|
|
5760
|
+
}
|
|
5761
|
+
return fallback;
|
|
5762
|
+
}
|
|
5763
|
+
function encodePathSegment(value, label) {
|
|
5764
|
+
const normalized = value.trim();
|
|
5765
|
+
if (!normalized) {
|
|
5766
|
+
throw new Error(`${label} is required.`);
|
|
5767
|
+
}
|
|
5768
|
+
return encodeURIComponent(normalized);
|
|
5769
|
+
}
|
|
5770
|
+
function encodeQuery(query) {
|
|
5771
|
+
if (!query) {
|
|
5772
|
+
return "";
|
|
5773
|
+
}
|
|
5774
|
+
const params = new URLSearchParams();
|
|
5775
|
+
for (const [key, value] of Object.entries(query)) {
|
|
5776
|
+
if (value === void 0 || value === null) {
|
|
5777
|
+
continue;
|
|
5778
|
+
}
|
|
5779
|
+
if (Array.isArray(value)) {
|
|
5780
|
+
for (const item of value) {
|
|
5781
|
+
if (item !== void 0 && item !== null) {
|
|
5782
|
+
params.append(key, String(item));
|
|
5783
|
+
}
|
|
5784
|
+
}
|
|
5785
|
+
continue;
|
|
5786
|
+
}
|
|
5787
|
+
params.set(key, String(value));
|
|
5788
|
+
}
|
|
5789
|
+
const encoded = params.toString();
|
|
5790
|
+
return encoded ? `?${encoded}` : "";
|
|
5791
|
+
}
|
|
5792
|
+
function createSocket(factory, url, protocols) {
|
|
5793
|
+
try {
|
|
5794
|
+
return new factory(url, protocols);
|
|
5795
|
+
} catch (error) {
|
|
5796
|
+
if (error instanceof TypeError) {
|
|
5797
|
+
return factory(url, protocols);
|
|
5798
|
+
}
|
|
5799
|
+
throw error;
|
|
5800
|
+
}
|
|
5801
|
+
}
|
|
5802
|
+
function buildHeaders3(config, options) {
|
|
5803
|
+
const headers = {
|
|
5804
|
+
Accept: "application/json",
|
|
5805
|
+
apikey: config.apiKey,
|
|
5806
|
+
"x-api-key": config.apiKey,
|
|
5807
|
+
"X-Athena-Sdk": SDK_HEADER_VALUE3
|
|
5808
|
+
};
|
|
5809
|
+
if (config.client || options?.client) {
|
|
5810
|
+
headers["X-Athena-Client"] = options?.client ?? config.client ?? "";
|
|
5811
|
+
}
|
|
5812
|
+
const bearerToken = options?.bearerToken ?? config.bearerToken;
|
|
5813
|
+
if (typeof bearerToken === "string" && bearerToken.trim()) {
|
|
5814
|
+
headers.Authorization = bearerToken.startsWith("Bearer ") ? bearerToken : `Bearer ${bearerToken}`;
|
|
5815
|
+
}
|
|
5816
|
+
const cookie = options?.cookie ?? config.cookie;
|
|
5817
|
+
if (typeof cookie === "string" && cookie.trim()) {
|
|
5818
|
+
headers.Cookie = cookie;
|
|
5819
|
+
}
|
|
5820
|
+
const sessionToken = options?.sessionToken ?? config.sessionToken;
|
|
5821
|
+
if (typeof sessionToken === "string" && sessionToken.trim()) {
|
|
5822
|
+
headers["X-Athena-Auth-Session-Token"] = sessionToken;
|
|
5823
|
+
}
|
|
5824
|
+
if (config.forceNoCache || options?.forceNoCache) {
|
|
5825
|
+
headers["Cache-Control"] = NO_CACHE_HEADER_VALUE3;
|
|
5826
|
+
}
|
|
5827
|
+
for (const source of [config.headers, options?.headers]) {
|
|
5828
|
+
for (const [key, value] of Object.entries(source ?? {})) {
|
|
5829
|
+
const normalized = normalizeHeaderValue3(value);
|
|
5830
|
+
if (normalized) {
|
|
5831
|
+
headers[key] = normalized;
|
|
5832
|
+
}
|
|
5833
|
+
}
|
|
5834
|
+
}
|
|
5835
|
+
return headers;
|
|
5836
|
+
}
|
|
5837
|
+
function withJsonBody(init, body) {
|
|
5838
|
+
return {
|
|
5839
|
+
...init,
|
|
5840
|
+
body: body === void 0 ? void 0 : JSON.stringify(body),
|
|
5841
|
+
headers: {
|
|
5842
|
+
"Content-Type": "application/json",
|
|
5843
|
+
...init.headers
|
|
5844
|
+
}
|
|
5845
|
+
};
|
|
5846
|
+
}
|
|
5847
|
+
async function request(config, method, endpoint, options, body) {
|
|
5848
|
+
if (!config.baseUrl) {
|
|
5849
|
+
throw new Error(
|
|
5850
|
+
"Athena chat base URL is not configured. Pass createClient({ url }) for unified routing or set chat.url / chatUrl explicitly."
|
|
5851
|
+
);
|
|
5852
|
+
}
|
|
5853
|
+
const url = `${config.baseUrl}${endpoint}`;
|
|
5854
|
+
const init = {
|
|
5855
|
+
method,
|
|
5856
|
+
headers: buildHeaders3(config, options),
|
|
5857
|
+
signal: options?.signal
|
|
5858
|
+
};
|
|
5859
|
+
const finalInit = body === void 0 || method === "GET" ? init : withJsonBody(init, body);
|
|
5860
|
+
const response = await fetch(url, finalInit);
|
|
5861
|
+
const rawText = await response.text();
|
|
5862
|
+
const { parsed } = parseResponseBody4(rawText, response.headers.get("content-type"));
|
|
5863
|
+
if (!response.ok) {
|
|
5864
|
+
throw new AthenaChatError({
|
|
5865
|
+
message: resolveErrorMessage4(parsed, `Athena chat ${method} ${endpoint} failed with ${response.status}`),
|
|
5866
|
+
status: response.status,
|
|
5867
|
+
endpoint,
|
|
5868
|
+
method,
|
|
5869
|
+
requestId: resolveRequestId3(response.headers),
|
|
5870
|
+
body: parsed
|
|
5871
|
+
});
|
|
5872
|
+
}
|
|
5873
|
+
return parsed;
|
|
5874
|
+
}
|
|
5875
|
+
function unwrapEnvelopeData(payload) {
|
|
5876
|
+
return payload.data;
|
|
5877
|
+
}
|
|
5878
|
+
function createRealtimeConnection(config, options) {
|
|
5879
|
+
if (!config.wsUrl) {
|
|
5880
|
+
throw new Error(
|
|
5881
|
+
"Athena chat WebSocket URL is not configured. Pass createClient({ url }) for unified routing or set chat.wsUrl / chatWsUrl explicitly."
|
|
5882
|
+
);
|
|
5883
|
+
}
|
|
5884
|
+
const wsFactory = config.webSocketFactory ?? globalThis.WebSocket;
|
|
5885
|
+
if (!wsFactory) {
|
|
5886
|
+
throw new Error(
|
|
5887
|
+
"No WebSocket implementation is available. Provide chat.webSocketFactory in createClient(...) or run in a runtime with global WebSocket support."
|
|
5888
|
+
);
|
|
5889
|
+
}
|
|
5890
|
+
const socket = createSocket(wsFactory, config.wsUrl, options?.protocols);
|
|
5891
|
+
const send = (command) => {
|
|
5892
|
+
socket.send(JSON.stringify(command));
|
|
5893
|
+
};
|
|
5894
|
+
if (options?.onMessage) {
|
|
5895
|
+
const listener = (event) => {
|
|
5896
|
+
const messageEvent = event;
|
|
5897
|
+
const raw = messageEvent?.data;
|
|
5898
|
+
if (typeof raw !== "string") {
|
|
5899
|
+
return;
|
|
5900
|
+
}
|
|
5901
|
+
try {
|
|
5902
|
+
options.onMessage?.(JSON.parse(raw));
|
|
5903
|
+
} catch {
|
|
5904
|
+
options.onMessage?.({ type: "error", error: "Invalid JSON message from Athena chat realtime gateway." });
|
|
5905
|
+
}
|
|
5906
|
+
};
|
|
5907
|
+
if (typeof socket.addEventListener === "function") {
|
|
5908
|
+
socket.addEventListener("message", listener);
|
|
5909
|
+
} else {
|
|
5910
|
+
socket.onmessage = listener;
|
|
5911
|
+
}
|
|
5912
|
+
}
|
|
5913
|
+
const hello = (command) => {
|
|
5914
|
+
send({
|
|
5915
|
+
type: "auth.hello",
|
|
5916
|
+
token: command?.token,
|
|
5917
|
+
room_subscriptions: command?.room_subscriptions
|
|
5918
|
+
});
|
|
5919
|
+
};
|
|
5920
|
+
if (options?.hello) {
|
|
5921
|
+
const onOpen = () => hello({
|
|
5922
|
+
token: options.hello?.token ?? void 0,
|
|
5923
|
+
room_subscriptions: options.hello?.room_subscriptions ?? void 0
|
|
5924
|
+
});
|
|
5925
|
+
if (typeof socket.addEventListener === "function") {
|
|
5926
|
+
socket.addEventListener("open", onOpen);
|
|
5927
|
+
} else {
|
|
5928
|
+
socket.onopen = onOpen;
|
|
5929
|
+
}
|
|
5930
|
+
}
|
|
5931
|
+
return {
|
|
5932
|
+
socket,
|
|
5933
|
+
send,
|
|
5934
|
+
hello,
|
|
5935
|
+
subscribe(roomId, fromSeq) {
|
|
5936
|
+
send({
|
|
5937
|
+
type: "chat.subscribe",
|
|
5938
|
+
room_id: roomId,
|
|
5939
|
+
from_seq: fromSeq ?? void 0
|
|
5940
|
+
});
|
|
5941
|
+
},
|
|
5942
|
+
unsubscribe(roomId) {
|
|
5943
|
+
send({
|
|
5944
|
+
type: "chat.unsubscribe",
|
|
5945
|
+
room_id: roomId
|
|
5946
|
+
});
|
|
5947
|
+
},
|
|
5948
|
+
resume(rooms) {
|
|
5949
|
+
send({
|
|
5950
|
+
type: "chat.resume",
|
|
5951
|
+
rooms
|
|
5952
|
+
});
|
|
5953
|
+
},
|
|
5954
|
+
typingStart(roomId) {
|
|
5955
|
+
send({
|
|
5956
|
+
type: "chat.typing.start",
|
|
5957
|
+
room_id: roomId
|
|
5958
|
+
});
|
|
5959
|
+
},
|
|
5960
|
+
typingStop(roomId) {
|
|
5961
|
+
send({
|
|
5962
|
+
type: "chat.typing.stop",
|
|
5963
|
+
room_id: roomId
|
|
5964
|
+
});
|
|
5965
|
+
},
|
|
5966
|
+
presenceHeartbeat(activeRoomId) {
|
|
5967
|
+
send({
|
|
5968
|
+
type: "chat.presence.heartbeat",
|
|
5969
|
+
active_room_id: activeRoomId ?? void 0
|
|
5970
|
+
});
|
|
5971
|
+
},
|
|
5972
|
+
readUpTo(roomId, input) {
|
|
5973
|
+
send({
|
|
5974
|
+
type: "chat.read.up_to",
|
|
5975
|
+
room_id: roomId,
|
|
5976
|
+
message_id: input?.message_id ?? void 0,
|
|
5977
|
+
seq: input?.seq ?? void 0
|
|
5978
|
+
});
|
|
5979
|
+
},
|
|
5980
|
+
ping(at = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
5981
|
+
send({
|
|
5982
|
+
type: "ping",
|
|
5983
|
+
at
|
|
5984
|
+
});
|
|
5985
|
+
},
|
|
5986
|
+
close(code, reason) {
|
|
5987
|
+
socket.close(code, reason);
|
|
5988
|
+
}
|
|
5989
|
+
};
|
|
5990
|
+
}
|
|
5991
|
+
function createChatModule(config) {
|
|
5992
|
+
const realtime = {
|
|
5993
|
+
info(options) {
|
|
5994
|
+
const realtimeInfoUrl = config.realtimeInfoUrl ?? deriveRealtimeInfoUrl(config.wsUrl);
|
|
5995
|
+
if (!realtimeInfoUrl) {
|
|
5996
|
+
throw new Error(
|
|
5997
|
+
"Athena chat realtime info URL is not configured. Pass createClient({ url }) for unified routing or set chat.wsUrl / chatWsUrl explicitly."
|
|
5998
|
+
);
|
|
5999
|
+
}
|
|
6000
|
+
return request(
|
|
6001
|
+
{
|
|
6002
|
+
...config,
|
|
6003
|
+
baseUrl: realtimeInfoUrl
|
|
6004
|
+
},
|
|
6005
|
+
"GET",
|
|
6006
|
+
"",
|
|
6007
|
+
options
|
|
6008
|
+
);
|
|
6009
|
+
},
|
|
6010
|
+
connect(options) {
|
|
6011
|
+
return createRealtimeConnection(config, options);
|
|
6012
|
+
}
|
|
6013
|
+
};
|
|
6014
|
+
return {
|
|
6015
|
+
room: {
|
|
6016
|
+
list(query, options) {
|
|
6017
|
+
return request(
|
|
6018
|
+
config,
|
|
6019
|
+
"GET",
|
|
6020
|
+
`/rooms${encodeQuery(query)}`,
|
|
6021
|
+
options
|
|
6022
|
+
);
|
|
6023
|
+
},
|
|
6024
|
+
create(input, options) {
|
|
6025
|
+
return request(config, "POST", "/rooms", options, input);
|
|
6026
|
+
},
|
|
6027
|
+
get(roomId, options) {
|
|
6028
|
+
return request(
|
|
6029
|
+
config,
|
|
6030
|
+
"GET",
|
|
6031
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}`,
|
|
6032
|
+
options
|
|
6033
|
+
);
|
|
6034
|
+
},
|
|
6035
|
+
update(roomId, input, options) {
|
|
6036
|
+
return request(
|
|
6037
|
+
config,
|
|
6038
|
+
"PATCH",
|
|
6039
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}`,
|
|
6040
|
+
options,
|
|
6041
|
+
input
|
|
6042
|
+
);
|
|
6043
|
+
},
|
|
6044
|
+
archive(roomId, options) {
|
|
6045
|
+
return request(
|
|
6046
|
+
config,
|
|
6047
|
+
"POST",
|
|
6048
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/archive`,
|
|
6049
|
+
options
|
|
6050
|
+
);
|
|
6051
|
+
},
|
|
6052
|
+
readCursor: {
|
|
6053
|
+
upTo(roomId, input, options) {
|
|
6054
|
+
return request(
|
|
6055
|
+
config,
|
|
6056
|
+
"POST",
|
|
6057
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/read-cursor`,
|
|
6058
|
+
options,
|
|
6059
|
+
input ?? {}
|
|
6060
|
+
);
|
|
6061
|
+
}
|
|
6062
|
+
},
|
|
6063
|
+
member: {
|
|
6064
|
+
list(roomId, options) {
|
|
6065
|
+
return request(
|
|
6066
|
+
config,
|
|
6067
|
+
"GET",
|
|
6068
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/members`,
|
|
6069
|
+
options
|
|
6070
|
+
);
|
|
6071
|
+
},
|
|
6072
|
+
add(roomId, input, options) {
|
|
6073
|
+
return request(
|
|
6074
|
+
config,
|
|
6075
|
+
"POST",
|
|
6076
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/members`,
|
|
6077
|
+
options,
|
|
6078
|
+
input
|
|
6079
|
+
);
|
|
6080
|
+
},
|
|
6081
|
+
remove(roomId, userId, options) {
|
|
6082
|
+
return request(
|
|
6083
|
+
config,
|
|
6084
|
+
"DELETE",
|
|
6085
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/members/${encodePathSegment(userId, "chat user ID")}`,
|
|
6086
|
+
options
|
|
6087
|
+
);
|
|
6088
|
+
}
|
|
6089
|
+
},
|
|
6090
|
+
message: {
|
|
6091
|
+
list(roomId, query, options) {
|
|
6092
|
+
return request(
|
|
6093
|
+
config,
|
|
6094
|
+
"GET",
|
|
6095
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/messages${encodeQuery(query)}`,
|
|
6096
|
+
options
|
|
6097
|
+
);
|
|
6098
|
+
},
|
|
6099
|
+
send(roomId, input, options) {
|
|
6100
|
+
return request(
|
|
6101
|
+
config,
|
|
6102
|
+
"POST",
|
|
6103
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/messages`,
|
|
6104
|
+
options,
|
|
6105
|
+
input
|
|
6106
|
+
);
|
|
6107
|
+
},
|
|
6108
|
+
update(roomId, messageId, input, options) {
|
|
6109
|
+
return request(
|
|
6110
|
+
config,
|
|
6111
|
+
"PATCH",
|
|
6112
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/messages/${encodePathSegment(messageId, "chat message ID")}`,
|
|
6113
|
+
options,
|
|
6114
|
+
input
|
|
6115
|
+
);
|
|
6116
|
+
},
|
|
6117
|
+
delete(roomId, messageId, options) {
|
|
6118
|
+
return request(
|
|
6119
|
+
config,
|
|
6120
|
+
"DELETE",
|
|
6121
|
+
`/rooms/${encodePathSegment(roomId, "chat room ID")}/messages/${encodePathSegment(messageId, "chat message ID")}`,
|
|
6122
|
+
options
|
|
6123
|
+
);
|
|
6124
|
+
}
|
|
6125
|
+
}
|
|
6126
|
+
},
|
|
6127
|
+
message: {
|
|
6128
|
+
reaction: {
|
|
6129
|
+
add(messageId, input, options) {
|
|
6130
|
+
return request(
|
|
6131
|
+
config,
|
|
6132
|
+
"POST",
|
|
6133
|
+
`/messages/${encodePathSegment(messageId, "chat message ID")}/reactions`,
|
|
6134
|
+
options,
|
|
6135
|
+
input
|
|
6136
|
+
);
|
|
6137
|
+
},
|
|
6138
|
+
remove(messageId, emoji, options) {
|
|
6139
|
+
return request(
|
|
6140
|
+
config,
|
|
6141
|
+
"DELETE",
|
|
6142
|
+
`/messages/${encodePathSegment(messageId, "chat message ID")}/reactions/${encodePathSegment(emoji, "reaction emoji")}`,
|
|
6143
|
+
options
|
|
6144
|
+
);
|
|
6145
|
+
}
|
|
6146
|
+
},
|
|
6147
|
+
search(input, options) {
|
|
6148
|
+
return request(
|
|
6149
|
+
config,
|
|
6150
|
+
"POST",
|
|
6151
|
+
"/messages/search",
|
|
6152
|
+
options,
|
|
6153
|
+
input
|
|
6154
|
+
);
|
|
6155
|
+
}
|
|
6156
|
+
},
|
|
6157
|
+
realtime
|
|
6158
|
+
};
|
|
6159
|
+
}
|
|
6160
|
+
var chatSdkManifest = {
|
|
6161
|
+
namespace: "chat",
|
|
6162
|
+
basePath: "/chat",
|
|
6163
|
+
methods: [
|
|
6164
|
+
{ name: "listRooms", method: "GET", path: "/chat/rooms" },
|
|
6165
|
+
{ name: "createRoom", method: "POST", path: "/chat/rooms" },
|
|
6166
|
+
{ name: "getRoom", method: "GET", path: "/chat/rooms/{room_id}" },
|
|
6167
|
+
{ name: "updateRoom", method: "PATCH", path: "/chat/rooms/{room_id}" },
|
|
6168
|
+
{ name: "archiveRoom", method: "POST", path: "/chat/rooms/{room_id}/archive" },
|
|
6169
|
+
{ name: "listRoomMessages", method: "GET", path: "/chat/rooms/{room_id}/messages" },
|
|
6170
|
+
{ name: "sendRoomMessage", method: "POST", path: "/chat/rooms/{room_id}/messages" },
|
|
6171
|
+
{ name: "updateRoomMessage", method: "PATCH", path: "/chat/rooms/{room_id}/messages/{message_id}" },
|
|
6172
|
+
{ name: "deleteRoomMessage", method: "DELETE", path: "/chat/rooms/{room_id}/messages/{message_id}" },
|
|
6173
|
+
{ name: "advanceReadCursor", method: "POST", path: "/chat/rooms/{room_id}/read-cursor" },
|
|
6174
|
+
{ name: "listRoomMembers", method: "GET", path: "/chat/rooms/{room_id}/members" },
|
|
6175
|
+
{ name: "addRoomMembers", method: "POST", path: "/chat/rooms/{room_id}/members" },
|
|
6176
|
+
{ name: "removeRoomMember", method: "DELETE", path: "/chat/rooms/{room_id}/members/{user_id}" },
|
|
6177
|
+
{ name: "addReaction", method: "POST", path: "/chat/messages/{message_id}/reactions" },
|
|
6178
|
+
{ name: "removeReaction", method: "DELETE", path: "/chat/messages/{message_id}/reactions/{emoji}" },
|
|
6179
|
+
{ name: "searchMessages", method: "POST", path: "/chat/messages/search" },
|
|
6180
|
+
{ name: "getRealtimeInfo", method: "GET", path: "/wss/info" },
|
|
6181
|
+
{ name: "connectRealtime", method: "GET", path: "/wss/gateway" }
|
|
6182
|
+
]
|
|
6183
|
+
};
|
|
6184
|
+
function unwrapChatRoom(payload) {
|
|
6185
|
+
return unwrapEnvelopeData(payload);
|
|
6186
|
+
}
|
|
6187
|
+
function unwrapChatMessage(payload) {
|
|
6188
|
+
return unwrapEnvelopeData(payload);
|
|
6189
|
+
}
|
|
6190
|
+
|
|
5619
6191
|
// src/client-builder.ts
|
|
5620
6192
|
var DEFAULT_BACKEND = { type: "athena" };
|
|
5621
6193
|
function toBackendConfig(value) {
|
|
@@ -5828,7 +6400,7 @@ var BOOLEAN_SAFE_OPERATORS = /* @__PURE__ */ new Set([
|
|
|
5828
6400
|
"ilike",
|
|
5829
6401
|
"is"
|
|
5830
6402
|
]);
|
|
5831
|
-
function
|
|
6403
|
+
function isRecord8(value) {
|
|
5832
6404
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
5833
6405
|
}
|
|
5834
6406
|
function isUuidString(value) {
|
|
@@ -5841,7 +6413,7 @@ function shouldUseUuidTextComparison(column, value) {
|
|
|
5841
6413
|
return typeof value === "string" && isUuidString(value) && isUuidIdentifierColumn(column);
|
|
5842
6414
|
}
|
|
5843
6415
|
function isRelationSelectNode(value) {
|
|
5844
|
-
return
|
|
6416
|
+
return isRecord8(value) && isRecord8(value.select);
|
|
5845
6417
|
}
|
|
5846
6418
|
function normalizeIdentifier(value, label) {
|
|
5847
6419
|
const normalized = value.trim();
|
|
@@ -5897,7 +6469,7 @@ function compileRelationToken(key, node) {
|
|
|
5897
6469
|
return `${prefix}${relationToken}(${nested})`;
|
|
5898
6470
|
}
|
|
5899
6471
|
function compileSelectShape(select) {
|
|
5900
|
-
if (!
|
|
6472
|
+
if (!isRecord8(select)) {
|
|
5901
6473
|
throw new Error("findMany select must be an object");
|
|
5902
6474
|
}
|
|
5903
6475
|
const tokens = [];
|
|
@@ -5921,7 +6493,7 @@ function compileSelectShape(select) {
|
|
|
5921
6493
|
return tokens.join(",");
|
|
5922
6494
|
}
|
|
5923
6495
|
function selectShapeUsesRelationSchema(select) {
|
|
5924
|
-
if (!
|
|
6496
|
+
if (!isRecord8(select)) {
|
|
5925
6497
|
return false;
|
|
5926
6498
|
}
|
|
5927
6499
|
for (const rawValue of Object.values(select)) {
|
|
@@ -5939,7 +6511,7 @@ function selectShapeUsesRelationSchema(select) {
|
|
|
5939
6511
|
}
|
|
5940
6512
|
function compileColumnWhere(column, input) {
|
|
5941
6513
|
const normalizedColumn = normalizeIdentifier(column, "where column");
|
|
5942
|
-
if (!
|
|
6514
|
+
if (!isRecord8(input)) {
|
|
5943
6515
|
return [buildGatewayCondition("eq", normalizedColumn, input)];
|
|
5944
6516
|
}
|
|
5945
6517
|
const conditions = [];
|
|
@@ -5967,7 +6539,7 @@ function compileColumnWhere(column, input) {
|
|
|
5967
6539
|
return conditions;
|
|
5968
6540
|
}
|
|
5969
6541
|
function compileBooleanExpressionTerms(clause, label) {
|
|
5970
|
-
if (!
|
|
6542
|
+
if (!isRecord8(clause)) {
|
|
5971
6543
|
throw new Error(`findMany where.${label} clauses must be objects`);
|
|
5972
6544
|
}
|
|
5973
6545
|
const entries = Object.entries(clause).filter(([, value]) => value !== void 0);
|
|
@@ -5976,7 +6548,7 @@ function compileBooleanExpressionTerms(clause, label) {
|
|
|
5976
6548
|
}
|
|
5977
6549
|
const [rawColumn, rawValue] = entries[0];
|
|
5978
6550
|
const column = normalizeIdentifier(rawColumn, `where.${label} column`);
|
|
5979
|
-
if (!
|
|
6551
|
+
if (!isRecord8(rawValue)) {
|
|
5980
6552
|
return [`${column}.eq.${stringifyFilterValue(rawValue)}`];
|
|
5981
6553
|
}
|
|
5982
6554
|
const operatorEntries = Object.entries(rawValue).filter(([, value]) => value !== void 0);
|
|
@@ -6000,7 +6572,7 @@ function compileWhere(where) {
|
|
|
6000
6572
|
if (where === void 0) {
|
|
6001
6573
|
return void 0;
|
|
6002
6574
|
}
|
|
6003
|
-
if (!
|
|
6575
|
+
if (!isRecord8(where)) {
|
|
6004
6576
|
throw new Error("findMany where must be an object");
|
|
6005
6577
|
}
|
|
6006
6578
|
const conditions = [];
|
|
@@ -6050,7 +6622,7 @@ function compileOrderBy(orderBy) {
|
|
|
6050
6622
|
if (orderBy === void 0) {
|
|
6051
6623
|
return void 0;
|
|
6052
6624
|
}
|
|
6053
|
-
if (!
|
|
6625
|
+
if (!isRecord8(orderBy)) {
|
|
6054
6626
|
throw new Error("findMany orderBy must be an object");
|
|
6055
6627
|
}
|
|
6056
6628
|
if ("column" in orderBy) {
|
|
@@ -6225,11 +6797,11 @@ function toFindManyAstOrder(order) {
|
|
|
6225
6797
|
ascending: order.direction !== "descending"
|
|
6226
6798
|
};
|
|
6227
6799
|
}
|
|
6228
|
-
function
|
|
6800
|
+
function isRecord9(value) {
|
|
6229
6801
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6230
6802
|
}
|
|
6231
6803
|
function normalizeFindManyAstColumnPredicate(value) {
|
|
6232
|
-
if (!
|
|
6804
|
+
if (!isRecord9(value)) {
|
|
6233
6805
|
return {
|
|
6234
6806
|
eq: value
|
|
6235
6807
|
};
|
|
@@ -6253,7 +6825,7 @@ function normalizeFindManyAstBooleanOperand(clause) {
|
|
|
6253
6825
|
return normalized;
|
|
6254
6826
|
}
|
|
6255
6827
|
function normalizeFindManyAstWhere(where) {
|
|
6256
|
-
if (!where || !
|
|
6828
|
+
if (!where || !isRecord9(where)) {
|
|
6257
6829
|
return where;
|
|
6258
6830
|
}
|
|
6259
6831
|
const normalized = {};
|
|
@@ -6267,7 +6839,7 @@ function normalizeFindManyAstWhere(where) {
|
|
|
6267
6839
|
);
|
|
6268
6840
|
continue;
|
|
6269
6841
|
}
|
|
6270
|
-
if (key === "not" &&
|
|
6842
|
+
if (key === "not" && isRecord9(value)) {
|
|
6271
6843
|
normalized.not = normalizeFindManyAstBooleanOperand(
|
|
6272
6844
|
value
|
|
6273
6845
|
);
|
|
@@ -6278,7 +6850,7 @@ function normalizeFindManyAstWhere(where) {
|
|
|
6278
6850
|
return normalized;
|
|
6279
6851
|
}
|
|
6280
6852
|
function predicateRequiresUuidQueryFallback(column, value) {
|
|
6281
|
-
if (!
|
|
6853
|
+
if (!isRecord9(value)) {
|
|
6282
6854
|
return shouldUseUuidTextComparison(column, value);
|
|
6283
6855
|
}
|
|
6284
6856
|
const eqValue = value.eq;
|
|
@@ -6296,7 +6868,7 @@ function booleanOperandRequiresUuidQueryFallback(clause) {
|
|
|
6296
6868
|
return false;
|
|
6297
6869
|
}
|
|
6298
6870
|
function findManyAstWhereRequiresLegacyTransport(where) {
|
|
6299
|
-
if (!where || !
|
|
6871
|
+
if (!where || !isRecord9(where)) {
|
|
6300
6872
|
return false;
|
|
6301
6873
|
}
|
|
6302
6874
|
for (const [key, value] of Object.entries(where)) {
|
|
@@ -6311,7 +6883,7 @@ function findManyAstWhereRequiresLegacyTransport(where) {
|
|
|
6311
6883
|
}
|
|
6312
6884
|
continue;
|
|
6313
6885
|
}
|
|
6314
|
-
if (key === "not" &&
|
|
6886
|
+
if (key === "not" && isRecord9(value)) {
|
|
6315
6887
|
if (booleanOperandRequiresUuidQueryFallback(value)) {
|
|
6316
6888
|
return true;
|
|
6317
6889
|
}
|
|
@@ -6860,6 +7432,7 @@ function resolveAthenaModelTargetTableName(target, options = {}) {
|
|
|
6860
7432
|
var DEFAULT_COLUMNS = "*";
|
|
6861
7433
|
var SAFE_CAST_PATTERN = /^[a-z_][a-z0-9_]*(?:\[\])?$/i;
|
|
6862
7434
|
var ATHENA_NORMALIZED_ERROR_KEY = "__athenaNormalizedError";
|
|
7435
|
+
var SDK_NAME4 = "xylex-group/athena";
|
|
6863
7436
|
function formatResult(response) {
|
|
6864
7437
|
const result = {
|
|
6865
7438
|
data: response.data ?? null,
|
|
@@ -6936,7 +7509,7 @@ async function executeExperimentalRead(experimental, runner) {
|
|
|
6936
7509
|
throw error;
|
|
6937
7510
|
}
|
|
6938
7511
|
}
|
|
6939
|
-
function
|
|
7512
|
+
function isRecord10(value) {
|
|
6940
7513
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
6941
7514
|
}
|
|
6942
7515
|
function firstNonEmptyString2(...values) {
|
|
@@ -6948,8 +7521,8 @@ function firstNonEmptyString2(...values) {
|
|
|
6948
7521
|
return void 0;
|
|
6949
7522
|
}
|
|
6950
7523
|
function resolveStructuredErrorPayload2(raw) {
|
|
6951
|
-
if (!
|
|
6952
|
-
return
|
|
7524
|
+
if (!isRecord10(raw)) return null;
|
|
7525
|
+
return isRecord10(raw.error) ? raw.error : raw;
|
|
6953
7526
|
}
|
|
6954
7527
|
function resolveStructuredErrorDetails(payload, message) {
|
|
6955
7528
|
if (!payload || !("details" in payload)) {
|
|
@@ -6965,7 +7538,7 @@ function resolveStructuredErrorDetails(payload, message) {
|
|
|
6965
7538
|
return details;
|
|
6966
7539
|
}
|
|
6967
7540
|
function createResultError(response, result, normalized) {
|
|
6968
|
-
const rawRecord =
|
|
7541
|
+
const rawRecord = isRecord10(response.raw) ? response.raw : null;
|
|
6969
7542
|
const payload = resolveStructuredErrorPayload2(response.raw);
|
|
6970
7543
|
const message = firstNonEmptyString2(
|
|
6971
7544
|
response.error,
|
|
@@ -7028,6 +7601,43 @@ function asAthenaJsonObject(value) {
|
|
|
7028
7601
|
function asAthenaJsonObjectArray(values) {
|
|
7029
7602
|
return values;
|
|
7030
7603
|
}
|
|
7604
|
+
function parseArbitraryResponseBody(rawText, contentType) {
|
|
7605
|
+
if (!rawText) {
|
|
7606
|
+
return null;
|
|
7607
|
+
}
|
|
7608
|
+
const contentTypeSuggestsJson = contentType?.toLowerCase().includes("application/json") ?? false;
|
|
7609
|
+
const looksJson = contentTypeSuggestsJson || rawText.startsWith("{") || rawText.startsWith("[");
|
|
7610
|
+
if (!looksJson) {
|
|
7611
|
+
return rawText;
|
|
7612
|
+
}
|
|
7613
|
+
try {
|
|
7614
|
+
return JSON.parse(rawText);
|
|
7615
|
+
} catch {
|
|
7616
|
+
return rawText;
|
|
7617
|
+
}
|
|
7618
|
+
}
|
|
7619
|
+
function toRequestQueryString(query) {
|
|
7620
|
+
if (!query) {
|
|
7621
|
+
return "";
|
|
7622
|
+
}
|
|
7623
|
+
const params = new URLSearchParams();
|
|
7624
|
+
for (const [key, value] of Object.entries(query)) {
|
|
7625
|
+
if (value === void 0 || value === null) {
|
|
7626
|
+
continue;
|
|
7627
|
+
}
|
|
7628
|
+
if (Array.isArray(value)) {
|
|
7629
|
+
for (const item of value) {
|
|
7630
|
+
if (item !== void 0 && item !== null) {
|
|
7631
|
+
params.append(key, String(item));
|
|
7632
|
+
}
|
|
7633
|
+
}
|
|
7634
|
+
continue;
|
|
7635
|
+
}
|
|
7636
|
+
params.set(key, String(value));
|
|
7637
|
+
}
|
|
7638
|
+
const encoded = params.toString();
|
|
7639
|
+
return encoded ? `?${encoded}` : "";
|
|
7640
|
+
}
|
|
7031
7641
|
function normalizeSelectColumnsInput(columns) {
|
|
7032
7642
|
if (columns === void 0) {
|
|
7033
7643
|
return void 0;
|
|
@@ -8334,6 +8944,8 @@ var ATHENA_ENV_GATEWAY_URL_KEYS = [
|
|
|
8334
8944
|
"NEXT_PUBLIC_ATHENA_DB_API_URL"
|
|
8335
8945
|
];
|
|
8336
8946
|
var ATHENA_ENV_AUTH_URL_KEYS = ["ATHENA_AUTH_URL", "NEXT_PUBLIC_ATHENA_AUTH_URL"];
|
|
8947
|
+
var ATHENA_ENV_CHAT_URL_KEYS = ["ATHENA_CHAT_URL", "NEXT_PUBLIC_ATHENA_CHAT_URL"];
|
|
8948
|
+
var ATHENA_ENV_CHAT_WS_URL_KEYS = ["ATHENA_CHAT_WS_URL", "NEXT_PUBLIC_ATHENA_CHAT_WS_URL"];
|
|
8337
8949
|
var ATHENA_ENV_STORAGE_URL_KEYS = ["ATHENA_STORAGE_URL", "NEXT_PUBLIC_ATHENA_STORAGE_URL"];
|
|
8338
8950
|
var ATHENA_ENV_KEY_KEYS = [
|
|
8339
8951
|
"ATHENA_API_KEY",
|
|
@@ -8414,6 +9026,15 @@ function appendServicePath(baseUrl, segment) {
|
|
|
8414
9026
|
const normalizedBaseUrl = normalizeAthenaGatewayBaseUrl(baseUrl, { label: "Athena public base URL" });
|
|
8415
9027
|
return `${normalizedBaseUrl}/${segment.replace(/^\/+/, "")}`;
|
|
8416
9028
|
}
|
|
9029
|
+
function appendRealtimeGatewayPath(baseUrl) {
|
|
9030
|
+
const normalizedBaseUrl = normalizeAthenaGatewayBaseUrl(baseUrl, { label: "Athena public base URL" });
|
|
9031
|
+
const wsUrl = new URL(normalizedBaseUrl);
|
|
9032
|
+
wsUrl.protocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
9033
|
+
wsUrl.pathname = `${wsUrl.pathname.replace(/\/+$/, "")}/wss/gateway`;
|
|
9034
|
+
wsUrl.search = "";
|
|
9035
|
+
wsUrl.hash = "";
|
|
9036
|
+
return wsUrl.toString();
|
|
9037
|
+
}
|
|
8417
9038
|
function resolveServiceUrlOverride(value, label) {
|
|
8418
9039
|
return resolveClientServiceBaseUrl(value, label);
|
|
8419
9040
|
}
|
|
@@ -8422,6 +9043,8 @@ function resolveServiceUrls(config) {
|
|
|
8422
9043
|
return {
|
|
8423
9044
|
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),
|
|
8424
9045
|
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),
|
|
9046
|
+
chatUrl: resolveServiceUrlOverride(config.chat?.url, "Athena chat base URL") ?? resolveServiceUrlOverride(config.chatUrl, "Athena chat base URL") ?? (baseUrl ? appendServicePath(baseUrl, "chat") : void 0),
|
|
9047
|
+
chatWsUrl: normalizeOptionalString(config.chat?.wsUrl) ?? normalizeOptionalString(config.chatWsUrl) ?? (baseUrl ? appendRealtimeGatewayPath(baseUrl) : void 0),
|
|
8425
9048
|
storageUrl: resolveServiceUrlOverride(config.storage?.url, "Athena storage base URL") ?? resolveServiceUrlOverride(config.storageUrl, "Athena storage base URL") ?? (baseUrl ? appendServicePath(baseUrl, "storage") : void 0)
|
|
8426
9049
|
};
|
|
8427
9050
|
}
|
|
@@ -8514,6 +9137,7 @@ function mergeClientOverrideOptions(base, overrides) {
|
|
|
8514
9137
|
} : void 0,
|
|
8515
9138
|
db: base.db ? { ...base.db } : void 0,
|
|
8516
9139
|
gateway: base.gateway ? { ...base.gateway } : void 0,
|
|
9140
|
+
chat: base.chat ? { ...base.chat } : void 0,
|
|
8517
9141
|
storage: base.storage ? { ...base.storage } : void 0
|
|
8518
9142
|
};
|
|
8519
9143
|
}
|
|
@@ -8524,6 +9148,7 @@ function mergeClientOverrideOptions(base, overrides) {
|
|
|
8524
9148
|
auth: mergeAuthClientOptions(base.auth, overrides.auth),
|
|
8525
9149
|
db: mergeServiceUrlOverrides(base.db, overrides.db),
|
|
8526
9150
|
gateway: mergeServiceUrlOverrides(base.gateway, overrides.gateway),
|
|
9151
|
+
chat: mergeServiceUrlOverrides(base.chat, overrides.chat),
|
|
8527
9152
|
storage: mergeServiceUrlOverrides(base.storage, overrides.storage)
|
|
8528
9153
|
};
|
|
8529
9154
|
}
|
|
@@ -8582,6 +9207,9 @@ function resolveCreateClientConfig(config) {
|
|
|
8582
9207
|
headers: config.headers,
|
|
8583
9208
|
auth: config.auth,
|
|
8584
9209
|
authUrl: resolvedUrls.authUrl,
|
|
9210
|
+
chat: config.chat,
|
|
9211
|
+
chatUrl: resolvedUrls.chatUrl,
|
|
9212
|
+
chatWsUrl: resolvedUrls.chatWsUrl,
|
|
8585
9213
|
storageUrl: resolvedUrls.storageUrl,
|
|
8586
9214
|
experimental: config.experimental
|
|
8587
9215
|
};
|
|
@@ -8666,6 +9294,119 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
8666
9294
|
queryTracer
|
|
8667
9295
|
);
|
|
8668
9296
|
const db = createDbModule({ from, rpc, query });
|
|
9297
|
+
const chat = createChatModule({
|
|
9298
|
+
baseUrl: config.chatUrl,
|
|
9299
|
+
apiKey: config.apiKey,
|
|
9300
|
+
client: config.client,
|
|
9301
|
+
headers: config.headers,
|
|
9302
|
+
bearerToken: normalizedAuthConfig?.bearerToken,
|
|
9303
|
+
cookie: normalizedAuthConfig?.cookie,
|
|
9304
|
+
sessionToken: normalizedAuthConfig?.sessionToken,
|
|
9305
|
+
forceNoCache: config.forceNoCache,
|
|
9306
|
+
wsUrl: config.chatWsUrl,
|
|
9307
|
+
webSocketFactory: config.chat?.webSocketFactory ?? void 0
|
|
9308
|
+
});
|
|
9309
|
+
const request2 = async (options) => {
|
|
9310
|
+
const method = options.method ?? "GET";
|
|
9311
|
+
const responseType = options.responseType ?? "json";
|
|
9312
|
+
const service = options.service ?? "db";
|
|
9313
|
+
const baseUrlByService = {
|
|
9314
|
+
db: config.baseUrl,
|
|
9315
|
+
auth: config.authUrl,
|
|
9316
|
+
chat: config.chatUrl,
|
|
9317
|
+
storage: config.storageUrl
|
|
9318
|
+
};
|
|
9319
|
+
const resolvedBaseUrl = options.url ?? baseUrlByService[service];
|
|
9320
|
+
if (!resolvedBaseUrl) {
|
|
9321
|
+
throw new Error(
|
|
9322
|
+
`Athena ${service} base URL is not configured. Pass createClient({ url }) for unified routing or set the service-specific URL first.`
|
|
9323
|
+
);
|
|
9324
|
+
}
|
|
9325
|
+
const normalizedBaseUrl = normalizeAthenaGatewayBaseUrl(resolvedBaseUrl, {
|
|
9326
|
+
label: `Athena ${service} base URL`
|
|
9327
|
+
});
|
|
9328
|
+
const normalizedPath = options.url ? "" : (() => {
|
|
9329
|
+
const path = options.path?.trim();
|
|
9330
|
+
if (!path) {
|
|
9331
|
+
throw new Error("client.request(...) requires either an absolute url or a non-empty path.");
|
|
9332
|
+
}
|
|
9333
|
+
return path.startsWith("/") ? path : `/${path}`;
|
|
9334
|
+
})();
|
|
9335
|
+
const targetUrl = options.url ? `${normalizedBaseUrl}${toRequestQueryString(options.query)}` : `${normalizedBaseUrl}${normalizedPath}${toRequestQueryString(options.query)}`;
|
|
9336
|
+
const headers = {
|
|
9337
|
+
"X-Athena-Sdk": buildSdkHeaderValue(SDK_NAME4),
|
|
9338
|
+
...config.headers ?? {},
|
|
9339
|
+
...options.headers ?? {}
|
|
9340
|
+
};
|
|
9341
|
+
if (service !== "auth") {
|
|
9342
|
+
headers.apikey = headers.apikey ?? config.apiKey;
|
|
9343
|
+
headers["x-api-key"] = headers["x-api-key"] ?? config.apiKey;
|
|
9344
|
+
if (config.client && !hasHeaderIgnoreCase(headers, "X-Athena-Client")) {
|
|
9345
|
+
headers["X-Athena-Client"] = config.client;
|
|
9346
|
+
}
|
|
9347
|
+
if (config.userId && !hasHeaderIgnoreCase(headers, "X-User-Id")) {
|
|
9348
|
+
headers["X-User-Id"] = config.userId;
|
|
9349
|
+
}
|
|
9350
|
+
if (config.organizationId && !hasHeaderIgnoreCase(headers, "X-Organization-Id")) {
|
|
9351
|
+
headers["X-Organization-Id"] = config.organizationId;
|
|
9352
|
+
}
|
|
9353
|
+
if (normalizedAuthConfig?.sessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
9354
|
+
headers["X-Athena-Auth-Session-Token"] = normalizedAuthConfig.sessionToken;
|
|
9355
|
+
}
|
|
9356
|
+
if (normalizedAuthConfig?.bearerToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Bearer-Token")) {
|
|
9357
|
+
headers["X-Athena-Auth-Bearer-Token"] = normalizedAuthConfig.bearerToken;
|
|
9358
|
+
}
|
|
9359
|
+
if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
9360
|
+
headers.Cookie = normalizedAuthConfig.cookie;
|
|
9361
|
+
}
|
|
9362
|
+
} else {
|
|
9363
|
+
const authApiKey = normalizedAuthConfig?.apiKey ?? config.apiKey;
|
|
9364
|
+
if (authApiKey && !hasHeaderIgnoreCase(headers, "x-api-key")) {
|
|
9365
|
+
headers.apikey = headers.apikey ?? authApiKey;
|
|
9366
|
+
headers["x-api-key"] = headers["x-api-key"] ?? authApiKey;
|
|
9367
|
+
}
|
|
9368
|
+
if (normalizedAuthConfig?.bearerToken && !hasHeaderIgnoreCase(headers, "Authorization")) {
|
|
9369
|
+
headers.Authorization = `Bearer ${normalizedAuthConfig.bearerToken}`;
|
|
9370
|
+
}
|
|
9371
|
+
if (normalizedAuthConfig?.cookie && !hasHeaderIgnoreCase(headers, "Cookie")) {
|
|
9372
|
+
headers.Cookie = normalizedAuthConfig.cookie;
|
|
9373
|
+
}
|
|
9374
|
+
if (normalizedAuthConfig?.sessionToken && !hasHeaderIgnoreCase(headers, "X-Athena-Auth-Session-Token")) {
|
|
9375
|
+
headers["X-Athena-Auth-Session-Token"] = normalizedAuthConfig.sessionToken;
|
|
9376
|
+
}
|
|
9377
|
+
}
|
|
9378
|
+
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";
|
|
9379
|
+
if (shouldSendJsonBody && !hasHeaderIgnoreCase(headers, "Content-Type")) {
|
|
9380
|
+
headers["Content-Type"] = "application/json";
|
|
9381
|
+
}
|
|
9382
|
+
const response = await fetch(targetUrl, {
|
|
9383
|
+
method,
|
|
9384
|
+
headers,
|
|
9385
|
+
body: options.body === void 0 || options.body === null ? void 0 : shouldSendJsonBody ? JSON.stringify(options.body) : options.body,
|
|
9386
|
+
signal: options.signal,
|
|
9387
|
+
credentials: options.credentials
|
|
9388
|
+
});
|
|
9389
|
+
if (responseType === "response") {
|
|
9390
|
+
return {
|
|
9391
|
+
ok: response.ok,
|
|
9392
|
+
status: response.status,
|
|
9393
|
+
statusText: response.statusText,
|
|
9394
|
+
headers: response.headers,
|
|
9395
|
+
data: null,
|
|
9396
|
+
raw: response
|
|
9397
|
+
};
|
|
9398
|
+
}
|
|
9399
|
+
const rawText = await response.text();
|
|
9400
|
+
const parsed = responseType === "text" ? rawText : parseArbitraryResponseBody(rawText, response.headers.get("content-type"));
|
|
9401
|
+
return {
|
|
9402
|
+
ok: response.ok,
|
|
9403
|
+
status: response.status,
|
|
9404
|
+
statusText: response.statusText,
|
|
9405
|
+
headers: response.headers,
|
|
9406
|
+
data: parsed,
|
|
9407
|
+
raw: response
|
|
9408
|
+
};
|
|
9409
|
+
};
|
|
8669
9410
|
const withContext = (context) => createClientFromInput(
|
|
8670
9411
|
mergeClientOverrideOptions(sourceConfig, toClientContextOverrides(context))
|
|
8671
9412
|
);
|
|
@@ -8681,8 +9422,10 @@ function createClientFromConfig(config, sourceConfig) {
|
|
|
8681
9422
|
db,
|
|
8682
9423
|
rpc,
|
|
8683
9424
|
query,
|
|
9425
|
+
request: request2,
|
|
8684
9426
|
verifyConnection: gateway.verifyConnection,
|
|
8685
9427
|
auth: auth.auth,
|
|
9428
|
+
chat,
|
|
8686
9429
|
withContext,
|
|
8687
9430
|
withSession,
|
|
8688
9431
|
withOptions: authWithOptions
|
|
@@ -8727,6 +9470,8 @@ var AthenaClient = class {
|
|
|
8727
9470
|
const url = options.url ?? readFirstEnvValue(env, ATHENA_ENV_URL_KEYS);
|
|
8728
9471
|
const gatewayUrl = options.gatewayUrl ?? readFirstEnvValue(env, ATHENA_ENV_GATEWAY_URL_KEYS);
|
|
8729
9472
|
const authUrl = options.authUrl ?? readFirstEnvValue(env, ATHENA_ENV_AUTH_URL_KEYS);
|
|
9473
|
+
const chatUrl = options.chatUrl ?? readFirstEnvValue(env, ATHENA_ENV_CHAT_URL_KEYS);
|
|
9474
|
+
const chatWsUrl = options.chatWsUrl ?? readFirstEnvValue(env, ATHENA_ENV_CHAT_WS_URL_KEYS);
|
|
8730
9475
|
const storageUrl = options.storageUrl ?? readFirstEnvValue(env, ATHENA_ENV_STORAGE_URL_KEYS);
|
|
8731
9476
|
const key = options.key ?? readFirstEnvValue(env, ATHENA_ENV_KEY_KEYS);
|
|
8732
9477
|
const client = options.client ?? readFirstEnvValue(env, ATHENA_ENV_CLIENT_KEYS);
|
|
@@ -8741,6 +9486,8 @@ var AthenaClient = class {
|
|
|
8741
9486
|
url,
|
|
8742
9487
|
gatewayUrl,
|
|
8743
9488
|
authUrl,
|
|
9489
|
+
chatUrl,
|
|
9490
|
+
chatWsUrl,
|
|
8744
9491
|
storageUrl,
|
|
8745
9492
|
key,
|
|
8746
9493
|
client
|
|
@@ -8786,7 +9533,7 @@ function resolveNullishValue(mode) {
|
|
|
8786
9533
|
if (mode === "null") return null;
|
|
8787
9534
|
return "";
|
|
8788
9535
|
}
|
|
8789
|
-
function
|
|
9536
|
+
function isRecord11(value) {
|
|
8790
9537
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
8791
9538
|
}
|
|
8792
9539
|
function isNullableColumn(model, key) {
|
|
@@ -8795,7 +9542,7 @@ function isNullableColumn(model, key) {
|
|
|
8795
9542
|
}
|
|
8796
9543
|
function toModelFormDefaults(model, values, options) {
|
|
8797
9544
|
const source = values;
|
|
8798
|
-
if (!
|
|
9545
|
+
if (!isRecord11(source)) {
|
|
8799
9546
|
return {};
|
|
8800
9547
|
}
|
|
8801
9548
|
const mode = options?.nullishMode ?? "empty-string";
|
|
@@ -9309,6 +10056,9 @@ var TypedAthenaClientImpl = class _TypedAthenaClientImpl {
|
|
|
9309
10056
|
query(query, options) {
|
|
9310
10057
|
return this.baseClient.query(query, options);
|
|
9311
10058
|
}
|
|
10059
|
+
request(options) {
|
|
10060
|
+
return this.baseClient.request(options);
|
|
10061
|
+
}
|
|
9312
10062
|
verifyConnection(options) {
|
|
9313
10063
|
return this.baseClient.verifyConnection(options);
|
|
9314
10064
|
}
|
|
@@ -11605,15 +12355,15 @@ function readCookieFromHeaders(headers, name) {
|
|
|
11605
12355
|
}
|
|
11606
12356
|
return parseCookies(cookieHeader).get(name);
|
|
11607
12357
|
}
|
|
11608
|
-
function
|
|
12358
|
+
function isRecord12(value) {
|
|
11609
12359
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
11610
12360
|
}
|
|
11611
12361
|
function resolveSessionCandidate(value) {
|
|
11612
|
-
if (!
|
|
12362
|
+
if (!isRecord12(value)) {
|
|
11613
12363
|
return null;
|
|
11614
12364
|
}
|
|
11615
|
-
const session =
|
|
11616
|
-
const user =
|
|
12365
|
+
const session = isRecord12(value.session) ? value.session : void 0;
|
|
12366
|
+
const user = isRecord12(value.user) ? value.user : void 0;
|
|
11617
12367
|
if (session && typeof session.token === "string" && session.token.length > 0 && user) {
|
|
11618
12368
|
return {
|
|
11619
12369
|
session,
|
|
@@ -11623,7 +12373,7 @@ function resolveSessionCandidate(value) {
|
|
|
11623
12373
|
return null;
|
|
11624
12374
|
}
|
|
11625
12375
|
function inferSessionPair(returned) {
|
|
11626
|
-
return resolveSessionCandidate(returned) ?? (
|
|
12376
|
+
return resolveSessionCandidate(returned) ?? (isRecord12(returned) ? resolveSessionCandidate(returned.data) : null) ?? (isRecord12(returned) ? resolveSessionCandidate(returned.session) : null);
|
|
11627
12377
|
}
|
|
11628
12378
|
function resolveResponseHeaders(ctx) {
|
|
11629
12379
|
if (ctx.context.responseHeaders instanceof Headers) {
|
|
@@ -11646,23 +12396,23 @@ function normalizeBasePath(basePath) {
|
|
|
11646
12396
|
function isDynamicBaseURLConfig2(baseURL) {
|
|
11647
12397
|
return typeof baseURL === "object" && baseURL !== null && "allowedHosts" in baseURL && Array.isArray(baseURL.allowedHosts);
|
|
11648
12398
|
}
|
|
11649
|
-
function getRequestUrl(
|
|
12399
|
+
function getRequestUrl(request2) {
|
|
11650
12400
|
try {
|
|
11651
|
-
return new URL(
|
|
12401
|
+
return new URL(request2.url);
|
|
11652
12402
|
} catch {
|
|
11653
12403
|
return new URL("http://localhost");
|
|
11654
12404
|
}
|
|
11655
12405
|
}
|
|
11656
|
-
function getRequestHost(
|
|
11657
|
-
const forwardedHost =
|
|
11658
|
-
const host = forwardedHost ||
|
|
12406
|
+
function getRequestHost(request2, url) {
|
|
12407
|
+
const forwardedHost = request2.headers.get("x-forwarded-host")?.split(",")[0]?.trim();
|
|
12408
|
+
const host = forwardedHost || request2.headers.get("host") || url.host;
|
|
11659
12409
|
return host || null;
|
|
11660
12410
|
}
|
|
11661
|
-
function getRequestProtocol(
|
|
12411
|
+
function getRequestProtocol(request2, configuredProtocol, url) {
|
|
11662
12412
|
if (configuredProtocol === "http" || configuredProtocol === "https") {
|
|
11663
12413
|
return configuredProtocol;
|
|
11664
12414
|
}
|
|
11665
|
-
const forwardedProto =
|
|
12415
|
+
const forwardedProto = request2.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();
|
|
11666
12416
|
if (forwardedProto === "http" || forwardedProto === "https") {
|
|
11667
12417
|
return forwardedProto;
|
|
11668
12418
|
}
|
|
@@ -11671,12 +12421,12 @@ function getRequestProtocol(request, configuredProtocol, url) {
|
|
|
11671
12421
|
}
|
|
11672
12422
|
return "http";
|
|
11673
12423
|
}
|
|
11674
|
-
function resolveRequestBaseURL(baseURL,
|
|
12424
|
+
function resolveRequestBaseURL(baseURL, request2) {
|
|
11675
12425
|
if (typeof baseURL === "string") {
|
|
11676
12426
|
return normalizeBaseURL(baseURL);
|
|
11677
12427
|
}
|
|
11678
|
-
const requestUrl = getRequestUrl(
|
|
11679
|
-
const host = getRequestHost(
|
|
12428
|
+
const requestUrl = getRequestUrl(request2);
|
|
12429
|
+
const host = getRequestHost(request2, requestUrl);
|
|
11680
12430
|
if (!host) {
|
|
11681
12431
|
return null;
|
|
11682
12432
|
}
|
|
@@ -11686,7 +12436,7 @@ function resolveRequestBaseURL(baseURL, request) {
|
|
|
11686
12436
|
return null;
|
|
11687
12437
|
}
|
|
11688
12438
|
}
|
|
11689
|
-
const protocol = typeof baseURL === "object" && baseURL !== null ? getRequestProtocol(
|
|
12439
|
+
const protocol = typeof baseURL === "object" && baseURL !== null ? getRequestProtocol(request2, baseURL.protocol, requestUrl) : getRequestProtocol(request2, void 0, requestUrl);
|
|
11690
12440
|
return `${protocol}://${host}`;
|
|
11691
12441
|
}
|
|
11692
12442
|
function getOrigin(baseURL) {
|
|
@@ -11699,16 +12449,16 @@ function getOrigin(baseURL) {
|
|
|
11699
12449
|
return void 0;
|
|
11700
12450
|
}
|
|
11701
12451
|
}
|
|
11702
|
-
async function resolveTrustedOrigins(config, baseURL,
|
|
11703
|
-
const resolved = typeof config.trustedOrigins === "function" ? await config.trustedOrigins(
|
|
12452
|
+
async function resolveTrustedOrigins(config, baseURL, request2) {
|
|
12453
|
+
const resolved = typeof config.trustedOrigins === "function" ? await config.trustedOrigins(request2) : config.trustedOrigins ?? [];
|
|
11704
12454
|
const values = [
|
|
11705
12455
|
getOrigin(baseURL),
|
|
11706
12456
|
...resolved
|
|
11707
12457
|
];
|
|
11708
12458
|
return Array.from(new Set(values.filter((value) => typeof value === "string" && value.length > 0)));
|
|
11709
12459
|
}
|
|
11710
|
-
async function resolveTrustedProviders(config,
|
|
11711
|
-
const configured = typeof config.trustedProviders === "function" ? await config.trustedProviders(
|
|
12460
|
+
async function resolveTrustedProviders(config, request2) {
|
|
12461
|
+
const configured = typeof config.trustedProviders === "function" ? await config.trustedProviders(request2) : config.trustedProviders ?? [];
|
|
11712
12462
|
const values = [
|
|
11713
12463
|
...Object.keys(config.socialProviders ?? {}),
|
|
11714
12464
|
...configured
|
|
@@ -11833,9 +12583,9 @@ function athenaAuth(config) {
|
|
|
11833
12583
|
}
|
|
11834
12584
|
return ctx;
|
|
11835
12585
|
};
|
|
11836
|
-
const resolveRequestContext = async (
|
|
11837
|
-
const requestUrl = getRequestUrl(
|
|
11838
|
-
const resolvedBaseURL = resolveRequestBaseURL(config.baseURL,
|
|
12586
|
+
const resolveRequestContext = async (request2) => {
|
|
12587
|
+
const requestUrl = getRequestUrl(request2);
|
|
12588
|
+
const resolvedBaseURL = resolveRequestBaseURL(config.baseURL, request2);
|
|
11839
12589
|
if (!resolvedBaseURL) {
|
|
11840
12590
|
throw new Error(
|
|
11841
12591
|
isDynamicBaseURLConfig2(config.baseURL) ? "Could not resolve base URL from request. Check allowedHosts/baseURL." : "Could not resolve base URL from request."
|
|
@@ -11846,17 +12596,17 @@ function athenaAuth(config) {
|
|
|
11846
12596
|
session: config.session,
|
|
11847
12597
|
advanced: config.advanced
|
|
11848
12598
|
});
|
|
11849
|
-
const trustedOrigins = await resolveTrustedOrigins(config, resolvedBaseURL,
|
|
11850
|
-
const trustedProviders = await resolveTrustedProviders(config,
|
|
12599
|
+
const trustedOrigins = await resolveTrustedOrigins(config, resolvedBaseURL, request2);
|
|
12600
|
+
const trustedProviders = await resolveTrustedProviders(config, request2);
|
|
11851
12601
|
return {
|
|
11852
12602
|
auth,
|
|
11853
|
-
request,
|
|
12603
|
+
request: request2,
|
|
11854
12604
|
url: requestUrl,
|
|
11855
12605
|
path: requestUrl.pathname,
|
|
11856
12606
|
basePath: normalizedBasePath,
|
|
11857
12607
|
baseURL: resolvedBaseURL,
|
|
11858
12608
|
origin: getOrigin(resolvedBaseURL) ?? resolvedBaseURL,
|
|
11859
|
-
headers:
|
|
12609
|
+
headers: request2.headers,
|
|
11860
12610
|
cookies: requestCookies,
|
|
11861
12611
|
trustedOrigins,
|
|
11862
12612
|
trustedProviders,
|
|
@@ -11869,8 +12619,8 @@ function athenaAuth(config) {
|
|
|
11869
12619
|
socialProviders: auth.socialProviders
|
|
11870
12620
|
};
|
|
11871
12621
|
};
|
|
11872
|
-
const handler = async (
|
|
11873
|
-
const requestContext = await resolveRequestContext(
|
|
12622
|
+
const handler = async (request2) => {
|
|
12623
|
+
const requestContext = await resolveRequestContext(request2);
|
|
11874
12624
|
if (typeof config.handler !== "function") {
|
|
11875
12625
|
return createJsonResponse(
|
|
11876
12626
|
{
|
|
@@ -11891,7 +12641,7 @@ function athenaAuth(config) {
|
|
|
11891
12641
|
const responseHeaders = new Headers(response.headers);
|
|
11892
12642
|
await runAfterHooks({
|
|
11893
12643
|
path: requestContext.path,
|
|
11894
|
-
headers:
|
|
12644
|
+
headers: request2.headers,
|
|
11895
12645
|
context: {
|
|
11896
12646
|
responseHeaders,
|
|
11897
12647
|
returned: result.returned,
|
|
@@ -11967,6 +12717,6 @@ function athenaAuth(config) {
|
|
|
11967
12717
|
return auth;
|
|
11968
12718
|
}
|
|
11969
12719
|
|
|
11970
|
-
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 };
|
|
12720
|
+
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 };
|
|
11971
12721
|
//# sourceMappingURL=index.js.map
|
|
11972
12722
|
//# sourceMappingURL=index.js.map
|