@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/browser.js CHANGED
@@ -666,9 +666,16 @@ var getSessionCookie = (request, config) => {
666
666
  const { cookieName = "session_token", cookiePrefix = "athena-auth" } = config || {};
667
667
  const parsedCookie = parseCookies(cookies);
668
668
  const getCookie = (name) => parsedCookie.get(name) || parsedCookie.get(`${SECURE_COOKIE_PREFIX}${name}`);
669
- const sessionToken = getCookie(`${cookiePrefix}.${cookieName}`) || getCookie(`${cookiePrefix}-${cookieName}`);
670
- if (sessionToken) {
671
- return sessionToken;
669
+ const candidateCookieNames = Array.from(/* @__PURE__ */ new Set([
670
+ cookieName,
671
+ cookieName.replace(/_/g, "-"),
672
+ cookieName.replace(/-/g, "_")
673
+ ])).filter(Boolean);
674
+ for (const candidateName of candidateCookieNames) {
675
+ const sessionToken = getCookie(`${cookiePrefix}.${candidateName}`) || getCookie(`${cookiePrefix}-${candidateName}`);
676
+ if (sessionToken) {
677
+ return sessionToken;
678
+ }
672
679
  }
673
680
  return null;
674
681
  };
@@ -791,7 +798,7 @@ var getCookieCache = async (request, config) => {
791
798
 
792
799
  // package.json
793
800
  var package_default = {
794
- version: "2.6.0"
801
+ version: "2.7.0"
795
802
  };
796
803
 
797
804
  // src/sdk-version.ts
@@ -3366,6 +3373,344 @@ function createDbModule(input) {
3366
3373
  return db;
3367
3374
  }
3368
3375
 
3376
+ // src/storage/file.ts
3377
+ function createStorageFileModule(base, config = {}) {
3378
+ const upload = async (input, options) => {
3379
+ const sources = normalizeUploadSources(input);
3380
+ validateUploadConstraints(sources, input);
3381
+ const uploadRequests = sources.map((source, index) => {
3382
+ const storageKey = resolveUploadStorageKey(input, source, index, options, config);
3383
+ return {
3384
+ source,
3385
+ uploadRequest: {
3386
+ s3_id: input.s3_id,
3387
+ bucket: input.bucket,
3388
+ storage_key: storageKey,
3389
+ name: input.name ?? source.fileName,
3390
+ original_name: input.original_name ?? source.fileName,
3391
+ resource_id: input.resource_id ?? input.resourceId,
3392
+ mime_type: input.mime_type ?? source.contentType,
3393
+ content_type: input.content_type ?? source.contentType,
3394
+ size_bytes: source.sizeBytes,
3395
+ public: input.public,
3396
+ metadata: input.metadata
3397
+ }
3398
+ };
3399
+ });
3400
+ input.onProgress?.(createProgressSnapshot("preparing", sources, 0, 0, 0));
3401
+ const uploadUrls = uploadRequests.length === 1 ? [await base.createStorageUploadUrl(uploadRequests[0].uploadRequest, options)] : (await base.createStorageUploadUrls({ files: uploadRequests.map((request) => request.uploadRequest) }, options)).files;
3402
+ const aggregateLoaded = new Array(uploadRequests.length).fill(0);
3403
+ const uploaded = [];
3404
+ for (let index = 0; index < uploadRequests.length; index += 1) {
3405
+ const request = uploadRequests[index];
3406
+ const uploadUrl = uploadUrls[index];
3407
+ const response = await putUploadBody(uploadUrl.upload.url, request.source, input, options, (progress) => {
3408
+ aggregateLoaded[index] = progress.loaded;
3409
+ input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
3410
+ });
3411
+ uploaded.push({
3412
+ file: uploadUrl.file,
3413
+ upload: uploadUrl.upload,
3414
+ source: request.source.source,
3415
+ fileName: request.source.fileName,
3416
+ storage_key: request.uploadRequest.storage_key,
3417
+ response
3418
+ });
3419
+ aggregateLoaded[index] = request.source.sizeBytes;
3420
+ input.onProgress?.(createProgressSnapshot("complete", sources, index, request.source.sizeBytes, sum(aggregateLoaded)));
3421
+ }
3422
+ return {
3423
+ files: uploaded,
3424
+ count: uploaded.length
3425
+ };
3426
+ };
3427
+ const download = ((input, queryOrOptions, maybeOptions) => {
3428
+ const { fileIds, query, options } = normalizeDownloadArgs(input, queryOrOptions, maybeOptions);
3429
+ const downloads = fileIds.map((fileId) => base.getStorageFileProxy(fileId, query, options));
3430
+ return Array.isArray(input) || isRecord5(input) && Array.isArray(input.fileIds) ? Promise.all(downloads) : downloads[0];
3431
+ });
3432
+ const deleteFile = ((input, options) => {
3433
+ if (Array.isArray(input)) {
3434
+ return Promise.all(input.map((fileId) => base.deleteStorageFile(fileId, options)));
3435
+ }
3436
+ return base.deleteStorageFile(input, options);
3437
+ });
3438
+ return {
3439
+ upload,
3440
+ download,
3441
+ list(input, options) {
3442
+ const prefix = resolveStoragePath(input.prefix ?? "", input, options, config);
3443
+ return base.listStorageFiles(
3444
+ {
3445
+ s3_id: input.s3_id,
3446
+ prefix
3447
+ },
3448
+ options
3449
+ );
3450
+ },
3451
+ delete: deleteFile
3452
+ };
3453
+ }
3454
+ function resolveStoragePath(path, input, options, config = {}) {
3455
+ const context = createPathContext(input, options, config);
3456
+ const prefixPath = input.prefixPath ?? config.prefixPath;
3457
+ const prefix = typeof prefixPath === "function" ? prefixPath(context) : prefixPath;
3458
+ return joinStoragePath(renderStorageTemplate(prefix ?? "", context), renderStorageTemplate(path, context));
3459
+ }
3460
+ function resolveUploadStorageKey(input, source, index, options, config) {
3461
+ const explicitKey = input.storage_key ?? input.storageKey;
3462
+ const keyTemplate = input.storageKeyTemplate;
3463
+ const fallbackName = source.fileName;
3464
+ const context = createPathContext(input, options, config);
3465
+ const key = keyTemplate ? renderStorageTemplate(keyTemplate, {
3466
+ ...context,
3467
+ vars: {
3468
+ ...context.vars,
3469
+ index,
3470
+ fileName: source.fileName,
3471
+ name: source.fileName
3472
+ }
3473
+ }) : explicitKey ?? fallbackName;
3474
+ return resolveStoragePath(key, input, options, config);
3475
+ }
3476
+ function normalizeUploadSources(input) {
3477
+ const files = toArray(input.files);
3478
+ if (files.length === 0) {
3479
+ throw new Error("athena.storage.file.upload requires at least one file");
3480
+ }
3481
+ return files.map((source, index) => {
3482
+ const fileName = input.fileName ?? sourceName(source) ?? `file-${index + 1}`;
3483
+ const sizeBytes = sourceSize(source);
3484
+ const contentType = input.content_type ?? input.mime_type ?? sourceContentType(source);
3485
+ return {
3486
+ source,
3487
+ fileName,
3488
+ sizeBytes,
3489
+ contentType
3490
+ };
3491
+ });
3492
+ }
3493
+ function validateUploadConstraints(sources, input) {
3494
+ const maxFiles = input.maxFiles ?? 1;
3495
+ if (sources.length > maxFiles) {
3496
+ throw new Error(`athena.storage.file.upload accepts at most ${maxFiles} file${maxFiles === 1 ? "" : "s"} for this call`);
3497
+ }
3498
+ const maxFileSizeBytes = input.maxFileSizeBytes ?? (input.maxFileSizeMb === void 0 ? void 0 : Math.floor(input.maxFileSizeMb * 1024 * 1024));
3499
+ if (maxFileSizeBytes !== void 0) {
3500
+ const tooLarge = sources.find((source) => source.sizeBytes > maxFileSizeBytes);
3501
+ if (tooLarge) {
3502
+ throw new Error(`athena.storage.file.upload rejected ${tooLarge.fileName}: file exceeds ${maxFileSizeBytes} bytes`);
3503
+ }
3504
+ }
3505
+ const allowedExtensions = normalizeExtensions(input.allowedExtensions ?? input.extensions);
3506
+ if (allowedExtensions.size > 0) {
3507
+ const invalid = sources.find((source) => !allowedExtensions.has(fileExtension(source.fileName)));
3508
+ if (invalid) {
3509
+ throw new Error(`athena.storage.file.upload rejected ${invalid.fileName}: extension is not allowed`);
3510
+ }
3511
+ }
3512
+ }
3513
+ async function putUploadBody(url, source, input, options, onProgress) {
3514
+ const headers = new Headers(input.uploadHeaders);
3515
+ if (source.contentType && !headers.has("Content-Type")) {
3516
+ headers.set("Content-Type", source.contentType);
3517
+ }
3518
+ if (typeof XMLHttpRequest !== "undefined") {
3519
+ return putUploadBodyWithXhr(url, source, headers, options, onProgress);
3520
+ }
3521
+ onProgress({ loaded: 0 });
3522
+ const response = await fetch(url, {
3523
+ method: "PUT",
3524
+ headers,
3525
+ body: source.source,
3526
+ signal: options?.signal
3527
+ });
3528
+ if (!response.ok) {
3529
+ throw new Error(`athena.storage.file.upload failed with status ${response.status}`);
3530
+ }
3531
+ onProgress({ loaded: source.sizeBytes });
3532
+ return response;
3533
+ }
3534
+ function putUploadBodyWithXhr(url, source, headers, options, onProgress) {
3535
+ const Xhr = XMLHttpRequest;
3536
+ if (Xhr === void 0) {
3537
+ return Promise.reject(new Error("athena.storage.file.upload requires XMLHttpRequest in this runtime"));
3538
+ }
3539
+ return new Promise((resolve, reject) => {
3540
+ const xhr = new Xhr();
3541
+ const abort = () => xhr.abort();
3542
+ xhr.open("PUT", url);
3543
+ headers.forEach((value, key) => xhr.setRequestHeader(key, value));
3544
+ xhr.upload.onprogress = (event) => {
3545
+ onProgress({ loaded: event.loaded });
3546
+ };
3547
+ xhr.onload = () => {
3548
+ if (options?.signal) {
3549
+ options.signal.removeEventListener("abort", abort);
3550
+ }
3551
+ if (xhr.status < 200 || xhr.status >= 300) {
3552
+ reject(new Error(`athena.storage.file.upload failed with status ${xhr.status}`));
3553
+ return;
3554
+ }
3555
+ onProgress({ loaded: source.sizeBytes });
3556
+ resolve(new Response(xhr.response, {
3557
+ status: xhr.status,
3558
+ statusText: xhr.statusText,
3559
+ headers: parseXhrHeaders(xhr.getAllResponseHeaders())
3560
+ }));
3561
+ };
3562
+ xhr.onerror = () => {
3563
+ if (options?.signal) {
3564
+ options.signal.removeEventListener("abort", abort);
3565
+ }
3566
+ reject(new Error("athena.storage.file.upload failed with a network error"));
3567
+ };
3568
+ xhr.onabort = () => {
3569
+ if (options?.signal) {
3570
+ options.signal.removeEventListener("abort", abort);
3571
+ }
3572
+ reject(new DOMException("Upload aborted", "AbortError"));
3573
+ };
3574
+ if (options?.signal) {
3575
+ if (options.signal.aborted) {
3576
+ abort();
3577
+ return;
3578
+ }
3579
+ options.signal.addEventListener("abort", abort, { once: true });
3580
+ }
3581
+ xhr.send(source.source);
3582
+ });
3583
+ }
3584
+ function normalizeDownloadArgs(input, queryOrOptions, maybeOptions) {
3585
+ if (typeof input === "string") {
3586
+ return { fileIds: [input], query: queryOrOptions, options: maybeOptions };
3587
+ }
3588
+ if (Array.isArray(input)) {
3589
+ return { fileIds: [...input], query: queryOrOptions, options: maybeOptions };
3590
+ }
3591
+ const downloadInput = input;
3592
+ const { fileId, fileIds, ...query } = downloadInput;
3593
+ return {
3594
+ fileIds: fileIds ? [...fileIds] : fileId ? [fileId] : [],
3595
+ query,
3596
+ options: queryOrOptions
3597
+ };
3598
+ }
3599
+ function createPathContext(input, options, config) {
3600
+ const organizationId = input.organizationId ?? input.organization_id ?? options?.organizationId ?? void 0;
3601
+ const userId = input.userId ?? input.user_id ?? options?.userId ?? void 0;
3602
+ const resourceId = input.resourceId ?? input.resource_id ?? void 0;
3603
+ const vars = {
3604
+ ...config.vars ?? {},
3605
+ ...input.vars ?? {}
3606
+ };
3607
+ if (organizationId !== void 0) {
3608
+ vars.organizationId = organizationId;
3609
+ vars.organization_id = organizationId;
3610
+ }
3611
+ if (userId !== void 0) {
3612
+ vars.userId = userId;
3613
+ vars.user_id = userId;
3614
+ }
3615
+ if (resourceId !== void 0) {
3616
+ vars.resourceId = resourceId;
3617
+ vars.resource_id = resourceId;
3618
+ }
3619
+ return {
3620
+ vars,
3621
+ env: {
3622
+ ...readProcessEnv(),
3623
+ ...config.env ?? {},
3624
+ ...input.env ?? {}
3625
+ },
3626
+ organizationId,
3627
+ organization_id: organizationId,
3628
+ userId,
3629
+ user_id: userId,
3630
+ resourceId,
3631
+ resource_id: resourceId
3632
+ };
3633
+ }
3634
+ function renderStorageTemplate(template, context) {
3635
+ return template.replace(/\$\{([^}]+)\}|\{([^}]+)\}/g, (_match, shellToken, braceToken) => {
3636
+ const token = (shellToken ?? braceToken ?? "").trim();
3637
+ if (!token) return "";
3638
+ const value = resolveTemplateToken(token, context);
3639
+ return value === void 0 || value === null ? "" : String(value);
3640
+ });
3641
+ }
3642
+ function resolveTemplateToken(token, context) {
3643
+ if (token.startsWith("env.")) {
3644
+ return context.env[token.slice(4)];
3645
+ }
3646
+ if (token in context.vars) {
3647
+ return context.vars[token];
3648
+ }
3649
+ return context.env[token];
3650
+ }
3651
+ function joinStoragePath(...parts) {
3652
+ return parts.map((part) => part.trim().replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/");
3653
+ }
3654
+ function toArray(files) {
3655
+ if (isUploadSource(files)) return [files];
3656
+ return Array.from(files);
3657
+ }
3658
+ function isUploadSource(value) {
3659
+ return value instanceof Blob || value instanceof ArrayBuffer || value instanceof Uint8Array;
3660
+ }
3661
+ function sourceName(source) {
3662
+ return isRecord5(source) && typeof source.name === "string" && source.name.trim() ? source.name.trim() : void 0;
3663
+ }
3664
+ function sourceSize(source) {
3665
+ if (source instanceof Blob) return source.size;
3666
+ return source.byteLength;
3667
+ }
3668
+ function sourceContentType(source) {
3669
+ return source instanceof Blob && source.type.trim() ? source.type.trim() : void 0;
3670
+ }
3671
+ function normalizeExtensions(extensions) {
3672
+ return new Set((extensions ?? []).map((extension) => extension.replace(/^\./, "").toLowerCase()).filter(Boolean));
3673
+ }
3674
+ function fileExtension(fileName) {
3675
+ const lastDot = fileName.lastIndexOf(".");
3676
+ return lastDot === -1 ? "" : fileName.slice(lastDot + 1).toLowerCase();
3677
+ }
3678
+ function createProgressSnapshot(phase, sources, fileIndex, loaded, aggregateLoaded) {
3679
+ const total = sources[fileIndex]?.sizeBytes ?? 0;
3680
+ const aggregateTotal = sources.reduce((totalBytes, source) => totalBytes + source.sizeBytes, 0);
3681
+ return {
3682
+ phase,
3683
+ fileIndex,
3684
+ fileCount: sources.length,
3685
+ fileName: sources[fileIndex]?.fileName ?? "",
3686
+ loaded,
3687
+ total,
3688
+ percent: total > 0 ? Math.round(loaded / total * 100) : 100,
3689
+ aggregateLoaded,
3690
+ aggregateTotal,
3691
+ aggregatePercent: aggregateTotal > 0 ? Math.round(aggregateLoaded / aggregateTotal * 100) : 100
3692
+ };
3693
+ }
3694
+ function sum(values) {
3695
+ return values.reduce((total, value) => total + value, 0);
3696
+ }
3697
+ function parseXhrHeaders(raw) {
3698
+ const headers = new Headers();
3699
+ for (const line of raw.trim().split(/[\r\n]+/)) {
3700
+ const index = line.indexOf(":");
3701
+ if (index === -1) continue;
3702
+ headers.set(line.slice(0, index).trim(), line.slice(index + 1).trim());
3703
+ }
3704
+ return headers;
3705
+ }
3706
+ function readProcessEnv() {
3707
+ const processLike = globalThis.process;
3708
+ return processLike?.env ?? {};
3709
+ }
3710
+ function isRecord5(value) {
3711
+ return Boolean(value) && typeof value === "object";
3712
+ }
3713
+
3369
3714
  // src/storage/module.ts
3370
3715
  var storageSdkManifest = {
3371
3716
  namespace: "storage",
@@ -3574,7 +3919,7 @@ var AthenaStorageError = class extends Error {
3574
3919
  };
3575
3920
  }
3576
3921
  };
