@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/index.cjs CHANGED
@@ -673,9 +673,16 @@ var getSessionCookie = (request, config) => {
673
673
  const { cookieName = "session_token", cookiePrefix = "athena-auth" } = config || {};
674
674
  const parsedCookie = parseCookies(cookies);
675
675
  const getCookie = (name) => parsedCookie.get(name) || parsedCookie.get(`${SECURE_COOKIE_PREFIX}${name}`);
676
- const sessionToken = getCookie(`${cookiePrefix}.${cookieName}`) || getCookie(`${cookiePrefix}-${cookieName}`);
677
- if (sessionToken) {
678
- return sessionToken;
676
+ const candidateCookieNames = Array.from(/* @__PURE__ */ new Set([
677
+ cookieName,
678
+ cookieName.replace(/_/g, "-"),
679
+ cookieName.replace(/-/g, "_")
680
+ ])).filter(Boolean);
681
+ for (const candidateName of candidateCookieNames) {
682
+ const sessionToken = getCookie(`${cookiePrefix}.${candidateName}`) || getCookie(`${cookiePrefix}-${candidateName}`);
683
+ if (sessionToken) {
684
+ return sessionToken;
685
+ }
679
686
  }
680
687
  return null;
681
688
  };
@@ -798,7 +805,7 @@ var getCookieCache = async (request, config) => {
798
805
 
799
806
  // package.json
800
807
  var package_default = {
801
- version: "2.6.0"
808
+ version: "2.7.0"
802
809
  };
803
810
 
804
811
  // src/sdk-version.ts
@@ -3373,6 +3380,344 @@ function createDbModule(input) {
3373
3380
  return db;
3374
3381
  }
3375
3382
 
3383
+ // src/storage/file.ts
3384
+ function createStorageFileModule(base, config = {}) {
3385
+ const upload = async (input, options) => {
3386
+ const sources = normalizeUploadSources(input);
3387
+ validateUploadConstraints(sources, input);
3388
+ const uploadRequests = sources.map((source, index) => {
3389
+ const storageKey = resolveUploadStorageKey(input, source, index, options, config);
3390
+ return {
3391
+ source,
3392
+ uploadRequest: {
3393
+ s3_id: input.s3_id,
3394
+ bucket: input.bucket,
3395
+ storage_key: storageKey,
3396
+ name: input.name ?? source.fileName,
3397
+ original_name: input.original_name ?? source.fileName,
3398
+ resource_id: input.resource_id ?? input.resourceId,
3399
+ mime_type: input.mime_type ?? source.contentType,
3400
+ content_type: input.content_type ?? source.contentType,
3401
+ size_bytes: source.sizeBytes,
3402
+ public: input.public,
3403
+ metadata: input.metadata
3404
+ }
3405
+ };
3406
+ });
3407
+ input.onProgress?.(createProgressSnapshot("preparing", sources, 0, 0, 0));
3408
+ const uploadUrls = uploadRequests.length === 1 ? [await base.createStorageUploadUrl(uploadRequests[0].uploadRequest, options)] : (await base.createStorageUploadUrls({ files: uploadRequests.map((request) => request.uploadRequest) }, options)).files;
3409
+ const aggregateLoaded = new Array(uploadRequests.length).fill(0);
3410
+ const uploaded = [];
3411
+ for (let index = 0; index < uploadRequests.length; index += 1) {
3412
+ const request = uploadRequests[index];
3413
+ const uploadUrl = uploadUrls[index];
3414
+ const response = await putUploadBody(uploadUrl.upload.url, request.source, input, options, (progress) => {
3415
+ aggregateLoaded[index] = progress.loaded;
3416
+ input.onProgress?.(createProgressSnapshot("uploading", sources, index, progress.loaded, sum(aggregateLoaded)));
3417
+ });
3418
+ uploaded.push({
3419
+ file: uploadUrl.file,
3420
+ upload: uploadUrl.upload,
3421
+ source: request.source.source,
3422
+ fileName: request.source.fileName,
3423
+ storage_key: request.uploadRequest.storage_key,
3424
+ response
3425
+ });
3426
+ aggregateLoaded[index] = request.source.sizeBytes;
3427
+ input.onProgress?.(createProgressSnapshot("complete", sources, index, request.source.sizeBytes, sum(aggregateLoaded)));
3428
+ }
3429
+ return {
3430
+ files: uploaded,
3431
+ count: uploaded.length
3432
+ };
3433
+ };
3434
+ const download = ((input, queryOrOptions, maybeOptions) => {
3435
+ const { fileIds, query, options } = normalizeDownloadArgs(input, queryOrOptions, maybeOptions);
3436
+ const downloads = fileIds.map((fileId) => base.getStorageFileProxy(fileId, query, options));
3437
+ return Array.isArray(input) || isRecord5(input) && Array.isArray(input.fileIds) ? Promise.all(downloads) : downloads[0];
3438
+ });
3439
+ const deleteFile = ((input, options) => {
3440
+ if (Array.isArray(input)) {
3441
+ return Promise.all(input.map((fileId) => base.deleteStorageFile(fileId, options)));
3442
+ }
3443
+ return base.deleteStorageFile(input, options);
3444
+ });
3445
+ return {
3446
+ upload,
3447
+ download,
3448
+ list(input, options) {
3449
+ const prefix = resolveStoragePath(input.prefix ?? "", input, options, config);
3450
+ return base.listStorageFiles(
3451
+ {
3452
+ s3_id: input.s3_id,
3453
+ prefix
3454
+ },
3455
+ options
3456
+ );
3457
+ },
3458
+ delete: deleteFile
3459
+ };
3460
+ }
3461
+ function resolveStoragePath(path, input, options, config = {}) {
3462
+ const context = createPathContext(input, options, config);
3463
+ const prefixPath = input.prefixPath ?? config.prefixPath;
3464
+ const prefix = typeof prefixPath === "function" ? prefixPath(context) : prefixPath;
3465
+ return joinStoragePath(renderStorageTemplate(prefix ?? "", context), renderStorageTemplate(path, context));
3466
+ }
3467
+ function resolveUploadStorageKey(input, source, index, options, config) {
3468
+ const explicitKey = input.storage_key ?? input.storageKey;
3469
+ const keyTemplate = input.storageKeyTemplate;
3470
+ const fallbackName = source.fileName;
3471
+ const context = createPathContext(input, options, config);
3472
+ const key = keyTemplate ? renderStorageTemplate(keyTemplate, {
3473
+ ...context,
3474
+ vars: {
3475
+ ...context.vars,
3476
+ index,
3477
+ fileName: source.fileName,
3478
+ name: source.fileName
3479
+ }
3480
+ }) : explicitKey ?? fallbackName;
3481
+ return resolveStoragePath(key, input, options, config);
3482
+ }
3483
+ function normalizeUploadSources(input) {
3484
+ const files = toArray(input.files);
3485
+ if (files.length === 0) {
3486
+ throw new Error("athena.storage.file.upload requires at least one file");
3487
+ }
3488
+ return files.map((source, index) => {
3489
+ const fileName = input.fileName ?? sourceName(source) ?? `file-${index + 1}`;
3490
+ const sizeBytes = sourceSize(source);
3491
+ const contentType = input.content_type ?? input.mime_type ?? sourceContentType(source);
3492
+ return {
3493
+ source,
3494
+ fileName,
3495
+ sizeBytes,
3496
+ contentType
3497
+ };
3498
+ });
3499
+ }
3500
+ function validateUploadConstraints(sources, input) {
3501
+ const maxFiles = input.maxFiles ?? 1;
3502
+ if (sources.length > maxFiles) {
3503
+ throw new Error(`athena.storage.file.upload accepts at most ${maxFiles} file${maxFiles === 1 ? "" : "s"} for this call`);
3504
+ }
3505
+ const maxFileSizeBytes = input.maxFileSizeBytes ?? (input.maxFileSizeMb === void 0 ? void 0 : Math.floor(input.maxFileSizeMb * 1024 * 1024));
3506
+ if (maxFileSizeBytes !== void 0) {
3507
+ const tooLarge = sources.find((source) => source.sizeBytes > maxFileSizeBytes);
3508
+ if (tooLarge) {
3509
+ throw new Error(`athena.storage.file.upload rejected ${tooLarge.fileName}: file exceeds ${maxFileSizeBytes} bytes`);
3510
+ }
3511
+ }
3512
+ const allowedExtensions = normalizeExtensions(input.allowedExtensions ?? input.extensions);
3513
+ if (allowedExtensions.size > 0) {
3514
+ const invalid = sources.find((source) => !allowedExtensions.has(fileExtension(source.fileName)));
3515
+ if (invalid) {
3516
+ throw new Error(`athena.storage.file.upload rejected ${invalid.fileName}: extension is not allowed`);
3517
+ }
3518
+ }
3519
+ }
3520
+ async function putUploadBody(url, source, input, options, onProgress) {
3521
+ const headers = new Headers(input.uploadHeaders);
3522
+ if (source.contentType && !headers.has("Content-Type")) {
3523
+ headers.set("Content-Type", source.contentType);
3524
+ }
3525
+ if (typeof XMLHttpRequest !== "undefined") {
3526
+ return putUploadBodyWithXhr(url, source, headers, options, onProgress);
3527
+ }
3528
+ onProgress({ loaded: 0 });
3529
+ const response = await fetch(url, {
3530
+ method: "PUT",
3531
+ headers,
3532
+ body: source.source,
3533
+ signal: options?.signal
3534
+ });
3535
+ if (!response.ok) {
3536
+ throw new Error(`athena.storage.file.upload failed with status ${response.status}`);
3537
+ }
3538
+ onProgress({ loaded: source.sizeBytes });
3539
+ return response;
3540
+ }
3541
+ function putUploadBodyWithXhr(url, source, headers, options, onProgress) {
3542
+ const Xhr = XMLHttpRequest;
3543
+ if (Xhr === void 0) {
3544
+ return Promise.reject(new Error("athena.storage.file.upload requires XMLHttpRequest in this runtime"));
3545
+ }
3546
+ return new Promise((resolve3, reject) => {
3547
+ const xhr = new Xhr();
3548
+ const abort = () => xhr.abort();
3549
+ xhr.open("PUT", url);
3550
+ headers.forEach((value, key) => xhr.setRequestHeader(key, value));
3551
+ xhr.upload.onprogress = (event) => {
3552
+ onProgress({ loaded: event.loaded });
3553
+ };
3554
+ xhr.onload = () => {
3555
+ if (options?.signal) {
3556
+ options.signal.removeEventListener("abort", abort);
3557
+ }
3558
+ if (xhr.status < 200 || xhr.status >= 300) {
3559
+ reject(new Error(`athena.storage.file.upload failed with status ${xhr.status}`));
3560
+ return;
3561
+ }
3562
+ onProgress({ loaded: source.sizeBytes });
3563
+ resolve3(new Response(xhr.response, {
3564
+ status: xhr.status,
3565
+ statusText: xhr.statusText,
3566
+ headers: parseXhrHeaders(xhr.getAllResponseHeaders())
3567
+ }));
3568
+ };
3569
+ xhr.onerror = () => {
3570
+ if (options?.signal) {
3571
+ options.signal.removeEventListener("abort", abort);
3572
+ }
3573
+ reject(new Error("athena.storage.file.upload failed with a network error"));
3574
+ };
3575
+ xhr.onabort = () => {
3576
+ if (options?.signal) {
3577
+ options.signal.removeEventListener("abort", abort);
3578
+ }
3579
+ reject(new DOMException("Upload aborted", "AbortError"));
3580
+ };
3581
+ if (options?.signal) {
3582
+ if (options.signal.aborted) {
3583
+ abort();
3584
+ return;
3585
+ }
3586
+ options.signal.addEventListener("abort", abort, { once: true });
3587
+ }
3588
+ xhr.send(source.source);
3589
+ });
3590
+ }
3591
+ function normalizeDownloadArgs(input, queryOrOptions, maybeOptions) {
3592
+ if (typeof input === "string") {
3593
+ return { fileIds: [input], query: queryOrOptions, options: maybeOptions };
3594
+ }
3595
+ if (Array.isArray(input)) {
3596
+ return { fileIds: [...input], query: queryOrOptions, options: maybeOptions };
3597
+ }
3598
+ const downloadInput = input;
3599
+ const { fileId, fileIds, ...query } = downloadInput;
3600
+ return {
3601
+ fileIds: fileIds ? [...fileIds] : fileId ? [fileId] : [],
3602
+ query,
3603
+ options: queryOrOptions
3604
+ };
3605
+ }
3606
+ function createPathContext(input, options, config) {
3607
+ const organizationId = input.organizationId ?? input.organization_id ?? options?.organizationId ?? void 0;
3608
+ const userId = input.userId ?? input.user_id ?? options?.userId ?? void 0;
3609
+ const resourceId = input.resourceId ?? input.resource_id ?? void 0;
3610
+ const vars = {
3611
+ ...config.vars ?? {},
3612
+ ...input.vars ?? {}
3613
+ };
3614
+ if (organizationId !== void 0) {
3615
+ vars.organizationId = organizationId;
3616
+ vars.organization_id = organizationId;
3617
+ }
3618
+ if (userId !== void 0) {
3619
+ vars.userId = userId;
3620
+ vars.user_id = userId;
3621
+ }
3622
+ if (resourceId !== void 0) {
3623
+ vars.resourceId = resourceId;
3624
+ vars.resource_id = resourceId;
3625
+ }
3626
+ return {
3627
+ vars,
3628
+ env: {
3629
+ ...readProcessEnv(),
3630
+ ...config.env ?? {},
3631
+ ...input.env ?? {}
3632
+ },
3633
+ organizationId,
3634
+ organization_id: organizationId,
3635
+ userId,
3636
+ user_id: userId,
3637
+ resourceId,
3638
+ resource_id: resourceId
3639
+ };
3640
+ }
3641
+ function renderStorageTemplate(template, context) {
3642
+ return template.replace(/\$\{([^}]+)\}|\{([^}]+)\}/g, (_match, shellToken, braceToken) => {
3643
+ const token = (shellToken ?? braceToken ?? "").trim();
3644
+ if (!token) return "";
3645
+ const value = resolveTemplateToken(token, context);
3646
+ return value === void 0 || value === null ? "" : String(value);
3647
+ });
3648
+ }
3649
+ function resolveTemplateToken(token, context) {
3650
+ if (token.startsWith("env.")) {
3651
+ return context.env[token.slice(4)];
3652
+ }
3653
+ if (token in context.vars) {
3654
+ return context.vars[token];
3655
+ }
3656
+ return context.env[token];
3657
+ }
3658
+ function joinStoragePath(...parts) {
3659
+ return parts.map((part) => part.trim().replace(/^\/+|\/+$/g, "")).filter(Boolean).join("/");
3660
+ }
3661
+ function toArray(files) {
3662
+ if (isUploadSource(files)) return [files];
3663
+ return Array.from(files);
3664
+ }
3665
+ function isUploadSource(value) {
3666
+ return value instanceof Blob || value instanceof ArrayBuffer || value instanceof Uint8Array;
3667
+ }
3668
+ function sourceName(source) {
3669
+ return isRecord5(source) && typeof source.name === "string" && source.name.trim() ? source.name.trim() : void 0;
3670
+ }
3671
+ function sourceSize(source) {
3672
+ if (source instanceof Blob) return source.size;
3673
+ return source.byteLength;
3674
+ }
3675
+ function sourceContentType(source) {
3676
+ return source instanceof Blob && source.type.trim() ? source.type.trim() : void 0;
3677
+ }
3678
+ function normalizeExtensions(extensions) {
3679
+ return new Set((extensions ?? []).map((extension) => extension.replace(/^\./, "").toLowerCase()).filter(Boolean));
3680
+ }
3681
+ function fileExtension(fileName) {
3682
+ const lastDot = fileName.lastIndexOf(".");
3683
+ return lastDot === -1 ? "" : fileName.slice(lastDot + 1).toLowerCase();
3684
+ }
3685
+ function createProgressSnapshot(phase, sources, fileIndex, loaded, aggregateLoaded) {
3686
+ const total = sources[fileIndex]?.sizeBytes ?? 0;
3687
+ const aggregateTotal = sources.reduce((totalBytes, source) => totalBytes + source.sizeBytes, 0);
3688
+ return {
3689
+ phase,
3690
+ fileIndex,
3691
+ fileCount: sources.length,
3692
+ fileName: sources[fileIndex]?.fileName ?? "",
3693
+ loaded,
3694
+ total,
3695
+ percent: total > 0 ? Math.round(loaded / total * 100) : 100,
3696
+ aggregateLoaded,
3697
+ aggregateTotal,
3698
+ aggregatePercent: aggregateTotal > 0 ? Math.round(aggregateLoaded / aggregateTotal * 100) : 100
3699
+ };
3700
+ }
3701
+ function sum(values) {
3702
+ return values.reduce((total, value) => total + value, 0);
3703
+ }
3704
+ function parseXhrHeaders(raw) {
3705
+ const headers = new Headers();
3706
+ for (const line of raw.trim().split(/[\r\n]+/)) {
3707
+ const index = line.indexOf(":");
3708
+ if (index === -1) continue;
3709
+ headers.set(line.slice(0, index).trim(), line.slice(index + 1).trim());
3710
+ }
3711
+ return headers;
3712
+ }
3713
+ function readProcessEnv() {
3714
+ const processLike = globalThis.process;
3715
+ return processLike?.env ?? {};
3716
+ }
3717
+ function isRecord5(value) {
3718
+ return Boolean(value) && typeof value === "object";
3719
+ }
3720
+
3376
3721
  // src/storage/module.ts
