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