@xylex-group/athena 2.6.0 → 2.7.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.
Files changed (44) hide show
  1. package/README.md +1 -1
  2. package/dist/browser.cjs +837 -114
  3. package/dist/browser.cjs.map +1 -1
  4. package/dist/browser.d.cts +7 -7
  5. package/dist/browser.d.ts +7 -7
  6. package/dist/browser.js +837 -114
  7. package/dist/browser.js.map +1 -1
  8. package/dist/cli/index.cjs +830 -107
  9. package/dist/cli/index.cjs.map +1 -1
  10. package/dist/cli/index.d.cts +3 -3
  11. package/dist/cli/index.d.ts +3 -3
  12. package/dist/cli/index.js +830 -107
  13. package/dist/cli/index.js.map +1 -1
  14. package/dist/cookies.cjs +10 -3
  15. package/dist/cookies.cjs.map +1 -1
  16. package/dist/cookies.js +10 -3
  17. package/dist/cookies.js.map +1 -1
  18. package/dist/index.cjs +837 -114
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +7 -7
  21. package/dist/index.d.ts +7 -7
  22. package/dist/index.js +837 -114
  23. package/dist/index.js.map +1 -1
  24. package/dist/model-form-AKYrgede.d.ts +2772 -0
  25. package/dist/model-form-ehfqLuG7.d.cts +2772 -0
  26. package/dist/{pipeline-Ce3pTw5h.d.ts → pipeline-BUsR9XlO.d.ts} +1 -1
  27. package/dist/{pipeline-D1ZYeoH7.d.cts → pipeline-BfCWSRYl.d.cts} +1 -1
  28. package/dist/react-email-BQzmXBDE.d.cts +304 -0
  29. package/dist/react-email-BrVRp80B.d.ts +304 -0
  30. package/dist/react.cjs +178 -71
  31. package/dist/react.cjs.map +1 -1
  32. package/dist/react.d.cts +22 -5
  33. package/dist/react.d.ts +22 -5
  34. package/dist/react.js +92 -5
  35. package/dist/react.js.map +1 -1
  36. package/dist/{types-CUuo4NDi.d.cts → types-BSIsyss1.d.cts} +1 -1
  37. package/dist/{types-DSX6AT5B.d.cts → types-BsyRW49r.d.cts} +1 -1
  38. package/dist/{types-DSX6AT5B.d.ts → types-BsyRW49r.d.ts} +1 -1
  39. package/dist/{types-DapchQY5.d.ts → types-t_TVqnmp.d.ts} +1 -1
  40. package/package.json +193 -193
  41. package/dist/model-form-BaHWi3gm.d.cts +0 -1383
  42. package/dist/model-form-Dh6gWjL0.d.ts +0 -1383
  43. package/dist/react-email-B8O1Jeff.d.cts +0 -1230
  44. package/dist/react-email-CDEF0jij.d.ts +0 -1230