3377
3722
  var storageSdkManifest = {
3378
3723
  namespace: "storage",
@@ -3581,7 +3926,7 @@ var AthenaStorageError = class extends Error {
3581
3926
  };
3582
3927
  }
3583
3928
  };
3584
- function isRecord5(value) {
3929
+ function isRecord6(value) {
3585
3930
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
3586
3931
  }
3587
3932
  function causeToString(cause) {
@@ -3696,7 +4041,7 @@ function withPathParam(path, name, value) {
3696
4041
  return path.replace(`{${name}}`, encodeURIComponent(value));
3697
4042
  }
3698
4043
  function resolveErrorMessage3(payload, fallback) {
3699
- if (isRecord5(payload)) {
4044
+ if (isRecord6(payload)) {
3700
4045
  const message = payload.message ?? payload.error ?? payload.details;
3701
4046
  if (typeof message === "string" && message.trim()) {
3702
4047
  return message.trim();
@@ -3708,12 +4053,12 @@ function resolveErrorMessage3(payload, fallback) {
3708
4053
  return fallback;
3709
4054
  }
3710
4055
  function resolveErrorHint2(payload) {
3711
- if (!isRecord5(payload)) return void 0;
4056
+ if (!isRecord6(payload)) return void 0;
3712
4057
  const hint = payload.hint ?? payload.suggestion;
3713
4058
  return typeof hint === "string" && hint.trim() ? hint.trim() : void 0;
3714
4059
  }
3715
4060
  function resolveErrorCause(payload) {
3716
- if (!isRecord5(payload)) return void 0;
4061
+ if (!isRecord6(payload)) return void 0;
3717
4062
  const cause = payload.cause ?? payload.reason;
3718
4063
  return typeof cause === "string" && cause.trim() ? cause.trim() : void 0;
3719
4064
  }
@@ -3832,7 +4177,7 @@ async function callStorageEndpoint(gateway, endpoint, method, envelope, payload,
3832
4177
  );
3833
4178
  }
3834
4179
  if (envelope === "athena") {
3835
- if (!isRecord5(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
4180
+ if (!isRecord6(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
3836
4181
  return rejectStorageError(
3837
4182
  {
3838
4183
  code: "INVALID_ATHENA_ENVELOPE",
@@ -3940,81 +4285,260 @@ async function callStorageBinaryEndpoint(gateway, endpoint, method, options, run
3940
4285
  runtimeOptions
3941
4286
  );
3942
4287
  }
3943
- function createStorageModule(gateway, runtimeOptions) {
4288
+ function isBlobBody(body) {
4289
+ return typeof Blob !== "undefined" && body instanceof Blob;
4290
+ }
4291
+ function isReadableStreamBody(body) {
4292
+ return typeof ReadableStream !== "undefined" && body instanceof ReadableStream;
4293
+ }
4294
+ async function putPresignedUploadBody(uploadUrl, uploadHeaders, body, options) {
4295
+ const headers = new Headers(uploadHeaders);
4296
+ Object.entries(options?.headers ?? {}).forEach(([key, value]) => headers.set(key, value));
4297
+ if (!headers.has("Content-Type") && isBlobBody(body) && body.type) {
4298
+ headers.set("Content-Type", body.type);
4299
+ }
4300
+ const init = {
4301
+ method: "PUT",
4302
+ headers,
4303
+ body,
4304
+ signal: options?.signal
4305
+ };
4306
+ if (isReadableStreamBody(body)) {
4307
+ init.duplex = "half";
4308
+ }
4309
+ return fetch(uploadUrl, init);
4310
+ }
4311
+ function attachManagedUpload(upload) {
4312
+ const headers = {};
3944
4313
  return {
4314
+ ...upload,
4315
+ method: "PUT",
4316
+ headers,
4317
+ expiresAt: upload.expires_at,
4318
+ put(body, options) {
4319
+ return putPresignedUploadBody(upload.url, headers, body, options);
4320
+ }
4321
+ };
4322
+ }
4323
+ function attachUploadHelper(response) {
4324
+ return {
4325
+ ...response,
4326
+ upload: attachManagedUpload(response.upload)
4327
+ };
4328
+ }
4329
+ function attachUploadHelpers(response) {
4330
+ return {
4331
+ files: response.files.map(attachUploadHelper)
4332
+ };
4333
+ }
4334
+ function normalizeUploadUrlRequest(input) {
4335
+ const s3_id = input.s3_id ?? input.s3Id;
4336
+ const storage_key = input.storage_key ?? input.storageKey;
4337
+ if (!s3_id?.trim()) {
4338
+ throw new Error("athena.storage.file.upload requires s3_id or s3Id");
4339
+ }
4340
+ if (!storage_key?.trim()) {
4341
+ throw new Error("athena.storage.file.upload requires storage_key or storageKey");
4342
+ }
4343
+ const fileName = input.fileName?.trim();
4344
+ const originalName = input.originalName?.trim();
4345
+ return {
4346
+ s3_id,
4347
+ bucket: input.bucket,
4348
+ storage_key,
4349
+ name: input.name ?? fileName,
4350
+ original_name: input.original_name ?? originalName ?? fileName,
4351
+ resource_id: input.resource_id ?? input.resourceId,
4352
+ mime_type: input.mime_type ?? input.mimeType,
4353
+ content_type: input.content_type ?? input.contentType,
4354
+ size_bytes: input.size_bytes ?? input.sizeBytes,
4355
+ file_id: input.file_id ?? input.fileId,
4356
+ public: input.public,
4357
+ visibility: input.visibility,
4358
+ metadata: input.metadata
4359
+ };
4360
+ }
4361
+ async function callStorageUploadBinaryEndpoint(gateway, endpoint, body, options, runtimeOptions) {
4362
+ let url;
4363
+ let headers;
4364
+ try {
4365
+ const baseUrl = options?.baseUrl ? normalizeAthenaGatewayBaseUrl(options.baseUrl) : gateway.baseUrl;
4366
+ url = buildAthenaGatewayUrl(baseUrl, endpoint);
4367
+ headers = gateway.buildHeaders(options);
4368
+ } catch (error) {
4369
+ return rejectStorageError(
4370
+ {
4371
+ code: storageCodeFromUnknown(error),
4372
+ message: error instanceof Error ? error.message : `Athena storage PUT ${endpoint} failed before sending the request`,
4373
+ status: isAthenaGatewayError(error) ? error.status : 0,
4374
+ endpoint,
4375
+ method: "PUT",
4376
+ raw: error,
4377
+ requestId: isAthenaGatewayError(error) ? error.requestId : void 0,
4378
+ hint: isAthenaGatewayError(error) ? error.hint : void 0,
4379
+ cause: error
4380
+ },
4381
+ options,
4382
+ runtimeOptions
4383
+ );
4384
+ }
4385
+ delete headers["Content-Type"];
4386
+ delete headers["content-type"];
4387
+ if (isBlobBody(body) && body.type) {
4388
+ headers["Content-Type"] = body.type;
4389
+ }
4390
+ const requestInit = {
4391
+ method: "PUT",
4392
+ headers,
4393
+ body,
4394
+ signal: options?.signal
4395
+ };
4396
+ if (isReadableStreamBody(body)) {
4397
+ requestInit.duplex = "half";
4398
+ }
4399
+ let response;
4400
+ try {
4401
+ response = await fetch(url, requestInit);
4402
+ } catch (error) {
4403
+ const message = error instanceof Error ? error.message : String(error);
4404
+ return rejectStorageError(
4405
+ {
4406
+ code: "NETWORK_ERROR",
4407
+ message: `Network error while calling Athena storage PUT ${endpoint}: ${message}`,
4408
+ status: 0,
4409
+ endpoint,
4410
+ method: "PUT",
4411
+ cause: error
4412
+ },
4413
+ options,
4414
+ runtimeOptions
4415
+ );
4416
+ }
4417
+ let rawText;
4418
+ try {
4419
+ rawText = await response.text();
4420
+ } catch (error) {
4421
+ return rejectStorageError(
4422
+ {
4423
+ code: "NETWORK_ERROR",
4424
+ message: `Athena storage PUT ${endpoint} response body could not be read`,
4425
+ status: response.status,
4426
+ endpoint,
4427
+ method: "PUT",
4428
+ requestId: headerValue(response.headers, ["x-athena-request-id", "x-request-id", "request-id"]),
4429
+ cause: error
4430
+ },
4431
+ options,
4432
+ runtimeOptions
4433
+ );
4434
+ }
4435
+ const parsedBody = parseResponseBody3(rawText ?? "", response.headers.get("content-type"));
4436
+ const requestId = headerValue(response.headers, ["x-athena-request-id", "x-request-id", "request-id"]);
4437
+ if (parsedBody.parseFailed) {
4438
+ return rejectStorageError(
4439
+ {
4440
+ code: "INVALID_JSON",
4441
+ message: `Athena storage PUT ${endpoint} returned malformed JSON`,
4442
+ status: response.status,
4443
+ endpoint,
4444
+ method: "PUT",
4445
+ requestId,
4446
+ raw: parsedBody.parsed
4447
+ },
4448
+ options,
4449
+ runtimeOptions
4450
+ );
4451
+ }
4452
+ if (!response.ok) {
4453
+ return rejectStorageError(
4454
+ {
4455
+ code: "HTTP_ERROR",
4456
+ message: resolveErrorMessage3(
4457
+ parsedBody.parsed,
4458
+ `Athena storage PUT ${endpoint} failed with status ${response.status}`
4459
+ ),
4460
+ status: response.status,
4461
+ endpoint,
4462
+ method: "PUT",
4463
+ requestId,
4464
+ hint: resolveErrorHint2(parsedBody.parsed),
4465
+ cause: resolveErrorCause(parsedBody.parsed),
4466
+ raw: parsedBody.parsed
4467
+ },
4468
+ options,
4469
+ runtimeOptions
4470
+ );
4471
+ }
4472
+ if (!isRecord6(parsedBody.parsed) || !("data" in parsedBody.parsed)) {
4473
+ return rejectStorageError(
4474
+ {
4475
+ code: "INVALID_ATHENA_ENVELOPE",
4476
+ message: `Athena storage PUT ${endpoint} returned an invalid Athena envelope`,
4477
+ status: response.status,
4478
+ endpoint,
4479
+ method: "PUT",
4480
+ requestId,
4481
+ raw: parsedBody.parsed
4482
+ },
4483
+ options,
4484
+ runtimeOptions
4485
+ );
4486
+ }
4487
+ return parsedBody.parsed.data;
4488
+ }
4489
+ function createStorageModule(gateway, runtimeOptions) {
4490
+ const callRaw = (path, method, payload, options) => callStorageEndpoint(
4491
+ gateway,
4492
+ storagePath(path),
4493
+ method,
4494
+ "raw",
4495
+ payload,
4496
+ options,
4497
+ runtimeOptions
4498
+ );
4499
+ const callAthena2 = (path, method, payload, options) => callStorageEndpoint(
4500
+ gateway,
4501
+ storagePath(path),
4502
+ method,
4503
+ "athena",
4504
+ payload,
4505
+ options,
4506
+ runtimeOptions
4507
+ );
4508
+ const base = {
3945
4509
  listStorageCatalogs(options) {
3946
- return callStorageEndpoint(gateway, storagePath("/storage/catalogs"), "GET", "raw", void 0, options, runtimeOptions);
4510
+ return callRaw("/storage/catalogs", "GET", void 0, options);
3947
4511
  },
3948
4512
  createStorageCatalog(input, options) {
3949
- return callStorageEndpoint(gateway, storagePath("/storage/catalogs"), "POST", "raw", input, options, runtimeOptions);
4513
+ return callRaw("/storage/catalogs", "POST", input, options);
3950
4514
  },
3951
4515
  updateStorageCatalog(id, input, options) {
3952
- return callStorageEndpoint(
3953
- gateway,
3954
- storagePath(withPathParam("/storage/catalogs/{id}", "id", id)),
3955
- "PATCH",
3956
- "raw",
3957
- input,
3958
- options,
3959
- runtimeOptions
3960
- );
4516
+ return callRaw(withPathParam("/storage/catalogs/{id}", "id", id), "PATCH", input, options);
3961
4517
  },
3962
4518
  deleteStorageCatalog(id, options) {
3963
- return callStorageEndpoint(
3964
- gateway,
3965
- storagePath(withPathParam("/storage/catalogs/{id}", "id", id)),
3966
- "DELETE",
3967
- "raw",
3968
- void 0,
3969
- options,
3970
- runtimeOptions
3971
- );
4519
+ return callRaw(withPathParam("/storage/catalogs/{id}", "id", id), "DELETE", void 0, options);
3972
4520
  },
3973
4521
  listStorageCredentials(options) {
3974
- return callStorageEndpoint(gateway, storagePath("/storage/credentials"), "GET", "raw", void 0, options, runtimeOptions);
4522
+ return callRaw("/storage/credentials", "GET", void 0, options);
3975
4523
  },
3976
4524
  createStorageUploadUrl(input, options) {
3977
- return callStorageEndpoint(
3978
- gateway,
3979
- storagePath("/storage/files/upload-url"),
3980
- "POST",
3981
- "athena",
3982
- input,
3983
- options,
3984
- runtimeOptions
3985
- );
4525
+ return callAthena2("/storage/files/upload-url", "POST", input, options);
3986
4526
  },
3987
4527
  createStorageUploadUrls(input, options) {
3988
- return callStorageEndpoint(
3989
- gateway,
3990
- storagePath("/storage/files/upload-urls"),
3991
- "POST",
3992
- "athena",
3993
- input,
3994
- options,
3995
- runtimeOptions
3996
- );
4528
+ return callAthena2("/storage/files/upload-urls", "POST", input, options);
3997
4529
  },
3998
4530
  listStorageFiles(input, options) {
3999
- return callStorageEndpoint(gateway, storagePath("/storage/files/list"), "POST", "athena", input, options, runtimeOptions);
4531
+ return callAthena2("/storage/files/list", "POST", input, options);
4000
4532
  },
4001
4533
  getStorageFile(fileId, options) {
4002
- return callStorageEndpoint(
4003
- gateway,
4004
- storagePath(withPathParam("/storage/files/{file_id}", "file_id", fileId)),
4005
- "GET",
4006
- "athena",
4007
- void 0,
4008
- options,
4009
- runtimeOptions
4010
- );
4534
+ return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "GET", void 0, options);
4011
4535
  },
4012
4536
  getStorageFileUrl(fileId, query, options) {
4013
4537
  const path = appendQuery(
4014
4538
  withPathParam("/storage/files/{file_id}/url", "file_id", fileId),
4015
4539
  query
4016
4540
  );
4017
- return callStorageEndpoint(gateway, storagePath(path), "GET", "athena", void 0, options, runtimeOptions);
4541
+ return callAthena2(path, "GET", void 0, options);
4018
4542
  },
4019
4543
  getStorageFileProxy(fileId, query, options) {
4020
4544
  const path = appendQuery(
@@ -4024,45 +4548,244 @@ function createStorageModule(gateway, runtimeOptions) {
4024
4548
  return callStorageBinaryEndpoint(gateway, storagePath(path), "GET", options, runtimeOptions);
4025
4549
  },
4026
4550
  updateStorageFile(fileId, input, options) {
4027
- return callStorageEndpoint(
4028
- gateway,
4029
- storagePath(withPathParam("/storage/files/{file_id}", "file_id", fileId)),
4030
- "PATCH",
4031
- "athena",
4032
- input,
4033
- options,
4034
- runtimeOptions
4035
- );
4551
+ return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "PATCH", input, options);
4036
4552
  },
4037
4553
  deleteStorageFile(fileId, options) {
4038
- return callStorageEndpoint(
4039
- gateway,
4040
- storagePath(withPathParam("/storage/files/{file_id}", "file_id", fileId)),
4041
- "DELETE",
4042
- "athena",
4043
- void 0,
4044
- options,
4045
- runtimeOptions
4046
- );
4554
+ return callAthena2(withPathParam("/storage/files/{file_id}", "file_id", fileId), "DELETE", void 0, options);
4047
4555
  },
4048
4556
  setStorageFileVisibility(fileId, input, options) {
4049
- return callStorageEndpoint(
4557
+ return callAthena2(withPathParam("/storage/files/{file_id}/visibility", "file_id", fileId), "PATCH", input, options);
4558
+ },
4559
+ deleteStorageFolder(input, options) {
4560
+ return callAthena2("/storage/folders/delete", "POST", input, options);
4561
+ },
4562
+ moveStorageFolder(input, options) {
4563
+ return callAthena2("/storage/folders/move", "POST", input, options);
4564
+ }
4565
+ };
4566
+ const fileFacade = createStorageFileModule(base, runtimeOptions);
4567
+ const fileUpload = ((input, options) => {
4568
+ if (isRecord6(input) && "files" in input) {
4569
+ return fileFacade.upload(input, options);
4570
+ }
4571
+ return base.createStorageUploadUrl(
4572
+ normalizeUploadUrlRequest(input),
4573
+ options
4574
+ ).then(attachUploadHelper);
4575
+ });
4576
+ const fileDelete = ((input, options) => fileFacade.delete(input, options));
4577
+ const file = {
4578
+ ...fileFacade,
4579
+ upload: fileUpload,
4580
+ uploadMany(input, options) {
4581
+ return base.createStorageUploadUrls(
4582
+ { files: input.files.map(normalizeUploadUrlRequest) },
4583
+ options
4584
+ ).then(attachUploadHelpers);
4585
+ },
4586
+ confirmUpload(fileId, input, options) {
4587
+ return callAthena2(withPathParam("/storage/files/{file_id}/confirm-upload", "file_id", fileId), "POST", input ?? {}, options);
4588
+ },
4589
+ uploadBinary(fileId, body, options) {
4590
+ return callStorageUploadBinaryEndpoint(
4050
4591
  gateway,
4051
- storagePath(withPathParam("/storage/files/{file_id}/visibility", "file_id", fileId)),
4052
- "PATCH",
4053
- "athena",
4054
- input,
4592
+ storagePath(withPathParam("/storage/files/{file_id}/upload", "file_id", fileId)),
4593
+ body,
4055
4594
  options,
4056
4595
  runtimeOptions
4057
4596
  );
4058
4597
  },
4059
- deleteStorageFolder(input, options) {
4060
- return callStorageEndpoint(gateway, storagePath("/storage/folders/delete"), "POST", "athena", input, options, runtimeOptions);
4598
+ search(input, options) {
4599
+ return callAthena2("/storage/files/search", "POST", input, options);
4061
4600
  },
4062
- moveStorageFolder(input, options) {
4063
- return callStorageEndpoint(gateway, storagePath("/storage/folders/move"), "POST", "athena", input, options, runtimeOptions);
4601
+ get(fileId, options) {
4602
+ return base.getStorageFile(fileId, options);
4603
+ },
4604
+ update(fileId, input, options) {
4605
+ return base.updateStorageFile(fileId, input, options);
4606
+ },
4607
+ delete: fileDelete,
4608
+ deleteMany(input, options) {
4609
+ return callAthena2("/storage/files/delete-many", "POST", input, options);
4610
+ },
4611
+ updateMany(input, options) {
4612
+ return callAthena2("/storage/files/update-many", "POST", input, options);
4613
+ },
4614
+ restore(fileId, options) {
4615
+ return callAthena2(withPathParam("/storage/files/{file_id}/restore", "file_id", fileId), "POST", {}, options);
4616
+ },
4617
+ purge(fileId, options) {
4618
+ return callAthena2(withPathParam("/storage/files/{file_id}/purge", "file_id", fileId), "DELETE", void 0, options);
4619
+ },
4620
+ copy(fileId, input, options) {
4621
+ return callAthena2(withPathParam("/storage/files/{file_id}/copy", "file_id", fileId), "POST", input, options);
4622
+ },
4623
+ url(fileId, query, options) {
4624
+ return base.getStorageFileUrl(fileId, query, options);
4625
+ },
4626
+ publicUrl(fileId, options) {
4627
+ return callAthena2(withPathParam("/storage/files/{file_id}/public-url", "file_id", fileId), "GET", void 0, options);
4628
+ },
4629
+ proxy(fileId, query, options) {
4630
+ return base.getStorageFileProxy(fileId, query, options);
4631
+ },
4632
+ visibility: {
4633
+ set(fileId, input, options) {
4634
+ return base.setStorageFileVisibility(fileId, input, options);
4635
+ },
4636
+ setMany(input, options) {
4637
+ return callAthena2("/storage/files/visibility-many", "POST", input, options);
4638
+ }
4639
+ }
4640
+ };
4641
+ const credentials = {
4642
+ list(options) {
4643
+ return base.listStorageCredentials(options);
4644
+ }
4645
+ };
4646
+ const catalog = {
4647
+ list(options) {
4648
+ return base.listStorageCatalogs(options);
4649
+ },
4650
+ create(input, options) {
4651
+ return base.createStorageCatalog(input, options);
4652
+ },
4653
+ update(id, input, options) {
4654
+ return base.updateStorageCatalog(id, input, options);
4655
+ },
4656
+ delete(id, options) {
4657
+ return base.deleteStorageCatalog(id, options);
4658
+ }
4659
+ };
4660
+ const folder = {
4661
+ list(input, options) {
4662
+ return callAthena2("/storage/folders/list", "POST", input, options);
4663
+ },
4664
+ tree(input, options) {
4665
+ return callAthena2("/storage/folders/tree", "POST", input, options);
4666
+ },
4667
+ delete(input, options) {
4668
+ return base.deleteStorageFolder(input, options);
4669
+ },
4670
+ move(input, options) {
4671
+ return base.moveStorageFolder(input, options);
4672
+ }
4673
+ };
4674
+ const permission = {
4675
+ list(input, options) {
4676
+ return callAthena2("/storage/permissions/list", "POST", input, options);
4677
+ },
4678
+ grant(input, options) {
4679
+ return callAthena2("/storage/permissions/grant", "POST", input, options);
4680
+ },
4681
+ revoke(input, options) {
4682
+ return callAthena2("/storage/permissions/revoke", "POST", input, options);
4683
+ },
4684
+ check(input, options) {
4685
+ return callAthena2("/storage/permissions/check", "POST", input, options);
4064
4686
  }
4065
4687
  };
4688
+ const objectFolder = {
4689
+ create(input, options) {
4690
+ return callAthena2("/storage/objects/folder", "POST", input, options);
4691
+ },
4692
+ delete(input, options) {
4693
+ return callAthena2("/storage/objects/folder/delete", "POST", input, options);
4694
+ },
4695
+ rename(input, options) {
4696
+ return callAthena2("/storage/objects/folder/rename", "POST", input, options);
4697
+ }
4698
+ };
4699
+ const object = {
4700
+ list(input, options) {
4701
+ return callAthena2("/storage/objects", "POST", input, options);
4702
+ },
4703
+ head(input, options) {
4704
+ return callAthena2("/storage/objects/head", "POST", input, options);
4705
+ },
4706
+ exists(input, options) {
4707
+ return callAthena2("/storage/objects/exists", "POST", input, options);
4708
+ },
4709
+ validate(input, options) {
4710
+ return callAthena2("/storage/objects/validate", "POST", input, options);
4711
+ },
4712
+ update(input, options) {
4713
+ return callAthena2("/storage/objects/update", "POST", input, options);
4714
+ },
4715
+ copy(input, options) {
4716
+ return callAthena2("/storage/objects/copy", "POST", input, options);
4717
+ },
4718
+ url(input, options) {
4719
+ return callAthena2("/storage/objects/url", "POST", input, options);
4720
+ },
4721
+ publicUrl(input, options) {
4722
+ return callAthena2("/storage/objects/public-url", "POST", input, options);
4723
+ },
4724
+ delete(input, options) {
4725
+ return callAthena2("/storage/objects/delete", "POST", input, options);
4726
+ },
4727
+ uploadUrl(input, options) {
4728
+ return callAthena2("/storage/objects/upload-url", "POST", input, options);
4729
+ },
4730
+ folder: objectFolder
4731
+ };
4732
+ const bucket = {
4733
+ list(input, options) {
4734
+ return callAthena2("/storage/buckets/list", "POST", input, options);
4735
+ },
4736
+ create(input, options) {
4737
+ return callAthena2("/storage/buckets/create", "POST", input, options);
4738
+ },
4739
+ delete(input, options) {
4740
+ return callAthena2("/storage/buckets/delete", "POST", input, options);
4741
+ },
4742
+ cors: {
4743
+ get(input, options) {
4744
+ return callAthena2("/storage/buckets/cors", "POST", input, options);
4745
+ },
4746
+ set(input, options) {
4747
+ return callAthena2("/storage/buckets/cors/set", "POST", input, options);
4748
+ },
4749
+ delete(input, options) {
4750
+ return callAthena2("/storage/buckets/cors/delete", "POST", input, options);
4751
+ }
4752
+ }
4753
+ };
4754
+ const multipart = {
4755
+ create(input, options) {
4756
+ return callAthena2("/storage/multipart/create", "POST", input, options);
4757
+ },
4758
+ signPart(input, options) {
4759
+ return callAthena2("/storage/multipart/sign-part", "POST", input, options);
4760
+ },
4761
+ complete(input, options) {
4762
+ return callAthena2("/storage/multipart/complete", "POST", input, options);
4763
+ },
4764
+ abort(input, options) {
4765
+ return callAthena2("/storage/multipart/abort", "POST", input, options);
4766
+ },
4767
+ listParts(input, options) {
4768
+ return callAthena2("/storage/multipart/list-parts", "POST", input, options);
4769
+ }
4770
+ };
4771
+ const audit = {
4772
+ list(input, options) {
4773
+ return callAthena2("/storage/audit/list", "POST", input, options);
4774
+ }
4775
+ };
4776
+ return {
4777
+ ...base,
4778
+ credentials,
4779
+ catalog,
4780
+ file,
4781
+ folder,
4782
+ permission,
4783
+ object,
4784
+ bucket,
4785
+ multipart,
4786
+ audit,
4787
+ delete: file.delete
4788
+ };
4066
4789
  }
4067
4790
 
4068
4791
  // src/query-ast.ts
@@ -4092,7 +4815,7 @@ var BOOLEAN_SAFE_OPERATORS = /* @__PURE__ */ new Set([
4092
4815
  "ilike",
4093
4816
  "is"
4094
4817
  ]);
4095
- function isRecord6(value) {
4818
+ function isRecord7(value) {
4096
4819
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4097
4820
  }
4098
4821
  function isUuidString(value) {
@@ -4105,7 +4828,7 @@ function shouldUseUuidTextComparison(column, value) {
4105
4828
  return typeof value === "string" && isUuidString(value) && isUuidIdentifierColumn(column);
4106
4829
  }
4107
4830
  function isRelationSelectNode(value) {
4108
- return isRecord6(value) && isRecord6(value.select);
4831
+ return isRecord7(value) && isRecord7(value.select);
4109
4832
  }
4110
4833
  function normalizeIdentifier(value, label) {
4111
4834
  const normalized = value.trim();
@@ -4161,7 +4884,7 @@ function compileRelationToken(key, node) {
4161
4884
  return `${prefix}${relationToken}(${nested})`;
4162
4885
  }
4163
4886
  function compileSelectShape(select) {
4164
- if (!isRecord6(select)) {
4887
+ if (!isRecord7(select)) {
4165
4888
  throw new Error("findMany select must be an object");
4166
4889
  }
4167
4890
  const tokens = [];
@@ -4185,7 +4908,7 @@ function compileSelectShape(select) {
4185
4908
  return tokens.join(",");
4186
4909
  }
4187
4910
  function selectShapeUsesRelationSchema(select) {
4188
- if (!isRecord6(select)) {
4911
+ if (!isRecord7(select)) {
4189
4912
  return false;
4190
4913
  }
4191
4914
  for (const rawValue of Object.values(select)) {
@@ -4203,7 +4926,7 @@ function selectShapeUsesRelationSchema(select) {
4203
4926
  }
4204
4927
  function compileColumnWhere(column, input) {
4205
4928
  const normalizedColumn = normalizeIdentifier(column, "where column");
4206
- if (!isRecord6(input)) {
4929
+ if (!isRecord7(input)) {
4207
4930
  return [buildGatewayCondition("eq", normalizedColumn, input)];
4208
4931
  }
4209
4932
  const conditions = [];
@@ -4231,7 +4954,7 @@ function compileColumnWhere(column, input) {
4231
4954
  return conditions;
4232
4955
  }
4233
4956
  function compileBooleanExpressionTerms(clause, label) {
4234
- if (!isRecord6(clause)) {
4957
+ if (!isRecord7(clause)) {
4235
4958
  throw new Error(`findMany where.${label} clauses must be objects`);
4236
4959
  }
4237
4960
  const entries = Object.entries(clause).filter(([, value]) => value !== void 0);
@@ -4240,7 +4963,7 @@ function compileBooleanExpressionTerms(clause, label) {
4240
4963
  }
4241
4964
  const [rawColumn, rawValue] = entries[0];
4242
4965
  const column = normalizeIdentifier(rawColumn, `where.${label} column`);
4243
- if (!isRecord6(rawValue)) {
4966
+ if (!isRecord7(rawValue)) {
4244
4967
  return [`${column}.eq.${stringifyFilterValue(rawValue)}`];
4245
4968
  }
4246
4969
  const operatorEntries = Object.entries(rawValue).filter(([, value]) => value !== void 0);
@@ -4264,7 +4987,7 @@ function compileWhere(where) {
4264
4987
  if (where === void 0) {
4265
4988
  return void 0;
4266
4989
  }
4267
- if (!isRecord6(where)) {
4990
+ if (!isRecord7(where)) {
4268
4991
  throw new Error("findMany where must be an object");
4269
4992
  }
4270
4993
  const conditions = [];
@@ -4314,7 +5037,7 @@ function compileOrderBy(orderBy) {
4314
5037
  if (orderBy === void 0) {
4315
5038
  return void 0;
4316
5039
  }
4317
- if (!isRecord6(orderBy)) {
5040
+ if (!isRecord7(orderBy)) {
4318
5041
  throw new Error("findMany orderBy must be an object");
4319
5042
  }
4320
5043
  if ("column" in orderBy) {
@@ -4489,11 +5212,11 @@ function toFindManyAstOrder(order) {
4489
5212
  ascending: order.direction !== "descending"
4490
5213
  };
4491
5214
  }
4492
- function isRecord7(value) {
5215
+ function isRecord8(value) {
4493
5216
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4494
5217
  }
4495
5218
  function normalizeFindManyAstColumnPredicate(value) {
4496
- if (!isRecord7(value)) {
5219
+ if (!isRecord8(value)) {
4497
5220
  return {
4498
5221
  eq: value
4499
5222
  };
@@ -4517,7 +5240,7 @@ function normalizeFindManyAstBooleanOperand(clause) {
4517
5240
  return normalized;
4518
5241
  }
4519
5242
  function normalizeFindManyAstWhere(where) {
4520
- if (!where || !isRecord7(where)) {
5243
+ if (!where || !isRecord8(where)) {
4521
5244
  return where;
4522
5245
  }
4523
5246
  const normalized = {};
@@ -4531,7 +5254,7 @@ function normalizeFindManyAstWhere(where) {
4531
5254
  );
4532
5255
  continue;
4533
5256
  }
4534
- if (key === "not" && isRecord7(value)) {
5257
+ if (key === "not" && isRecord8(value)) {
4535
5258
  normalized.not = normalizeFindManyAstBooleanOperand(
4536
5259
  value
4537
5260
  );
@@ -4542,7 +5265,7 @@ function normalizeFindManyAstWhere(where) {
4542
5265
  return normalized;
4543
5266
  }
4544
5267
  function predicateRequiresUuidQueryFallback(column, value) {
4545
- if (!isRecord7(value)) {
5268
+ if (!isRecord8(value)) {
4546
5269
  return shouldUseUuidTextComparison(column, value);
4547
5270
  }
4548
5271
  const eqValue = value.eq;
@@ -4560,7 +5283,7 @@ function booleanOperandRequiresUuidQueryFallback(clause) {
4560
5283
  return false;
4561
5284
  }
4562
5285
  function findManyAstWhereRequiresLegacyTransport(where) {
4563
- if (!where || !isRecord7(where)) {
5286
+ if (!where || !isRecord8(where)) {
4564
5287
  return false;
4565
5288
  }
4566
5289
  for (const [key, value] of Object.entries(where)) {
@@ -4575,7 +5298,7 @@ function findManyAstWhereRequiresLegacyTransport(where) {
4575
5298
  }
4576
5299
  continue;
4577
5300
  }
4578
- if (key === "not" && isRecord7(value)) {
5301
+ if (key === "not" && isRecord8(value)) {
4579
5302
  if (booleanOperandRequiresUuidQueryFallback(value)) {
4580
5303
  return true;
4581
5304
  }
@@ -4777,7 +5500,7 @@ async function executeExperimentalRead(experimental, runner) {
4777
5500
  throw error;
4778
5501
  }
4779
5502
  }
4780
- function isRecord8(value) {
5503
+ function isRecord9(value) {
4781
5504
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
4782
5505
  }
4783
5506
  function firstNonEmptyString2(...values) {
@@ -4789,8 +5512,8 @@ function firstNonEmptyString2(...values) {
4789
5512
  return void 0;
4790
5513
  }
4791
5514
  function resolveStructuredErrorPayload2(raw) {
4792
- if (!isRecord8(raw)) return null;
4793
- return isRecord8(raw.error) ? raw.error : raw;
5515
+ if (!isRecord9(raw)) return null;
5516
+ return isRecord9(raw.error) ? raw.error : raw;
4794
5517
  }
4795
5518
  function resolveStructuredErrorDetails(payload, message) {
4796
5519
  if (!payload || !("details" in payload)) {
@@ -4806,7 +5529,7 @@ function resolveStructuredErrorDetails(payload, message) {
4806
5529
  return details;
4807
5530
  }
4808
5531
  function createResultError(response, result, normalized) {
4809
- const rawRecord = isRecord8(response.raw) ? response.raw : null;
5532
+ const rawRecord = isRecord9(response.raw) ? response.raw : null;
4810
5533
  const payload = resolveStructuredErrorPayload2(response.raw);
4811
5534
  const message = firstNonEmptyString2(
4812
5535
  response.error,
@@ -7009,7 +7732,7 @@ function resolveNullishValue(mode) {
7009
7732
  if (mode === "null") return null;
7010
7733
  return "";
7011
7734
  }
7012
- function isRecord9(value) {
7735
+ function isRecord10(value) {
7013
7736
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
7014
7737
  }
7015
7738
  function isNullableColumn(model, key) {
@@ -7018,7 +7741,7 @@ function isNullableColumn(model, key) {
7018
7741
  }
7019
7742
  function toModelFormDefaults(model, values, options) {
7020
7743
  const source = values;
7021
- if (!isRecord9(source)) {
7744
+ if (!isRecord10(source)) {
7022
7745
  return {};
7023
7746
  }
7024
7747
  const mode = options?.nullishMode ?? "empty-string";
@@ -8355,15 +9078,15 @@ function readCookieFromHeaders(headers, name) {
8355
9078
  }
8356
9079
  return parseCookies(cookieHeader).get(name);
8357
9080
  }
8358
- function isRecord10(value) {
9081
+ function isRecord11(value) {
8359
9082
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
8360
9083
  }
8361
9084
  function resolveSessionCandidate(value) {
8362
- if (!isRecord10(value)) {
9085
+ if (!isRecord11(value)) {
8363
9086
  return null;
8364
9087
  }
8365
- const session = isRecord10(value.session) ? value.session : void 0;
8366
- const user = isRecord10(value.user) ? value.user : void 0;
9088
+ const session = isRecord11(value.session) ? value.session : void 0;
9089
+ const user = isRecord11(value.user) ? value.user : void 0;
8367
9090
  if (session && typeof session.token === "string" && session.token.length > 0 && user) {
8368
9091
  return {
8369
9092
  session,
@@ -8373,7 +9096,7 @@ function resolveSessionCandidate(value) {
8373
9096
  return null;
8374
9097
  }
8375
9098
  function inferSessionPair(returned) {
8376
- return resolveSessionCandidate(returned) ?? (isRecord10(returned) ? resolveSessionCandidate(returned.data) : null) ?? (isRecord10(returned) ? resolveSessionCandidate(returned.session) : null);
9099
+ return resolveSessionCandidate(returned) ?? (isRecord11(returned) ? resolveSessionCandidate(returned.data) : null) ?? (isRecord11(returned) ? resolveSessionCandidate(returned.session) : null);
8377
9100
  }
8378
9101
  function resolveResponseHeaders(ctx) {
8379
9102
  if (ctx.context.responseHeaders instanceof Headers) {