3577
- function isRecord5(value) {
3922
+ function isRecord6(value) {
3578
3923
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
3579
3924
  }
3580
3925
  function causeToString(cause) {
@@ -3689,7 +4034,7 @@ function withPathParam(path, name, value) {
3689
4034
  return path.replace(`{${name}}`, encodeURIComponent(value));
3690
4035
  }
3691
4036
  function resolveErrorMessage3(payload, fallback) {
3692
- if (isRecord5(payload)) {
4037
+ if (isRecord6(payload)) {
3693
4038
  const message = payload.message ?? payload.error ?? payload.details;
3694
4039
  if (typeof message === "string" && message.trim()) {
3695
4040
  return message.trim();
@@ -3701,12 +4046,12 @@ function resolveErrorMessage3(payload, fallback) {
3701
4046
  return fallback;
3702
4047
  }
3703
4048
  function resolveErrorHint2(payload) {
3704
- if (!isRecord5(payload)) return void 0;
4049
+ if (!isRecord6(payload)) return void 0;
3705
4050
  const hint = payload.hint ?? payload.suggestion;
3706
4051
  return typeof hint === "string" && hint.trim() ? hint.trim() : void 0;
3707
4052
  }
3708
4053
  function resolveErrorCause(payload) {
3709
- if (!isRecord5(payload)) return void 0;
4054
+ if (!isRecord6(payload)) return void 0;
3710
4055
  const cause = payload.cause ?? payload.reason;
3711
4056
  return typeof cause === "string" && cause.trim() ? cause.trim() : void 0;
3712
4057
  }
@@ -3825,7 +4170,7 @@ async function callStorageEndpoint(gateway, endpoint, method, envelope, payload,
3825
4170
  );
3826
4171
  }
3827
4172
  if (envelope === "athena") {
3828
- if (!isRecord5(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
4173
+ if (!isRecord6(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
3829
4174
  return rejectStorageError(
3830
4175
  {
3831
4176
  code: "INVALID_ATHENA_ENVELOPE",
@@ -3933,81 +4278,260 @@ async function callStorageBinaryEndpoint(gateway, endpoint, method, options, run
3933
4278
  runtimeOptions
3934
4279
  );
3935
4280
  }
3936
- function createStorageModule(gateway, runtimeOptions) {
4281
+ function isBlobBody(body) {
4282
+ return typeof Blob !== "undefined" && body instanceof Blob;
4283
+ }
4284
+ function isReadableStreamBody(body) {
4285
+ return typeof ReadableStream !== "undefined" && body instanceof ReadableStream;
4286
+ }
4287
+ async function putPresignedUploadBody(uploadUrl, uploadHeaders, body, options) {
4288
+ const headers = new Headers(uploadHeaders);
4289
+ Object.entries(options?.headers ?? {}).forEach(([key, value]) => headers.set(key, value));
4290
+ if (!headers.has("Content-Type") && isBlobBody(body) && body.type) {
4291
+ headers.set("Content-Type", body.type);
4292
+ }
4293
+ const init = {
4294
+ method: "PUT",
4295
+ headers,
4296
+ body,
4297
+ signal: options?.signal
4298
+ };
4299
+ if (isReadableStreamBody(body)) {
4300
+ init.duplex = "half";
4301
+ }
4302
+ return fetch(uploadUrl, init);
4303
+ }
4304
+ function attachManagedUpload(upload) {
4305
+ const headers = {};
3937
4306
  return {
4307
+ ...upload,
4308
+ method: "PUT",
4309
+ headers,
4310
+ expiresAt: upload.expires_at,
4311
+ put(body, options) {
4312
+ return putPresignedUploadBody(upload.url, headers, body, options);
4313
+ }
4314
+ };
4315
+ }
4316
+ function attachUploadHelper(response) {
4317
+ return {
4318
+ ...response,
4319
+ upload: attachManagedUpload(response.upload)
4320
+ };
4321
+ }
4322
+ function attachUploadHelpers(response) {
4323
+ return {
4324
+ files: response.files.map(attachUploadHelper)
4325
+ };
4326
+ }
4327
+ function normalizeUploadUrlRequest(input) {
4328
+ const s3_id = input.s3_id ?? input.s3Id;
4329
+ const storage_key = input.storage_key ?? input.storageKey;
4330
+ if (!s3_id?.trim()) {
4331
+ throw new Error("athena.storage.file.upload requires s3_id or s3Id");
4332
+ }
4333
+ if (!storage_key?.trim()) {
4334
+ throw new Error("athena.storage.file.upload requires storage_key or storageKey");
4335
+ }
4336
+ const fileName = input.fileName?.trim();
4337
+ const originalName = input.originalName?.trim();
4338
+ return {
4339
+ s3_id,
4340
+ bucket: input.bucket,
4341
+ storage_key,
4342
+ name: input.name ?? fileName,
4343
+ original_name: input.original_name ?? originalName ?? fileName,
4344
+ resource_id: input.resource_id ?? input.resourceId,
4345
+ mime_type: input.mime_type ?? input.mimeType,
4346
+ content_type: input.content_type ?? input.contentType,
4347
+ size_bytes: input.size_bytes ?? input.sizeBytes,
4348
+ file_id: input.file_id ?? input.fileId,
4349
+ public: input.public,
4350
+ visibility: input.visibility,
4351
+ metadata: input.metadata
4352
+ };
4353
+ }
4354
+ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options, runtimeOptions) {
4355
+ let url;
4356
+ let headers;
4357
+ try {
4358
+ const baseUrl = options?.baseUrl ? normalizeAthenaGatewayBaseUrl(options.baseUrl) : gateway.baseUrl;
4359
+ url = buildAthenaGatewayUrl(baseUrl, endpoint);
4360
+ headers = gateway.buildHeaders(options);
4361
+ } catch (error) {
4362
+ return rejectStorageError(
4363
+ {
4364
+ code: storageCodeFromUnknown(error),
4365
+ message: error instanceof Error ? error.message : `Athena storage PUT ${endpoint} failed before sending the request`,
4366
+ status: isAthenaGatewayError(error) ? error.status : 0,
4367
+ endpoint,
4368
+ method: "PUT",
4369
+ raw: error,
4370
+ requestId: isAthenaGatewayError(error) ? error.requestId : void 0,
4371
+ hint: isAthenaGatewayError(error) ? error.hint : void 0,
4372
+ cause: error
4373
+ },
4374
+ options,
4375
+ runtimeOptions
4376
+ );
4377
+ }
4378
+ delete headers["Content-Type"];
4379
+ delete headers["content-type"];
4380
+ if (isBlobBody(body) && body.type) {
4381
+ headers["Content-Type"] = body.type;
4382
+ }
4383
+ const requestInit = {
4384
+ method: "PUT",
4385
+ headers,
4386
+ body,
4387
+ signal: options?.signal
4388
+ };
4389
+ if (isReadableStreamBody(body)) {
4390
+ requestInit.duplex = "half";
4391
+ }
4392
+ let response;
4393
+ try {
4394
+ response = await fetch(url, requestInit);
4395
+ } catch (error) {
4396
+ const message = error instanceof Error ? error.message : String(error);
4397
+ return rejectStorageError(
4398
+ {
4399
+ code: "NETWORK_ERROR",
4400
+ message: `Network error while calling Athena storage PUT ${endpoint}: ${message}`,
4401
+ status: 0,
4402
+ endpoint,
4403
+ method: "PUT",
4404
+ cause: error
4405
+ },
4406
+ options,
4407
+ runtimeOptions
4408
+ );
4409
+ }
4410
+ let rawText;
4411
+ try {
4412
+ rawText = await response.text();
4413
+ } catch (error) {
4414
+ return rejectStorageError(
4415
+ {
4416
+ code: "NETWORK_ERROR",
4417
+ message: `Athena storage PUT ${endpoint} response body could not be read`,
4418
+ status: response.status,
4419
+ endpoint,
4420
+ method: "PUT",
4421
+ requestId: headerValue(response.headers, ["x-athena-request-id", "x-request-id", "request-id"]),
4422
+ cause: error
4423
+ },
4424
+ options,
4425
+ runtimeOptions
4426
+ );
4427
+ }
4428
+ const parsedBody = parseResponseBody3(rawText ?? "", response.headers.get("content-type"));
4429
+ const requestId = headerValue(response.headers, ["x-athena-request-id", "x-request-id", "request-id"]);
4430
+ if (parsedBody.parseFailed) {
4431
+ return rejectStorageError(
4432
+ {
4433
+ code: "INVALID_JSON",
4434
+ message: `Athena storage PUT ${endpoint} returned malformed JSON`,
4435
+ status: response.status,
4436
+ endpoint,
4437
+ method: "PUT",
4438
+ requestId,
4439
+ raw: parsedBody.parsed
4440
+ },
4441
+ options,
4442
+ runtimeOptions
4443
+ );
4444
+ }
4445
+ if (!response.ok) {
4446
+ return rejectStorageError(
4447
+ {
4448
+ code: "HTTP_ERROR",
4449
+ message: resolveErrorMessage3(
4450
+ parsedBody.parsed,
4451
+ `Athena storage PUT ${endpoint} failed with status ${response.status}`
4452
+ ),
4453
+ status: response.status,
4454
+ endpoint,
4455
+ method: "PUT",
4456
+ requestId,
4457
+ hint: resolveErrorHint2(parsedBody.parsed),
4458
+ cause: resolveErrorCause(parsedBody.parsed),
4459
+ raw: parsedBody.parsed
4460
+ },
4461
+ options,
4462
+ runtimeOptions
4463
+ );
4464
+ }
4465
+ if (!isRecord6(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
4466
+ return rejectStorageError(
4467
+ {
4468
+ code: "INVALID_ATHENA_ENVELOPE",
4469
+ message: `Athena storage PUT ${endpoint} returned an invalid Athena envelope`,
4470
+ status: response.status,
4471
+ endpoint,
4472
+ method: "PUT",
4473
+ requestId,
4474
+ raw: parsedBody.parsed
4475
+ },
4476
+ options,
4477
+ runtimeOptions
4478
+ );
4479
+ }
4480
+ return parsedBody.parsed.data;
4481
+ }
4482
+ function createStorageModule(gateway, runtimeOptions) {
4483
+ const callRaw = (path, method, payload, options) => callStorageEndpoint(
4484
+ gateway,
4485
+ storagePath(path),
4486
+ method,
4487
+ "raw",
4488
+ payload,
4489
+ options,
4490
+ runtimeOptions
4491
+ );
4492
+ const callAthena2 = (path, method, payload, options) => callStorageEndpoint(
4493
+ gateway,
4494
+ storagePath(path),
4495
+ method,
4496
+ "athena",
4497
+ payload,
4498
+ options,
4499
+ runtimeOptions
4500
+ );
4501
+ const base = {
3938
4502
  listStorageCatalogs(options) {
3939
- return callStorageEndpoint(gateway, storagePath("/storage/catalogs"), "GET", "raw", void 0, options, runtimeOptions);
4503
+ return callRaw("/storage/catalogs", "GET", void 0, options);
3940
4504
  },
3941
4505
  createStorageCatalog(input, options) {
3942
- return callStorageEndpoint(gateway, storagePath("/storage/catalogs"), "POST", "raw", input, options, runtimeOptions);
4506
+ return callRaw("/storage/catalogs", "POST", input, options);
3943
4507
  },
3944
4508
  updateStorageCatalog(id, input, options) {
3945
- return callStorageEndpoint(
3946
- gateway,
3947
- storagePath(withPathParam("/storage/catalogs/{id}", "id", id)),
3948
- "PATCH",
3949
- "raw",
3950
- input,
3951
- options,
3952
- runtimeOptions
3953
- );
4509
+ return callRaw(withPathParam("/storage/catalogs/{id}", "id", id), "PATCH", input, options);
3954
4510
  },
3955
4511
  deleteStorageCatalog(id, options) {
3956
- return callStorageEndpoint(
3957
- gateway,
3958
- storagePath(withPathParam("/storage/catalogs/{id}", "id", id)),
3959
- "DELETE",
3960
- "raw",
3961
- void 0,
3962
- options,
3963
- runtimeOptions
3964
- );
4512
+ return callRaw(withPathParam("/storage/catalogs/{id}", "id", id), "DELETE", void 0, options);
3965
4513
  },
3966
4514
  listStorageCredentials(options) {
3967
- return callStorageEndpoint(gateway, storagePath("/storage/credentials"), "GET", "raw", void 0, options, runtimeOptions);
4515
+ return callRaw("/storage/credentials", "GET", void 0, options);
3968
4516
  },
3969
4517
  createStorageUploadUrl(input, options) {
3970
- return callStorageEndpoint(
3971
- gateway,
3972
- storagePath("/storage/files/upload-url"),
3973
- "POST",
3974
- "athena",
3975
- input,
3976
- options,
3977
- runtimeOptions
3978
- );
4518
+ return callAthena2("/storage/files/upload-url", "POST", input, options);
3979
4519
  },
3980
4520
  createStorageUploadUrls(input, options) {
3981
- return callStorageEndpoint(
3982
- gateway,
3983
- storagePath("/storage/files/upload-urls"),
3984
- "POST",
3985
- "athena",
3986
- input,
3987
- options,
3988
- runtimeOptions
3989
- );
4521
+ return callAthena2("/storage/files/upload-urls", "POST", input, options);
3990
4522
  },
3991
4523
  listStorageFiles(input, options) {
3992
- return callStorageEndpoint(gateway, storagePath("/storage/files/list"), "POST", "athena", input, options, runtimeOptions);
4524
+ return callAthena2("/storage/files/list", "POST", input, options);
3993
4525
  },
3994
4526
  getStorageFile(fileId, options) {
3995
- return callStorageEndpoint(
3996
- gateway,
3997
- storagePath(withPathParam("/storage/files/{file_id}", "file_id", fileId)),
3998
- "GET",
3999
- "athena",
4000
- void 0,
4001
- options,
4002
- runtimeOptions
4003
- );
4527
+ return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "GET", void 0, options);
4004
4528
  },
4005
4529
  getStorageFileUrl(fileId, query, options) {
4006
4530
  const path = appendQuery(
4007
4531
  withPathParam("/storage/files/{file_id}/url", "file_id", fileId),
4008
4532
  query
4009
4533
  );
4010
- return callStorageEndpoint(gateway, storagePath(path), "GET", "athena", void 0, options, runtimeOptions);
4534
+ return callAthena2(path, "GET", void 0, options);
4011
4535
  },
4012
4536
  getStorageFileProxy(fileId, query, options) {
4013
4537
  const path = appendQuery(
@@ -4017,45 +4541,244 @@ function createStorageModule(gateway, runtimeOptions) {
4017
4541
  return callStorageBinaryEndpoint(gateway, storagePath(path), "GET", options, runtimeOptions);
4018
4542
  },
4019
4543
  updateStorageFile(fileId, input, options) {
4020
- return callStorageEndpoint(
4021
- gateway,
4022
- storagePath(withPathParam("/storage/files/{file_id}", "file_id", fileId)),
4023
- "PATCH",
4024
- "athena",
4025
- input,
4026
- options,
4027
- runtimeOptions
4028
- );
4544
+ return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "PATCH", input, options);
4029
4545
  },
4030
4546
  deleteStorageFile(fileId, options) {
4031
- return callStorageEndpoint(
4032
- gateway,
4033
- storagePath(withPathParam("/storage/files/{file_id}", "file_id", fileId)),
4034
- "DELETE",
4035
- "athena",
4036
- void 0,
4037
- options,
4038
- runtimeOptions
4039
- );
4547
+ return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "DELETE", void 0, options);
4040
4548
  },
4041
4549
  setStorageFileVisibility(fileId, input, options) {
4042
- return callStorageEndpoint(
4550
+ return callAthena2(withPathParam("/storage/files/{file_id}/visibility", "file_id", fileId), "PATCH", input, options);
4551
+ },
4552
+ deleteStorageFolder(input, options) {
4553
+ return callAthena2("/storage/folders/delete", "POST", input, options);
4554
+ },
4555
+ moveStorageFolder(input, options) {
4556
+ return callAthena2("/storage/folders/move", "POST", input, options);
4557
+ }
4558
+ };
4559
+ const fileFacade = createStorageFileModule(base, runtimeOptions);
4560
+ const fileUpload = ((input, options) => {
4561
+ if (isRecord6(input) && "files" in input) {
4562
+ return fileFacade.upload(input, options);
4563
+ }
4564
+ return base.createStorageUploadUrl(
4565
+ normalizeUploadUrlRequest(input),
4566
+ options
4567
+ ).then(attachUploadHelper);
4568
+ });
4569
+ const fileDelete = ((input, options) => fileFacade.delete(input, options));
4570
+ const file = {
4571
+ ...fileFacade,
4572
+ upload: fileUpload,
4573
+ uploadMany(input, options) {
4574
+ return base.createStorageUploadUrls(
4575
+ { files: input.files.map(normalizeUploadUrlRequest) },
4576
+ options
4577
+ ).then(attachUploadHelpers);
4578
+ },
4579
+ confirmUpload(fileId, input, options) {
4580
+ return callAthena2(withPathParam("/storage/files/{file_id}/confirm-upload", "file_id", fileId), "POST", input ?? {}, options);
4581
+ },
4582
+ uploadBinary(fileId, body, options) {
4583
+ return callStorageUploadBinaryEndpoint(
4043
4584
  gateway,
4044
- storagePath(withPathParam("/storage/files/{file_id}/visibility", "file_id", fileId)),
4045
- "PATCH",
4046
- "athena",
4047
- input,
4585
+ storagePath(withPathParam("/storage/files/{file_id}/upload", "file_id", fileId)),
4586
+ body,
4048
4587
  options,
4049
4588
  runtimeOptions
4050
4589
  );
4051
4590
  },
4052
- deleteStorageFolder(input, options) {
4053
- return callStorageEndpoint(gateway, storagePath("/storage/folders/delete"), "POST", "athena", input, options, runtimeOptions);
4591
+ search(input, options) {
4592
+ return callAthena2("/storage/files/search", "POST", input, options);
4054
4593
  },
4055
- moveStorageFolder(input, options) {
4056
- return callStorageEndpoint(gateway, storagePath("/storage/folders/move"), "POST", "athena", input, options, runtimeOptions);
4594
+ get(fileId, options) {
4595
+ return base.getStorageFile(fileId, options);
4596
+ },
4597
+ update(fileId, input, options) {
4598
+ return base.updateStorageFile(fileId, input, options);
4599
+ },
4600
+ delete: fileDelete,
4601
+ deleteMany(input, options) {
4602
+ return callAthena2("/storage/files/delete-many", "POST", input, options);
4603
+ },
4604
+ updateMany(input, options) {
4605
+ return callAthena2("/storage/files/update-many", "POST", input, options);
4606
+ },
4607
+ restore(fileId, options) {
4608
+ return callAthena2(withPathParam("/storage/files/{file_id}/restore", "file_id", fileId), "POST", {}, options);
4609
+ },
4610
+ purge(fileId, options) {
4611
+ return callAthena2(withPathParam("/storage/files/{file_id}/purge", "file_id", fileId), "DELETE", void 0, options);
4612
+ },
4613
+ copy(fileId, input, options) {
4614
+ return callAthena2(withPathParam("/storage/files/{file_id}/copy", "file_id", fileId), "POST", input, options);
4615
+ },
4616
+ url(fileId, query, options) {
4617
+ return base.getStorageFileUrl(fileId, query, options);
4618
+ },
4619
+ publicUrl(fileId, options) {
4620
+ return callAthena2(withPathParam("/storage/files/{file_id}/public-url", "file_id", fileId), "GET", void 0, options);
4621
+ },
4622
+ proxy(fileId, query, options) {
4623
+ return base.getStorageFileProxy(fileId, query, options);
4624
+ },
4625
+ visibility: {
4626
+ set(fileId, input, options) {
4627
+ return base.setStorageFileVisibility(fileId, input, options);
4628
+ },
4629
+ setMany(input, options) {
4630
+ return callAthena2("/storage/files/visibility-many", "POST", input, options);
4631
+ }
4632
+ }
4633
+ };
4634
+ const credentials = {
4635
+ list(options) {
4636
+ return base.listStorageCredentials(options);
4637
+ }
4638
+ };
4639
+ const catalog = {
4640
+ list(options) {
4641
+ return base.listStorageCatalogs(options);
4642
+ },
4643
+ create(input, options) {
4644
+ return base.createStorageCatalog(input, options);
4645
+ },
4646
+ update(id, input, options) {
4647
+ return base.updateStorageCatalog(id, input, options);
4648
+ },
4649
+ delete(id, options) {
4650
+ return base.deleteStorageCatalog(id, options);
4651
+ }
4652
+ };
4653
+ const folder = {
4654
+ list(input, options) {
4655
+ return callAthena2("/storage/folders/list", "POST", input, options);
4656
+ },
4657
+ tree(input, options) {
4658
+ return callAthena2("/storage/folders/tree", "POST", input, options);
4659
+ },
4660
+ delete(input, options) {
4661
+ return base.deleteStorageFolder(input, options);
4662
+ },
4663
+ move(input, options) {
4664
+ return base.moveStorageFolder(input, options);
4665
+ }
4666
+ };
4667
+ const permission = {
4668
+ list(input, options) {
4669
+ return callAthena2("/storage/permissions/list", "POST", input, options);
4670
+ },
4671
+ grant(input, options) {
4672
+ return callAthena2("/storage/permissions/grant", "POST", input, options);
4673
+ },
4674
+ revoke(input, options) {
4675
+ return callAthena2("/storage/permissions/revoke", "POST", input, options);
4676
+ },
4677
+ check(input, options) {
4678
+ return callAthena2("/storage/permissions/check", "POST", input, options);
4057
4679
  }
4058
4680
  };
4681
+ const objectFolder = {
4682
+ create(input, options) {
4683
+ return callAthena2("/storage/objects/folder", "POST", input, options);
4684
+ },
4685
+ delete(input, options) {
4686
+ return callAthena2("/storage/objects/folder/delete", "POST", input, options);
4687
+ },
4688
+ rename(input, options) {
4689
+ return callAthena2("/storage/objects/folder/rename", "POST", input, options);
4690
+ }
4691
+ };
4692
+ const object = {
4693
+ list(input, options) {
4694
+ return callAthena2("/storage/objects", "POST", input, options);
4695
+ },
4696
+ head(input, options) {
4697
+ return callAthena2("/storage/objects/head", "POST", input, options);
4698
+ },
4699
+ exists(input, options) {
4700
+ return callAthena2("/storage/objects/exists", "POST", input, options);
4701
+ },
4702
+ validate(input, options) {
4703
+ return callAthena2("/storage/objects/validate", "POST", input, options);
4704
+ },
4705
+ update(input, options) {
4706
+ return callAthena2("/storage/objects/update", "POST", input, options);
4707
+ },
4708
+ copy(input, options) {
4709
+ return callAthena2("/storage/objects/copy", "POST", input, options);
4710
+ },
4711
+ url(input, options) {
4712
+ return callAthena2("/storage/objects/url", "POST", input, options);
4713
+ },
4714
+ publicUrl(input, options) {
4715
+ return callAthena2("/storage/objects/public-url", "POST", input, options);
4716
+ },
4717
+ delete(input, options) {
4718
+ return callAthena2("/storage/objects/delete", "POST", input, options);
4719
+ },
4720
+ uploadUrl(input, options) {
4721
+ return callAthena2("/storage/objects/upload-url", "POST", input, options);
4722
+ },
4723
+ folder: objectFolder
4724
+ };
4725
+ const bucket = {
4726
+ list(input, options) {
4727
+ return callAthena2("/storage/buckets/list", "POST", input, options);
4728
+ },
4729
+ create(input, options) {
4730
+ return callAthena2("/storage/buckets/create", "POST", input, options);
4731
+ },
4732
+ delete(input, options) {
4733
+ return callAthena2("/storage/buckets/delete", "POST", input, options);
4734
+ },
4735
+ cors: {
4736
+ get(input, options) {
4737
+ return callAthena2("/storage/buckets/cors", "POST", input, options);
4738
+ },
4739
+ set(input, options) {
4740
+ return callAthena2("/storage/buckets/cors/set", "POST", input, options);
4741
+ },
4742
+ delete(input, options) {
4743
+ return callAthena2("/storage/buckets/cors/delete", "POST", input, options);
4744
+ }
4745
+ }
4746
+ };
4747
+ const multipart = {
4748
+ create(input, options) {
4749
+ return callAthena2("/storage/multipart/create", "POST", input, options);
4750
+ },
4751
+ signPart(input, options) {
4752
+ return callAthena2("/storage/multipart/sign-part", "POST", input, options);
4753
+ },
4754
+ complete(input, options) {
4755
+ return callAthena2("/storage/multipart/complete", "POST", input, options);
4756
+ },
4757
+ abort(input, options) {
4758
+ return callAthena2("/storage/multipart/abort", "POST", input, options);
4759
+ },
4760
+ listParts(input, options) {
4761
+ return callAthena2("/storage/multipart/list-parts", "POST", input, options);
4762
+ }
4763
+ };
4764
+ const audit = {
4765
+ list(input, options) {
4766
+ return callAthena2("/storage/audit/list", "POST", input, options);
4767
+ }
4768
+ };
4769
+ return {
4770
+ ...base,
4771
+ credentials,
4772
+ catalog,
4773
+ file,
4774
+ folder,
4775
+ permission,
4776
+ object,
4777
+ bucket,
4778
+ multipart,
4779
+ audit,
4780
+ delete: file.delete
4781
+ };
4059
4782
  }
4060
4783
 
4061
4784
  // src/query-ast.ts
@@ -4085,7 +4808,7 @@ var BOOLEAN_SAFE_OPERATORS = /* @__PURE__ */ new Set([
4085
4808
  "ilike",
4086
4809
  "is"
4087
4810
  ]);
4088
- function isRecord6(value) {
4811
+ function isRecord7(value) {
4089
4812
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4090
4813
  }
4091
4814
  function isUuidString(value) {
@@ -4098,7 +4821,7 @@ function shouldUseUuidTextComparison(column, value) {
4098
4821
  return typeof value === "string" && isUuidString(value) && isUuidIdentifierColumn(column);
4099
4822
  }
4100
4823
  function isRelationSelectNode(value) {
4101
- return isRecord6(value) && isRecord6(value.select);
4824
+ return isRecord7(value) && isRecord7(value.select);
4102
4825
  }
4103
4826
  function normalizeIdentifier(value, label) {
4104
4827
  const normalized = value.trim();
@@ -4154,7 +4877,7 @@ function compileRelationToken(key, node) {
4154
4877
  return `${prefix}${relationToken}(${nested})`;
4155
4878
  }
4156
4879
  function compileSelectShape(select) {
4157
- if (!isRecord6(select)) {
4880
+ if (!isRecord7(select)) {
4158
4881
  throw new Error("findMany select must be an object");
4159
4882
  }
4160
4883
  const tokens = [];
@@ -4178,7 +4901,7 @@ function compileSelectShape(select) {
4178
4901
  return tokens.join(",");
4179
4902
  }
4180
4903
  function selectShapeUsesRelationSchema(select) {
4181
- if (!isRecord6(select)) {
4904
+ if (!isRecord7(select)) {
4182
4905
  return false;
4183
4906
  }
4184
4907
  for (const rawValue of Object.values(select)) {
@@ -4196,7 +4919,7 @@ function selectShapeUsesRelationSchema(select) {
4196
4919
  }
4197
4920
  function compileColumnWhere(column, input) {
4198
4921
  const normalizedColumn = normalizeIdentifier(column, "where column");
4199
- if (!isRecord6(input)) {
4922
+ if (!isRecord7(input)) {
4200
4923
  return [buildGatewayCondition("eq", normalizedColumn, input)];
4201
4924
  }
4202
4925
  const conditions = [];
@@ -4224,7 +4947,7 @@ function compileColumnWhere(column, input) {
4224
4947
  return conditions;
4225
4948
  }
4226
4949
  function compileBooleanExpressionTerms(clause, label) {
4227
- if (!isRecord6(clause)) {
4950
+ if (!isRecord7(clause)) {
4228
4951
  throw new Error(`findMany where.${label} clauses must be objects`);
4229
4952
  }
4230
4953
  const entries = Object.entries(clause).filter(([, value]) => value !== void 0);
@@ -4233,7 +4956,7 @@ function compileBooleanExpressionTerms(clause, label) {
4233
4956
  }
4234
4957
  const [rawColumn, rawValue] = entries[0];
4235
4958
  const column = normalizeIdentifier(rawColumn, `where.${label} column`);
4236
- if (!isRecord6(rawValue)) {
4959
+ if (!isRecord7(rawValue)) {
4237
4960
  return [`${column}.eq.${stringifyFilterValue(rawValue)}`];
4238
4961
  }
4239
4962
  const operatorEntries = Object.entries(rawValue).filter(([, value]) => value !== void 0);
@@ -4257,7 +4980,7 @@ function compileWhere(where) {
4257
4980
  if (where === void 0) {
4258
4981
  return void 0;
4259
4982
  }
4260
- if (!isRecord6(where)) {
4983
+ if (!isRecord7(where)) {
4261
4984
  throw new Error("findMany where must be an object");
4262
4985
  }
4263
4986
  const conditions = [];
@@ -4307,7 +5030,7 @@ function compileOrderBy(orderBy) {
4307
5030
  if (orderBy === void 0) {
4308
5031
  return void 0;
4309
5032
  }
4310
- if (!isRecord6(orderBy)) {
5033
+ if (!isRecord7(orderBy)) {
4311
5034
  throw new Error("findMany orderBy must be an object");
4312
5035
  }
4313
5036
  if ("column" in orderBy) {
@@ -4482,11 +5205,11 @@ function toFindManyAstOrder(order) {
4482
5205
  ascending: order.direction !== "descending"
4483
5206
  };
4484
5207
  }
4485
- function isRecord7(value) {
5208
+ function isRecord8(value) {
4486
5209
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4487
5210
  }
4488
5211
  function normalizeFindManyAstColumnPredicate(value) {
4489
- if (!isRecord7(value)) {
5212
+ if (!isRecord8(value)) {
4490
5213
  return {
4491
5214
  eq: value
4492
5215
  };
@@ -4510,7 +5233,7 @@ function normalizeFindManyAstBooleanOperand(clause) {
4510
5233
  return normalized;
4511
5234
  }
4512
5235
  function normalizeFindManyAstWhere(where) {
4513
- if (!where || !isRecord7(where)) {
5236
+ if (!where || !isRecord8(where)) {
4514
5237
  return where;
4515
5238
  }
4516
5239
  const normalized = {};
@@ -4524,7 +5247,7 @@ function normalizeFindManyAstWhere(where) {
4524
5247
  );
4525
5248
  continue;
4526
5249
  }
4527
- if (key === "not" && isRecord7(value)) {
5250
+ if (key === "not" && isRecord8(value)) {
4528
5251
  normalized.not = normalizeFindManyAstBooleanOperand(
4529
5252
  value
4530
5253
  );
@@ -4535,7 +5258,7 @@ function normalizeFindManyAstWhere(where) {
4535
5258
  return normalized;
4536
5259
  }
4537
5260
  function predicateRequiresUuidQueryFallback(column, value) {
4538
- if (!isRecord7(value)) {
5261
+ if (!isRecord8(value)) {
4539
5262
  return shouldUseUuidTextComparison(column, value);
4540
5263
  }
4541
5264
  const eqValue = value.eq;
@@ -4553,7 +5276,7 @@ function booleanOperandRequiresUuidQueryFallback(clause) {
4553
5276
  return false;
4554
5277
  }
4555
5278
  function findManyAstWhereRequiresLegacyTransport(where) {
4556
- if (!where || !isRecord7(where)) {
5279
+ if (!where || !isRecord8(where)) {
4557
5280
  return false;
4558
5281
  }
4559
5282
  for (const [key, value] of Object.entries(where)) {
@@ -4568,7 +5291,7 @@ function findManyAstWhereRequiresLegacyTransport(where) {
4568
5291
  }
4569
5292
  continue;
4570
5293
  }
4571
- if (key === "not" && isRecord7(value)) {
5294
+ if (key === "not" && isRecord8(value)) {
4572
5295
  if (booleanOperandRequiresUuidQueryFallback(value)) {
4573
5296
  return true;
4574
5297
  }
@@ -4770,7 +5493,7 @@ async function executeExperimentalRead(experimental, runner) {
4770
5493
  throw error;
4771
5494
  }
4772
5495
  }
4773
- function isRecord8(value) {
5496
+ function isRecord9(value) {
4774
5497
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4775
5498
  }
4776
5499
  function firstNonEmptyString2(...values) {
@@ -4782,8 +5505,8 @@ function firstNonEmptyString2(...values) {
4782
5505
  return void 0;
4783
5506
  }
4784
5507
  function resolveStructuredErrorPayload2(raw) {
4785
- if (!isRecord8(raw)) return null;
4786
- return isRecord8(raw.error) ? raw.error : raw;
5508
+ if (!isRecord9(raw)) return null;
5509
+ return isRecord9(raw.error) ? raw.error : raw;
4787
5510
  }
4788
5511
  function resolveStructuredErrorDetails(payload, message) {
4789
5512
  if (!payload || !("details" in payload)) {
@@ -4799,7 +5522,7 @@ function resolveStructuredErrorDetails(payload, message) {
4799
5522
  return details;
4800
5523
  }
4801
5524
  function createResultError(response, result, normalized) {
4802
- const rawRecord = isRecord8(response.raw) ? response.raw : null;
5525
+ const rawRecord = isRecord9(response.raw) ? response.raw : null;
4803
5526
  const payload = resolveStructuredErrorPayload2(response.raw);
4804
5527
  const message = firstNonEmptyString2(
4805
5528
  response.error,
@@ -6567,7 +7290,7 @@ function resolveNullishValue(mode) {
6567
7290
  if (mode === "null") return null;
6568
7291
  return "";
6569
7292
  }
6570
- function isRecord9(value) {
7293
+ function isRecord10(value) {
6571
7294
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
6572
7295
  }
6573
7296
  function isNullableColumn(model, key) {
@@ -6576,7 +7299,7 @@ function isNullableColumn(model, key) {
6576
7299
  }
6577
7300
  function toModelFormDefaults(model, values, options) {
6578
7301
  const source = values;
6579
- if (!isRecord9(source)) {
7302
+ if (!isRecord10(source)) {
6580
7303
  return {};
6581
7304
  }
6582
7305
  const mode = options?.nullishMode ?? "empty-string";
@@ -6916,15 +7639,15 @@ function readCookieFromHeaders(headers, name) {
6916
7639
  }
6917
7640
  return parseCookies(cookieHeader).get(name);
6918
7641
  }
6919
- function isRecord10(value) {
7642
+ function isRecord11(value) {
6920
7643
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
6921
7644
  }
6922
7645
  function resolveSessionCandidate(value) {
6923
- if (!isRecord10(value)) {
7646
+ if (!isRecord11(value)) {
6924
7647
  return null;
6925
7648
  }
6926
- const session = isRecord10(value.session) ? value.session : void 0;
6927
- const user = isRecord10(value.user) ? value.user : void 0;
7649
+ const session = isRecord11(value.session) ? value.session : void 0;
7650
+ const user = isRecord11(value.user) ? value.user : void 0;
6928
7651
  if (session && typeof session.token === "string" && session.token.length > 0 && user) {
6929
7652
  return {
6930
7653
  session,
@@ -6934,7 +7657,7 @@ function resolveSessionCandidate(value) {
6934
7657
  return null;
6935
7658
  }
6936
7659
  function inferSessionPair(returned) {
6937
- return resolveSessionCandidate(returned) ?? (isRecord10(returned) ? resolveSessionCandidate(returned.data) : null) ?? (isRecord10(returned) ? resolveSessionCandidate(returned.session) : null);
7660
+ return resolveSessionCandidate(returned) ?? (isRecord11(returned) ? resolveSessionCandidate(returned.data) : null) ?? (isRecord11(returned) ? resolveSessionCandidate(returned.session) : null);
6938
7661
  }
6939
7662
  function resolveResponseHeaders(ctx) {
6940
7663
  if (ctx.context.responseHeaders instanceof Headers) {