package/dist/cli/index.js CHANGED
@@ -1495,16 +1495,23 @@ var getSessionCookie = (request, config) => {
1495
1495
  const { cookieName = "session_token", cookiePrefix = "athena-auth" } = {};
1496
1496
  const parsedCookie = parseCookies(cookies);
1497
1497
  const getCookie = (name) => parsedCookie.get(name) || parsedCookie.get(`${SECURE_COOKIE_PREFIX}${name}`);
1498
- const sessionToken = getCookie(`${cookiePrefix}.${cookieName}`) || getCookie(`${cookiePrefix}-${cookieName}`);
1499
- if (sessionToken) {
1500
- return sessionToken;
1498
+ const candidateCookieNames = Array.from(/* @__PURE__ */ new Set([
1499
+ cookieName,
1500
+ cookieName.replace(/_/g, "-"),
1501
+ cookieName.replace(/-/g, "_")
1502
+ ])).filter(Boolean);
1503
+ for (const candidateName of candidateCookieNames) {
1504
+ const sessionToken = getCookie(`${cookiePrefix}.${candidateName}`) || getCookie(`${cookiePrefix}-${candidateName}`);
1505
+ if (sessionToken) {
1506
+ return sessionToken;
1507
+ }
1501
1508
  }
1502
1509
  return null;
1503
1510
  };
1504
1511
 
1505
1512
  // package.json
1506
1513
  var package_default = {
1507
- version: "2.6.0"
1514
+ version: "2.7.0"
1508
1515
  };
1509
1516
 
1510
1517
  // src/sdk-version.ts
@@ -3479,6 +3486,344 @@ function createDbModule(input) {
3479
3486
  return db;
3480
3487
  }
3481
3488
 
3489
+ // src/storage/file.ts
3490
+ function createStorageFileModule(base, config = {}) {
3491
+ const upload = async (input, options) => {
3492
+ const sources = normalizeUploadSources(input);
3493
+ validateUploadConstraints(sources, input);
3494
+ const uploadRequests = sources.map((source, index) => {
3495
+ const storageKey = resolveUploadStorageKey(input, source, index, options, config);
3496
+ return {
3497
+ source,
3498
+ uploadRequest: {
3499
+ s3_id: input.s3_id,
3500
+ bucket: input.bucket,
3501
+ storage_key: storageKey,
3502
+ name: input.name ?? source.fileName,
3503
+ original_name: input.original_name ?? source.fileName,
3504
+ resource_id: input.resource_id ?? input.resourceId,
3505
+ mime_type: input.mime_type ?? source.contentType,
3506
+ content_type: input.content_type ?? source.contentType,
3507
+ size_bytes: source.sizeBytes,
3508
+ public: input.public,
3509
+ metadata: input.metadata
3510
+ }
3511
+ };
3512
+ });
3513
+ input.onProgress?.(createProgressSnapshot("preparing", sources, 0, 0, 0));
3514
+ const uploadUrls = uploadRequests.length === 1 ? [await base.createStorageUploadUrl(uploadRequests[0].uploadRequest, options)] : (await base.createStorageUploadUrls({ files: uploadRequests.map((request) => request.uploadRequest) }, options)).files;
3515
+ const aggregateLoaded = new Array(uploadRequests.length).fill(0);
3516
+ const uploaded = [];
3517
+ for (let index = 0; index < uploadRequests.length; index += 1) {
3518
+ const request = uploadRequests[index];
3519
+ const uploadUrl = uploadUrls[index];
3520
+ const response = await putUploadBody(uploadUrl.upload.url, request.source, input, options, (progress) => {
3521
+ aggregateLoaded[index] = progress.loaded;
3522
+ input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
3523
+ });
3524
+ uploaded.push({
3525
+ file: uploadUrl.file,
3526
+ upload: uploadUrl.upload,
3527
+ source: request.source.source,
3528
+ fileName: request.source.fileName,
3529
+ storage_key: request.uploadRequest.storage_key,
3530
+ response
3531
+ });
3532
+ aggregateLoaded[index] = request.source.sizeBytes;
3533
+ input.onProgress?.(createProgressSnapshot("complete", sources, index, request.source.sizeBytes, sum(aggregateLoaded)));
3534
+ }
3535
+ return {
3536
+ files: uploaded,
3537
+ count: uploaded.length
3538
+ };
3539
+ };
3540
+ const download = ((input, queryOrOptions, maybeOptions) => {
3541
+ const { fileIds, query, options } = normalizeDownloadArgs(input, queryOrOptions, maybeOptions);
3542
+ const downloads = fileIds.map((fileId) => base.getStorageFileProxy(fileId, query, options));
3543
+ return Array.isArray(input) || isRecord5(input) && Array.isArray(input.fileIds) ? Promise.all(downloads) : downloads[0];
3544
+ });
3545
+ const deleteFile = ((input, options) => {
3546
+ if (Array.isArray(input)) {
3547
+ return Promise.all(input.map((fileId) => base.deleteStorageFile(fileId, options)));
3548
+ }
3549
+ return base.deleteStorageFile(input, options);
3550
+ });
3551
+ return {
3552
+ upload,
3553
+ download,
3554
+ list(input, options) {
3555
+ const prefix = resolveStoragePath(input.prefix ?? "", input, options, config);
3556
+ return base.listStorageFiles(
3557
+ {
3558
+ s3_id: input.s3_id,
3559
+ prefix
3560
+ },
3561
+ options
3562
+ );
3563
+ },
3564
+ delete: deleteFile
3565
+ };
3566
+ }
3567
+ function resolveStoragePath(path, input, options, config = {}) {
3568
+ const context = createPathContext(input, options, config);
3569
+ const prefixPath = input.prefixPath ?? config.prefixPath;
3570
+ const prefix = typeof prefixPath === "function" ? prefixPath(context) : prefixPath;
3571
+ return joinStoragePath(renderStorageTemplate(prefix ?? "", context), renderStorageTemplate(path, context));
3572
+ }
3573
+ function resolveUploadStorageKey(input, source, index, options, config) {
3574
+ const explicitKey = input.storage_key ?? input.storageKey;
3575
+ const keyTemplate = input.storageKeyTemplate;
3576
+ const fallbackName = source.fileName;
3577
+ const context = createPathContext(input, options, config);
3578
+ const key = keyTemplate ? renderStorageTemplate(keyTemplate, {
3579
+ ...context,
3580
+ vars: {
3581
+ ...context.vars,
3582
+ index,
3583
+ fileName: source.fileName,
3584
+ name: source.fileName
3585
+ }
3586
+ }) : explicitKey ?? fallbackName;
3587
+ return resolveStoragePath(key, input, options, config);
3588
+ }
3589
+ function normalizeUploadSources(input) {
3590
+ const files = toArray(input.files);
3591
+ if (files.length === 0) {
3592
+ throw new Error("athena.storage.file.upload requires at least one file");
3593
+ }
3594
+ return files.map((source, index) => {
3595
+ const fileName = input.fileName ?? sourceName(source) ?? `file-${index + 1}`;
3596
+ const sizeBytes = sourceSize(source);
3597
+ const contentType = input.content_type ?? input.mime_type ?? sourceContentType(source);
3598
+ return {
3599
+ source,
3600
+ fileName,
3601
+ sizeBytes,
3602
+ contentType
3603
+ };
3604
+ });
3605
+ }
3606
+ function validateUploadConstraints(sources, input) {
3607
+ const maxFiles = input.maxFiles ?? 1;
3608
+ if (sources.length > maxFiles) {
3609
+ throw new Error(`athena.storage.file.upload accepts at most ${maxFiles} file${maxFiles === 1 ? "" : "s"} for this call`);
3610
+ }
3611
+ const maxFileSizeBytes = input.maxFileSizeBytes ?? (input.maxFileSizeMb === void 0 ? void 0 : Math.floor(input.maxFileSizeMb * 1024 * 1024));
3612
+ if (maxFileSizeBytes !== void 0) {
3613
+ const tooLarge = sources.find((source) => source.sizeBytes > maxFileSizeBytes);
3614
+ if (tooLarge) {
3615
+ throw new Error(`athena.storage.file.upload rejected ${tooLarge.fileName}: file exceeds ${maxFileSizeBytes} bytes`);
3616
+ }
3617
+ }
3618
+ const allowedExtensions = normalizeExtensions(input.allowedExtensions ?? input.extensions);
3619
+ if (allowedExtensions.size > 0) {
3620
+ const invalid = sources.find((source) => !allowedExtensions.has(fileExtension(source.fileName)));
3621
+ if (invalid) {
3622
+ throw new Error(`athena.storage.file.upload rejected ${invalid.fileName}: extension is not allowed`);
3623
+ }
3624
+ }
3625
+ }
3626
+ async function putUploadBody(url, source, input, options, onProgress) {
3627
+ const headers = new Headers(input.uploadHeaders);
3628
+ if (source.contentType && !headers.has("Content-Type")) {
3629
+ headers.set("Content-Type", source.contentType);
3630
+ }
3631
+ if (typeof XMLHttpRequest !== "undefined") {
3632
+ return putUploadBodyWithXhr(url, source, headers, options, onProgress);
3633
+ }
3634
+ onProgress({ loaded: 0 });
3635
+ const response = await fetch(url, {
3636
+ method: "PUT",
3637
+ headers,
3638
+ body: source.source,
3639
+ signal: options?.signal
3640
+ });
3641
+ if (!response.ok) {
3642
+ throw new Error(`athena.storage.file.upload failed with status ${response.status}`);
3643
+ }
3644
+ onProgress({ loaded: source.sizeBytes });
3645
+ return response;
3646
+ }
3647
+ function putUploadBodyWithXhr(url, source, headers, options, onProgress) {
3648
+ const Xhr = XMLHttpRequest;
3649
+ if (Xhr === void 0) {
3650
+ return Promise.reject(new Error("athena.storage.file.upload requires XMLHttpRequest in this runtime"));
3651
+ }
3652
+ return new Promise((resolve3, reject) => {
3653
+ const xhr = new Xhr();
3654
+ const abort = () => xhr.abort();
3655
+ xhr.open("PUT", url);
3656
+ headers.forEach((value, key) => xhr.setRequestHeader(key, value));
3657
+ xhr.upload.onprogress = (event) => {
3658
+ onProgress({ loaded: event.loaded });
3659
+ };
3660
+ xhr.onload = () => {
3661
+ if (options?.signal) {
3662
+ options.signal.removeEventListener("abort", abort);
3663
+ }
3664
+ if (xhr.status < 200 || xhr.status >= 300) {
3665
+ reject(new Error(`athena.storage.file.upload failed with status ${xhr.status}`));
3666
+ return;
3667
+ }
3668
+ onProgress({ loaded: source.sizeBytes });
3669
+ resolve3(new Response(xhr.response, {
3670
+ status: xhr.status,
3671
+ statusText: xhr.statusText,
3672
+ headers: parseXhrHeaders(xhr.getAllResponseHeaders())
3673
+ }));
3674
+ };
3675
+ xhr.onerror = () => {
3676
+ if (options?.signal) {
3677
+ options.signal.removeEventListener("abort", abort);
3678
+ }
3679
+ reject(new Error("athena.storage.file.upload failed with a network error"));
3680
+ };
3681
+ xhr.onabort = () => {
3682
+ if (options?.signal) {
3683
+ options.signal.removeEventListener("abort", abort);
3684
+ }
3685
+ reject(new DOMException("Upload aborted", "AbortError"));
3686
+ };
3687
+ if (options?.signal) {
3688
+ if (options.signal.aborted) {
3689
+ abort();
3690
+ return;
3691
+ }
3692
+ options.signal.addEventListener("abort", abort, { once: true });
3693
+ }
3694
+ xhr.send(source.source);
3695
+ });
3696
+ }
3697
+ function normalizeDownloadArgs(input, queryOrOptions, maybeOptions) {
3698
+ if (typeof input === "string") {
3699
+ return { fileIds: [input], query: queryOrOptions, options: maybeOptions };
3700
+ }
3701
+ if (Array.isArray(input)) {
3702
+ return { fileIds: [...input], query: queryOrOptions, options: maybeOptions };
3703
+ }
3704
+ const downloadInput = input;
3705
+ const { fileId, fileIds, ...query } = downloadInput;
3706
+ return {
3707
+ fileIds: fileIds ? [...fileIds] : fileId ? [fileId] : [],
3708
+ query,
3709
+ options: queryOrOptions
3710
+ };
3711
+ }
3712
+ function createPathContext(input, options, config) {
3713
+ const organizationId = input.organizationId ?? input.organization_id ?? options?.organizationId ?? void 0;
3714
+ const userId = input.userId ?? input.user_id ?? options?.userId ?? void 0;
3715
+ const resourceId = input.resourceId ?? input.resource_id ?? void 0;
3716
+ const vars = {
3717
+ ...config.vars ?? {},
3718
+ ...input.vars ?? {}
3719
+ };
3720
+ if (organizationId !== void 0) {
3721
+ vars.organizationId = organizationId;
3722
+ vars.organization_id = organizationId;
3723
+ }
3724
+ if (userId !== void 0) {
3725
+ vars.userId = userId;
3726
+ vars.user_id = userId;
3727
+ }
3728
+ if (resourceId !== void 0) {
3729
+ vars.resourceId = resourceId;
3730
+ vars.resource_id = resourceId;
3731
+ }
3732
+ return {
3733
+ vars,
3734
+ env: {
3735
+ ...readProcessEnv(),
3736
+ ...config.env ?? {},
3737
+ ...input.env ?? {}
3738
+ },
3739
+ organizationId,
3740
+ organization_id: organizationId,
3741
+ userId,
3742
+ user_id: userId,
3743
+ resourceId,
3744
+ resource_id: resourceId
3745
+ };
3746
+ }
3747
+ function renderStorageTemplate(template, context) {
3748
+ return template.replace(/\$\{([^}]+)\}|\{([^}]+)\}/g, (_match, shellToken, braceToken) => {
3749
+ const token = (shellToken ?? braceToken ?? "").trim();
3750
+ if (!token) return "";
3751
+ const value = resolveTemplateToken(token, context);
3752
+ return value === void 0 || value === null ? "" : String(value);
3753
+ });
3754
+ }
3755
+ function resolveTemplateToken(token, context) {
3756
+ if (token.startsWith("env.")) {
3757
+ return context.env[token.slice(4)];
3758
+ }
3759
+ if (token in context.vars) {
3760
+ return context.vars[token];
3761
+ }
3762
+ return context.env[token];
3763
+ }
3764
+ function joinStoragePath(...parts) {
3765
+ return parts.map((part) => part.trim().replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/");
3766
+ }
3767
+ function toArray(files) {
3768
+ if (isUploadSource(files)) return [files];
3769
+ return Array.from(files);
3770
+ }
3771
+ function isUploadSource(value) {
3772
+ return value instanceof Blob || value instanceof ArrayBuffer || value instanceof Uint8Array;
3773
+ }
3774
+ function sourceName(source) {
3775
+ return isRecord5(source) && typeof source.name === "string" && source.name.trim() ? source.name.trim() : void 0;
3776
+ }
3777
+ function sourceSize(source) {
3778
+ if (source instanceof Blob) return source.size;
3779
+ return source.byteLength;
3780
+ }
3781
+ function sourceContentType(source) {
3782
+ return source instanceof Blob && source.type.trim() ? source.type.trim() : void 0;
3783
+ }
3784
+ function normalizeExtensions(extensions) {
3785
+ return new Set((extensions ?? []).map((extension) => extension.replace(/^\./, "").toLowerCase()).filter(Boolean));
3786
+ }
3787
+ function fileExtension(fileName) {
3788
+ const lastDot = fileName.lastIndexOf(".");
3789
+ return lastDot === -1 ? "" : fileName.slice(lastDot + 1).toLowerCase();
3790
+ }
3791
+ function createProgressSnapshot(phase, sources, fileIndex, loaded, aggregateLoaded) {
3792
+ const total = sources[fileIndex]?.sizeBytes ?? 0;
3793
+ const aggregateTotal = sources.reduce((totalBytes, source) => totalBytes + source.sizeBytes, 0);
3794
+ return {
3795
+ phase,
3796
+ fileIndex,
3797
+ fileCount: sources.length,
3798
+ fileName: sources[fileIndex]?.fileName ?? "",
3799
+ loaded,
3800
+ total,
3801
+ percent: total > 0 ? Math.round(loaded / total * 100) : 100,
3802
+ aggregateLoaded,
3803
+ aggregateTotal,
3804
+ aggregatePercent: aggregateTotal > 0 ? Math.round(aggregateLoaded / aggregateTotal * 100) : 100
3805
+ };
3806
+ }
3807
+ function sum(values) {
3808
+ return values.reduce((total, value) => total + value, 0);
3809
+ }
3810
+ function parseXhrHeaders(raw) {
3811
+ const headers = new Headers();
3812
+ for (const line of raw.trim().split(/[\r\n]+/)) {
3813
+ const index = line.indexOf(":");
3814
+ if (index === -1) continue;
3815
+ headers.set(line.slice(0, index).trim(), line.slice(index + 1).trim());
3816
+ }
3817
+ return headers;
3818
+ }
3819
+ function readProcessEnv() {
3820
+ const processLike = globalThis.process;
3821
+ return processLike?.env ?? {};
3822
+ }
3823
+ function isRecord5(value) {
3824
+ return Boolean(value) && typeof value === "object";
3825
+ }
3826
+
3482
3827
  // src/storage/module.ts
3483
3828
  var storageSdkManifest = {
3484
3829
  methods: [
@@ -3673,7 +4018,7 @@ var AthenaStorageError = class extends Error {
3673
4018
  };
3674
4019
  }
3675
4020
  };
3676
- function isRecord5(value) {
4021
+ function isRecord6(value) {
3677
4022
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
3678
4023
  }
3679
4024
  function causeToString(cause) {
@@ -3788,7 +4133,7 @@ function withPathParam(path, name, value) {
3788
4133
  return path.replace(`{${name}}`, encodeURIComponent(value));
3789
4134
  }
3790
4135
  function resolveErrorMessage3(payload, fallback) {
3791
- if (isRecord5(payload)) {
4136
+ if (isRecord6(payload)) {
3792
4137
  const message = payload.message ?? payload.error ?? payload.details;
3793
4138
  if (typeof message === "string" && message.trim()) {
3794
4139
  return message.trim();
@@ -3800,12 +4145,12 @@ function resolveErrorMessage3(payload, fallback) {
3800
4145
  return fallback;
3801
4146
  }
3802
4147
  function resolveErrorHint2(payload) {
3803
- if (!isRecord5(payload)) return void 0;
4148
+ if (!isRecord6(payload)) return void 0;
3804
4149
  const hint = payload.hint ?? payload.suggestion;
3805
4150
  return typeof hint === "string" && hint.trim() ? hint.trim() : void 0;
3806
4151
  }
3807
4152
  function resolveErrorCause(payload) {
3808
- if (!isRecord5(payload)) return void 0;
4153
+ if (!isRecord6(payload)) return void 0;
3809
4154
  const cause = payload.cause ?? payload.reason;
3810
4155
  return typeof cause === "string" && cause.trim() ? cause.trim() : void 0;
3811
4156
  }
@@ -3924,7 +4269,7 @@ async function callStorageEndpoint(gateway, endpoint, method, envelope, payload,
3924
4269
  );
3925
4270
  }
3926
4271
  if (envelope === "athena") {
3927
- if (!isRecord5(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
4272
+ if (!isRecord6(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
3928
4273
  return rejectStorageError(
3929
4274
  {
3930
4275
  code: "INVALID_ATHENA_ENVELOPE",
@@ -4032,81 +4377,260 @@ async function callStorageBinaryEndpoint(gateway, endpoint, method, options, run
4032
4377
  runtimeOptions
4033
4378
  );
4034
4379
  }
4035
- function createStorageModule(gateway, runtimeOptions) {
4380
+ function isBlobBody(body) {
4381
+ return typeof Blob !== "undefined" && body instanceof Blob;
4382
+ }
4383
+ function isReadableStreamBody(body) {
4384
+ return typeof ReadableStream !== "undefined" && body instanceof ReadableStream;
4385
+ }
4386
+ async function putPresignedUploadBody(uploadUrl, uploadHeaders, body, options) {
4387
+ const headers = new Headers(uploadHeaders);
4388
+ Object.entries(options?.headers ?? {}).forEach(([key, value]) => headers.set(key, value));
4389
+ if (!headers.has("Content-Type") && isBlobBody(body) && body.type) {
4390
+ headers.set("Content-Type", body.type);
4391
+ }
4392
+ const init = {
4393
+ method: "PUT",
4394
+ headers,
4395
+ body,
4396
+ signal: options?.signal
4397
+ };
4398
+ if (isReadableStreamBody(body)) {
4399
+ init.duplex = "half";
4400
+ }
4401
+ return fetch(uploadUrl, init);
4402
+ }
4403
+ function attachManagedUpload(upload) {
4404
+ const headers = {};
4405
+ return {
4406
+ ...upload,
4407
+ method: "PUT",
4408
+ headers,
4409
+ expiresAt: upload.expires_at,
4410
+ put(body, options) {
4411
+ return putPresignedUploadBody(upload.url, headers, body, options);
4412
+ }
4413
+ };
4414
+ }
4415
+ function attachUploadHelper(response) {
4416
+ return {
4417
+ ...response,
4418
+ upload: attachManagedUpload(response.upload)
4419
+ };
4420
+ }
4421
+ function attachUploadHelpers(response) {
4036
4422
  return {
4423
+ files: response.files.map(attachUploadHelper)
4424
+ };
4425
+ }
4426
+ function normalizeUploadUrlRequest(input) {
4427
+ const s3_id = input.s3_id ?? input.s3Id;
4428
+ const storage_key = input.storage_key ?? input.storageKey;
4429
+ if (!s3_id?.trim()) {
4430
+ throw new Error("athena.storage.file.upload requires s3_id or s3Id");
4431
+ }
4432
+ if (!storage_key?.trim()) {
4433
+ throw new Error("athena.storage.file.upload requires storage_key or storageKey");
4434
+ }
4435
+ const fileName = input.fileName?.trim();
4436
+ const originalName = input.originalName?.trim();
4437
+ return {
4438
+ s3_id,
4439
+ bucket: input.bucket,
4440
+ storage_key,
4441
+ name: input.name ?? fileName,
4442
+ original_name: input.original_name ?? originalName ?? fileName,
4443
+ resource_id: input.resource_id ?? input.resourceId,
4444
+ mime_type: input.mime_type ?? input.mimeType,
4445
+ content_type: input.content_type ?? input.contentType,
4446
+ size_bytes: input.size_bytes ?? input.sizeBytes,
4447
+ file_id: input.file_id ?? input.fileId,
4448
+ public: input.public,
4449
+ visibility: input.visibility,
4450
+ metadata: input.metadata
4451
+ };
4452
+ }
4453
+ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options, runtimeOptions) {
4454
+ let url;
4455
+ let headers;
4456
+ try {
4457
+ const baseUrl = options?.baseUrl ? normalizeAthenaGatewayBaseUrl(options.baseUrl) : gateway.baseUrl;
4458
+ url = buildAthenaGatewayUrl(baseUrl, endpoint);
4459
+ headers = gateway.buildHeaders(options);
4460
+ } catch (error) {
4461
+ return rejectStorageError(
4462
+ {
4463
+ code: storageCodeFromUnknown(error),
4464
+ message: error instanceof Error ? error.message : `Athena storage PUT ${endpoint} failed before sending the request`,
4465
+ status: isAthenaGatewayError(error) ? error.status : 0,
4466
+ endpoint,
4467
+ method: "PUT",
4468
+ raw: error,
4469
+ requestId: isAthenaGatewayError(error) ? error.requestId : void 0,
4470
+ hint: isAthenaGatewayError(error) ? error.hint : void 0,
4471
+ cause: error
4472
+ },
4473
+ options,
4474
+ runtimeOptions
4475
+ );
4476
+ }
4477
+ delete headers["Content-Type"];
4478
+ delete headers["content-type"];
4479
+ if (isBlobBody(body) && body.type) {
4480
+ headers["Content-Type"] = body.type;
4481
+ }
4482
+ const requestInit = {
4483
+ method: "PUT",
4484
+ headers,
4485
+ body,
4486
+ signal: options?.signal
4487
+ };
4488
+ if (isReadableStreamBody(body)) {
4489
+ requestInit.duplex = "half";
4490
+ }
4491
+ let response;
4492
+ try {
4493
+ response = await fetch(url, requestInit);
4494
+ } catch (error) {
4495
+ const message = error instanceof Error ? error.message : String(error);
4496
+ return rejectStorageError(
4497
+ {
4498
+ code: "NETWORK_ERROR",
4499
+ message: `Network error while calling Athena storage PUT ${endpoint}: ${message}`,
4500
+ status: 0,
4501
+ endpoint,
4502
+ method: "PUT",
4503
+ cause: error
4504
+ },
4505
+ options,
4506
+ runtimeOptions
4507
+ );
4508
+ }
4509
+ let rawText;
4510
+ try {
4511
+ rawText = await response.text();
4512
+ } catch (error) {
4513
+ return rejectStorageError(
4514
+ {
4515
+ code: "NETWORK_ERROR",
4516
+ message: `Athena storage PUT ${endpoint} response body could not be read`,
4517
+ status: response.status,
4518
+ endpoint,
4519
+ method: "PUT",
4520
+ requestId: headerValue(response.headers, ["x-athena-request-id", "x-request-id", "request-id"]),
4521
+ cause: error
4522
+ },
4523
+ options,
4524
+ runtimeOptions
4525
+ );
4526
+ }
4527
+ const parsedBody = parseResponseBody3(rawText ?? "", response.headers.get("content-type"));
4528
+ const requestId = headerValue(response.headers, ["x-athena-request-id", "x-request-id", "request-id"]);
4529
+ if (parsedBody.parseFailed) {
4530
+ return rejectStorageError(
4531
+ {
4532
+ code: "INVALID_JSON",
4533
+ message: `Athena storage PUT ${endpoint} returned malformed JSON`,
4534
+ status: response.status,
4535
+ endpoint,
4536
+ method: "PUT",
4537
+ requestId,
4538
+ raw: parsedBody.parsed
4539
+ },
4540
+ options,
4541
+ runtimeOptions
4542
+ );
4543
+ }
4544
+ if (!response.ok) {
4545
+ return rejectStorageError(
4546
+ {
4547
+ code: "HTTP_ERROR",
4548
+ message: resolveErrorMessage3(
4549
+ parsedBody.parsed,
4550
+ `Athena storage PUT ${endpoint} failed with status ${response.status}`
4551
+ ),
4552
+ status: response.status,
4553
+ endpoint,
4554
+ method: "PUT",
4555
+ requestId,
4556
+ hint: resolveErrorHint2(parsedBody.parsed),
4557
+ cause: resolveErrorCause(parsedBody.parsed),
4558
+ raw: parsedBody.parsed
4559
+ },
4560
+ options,
4561
+ runtimeOptions
4562
+ );
4563
+ }
4564
+ if (!isRecord6(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
4565
+ return rejectStorageError(
4566
+ {
4567
+ code: "INVALID_ATHENA_ENVELOPE",
4568
+ message: `Athena storage PUT ${endpoint} returned an invalid Athena envelope`,
4569
+ status: response.status,
4570
+ endpoint,
4571
+ method: "PUT",
4572
+ requestId,
4573
+ raw: parsedBody.parsed
4574
+ },
4575
+ options,
4576
+ runtimeOptions
4577
+ );
4578
+ }
4579
+ return parsedBody.parsed.data;
4580
+ }
4581
+ function createStorageModule(gateway, runtimeOptions) {
4582
+ const callRaw = (path, method, payload, options) => callStorageEndpoint(
4583
+ gateway,
4584
+ storagePath(path),
4585
+ method,
4586
+ "raw",
4587
+ payload,
4588
+ options,
4589
+ runtimeOptions
4590
+ );
4591
+ const callAthena2 = (path, method, payload, options) => callStorageEndpoint(
4592
+ gateway,
4593
+ storagePath(path),
4594
+ method,
4595
+ "athena",
4596
+ payload,
4597
+ options,
4598
+ runtimeOptions
4599
+ );
4600
+ const base = {
4037
4601
  listStorageCatalogs(options) {
4038
- return callStorageEndpoint(gateway, storagePath("/storage/catalogs"), "GET", "raw", void 0, options, runtimeOptions);
4602
+ return callRaw("/storage/catalogs", "GET", void 0, options);
4039
4603
  },
4040
4604
  createStorageCatalog(input, options) {
4041
- return callStorageEndpoint(gateway, storagePath("/storage/catalogs"), "POST", "raw", input, options, runtimeOptions);
4605
+ return callRaw("/storage/catalogs", "POST", input, options);
4042
4606
  },
4043
4607
  updateStorageCatalog(id, input, options) {
4044
- return callStorageEndpoint(
4045
- gateway,
4046
- storagePath(withPathParam("/storage/catalogs/{id}", "id", id)),
4047
- "PATCH",
4048
- "raw",
4049
- input,
4050
- options,
4051
- runtimeOptions
4052
- );
4608
+ return callRaw(withPathParam("/storage/catalogs/{id}", "id", id), "PATCH", input, options);
4053
4609
  },
4054
4610
  deleteStorageCatalog(id, options) {
4055
- return callStorageEndpoint(
4056
- gateway,
4057
- storagePath(withPathParam("/storage/catalogs/{id}", "id", id)),
4058
- "DELETE",
4059
- "raw",
4060
- void 0,
4061
- options,
4062
- runtimeOptions
4063
- );
4611
+ return callRaw(withPathParam("/storage/catalogs/{id}", "id", id), "DELETE", void 0, options);
4064
4612
  },
4065
4613
  listStorageCredentials(options) {
4066
- return callStorageEndpoint(gateway, storagePath("/storage/credentials"), "GET", "raw", void 0, options, runtimeOptions);
4614
+ return callRaw("/storage/credentials", "GET", void 0, options);
4067
4615
  },
4068
4616
  createStorageUploadUrl(input, options) {
4069
- return callStorageEndpoint(
4070
- gateway,
4071
- storagePath("/storage/files/upload-url"),
4072
- "POST",
4073
- "athena",
4074
- input,
4075
- options,
4076
- runtimeOptions
4077
- );
4617
+ return callAthena2("/storage/files/upload-url", "POST", input, options);
4078
4618
  },
4079
4619
  createStorageUploadUrls(input, options) {
4080
- return callStorageEndpoint(
4081
- gateway,
4082
- storagePath("/storage/files/upload-urls"),
4083
- "POST",
4084
- "athena",
4085
- input,
4086
- options,
4087
- runtimeOptions
4088
- );
4620
+ return callAthena2("/storage/files/upload-urls", "POST", input, options);
4089
4621
  },
4090
4622
  listStorageFiles(input, options) {
4091
- return callStorageEndpoint(gateway, storagePath("/storage/files/list"), "POST", "athena", input, options, runtimeOptions);
4623
+ return callAthena2("/storage/files/list", "POST", input, options);
4092
4624
  },
4093
4625
  getStorageFile(fileId, options) {
4094
- return callStorageEndpoint(
4095
- gateway,
4096
- storagePath(withPathParam("/storage/files/{file_id}", "file_id", fileId)),
4097
- "GET",
4098
- "athena",
4099
- void 0,
4100
- options,
4101
- runtimeOptions
4102
- );
4626
+ return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "GET", void 0, options);
4103
4627
  },
4104
4628
  getStorageFileUrl(fileId, query, options) {
4105
4629
  const path = appendQuery(
4106
4630
  withPathParam("/storage/files/{file_id}/url", "file_id", fileId),
4107
4631
  query
4108
4632
  );
4109
- return callStorageEndpoint(gateway, storagePath(path), "GET", "athena", void 0, options, runtimeOptions);
4633
+ return callAthena2(path, "GET", void 0, options);
4110
4634
  },
4111
4635
  getStorageFileProxy(fileId, query, options) {
4112
4636
  const path = appendQuery(
@@ -4116,45 +4640,244 @@ function createStorageModule(gateway, runtimeOptions) {
4116
4640
  return callStorageBinaryEndpoint(gateway, storagePath(path), "GET", options, runtimeOptions);
4117
4641
  },
4118
4642
  updateStorageFile(fileId, input, options) {
4119
- return callStorageEndpoint(
4120
- gateway,
4121
- storagePath(withPathParam("/storage/files/{file_id}", "file_id", fileId)),
4122
- "PATCH",
4123
- "athena",
4124
- input,
4125
- options,
4126
- runtimeOptions
4127
- );
4643
+ return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "PATCH", input, options);
4128
4644
  },
4129
4645
  deleteStorageFile(fileId, options) {
4130
- return callStorageEndpoint(
4131
- gateway,
4132
- storagePath(withPathParam("/storage/files/{file_id}", "file_id", fileId)),
4133
- "DELETE",
4134
- "athena",
4135
- void 0,
4136
- options,
4137
- runtimeOptions
4138
- );
4646
+ return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "DELETE", void 0, options);
4139
4647
  },
4140
4648
  setStorageFileVisibility(fileId, input, options) {
4141
- return callStorageEndpoint(
4649
+ return callAthena2(withPathParam("/storage/files/{file_id}/visibility", "file_id", fileId), "PATCH", input, options);
4650
+ },
4651
+ deleteStorageFolder(input, options) {
4652
+ return callAthena2("/storage/folders/delete", "POST", input, options);
4653
+ },
4654
+ moveStorageFolder(input, options) {
4655
+ return callAthena2("/storage/folders/move", "POST", input, options);
4656
+ }
4657
+ };
4658
+ const fileFacade = createStorageFileModule(base, runtimeOptions);
4659
+ const fileUpload = ((input, options) => {
4660
+ if (isRecord6(input) && "files" in input) {
4661
+ return fileFacade.upload(input, options);
4662
+ }
4663
+ return base.createStorageUploadUrl(
4664
+ normalizeUploadUrlRequest(input),
4665
+ options
4666
+ ).then(attachUploadHelper);
4667
+ });
4668
+ const fileDelete = ((input, options) => fileFacade.delete(input, options));
4669
+ const file = {
4670
+ ...fileFacade,
4671
+ upload: fileUpload,
4672
+ uploadMany(input, options) {
4673
+ return base.createStorageUploadUrls(
4674
+ { files: input.files.map(normalizeUploadUrlRequest) },
4675
+ options
4676
+ ).then(attachUploadHelpers);
4677
+ },
4678
+ confirmUpload(fileId, input, options) {
4679
+ return callAthena2(withPathParam("/storage/files/{file_id}/confirm-upload", "file_id", fileId), "POST", input ?? {}, options);
4680
+ },
4681
+ uploadBinary(fileId, body, options) {
4682
+ return callStorageUploadBinaryEndpoint(
4142
4683
  gateway,
4143
- storagePath(withPathParam("/storage/files/{file_id}/visibility", "file_id", fileId)),
4144
- "PATCH",
4145
- "athena",
4146
- input,
4684
+ storagePath(withPathParam("/storage/files/{file_id}/upload", "file_id", fileId)),
4685
+ body,
4147
4686
  options,
4148
4687
  runtimeOptions
4149
4688
  );
4150
4689
  },
4151
- deleteStorageFolder(input, options) {
4152
- return callStorageEndpoint(gateway, storagePath("/storage/folders/delete"), "POST", "athena", input, options, runtimeOptions);
4690
+ search(input, options) {
4691
+ return callAthena2("/storage/files/search", "POST", input, options);
4153
4692
  },
4154
- moveStorageFolder(input, options) {
4155
- return callStorageEndpoint(gateway, storagePath("/storage/folders/move"), "POST", "athena", input, options, runtimeOptions);
4693
+ get(fileId, options) {
4694
+ return base.getStorageFile(fileId, options);
4695
+ },
4696
+ update(fileId, input, options) {
4697
+ return base.updateStorageFile(fileId, input, options);
4698
+ },
4699
+ delete: fileDelete,
4700
+ deleteMany(input, options) {
4701
+ return callAthena2("/storage/files/delete-many", "POST", input, options);
4702
+ },
4703
+ updateMany(input, options) {
4704
+ return callAthena2("/storage/files/update-many", "POST", input, options);
4705
+ },
4706
+ restore(fileId, options) {
4707
+ return callAthena2(withPathParam("/storage/files/{file_id}/restore", "file_id", fileId), "POST", {}, options);
4708
+ },
4709
+ purge(fileId, options) {
4710
+ return callAthena2(withPathParam("/storage/files/{file_id}/purge", "file_id", fileId), "DELETE", void 0, options);
4711
+ },
4712
+ copy(fileId, input, options) {
4713
+ return callAthena2(withPathParam("/storage/files/{file_id}/copy", "file_id", fileId), "POST", input, options);
4714
+ },
4715
+ url(fileId, query, options) {
4716
+ return base.getStorageFileUrl(fileId, query, options);
4717
+ },
4718
+ publicUrl(fileId, options) {
4719
+ return callAthena2(withPathParam("/storage/files/{file_id}/public-url", "file_id", fileId), "GET", void 0, options);
4720
+ },
4721
+ proxy(fileId, query, options) {
4722
+ return base.getStorageFileProxy(fileId, query, options);
4723
+ },
4724
+ visibility: {
4725
+ set(fileId, input, options) {
4726
+ return base.setStorageFileVisibility(fileId, input, options);
4727
+ },
4728
+ setMany(input, options) {
4729
+ return callAthena2("/storage/files/visibility-many", "POST", input, options);
4730
+ }
4731
+ }
4732
+ };
4733
+ const credentials = {
4734
+ list(options) {
4735
+ return base.listStorageCredentials(options);
4736
+ }
4737
+ };
4738
+ const catalog = {
4739
+ list(options) {
4740
+ return base.listStorageCatalogs(options);
4741
+ },
4742
+ create(input, options) {
4743
+ return base.createStorageCatalog(input, options);
4744
+ },
4745
+ update(id, input, options) {
4746
+ return base.updateStorageCatalog(id, input, options);
4747
+ },
4748
+ delete(id, options) {
4749
+ return base.deleteStorageCatalog(id, options);
4156
4750
  }
4157
4751
  };
4752
+ const folder = {
4753
+ list(input, options) {
4754
+ return callAthena2("/storage/folders/list", "POST", input, options);
4755
+ },
4756
+ tree(input, options) {
4757
+ return callAthena2("/storage/folders/tree", "POST", input, options);
4758
+ },
4759
+ delete(input, options) {
4760
+ return base.deleteStorageFolder(input, options);
4761
+ },
4762
+ move(input, options) {
4763
+ return base.moveStorageFolder(input, options);
4764
+ }
4765
+ };
4766
+ const permission = {
4767
+ list(input, options) {
4768
+ return callAthena2("/storage/permissions/list", "POST", input, options);
4769
+ },
4770
+ grant(input, options) {
4771
+ return callAthena2("/storage/permissions/grant", "POST", input, options);
4772
+ },
4773
+ revoke(input, options) {
4774
+ return callAthena2("/storage/permissions/revoke", "POST", input, options);
4775
+ },
4776
+ check(input, options) {
4777
+ return callAthena2("/storage/permissions/check", "POST", input, options);
4778
+ }
4779
+ };
4780
+ const objectFolder = {
4781
+ create(input, options) {
4782
+ return callAthena2("/storage/objects/folder", "POST", input, options);
4783
+ },
4784
+ delete(input, options) {
4785
+ return callAthena2("/storage/objects/folder/delete", "POST", input, options);
4786
+ },
4787
+ rename(input, options) {
4788
+ return callAthena2("/storage/objects/folder/rename", "POST", input, options);
4789
+ }
4790
+ };
4791
+ const object = {
4792
+ list(input, options) {
4793
+ return callAthena2("/storage/objects", "POST", input, options);
4794
+ },
4795
+ head(input, options) {
4796
+ return callAthena2("/storage/objects/head", "POST", input, options);
4797
+ },
4798
+ exists(input, options) {
4799
+ return callAthena2("/storage/objects/exists", "POST", input, options);
4800
+ },
4801
+ validate(input, options) {
4802
+ return callAthena2("/storage/objects/validate", "POST", input, options);
4803
+ },
4804
+ update(input, options) {
4805
+ return callAthena2("/storage/objects/update", "POST", input, options);
4806
+ },
4807
+ copy(input, options) {
4808
+ return callAthena2("/storage/objects/copy", "POST", input, options);
4809
+ },
4810
+ url(input, options) {
4811
+ return callAthena2("/storage/objects/url", "POST", input, options);
4812
+ },
4813
+ publicUrl(input, options) {
4814
+ return callAthena2("/storage/objects/public-url", "POST", input, options);
4815
+ },
4816
+ delete(input, options) {
4817
+ return callAthena2("/storage/objects/delete", "POST", input, options);
4818
+ },
4819
+ uploadUrl(input, options) {
4820
+ return callAthena2("/storage/objects/upload-url", "POST", input, options);
4821
+ },
4822
+ folder: objectFolder
4823
+ };
4824
+ const bucket = {
4825
+ list(input, options) {
4826
+ return callAthena2("/storage/buckets/list", "POST", input, options);
4827
+ },
4828
+ create(input, options) {
4829
+ return callAthena2("/storage/buckets/create", "POST", input, options);
4830
+ },
4831
+ delete(input, options) {
4832
+ return callAthena2("/storage/buckets/delete", "POST", input, options);
4833
+ },
4834
+ cors: {
4835
+ get(input, options) {
4836
+ return callAthena2("/storage/buckets/cors", "POST", input, options);
4837
+ },
4838
+ set(input, options) {
4839
+ return callAthena2("/storage/buckets/cors/set", "POST", input, options);
4840
+ },
4841
+ delete(input, options) {
4842
+ return callAthena2("/storage/buckets/cors/delete", "POST", input, options);
4843
+ }
4844
+ }
4845
+ };
4846
+ const multipart = {
4847
+ create(input, options) {
4848
+ return callAthena2("/storage/multipart/create", "POST", input, options);
4849
+ },
4850
+ signPart(input, options) {
4851
+ return callAthena2("/storage/multipart/sign-part", "POST", input, options);
4852
+ },
4853
+ complete(input, options) {
4854
+ return callAthena2("/storage/multipart/complete", "POST", input, options);
4855
+ },
4856
+ abort(input, options) {
4857
+ return callAthena2("/storage/multipart/abort", "POST", input, options);
4858
+ },
4859
+ listParts(input, options) {
4860
+ return callAthena2("/storage/multipart/list-parts", "POST", input, options);
4861
+ }
4862
+ };
4863
+ const audit = {
4864
+ list(input, options) {
4865
+ return callAthena2("/storage/audit/list", "POST", input, options);
4866
+ }
4867
+ };
4868
+ return {
4869
+ ...base,
4870
+ credentials,
4871
+ catalog,
4872
+ file,
4873
+ folder,
4874
+ permission,
4875
+ object,
4876
+ bucket,
4877
+ multipart,
4878
+ audit,
4879
+ delete: file.delete
4880
+ };
4158
4881
  }
4159
4882
 
4160
4883
  // src/query-ast.ts
@@ -4184,7 +4907,7 @@ var BOOLEAN_SAFE_OPERATORS = /* @__PURE__ */ new Set([
4184
4907
  "ilike",
4185
4908
  "is"
4186
4909
  ]);
4187
- function isRecord6(value) {
4910
+ function isRecord7(value) {
4188
4911
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4189
4912
  }
4190
4913
  function isUuidString(value) {
@@ -4197,7 +4920,7 @@ function shouldUseUuidTextComparison(column, value) {
4197
4920
  return typeof value === "string" && isUuidString(value) && isUuidIdentifierColumn(column);
4198
4921
  }
4199
4922
  function isRelationSelectNode(value) {
4200
- return isRecord6(value) && isRecord6(value.select);
4923
+ return isRecord7(value) && isRecord7(value.select);
4201
4924
  }
4202
4925
  function normalizeIdentifier(value, label) {
4203
4926
  const normalized = value.trim();
@@ -4253,7 +4976,7 @@ function compileRelationToken(key, node) {
4253
4976
  return `${prefix}${relationToken}(${nested})`;
4254
4977
  }
4255
4978
  function compileSelectShape(select) {
4256
- if (!isRecord6(select)) {
4979
+ if (!isRecord7(select)) {
4257
4980
  throw new Error("findMany select must be an object");
4258
4981
  }
4259
4982
  const tokens = [];
@@ -4277,7 +5000,7 @@ function compileSelectShape(select) {
4277
5000
  return tokens.join(",");
4278
5001
  }
4279
5002
  function selectShapeUsesRelationSchema(select) {
4280
- if (!isRecord6(select)) {
5003
+ if (!isRecord7(select)) {
4281
5004
  return false;
4282
5005
  }
4283
5006
  for (const rawValue of Object.values(select)) {
@@ -4295,7 +5018,7 @@ function selectShapeUsesRelationSchema(select) {
4295
5018
  }
4296
5019
  function compileColumnWhere(column, input) {
4297
5020
  const normalizedColumn = normalizeIdentifier(column, "where column");
4298
- if (!isRecord6(input)) {
5021
+ if (!isRecord7(input)) {
4299
5022
  return [buildGatewayCondition("eq", normalizedColumn, input)];
4300
5023
  }
4301
5024
  const conditions = [];
@@ -4323,7 +5046,7 @@ function compileColumnWhere(column, input) {
4323
5046
  return conditions;
4324
5047
  }
4325
5048
  function compileBooleanExpressionTerms(clause, label) {
4326
- if (!isRecord6(clause)) {
5049
+ if (!isRecord7(clause)) {
4327
5050
  throw new Error(`findMany where.${label} clauses must be objects`);
4328
5051
  }
4329
5052
  const entries = Object.entries(clause).filter(([, value]) => value !== void 0);
@@ -4332,7 +5055,7 @@ function compileBooleanExpressionTerms(clause, label) {
4332
5055
  }
4333
5056
  const [rawColumn, rawValue] = entries[0];
4334
5057
  const column = normalizeIdentifier(rawColumn, `where.${label} column`);
4335
- if (!isRecord6(rawValue)) {
5058
+ if (!isRecord7(rawValue)) {
4336
5059
  return [`${column}.eq.${stringifyFilterValue(rawValue)}`];
4337
5060
  }
4338
5061
  const operatorEntries = Object.entries(rawValue).filter(([, value]) => value !== void 0);
@@ -4356,7 +5079,7 @@ function compileWhere(where) {
4356
5079
  if (where === void 0) {
4357
5080
  return void 0;
4358
5081
  }
4359
- if (!isRecord6(where)) {
5082
+ if (!isRecord7(where)) {
4360
5083
  throw new Error("findMany where must be an object");
4361
5084
  }
4362
5085
  const conditions = [];
@@ -4406,7 +5129,7 @@ function compileOrderBy(orderBy) {
4406
5129
  if (orderBy === void 0) {
4407
5130
  return void 0;
4408
5131
  }
4409
- if (!isRecord6(orderBy)) {
5132
+ if (!isRecord7(orderBy)) {
4410
5133
  throw new Error("findMany orderBy must be an object");
4411
5134
  }
4412
5135
  if ("column" in orderBy) {
@@ -4581,11 +5304,11 @@ function toFindManyAstOrder(order) {
4581
5304
  ascending: order.direction !== "descending"
4582
5305
  };
4583
5306
  }
4584
- function isRecord7(value) {
5307
+ function isRecord8(value) {
4585
5308
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4586
5309
  }
4587
5310
  function normalizeFindManyAstColumnPredicate(value) {
4588
- if (!isRecord7(value)) {
5311
+ if (!isRecord8(value)) {
4589
5312
  return {
4590
5313
  eq: value
4591
5314
  };
@@ -4609,7 +5332,7 @@ function normalizeFindManyAstBooleanOperand(clause) {
4609
5332
  return normalized;
4610
5333
  }
4611
5334
  function normalizeFindManyAstWhere(where) {
4612
- if (!where || !isRecord7(where)) {
5335
+ if (!where || !isRecord8(where)) {
4613
5336
  return where;
4614
5337
  }
4615
5338
  const normalized = {};
@@ -4623,7 +5346,7 @@ function normalizeFindManyAstWhere(where) {
4623
5346
  );
4624
5347
  continue;
4625
5348
  }
4626
- if (key === "not" && isRecord7(value)) {
5349
+ if (key === "not" && isRecord8(value)) {
4627
5350
  normalized.not = normalizeFindManyAstBooleanOperand(
4628
5351
  value
4629
5352
  );
@@ -4634,7 +5357,7 @@ function normalizeFindManyAstWhere(where) {
4634
5357
  return normalized;
4635
5358
  }
4636
5359
  function predicateRequiresUuidQueryFallback(column, value) {
4637
- if (!isRecord7(value)) {
5360
+ if (!isRecord8(value)) {
4638
5361
  return shouldUseUuidTextComparison(column, value);
4639
5362
  }
4640
5363
  const eqValue = value.eq;
@@ -4652,7 +5375,7 @@ function booleanOperandRequiresUuidQueryFallback(clause) {
4652
5375
  return false;
4653
5376
  }
4654
5377
  function findManyAstWhereRequiresLegacyTransport(where) {
4655
- if (!where || !isRecord7(where)) {
5378
+ if (!where || !isRecord8(where)) {
4656
5379
  return false;
4657
5380
  }
4658
5381
  for (const [key, value] of Object.entries(where)) {
@@ -4667,7 +5390,7 @@ function findManyAstWhereRequiresLegacyTransport(where) {
4667
5390
  }
4668
5391
  continue;
4669
5392
  }
4670
- if (key === "not" && isRecord7(value)) {
5393
+ if (key === "not" && isRecord8(value)) {
4671
5394
  if (booleanOperandRequiresUuidQueryFallback(value)) {
4672
5395
  return true;
4673
5396
  }
@@ -4869,7 +5592,7 @@ async function executeExperimentalRead(experimental, runner) {
4869
5592
  throw error;
4870
5593
  }
4871
5594
  }
4872
- function isRecord8(value) {
5595
+ function isRecord9(value) {
4873
5596
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4874
5597
  }
4875
5598
  function firstNonEmptyString2(...values) {
@@ -4881,8 +5604,8 @@ function firstNonEmptyString2(...values) {
4881
5604
  return void 0;
4882
5605
  }
4883
5606
  function resolveStructuredErrorPayload2(raw) {
4884
- if (!isRecord8(raw)) return null;
4885
- return isRecord8(raw.error) ? raw.error : raw;
5607
+ if (!isRecord9(raw)) return null;
5608
+ return isRecord9(raw.error) ? raw.error : raw;
4886
5609
  }
4887
5610
  function resolveStructuredErrorDetails(payload, message) {
4888
5611
  if (!payload || !("details" in payload)) {
@@ -4898,7 +5621,7 @@ function resolveStructuredErrorDetails(payload, message) {
4898
5621
  return details;
4899
5622
  }
4900
5623
  function createResultError(response, result, normalized) {
4901
- const rawRecord = isRecord8(response.raw) ? response.raw : null;
5624
+ const rawRecord = isRecord9(response.raw) ? response.raw : null;
4902
5625
  const payload = resolveStructuredErrorPayload2(response.raw);
4903
5626
  const message = firstNonEmptyString2(
4904
5627
  response.error,